feat(agent): Claude SDK migration with chat UI and worktree isolation - #15
Merged
Conversation
Replace xterm.js terminal with structured chat UI using Claude Code SDK subprocesses, SSE streaming, and custom React components. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
11-task plan covering: event types, agent process manager, SSE endpoint, React hooks, chat components, SessionDetail integration, and send route wiring. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Introduces foundational AgentEvent type definitions (EventType, EventData variants, AgentStatus) and the createAgentEvent factory with unique counter-based IDs. All 3 unit tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements the AgentProcessManager class that wraps the Claude Code SDK (claude function) to manage one agent process per chat session, replacing tmux-based session management for chat-mode interactions. Also fixes vitest.config.ts to resolve @anthropic-ai/claude-code by pointing its bare specifier to cli.js (the package ships no exports/main field). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements GET /api/sessions/[id]/stream as a Server-Sent Events route that replays session history on connect, sends current status, subscribes to live AgentProcessManager events, and sends a heartbeat every 15s. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Groups consecutive tool_use and file_change events into renderable blocks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
UserMessage, ThinkingRow, ToolCallGroup, FileBadge, FileChangeSummary, StreamingIndicator, MarkdownContent Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Composite components that wire hooks to atomic UI pieces. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sessions with metadata.useChatUI=true render ChatPanel instead of DirectTerminal. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sessions with metadata.useChatUI=true bypass tmux and use Claude Code SDK. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…remove tmux IPC channels Add @anthropic-ai/claude-code as a dependency and webpack external for the main process. Create shared AgentEvent types (src/common/agentEvents.ts) for structured event communication between main and renderer. Remove three tmux-specific IPC channels (AO_SEND_RAW_INPUT, AO_RESIZE_TERMINAL, AO_OPEN_TERMINAL) that are no longer needed with the SDK approach. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace all tmux/CLI-based session management with direct Claude SDK calls. Sessions now stream structured AgentEvents (assistant messages, thinking, tool use) via BrowserWindow IPC instead of raw terminal output. Removed: AO CLI spawn, tmux capture/polling/streaming, FIFO pipes, YAML config generation, session persistence to disk, raw terminal input, resize, and openTerminal. Added: broadcastEvent (sends to all windows), processSDKEvent (converts SDK stream to AgentEvents), summarizeToolInput, runClaude (async stream runner with AbortController). Updated spawnSession, sendMessage, killSession, and getSessionStatus accordingly. All git methods (getDiff, getGitFiles, getGitChanges, getGitFullStatus, gitAction) and path helpers are preserved unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The @anthropic-ai/claude-code package is CLI-only (no programmatic
export). Replace `import {claude}` with spawning the CLI using
`--print --output-format stream-json --verbose --dangerously-skip-permissions`
and parsing the newline-delimited JSON stream.
Follow-up messages use --resume to continue the conversation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove AO_SEND_RAW_INPUT, AO_RESIZE_TERMINAL, AO_OPEN_TERMINAL handler registrations from initialize.ts and their preload bridge methods from internalAPI.js. Fix AO_GET_SESSION_STATUS handler to drop the unused event.sender argument, matching the updated aoManager API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the never-defined EmbeddedTerminal reference with the existing AgentChat component that renders structured AgentEvent objects in a chat UI. Replace xterm terminal styles with chat message styles. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove sendRawInput, resizeTerminal, openTerminal from window type
definitions. Update onOutputUpdate/offOutputUpdate callback to use
AgentEvent instead of old {data: string} shape.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The --bare flag skips keychain reads and OAuth, requiring ANTHROPIC_API_KEY instead. Users logged in via OAuth get "Not logged in" errors. Remove the flag so normal auth works. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Agents now work in dedicated git worktrees (~/.worktrees/{projectId}/{issue-id}/)
instead of the linked repo directly. This ensures each issue gets its own branch
(oli/{identifier}) based on origin/{defaultBranch}, making diffs and git status
work correctly.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…shboard The agent-process-manager was importing a non-existent `claude` function from @anthropic-ai/claude-code (which is a CLI tool, not a JS library). Rewrite to spawn the Claude CLI directly via child_process, matching the desktop app's aoManager.ts approach with stream-json output parsing and session resumption via --resume flag. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Rewrites the Agent Orchestrator integration from tmux-based session management to direct Claude CLI spawning via the Claude Code SDK. Adds a new chat UI for agent interaction, and implements per-issue git worktree isolation so each agent session works in a dedicated branch.
Key changes:
--print --output-format stream-jsonspawning, streaming structured SDK events (assistant messages, thinking, tool use) back to the renderer.~/.worktrees/{projectId}/{issue-id}/on brancholi/{identifier}, so diffs, git status, and file changes work correctly per issue.common/agentEvents.tsmodule with typed event creation for cross-process event streaming.Ticket Link
N/A — internal architectural improvement
Checklist
npm run lint:jsfor proper code formattingRelease Note