fix: PGlite session stability + voice error handling#37
Merged
Conversation
PGlite is single-writer — concurrent DB writes from gateway health/tick events cause "Another write batch or compaction is already active" errors. Add a WriteQueue that serializes all PGlite operations (query, exec, transaction) so only one runs at a time. The drizzle instance and schema setup both use the queued client. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…load Chat messages were stored in localStorage (per-device) and PGlite (per-device instance), causing history to regress when switching devices. Now the gateway's chat.history RPC is fetched first as the source of truth, with local messages merged in (gateway wins on conflicts). localStorage becomes a write-through cache, and the DB is a fallback only when the gateway is unreachable. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When accessing CrewCmd from a tablet/remote device via Tailscale, the STT endpoint fetch would fail with "TypeError: Load failed" and spam the console. Now both VoiceRecorder and VoiceAgent show visible error messages instead. The STT probe also uses a 5s timeout to fail fast on unreachable hosts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three targeted fixes for stability issues on multi-device setups:
Bug 1: PGlite Compaction Race Condition (
b5237ad)Added a
WriteQueueclass that serializes all PGlitequery/exec/transactioncalls through a sequential queue via Proxy. PreventsAnother write batch or compaction is already activeerrors from concurrent gateway health/tick events.Bug 2: Session Resume Across Devices (
ae31248)Reordered the chat history load waterfall: gateway (
/api/chat/history) is now fetched as the authoritative source before falling back to PGlite DB. Gateway messages win on conflicts; local-only messages are merged in. localStorage is write-through cache only.Bug 3: Voice Transcription Error UX (
a7c2d8a)Voice recorder and voice agent now show user-facing error messages instead of spamming console.error when the STT endpoint is unreachable. Added 5s timeout on STT probe. URLs were already relative.
Relates to TSK-390