Skip to content

feat(sessions): Navigate previous messages with plain arrow keys#3443

Open
charlesvien wants to merge 4 commits into
mainfrom
feat/composer-arrow-message-nav
Open

feat(sessions): Navigate previous messages with plain arrow keys#3443
charlesvien wants to merge 4 commits into
mainfrom
feat/composer-arrow-message-nav

Conversation

@charlesvien

@charlesvien charlesvien commented Jul 14, 2026

Copy link
Copy Markdown
Member

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?

  • Unit tests for the navigation decision logic (composerMessageNavigation.test.ts)
  • pnpm --filter @posthog/ui test (1576 tests) and pnpm typecheck pass
  • Not yet dogfooded in the running app, hence the draft

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@trunk-io

trunk-io Bot commented Jul 14, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

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

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

React Doctor found 1 issue in 1 file · 1 error.

Errors

Reviewed by React Doctor for commit 66b179f.

@charlesvien charlesvien marked this pull request as ready for review July 14, 2026 19:07
@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "navigate previous messages with arrow ke..." | Re-trigger Greptile

Comment on lines +362 to +365
if (navigateMessages) {
const visibleSuggestion = document.querySelector(
"[data-tippy-root] .tippy-box:not([data-state='hidden'])",
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Unrelated Popup Blocks Navigation

This document-wide query treats any visible Tippy suggestion as belonging to this editor. When another mounted composer has an open suggestion popup, Up/Down at this editor's boundary skips message navigation even though this editor has no active suggestions.

Comment on lines +366 to +372
useEffect(() => {
if (!composerNavigationRef) return;
composerNavigationRef.current = navigateFromComposer;
return () => {
composerNavigationRef.current = null;
};
}, [composerNavigationRef, navigateFromComposer]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

@charlesvien charlesvien added the Stamphog This will request an autostamp by stamphog on small changes label Jul 14, 2026

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant