Skip to content

Fix production mock-data gaps: wallet prefetch isolation, overview/API-key types, mock gating - #744

Merged
Jambox11 merged 1 commit into
mux-labs:stagingfrom
graceuvala-collab:fix/705-708-mock-tenant-isolation
Aug 30, 2026
Merged

Fix production mock-data gaps: wallet prefetch isolation, overview/API-key types, mock gating#744
Jambox11 merged 1 commit into
mux-labs:stagingfrom
graceuvala-collab:fix/705-708-mock-tenant-isolation

Conversation

@graceuvala-collab

Copy link
Copy Markdown
Contributor

Summary

Closes #705
Closes #706
Closes #707
Closes #708

⚠️ Warning

This PR is implementation only, per explicit instruction from the requester. No automated test coverage (Vitest or Playwright) was added, even though all four linked issues' acceptance criteria ask for tests that fail if the gap returns. Please add regression tests covering:

  • Prefetch cache tenant isolation (different session tokens must not share a cache entry) and the now-attached Authorization header.
  • /api/overview and /api/api-keys returning 503 in a production build with no backend configured.
  • APIKeyModal's fallback key generator throwing (not fabricating a secret) when mock fallback isn't allowed.

before or while merging this branch.

Test plan

  • pnpm test (Vitest)
  • pnpm run typecheck
  • pnpm run test:e2e (Playwright) for the wallets sidebar-hover prefetch and API keys create/revoke flows
  • Manual: NODE_ENV=production with NEXT_PUBLIC_API_URL unset → /api/overview and /api/api-keys (GET/POST/PATCH) return 503 backend_unavailable

…view/API-key types, and mock fallback gating

- src/lib/walletsPrefetchCache.ts: prefetch now attaches the caller's
  session bearer token and keys its in-memory cache entry by that
  token, so a wallets prefetch started under one session can never be
  served to a different session that signs in afterward on the same
  tab/device within the TTL window (mux-labs#705).
- src/types/overview.ts, src/types/apiKey.ts: extracted OverviewData /
  ApiKey / CreatedApiKey out of src/mock-data/* into canonical type
  modules; DashboardOverview, ApiKeysTable, APIKeyModal, and the
  useApiKeys/useRevokeApiKey hooks now type against these instead of
  the mock fixtures, so a real mux-backend response only needs to
  satisfy the real contract (mux-labs#706, mux-labs#707, mux-labs#708).
- src/app/api/overview/route.ts and src/app/api/api-keys/route.ts
  (GET/POST/PATCH): gated the mock-data fallback behind
  isMockFallbackAllowed(), matching /api/wallets and /api/activity, so
  a production deployment with no backend configured returns 503
  instead of silently listing/creating/revoking against mock data
  (mux-labs#706, mux-labs#707).
- src/components/APIKeyModal.tsx: the modal's standalone (no
  onCreateKey) key generator now throws instead of fabricating a
  secret when isMockFallbackAllowed() is false (mux-labs#708).
- Updated README.md, docs/frontend-env-vars.md, and
  src/docs/API_Hooks.md to describe the new production/mock split and
  type ownership.

Closes mux-labs#705, Closes mux-labs#706, Closes mux-labs#707, Closes mux-labs#708

WARNING: implementation only, per explicit instruction — no automated
test coverage (Vitest/Playwright) was added for these changes, despite
the linked issues' acceptance criteria asking for it. Please add
regression tests before/while merging.
@Jambox11
Jambox11 merged commit a88eb8a into mux-labs:staging Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants