Make BlocklistAiAinputModel surface agnostic#13333
Conversation
1d3fc30 to
ac50bee
Compare
5205fea to
63ad782
Compare
ac50bee to
52658fc
Compare
8bb92ac to
dd2d631
Compare
bec8c91 to
d0c2d95
Compare
dd2d631 to
2300f7c
Compare
d0c2d95 to
b140ab5
Compare
2300f7c to
3fd1d55
Compare
b140ab5 to
4ddf203
Compare
|
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 |
BlocklistAIInputModel consulted GUI-only state (FeatureFlag::AgentView, fullscreen-vs-terminal context, CLI agent sessions) directly in five places, which made the model unusable from the TUI frontend: the AI-lock gate silently rejects locked-AI configs and the reactive subscriptions rewrite the config based on GUI product rules. Following the ConversationSelection injection pattern, extract those decisions into a view-supplied InputModePolicy trait: - GuiInputModePolicy transplants the existing branches verbatim (no behavior change). - TuiInputModePolicy gives the TUI a deterministic agent-first config. See specs/input-mode-policy/TECH.md. Co-Authored-By: Oz <oz-agent@warp.dev>
4ddf203 to
4898f7e
Compare
There was a problem hiding this comment.
Overview
This PR extracts BlocklistAIInputModel's surface-specific input-mode decisions into an injected InputModePolicy, wires GUI and TUI policy implementations, adds model-level tests, and includes a tech spec for the refactor.
Concerns
- The PR changes user-facing TUI/input-mode behavior but the description does not include screenshots or a recording; repo guidance requires visual evidence for manually testable user-facing changes.
- The added tech spec's validation section claims new
warp_tuiinput-mode policy unit tests, but the diff only addsapp/src/ai/blocklist/input_model_tests.rs; either add the promised TUI policy tests or correct the validation section. spec_context.mdreports no approved or repository spec context for this PR, so no external spec-drift concern was identified.
Verdict
Found: 0 critical, 1 important, 1 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
|
|
||
| impl InputModePolicy for TuiInputModePolicy { | ||
| fn initial_config(&self, _app: &AppContext) -> InputConfig { | ||
| InputConfig { |
There was a problem hiding this comment.
| ## Testing and validation | ||
|
|
||
| - This is a no-behavior-change refactor for the GUI: `app/src/terminal/input_tests.rs` (~43 references) exercises every input-mode flow (⌘I toggle, `!` prefix, `&` handoff, ctrl-c reset, history selection, workflow insertion, attachment locking) through the real `Input` view and must pass with **no assertion changes**. Same for `app/src/terminal/view_tests.rs` and `queued_prompts_tests.rs`. | ||
| - New `input_mode_policy` unit tests in `warp_tui` assert the TUI policy's determinism: initial `{AI, locked}` sticks (the old gate would have rejected it), and reactive hooks leave the config untouched across conversation activate/deactivate. |
There was a problem hiding this comment.
💡 [SUGGESTION] This validation item says new warp_tui input-mode policy unit tests were added, but the diff only adds app/src/ai/blocklist/input_model_tests.rs. Either add the promised TUI policy tests or update the validation section to match the actual coverage.

Description
BlocklistAIInputModelis shared between frontends, but its input-mode decisions were GUI-shaped: the initial config, the locked-AI gate, and the reactive transitions on conversation-selection and AI-settings events all consulted GUI-only state inline (FeatureFlag::AgentView, fullscreen-vs-terminal checks,CLIAgentSessionsModel). For the TUI this wasn't just untidy — it was incorrect: the gate silently no-oped the TUI's desired default ({AI, locked}with no active conversation), and the reactive writes could flip a TUI surface into{Shell, locked}(e.g. on conversation deactivation with NLD disabled), which the TUI would misread as user-requested shell mode. This PR extracts those decisions into a view-suppliedInputModePolicytrait — following the same injection pattern asConversationSelection— so the GUI and TUI each answer them for their own surface while the model keeps the shared mechanism.The split is decisions-out, subscriptions-in: the model still owns the
AISettingsandConversationSelectionsubscriptions (the ~35 GUI mutator call sites rely on the model self-healing across CLI-agent-input close and agent-view enter/exit), but each subscription now just forwards the raw event to the policy and applies the returnedPolicyConfigUpdate— which bundles exactly what the previously-inlined GUI code passed to the internal setter: the config, its recorded decision source, and (for one agent-view entry path) a brief autodetection suppression. This is a pure refactor for the GUI:GuiInputModePolicytransplants each branch verbatim, and the existing input-mode test suites pass with no assertion changes.This unblocks TUI input-mode work up-stack (
specs/CODE-1805, TUI!shell mode):TuiInputModePolicystarts locked to AI, always allows it, and never reacts to conversation or settings events — when TUI autodetection ships, that one file changes.what to read
specs/input-mode-policy/TECH.md— the design doc; worth reading first.app/src/ai/blocklist/input_mode_policy.rs— the new trait. Required methods are the five decision points the model can't make view-agnostically: initial config, the locked-AI gate, the autodetection setting for the surface's current context, and the two reactive hooks. The hooks receive the raw events, so view-specific payloads (fullscreen vs. inline, entry origins) stay a concern of the implementing view. The settings hook takes the model's guarded autodetection state as abool; computing it takes the terminal-model lock, so the model only computes it forAIAutoDetectionEnabledevents.app/src/ai/blocklist/agent_view/gui_input_mode_policy.rs— the GUI policy: each method is the corresponding branch from master, moved verbatim. TheFeatureFlag::AgentViewchecks become a GUI-policy detail instead of a model detail.app/src/ai/blocklist/input_model.rs— the model after the extraction: subscriptions forward to the policy, the gate asksallows_locked_ai_input, andis_autodetection_enabled_for_current_contextkeeps only the view-agnostic guards (agent-in-control, pending attachments) layered over the policy's setting lookup.InputConfig::unlocked_if_autodetection_enabledis no longer called by the model.app/src/ai/blocklist/input_model_tests.rs— new unit tests driving the model through a configurableStubPolicy: the initial config comes from the policy (a locked-AI initial sticks — the old gate would have rejected it), locked-AI writes require policy permission, and inert policies leave the config untouched across conversation and settings events.crates/warp_tui/src/input_mode_policy.rs— the TUI policy:{AI, locked}initial, locked AI always allowed, no autodetection, both reactive hooks returnNone.Testing
./script/runScreenshots / Videos
Nothing to show yet, but things continue to work as before.
Agent Mode