Adds system_prompt parameter to chat_stream so the Matrix bot
passes "Your name is {name}" to Claude Code. Reads display_name
from bot.toml config. Resolved conflicts by integrating bot_name
into master's permission-handling code structure.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The history trimming logic cleared session_id = None whenever entries
exceeded history_size. Since the history was always at capacity, every
new message wiped the session_id immediately after storing it. This
meant --resume was never passed to Claude Code, making every turn a
fresh conversation.
Fix: preserve session_id on trim. Claude Code's --resume loads the
full conversation from its own session transcript on disk, so trimming
our local tracking entries doesn't invalidate the session.
Also adds debug logging for session_id capture/storage (temporary).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The revert of story 86's merge left broken code from stories 131/135
that depended on it. Removed dead inline event dispatch (referencing
undefined event_type, pty_writer, PermissionReqMsg), added activity_tx
to process_json_event, and removed unused permission_tx parameter from
chat_stream/chat (permissions go through MCP, not PTY).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Old process_json_event call and new handle_stream_event match block were
both kept during auto-resolution; remove the old code to fix unclosed delimiter.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add missing closing brace and #[test] attr between test functions in claude_code.rs
- Remove premature semicolon in TypeScript union type in client.ts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add log_buffer module: bounded 1000-line ring buffer with push/get_recent API
- Add slog! macro: drop-in for eprintln! that also captures to ring buffer
- Replace all eprintln! calls across agents, watcher, search, chat, worktree, claude_code with slog!
- Add get_server_logs MCP tool: accepts count (1-500) and optional filter params
- 5 unit tests for log_buffer covering push/retrieve, eviction, filtering, count limits, empty buffer
- 262 tests passing, clippy clean
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Keep master's quiet system/rate_limit_event handlers while preserving
the story-62 permission_request handler (the core feature).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When Claude Code requires user approval before executing a tool (file
writes, commits, etc.) the agent sends a permission_request message
over the WebSocket. The web UI now intercepts that message, surfaces a
modal dialog showing the tool name and input, and lets the user approve
or deny. The decision is sent back as a permission_response, allowing
the agent to continue or adjust its approach.
Backend changes:
- claude_code.rs: parse "permission_request" NDJSON events from the PTY,
block the PTY thread via a sync channel, and write the user's decision
back to the PTY stdin as a JSON permission_response.
- chat.rs: thread an optional UnboundedSender<PermissionReqMsg> through
to the provider.
- ws.rs: create a permission-request channel, forward requests to the
client, collect responses via a pending-perms map, and interleave all
of this with the active chat session using tokio::select!.
Frontend changes:
- client.ts: add permission_request to WsResponse, permission_response
to WsRequest, onPermissionRequest handler to ChatWebSocket.connect(),
and sendPermissionResponse() method.
- types.ts: mirror the same type additions.
- Chat.tsx: add permissionRequest state, wire onPermissionRequest
callback, and render an approval modal with tool name, input context,
Approve and Deny buttons.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Integrate Claude Code provider into the chat UI alongside regular
Ollama/Anthropic providers. Updates AgentPanel and Chat components.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use --resume <session_id> with claude -p so the web UI claude-code-pty
provider maintains full conversation context across messages, identical
to a long-running terminal Claude Code session.
Changes:
- Capture session_id from claude -p stream-json system event
- Pass --resume on subsequent messages in same chat session
- Thread session_id through ProviderConfig, ChatResult, WsResponse
- Frontend stores sessionId per chat, clears on New Session
- Unset CLAUDECODE env to allow nested spawning from server
- Wait for clean process exit to ensure transcript flush to disk
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add git worktree isolation for concurrent story agents. Each agent now
runs in its own worktree with setup/teardown commands driven by
.story_kit/project.toml config. Agents stream output via SSE and support
start/stop lifecycle with Pending/Running/Completed/Failed statuses.
Backend: config.rs (TOML parsing), worktree.rs (git worktree lifecycle),
refactored agents.rs (broadcast streaming), agents_sse.rs (SSE endpoint).
Frontend: AgentPanel.tsx with Run/Stop buttons and streaming output log.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Proves that spawning `claude -p` in a pseudo-terminal from Rust gets Max
subscription billing (apiKeySource: "none", rateLimitType: "five_hour")
instead of per-token API charges. Concurrent agents run in parallel PTY
sessions with session resumption via --resume for multi-turn conversations.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>