Initial public release of Warp.
Repo-Sync-Origin: warpdotdev/warp-internal@12af1d983b
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
# CLI Agent Rich Input: @ Context Product Spec
|
||||
|
||||
## Summary
|
||||
Add support for `@` context (files, folders, and code symbols) in the CLI agent rich input composer — the input that appears when composing a prompt to send to a running CLI agent (Claude Code, Codex, Gemini CLI, etc.). Selected items are inserted as repo-relative paths.
|
||||
|
||||
## Problem
|
||||
When users compose prompts for CLI agents through Warp's rich input (Ctrl-G or the Compose button), they cannot reference files or code symbols. Users must manually type file paths without any discovery or autocomplete. The normal Warp agent input supports `@` context, but the CLI agent input does not.
|
||||
|
||||
The core constraint is that CLI agent input writes plain text to a PTY — so `@` context must resolve to a plain text path that the CLI agent can interpret.
|
||||
|
||||
## Goals
|
||||
- Let users attach file, folder, and code symbol paths via `@` in the CLI agent rich input.
|
||||
- Insert repo-relative paths as plain text.
|
||||
- Hide Warp-specific `@` context categories that CLI agents cannot interpret.
|
||||
|
||||
## Non-goals
|
||||
- Supporting `@` context types other than files/folders and code symbols (e.g., Blocks, Workflows, Diff Sets, Notebooks). These are Warp-specific concepts that CLI agents cannot interpret.
|
||||
|
||||
## Figma
|
||||
https://www.figma.com/design/CsBdBW4YoLgSAbr5eSkwV6/House-of-Agents?node-id=7001-18001&p=f&m=dev
|
||||
|
||||
## User Experience
|
||||
|
||||
### Trigger
|
||||
User types `@` anywhere in the CLI agent rich input. This works regardless of position in the buffer — including when the input starts with a mode-switch prefix like `!` (bash mode in Claude Code) or `&` (background mode). The `@` trigger is not restricted to AI-mode input.
|
||||
|
||||
### Limitation
|
||||
`@` context is only available in local sessions. It is not supported in SSH/remote contexts because file search and code symbol indexing rely on local filesystem access.
|
||||
|
||||
### Menu
|
||||
The AI context menu opens showing the available categories: files/folders and code symbols. These are the only categories relevant for CLI agents — all Warp-specific categories (Blocks, Workflows, Notebooks, Diff Sets, Conversations, etc.) are hidden.
|
||||
|
||||
### Search
|
||||
The user can type after `@` to filter file results, reusing the existing file search logic. For example, typing `@foo` filters to files matching "foo" (e.g., `footer.rs`, `foo_bar.py`). This is the same search behavior already implemented for the file data source in the AI context menu.
|
||||
|
||||
### Selection
|
||||
When the user selects a file or folder, the repo-relative path is inserted into the input buffer as plain text followed by a trailing space (e.g., `src/foo.rs `). The trailing space lets the user continue typing immediately. CLI agents typically reference files relative to the project root, so repo-relative paths are concise and consistent with how these tools handle file references. If the file is outside the project tree, fall back to an absolute path. No special chip or token rendering is needed.
|
||||
|
||||
When the user is outside a git repository, the menu shows files from the current working directory (matching existing Warp behavior). Paths are relative to pwd in this case. This is the existing `CurrentFolderFiles` vs `RepoFiles` distinction in the AI context menu.
|
||||
|
||||
### Submission
|
||||
The inserted file path is part of the plain text written to the PTY. No special processing is needed at submit time.
|
||||
|
||||
### Edge cases
|
||||
- Paths with spaces should be inserted as-is (the CLI agent will interpret them in the context of the surrounding prompt text, not as shell arguments).
|
||||
- If no files are found (e.g. empty directory), the menu should show its standard empty state.
|
||||
|
||||
## Success Criteria
|
||||
- Users can type `@` in the CLI agent rich input, see file/folder and code symbol results, select one, and have the repo-relative path inserted as text.
|
||||
- Warp-specific `@` context categories do not appear in the menu.
|
||||
- This feature is only available in local sessions, not SSH/remote.
|
||||
|
||||
## Validation
|
||||
- Open a CLI agent rich input while Claude Code is running. Type `@`, verify files/folders and code symbols categories appear (no Warp-specific categories), select a file, verify the repo-relative path is inserted.
|
||||
- Verify `@foo` filters files by name.
|
||||
- Verify `@` works after `!` prefix in the buffer.
|
||||
- Verify that Warp-specific context categories (Blocks, Workflows, etc.) do not appear.
|
||||
- Verify that `@` context is not available in SSH/remote sessions.
|
||||
@@ -0,0 +1,64 @@
|
||||
# CLI Agent Rich Input: @ Context Technical Spec
|
||||
|
||||
## Summary
|
||||
This spec covers implementing `@` context (files, folders, code symbols) in the CLI agent rich input composer. The approach reuses the existing AI context menu with mode-based category filtering, restricting it to files/folders and code symbols.
|
||||
|
||||
## Relevant Code
|
||||
- `app/src/search/ai_context_menu/view.rs` — `AIContextMenu`, `get_categories_for_mode()`, `refresh_categories_state()`
|
||||
- `app/src/terminal/input.rs` — `Input` view; handles `EditorEvent::AcceptAIContextMenuItem`, `InsertFilePath` action
|
||||
- `app/src/terminal/cli_agent_sessions/mod.rs` — `CLIAgentSessionsModel`, `CLIAgentInputState`
|
||||
- `app/src/search/ai_context_menu/files/data_source.rs` — `file_data_source_for_current_repo()`, `file_data_source_for_pwd()`
|
||||
- `app/src/search/files/model.rs` — `FileSearchModel` (relies on `ActiveSession::path_if_local()` — local only)
|
||||
|
||||
## Current State
|
||||
The AI context menu (`AIContextMenu`) already supports mode-based category filtering via `get_categories_for_mode()`. It takes flags like `is_ai_or_autodetect_mode`, `is_shared_session_viewer`, and `is_in_ambient_agent` to determine which categories to show. When only one category is available, `refresh_categories_state()` automatically skips the category picker and jumps to the search results view.
|
||||
|
||||
The file data sources (`file_data_source_for_current_repo`, `file_data_source_for_pwd`) use `ActiveSession::path_if_local()` and local `FileSearchModel`/`RepositoryMetadataModel` — these only work for local sessions, not SSH/remote.
|
||||
|
||||
The `InsertFilePath` handler in `EditorEvent::AcceptAIContextMenuItem` already handles file path insertion via `replace_at_symbol_with_text()`. In AI mode it inserts repo-relative paths; in terminal mode it computes the shorter of relative-to-cwd or absolute.
|
||||
|
||||
The `@` trigger in the editor fires when the user types `@` and the input is in AI mode. The CLI agent rich input calls `set_input_mode_agent`, so the `@` trigger should already work.
|
||||
|
||||
## Proposed Changes
|
||||
|
||||
### 1. Filter AI context menu categories for CLI agent input
|
||||
|
||||
**What changes**: `get_categories_for_mode()` gains an additional `is_cli_agent_input: bool` parameter. When true, it uses a **positive allowlist** to determine which categories to show: `RepoFiles`, `CurrentFolderFiles`, and `Code`. All other categories are excluded by default. This is safer than a blocklist because new categories added to the enum in the future won't accidentally leak into the CLI agent menu.
|
||||
|
||||
**Source of truth**: Rather than storing a duplicated flag on `AIContextMenuState`, callers should read `CLIAgentSessionsModel::is_input_open(terminal_view_id)` and pass the result into `get_categories_for_mode()`. The `AIContextMenu` needs to subscribe to `CLIAgentSessionsModel` events and call `refresh_categories_state()` when the input session changes — same pattern used elsewhere (e.g., `UseAgentToolbar` subscribes to `CLIAgentSessionsModel` and re-renders on change). This avoids stale duplicated state.
|
||||
|
||||
### 2. Path insertion: use repo-relative paths
|
||||
|
||||
**Insertion**: The `InsertFilePath` action in `EditorEvent::AcceptAIContextMenuItem` already handles file path insertion via `replace_at_symbol_with_text()`. In AI mode, this appends a trailing space after the inserted path (`format!("{text} ")`). For CLI agent input, use the same AI-mode behavior (repo-relative paths with trailing space). The trailing space is desirable — it lets the user continue typing the prompt naturally after the path.
|
||||
|
||||
### 3. Ensure @ trigger works in CLI agent mode
|
||||
|
||||
**Trigger gating**: The `@` trigger must work anywhere in the buffer, including after mode-switch prefixes like `!`. The CLI agent input already calls `set_input_mode_agent`, so the existing `@` detection logic should fire. Verify this works — if the `@` detection is gated differently, add an explicit check for `CLIAgentSessionsModel::is_input_open()`.
|
||||
|
||||
## End-to-End Flow
|
||||
1. User opens CLI agent rich input (Ctrl-G or Compose button).
|
||||
2. User types `@` anywhere in the buffer.
|
||||
3. Editor detects `@` and opens the AI context menu.
|
||||
4. `AIContextMenu` reads `CLIAgentSessionsModel::is_input_open()` = true, returns only file/folder and code symbols categories.
|
||||
5. User types to filter, selects a file.
|
||||
6. `InsertFilePath` action fires → `replace_at_symbol_with_text()` inserts the repo-relative path.
|
||||
7. User presses Enter → buffer text (including the file path) is written to the PTY.
|
||||
|
||||
## Risks and Mitigations
|
||||
|
||||
### @ trigger not firing in CLI agent mode
|
||||
The editor's `@` detection may be gated on AI mode. The CLI agent input does call `set_input_mode_agent`, so this should work, but needs verification. If gated differently, add an explicit check for CLI agent input being open.
|
||||
|
||||
### Mode-switch prefix interaction with @
|
||||
When input starts with `!` (bash mode), the `@` trigger must still work at positions after the prefix. The existing `@` detection is position-based (tracks the byte offset of the `@` character) and should work regardless of preceding content. No special handling needed.
|
||||
|
||||
## Testing and Validation
|
||||
- Verify `@` opens the context menu with files/folders and code symbols (no Warp-specific categories) in CLI agent rich input.
|
||||
- Verify `@foo` filters files by name.
|
||||
- Verify selecting a file inserts the repo-relative path as plain text.
|
||||
- Verify `@` works after `!` prefix in the buffer.
|
||||
- Verify all inserted content submits correctly to the PTY.
|
||||
- Verify no regressions in normal Warp agent input (`@` context still works as before).
|
||||
|
||||
## Follow-ups
|
||||
- Support `@` context in SSH/remote sessions (requires remote file discovery).
|
||||
Reference in New Issue
Block a user