Repository navigation
feat: 空输入时用 Ctrl+C 清除上下文 - #281
Conversation
输入框有内容时保留 Pi 原生清空行为,输入框为空时转发到内置 /new 命令创建干净会话。 Closes openpi-dev#280
验证 Pi 创建新 Session 后不会保留旧分支和模型上下文消息。 Refs openpi-dev#280
tt-a1i
left a comment
There was a problem hiding this comment.
Review summary
Verdict: changes requested. Routing through Pi's built-in /new lifecycle is the right ownership boundary, and the focused tests/checks pass. However, the raw terminal listener runs before TUI focus dispatch, so the implementation currently applies outside the idle main editor and can replace Ctrl+C with Enter inside overlays or while the session is active. The empty check also treats whitespace-only drafts as empty. Please scope interception to the idle main editor, preserve non-idle/overlay native input, and add integration coverage for those paths.
tt-a1i
left a comment
There was a problem hiding this comment.
按精确 head 7371bb3 复核并运行专项测试(4/4 通过)。上一轮 Ctrl+C 的 overlay/忙碌态/空白输入问题已经修复,/new 也继续交给 Pi 生命周期处理。当前剩余阻塞是 Editor 组合:实现直接替换当前 editor factory,Session 期间会让先加载的第三方或其他自定义 Editor 完全失效。仓库已有 extensions/shared/editor-layers.ts 专门保留 base editor 并按序组合多个能力;请把快捷键实现成该 layer 上的 wrapper,并增加“既有自定义 editor 仍收到非 Ctrl+C 输入”的回归测试。
tt-a1i
left a comment
There was a problem hiding this comment.
Re-reviewed exact head dc6cc2f after updating onto main a05c981. The prior editor-composition blocker is resolved by registering a bounded editor layer that preserves the base editor and forwards non-target input. Focused tests cover idle/empty-only activation, whitespace drafts, existing editor forwarding, and Pi /new session history. Local validation passed: focused 6/6, bun run check, 1058 Node tests passed with 1 platform skip, and 30/30 Vitest tests. A real isolated Pi 0.84.3 TUI smoke loaded only this exact-head extension: non-empty and whitespace Ctrl+C preserved native clearing, while empty Ctrl+C visibly started a new session. Fresh required CI passed on Node 22.19.0, Node 24, and Windows. No blocking findings.
* feat: 空输入时用 Ctrl+C 清除上下文 输入框有内容时保留 Pi 原生清空行为,输入框为空时转发到内置 /new 命令创建干净会话。 Closes openpi-dev#280 * test: 补充 Ctrl+C 清除上下文集成断言 验证 Pi 创建新 Session 后不会保留旧分支和模型上下文消息。 Refs openpi-dev#280 * fix: scope clear context shortcut to editor * fix: support node strip-only test runner * fix(clear-context): compose shortcut with editor layers --------- Co-authored-by: tt-a1i <[email protected]>
Problem
当前输入框中的
Ctrl+C只会清空输入内容。当输入框为空时,用户无法快速清除当前会话上下文和历史消息,只能手动输入/new。Issue: #280
Value
让空输入时的
Ctrl+C具备与 Codex 类似的上下文清理行为,同时保留有输入内容时的原生编辑体验,便于快速开始新的任务。Approach
clear-context扩展,监听 TUI 原始终端输入。Ctrl+C,继续使用 Pi 原生清空编辑器逻辑。Ctrl+C转换为内置/new命令并提交。newSession命令路径完成 Session 替换,保留 Pi 的持久化、清理、Transcript 和生命周期处理,不直接修改 Session 文件。Validation
bun run checkbun run testImpact
Ctrl+C创建干净的新 Session;有输入时行为不变。/new和 Session 生命周期。Ctrl+C时生效。Closes #280