Problem#
The Agents panel loses the user's place in a long roster, in two ways:
- Remounts reset it. Switching to the Files tab and back, or hiding and showing the right panel, remounts
AgentsPanel. The roster then jumps to the top.
- Thread switches leak it.
ChatView is not remounted on ordinary thread switches, so when both threads show the Agents tab, React reuses the same panel and viewport. Thread B opens at thread A's offset. If B's right panel was on another tab, the panel mounts fresh and B opens at 0, which is why this only shows up when Agents is open on both threads.
Change#
ChatView keys AgentsPanel by the environment-qualified thread key, so each thread gets its own panel lifetime.
AgentsPanel remembers each thread's offset in renderer memory and restores it in a layout effect, before paint. A passive scroll listener records the offset without React renders. The map keeps the 100 most recently used threads, the same bound as the timeline's position cache in timelineScrollAnchoring.ts.
- If a shorter layout clamps the restored offset, the deeper offset stays pending. A
ResizeObserver applies it when the roster grows back, and it is dropped once the user scrolls away from the bottom. The clamped value never overwrites the saved one.
ScrollArea takes an optional viewportRef, because the panel needs the element that actually scrolls and Base UI renders it internally. Existing callers are unchanged.
Nothing crosses the wire or persists.
Scope and approval#
This is a small, obvious bug fix under the prior-approval exception. It fixes observable wrong behavior in an existing panel: losing your place on a remount, and inheriting another thread's position. It makes no product decision. The chat timeline already restores a per-thread position the same way, and this brings the Agents roster in line with it. It adds no settings, server state, persistence, or contract changes, and touches 3 source files plus a test.
This replaces #9637 and #14512, both closed for missing UI evidence. GitHub refused to reopen #14512 after its evidence was added, so this is the focused replacement permitted by CONTRIBUTING.md. It addresses that PR's review findings: the cache is now bounded (Macroscope, CodeRabbit), and sub-pixel clamping is tolerated (Cursor Bugbot).
Verification#
Environment. macOS 26.4.1, vp run dev from this branch's worktree, recorded in headless Chrome 154 at 1536 × 960 through Playwright. The database is a synthetic showcase fixture with 22 agents in thread A and 36 in thread B. No real projects, sessions, or conversations are included. The public T3 Code repository name is a fixture label.
Reproduction. Open thread A, show the Agents tab, and scroll the roster to 500. Switch to Files and back to Agents, then hide and show the right panel. Show the Agents tab on thread B as well, open B, then return to A. Before each recorded thread switch, both threads already had the Agents tab open, so the leak is visible.
A script logged the roster's scrollTop after each step:
| Step | Before (main) | After |
|---|
| Scroll A | 500 | 500 |
| Files → Agents | 0 | 500 |
| Hide/show panel | 0 | 500 |
| Open unscrolled B | 500 | 0 |
| Return to A | 500 | 500 |
Before — main 0cf482b08b

https://github.com/user-attachments/assets/9b4eb071-7189-473f-95be-7f5ad475b6da
After — PR head 8d278e2a7b

https://github.com/user-attachments/assets/e618769e-8ae6-433b-85ef-dc0329e5b864
The stills are taken six seconds into each recording, after Files → Agents. The videos also show the panel hide/show and the thread switches.
The later commits only change what happens when a restored offset is clamped (for example by workflows that start collapsed after a remount), or when the roster empties without the panel unmounting. Neither happens in the recording, so it still matches the head. The unit tests cover both cases.
A separate pass in the T3 in-app browser confirmed the tab and panel resets on main and the fix on this branch. That pass opened thread B at 0 on main. The leak needs the Agents tab to already be showing when the thread switches, and in the recordings above it is.
Checks at the PR head
vp test run src/components/AgentsPanel.test.tsx: 7/7 pass. The tests cover:
- restoring on remount;
- a roster that appears late;
- keeping a clamped deeper offset, including a sub-pixel clamp;
- keeping the offset when the roster empties without unmounting;
- following that offset as the roster grows, until the user scrolls or expands a section;
- the 100-thread bound.
- With main's
AgentsPanel and ScrollArea, the restore tests fail; only the cache-bound test passes. I also removed each guard in turn: the resize restore, the pending target on cleanup, the clamp guard and its 1px tolerance, the user-scroll and user-input cancels, LRU eviction, and the hasAgents dependency. Each removal fails its matching test. The thread-switch key in ChatView is shown by the recordings, not a unit test.
vp run typecheck in apps/web passes. vp lint and vp fmt --check pass on the changed files. Existing ChatView.tsx warnings are unchanged.
Surfaces. Every entry point (panel tabs and visibility controls) goes through the same ChatView Agents panel. Desktop renders the same web component. Mobile has no Agents roster. The change doesn't depend on the provider. It uses environment-qualified keys, so several environments don't collide.
Not checked directly. The Electron shell, the narrow sheet layout, and remote/relay/tunnel connections. All of them render this same component. Existing user guidance is still accurate.
Implemented by Claude Opus 5.5 in Claude Code, running in T3 Code. Browser verification and the upload of GitHub evidence were done by GPT-6.1-Sol (high) in the Codex harness, running in T3 Code.
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
Important
Review skipped#
Review was skipped as selected files did not have any reviewable changes.
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
ff822136-a8cf-43a1-9b6b-8c885255e216📥 Commits
Reviewing files that changed from the base of the PR and between 6bc91a6a51f0023ed1b5ac59f1e5cfc725ed4366 and a1196ea6cbb736491f0c24b68be7bf3162a102c5.
You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
4f7fc93c-cd2c-4b4b-ac58-578dbaf3fcf1📥 Commits
Reviewing files that changed from the base of the PR and between 12b2cf8e518da2717639db61550024e0fab5a1af and 6bc91a6a51f0023ed1b5ac59f1e5cfc725ed4366.
📒 Files selected for processing (2)
apps/web/src/components/AgentsPanel.test.tsxapps/web/src/components/AgentsPanel.tsxIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
📝 Walkthrough
Walkthrough#
The Agents panel saves and restores scroll positions by thread key. It retains up to 100 thread positions. ChatView passes the active thread key, and ScrollArea exposes its viewport through an optional ref.
Changes#
Agents panel scroll restoration
apps/web/src/components/ui/scroll-area.tsx,apps/web/src/components/AgentsPanel.tsx,apps/web/src/components/ChatView.tsx,apps/web/src/components/AgentsPanel.test.tsxPriority: ⬇️ Low
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)#
Possibly related PRs
Merge Risk: ⚪ Minimal · up to
6bc91The change preserves Agents panel positions per thread without adding persistent state or changing external contracts. No concrete merge-blocking issue is identified; merge after normal checks pass.
Security Architecture Review#
Security architecture risk: ⚪ Minimal · up to
6bc91The change remembers presentation state without granting access to data or agent capabilities. Environment-qualified thread keys separate saved positions, storage is bounded, and restoration yields to user interaction. No material security risk was identified in the changed behavior.
Retained concerns No architecture-level concerns identified.
Security review details
Security Blast Radius
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.