Keep saved Agent Mode prompts in AI mode instead of running them as shell commands#13125
Keep saved Agent Mode prompts in AI mode instead of running them as shell commands#13125warp-dev-github-integration[bot] wants to merge 2 commits into
Conversation
…hell commands Selecting an Agent Mode saved prompt from the slash menu could leave the terminal input in (or be reclassified to) Shell mode, so pressing Enter ran the prompt text as a terminal command (landing at a quote> continuation). Anchor the input to AI mode on agent-mode workflow insertion and suppress NLD for the lifetime of the composed prompt; clear the anchor on submit, manual toggle, or buffer clear. Co-Authored-By: Oz <oz-agent@warp.dev>
|
@warp-dev-github-integration[bot] 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 Powered by Oz |
There was a problem hiding this comment.
Overview
This PR anchors saved Agent Mode workflow prompts to AI mode so natural-language detection cannot reclassify the composed prompt as a shell command, and adds regression coverage for selection, NLD suppression, shell workflows, manual toggles, and buffer clearing.
Concerns
- The anchor cleanup currently relies on
handle_input_buffer_submitted, but the AgentView terminal submission path emitsEnterAgentViewand returns before that handler runs, so a submitted saved prompt can leave the anchor active and keep suppressing NLD after the prompt is sent. - This is a user-facing terminal/Agent Mode behavior change, but the PR only says screenshots were posted in Slack; please attach screenshots or a short recording to the PR so reviewers have end-to-end visual evidence.
Verdict
Found: 0 critical, 2 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
|
|
||
| /// Handles the input buffer being submitted. | ||
| pub fn handle_input_buffer_submitted(&mut self, ctx: &mut ModelContext<Self>) { | ||
| // Submitting consumes the composed prompt, so any Agent Mode prompt anchor is done. |
There was a problem hiding this comment.
submit_ai_query emits EnterAgentView and returns before calling handle_input_buffer_submitted, so a saved prompt submitted from terminal can leave the anchor active and keep suppressing NLD after the prompt is sent. Clear the anchor before emitting EnterAgentView or in the AgentView entry handler.
There was a problem hiding this comment.
Fixed in 0fa933d — the anchor is now cleared in the AgentView EnteredAgentView/ExitedAgentView handlers, so it no longer outlives a terminal submit that enters the agent view before handle_input_buffer_submitted runs. Added regression test agent_mode_saved_prompt_anchor_cleared_when_entering_agent_view covering that exact path.
Addresses review feedback: the terminal submit path (submit_ai_query) enters the agent view and returns before handle_input_buffer_submitted runs, so a submitted saved prompt could leave the anchor active and keep suppressing NLD afterward. Clear the anchor in the AgentView enter/exit handlers, and add a regression test covering the submit-enters-agent-view path. Co-Authored-By: Oz <oz-agent@warp.dev>
|
Addressed in |
|
be less verbose on the comment; comment should be concise |
|
Good call — trimmed the comment above. |
Description
Saved Agent Mode prompts invoked from the
/slash menu could end up running as terminal commands instead of being sent to the agent. After selecting a saved prompt and filling in its argument (e.g. pasting a PR link), pressing Enter executed the prompt text in the shell — landing the user at aquote>continuation when the prompt contained an apostrophe.Root cause:
Input::insert_workflow_into_inputset AI mode for agent-mode workflows viaset_input_type, which preserves the current lock state and only suppresses NLD for 250ms. Under the AgentView / NLD-in-terminal rollout this broke two ways:{Shell, locked}, so the request became{AI, locked}— which the AgentView terminal-mode guard inset_input_config_internalrejects as a no-op. The input stayed in Shell mode. (Dominant case.){AI, unlocked}, so once the 250ms window elapsed, editing/pasting the argument re-ran the classifier, which reclassified the command-like prompt back to Shell.Fix: Agent Mode saved prompts are never terminal commands, so on insertion (when AgentView is enabled) the input is now anchored to AI mode via a new
agent_prompt_ai_anchoronBlocklistAIInputModel. While the anchor is active,is_autodetection_enabled_for_current_contextreturnsfalse, fully suppressing NLD so the composed prompt and its argument can't be reclassified to Shell. The anchor sets{AI, unlocked}(which passes the guard) and is cleared on submit, manual mode toggle (cmd+I), or when the buffer is cleared (prompt abandoned). The legacy AgentView-off path keeps its original behavior.Linked Issue
Reported in the factory-client triage thread (Slack). N/A GitHub issue.
ready-to-specorready-to-implement.Testing
Added regression tests in
app/src/terminal/input_tests.rs:agent_mode_saved_prompt_selection_enters_ai_mode_in_terminal— selecting an agent-mode prompt enters AI mode with NLD-in-terminal off (fails before this fix; the input stayed Shell).agent_mode_saved_prompt_anchor_suppresses_nld_when_terminal_nld_enabled— with NLD on, the anchor keeps AI mode andshould_run_input_autodetectionis false.shell_workflow_selection_stays_in_shell_mode— shell workflows are unaffected (no anchor, stays Shell).agent_mode_saved_prompt_anchor_cleared_on_manual_toggle_to_shell— cmd+I → Shell clears the anchor.agent_mode_saved_prompt_anchor_cleared_when_buffer_cleared— abandoning the prompt resets to Shell../script/formatandcargo clippy -p warp --all-targets --tests -- -D warningspass. New + related tests pass viacargo nextest run -p warp.Manually verified end-to-end with
cargo run --bin warp(signed-in dogfood build) driving the real UI, in BOTH NLD-off and NLD-on: selecting the saved prompt keeps the input in Agent mode, filling the{{branch}}argument no longer flips it to Shell, and Enter starts an agent conversation (noquote>). Confirmed cmd+I still toggles to Shell.Screenshots / Videos
Before (bug) and after (fix) screenshots were posted to the originating Slack thread.
Agent Mode
CHANGELOG-BUG-FIX: Fixed saved Agent Mode prompts invoked from the slash menu being run as terminal commands instead of being sent to the agent.
Conversation: https://staging.warp.dev/conversation/073f5a22-1e86-4568-b287-4965cc235ad4
Run: https://oz.staging.warp.dev/runs/019f03bb-508c-7d53-b42a-adf1d6a3a183
This PR was generated with Oz.