fix(agent-console): new session file takes ~60s to appear in preview after daemon subscribe
Symptom
Starting a new agent session from the console: messages sent to the agent reach the process and the agent responds quickly, but the console preview shows nothing for ~60+ seconds. The preview starts working only after the slow list-poll picks up the session file.
Root cause
Not a devkitd delay — a regression from the daemon event-stream subscription in useAgentList:
- New agent appears → daemon sweep emits
agent.appeared→ immediaterefresh()→ agent listed, butsessionFilePathisnull(the agent hasn't written its session file yet). - The session file materializes a few seconds later, but no daemon event fires — the daemon only observes process lifecycle (
ps), not session-file attribution. - Meanwhile the daemon-subscribed path relaxes the list poll to
LIST_FALLBACK_INTERVAL_MS = 60_000(useAgentList.ts), sosessionFilePathstaysnulluntil the next blind poll. useAgentConversationpolls every 3s correctly, butagent.sessionFilePathisnull→no-session-filestate — nothing to read.
Before the daemon subscription existed, the 3s blind poll incidentally picked up session files within seconds, masking this gap.
Evidence
useAgentList.ts: fast poll →LIST_FALLBACK_INTERVAL_MSrelax on successfulattachDaemonRefresh; comment already notes fallback covers "attribution drift (status text, session files) the daemon can't see"useAgentConversation.ts:PREVIEW_POLL_INTERVAL_MS = 3000— preview is fast oncesessionFilePathis populated- Related: #398 (preview refresh timing around session files)
Proposed fix (not started)
Warm-up refreshes after lifecycle events: when a daemon appeared/agent.started event triggers refresh, also schedule 2–3 delayed refreshes (~+4s, +10s, +25s) to cover session-file/status attribution materializing after the appear — without re-tightening the steady-state poll.
Alternative: have useAgentConversation trigger a list refresh() while in no-session-file state (self-healing, but couples the two hooks).