Repository navigation
fix(remote): open another conversation on its newest message - #1691
Merged
Merged
Conversation
The remote view is drawn for whichever conversation is open, and the app's own chat column keys `AgentThread` per thread for exactly this reason — the remote view had no key. So switching from one remote conversation to another (the left rail's merged list, a fork's child, the palette) kept the instance, and `useStickyAutoScroll` keeps its stickiness, reading anchor and the container's `scrollTop` in refs and DOM across that swap. With the reader scrolled up — reading history while a reply streams — the new transcript inherited `stickToBottom=false` and an anchor naming a message it does not have. `settleViewport` then deliberately keeps the current position, so the conversation opened at the previous one's pixel offset. A short transcript hid it, because the browser clamps a stale offset to the bottom; a long one landed on a historical message, which is the report. Key the view per `desktopId:sessionId`, and give the hook a `resetKey` for the frames that hand it another conversation without remounting it (the vibe cell, a panel) — so the reset does not depend on every caller remembering the key. Both tests fail without the fix, landing at the old offset (2800 of 4000).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Switching between two remote conversations in the desktop app opened the second one at the first one's scroll position — a message from a while back, seemingly at random. Long conversations made it visible; short ones hid it.
Why
The remote view is drawn for whichever conversation is open, and the app's own chat column keys
AgentThreadper thread for exactly this reason — the remote view had no key:AppShellrendersRemoteConversationViewwithout one, and every in-chat switch (left rail's merged list, a fork's child, the palette) only changesactiveRemote, so the instance survives;useStickyAutoScrollkeepsstickToBottomRef,anchorRefand the container'sscrollTopoutside React state, so the new transcript inherits the old one's "the reader scrolled up" and an anchor naming a message it does not have;settleViewportthen does what it is written to do for a replaced transcript — keep the current position — so the conversation opens at the previous pixel offset. A short transcript clamps that offset to the bottom (looks fine); a long one lands on real content.The remote timeline's snapshot cache makes it worse on revisit: the cached entries are seeded synchronously, so there is no short intermediate frame to clamp the offset back.
Fix
RemoteConversationViewby${desktopId}:${sessionId}, the same contractAgentThreadstates for local threads;useStickyAutoScrollaresetKeythat drops stickiness/anchor and follows the newest message, for the frames that hand this view another conversation without remounting (the vibe cell, a panel). Callers that already remount leave it out.Tests
useStickyAutoScrollHook.test.ts: a swap under one container now lands atscrollHeight; the same key still keeps the reader's position.RemoteConversationView.scroll.test.tsx: opened another conversation through the view, with faked viewport heights.Both fail without the fix (
2800where4000is expected). Full desktop suite passes: 441 files / 6291 tests,tsc --noEmitand eslint clean.Not in this PR
Two adjacent findings, either worth its own change:
Number.MAX_SAFE_INTEGERon the client andNEWEST_PAGE_CURSORon the host, but the Agent only recognisesbefore == i64::MAX(agent/src/session/history/paging.rs:284), so desktop and phone first paints get the 600-row ceiling instead of the intended 150 — the code comment there measures that at 250–310 ms on a long tool-heavy conversation;readPageignorestrimmed/shortPage; the phone backfills (HISTORY_TAIL_BACKFILL_MAX_PAGES).