Commit Graph
57 Commits
Author SHA1 Message Date
Mohamed BoudraandClaude 8b87b0a4e2 Remove agent directory syncing, make it pure derived state
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>
2025-12-02 14:15:32 +00:00
Mohamed BoudraandClaude f5c6bce54f Migrate SessionContext to pure Zustand, eliminate hybrid overhead
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>
2025-12-02 14:08:56 +00:00
Mohamed BoudraandClaude 32e111e1bf fix: remove unused focusedAgentId orchestrator logic and timestamp thrashing
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>
2025-12-02 13:14:49 +00:00
Mohamed Boudra 7896bdd42c revert: remove Phase 3 complexity - server handles persistence 2025-12-02 11:06:57 +00:00
Mohamed Boudra 3208624c5e perf: cap messages and optimize persistence (Phase 3) 2025-12-02 10:50:11 +00:00
Mohamed Boudra 6e259c37db refactor: SessionProvider to use Zustand setters directly (Phase 2b) 2025-12-02 10:13:25 +00:00
Mohamed Boudra b278b43fac feat: extract lightweight agent directory (Phase 1) 2025-12-02 09:28:52 +00:00
Mohamed Boudra 34e0e21657 chore: add session perf instrumentation 2025-12-02 09:20:02 +00:00
Mohamed Boudra dc26bf713e feat(dictation): add resilient rpc retries and status toasts 2025-12-02 08:12:02 +00:00
Mohamed Boudra 71b238c0cd feat(dictation): migrate transcription to session rpc hook 2025-12-02 04:30:38 +00:00
Mohamed Boudra b36f870ee9 Add RPC helper for agent initialization 2025-12-02 03:57:36 +00:00
Mohamed BoudraandClaude 7c1517d830 feat(server): add Playwright MCP with headless mode to spawned Claude agents
Spawned agents now get Playwright browser automation capabilities by default.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 05:08:56 +00:00
Mohamed BoudraandClaude e80989ea78 perf: remove raw field from timeline items to reduce payload size
Remove the `raw` field that was duplicating provider data in timeline
items, reducing WebSocket payload sizes by 64-85%:
- session_state: ~320KB → ~48KB
- agent_stream_snapshot: ~320KB → ~114KB

Changes:
- Remove raw from AgentTimelineItem, AgentStreamEvent, AgentPermissionRequest
- Remove raw assignments from claude-agent.ts and codex-agent.ts
- Remove provider_event handling from stream.ts (only used for Codex raw)
- Update tests to reflect new behavior

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 18:20:33 +00:00
Mohamed BoudraandClaude ae4678bca8 fix: eliminate duplicate WebSocket messages during agent history priming
- Skip dispatching individual agent_stream events when replaying history
  (the snapshot is sent after priming anyway, so individual events were wasted)
- Add WebSocket message logging on client (type, size, id) for debugging
- Change default daemon URL from dev to localhost
- Clean up unused imports in session.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 17:44:07 +00:00
Mohamed Boudra 1b019c4688 chore: update android scripts and add dev runner with IPC restart support 2025-11-28 11:39:31 +01:00
Mohamed Boudra b97ae99b2b feat(app): add Android product flavors and env-based daemon config 2025-11-28 08:19:41 +01:00
Mohamed Boudra 08dc2ed937 feat(app): add zustand store for session state management 2025-11-27 21:36:03 +01:00
Mohamed Boudra bf58e81ce8 refactor(app): simplify session directory with direct snapshots and add sessionReady state
Replace subscription-based session accessor pattern with direct snapshot updates in daemon connections context. Add sessionReady flag to connection state to track when initial agent list has been received. Auto-select first ready host in create agent modal. Migrate from app.json to app.config.js. Add android:release script and Playwright testing docs.
2025-11-27 21:06:48 +01:00
Mohamed Boudra 670c38ab8c Remove legacy host auto-connect state 2025-11-26 18:53:53 +01:00
Mohamed Boudra db87f331fb Remove primary host plumbing 2025-11-26 18:30:04 +01:00
Mohamed Boudra e6d2998904 Remove primary host concept 2025-11-26 17:51:25 +01:00
Mohamed Boudra 04d51fbe10 Rename daemon UI copy to host 2025-11-26 17:26:25 +01:00
Mohamed Boudra 59967aad87 chore: land multi-daemon rollout 2025-11-26 08:47:49 +00:00
Mohamed BoudraandClaude 4ab79b1a50 feat: add multi-daemon support with session routing and connection management
Introduce DaemonRegistry and DaemonConnections contexts for managing multiple server connections. Add session directory for aggregating agents across daemons, with automatic routing based on agent/server context.

Key changes:
- Add daemon profile management (add/edit/remove/set default)
- Implement connection state tracking with reconnection and exponential backoff
- Create useAggregatedAgents hook for unified agent list across daemons
- Add useDaemonSession and useDaemonRequest hooks for daemon-scoped operations
- Update agent routes to include serverId for proper session routing
- Add connection health indicators on home screen and settings
- Persist session snapshots per daemon for faster hydration on reconnect
- Guard screens gracefully when target daemon is offline
- Add React Query for consistent loading/error state management

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 08:25:02 +01:00
Mohamed Boudra 30d1b63b2b chore: typecheck and build readiness 2025-11-24 22:31:41 +01:00
Mohamed Boudra a95184cc5a Fix agent web loading issues 2025-11-23 14:49:29 +01:00
Mohamed Boudra 47a99f5668 Fix reasoning timeline UI and type errors 2025-11-23 14:12:53 +01:00
Mohamed Boudra 95bacf8fc7 feat: add git branch/worktree setup, message queueing, file explorer improvements, and server restart 2025-11-22 23:20:42 +01:00
Mohamed Boudra 9feec81047 feat: improve audio streaming and add wait-for-agent cancellation support 2025-11-16 18:02:13 +01:00
Mohamed Boudra 9dcc8314b2 Add barge-in telemetry 2025-11-15 19:31:27 +01:00
Mohamed Boudra 4bd36c0808 feat: keep agents running during orchestrator speech 2025-11-15 19:21:57 +01:00
Mohamed Boudra 24a245bd17 auto-focus orchestrator agent during realtime 2025-11-15 19:18:39 +01:00
Mohamed Boudra 7284efd0fe Prototype streaming TTS chunks 2025-11-15 19:06:53 +01:00
Mohamed Boudra 8202985bad Interrupt focused agent before realtime turns 2025-11-15 18:35:13 +01:00
Mohamed Boudra 673c6f1594 Abort realtime turn on speech start 2025-11-15 18:21:02 +01:00
Mohamed Boudra 2a02f41182 refactor: implement agent cancellation and deletion with UI controls
Add cancel button during agent runs, real-time mode toggle in all states, and agent deletion via long-press action sheet. Server now handles cancel_agent_request and delete_agent_request messages, cleaning up agent state and notifying clients.
2025-11-15 18:13:04 +01:00
Mohamed Boudra b45583a2b2 refactor: standardize pending permission keying and user message hydration 2025-11-15 17:36:15 +01:00
Mohamed Boudra c37e499562 refactor(agent): unify timeline events with tool_call schema and add resume/refresh capabilities 2025-11-15 11:58:41 +01:00
Mohamed BoudraandClaude 8cf808b14d refactor(agent): consolidate agent system into unified AgentManager with provider-based architecture
Replace separate ACP and agent-types modules with unified AgentManager using provider pattern. Migrate Claude and Codex implementations to provider-specific clients. Streamline session-agent integration, remove old ACP notification types, and introduce agent timeline events. Delete obsolete documentation and test files. Add AgentRegistry for persistence and agent-stream-based communication pattern.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-15 02:06:09 +01:00
Mohamed Boudra f766a18d7b refactor(file-explorer): centralize navigation state in session context and optimize initialization 2025-11-11 18:15:46 +01:00
Mohamed Boudra c5b30ed878 Add read-only file explorer 2025-11-07 20:36:23 +01:00
Mohamed BoudraandClaude 086dde30cc feat(agent): add git diff viewer and improve permission handling
- Add git diff viewer screen accessible via agent dropdown menu
- Implement git_diff_request/response WebSocket messages
- Add dropdown menu to agent screen header with "View Changes" option
- Clear pending permissions when starting new agent turn to prevent conflicts
- Treat agent refusals as completed rather than failed state
- Add test coverage for permission handling edge cases
- Configure vitest to run in single-threaded mode for stability
- Remove redundant wrapper in agent stream view

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 22:19:16 +01:00
Mohamed Boudra edf47a24bc refactor(agent): consolidate agent type definitions and add multi-agent-type support 2025-10-26 18:03:03 +01:00
Mohamed Boudra 2c1b5b13fe fix(agent): track initialization state to prevent duplicate agent initialization 2025-10-26 16:28:55 +01:00
Mohamed Boudra c4bb10d3c9 feat: add voice note recording overlay with transcription feedback and worktree support 2025-10-26 13:48:14 +01:00
Mohamed Boudra 7d1ef63c8f chore(deps): upgrade claude-code-acp to v0.8.4 and optimize image upload implementation 2025-10-26 09:07:41 +01:00
Mohamed Boudra a3224175ee feat: add image upload support to agent chat with attachment preview 2025-10-26 07:35:06 +01:00
Mohamed Boudra faf087b3a6 refactor: standardize footer height calculations and alignment across components 2025-10-25 22:14:15 +02:00
Mohamed Boudra 8d591da671 refactor: add dynamic input height, agent sorting, and last activity tracking 2025-10-25 21:56:44 +02:00
Mohamed Boudra 64d1518a6f Prompt is too long 2025-10-25 15:14:44 +02:00