Repository navigation
Conversation
🦋 Changeset detectedLatest commit: acbf61c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
67418c5 to
0c5ce9e
Compare
…igation labels Allow TuiAltScreen instances to override viewport and search keybindings without mutating the global singleton, add idempotent TuiAltScreen.openSearch(query?) with Input.moveCursorToEnd(), show semantic arrow navigation labels (↑ Previous / ↓ Next), defer search shortcuts to focused non-search overlays and non-scroll layout roots, and normalize Kitty Caps Lock + Ctrl letter sequences.
…command Bind fullscreen transcript search to Ctrl+F (retaining Ctrl+Shift+F) and match navigation to ↑/↓ via per-instance keybindings, add fullscreen-only /find [query] command hidden in regular mode, unify host slash-command resolution with runtime tuiMode, and show Ctrl-F in fullscreen /help.
…esets Document Ctrl-F and /find [<query>] in English and Chinese reference pages and add changesets for @moonshot-ai/pi-tui and @moonshot-ai/kimi-code.
0c5ce9e to
c4053b5
Compare
…mponent Close active transcript search before transferring mouse focus to a component outside the search overlay so keyboard input goes directly to the clicked target instead of being reclaimed by overlay focus restore, while keeping scroll, selection, and search-box clicks open.
…ints Update CustomEditor argument hint injection to anchor after FAKE_CURSOR_END and measure trailing padding with visibleWidth so hardware cursor and IME positioning remain intact and lines do not overflow; skip APC cursor markers during slash token highlighting.
… and tighten search/keys guards
…itor cursor injection
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: acbf61c990
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| }, | ||
| "tui.altScreen.search": { | ||
| defaultKeys: "ctrl+shift+f", | ||
| defaultKeys: ["ctrl+f", "ctrl+shift+f"], |
There was a problem hiding this comment.
Keep pi-tui's upstream search defaults unchanged
Changing the published library-wide default to include Ctrl+F affects every direct @moonshot-ai/pi-tui alternate-screen consumer: a key that previously reached the focused editor and moved its cursor right is now intercepted to open search unless the consumer proactively overrides the bindings. Keep the upstream default and enable the Kimi-specific binding through an application-owned opt-in or default-disabled extension.
AGENTS.md reference: packages/pi-tui/AGENTS.md:L13-L17
Useful? React with 👍 / 👎.
| const focusTarget = this.resolveMouseFocusTarget(result.focusTarget ?? result.target.component); | ||
| const focusChanged = result.focus === true && this.getFocusedComponent() !== focusTarget; | ||
| if (result.focus) this.setFocus(focusTarget); | ||
| const shouldFocus = result.focus === true && event.type !== "wheel"; |
There was a problem hiding this comment.
Honor focus requests from wheel handlers outside search
When any TuiAltScreen component returns { focus: true } from a wheel handler, this condition now discards the request even when transcript search is not active. TuiMouseEventResult.focus promises keyboard focus without excluding wheel events, and the previous implementation always called setFocus, so wheel-to-focus components can scroll while subsequent keys remain routed to the previously focused component. Limit the wheel suppression to the active-search case rather than changing mouse focus semantics globally.
AGENTS.md reference: packages/pi-tui/AGENTS.md:L13-L17
Useful? React with 👍 / 👎.
| textWidth: number, | ||
| ): string { | ||
| const remaining = Math.max(0, visibleWidth(line.slice(insertAt)) - textWidth); | ||
| return line.slice(0, insertAt) + styledText + ' '.repeat(remaining); |
There was a problem hiding this comment.
Preserve text following an inline cursor
When a user moves the caret left while the input is still a hint-bearing command such as /find , insertAt is immediately after the fake cursor, so this return replaces every character after the caret with the hint and padding. The underlying editor value still contains those characters, leaving the displayed command inconsistent with what will be submitted; preserve the existing suffix or only inject the hint when the caret is at the command's end.
Useful? React with 👍 / 👎.
Screenshots / Recordings
全屏搜索框底栏文案(
VirtualTerminal78×6 渲染,关注右下角导航提示)全屏
/find补全与/help面板(真实全屏 CLI 终端输出片段)输入
/fi时仅全屏模式列出/find [query]:全屏
/help面板在快捷键与命令列表中分别显示Ctrl-F与/find(普通模式均不显示):Requirement or Bug
全屏模式此前只将对话搜索绑定在
Ctrl+Shift+F,容易被 Windows Terminal 等终端默认占用,在非 Kitty 协议终端里也无法与Ctrl+F区分。本 PR 将全屏对话搜索默认快捷键改为全平台统一的
Ctrl+F(保留Ctrl+Shift+F),为搜索结果跳转增加方向键↑/↓与↑ Previous · ↓ Next标签,新增仅全屏可见的/find [query]命令,并同步修复搜索框打开时点击底部输入框仍被抢回焦点,以及输入带参数提示的斜杠命令(如/find)时光标与输入法位置错位的问题。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
核心思路
直接在
packages/pi-tui的TUI_KEYBINDINGS中更新全屏搜索默认键位,保持getKeybindings()作为所有组件唯一的键位真源;普通模式(TuiMainScreen)不消费tui.altScreen.*,原有Ctrl+F光标右移不受影响。在TuiAltScreen上新增幂等的openSearch(query?)入口、快捷键让位守卫以及“非滚轮鼠标焦点切出搜索框时自动关闭搜索”的逻辑,同时在keys.ts中对称修复 Kitty 协议下 Caps Lock + 修饰键的大写字母匹配。在apps/kimi-code中用必填的tuiMode收口斜杠命令可见性与解析路径,并在CustomEditor中统一光标标记与可见宽度计算逻辑以修复参数提示下的光标和输入法定位。结构图
flowchart LR A["TUI_KEYBINDINGS 默认键位<br/>packages/pi-tui/src/keybindings.ts"] --> B["TuiAltScreen<br/>openSearch / 快捷键让位 / 鼠标切焦点关闭搜索"] A --> C["AltScreenSearchComponent<br/>setQuery / ↑ Previous · ↓ Next"] D["keys.ts<br/>Kitty Caps Lock 修饰键归一化"] --> B E["斜杠命令注册表<br/>commands/registry.ts"] --> F["统一可见性过滤<br/>isSlashCommandVisible(tuiMode)"] F --> G["补全与 /help<br/>kimi-tui.ts / help-panel.ts"] F --> H["统一输入解析<br/>resolveHostUserInput"] H --> I["/find 命令分发<br/>commands/dispatch.ts"] I --> B J["CustomEditor<br/>共享光标锚点与可见宽度注入"] --> K["argumentHint / promptPrediction<br/>保留 CURSOR_MARKER 与行宽"]键位默认值留在
TUI_KEYBINDINGS单一真源里,避免应用层局部覆盖与组件内getKeybindings()分裂。斜杠命令可见性通过必填tuiMode收敛在registry.ts与resolveHostUserInput,补全、/help与提交解析共用同一套判断。关键决策
pi-tui的TUI_KEYBINDINGSTuiAltScreenOptions增加实例级keybindings覆盖pi-tui内有 7 个组件(含搜索框内的Input)读取getKeybindings(),只在TuiAltScreen传实例键位会造成同一套 UI 读两份键位源;普通模式不读取tui.altScreen.*,直接改TUI_KEYBINDINGS即可隔离setFocus(editor)TuiBase.showOverlay通过overlayFocusRestore维持浮层焦点,只切焦点不关搜索会在下一次按键时把输入抢回搜索框;自动关闭搜索符合直觉,同时滚轮、框内点击与划词复制均保持搜索打开/find的表现Input.getCursor()/Input.setCursor(position)并在setQuery()后置尾Input.setValue()默认把光标放末尾,或只加特化的moveCursorToEnd()Input.setValue()光标归零的契约,而getCursor()/setCursor(position)与getValue()/setValue()对称且可用于任意光标位置读写TuiAltScreen让位给聚焦的非搜索 capturing overlay 和无ScrollView布局;在keys.ts归一化 Caps Lock + 任意非锁修饰键的A–ZCtrl+F或仅对Ctrl做特判Ctrl/Alt/Super组合键custom-editor.ts将stripNonVisibleSequences扩展跳过 APC 序列,并抽出findCursorAnchor/injectTextAfterCursor供injectArgumentHint与injectPromptPrediction共用injectArgumentHint中复制粘贴补丁injectArgumentHint还在查找旧版CURSOR_BLOCK并按原始字符串长度补空格,导致截掉CURSOR_MARKER与假光标并撑爆行宽;统一后两处共用同一套逻辑阅读指南
packages/pi-tui/src/keybindings.ts与packages/pi-tui/src/keys.ts:全屏搜索默认键位更新,以及 Kitty Caps Lock 修饰键大写字母归一化。packages/pi-tui/src/tui-alt-screen.ts、packages/pi-tui/src/alt-screen-search.ts、packages/pi-tui/src/components/input.ts:幂等openSearch(query?)、浮层与无ScrollView布局的快捷键让位、非滚轮切焦点关闭搜索、↑ Previous · ↓ Next标签与纯空白查询修复、Input.getCursor()/Input.setCursor(position)。apps/kimi-code/src/tui/commands/registry.ts、apps/kimi-code/src/tui/commands/resolve.ts、apps/kimi-code/src/tui/commands/dispatch.ts:/find注册、visible(context)可见性过滤、必填tuiMode的resolveHostUserInput统一解析与命令分发。apps/kimi-code/src/tui/components/editor/custom-editor.ts:APC 安全的stripNonVisibleSequences,以及injectArgumentHint/injectPromptPrediction共享的光标锚点与可见宽度注入。apps/kimi-code/src/tui/components/dialogs/help-panel.ts与apps/kimi-code/src/tui/kimi-tui.ts:全屏/help快捷键展示与命令列表接线。可略读:
packages/pi-tui/UPSTREAM.md(fork 意图卡片)、docs/(四处参考表增补行)、.changeset/以及各测试文件。Behavior Changes and Affected Users
Ctrl+F→相同)Ctrl+Shift+F)Ctrl+F右移的 TUI 用户→右移光标,或切回普通模式(regular)保留原有Ctrl+F光标右移↑/↓及底栏标签↑/↓不切换匹配;底栏显示↑ Shift+Enter · ↓ Enter↑/↓跳转上一处/下一处匹配(保留Shift+Enter/Enter/Ctrl+Shift+G/Ctrl+G);底栏显示↑ Previous · ↓ Next(窄屏退化为↑ ↓)Enter/Shift+Enter/Ctrl+G/Ctrl+Shift+G全部保留overlayFocusRestore抢回搜索框/find或/find <query>/findskill 的 TUI 用户/skill:find显式调用同名 skillregular)下Ctrl+F、/find与/helpCtrl+F右移光标;无/find;/help不含Ctrl-FTuiMainScreen不读取tui.altScreen.*,且斜杠命令解析按必填tuiMode过滤掉/find,Ctrl+F与同名 skill 均走原路径/findskill 的用户ScrollView)及pi-tui聚焦的 capturing overlay 中按Ctrl+Fpi-tuioverlay 或无ScrollView的接管视图,不被搜索拦截(主布局内嵌挂载的面板如/help、/model仍保留主ScrollView)Ctrl+E)与/tasks查看器的用户/find)时的光标与输入法定位injectArgumentHint截断CURSOR_MARKER与假光标并导致行宽溢出CURSOR_MARKER与假光标并按visibleWidth对齐行宽,光标显示与中文输入法候选框定位恢复正常argumentHint内置斜杠命令的 TUI 用户pi-tui键位匹配失败keys.ts将 Caps Lock + 任意非锁修饰键(Ctrl/Alt/Super/Shift)的A–Z归一化为小写键位,无修饰 Caps Lock 大写输入不受影响@moonshot-ai/pi-tui默认全屏搜索键位与 APItui.altScreen.search默认ctrl+shift+f,searchNext/searchPrevious默认不含down/up;无openSearch、getCursor/setCursor;纯空白查询显示No matches["ctrl+f", "ctrl+shift+f"]与down/up优先;新增openSearch(query?)与Input.getCursor()/Input.setCursor(position);纯空白查询不显示No matches@moonshot-ai/pi-tui并依赖旧默认键位的调用方setKeybindings()覆盖回旧键位受影响模块与测试覆盖
packages/pi-tui:keybindings.test.ts、input.test.ts、keys.test.ts、tui-alt-screen.test.ts覆盖默认键位更新、自定义setKeybindings覆盖与反转标签、openSearch幂等/预填清洗/无ScrollView守卫、↑ Previous · ↓ Next与窄屏退化、纯空白查询、聚焦非搜索浮层与无ScrollView接管视图透传、点击编辑器关闭搜索且滚轮/框内点击/划词不关闭搜索、Kitty Caps Lock 修饰键匹配。apps/kimi-code:create-tui-state.test.ts、commands/find.test.ts、commands/registry.test.ts、commands/resolve.test.ts、components/editor/custom-editor.test.ts、components/panels/help-panel.test.ts、controllers/editor-keyboard.test.ts覆盖全屏Ctrl+F/Ctrl+Shift+F/↑/↓、普通模式Ctrl+F光标右移保留、接管视图透传Ctrl+F、Caps LockCtrl+F、/find全屏执行与普通模式隐藏(含同名 skill 透传)、流式与压缩期间可用、argumentHint光标标记与行宽保持、全屏与普通模式/help差异。docs:中英文reference/keyboard.md与reference/slash-commands.md同步增补。pnpm lint、check:duplication以及真实全屏与普通模式 CLI 端到端交互验证;Linux 由 CI 覆盖(CI/build、CI/lint、CI/typecheck、CI/test (1..5)、CI/test-standalone-suites);Windows 未验证(本机为 macOS,且本次 PR 中CI/test-windows按工作流过滤条件被跳过)。本地验证详情(HEAD acbf61c)
pnpm --filter @moonshot-ai/pi-tui test:1250 通过,0 失败,1 跳过(既有)。pnpm exec tsc -p packages/pi-tui/tsconfig.json --noEmit与pnpm exec tsc -p apps/kimi-code/tsconfig.json --noEmit:通过。pnpm exec vitest run --reporter=agent apps/kimi-code/test/tui/components/editor/custom-editor.test.ts apps/kimi-code/test/tui/create-tui-state.test.ts apps/kimi-code/test/tui/commands apps/kimi-code/test/tui/components/panels/help-panel.test.ts apps/kimi-code/test/tui/controllers/editor-keyboard.test.ts:29 个测试文件、564 个用例全部通过。pnpm lint:全部检查通过,0 警告 0 错误。pnpm run check:duplication 9c1c1451b25ce74e0762e9070c5682a889ea2d03:0 新增重复。Ctrl+F打开搜索与↑ Previous · ↓ Next、↑/↓切换命中、Esc关闭、/find补全与/find <query>预填光标置末、全屏/help展示及普通模式完全隐藏。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.