Fix useDaemonSession to return combined state + APIs

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>
This commit is contained in:
Mohamed Boudra
2025-12-02 14:27:57 +00:00
co-authored by Claude
parent f5ec3bffb7
commit e8aa08159a
8 changed files with 161 additions and 19 deletions
@@ -1095,7 +1095,6 @@ const styles = StyleSheet.create(((theme: any) => ({
container: {
flexDirection: "column",
position: "relative",
flex: 1,
},
borderSeparator: {
height: theme.borderWidth[1],
@@ -252,7 +252,7 @@ function AgentFlowModal({
}, [serverId, daemonEntries]);
const [selectedServerId, setSelectedServerId] = useState<string | null>(initialServerId);
const selectSessionSlice = useCallback(
(session: SessionContextValue | null): CreateAgentSessionSlice | null => {
(session: import("@/hooks/use-daemon-session").DaemonSession | null): CreateAgentSessionSlice | null => {
if (!session) {
return null;
}