Skip to content

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

fix: isolate Wiki vault-default test from cross-test mock pollution (#2643)

Adam Eivy995d95578847
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index fa18310569..b3bd6eb874 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -36,6 +36,7 @@
## Fixed
+- **[issue-2643] De-flake the Wiki vault-default test under full-suite load.** `Wiki.test.jsx`'s "defaults to the first vault" (and the sibling "restores the selected vault") assertions checked `scanNotesVault` synchronously right after `await waitFor(...)` on the rendered vault id. That mock call is fired by a *separate* `useEffect` keyed on the selected vault, so the committed overview render can land before the passive effect flushes — reliably true in isolation, but on a CPU-saturated full client run the bare assertion raced ahead of the effect and failed (`expected vi.fn() to be called with arguments`). The two mock-call assertions now sit inside their own `waitFor`, awaiting the async side-effect instead of sampling it. Test-only change (no `test.retry` or timeout inflation) — no runtime behavior change.
- **[issue-2540] Stop full-JSONB table loads for pipeline issue id sweeps and bound the multi-account message inbox aggregate.** `listIssueIds` (the conflict-journal orphan-base-hash sweep + tombstone GC) went through `readState()` → `loadAll()`, pulling every issue's full `data` JSONB — up to ~12MB of stage `runHistory` each — into memory only to read the ids; it now sources the store's `SELECT id` projection, with the PG backend filtering tombstones via the mirrored `deleted` column (`listIds({ includeDeleted })`) so the whole-record load is skipped entirely for the default live sweep. Separately, `messageSync.getMessages`'s multi-account inbox spread every message from every account into one array and globally sorted it before slicing a page; it now bounds each account's contribution to the top `offset+limit` by date and merges those heads, so a paged inbox reads `accounts × (offset+limit)` messages into the merge instead of the full cross-account total (the exact `total` count is preserved).
- **[issue-2538] Bound Spotify auth and privacy-broker fetches, and single-flight token refresh.** The Spotify token endpoint (`spotifyAuth.js`) and the BADBOOL / CA-registry broker fetchers (`privacyBrokers.js`) used bare `fetch` with no timeout, so a hung `accounts.spotify.com` could stall an OAuth callback or a history-sync refresh — and a broker source that never responded could hang a user-triggered refresh — indefinitely. All three now go through the shared `fetchWithTimeout` helper with a 15s cap. Separately, concurrent `getAccessToken()` callers that all found the token expired each POSTed their own refresh, and since Spotify rotates the grant the losers persisted a stale token (last-write-wins); refreshes now share one in-flight `refreshPromise` (single-flight), so the grant is rotated exactly once and the guard is released on settle so a failed refresh can retry.
- **[issue-2552] Enlarge above-the-fold mobile touch targets to 44px.** The GoalDetailPanel close button (`p-1` + a 16px icon, ~24px) and the notification bell (40px min) were below the 44×44 touch-target minimum the shell's other chrome controls already meet. The close button now uses `min-h-[44px] min-w-[44px]` centered around its icon (matching the shared `Drawer` control sizing), and the bell's mobile hit area is bumped 40→44px (its `sm:` desktop shrink is unchanged). The notification panel also gains `max-w-[calc(100vw-2rem)]` so its `w-80` width can't overflow a narrow mobile sidebar, and the ⌘K result rows get a `min-h-[44px]` so each is comfortably tappable.
diff --git a/client/src/pages/Wiki.test.jsx b/client/src/pages/Wiki.test.jsx
index c892e2f841..40e89c5936 100644
--- a/client/src/pages/Wiki.test.jsx
+++ b/client/src/pages/Wiki.test.jsx
@@ -54,13 +54,16 @@ describe('Wiki vault URL wiring', () => {
it('defaults to the first vault when no ?vault= param is present', async () => {
renderWiki('/wiki/overview');
await waitFor(() => expect(screen.getByTestId('overview')).toHaveTextContent('overview:vault-a'));
- expect(scanNotesVault).toHaveBeenCalledWith('vault-a', { limit: 1000 });
+ // scanNotesVault is fired by a separate effect keyed on the selected vault id;
+ // wait for that async side-effect rather than asserting it synchronously — the
+ // passive effect can lag the committed overview render under full-suite load (#2643).
+ await waitFor(() => expect(scanNotesVault).toHaveBeenCalledWith('vault-a', { limit: 1000 }));
});
it('restores the selected vault from the ?vault= param', async () => {
renderWiki('/wiki/overview?vault=vault-b');
await waitFor(() => expect(screen.getByTestId('overview')).toHaveTextContent('overview:vault-b'));
- expect(scanNotesVault).toHaveBeenCalledWith('vault-b', { limit: 1000 });
+ await waitFor(() => expect(scanNotesVault).toHaveBeenCalledWith('vault-b', { limit: 1000 }));
});
it('preserves ?vault= through the base /wiki redirect', async () => {