Skip to content

Keep saved Agent Mode prompts in AI mode instead of running them as shell commands#13125

Open
warp-dev-github-integration[bot] wants to merge 2 commits into
masterfrom
factory/saved-prompt-ai-mode
Open

Keep saved Agent Mode prompts in AI mode instead of running them as shell commands#13125
warp-dev-github-integration[bot] wants to merge 2 commits into
masterfrom
factory/saved-prompt-ai-mode

Conversation

@warp-dev-github-integration

@warp-dev-github-integration warp-dev-github-integration Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

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 a quote> continuation when the prompt contained an apostrophe.

Root cause: Input::insert_workflow_into_input set AI mode for agent-mode workflows via set_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:

  • NLD-in-terminal OFF (default): the terminal input starts {Shell, locked}, so the request became {AI, locked} — which the AgentView terminal-mode guard in set_input_config_internal rejects as a no-op. The input stayed in Shell mode. (Dominant case.)
  • NLD-in-terminal ON: the input was {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_anchor on BlocklistAIInputModel. While the anchor is active, is_autodetection_enabled_for_current_context returns false, 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.

  • 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.

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 and should_run_input_autodetection is 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/format and cargo clippy -p warp --all-targets --tests -- -D warnings pass. New + related tests pass via cargo 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 (no quote>). Confirmed cmd+I still toggles to Shell.

  • I have manually tested my changes locally

Screenshots / Videos

Before (bug) and after (fix) screenshots were posted to the originating Slack thread.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI 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.

…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>
@cla-bot cla-bot Bot added the cla-signed label Jun 27, 2026
@oz-for-oss

oz-for-oss Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

@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 /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 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 emits EnterAgentView and 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ [IMPORTANT] Clearing the anchor here misses the AgentView terminal submit path: 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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>
@warp-dev-github-integration

warp-dev-github-integration Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in 0fa933d9: the AI-mode anchor is now cleared in the AgentView enter/exit handlers — covering the terminal submit → enter-agent-view path that bypassed handle_input_buffer_submitted — plus a regression test. Before/after screenshots are in the linked Slack thread.

@evelyn-with-warp

Copy link
Copy Markdown
Contributor

be less verbose on the comment; comment should be concise

@warp-dev-github-integration

Copy link
Copy Markdown
Contributor Author

Good call — trimmed the comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants