# VS Code (/docs/apps/vscode)

The codai extension for VS Code mirrors your GitHub Copilot Chat sessions to your watch, phone and desktop, so you can approve tools and answer questions from anywhere. Plus @codai in chat.

The **codai** extension (`dragoscv.codai-vscode`) shares the GitHub Copilot Chat sessions you work in with your codai account. They show up on your [Wear OS watch](./wear.mdx), in the [Android app](./android.mdx) and in the [desktop app](./desktop.mdx) like any other [shared session](../sessions/index.mdx). When Copilot's agent waits for you — *"Allow `run_in_terminal`?"* or a question with options — the ask reaches every device, and your answer is applied in VS Code.

Works on VS Code 1.105+ (stable and Insiders), Windows, macOS and Linux.

## Install [#install]

- **Marketplace**: search for **codai** by *dragoscv* in the Extensions view, or run `code --install-extension dragoscv.codai-vscode` (`code-insiders` for Insiders).
- **VSIX**: download `codai-<version>.vsix` from the release and use **Extensions → … → Install from VSIX**.

## Sign in [#sign-in]

Run **codai: Sign in** from the Command Palette. Your browser opens `auth.codai.ro/device` with the code already filled in (it is also copied to the clipboard); approve it. VS Code never sees your password — it receives its own `codai_` key, kept in VS Code's secret storage and listed as a device in [hub.codai.ro](https://hub.codai.ro) → **Security → Devices**.

**codai: Sign in with GitHub** uses the GitHub account VS Code is already signed in to: no browser round trip, and it lands on the same codai account as signing in with GitHub on the web.

Alternatively, **codai: Use an API key…** accepts a key you created yourself.

## What your devices see [#what-your-devices-see]

| In Copilot Chat | On the watch / phone / desktop |
| --- | --- |
| The chat title (or your first prompt) | The session title |
| Each prompt you send | A user line |
| Each finished tool call | A tool line (tool name and its one-line description) |
| A tool waiting for confirmation | An ask: **Allow** / **Deny** |
| A question carousel | An ask with the offered options, or a free answer |
| The final answer of a request | The assistant line |
| A failed or cancelled request | An error line |

The status bar shows **codai N** (sessions shared) and a bell with a count when something waits for you. Click it for the list, **Sync now**, the log and **Sign out**.

## Answering from another device [#answering-from-another-device]

- **Allow / Deny** on a tool ask confirms or skips the tool in that chat. VS Code applies a confirmation only to a chat that is open in a window, so with `codai.remote.revealSessions` (on by default) the extension opens the chat for you first.
- **Answer** a question with one of the options, its number, or free text (dictated on the watch). Only the first question of a carousel takes your answer; the others keep their defaults.
- **Send** a new prompt to the session and it is submitted in that chat.
- **Stop** cancels the running request.

Answers reach VS Code within a few seconds (`codai.sessions.pollSeconds`).

<Callout type="warn">
**New asks can take a minute or two to reach your watch.** VS Code writes chat sessions to disk on its own schedule, and the extension reads them from there. Answers in the other direction are fast.
</Callout>

## Pending prompts [#pending-prompts]

The **Pending prompts** view in the activity bar lists the [prompts saved for later](/docs/api/gateway/prompts) on any of your devices, and updates live when one changes elsewhere.

- **Open in chat**, **Copy**, **Snooze**, **Mark done**, **Dismiss**, **Delete**, and **Save selection as pending prompt** for new ones.
- **Detected automatically.** Paste a pending prompt into Copilot Chat in any VS Code window and it is marked **sent**, then **answered** when the response finishes. Nothing to click.
- **Verify prompt** / **Verify all prompts** ask codai whether the chat really did the job, using the chat and the repository diff since the prompt was sent. You get a short report (what changed, what is still missing); a complete job is marked **verified**.

## @codai in chat [#codai-in-chat]

Type `@codai` in Copilot Chat to talk to the `codai` model directly (streamed, billed to your codai account).

- `@codai /sessions` — your shared sessions on every device, with what waits for you.
- `@codai /asks` — only the open questions and approvals.

## Web search and deep research in agent mode [#web-search-and-deep-research-in-agent-mode]

From version 0.7.0 the extension adds three tools to Copilot agent mode, available to **every** model (including custom endpoints and BYOK models that have no built-in web search):

- `codai_web_search` (`#codaiWebSearch`) — verified web search: each result was fetched by codai and its snippet found on the page, cited as `[S1]`..`[Sn]`. The agent can restrict sites (`include_domains` / `exclude_domains`), ask for recent pages (`freshness` `day`/`week`/`month`/`year`, `published_after` / `published_before`), go `deep` for hard questions or get a longer verified excerpt per result (`content_chars`). Language and market are inferred from the query unless the agent sets `lang` / `country`.
- `codai_web_fetch` (`#codaiWebFetch`) — reads a public URL as clean markdown (up to 40,000 characters, 8,000 by default); `focus` returns only the relevant paragraphs. The page text is marked as untrusted content.
- `codai_deep_research` (`#codaiDeepResearch`) — plans several searches, reads the best pages and returns a report where every claim cites its source. If the report is not ready within the wait window, the tool returns a job id and the agent calls it again with `job_id`.

They are the same tools, with the same schemas and output, as on desktop, phone, the headless CLI and the hosted MCP ([one contract](/docs/agents/tools#web-tools-one-contract-everywhere)). They use your codai key (sign in first) and the API endpoints [`POST /v1/tools/search`](/docs/agents/tools), `POST /v1/tools/fetch` and [`POST /v1/research`](/docs/api/gateway/research). A refusal by one of your rules, a bad argument or a rate limit is shown to the model as an `ERROR` line and never silently retried. Searches and fetches are metered ([pricing](/docs/agents/tools#pricing)): the first 1,000 calls a month are free, and calls are free when `codai` is the chat model. Enable or disable them in the chat **Tools** picker, or reference them in a prompt with `#`.

## Sessions from other devices (experimental, Insiders) [#sessions-from-other-devices-experimental-insiders]

With `codai.experimental.chatSessionsProvider` on, VS Code Insiders lists the sessions that run on your *other* codai devices in its own Sessions view. Opening one shows its history; a prompt typed there is sent to the device running it. This uses a proposed VS Code API, so start Insiders with `--enable-proposed-api dragoscv.codai-vscode` (or add `"enable-proposed-api": ["dragoscv.codai-vscode"]` to `argv.json` via **Preferences: Configure Runtime Arguments**). Without that, the setting does nothing.

## Settings [#settings]

| Setting | Default | Meaning |
| --- | --- | --- |
| `codai.sessions.mirror` | `true` | Share this window's Copilot Chat sessions. Set it per workspace to keep one project private. |
| `codai.sessions.activeMinutes` | `120` | Only sessions changed in the last N minutes are shared. |
| `codai.sessions.backfillRequests` | `3` | Past requests shown when a session is first shared. |
| `codai.sessions.pollSeconds` | `5` | How often the extension checks for changes and remote answers. |
| `codai.remote.revealSessions` | `true` | Open the chat when an approval arrives from another device. |
| `codai.experimental.chatSessionsProvider` | `false` | Sessions from other devices in the Sessions view (Insiders + proposed API). |
| `codai.prompts.autoCapture` | `true` | Save handoff prompts (a `text` block in an answer that mentions a new chat) to Pending prompts. |
| `codai.prompts.autoDetect` | `true` | Mark a pending prompt **sent** / **answered** when you use it in Copilot Chat. |
| `codai.prompts.scanAllWorkspaces` | `true` | Look in the chats of every VS Code window on this machine, not only this one. |
| `codai.gatewayUrl` / `codai.authUrl` | `https://ai.codai.ro` / `https://auth.codai.ro` | Only change these for a self-hosted codai. |

## Privacy [#privacy]

The extension only **reads** the chat session files VS Code already keeps (`workspaceStorage/<id>/chatSessions/`, and for Copilot CLI chats in newer Insiders builds `globalStorage/agent-host.db` plus `~/.copilot/session-state/<id>/events.jsonl`, read from a private copy); it never modifies them. It sends to `ai.codai.ro`: the session title, your prompts without attached context, tool names and their one-line descriptions, the final answer text, and asks. It does **not** send file contents, attachments, tool results or edits. Each VS Code session maps to one codai session keyed `vscode:<machine>:<session id>`; delete it from the hub or any app like any other session. See the [privacy policy](https://codai.ro/privacy).

## Troubleshooting [#troubleshooting]

| Symptom | Fix |
| --- | --- |
| Status bar shows **codai** with a slashed circle | Not signed in — click it. |
| A session does not appear on the watch | It must have changed within `codai.sessions.activeMinutes`, and VS Code must have saved it (send one more message, or wait a minute). **codai: Sync sessions now** forces a read. |
| An approval from the watch did nothing | The chat was closed and `codai.remote.revealSessions` is off — open the chat, or turn the setting on. |
| Another device runs the same session | Only one device executes a session (the lease). The extension retries every minute; see the log (**codai: Shared sessions… → Show log**). |

<Cards>
  <Card title="Wear OS" href="./wear.mdx" description="Follow and answer sessions from the watch." />
  <Card title="Shared sessions" href="../sessions/index.mdx" description="The protocol every codai client speaks." />
</Cards>
