Skip to content

Fix rich input trapping arrow keys in CLI Agents#10556

Merged
advait-m merged 3 commits into
warpdotdev:masterfrom
SagarSDagdu:fix/codex-rich-input-traps-arrow-keys
May 12, 2026
Merged

Fix rich input trapping arrow keys in CLI Agents#10556
advait-m merged 3 commits into
warpdotdev:masterfrom
SagarSDagdu:fix/codex-rich-input-traps-arrow-keys

Conversation

@SagarSDagdu
Copy link
Copy Markdown
Contributor

@SagarSDagdu SagarSDagdu commented May 9, 2026

Description

When running codex (or opencode without its plugin), Warp's CLI agent rich input would auto-open and trap the arrow keys meant for navigating the agent's interactive option menus, leaving users unable to make a selection.

The auto-open path assumed any detected CLI agent would later emit Blocked-state events (PermissionRequest, QuestionAsked) that auto-close the rich input when the agent needs raw keyboard input. That assumption breaks for:

  • Codex — its listener (CodexSessionHandler) only forwards opaque OSC 9 notifications as Stop and never reports Blocked. supports_rich_status() already returns false, but the auto-open / auto-toggle paths weren't checking it.
  • OpenCode without the plugin — no listener at all (listener: None), so even though the handler supports rich status, no Blocked events ever arrive.

This PR gates the three rich-input auto-toggle paths on both a registered listener AND agent_supports_rich_status(&agent), so we only auto-open when we'll be able to auto-close on Blocked. Codex's proactive listener registration is preserved (it still drives OSC 9 notification suppression and the footer chip); only the auto-open and auto-toggle behaviors are suppressed for Codex. Users can still open rich input manually via the chip or Ctrl-G.

Before the fix

https://www.loom.com/share/46351245a93a4a14aa666be81d240dc8

After the fix

https://www.loom.com/share/89b33b8b6e8b4bf6a0af9ac903a21dc8

Files touched:

  • app/src/terminal/view.rsmaybe_auto_open_cli_agent_rich_input, status-change auto-toggle in handle_cli_agent_sessions_event
  • app/src/terminal/view/use_agent_footer/mod.rsmaybe_close_rich_input_after_submit
  • app/src/terminal/view_test.rs — regression test

Linked Issue

Fixes #9059

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).

Screenshots / Videos

Attached above

Testing

Added regression test codex_status_change_does_not_auto_open_rich_input (app/src/terminal/view_test.rs) that asserts a Codex session with should_auto_toggle_input: true and a registered listener does not re-open rich input on a Stop status event — the only status Codex's handler emits.

Existing related tests still pass:

  • status_blocked_auto_closes_rich_input
  • status_in_progress_auto_opens_rich_input_after_blocked
  • submit_with_plugin_and_auto_toggle_keeps_rich_input_open
  • submit_with_plugin_but_auto_toggle_off_respects_auto_dismiss

All 140 cli-agent-related unit tests pass. cargo fmt and cargo clippy -p warp --all-targets -- -D warnings are clean.

Manually verified on a local debug build:

  • codex no longer auto-opens rich input; arrow keys reach Codex's option menus.
  • claude still auto-opens rich input and auto-closes on permission prompts (regression check).
  • Manual open via the rich input chip / Ctrl-G still works for Codex.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Auto-toggle of the CLI agent rich input relies on plugin-emitted
Blocked-state events (PermissionRequest, QuestionAsked) to close the
editor when the agent needs raw keyboard input. Codex's listener only
forwards opaque OSC 9 notifications as Stop and never reports Blocked,
so rich input would stay open over Codex's option menus and trap the
arrow keys meant for selection. OpenCode without its plugin had no
listener at all and hit the same problem.

Gate the three auto-toggle paths on `agent_supports_rich_status` and
listener presence so we only auto-open the editor when we can also
auto-close on Blocked. Codex's listener registration is preserved so
OSC 9 notifications still flow; users can still open rich input
manually via the chip or Ctrl-G.

Fixes warpdotdev#9059
@cla-bot cla-bot Bot added the cla-signed label May 9, 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 9, 2026
@SagarSDagdu SagarSDagdu marked this pull request as ready for review May 9, 2026 12:36
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 9, 2026

@SagarSDagdu

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

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @Advait-M.

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

Powered by Oz

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 gates rich-input auto-open and status-driven auto-toggle on sessions that both have a registered listener and report rich status, preventing Codex/OpenCode-no-plugin flows from trapping arrow keys while preserving auto-toggle for rich-status agents.

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 a review from advait-m May 9, 2026 12:41
@SagarSDagdu
Copy link
Copy Markdown
Contributor Author

@advait-m Could you take a look please?

@advait-m
Copy link
Copy Markdown
Member

@advait-m Could you take a look please?

will do!

@advait-m
Copy link
Copy Markdown
Member

hmm @SagarSDagdu do you have this setting turned on?

image

Is this still an issue for you if you turn this setting off? In Agents > Third party CLI agents

@advait-m
Copy link
Copy Markdown
Member

advait-m commented May 12, 2026

I'm leaning towards removing the change from maybe_auto_open_cli_agent_rich_input which is explicitly requested by user in preferences (we default off) but we can leave in handle_cli_agent_sessions_event and maybe_close_rich_input_after_submit changes perhaps, which are both plugin-dependent (which we default on, only takes effect if you have plugin installed) @SagarSDagdu

i.e. if the user explicitly wants auto-open on CLI agent start (which is non-default), that should always happen. But, we should fix the default case with plugin

cc @harryalbert for thoughts

@advait-m
Copy link
Copy Markdown
Member

for context - our defaults for these settings:

image

`auto_open_rich_input_on_cli_agent_start` is a default-off user
preference — when the user explicitly opts in, respect it for all
agents. The plugin-driven auto-toggle and auto-dismiss paths
(default-on, plugin-gated) still need the rich-status check so they
don't trap arrow keys for Codex.
@SagarSDagdu
Copy link
Copy Markdown
Contributor Author

I'm leaning towards removing the change from maybe_auto_open_cli_agent_rich_input which is explicitly requested by user in preferences (we default off) but we can leave in handle_cli_agent_sessions_event and maybe_close_rich_input_after_submit changes perhaps, which are both plugin-dependent (which we default on, only takes effect if you have plugin installed) @SagarSDagdu

i.e. if the user explicitly wants auto-open on CLI agent start (which is non-default), that should always happen. But, we should fix the default case with plugin

cc @harryalbert for thoughts

@advait-m
Updated in 28b9581, reverted the gate on maybe_auto_open_cli_agent_rich_input so that when a user has explicitly opted into auto_open_rich_input_on_cli_agent_start (default off), we honor it for every agent regardless of plugin status.

Kept the rich-status check on the two plugin-driven paths (handle_cli_agent_sessions_event and maybe_close_rich_input_after_submit), since auto_toggle_rich_input is default-on and we'd otherwise trap arrow keys in Codex's option menus for the common case. The existing regression test (codex_status_change_does_not_auto_open_rich_input) covers the auto-toggle path.

@advait-m advait-m changed the title Fix rich input trapping arrow keys in Codex/OpenCode TUIs Fix rich input trapping arrow keys in Codex TUIs (or without plugin) May 12, 2026
Copy link
Copy Markdown
Member

@advait-m advait-m left a comment

Choose a reason for hiding this comment

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

cool, yeah I think the other 2 places make sense to update to me - will wait for CI to run and then merge

@advait-m advait-m changed the title Fix rich input trapping arrow keys in Codex TUIs (or without plugin) Fix rich input trapping arrow keys in CLI Agents May 12, 2026
@advait-m advait-m merged commit 96fc204 into warpdotdev:master May 12, 2026
29 checks passed
@advait-m
Copy link
Copy Markdown
Member

thanks for the contribution!

@SagarSDagdu SagarSDagdu deleted the fix/codex-rich-input-traps-arrow-keys branch May 14, 2026 04:04
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.

When using codex, the rich text input of warp cannot be selected

2 participants