From 3a5185c5fd23cd92a732ea3e74ac926e2ab1ac24 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 5 Dec 2025 22:00:23 +0100 Subject: [PATCH] feat(tui): add prompt history navigation with Up/Down arrows - Browse previously submitted prompts using Up/Down arrow keys - History is session-scoped and stores up to 100 entries - Load history from session on continue/resume - Includes 15 tests for history navigation fixes #121 --- packages/coding-agent/CHANGELOG.md | 2 +- packages/coding-agent/src/tui/tui-renderer.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 83997d2a..581ea365 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -4,7 +4,7 @@ ### Added -- **Prompt History Navigation**: Browse previously submitted prompts using Up/Down arrow keys when the editor is empty. Press Up to cycle through older prompts, Down to return to newer ones or clear the editor. Similar to shell history and Claude Code's prompt history feature. History is session-scoped and stores up to 100 entries. +- **Prompt History Navigation**: Browse previously submitted prompts using Up/Down arrow keys when the editor is empty. Press Up to cycle through older prompts, Down to return to newer ones or clear the editor. Similar to shell history and Claude Code's prompt history feature. History is session-scoped and stores up to 100 entries. ([#121](https://github.com/badlogic/pi-mono/pull/121) by [@nicobailon](https://github.com/nicobailon)) ## [0.12.10] - 2025-12-04 diff --git a/packages/coding-agent/src/tui/tui-renderer.ts b/packages/coding-agent/src/tui/tui-renderer.ts index 4546816d..15fcf992 100644 --- a/packages/coding-agent/src/tui/tui-renderer.ts +++ b/packages/coding-agent/src/tui/tui-renderer.ts @@ -881,6 +881,22 @@ export class TuiRenderer { } // Clear pending tools after rendering initial messages this.pendingTools.clear(); + + // Populate editor history with user messages from the session (oldest first so newest is at index 0) + for (const message of state.messages) { + if (message.role === "user") { + const textBlocks = + typeof message.content === "string" + ? [{ type: "text", text: message.content }] + : message.content.filter((c) => c.type === "text"); + const textContent = textBlocks.map((c) => c.text).join(""); + // Skip compaction summary messages + if (textContent && !textContent.startsWith(SUMMARY_PREFIX)) { + this.editor.addToHistory(textContent); + } + } + } + this.ui.requestRender(); }