Repository navigation
Description
Overview
Per ADR-034, ai-chat is a single node type discriminated by provider, and a PTY agent session (Claude Code / Codex / Gemini CLI / etc. running in an embedded terminal) IS an ai-chat node with provider: 'pty'. The rendering and launch/capture side of this mode is fully built, but there is no UI entry point to create a pty chat: the header model selector never offers a PTY option, so nothing ever writes provider: 'pty' onto a node and the entire mode is unreachable.
Problem Statement
User Experience:
- User opens a new
/ai-chatnode. - The header model selector (
AiChatModelSelector) lists only Local (native GGUF), Ollama, and Custom endpoints (OpenAI-compat), plus a "Set up…" action. - There is no way to choose "launch an agent CLI session" — the PTY / terminal mode.
- Expected: the selector offers a PTY option (e.g. an "Agent CLI" group or a "Launch agent session…" action) that sets
provider: 'pty'and routes the node to the embedded-terminal view.
Evidence — the mode is built but dead-ended:
AiChatProviderincludes'pty':packages/desktop-app/src/lib/types/ai-chat-node.ts:4- The viewer dispatches on it:
packages/desktop-app/src/lib/components/viewers/ai-chat-node-viewer.svelte:414—{:else if provider === 'pty'}→<AiChatPtySession {nodeId} /> AiChatPtySessionis complete: harness picker, availability checks (ptyCheckAgentAvailability), launch (ptyLaunchSession), capture backfill, ended-session summary —packages/desktop-app/src/lib/components/viewers/ai-chat-pty-session.svelte- But the selector's
ModelSelectiontype omits'pty'and no optgroup/option emits it:packages/desktop-app/src/lib/components/viewers/ai-chat-model-selector.svelte:16-20,237-301 - Consequently
handleModelSelectonly ever writesnative/ollama/openai-compat:ai-chat-node-viewer.svelte:144-190
Design Intent (confirmed)
This stays a single ai-chat node type — no separate PtyChatNode. provider is the discriminant. A PTY node legitimately stores no messages (messages: []); the conversation lives in the external harness's own PTY. What NodeSpace persists instead are capture references on the node's properties: capture:session_id (reference to the external session), capture:agent_type, optional capture:summary / capture:transcript backfilled at session end, and status (active → archived). Same schema, different fill: native/ollama nodes hold the full message log; PTY nodes hold a thin reference to an external session plus optional captured summary/transcript.
Root Cause
Location: packages/desktop-app/src/lib/components/viewers/ai-chat-model-selector.svelte
- The module-level
ModelSelectioninterface (lines 16-20) constrainsproviderto'native' | 'ollama' | 'openai-compat', so the selector cannot express a PTY selection. - The
<select>template (lines 237-301) builds only Local / Ollama / Custom-endpoints optgroups plus the "Set up…" sentinel — no PTY entry. - Therefore
handleModelSelectinai-chat-node-viewer.svelte(lines 144-190) is never invoked with a PTY selection, and no code path setsprovider: 'pty'on a node. The{:else if provider === 'pty'}branch is unreachable from the UI.
Proposed Solution
- Extend
ModelSelection.providerinai-chat-model-selector.svelteto include'pty'. - Add a PTY entry to the selector — an "Agent CLI" optgroup (or a single "Launch agent session…" action-style entry) — whose option value maps to a
{ provider: 'pty', modelId: '' }selection viaonSelect. A PTY node needs no model, somodelIdis empty and the specific harness (claude-code / codex / gemini-cli / …) is chosen later insideAiChatPtySession. - Handle
selection.provider === 'pty'inhandleModelSelect(ai-chat-node-viewer.svelte): writeprovider: 'pty'(and appropriatestatus) to the node viasharedNodeStore.updateNode, with nomodel, so the viewer routes toAiChatPtySession. - While in the viewer, verify the
provider === 'pty'branch atai-chat-node-viewer.svelte:414-420is clean — it appears to render<AiChatPtySession>immediately followed by aprovider-prompt"Choose a model" block, which looks like a possible merge artifact. Confirm the branch renders only the PTY session.
Acceptance Criteria
- The AI-Chat header model selector shows a PTY entry (e.g. an "Agent CLI" group or "Launch agent session…" action).
- Selecting it sets
provider: 'pty'on the node (nomodel) and the viewer rendersAiChatPtySession. - The launched node remains an
ai-chatnode with an emptymessagesarray; session state is stored via thecapture:*properties. -
ModelSelection.providerincludes'pty'; noanycasts or type suppression introduced. - The
provider === 'pty'branch inai-chat-node-viewer.svelterenders only the PTY session (no stray "Choose a model" block). - Existing native / ollama / openai-compat selection flows are unchanged.
- Tests pass (
bun run test:all), including a test asserting a PTY selection setsprovider: 'pty'. - Code passes
bun run quality:fix.
Technical Specifications
Files to Modify
- ai-chat-model-selector.svelte:
packages/desktop-app/src/lib/components/viewers/ai-chat-model-selector.svelte— extendModelSelection(lines 16-20) and add the PTY option to the<select>(lines 237-301) + a branch inhandleChange(lines 185-221). - ai-chat-node-viewer.svelte:
packages/desktop-app/src/lib/components/viewers/ai-chat-node-viewer.svelte— handleprovider === 'pty'inhandleModelSelect(lines 144-190); verify theptyrender branch (lines 392-420).
Reference Files (no change expected)
- ai-chat-pty-session.svelte:
packages/desktop-app/src/lib/components/viewers/ai-chat-pty-session.svelte— the target view; already handles harness selection, launch, capture, and ended state. - ai-chat-node.ts:
packages/desktop-app/src/lib/types/ai-chat-node.ts—AiChatProvideralready includes'pty';messagesdefaults to[].
Test Requirements
- Unit test (Happy-DOM,
bun run test): selecting the PTY option invokesonSelectwith{ provider: 'pty' }andhandleModelSelectwritesprovider: 'pty'(nomodel) to the node.
Non-Goals
- No changes to the daemon-side PTY launch/capture pipeline (
ptyLaunchSession,ptyCheckAgentAvailability) — already implemented. - No new harness integrations beyond the agents
AiChatPtySessionalready offers. - No separate node type for PTY sessions — this remains one
ai-chattype discriminated byprovider.
Activity
malibio commentedon Jul 11, 2026
Frontend baseline: 158 test files passed, 4019 tests passed.
AI-Chat model selector never offers the PTY (agent-CLI) option, leavi…
Add PTY agents (Claude Code, Gemini, Codex) to AI Chat model selector (…