warpdotdev/warp · warning

Attempted to accept diff in view-only mode

Error message

Attempted to accept diff in view-only mode

What it means

`try_accept_action_with_selection` refuses to accept a diff while `CodeDiffState::ViewOnly` is active (a read-only diff view, e.g. a passive/shared diff). Acceptance is only legal in states that own an actionable edit; the guard also fires `report_error!` to Sentry, because reaching it means the UI let an accept action through that should have been impossible.

Source

Thrown at app/src/ai/blocklist/inline_action/code_diff_view.rs:949

        self.pending_diffs = pending_diffs;
        ctx.emit(CodeDiffViewEvent::LoadedDiffs);
        ctx.notify();
    }

    pub fn try_accept_action(&mut self, ctx: &mut ViewContext<Self>) {
        let _ = self.try_accept_action_with_selection(AcceptSelection::Only, ctx);
    }

    /// Attempts to accept the diff and returns Ok(()) if the accept flow was initiated.
    /// Returns Err when acceptance is disallowed (e.g. view-only mode).
    fn try_accept_action_with_selection(
        &mut self,
        selection: AcceptSelection,
        ctx: &mut ViewContext<Self>,
    ) -> Result<()> {
        if matches!(self.state, CodeDiffState::ViewOnly { .. }) {
            report_error!("Attempted to accept diff in view-only mode");
            return Err(anyhow::anyhow!(
                "Attempted to accept diff in view-only mode"
            ));
        }

        match selection {
            AcceptSelection::Only => {
                send_telemetry_from_ctx!(
                    RequestFileEditsTelemetryEvent::EditAcceptClicked(EditAcceptClickedEvent {
                        identifiers: self.identifiers.clone(),
                        passive_diff: self.is_passive,
                    }),
                    ctx
                );
            }
            AcceptSelection::AndContinueWithAgent => {
                send_telemetry_from_ctx!(
                    RequestFileEditsTelemetryEvent::EditAcceptAndContinueClicked(
                        EditAcceptAndContinueClickedEvent {

View on GitHub (pinned to e72fd7aacb)

Solutions

  1. Gate accept affordances (buttons, shortcuts, palette entries) on the diff state before invoking — derive their availability from the same check
  2. Hide or disable the accept control whenever the view enters CodeDiffState::ViewOnly
  3. Unbind or reroute accept commands away from view-only diff views
  4. Treat a Sentry hit from this guard as a caller bug to fix, not noise to silence

Example fix

// before
let _ = self.try_accept_action_with_selection(AcceptSelection::Only, ctx);

// after: skip the attempt entirely in view-only mode
if !matches!(self.state, CodeDiffState::ViewOnly { .. }) {
    let _ = self.try_accept_action_with_selection(AcceptSelection::Only, ctx);
}
Defensive patterns

Strategy: type-guard

Validate before calling

if matches!(self.state, CodeDiffState::ViewOnly { .. }) {
    return; // accept is not offered in view-only mode
}

Type guard

fn can_accept_diff(state: &CodeDiffState) -> bool {
    !matches!(state, CodeDiffState::ViewOnly { .. })
}

Try / catch

if let Err(e) = self.try_accept_action_with_selection(selection, ctx) {
    if e.to_string().contains("view-only") {
        ctx.notify(); // guarded no-op: keep UI consistent, do not escalate
    } else {
        report_error!(e);
    }
}

Prevention

When it happens

Trigger: An accept command (AcceptSelection::Only or the accept-all path, via keyboard shortcut, button, or action dispatch) executes while the diff view is in ViewOnly state — e.g. a passive diff kept alive after its action completed, or a stale keybinding routed to a read-only diff view.

Common situations: Stale keyboard shortcut handling after a view transitions to view-only; accept button not hidden when the state changes; scripted/automation flows invoking accept on a review-only diff.

Related errors


AI-assisted analysis of warpdotdev/warp@e72fd7aacb (2026-08-16). Data as JSON: /api/errors/bd8bbac7bf87aa37. Report an issue: GitHub.