Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: make VoicePicker test waitFor guards assert to stop flaking (#1449)
Adam Eivy6237ca5fd13b
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 853df94dab..a986c196a7 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -148,6 +148,8 @@## Fixed+- **[issue-1449] Fixed a flaky VoicePicker test whose `waitFor` guards never actually waited.** Five tests in `VoicePicker.test.jsx` guarded the async voice load with `await waitFor(() => document.querySelector('option[value="kokoro:af_bella"]'))` — but `waitFor` only retries while its callback *throws*, and returning `null` (option not yet rendered) isn't a throw, so it resolved on the first tick and the subsequent `user.selectOptions` could run before `listPipelineTtsVoices` populated the `<option>`s (`Value "kokoro:af_bella" not found in options` in CI). Every non-asserting guard now uses the asserting form (`expect(...).toBeInTheDocument()`), matching the one sibling test that was already correct, so the suite stops losing the load race on slow runners. (`client/src/components/voice/VoicePicker.test.jsx`, #1449)+- **The CyberCity exploration avatar now faces its direction of travel instead of moonwalking.** The runner is modeled facing +Z (visor, chest core, boot toes) while the player rig's forward convention is −Z, so `root.rotation.y = rig.facing` pointed the model's face 180° opposite to its movement — it walked away from the camera while facing it, and at drop-in faced *away* from the city center despite the "facing downtown" spawn intent. The rig math is internally consistent on the −Z convention, so the fix is a single +π yaw offset where the model meets the rig in `PlayerAvatar.jsx`. (`client/src/components/city/PlayerAvatar.jsx`)- **Deleting a Brain memory imported from ChatGPT now removes its on-disk assets instead of orphaning them.** A `chatgpt-import` memory references an archived conversation transcript (`data/brain/imports/chatgpt/<sourceRef>`) and any number of served image/audio/PDF assets (`data/brain/imports/assets/`, embedded as `` links in the transcript). Deleting the memory only tombstoned the JSON record, so those files lived on disk forever — repeatedly importing and deleting exports slowly filled the disk with orphans. The Brain service's `deleteMemoryEntry` now cleans up after a successful delete: it removes the 1:1 archived transcript and unlinks every asset the deleted memory referenced that **no surviving import memory still uses** (a ChatGPT `file-service://` id can legitimately recur across conversations, so shared assets are kept). Cleanup is best-effort — an already-missing file is a no-op and an unlink failure is logged, never thrown, so it can't turn a successful delete into an error. (`server/services/brain.js`, `server/services/chatgptImport.js`)diff --git a/client/src/components/voice/VoicePicker.test.jsx b/client/src/components/voice/VoicePicker.test.jsxindex 6ade78c794..e7ec618053 100644--- a/client/src/components/voice/VoicePicker.test.jsx+++ b/client/src/components/voice/VoicePicker.test.jsx@@ -46,7 +46,9 @@ describe('VoicePicker', () => {const onChange = vi.fn();const user = userEvent.setup();render(<VoicePicker value={null} onChange={onChange} />);- await waitFor(() => document.querySelector('option[value="kokoro:af_bella"]'));+ await waitFor(() => {+ expect(document.querySelector('option[value="kokoro:af_bella"]')).toBeInTheDocument();+ });const select = screen.getByRole('combobox');await user.selectOptions(select, 'kokoro:af_bella');expect(onChange).toHaveBeenCalledWith('kokoro:af_bella');@@ -57,7 +59,9 @@ describe('VoicePicker', () => {const onChange = vi.fn();const user = userEvent.setup();render(<VoicePicker value="kokoro:af_bella" onChange={onChange} placeholder="Project default voice" />);- await waitFor(() => document.querySelector('option[value="kokoro:af_bella"]'));+ await waitFor(() => {+ expect(document.querySelector('option[value="kokoro:af_bella"]')).toBeInTheDocument();+ });const select = screen.getByRole('combobox');await user.selectOptions(select, '');expect(onChange).toHaveBeenCalledWith(null);@@ -84,7 +88,9 @@ describe('VoicePicker', () => {it('preserves an unavailable saved voiceId so the user sees what was bound', async () => {listPipelineTtsVoices.mockResolvedValue({ voices: SAMPLE_VOICES });render(<VoicePicker value="kokoro:retired-voice" onChange={() => {}} />);- await waitFor(() => document.querySelector('option[value="kokoro:af_bella"]'));+ await waitFor(() => {+ expect(document.querySelector('option[value="kokoro:af_bella"]')).toBeInTheDocument();+ });expect(screen.getByRole('option', { name: /retired-voice \(unavailable\)/i })).toBeInTheDocument();});@@ -94,7 +100,9 @@ describe('VoicePicker', () => {previewPipelineTtsVoice.mockResolvedValue(buf);const user = userEvent.setup();render(<VoicePicker value="kokoro:af_bella" onChange={() => {}} previewText="hello" />);- await waitFor(() => document.querySelector('option[value="kokoro:af_bella"]'));+ await waitFor(() => {+ expect(document.querySelector('option[value="kokoro:af_bella"]')).toBeInTheDocument();+ });const button = screen.getByRole('button', { name: /audition kokoro:af_bella/i });await user.click(button);await waitFor(() => {@@ -106,7 +114,9 @@ describe('VoicePicker', () => {it('disables the audition button when no voice is selected', async () => {listPipelineTtsVoices.mockResolvedValue({ voices: SAMPLE_VOICES });render(<VoicePicker value={null} onChange={() => {}} />);- await waitFor(() => document.querySelector('option[value="kokoro:af_bella"]'));+ await waitFor(() => {+ expect(document.querySelector('option[value="kokoro:af_bella"]')).toBeInTheDocument();+ });const button = screen.getByRole('button', { name: /audition voice/i });expect(button).toBeDisabled();});@@ -134,10 +144,14 @@ describe('VoicePicker', () => {it('shares the module-local cache between mounts (single fetch)', async () => {listPipelineTtsVoices.mockResolvedValue({ voices: SAMPLE_VOICES });const { unmount } = render(<VoicePicker value={null} onChange={() => {}} />);- await waitFor(() => document.querySelector('option[value="kokoro:af_bella"]'));+ await waitFor(() => {+ expect(document.querySelector('option[value="kokoro:af_bella"]')).toBeInTheDocument();+ });unmount();render(<VoicePicker value={null} onChange={() => {}} />);- await waitFor(() => document.querySelector('option[value="kokoro:af_bella"]'));+ await waitFor(() => {+ expect(document.querySelector('option[value="kokoro:af_bella"]')).toBeInTheDocument();+ });expect(listPipelineTtsVoices).toHaveBeenCalledTimes(1);});@@ -146,7 +160,9 @@ describe('VoicePicker', () => {try {listPipelineTtsVoices.mockResolvedValue({ voices: SAMPLE_VOICES });const { unmount } = render(<VoicePicker value={null} onChange={() => {}} />);- await waitFor(() => document.querySelector('option[value="kokoro:af_bella"]'));+ await waitFor(() => {+ expect(document.querySelector('option[value="kokoro:af_bella"]')).toBeInTheDocument();+ });unmount();// Advance past the 15-second TTL.vi.advanceTimersByTime(20_000);