fix(shell): disable kitty keys in VS Code#1440
fix(shell): disable kitty keys in VS Code#1440Timi16 wants to merge 2 commits intoMoonshotAI:mainfrom
Conversation
Signed-off-by: Timi16 <134459045+Timi16@users.noreply.github.com>
There was a problem hiding this comment.
🔴 NameError: _mcp_status_block, _mcp_status_loading, and _bg_task_count are used but no longer defined
The PR deleted the local function/class definitions for _mcp_status_block, _mcp_status_loading, _BgCountCache, and _bg_task_count (previously at old lines 200-230) but left the references to them at lines 204-206 when constructing the CustomPromptSession. This means entering the interactive shell (Shell.run() without a command) will immediately crash with a NameError. This breaks the primary interactive mode of the CLI.
(Refers to lines 204-206)
Prompt for agents
Restore the deleted local function/class definitions that were previously between lines 200-230 (old) of src/kimi_cli/ui/shell/__init__.py. Specifically, you need to re-add these definitions inside the run() method, before the `with CustomPromptSession(...)` block at line 202:
1. `_mcp_status_block(columns: int)` - closure that reads `self.soul.status.mcp_status` and calls `render_mcp_prompt`
2. `_mcp_status_loading() -> bool` - closure that checks if MCP is loading
3. `_BgCountCache` dataclass with `time` and `count` fields
4. `_bg_cache` instance of `_BgCountCache`
5. `_bg_task_count() -> int` - closure that returns background task count with caching
These were defined between the `_plan_mode_toggle` definition and the `CustomPromptSession` context manager, and should be placed back there (after the new `maybe_disable_kitty_keyboard_protocol()` call at line 200 and before the `with CustomPromptSession(...)` at line 202).
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
💡 Codex Review
kimi-cli/src/kimi_cli/ui/shell/__init__.py
Lines 204 to 206 in 423e762
Any interactive kimi session now fails before the first prompt is shown: Shell.run(command=None) still passes _mcp_status_block, _mcp_status_loading, and _bg_task_count into CustomPromptSession, but those locals were removed and there are no remaining definitions in this module. That turns shell startup into a runtime NameError for every normal interactive launch.
ℹ️ 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".
| if not _should_disable_kitty_keyboard_protocol(): | ||
| return | ||
|
|
||
| _write_escape("\x1b[<u") |
There was a problem hiding this comment.
Avoid popping the terminal's kitty key mode on startup
CSI < u is the kitty keyboard protocol pop/restore sequence, so sending it unconditionally here changes terminal state without a matching push from this process. In terminals where the parent shell/editor already enabled kitty key handling—or whenever users set KIMI_CLI_DISABLE_KITTY_KEYS=1 outside VS Code—starting kimi will consume the parent's stack entry and leave the outer program in the wrong keyboard mode after exit until it reconfigures the terminal.
Useful? React with 👍 / 👎.
Summary
KIMI_CLI_DISABLE_KITTY_KEYSto force the behavior elsewhere.Testing
Closes #1437
Summary
KIMI_CLI_DISABLE_KITTY_KEYSto force the behavior elsewhere.Testing
Closes #1437