Add SpriteWakeCoordinator for reliable sprite wake-up#56
Add SpriteWakeCoordinator for reliable sprite wake-up#56zmanian wants to merge 1 commit intomcintyre94:mainfrom
Conversation
Extract sprite wake logic into a testable coordinator that polls status, retries wake pings on a configurable interval, and distinguishes genuine network failures from transient server errors (e.g. 503 during warm-up). - SpriteWakeCoordinator: poll-based state machine with injectable sleep, fetchStatus, and triggerWake closures for testability - wakeSpriteIfNeeded on SpritesAPIClient: convenience wrapper - ChatViewModel: pre-wake sprite before sending; skip question tool install on timeout instead of blocking - DashboardViewModel: replace manual polling loop with coordinator - 4 unit tests covering already-running, wake transition, server error timeout, and network failure escalation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Can you explain the motivation for this one a bit? Sprites should wake on their own when we call them, and I think doing an extra wait for them to wake before calling them is just going to add latency. Especially because there isn't an actual wake command, just a no-op exec, which AFAIK just wakes it in the same way as any other call. |
|
Good question. Two motivations:
That said, if the Sprites API now reliably blocks/queues exec calls until the sprite is warm, the pre-wake step is unnecessary overhead and I'm happy to close this. Do exec WebSocket connections wait for the sprite to finish waking now, or do they still connect immediately? |
This is what I can't reproduce - when I send a message to a cold sprite it just shows the "Connecting..." status for a few seconds and then starts streaming. The Connecting status is basically a wake up, it's just done with a
The I think my more general view here is that the sprite platform is designed around being fast to start/stop, and automatically starting when it receives requests. I'm trying to design to/take advantage of the way the platform works, and I think custom wake logic should be unnecessary in general. |
Summary
SpriteWakeCoordinatorthat polls status, retries wake pings on a configurable interval, and distinguishes genuine network failures from transient server errors (e.g. 503 during warm-up)wakeSpriteIfNeededconvenience method onSpritesAPIClientChatViewModel(pre-wake before sending, skip question tool install on timeout) andDashboardViewModel(replaces manual polling loop)Test plan
Generated with Claude Code