Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ts/docs/architecture/agentServerConversations.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,18 @@ All HTML interpolated into either path is escaped via a local `escapeHtml()` (ma

See `packages/vscode-shell/src/agentServerBridge.ts` (`handleManageConversation`, `connectImpl`) and `packages/vscode-shell/src/extension.ts` for the implementation.

### Browser Extension

The browser extension (`packages/agents/browser/src/extension`) is a Chrome MV3 extension that runs in **connected mode only** — its service worker maintains a WebSocket to the agentServer. The chat panel surfaces the same `@conversation` slash commands and NL phrases as the Shell and CLI.

The chat panel forwards the dispatcher's `manage-conversation` `takeAction` payload to the service worker via a `chatPanelManageConversation` invoke RPC. The service worker (`extension/serviceWorker/dispatcherConnection.ts`) implements all eight subcommands (`new`, `list`, `info`, `switch`, `prev`, `next`, `rename`, `delete`) against `AgentServerInvokeFunctions` and returns a rendered HTML message plus a `switched` flag.

When `switched` is set, the chat panel clears its DOM and re-runs `loadSessionHistory()` (mirroring the Shell's `replayDisplayHistory` on `conversationChanged`), then renders the confirmation message so it lands after the replayed history. Live display events arriving during the replay are queued via a `runOrDefer` gate and flushed in order on completion.

Switching follows the bind-new → leave-old → delete-old-channels ordering used by `agentServerClient.ts` and the CLI's `commands/connect.ts`: if the new join throws, the existing dispatcher and channels stay live so the user can retry. The chat panel joins with `filter: false` (matching Shell), so display events from peer clients (Shell or CLI joined to the same conversation) are also visible.

See `packages/agents/browser/src/extension/serviceWorker/dispatcherConnection.ts` (`bindToConversation`, `switchToConversationId`, `manageConversation`) and `packages/agents/browser/src/extension/views/chatPanel.ts` (`dispatcherTakeAction`, `runOrDefer`, `loadSessionHistory`) for the implementation.

---

## Natural Language Conversation Management
Expand Down
9 changes: 9 additions & 0 deletions ts/packages/agents/browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ To build the browser extension, run `pnpm run build` in this folder. For debug s
- go back
- etc.

## Chat panel

The extension's chat panel supports the same `@conversation` slash
commands and natural-language conversation management as the Shell and
CLI (`new`, `list`, `info`, `switch`, `prev`, `next`, `rename`,
`delete`). Switching, creating, or moving between conversations clears
the panel and replays the new conversation's history, so peer activity
from a Shell or CLI joined to the same conversation is also visible.

## Architecture

### Agent WebSocket Server
Expand Down
5 changes: 5 additions & 0 deletions ts/packages/agents/browser/docs/dev-onboarding.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ DEBUG=typeagent:webAgent:proxy pnpm run cli:dev
keep-alive (20s interval) prevents this during normal operation.
- After extension reload, the service worker restarts and re-establishes
the WebSocket connection.
- **After `pnpm --filter browser-typeagent build`, the running service
worker does NOT auto-reload.** Click the ↻ reload icon for the extension
on `chrome://extensions` to pick up new code. A symptom of stale SW
code is an RPC error like `No invoke handler <name>` for a handler you
just added.

### Content script

Expand Down
17 changes: 17 additions & 0 deletions ts/packages/agents/browser/src/common/serviceTypes.mts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,23 @@ export type ChatPanelInvokeFunctions = {
actionName: string;
actionDescription: string;
}): Promise<{ success: boolean; flowName?: string; error?: string }>;

// @conversation slash commands and NL conversation actions. Returns
// an HTML message the chat panel renders inline; `switched` signals
// that the active conversation changed and history should be reloaded.
chatPanelManageConversation(params: {
subcommand:
| "new"
| "list"
| "info"
| "switch"
| "prev"
| "next"
| "rename"
| "delete";
name?: string;
newName?: string;
}): Promise<{ kind: "ok" | "error"; html: string; switched?: boolean }>;
};

// =============================================
Expand Down
Loading
Loading