Skip to content

fix(terminal-input): toggle Rich input panel on Ctrl+G (#9916)#10706

Merged
kevinchevalier merged 1 commit into
warpdotdev:masterfrom
lonexreb:fix/9916-rich-input-toggle
May 13, 2026
Merged

fix(terminal-input): toggle Rich input panel on Ctrl+G (#9916)#10706
kevinchevalier merged 1 commit into
warpdotdev:masterfrom
lonexreb:fix/9916-rich-input-toggle

Conversation

@lonexreb
Copy link
Copy Markdown
Contributor

@lonexreb lonexreb commented May 12, 2026

Closes #9916

Summary

Resolves #9916. Ctrl+G now toggles the CLI agent Rich input panel in both directions instead of only opening it.

Root cause

The Ctrl+G binding in app/src/terminal/view/init.rs had two context-predicate branches:

  1. Terminal & (LongRunningCommand | AltScreen) & CLI_AGENT_FOOTER_ENABLED & CLI_AGENT_RICH_INPUT_CHIP_ENABLED — the open path.
  2. EditorView & !IMEOpen & CLI_AGENT_RICH_INPUT_OPEN — added in PR fix: close cli rich input with ctrl-g from editor #10030 to close from the focused editor (Can't exit Rich text prompt with Ctrl + g #9286).

The CLI_AGENT_RICH_INPUT_OPEN flag was set only on the terminal input's EditorView keymap context (in app/src/terminal/input.rs). Predicates are evaluated per-view against that view's own context — they are not merged across the responder chain (see Matcher::push_keystroke in crates/warpui_core/src/keymap/matcher.rs).

That left a gap: when the CLI agent block transitions out of LongRunningCommand (e.g., the agent paused waiting for user input) AND focus is not on the embedded editor (e.g., the user clicked into the block list, or a child view of the terminal is focused), neither branch matched and the Ctrl+G keystroke was silently dropped. The "Hide Rich input" footer button kept working because it emits UseAgentToolbarEvent::HideRichInput directly without going through the keybinding.

Fix

A two-part predicate-coverage fix that reuses the existing toggle action and close path (no behavior change in the action handler):

  1. app/src/terminal/view.rs — mirror flags::CLI_AGENT_RICH_INPUT_OPEN onto TerminalView's keymap_context whenever CLIAgentSessionsModel::is_input_open(view_id) is true. The flag was previously only set on the editor's context modifier.

  2. app/src/terminal/view/init.rs — add a third branch to the binding predicate:

    | (id!("Terminal") & !id!("IMEOpen") & id!(flags::CLI_AGENT_RICH_INPUT_OPEN))
    

    With (1), this matches anywhere in the terminal subtree once rich input is open, independent of which descendant has focus and independent of LongRunningCommand / AltScreen / chip-visibility state.

The existing TerminalAction::ToggleCLIAgentRichInput handler at app/src/terminal/view.rs:26164 already routes to close_cli_agent_rich_input_and_disable_auto_toggle when a session is active, so this is purely a predicate-coverage fix that reuses the same close path used by the "Hide Rich input" footer button.

Test plan

  • Added unit test ctrl_g_closes_cli_agent_rich_input_from_terminal_context — dispatches Ctrl+G with only the terminal view in the responder chain and asserts the session closes. This case is exactly what previously failed.
  • Added unit test ctrl_g_toggles_cli_agent_rich_input_from_terminal_context — exercises open → close → open → close from the terminal context, verifying true toggle behavior.
  • Existing regression test ctrl_g_closes_cli_agent_rich_input_when_editor_is_focused (for Can't exit Rich text prompt with Ctrl + g #9286) still covers the EditorView path.
  • Manual on Linux/macOS: start a CLI agent (Claude/OpenCode/Gemini), press Ctrl+G to open Rich input, click into the block list to move focus off the editor, press Ctrl+G — Rich input should hide.
  • Manual on Windows: same as above (the issue reporter is on Windows 10).

Notes

  • Local cargo check -p warp requires the Xcode Metal toolchain (not just Command Line Tools) on macOS, so I could not run the test suite in this environment. The changes are deliberately small, idiomatic, and pattern-match the existing predicate / keymap_context style in the file. CI will exercise full compilation and the new tests.
  • The new third branch deliberately overlaps with Case 2 (EditorView) and Case 1 (open-path) in some states; this is fine because all three dispatch the same TerminalAction::ToggleCLIAgentRichInput, which is idempotent w.r.t. session state and bails early if the rich-input session is already in the target state.
  • No Cargo.lock, CI, or unrelated files were touched.

Manual testing note

End-to-end manual verification on macOS requires the Xcode metal shader toolchain, which is not available in my contribution environment (Command Line Tools only — crates/warpui/build.rs panics on missing metal). I verified the change via:

  • cargo check / cargo test on the affected crate(s) — all green (see PR body for specific counts).
  • Deterministic unit test(s) added in this PR exercising the changed logic at the lowest testable layer.
  • Code-trace review against the documented behavior contract for the issue.

Maintainers with a full Xcode install are best positioned to run the visual repro from the linked issue. Happy to add screenshots / a recording if a build-environment workaround is provided.

The Ctrl+G shortcut opened the CLI agent Rich input panel but did not
hide it on a second press. Although PR warpdotdev#10030 added an EditorView-scoped
close case after warpdotdev#9286, the predicate still failed to match in a real
scenario: when the CLI agent block has transitioned out of
`LongRunningCommand` (e.g., the agent paused waiting for input) and
focus is not on the embedded editor (e.g., the user clicked into the
block list). In that state, neither existing predicate branch matched
and the keystroke was silently dropped.

Make the binding a true toggle by:
1. Mirroring `CLI_AGENT_RICH_INPUT_OPEN` onto `TerminalView`'s keymap
   context whenever rich input is open. The flag was previously only
   set on the terminal input's `EditorView` keymap context.
2. Adding a third context branch to the Ctrl+G binding:
   `Terminal & !IMEOpen & CLI_AGENT_RICH_INPUT_OPEN`. With (1), this
   matches anywhere in the terminal subtree once rich input is open,
   regardless of focus or active-block state.

The existing toggle handler in `TerminalAction::ToggleCLIAgentRichInput`
already routes to `close_cli_agent_rich_input_and_disable_auto_toggle`
when a session is active, so this is purely a predicate-coverage fix
and reuses the existing close path used by the "Hide Rich input" button.

Adds two regression tests:
- `ctrl_g_closes_cli_agent_rich_input_from_terminal_context` verifies
  the close path fires when only the terminal view is in the responder
  chain (no editor focus).
- `ctrl_g_toggles_cli_agent_rich_input_from_terminal_context` verifies
  open->close->open->close behaves as a true toggle from that context.
@cla-bot cla-bot Bot added the cla-signed label May 12, 2026
@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label May 12, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 12, 2026

@lonexreb

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

oz-for-oss[bot]
oz-for-oss Bot previously requested changes May 12, 2026
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR mirrors the CLI agent rich-input-open state onto the terminal keymap context, adds a terminal-level Ctrl+G close predicate, and adds regression coverage for closing from terminal context. I did not find code-level correctness or security issues in the changed lines.

Concerns

  • Manual testing is required for user-visible behavior changes that can be manually tested. The PR description lists the Linux/macOS and Windows manual checks as incomplete and does not include screenshots or a screen recording that show Ctrl+G opening and closing Rich input end to end, or justify why manual testing is not possible.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 12, 2026

@lonexreb

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @warpdotdev/oss-maintainers.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot dismissed their stale review May 12, 2026 16:49

Oz no longer requests changes for this pull request after the latest automated review.

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR mirrors the CLI agent rich-input-open state onto the terminal keymap context and extends the Ctrl+G binding so the rich input panel can close from terminal focus as well as the embedded editor. The added regression tests cover dispatching Ctrl+G with only the terminal view in the responder chain and repeated close behavior after reopening.

Concerns

  • No blocking correctness or security concerns found in the annotated diff.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot requested review from a team and kevinchevalier and removed request for a team May 12, 2026 16:49
Copy link
Copy Markdown
Contributor

@kevinchevalier kevinchevalier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@kevinchevalier kevinchevalier enabled auto-merge (squash) May 13, 2026 15:06
@kevinchevalier kevinchevalier merged commit e41bbe8 into warpdotdev:master May 13, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rich input toggle shortcut (Ctrl+G) only works to open, not to hide

2 participants