Skip to content

feat(llm,keymap): Ctrl+Up/Down jump focus between chat panel and shell#77

Merged
fentas merged 2 commits into
masterfrom
feat/chat-prompt-focus-jump
May 18, 2026
Merged

feat(llm,keymap): Ctrl+Up/Down jump focus between chat panel and shell#77
fentas merged 2 commits into
masterfrom
feat/chat-prompt-focus-jump

Conversation

@fentas
Copy link
Copy Markdown
Owner

@fentas fentas commented May 18, 2026

Summary

While the inline chat panel is open, allow the user to type into the SHELL PROMPT above the panel WITHOUT closing the chat.

Today every keystroke is swallowed into the chat input buffer; user has to press Alt+C to close, type the shell command, reopen with Alt+C — clunky.

New flow:

  • Ctrl+Up — focus jumps to shell prompt; panel stays painted but dims its block cursor + input row.
  • Ctrl+Down — focus jumps back into the panel.
  • Alt+C — closes the panel as before; on next open, focus starts back in the panel (parked-state doesn't leak across sessions).

Implementation

  • New `Runtime.chat_focus_in_panel: bool = true`.
  • Two new `Action` enum variants: `chat_focus_to_shell`, `chat_focus_to_chat`.
  • Dual-encoded bindings: legacy `\x1b[1;5A` / `\x1b[1;5B` + kitty-kbd via `key("Ctrl+Up")` / `key("Ctrl+Down")`.
  • `onInput` swallows only when `chat_inline_open AND chat_focus_in_panel`. While parked, returns `.forward` so the keystroke flows through to bash.
  • `paintInlineChat` reads the focus flag — parked → real cursor shown (`?25h`), input row chrome dimmed, block-cursor glyph drawn as a dim outline (`▒`) instead of bright reverse-video.
  • Action handler refuses to consume Ctrl+Up/Ctrl+Down when the panel isn't open, so the keystroke flows through for tmux pane navigation / shell history scroll / etc.

Test plan

  • `zig build test` — 511/511 pass (2 new tests: focus-toggle round-trip + close-then-reopen reset)
  • `zig fmt --check` — clean
  • Manual: open Alt+C, type into chat, press Ctrl+Up, type into bash, press Ctrl+Down, resume typing into chat

🤖 Generated with Claude Code

fentas and others added 2 commits May 18, 2026 09:23
User-requested polish: while the inline chat panel is open, the user
wants to type into the SHELL PROMPT above the panel WITHOUT closing
the chat. Today every keystroke is swallowed into the chat input
buffer; user has to press Alt+C to close, type the shell command,
reopen with Alt+C — clunky.

New flow:

  Ctrl+Up   — focus jumps to shell prompt (panel stays painted,
              dims its block-cursor + input row to signal "parked").
  Ctrl+Down — focus jumps back into the panel.
  Alt+C     — closes the panel (as before); on next open, focus
              starts back in the panel (parked-state doesn't leak
              across sessions).

Implementation:

  - New `Runtime.chat_focus_in_panel: bool = true` field.
  - Two new keymap actions (`chat_focus_to_shell`, `chat_focus_to_chat`)
    with dual-encoded bindings (legacy CSI `\x1b[1;5A/B` + kitty
    kbd via `key("Ctrl+Up")` / `key("Ctrl+Down")`).
  - `onInput` only swallows when both `chat_inline_open` AND
    `chat_focus_in_panel`. While parked, returns `.forward` so the
    keystroke flows through to bash.
  - `paintInlineChat` reads the focus flag: parked → real cursor
    shown (`?25h`), input row chrome dimmed, block-cursor glyph
    drawn as a dim outline (`▒` instead of reverse-video block).
  - Action handler refuses to consume Ctrl+Up/Ctrl+Down when the
    panel isn't open — so the keystroke flows through for tmux pane
    navigation / shell history scroll / whatever.

2 new tests cover: focus-toggle round-trip + forwarding-while-parked +
no-op-without-panel; on-close-then-reopen focus resets to in-panel.

`zig build test` (511 pass) + `zig fmt --check` clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@fentas fentas merged commit 244abb4 into master May 18, 2026
3 checks passed
@fentas fentas deleted the feat/chat-prompt-focus-jump branch May 18, 2026 07:26
@github-actions github-actions Bot mentioned this pull request May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant