Preserve scroll position when switching between chat and file tabs#1125
Preserve scroll position when switching between chat and file tabs#1125vishsanghishetty wants to merge 2 commits intoambient-code:mainfrom
Conversation
render all tab content simultaneously and toggle visibility with CSS hidden class instead of mounting/unmounting. gates FileViewer polling on an isActive prop so background tabs don't fetch. closes ambient-code#1070 Signed-off-by: Vishali <vsanghis@redhat.com>
WalkthroughRenders chat, all open file tabs, and all open task tabs simultaneously (hidden via CSS) to preserve component state; adds an optional Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 `@components/frontend/src/app/projects/`[name]/sessions/[sessionName]/page.tsx:
- Around line 1691-1708: The TaskTranscriptViewer is polling running tasks even
when its tab is hidden; update the TaskTranscriptViewerProps to accept an
optional boolean isActive, pass isActive from the mapping (where
fileTabs.openTaskTabs is rendered) similarly to FileViewer, and change the
refetchInterval logic inside TaskTranscriptViewer to only poll when isActive &&
sessionPhase === "Running" && task?.status === "running" (matching FileViewer's
pattern) so inactive mounted tabs do not trigger periodic network calls.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: d24e5948-00e5-4adf-8053-e92ad69dd6d5
📒 Files selected for processing (3)
components/frontend/src/app/projects/[name]/sessions/[sessionName]/components/__tests__/file-viewer.test.tsxcomponents/frontend/src/app/projects/[name]/sessions/[sessionName]/components/file-viewer.tsxcomponents/frontend/src/app/projects/[name]/sessions/[sessionName]/page.tsx
components/frontend/src/app/projects/[name]/sessions/[sessionName]/page.tsx
Show resolved
Hide resolved
Signed-off-by: Vishali <vsanghis@redhat.com>
Summary
Fixes #1070 — the artifact viewer now preserves scroll position when switching between chat and file/task tabs.
The root cause was that
renderMainContent()conditionally mounted/unmounted the Chat, FileViewer, and TaskTranscriptViewer components on every tab switch. Each mount reset scroll position and React Query cache.The fix renders all tab content simultaneously and toggles visibility with the CSS
hiddenclass (display: none). Inactive FileViewers also stop polling via a newisActiveprop so background tabs don't make unnecessary fetches.What changed
renderMainContent()now renders chat, all open file tabs, and all open task tabs at once; inactive ones getclassName="hidden"isActiveprop (defaulttrue) that gatesrefetchIntervalso hidden tabs don't pollisActiveandsessionPhaseTest plan
tsc --noEmit)Video recording of the manual test will be attached in a comment below.
