Skip to content

spec: built-in /review slash command (#9606)#10014

Open
lonexreb wants to merge 1 commit intowarpdotdev:masterfrom
lonexreb:spec/9606-review-command
Open

spec: built-in /review slash command (#9606)#10014
lonexreb wants to merge 1 commit intowarpdotdev:masterfrom
lonexreb:spec/9606-review-command

Conversation

@lonexreb
Copy link
Copy Markdown
Contributor

@lonexreb lonexreb commented May 4, 2026

Adds a product+tech spec for #9606: a built-in /review slash command in Agent input that gathers local uncommitted changes and asks the Agent for a focused code review.

Files

  • specs/GH9606/product.md (108 lines) — V1 scope, user experience, fixed prompt template, 10 testable behavior invariants
  • specs/GH9606/tech.md (160 lines) — module layout, dispatch arm, diff-gathering helper, settings entry, end-to-end flow

Total: 383 insertions, 0 deletions. No code changes — this is a spec PR.

Why this command

Per the issue: users today get AI feedback on uncommitted changes by improvising — manual prompts ("can you review my changes?"), pasting diffs into the conversation, or building reusable skills. /review makes this discoverable as a built-in command that sits naturally next to the existing /init, /index, /fork, /open-code-review, and /pr-comments static commands.

V1 scope

  • New StaticCommand entry in app/src/search/slash_command_menu/static_commands/commands.rs alongside the existing crew.
  • Diff source: git diff HEAD --no-color (tracked, staged + unstaged) + synthesized /dev/null diffs for untracked files (respecting .gitignore via git ls-files --others --exclude-standard).
  • Truncation cap: default 50 KB (configurable 1 KB – 1 MB via ai.review_command_max_diff_bytes); over-cap diffs preserve shortest files first and the prompt notes the truncation explicitly.
  • Fixed V1 prompt template prioritizing the issue's stated focus (logic bugs → security → performance → simplicity → maintainability), with a "skip nits unless they hurt readability" line and an "if uncertain, say so" line to keep the V1 review tight.
  • Availability gate: REPOSITORY | AI_ENABLED | HAS_UNCOMMITTED_CHANGES (new flag, riding the existing file-tree-change cache that already powers the Code Review panel's empty state).

Out of V1 (tracked as follow-ups)

  • Commit-range review (/review HEAD~3..HEAD)
  • User-customizable prompt template (per-repo .warp/review-template.md)
  • Per-file scope (/review src/auth/)
  • Streaming summary→deep-dive multi-turn pattern
  • Diff redaction layer for sensitive content (mirrors existing command-output redaction)
  • "Re-review" affordance after follow-ups

Why this spec

  • Issue is ready-to-spec, no existing PR claims it.
  • Implementation surface is genuinely small: one new StaticCommand const, one dispatch arm, one diff-gathering helper module, one settings entry, one new Availability flag. Reuses existing agent-turn submission, telemetry, and Availability cache.
  • The pattern is already well-established by /init (also constructs an agent prompt and submits it).
  • Aligns with Warp's positioning as an agentic development environment — the issue calls this out explicitly, and the Project Explorer is on the critical path for navigation, but proactive AI review is also a high-frequency workflow.

Open questions for maintainers

  1. Untracked-file inclusion. V1 includes them via synthesized new-file diffs (matches colloquial "uncommitted changes"); excluding would silently drop new-file changes from review. Confirm this is the right default.
  2. Conversation routing. /review is specced as reuse-active-or-create-new (matches the default agent prompt path), so follow-ups attach without proliferating conversations.
  3. Settings group. This spec uses ai.review_command_max_diff_bytes. Confirm AISettings is the right Rust group at implementation time.

Happy to iterate on the design or tighten the V1 scope further.

Adds product.md and tech.md for issue warpdotdev#9606: a built-in /review slash
command in Agent input that gathers uncommitted local changes and asks
the agent for a focused code review.

V1 scope:
- New StaticCommand entry alongside /init, /index, /open-code-review
- Diff gathered via `git diff HEAD --no-color` (tracked) +
  synthesized /dev/null diffs for untracked files (respecting .gitignore
  via `git ls-files --others --exclude-standard`)
- Truncation cap (default 50KB, configurable 1KB-1MB) with
  shortest-files-first preservation when over cap
- Fixed V1 review prompt template prioritizing logic bugs, security,
  performance, simplicity, maintainability per the issue's stated focus
- Availability gate: REPOSITORY | AI_ENABLED | HAS_UNCOMMITTED_CHANGES
  (new flag, ridding the existing file-tree-change cache)

Out of V1 (tracked as follow-ups):
- Commit-range review (`/review HEAD~3..HEAD`)
- User-customizable prompt template
- Per-file scope (`/review src/auth/`)
- Streaming summary→deep-dive
- Diff redaction layer for sensitive content
- "Re-review" affordance after follow-ups

10 testable behavior invariants, each mapped to a test layer in tech.md.

Implementation surface is small: one StaticCommand const, one dispatch
arm, one new diff-gathering helper module, one settings entry, one new
Availability flag. Reuses existing agent turn submission, telemetry,
and Availability cache infrastructure.
@cla-bot cla-bot Bot added the cla-signed label May 4, 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 4, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 4, 2026

@lonexreb

I'm starting a first review of this spec-only 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

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 spec proposes a built-in /review slash command that gathers local uncommitted Git changes and submits them to the Agent for focused review. The product and tech specs cover the user flow, prompt template, diff gathering, settings, risks, and test plan.

Concerns

  • The spec has internal contradictions around untracked-only changes and where truncation notices appear in the fixed prompt.
  • The tech plan does not match the current slash-command dispatch and availability model, so an implementation following it would either fail to wire correctly or fail the promised disabled-state UX.

Security

  • The V1 design intentionally sends full diff contents, including untracked file contents, to the agent provider while deferring redaction; the spec should define a concrete V1 guardrail or user-visible disclosure before implementation.

Verdict

Found: 0 critical, 5 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

Comment thread specs/GH9606/product.md

## Prompt template (fixed in V1)

The agent prompt assembled by `/review` is, byte-for-byte:
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] The prompt cannot be byte-for-byte fixed while also including the required truncation note; define the exact conditional paragraph/placement so invariant 4 is implementable.

Comment thread specs/GH9606/product.md
4. When the gathered diff exceeds `ai.review_command_max_diff_bytes`, the prompt's diff content is truncated (longest files first), and the prompt body contains the literal substring `"This diff was truncated"`.
5. The diff content is wrapped between the literal markers `[BEGIN DIFF]` and `[END DIFF]` exactly once each.
6. The command's `Availability` flags include `REPOSITORY | AI_ENABLED` (matching the pattern set by `/init`).
7. If the user has uncommitted changes only in untracked (new) files — i.e. files Git does not yet know about — the command still gathers them (via `git diff HEAD --no-color --binary` plus the file contents for new files via the existing change-detection path).
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] This untracked-only invariant conflicts with the earlier tracked-file availability requirement; specify whether HAS_UNCOMMITTED_CHANGES includes untracked files and make the palette behavior match.

Comment thread specs/GH9606/tech.md

**File:** `app/src/terminal/input/slash_commands/mod.rs`.

The dispatch path that consumes `SlashCommandId` already has a switch over the registry's identifiers. Add an arm:
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] The current dispatcher matches command.name in execute_slash_command, and SlashCommandId is an opaque UUID rather than an enum; update the dispatch design so implementers do not add a nonexistent SlashCommandId::Review arm.

Comment thread specs/GH9606/tech.md

**File:** `app/src/search/slash_command_menu/static_commands/mod.rs`.

The existing `Availability` bitflags struct gets one more flag. The condition is true when the active session's CWD is inside a Git repo *and* `git status --porcelain` returns at least one entry. Existing `Availability` flags are checked at palette-render time via cached `WorkspaceState` flags (find the cache via `grep -rn "Availability::REPOSITORY" app/src/`). The new flag rides the same cache; the cache is invalidated when the working tree changes (which the file-tree observer already tracks for the existing Code Review panel).
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] Adding HAS_UNCOMMITTED_CHANGES as an Availability bit will hide /review when false because the data source filters inactive commands; either spec disabled-item support or change the no-changes UX to absence/toast-only.

Comment thread specs/GH9606/tech.md

## Risks

- **Diff payload as a security surface.** The diff is sent to the agent provider verbatim, including any secrets a developer accidentally committed locally (`.env` files, tokens in fixtures, etc.). **Mitigation:** the V1 prompt is silent about this; the existing AI privacy posture applies. Long-term, the existing redaction infrastructure (used for command output) could be applied to diffs — tracked as a follow-up. Document the risk in the docs page.
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] [SECURITY] Deferring redaction while sending full tracked and untracked diff contents verbatim leaves no V1 guardrail for secrets; specify redaction, an explicit confirmation/disclosure, or exclusions before implementation.

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.

1 participant