Updated @anthropic-ai/claude-agent-sdk from 0.1.74 to 0.1.75.
This version includes Opus 4.5 model (claude-opus-4-5-20251101).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Root cause identified: Infinite loop in git-diff.tsx due to unstable
requestGitDiff function reference. The useEffect depends on this
function which changes on every store update, causing repeated
git_diff_request calls (250+ times in seconds).
Added findings section documenting:
- Data flow analysis showing the dependency chain
- The exact loop mechanism
- Console evidence (setGitDiffs/setSessionMethods called 250+ times)
- Required fix: remove requestGitDiff from useEffect dependencies
Added follow-up tasks:
- Fix task to remove unstable dependency
- Test task to verify git diff loads correctly
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Re-audit confirms all model info tracking tasks are complete:
- Claude SDK investigation found model in init message
- Implementation captures model in handleSystemMessage()
- Fixed refreshRuntimeInfo() to emit state on changes
- Both Claude and Codex agents show actual runtime models
- All tests passed
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Created Claude agent with "Automatic" model config. Agent correctly
self-reported running on claude-opus-4-1-20250805 (Opus 4.1), and
the agent info menu now displays the correct runtime model instead
of "Unknown". The fix for capturing model from SDK init message and
emitting state after runtimeInfo changes is working correctly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Created a new Claude agent with "Automatic" model config.
The agent responded correctly stating it runs on Claude Opus 4.1.
However, the model still shows "Unknown" in the agent info menu.
Root cause: The server wasn't restarted after the fix was implemented.
The dev server uses tsx with explicit restart messaging - it doesn't
auto-reload on file changes. The fix code exists in source but the
server is running stale code.
Added follow-up tasks:
- Restart server to apply model capture fix
- Re-test Claude model display after server restart
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The Claude agent model was not showing in the UI ("Model: Unknown") because
refreshRuntimeInfo() updated agent.runtimeInfo but never called emitState()
to notify connected clients of the change.
Fixed by:
1. Adding change detection in refreshRuntimeInfo() to check if model, sessionId,
or modeId changed
2. Calling emitState(agent) when changes are detected
3. Added debug logging in handleSystemMessage() to confirm model capture
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Created Claude agent with 'Automatic' model config. Agent self-reported
running on claude-opus-4-1-20250805 (Opus 4.1), but UI shows 'Model: Unknown'
in agent info menu.
The implementation to capture model from SDK init message is not working -
model is not being propagated to the UI.
Added fix task and re-test task to address the issue.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tested Codex agent creation with "Automatic" model config.
After first turn completion, UI correctly displays `gpt-5.1-codex-max`
(actual runtime model from rollout file), confirming runtime model
detection is working correctly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update handleSystemMessage() in claude-agent.ts to read the actual model
from the SDK's init message (message.model) instead of just echoing back
the configured model. This gives us the real runtime model that the SDK
selected.
Also invalidates cached runtime info when the model is updated to ensure
getRuntimeInfo() returns the new value.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Investigated @anthropic-ai/claude-agent-sdk types and found that actual
model info is exposed in two places:
1. SDKSystemMessage (init) has `model` field
2. SDKResultMessage has `modelUsage` with model names as keys
Current implementation ignores both, only using config.model.
Added implementation task to capture actual model from init message.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Completed audit of current model info tracking implementation:
- Model config set via AgentSessionConfig.model
- Runtime info uses AgentRuntimeInfo type with model field
- UI correctly uses extractAgentModel() which reads runtimeInfo.model
Key findings:
- Codex agents: Correctly detect runtime model from rollout file ✓
- Claude agents: Currently echo configured model (not runtime detected)
- Gap: Claude SDK may expose actual model in response metadata
Added follow-up tasks:
- Investigate if Claude SDK exposes actual model in responses
- Test Codex runtime model detection
- Test Claude agent model display behavior
- Re-audit plan after investigation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements automatic detection and usage of system-installed Codex binary
with transparent fallback to embedded binary.
Changes:
- Add detectSystemCodexPath() to check for codex in PATH using `which`
- Update CodexAgentClient constructor to auto-detect system binary
- Log which binary is being used (system vs embedded) for debugging
- Preserve ability to explicitly override via codexPathOverride option
Benefits:
- No manual configuration required
- Uses latest system codex when available
- Seamless fallback to embedded binary
- Transparent to rest of codebase
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Upgrade packages to access latest model catalogs:
- @openai/codex-sdk: 0.58.0 → 0.76.0
- @anthropic-ai/claude-agent-sdk: 0.1.37 → 0.1.74
New models available after upgrade:
- Claude: Added Opus 4.5 and Haiku 4.5 to catalog
- Codex: Added gpt-5.2, gpt-5.2-codex, and gpt-5.1-codex variants
Updated patch file for new codex-sdk version.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implement a new UI section that surfaces agents requiring user attention at the top of the agent list. This includes agents that are running, have pending permissions, or have errors.
**Backend changes:**
- Add `requiresAttention` field to agent projections and SDK types
- Implement logic in AgentManager to detect attention states (running, pending permissions, errors)
- Add WebSocket message handler to notify clients of attention state changes
- Update session state to include attention tracking
**Frontend changes:**
- Add "REQUIRES ATTENTION" section in agent-list component with visual prominence
- Update useAggregatedAgents hook to expose `requiresAttention` agents
- Enhance session store to track and update attention states
- Add real-time updates via WebSocket for attention state changes
- Update type definitions across agent directory and stream types
Verified working via Playwright MCP testing on localhost:8081.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Added the --isolated flag to the Playwright MCP configuration to ensure
browser instances run in isolated contexts, preventing state leakage
between different agent sessions.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Previously, only standard tool_use blocks had their input parameters
captured in upsertToolUseEntry. MCP tools (mcp_tool_use) and server
tools (server_tool_use) were being handled for execution but their
inputs were never stored in the tool cache, resulting in missing input
data in the UI.
Now all three tool types have their inputs properly captured and
normalized, ensuring consistent tool call display across all tool types.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Replace portal/registry pattern with direct rendering where each screen
owns its footer. This eliminates FooterControlsContext indirection and
makes the code follow standard React composition patterns.
- Remove GlobalFooter and FooterControlsProvider from _layout.tsx
- Add HomeFooter component rendered directly in home screen
- Render AgentInputArea directly in agent screen (not via registration)
- Add keyboard animation and safe area handling to AgentInputArea
- Move FOOTER_HEIGHT constant to shared constants/layout.ts
- Delete footer-controls-context.tsx and global-footer.tsx
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Remove ReadonlyPendingPermissionsMap class and related deep cloning/freezing
methods that were causing "ManagedAgent views returned by AgentManager are
read-only" errors. The bug occurred because Map constructor internally calls
.set() which was overridden to throw.
Replace with simple shallow clones - sufficient because all consumers either
read 1-2 fields or immediately serialize via toAgentPayload() which already
creates safe copies.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Enhance the get_agent_activity tool to provide better context about the activity list:
- Add activity count headers showing "X of Y activities"
- Remove raw format option, always use curated format for consistency
- Simplify implementation by removing unnecessary format branching
- Respect limit parameter to show most recent N activities
This makes it clearer to users when they're viewing a subset of activities versus the full list.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implement hard-coded 60-second timeout for agent wait operations in three tools:
- create_agent (when background=false and initialPrompt provided)
- send_agent_prompt (when background=false)
- wait_for_agent (always)
When timeout occurs, returns gracefully with message "Awaiting the agent timed out, await again" instead of throwing an error. Agent continues running after timeout.
Added AGENT_WAIT_TIMEOUT_MS constant and waitForAgentWithTimeout helper function to handle timeout logic with proper cleanup and signal forwarding.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Replace greedy sessions selector with granular useShallow selectors
that only extract agent Maps and methods. This prevents HomeScreen
from re-rendering on every agent stream update.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Move mode validation from AgentManager into the individual AgentSession
implementations (ClaudeAgentSession and CodexAgentSession) where it belongs.
Each session validates modes in:
- Constructor (when config.modeId is provided)
- setMode() method (when mode is changed)
This follows the principle that the AgentManager is a coordinator while
the AgentSession is the authority on what modes it supports.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Prevents server crashes when invalid modes are passed to agents by
validating mode IDs before attempting to set them on the SDK.
- Export VALID_CLAUDE_MODES and VALID_CODEX_MODES from provider files
- Add validateMode() function in agent-manager.ts
- Apply validation in createAgent(), resumeAgent(), and setAgentMode()
- Throws clear error listing valid modes when validation fails
This fixes the crash when 'read-only' (Codex mode) was passed to
a Claude agent.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fixed two fire-and-forget promise patterns that could cause unhandled rejections:
- interruptActiveTurn() in requestCancel closure - now catches errors and logs warning
- forwardPromptEvents() in stream method - now catches errors and logs to console
Both now properly handle promise rejections to prevent Node.js process crashes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Previously, opening an agent screen would skip fetching timeline history
if stream state already existed in the cache. This caused issues when:
- Opening a running agent after reconnection
- Returning to an agent with stale/incomplete cache
Now we always fetch fresh timeline on open, ensuring:
- Complete history is shown regardless of client state
- Reconnection scenarios work correctly
- Agent state is always up-to-date
Uses a ref to track initialization per mount to prevent infinite loops.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add top-level agentLastActivity Map to store (prevents cascade rerenders)
- Remove lastActivityAt updates from agent_stream handler (only status changes update timestamps)
- useAggregatedAgents now uses agent.lastActivityAt directly
- Remove investigation logging from previous debug session
The root cause was that every stream event updated agent.lastActivityAt,
causing useAggregatedAgents to recalculate, which caused HomeScreen to
rerender even when not visible. Now timestamps only update on meaningful
events (agent status changes), not individual stream tokens.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Remove debug logging and render counters added during performance investigation.
All performance issues have been resolved by:
- Moving drafts to top-level store
- Moving agentLastActivity to top-level store
- Using granular Zustand selectors throughout
- Eliminating useDaemonSession hook
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Delete useDaemonSession hook that selected entire session object
- Move drafts to top-level store (not nested in sessions)
- Refactor all components to use granular useSessionStore selectors
- Fix infinite loop bugs from selector fallbacks (use stable constants)
Before: 15-20 component rerenders per keystroke
After: ~1-2 rerenders per keystroke
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Previously, drafts were nested inside each session object, which caused
the entire session to be recreated on every keystroke. This triggered
rerenders in all components subscribed to the session.
Now drafts are stored at the top level of the Zustand store, keyed by
agentId (not serverId:agentId since agent IDs are globally unique).
This means draft updates only trigger rerenders in components that
subscribe to drafts specifically.
Changes:
- Move drafts from SessionState to SessionStoreState (top-level)
- Add createModalDraft for future use by the create agent modal
- Update getDraftInput/saveDraftInput to work with agentId only
- Update session-context to clear drafts using new API
- Remove investigation console.log statements
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Backend fixes:
- Fix server crash when logging large session_state messages (186 agents)
- Use safe logging that extracts only message/stack properties
- Prevents TypeError in util.inspect on circular refs or deep objects
Frontend loading state fixes:
- Add reactive WebSocket update to prevent stale session.ws references
- Add timeout/retry wrapper for session_state loading (3 retries × 15s)
- Add hasEverReceivedSessionState flag to track cached data across reconnects
- Implement data-aware loading (isInitialLoad vs isRevalidating)
- Show reconnecting badge instead of hiding agents on reconnect
Debug improvements:
- Add detailed connection state logging in useAggregatedAgents
- Add connection status logging in AgentInputArea
- Track connecting reasons for easier debugging
Fixes:
- Agent screen no longer shows false "Offline" toast on reconnect
- Home screen shows loading immediately (no empty state flash)
- Home screen keeps agents visible during reconnect with badge
- Stuck loading has timeout protection with graceful degradation
- Server no longer crashes when sending session_state with many agents
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Finalizes the pure Zustand refactor by ensuring all components properly access both session state and imperative methods through useDaemonSession. Moves CLAUDE.md to root and ignores local overrides.
Changes:
- Fix useDaemonSession to return stable combined state + methods object
- Update components to use useDaemonSession instead of direct context
- Fix realtime context to work with session state only
- Move CLAUDE.md to root, ignore CLAUDE.local.md for local config
- Add proper null checks and type safety throughout
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Replace direct `agentId` prop usage with `agentIdRef.current` to prevent
messages from being sent to the wrong agent during navigation.
Fixed 3 instances:
- handleSendMessage: Line 383
- handleSendQueuedNow: Line 869
- handleCancelAgent: Line 834
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Problem: After migrating to pure Zustand, useDaemonSession returned only
SessionState from the store, but components need both state AND imperative
APIs (like sendAgentMessage, createAgent, etc.).
Solution: Create DaemonSession type that combines:
- SessionState (from Zustand store)
- Imperative APIs (from SessionContext)
- Wrapped store actions (getDraftInput, setFocusedAgentId, etc.)
Changes:
- Added DaemonSession type to use-daemon-session.ts
- useDaemonSession now merges sessionState + context + store actions
- Wraps store actions to bind serverId automatically
- Updated prop types in components to use DaemonSession
- Fixed use-session-directory.ts to use SessionState
This restores component compatibility while keeping pure Zustand architecture.
Still TODO: Fix remaining components that use SessionContext directly
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Problem: lastActivityAt was only updated when agent_state messages arrived
(which only happens on agent lifecycle changes), not when the agent was
actively streaming output. This meant the agent directory showed stale
"last activity" times.
Solution: Update agent.lastActivityAt whenever agent_stream events arrive,
using the event's timestamp. Now lastActivityAt tracks real-time activity.
Updates happen on:
1. agent_state message → lastActivityAt = updatedAt (from server)
2. agent_stream message → lastActivityAt = event.timestamp (real-time!)
This ensures the agent directory always shows fresh activity times.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Problem: Agent directory was still being synced from SessionProvider to
Zustand store, violating the "SessionProvider is just a message handler"
principle and creating unnecessary state duplication.
Solution: Make agent directory pure derived state:
- Removed agentDirectory from SessionStoreState
- Removed setAgentDirectory/clearAgentDirectory actions
- Changed getAgentDirectory to compute on-demand from session.agents
- Removed buildAgentDirectoryEntries and syncing from SessionProvider
- Updated useAggregatedAgents to derive from sessions directly
How it works now:
- Agent directory is computed on-demand from session.agents Map
- lastActivityAt automatically updates when agents update via WebSocket
- No syncing, no stale state, no overhead
- Single source of truth: session.agents
Benefits:
- Eliminated redundant state (agentDirectory was duplicate of agents)
- No sync overhead or complexity
- Always fresh data (derived on read)
- Simpler mental model (agents is the only source)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Problem: SessionContext used useSyncedSessionState which synced every state
update from React useState to Zustand, creating double overhead and complexity.
Solution: Complete migration to pure Zustand architecture:
- session-store.ts is now the single source of truth
- Moved ALL state directly into Zustand (no React useState)
- Added per-session state: messages, agents, commands, permissions, etc.
- Added Zustand actions for all state updates (setMessages, setAgents, etc.)
- Exported all types (MessageEntry, Agent, Command, etc.)
- session-context.tsx is now a pure WebSocket message handler
- Removed useSyncedSessionState hook entirely
- Removed all useState calls for session state
- Removed sync machinery (syncSessionField, syncSessionPartial)
- WebSocket handlers now call Zustand setters directly
- Context only provides imperative APIs (ws, audioPlayer, actions)
- No state values in context
Architecture change:
Before: WebSocket → React useState → sync → Zustand (double overhead)
After: WebSocket → Zustand directly (single source of truth)
Benefits:
- Eliminated double overhead from React → Zustand syncing
- Single state update per WebSocket message
- Better re-render optimization via Zustand selectors
- Cleaner separation: SessionProvider = message handler, SessionStore = state
- Reduced complexity: removed 400+ lines of hybrid sync code
Backward compatibility:
- useDaemonSession() already reads from Zustand, no changes needed
- Type exports re-exported from session-store for compatibility
- Components work exactly the same
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit implements a critical performance optimization by removing
unused orchestrator logic that was causing thousands of unnecessary
store updates per minute:
1. Removed orchestratorFocusedAgentId state and auto-selection logic
- The orchestrator auto-selected "most recently active agent"
- Nothing in the codebase actually reads focusedAgentId
- Simplified focusedAgentId to just focusedAgentOverride (user selection only)
2. Stopped updating timestamps on every stream event
- Previously updated lastActivityAt/updatedAt on every agent_stream event
- These events occur 15+ times per second during streaming
- Created 2700+ store updates per minute from a single agent
3. Removed focusedAgentId from store sync
- No longer syncs focusedAgentId changes to the store
- Reduces cascading updates throughout the app
Expected impact:
- 95%+ reduction in store updates during agent streaming
- Home screen no longer re-renders during agent activity
- Improved UI responsiveness and reduced battery usage
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
The previous fix only applied unstable_transformImportMeta to the native
platform, but Zustand 5's import.meta.env usage also breaks on web.
Moving the transform to the top level ensures it applies to both web and
native platforms, fixing the "Cannot use 'import.meta' outside a module"
error across all platforms.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>