feat(sessions): Navigate previous messages with plain arrow keys#3443
feat(sessions): Navigate previous messages with plain arrow keys#3443charlesvien wants to merge 4 commits into
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found 1 issue in 1 file · 1 error. Errors
Reviewed by React Doctor for commit |
|
Reviews (1): Last reviewed commit: "navigate previous messages with arrow ke..." | Re-trigger Greptile |
| if (navigateMessages) { | ||
| const visibleSuggestion = document.querySelector( | ||
| "[data-tippy-root] .tippy-box:not([data-state='hidden'])", | ||
| ); |
There was a problem hiding this comment.
| useEffect(() => { | ||
| if (!composerNavigationRef) return; | ||
| composerNavigationRef.current = navigateFromComposer; | ||
| return () => { | ||
| composerNavigationRef.current = null; | ||
| }; | ||
| }, [composerNavigationRef, navigateFromComposer]); |
There was a problem hiding this comment.
Navigation Handler Lags Messages
The handler is replaced in a passive effect after each message-list or focus update. A boundary arrow received after the updated view is committed but before this effect runs calls the previous closure, so it can select an older snapshot's message or scroll to the wrong row. The mirrored effect in the experimental thread has the same timing window.
There was a problem hiding this comment.
No human has reviewed this behavioral change to arrow-key handling in the composer editor. The bot reviewer raised two valid unaddressed concerns: (1) the document-wide Tippy selector could suppress navigation from a composer that has no active suggestion of its own if any other mounted composer does, and (2) the passive useEffect that writes the navigation handler into the ref can be stale for a brief window after a render, causing the arrow press to call an older closure. Neither is catastrophic, but both are real correctness issues on a feature that intercepts global key events in the editor.
Problem
Finding your own previous messages in a long agent conversation is tedious and forces a hand off the keyboard. #3407 added option+up/down and cmd+J for this, but plain arrow up is the established pattern from terminals, Claude, Codex and other chat inputs, so nobody discovers the modifier version.
Requested in team-desktop.
Changes
Plain up/down in the session composer now cycles through the prompts you actually sent in that conversation, terminal style: the recalled prompt is loaded into the input and the thread scrolls to and highlights that message. Arrows keep moving the caret as usual; only a press with the caret already at the start or end of the input triggers recall (same behavior as pi). Down walks back toward newer prompts, and one more down past the newest restores whatever you were typing and scrolls back to the bottom. Sending a prompt resets the cycle. Works in both the current conversation view and the experimental chat thread.
Option+up/down, cmd+J, prompt history in the new task composer and queued message restore on arrow up are unchanged.
How did you test this?
composerMessageNavigation.test.ts)pnpm --filter @posthog/ui test(1576 tests) andpnpm typecheckpassAutomatic notifications