fix(autorag): dynamically size topology nodes to fit long task labels#7208
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
📝 WalkthroughWalkthroughChanges add a test suite for the Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Actionable issuesCanvas context persistence and invalidation risk — The cached Font measurement mismatch — Missing null safety on 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/autorag/frontend/src/app/topology/utils.ts`:
- Around line 5-10: The function getCanvasContext repeatedly recreates a canvas
when getContext('2d') returns null because cachedCtx is initialized to null and
the guard uses !cachedCtx; change the caching logic so a null result is cached:
make cachedCtx start as undefined (type CanvasRenderingContext2D | null |
undefined) and change the condition in getCanvasContext to check cachedCtx ===
undefined so the first lookup stores either a context or null and subsequent
calls (e.g., from createNode) reuse that cached value.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 0713eea4-9823-499e-a2a1-206836e24045
📒 Files selected for processing (3)
packages/autorag/frontend/src/app/topology/__tests__/utils.spec.tspackages/autorag/frontend/src/app/topology/const.tspackages/autorag/frontend/src/app/topology/utils.ts
|
Thanks @jefho-rh AI assisted reviewOverall AssessmentApprove -- this is a clean, well-structured port of an already-merged pattern. The implementation is correct, the tests are thorough, and the fallback behavior is sound. A few non-blocking observations below. Suggestions
Test ValidationautoragFrontend ✅BFF ✅Contract ✅Manual validationNo obvious regressions
|
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: nickmazzi The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
93eb293
into
opendatahub-io:main
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7208 +/- ##
==========================================
+ Coverage 64.79% 64.81% +0.02%
==========================================
Files 2447 2441 -6
Lines 76059 76004 -55
Branches 19172 19159 -13
==========================================
- Hits 49279 49260 -19
+ Misses 26780 26744 -36 see 14 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|

https://redhat.atlassian.net/browse/RHOAIUX-2271
Description
Applies the same dynamic node sizing from #7189 (automl) to the autorag topology view. Uses canvas text measurement to compute node widths based on actual label text, preventing long task names from being clipped. Falls back to the default
NODE_WIDTHwhen canvas is unavailable.Before

After

How Has This Been Tested?
createNodeandmeasureTextWidth(canvas available and unavailable paths)Test Impact
packages/autorag/frontend/src/app/topology/__tests__/utils.spec.ts(6 tests)Request review criteria:
Self checklist (all need to be checked):
If you have UI changes:
After the PR is posted & before it merges:
main🤖 Generated with Claude Code
Summary by CodeRabbit
Tests
Improvements