Apps

Chat

# AI Chat — AI Chat Panel A draw-based AI chat panel with markdown rendering, multi-provider support (Anthropic, DeepSeek, OpenAI, Ollama), MCP tool integration, and project-aware system prompts. ## Key Bindings ### Input Line | Key | Action | |-----|--------| | `Enter` | Send message (queues it while a turn is running) | | `Backspace` | Delete character before cursor (or delete selection) | | `Delete` | Delete character after cursor (or delete selection) | | `Ctrl+Backspace` / `Alt+Backspace` | Delete word backward | | `Left` / `Right` | Move cursor left/right (clears selection) | | `Home` | Move cursor to start of line | | `End` | Move cursor to end of line | | `Ctrl+Left` | Move to previous word boundary | | `Ctrl+Right` | Move to next word boundary | | `Shift+Left` / `Shift+Right` | Extend selection left/right by character | | `Shift+Home` | Extend selection to line start | | `Ctrl+A` | Select all | | `Ctrl+C` | Copy selection, or the whole input when nothing is selected | | `Ctrl+V` | Paste from clipboard | | `Ctrl+X` | Stop the running turn | | `Escape` | Stop the running turn, close dropdowns, or clear selection | | `Shift+Tab` | Cycle operation modes (Build → Plan → Speculate) | ## Operation Modes Every session runs in one of three modes, shown as a colored badge in the status bar and selectable from the Mode menu, the app pie (Mode sub-pie), `Shift+Tab`, or slash commands: | Mode | Behavior | Tools | |------|----------|-------| | Build | Normal operation — investigate and implement changes. | All tools. | | Plan | Read-only investigation; the assistant produces a concrete, actionable plan (steps, files, risks) and tells you to switch to Build to execute it. | Read/search/grep/git/web tools. Mutating tools, shell, subagents, and `@rpc` app tools are blocked (read-only exceptions such as the editor context readers stay available). | | Speculate | Read-only brainstorm — explores ideas, hypotheses, and alternatives, clearly separating verified facts (`file:line`) from conjecture. | Same read-only tool set as Plan. | Slash commands: `/build`, `/plan`, `/speculate`, and `/mode [name]` (no argument shows the current mode). The mode is per session: switching sessions restores that session's mode, and new sessions start in the mode you were using. Switching is refused while a turn is running (stop it first with Escape/`/cancel`) so the in-flight prompt and tools can't disagree with the badge. In Plan/Speculate the assistant's tool roster (Actions → Tool Roster) shows exactly the reduced set it is sent. ## Stopping & Queueing Turns While the assistant is working (status bar shows `Thinking…`, `Waiting…`, or `Using tools…`), the input stays usable: - Enter queues the message instead of sending it. The status bar shows the queue depth (`N queued`); queued messages are sent in order, one per turn, as soon as the current turn ends. - Stop (the status-bar button), Escape, or Ctrl+X terminates the running turn and returns control to the input. The in-flight request still completes in the background, but its reply is discarded; queued messages are sent next. - `/cancel` (or `/c`) is the command-line equivalent of Stop. - `/clear-queue` (or `/cq`) drops every queued message without stopping the turn. ## Thinking Dock The reasoning stream renders in the Thinking dock (right edge). It scrolls: - Mouse wheel over the dock — also focuses the dock so keys follow. - Up / Down scroll a row, PgUp / PgDn a page, Home / End jump to the top/bottom (a click on the dock content focuses it too). - While a response is streaming, the dock stays pinned to the bottom; the first wheel/key scroll cancels the pin (your position survives new lines), and scrolling back to the bottom — or End — re-arms it. - Escape (or clicking panel content) returns keyboard focus to the panel. ## Transcript Your questions render as a highlighted band (`**You►** …`), so each one is easy to spot in a long conversation. The band is a tint of the theme's chat `:user-fg`; set `:chat :question-bg` in a theme to override the color, or use markdown `:line-rules` to style other line prefixes the same way. ## Transcript Selection Select conversation text in the transcript viewer, then copy it: - Mouse drag across lines selects a range; Shift+click extends from the last anchor (click a line, Shift+click another — or the same line twice — to select it alone). A plain click just repositions. - Shift+Up / Shift+Down extend the selection by a line, Shift+PgUp / Shift+PgDn by a page, Shift+Home / Shift+End to the edges. These work even while typing in the input; the view scrolls to follow the selection. - Ctrl+C copies the active transcript selection (falls back to the input's own Ctrl+C behaviour when nothing is selected). - Escape clears the selection. ## Providers Configure via `state~cfg` or set `ANTHROPIC_API_KEY`, `DEEPSEEK_API_KEY`, `OPENAI_API_KEY` environment variables. Supports Anthropic, DeepSeek, OpenAI, and Ollama. ## Pie menu Hold the pie trigger (Super by default; `ui/pie-trigger` selects `:f1`, `:ctrl-space`, or `:off`) to open the workspace pie, then move into the hub to descend into chat's ring. Providers, Models, and Mode are sub-pies: selecting one drills in (Enter, or release the trigger and press it again), so switching provider + model — or mode — takes two flicks from the hub. Sub-pie slices show a `>` next to their key hint, the hub (`Back`) walks back up, and the remaining slices run the session and action commands from the menu bar. ## Timeouts `:chat/timeout-ms` (default `900000` = 15 minutes, clamped 5s..1h) is the per-request AI HTTP timeout — generous enough for thinking/reasoning models to finish a long answer. Each AI request uses its own HTTP client, so stale keep-alive connections can't hang a call until the deadline; if a request does hit the timeout, the error message reports the elapsed time and the configured limit. ## Tools The assistant sees two tool sources, merged per request (in Plan and Speculate modes this set is reduced — see Operation Modes above): - MCP tools (`deft/stdext/mcp_tools`) — the curated built-in set (help lookup, source reading, file writing, …). Always available in-process. The HTTP MCP server for external clients (VS Code, Copilot, Goose) is opt-in via `:chat/mcp-server` (default `false`). App control tools (editor, sheet, …) are deliberately not part of this always-on set. - @rpc tools (`deft/stdext/rpc_tools`) — methods of the apps you opt in, addressed as `runtime__method` (e.g. `editor__cmd-open-file`). Nothing is exposed by default; enable apps in `:chat/rpc-tools`:
:chat/rpc-tools %{ :include @{"editor" "diff"} :exclude @{} }
An app that marks methods `@ai true` (next to `@rpc true`) exposes only that curated subset — the editor marks open/save/edit/context commands and hides cursor motion, selection, and clipboard commands from the model. Apps without marks expose every `@rpc` method. Both keys live in the config registry (`packages/chat/config.dft` defaults) and can be edited from the config app. ## Automate menu The Automate menu lists every currently-instanced app that exposes `@rpc` methods. Selecting an app toggles its automation: - enables/disables that app in `:chat/rpc-tools` (the `[on]` marker shows the current state) — only the app's `@ai`-marked methods are exposed, so the editor contributes a focused open/save/edit/context surface rather than all of its commands, and - appends the app package's `AGENTS.md` (or legacy `agent.md`) to the assistant's system prompt, so it knows how to drive the app (e.g. `editor/AGENTS.md` documents the editor tools and their coordinate conventions; `sheet/AGENTS.md` documents cell formulas, ranges and the `prog.dft` program file). Guidance is injected only while the app is actually running (it has live `@rpc` methods), so the prompt never advertises tools that aren't in the request. "Refresh app list" rescans for apps launched since the menu was built. See `packages/editor/AGENTS.md` and `packages/sheet/AGENTS.md` for reference guidance files; add an `AGENTS.md` to any package to give the assistant app-specific instructions. ## Tool Roster Actions → Tool Roster opens a filterable list of every tool available to the current session — the MCP registry entries plus the `@rpc` tools of the apps enabled in the Automate menu — each shown as `[source] name — description` (`[mcp]` / `[rpc]` prefixes mark where the tool comes from). Type to filter (space-separated terms, case-insensitive), arrow keys / PgUp / PgDn to scroll, Esc to close. The list is built from the same merged schema the next request sends, so it always reflects the live Automate toggles.