Skip to content

feat(ui): shell-style message history recall in the chat composer#2284

Open
Feelings0220 wants to merge 1 commit into
kagent-dev:mainfrom
Feelings0220:ui/composer-history-upstream
Open

feat(ui): shell-style message history recall in the chat composer#2284
Feelings0220 wants to merge 1 commit into
kagent-dev:mainfrom
Feelings0220:ui/composer-history-upstream

Conversation

@Feelings0220

Copy link
Copy Markdown

ArrowUp on the composer's first line steps back through this session's previously sent messages (consecutive duplicates collapsed); ArrowDown steps forward and finally restores the unsent draft. Guards keep normal editing intact: recall only fires with a collapsed cursor on the first/last line, never during IME composition, and any manual edit or send exits history-browsing mode. The cursor lands at the end of each recalled message.

ArrowUp on the composer's first line steps back through this session's
previously sent messages (consecutive duplicates collapsed); ArrowDown
steps forward and finally restores the unsent draft. Guards keep normal
editing intact: recall only fires with a collapsed cursor on the
first/last line, never during IME composition, and any manual edit or
send exits history-browsing mode. The cursor lands at the end of each
recalled message.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016d9SxeefoRSLZmQ1oKo17j
Copilot AI review requested due to automatic review settings July 18, 2026 04:47
@github-actions github-actions Bot added the enhancement New feature or request label Jul 18, 2026

Copilot AI left a comment

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.

Pull request overview

Adds shell-style message history navigation to the chat composer in the UI so users can recall previously sent messages from the current session with ArrowUp/ArrowDown while preserving normal multiline editing and IME behavior.

Changes:

  • Computes a session-scoped history of user message texts (collapsing consecutive duplicates) for recall.
  • Adds ArrowUp/ArrowDown key handling with guards (first/last line + collapsed cursor + not composing) and restores the unsent draft when stepping past the newest entry.
  • Tracks history navigation state via refs (current history index + draft buffer) and exits history mode on send and manual edits.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +116 to +117
// Shell-style composer history: this session's user message texts, oldest
// first, consecutive duplicates collapsed. Recalled with ArrowUp/ArrowDown.
Comment on lines +116 to +130
// Shell-style composer history: this session's user message texts, oldest
// first, consecutive duplicates collapsed. Recalled with ArrowUp/ArrowDown.
const userMessageHistory = useMemo(() => {
const texts: string[] = [];
for (const msg of allMessages) {
if (msg.role !== "user") continue;
const text = (msg.parts ?? [])
.filter(part => part.kind === "text")
.map(part => (part as { text?: string }).text ?? "")
.join("")
.trim();
if (text && texts[texts.length - 1] !== text) texts.push(text);
}
return texts;
}, [allMessages]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants