Repository navigation
Conversation
Pi's TUI editor recalls earlier prompts with Up and Down, but the Web composer only used the arrows for the slash command menu. Add the same behaviour. Up recalls from an empty editor, from the very start of the text, or while already browsing; Down walks back toward the newest prompt and then restores the unsent draft. Any edit ends browsing. The slash command menu, IME composition and modified arrows keep their existing behaviour. History is the selected Session's loaded user prompts, using the same setup-echo rules as turn navigation, so it survives a reload and is never a second store of user input. A prompt the transcript only projects in part is recalled from its complete native text, or not at all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Problem
Web 的输入框不能像 TUI 那样按 ↑ 调出之前发过的消息。
web/ui/src/features/composer/Composer.tsx)里的 ↑ / ↓ 只在斜杠命令菜单打开时用来选命令。菜单关着时按 ↑ 只会移动光标,想复用上一条只能翻对话记录复制粘贴。两边用起来不一致,从 TUI 换到 Web 的用户会很不习惯。
Value
在 Web 里也能快速重发、微调上一条或者更早的消息,操作和 TUI 一样。
Approach
按键规则:和 Pi 的 TUI 一致
参照
pi-tui里Editor.navigateHistory:/开头,不会自动弹出斜杠命令菜单,免得 ↑ / ↓ 被菜单抢走。历史从哪来
setupDisplayMessage/isSetupPromptEcho),同一次输入不会出现两次。visibleText截断标记)。调出这种消息时,先用已有的/api/session/item分页取回全文再填进输入框。取不到、取回时会话变了,或者用户已经在输入框里改了内容,就不填,不会把截断后的半截文字当成原文。代码
web/ui/src/features/composer/prompt-history.ts:从会话记录里提取历史、判断按键是否触发、计算下一个位置。都是纯函数,方便单独测试。Composer.tsx:在按键处理里,斜杠命令菜单那段之后、Enter 发送之前,加一个recallPrompt。写入输入框复用已有的updateDraft,所以草稿的保存和恢复(composer-drafts.ts)照常生效。web/dist已经重新构建。范围限制
只翻已经加载到页面上的那部分会话(最多最近 250 条记录)。更早的消息以后可以接
/api/session/prompt-history分页加载,这次没做。Validation
基线是上游
0addb73,Pi 1.2.0,环境是 macOS arm64、Node v24.16.0。新加的测试:
tests/web/composer-prompt-history.spec.ts,10 个用例。最后 4 个在修改前就能通过,是用来保证原有行为没被破坏的。
其他命令:
composer-*、斜杠命令、command-turn-state、prompt-visibility、app-render、模型选择器,加上新测试,共 11 个文件 320/320 通过。bun run check:通过。bun run test,Node 部分:2452 个,2442 通过、8 跳过、2 失败。tests/extensions/plan-mode/result-rendering.test.ts里的a rich plan renders without throwing and keeps its content和expanded survives edge-content plans at extreme widths。bun run test,UI 部分:Node 部分失败后脚本没有继续,我用bun run test:ui单独补跑了,109 个文件、1642 个用例全部通过。Impact
/api/session/item请求,切换会话或卸载组件时会取消。🤖 Generated with Claude Code