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
test: await canvas draw assertions in songs tests to fix MidiVisualization CI flake (#2580)
[._.]/ Adam Eivy0c12c54c03a2
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 5d593be388..f70652470c 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -63,3 +63,4 @@- **Fix the DevTools → Usage page crashing with "(providers || []).map/filter is not a function".** `services/providers.getAllProviders()` returns the wrapped `{ activeProvider, providers }` object, but `routes/usage.js` (GET `/api/usage`) and `services/providerUsage.js#getProviderQuotas` (GET `/api/usage/providers`) passed that object straight into `.map`/`.filter`, throwing on every request so the Usage page showed "Couldn't read provider usage." / "No usage data available." Both call sites now unwrap `.providers` via the `Array.isArray(result) ? result : (result?.providers || [])` pattern already used in `jiraReports.js`/`loops.js`. The two test suites mocked `getAllProviders` as a bare array (masking the bug); their mocks now return the real object shape, plus a new `getProviderQuotas` regression test asserts the unwrap.- **[issue-2598] Add Antigravity + Grok subscription-usage adapters via headless TUI `/usage` scrape.** DevTools → Usage previously showed "not available" placeholders for the `agy` (Antigravity) and `grok` (Grok Build) provider families, because neither CLI exposes quota in non-interactive `--print` mode (there `/usage` is treated as an LLM prompt — wrong data, and it burns tokens). Their real usage surface is an interactive slash command (`/usage` for agy, `/usage show` for grok), so a new `server/lib/tuiUsageScrape.js#scrapeTuiUsage` drives the TUI in a **sandbox PTY** (a fixed dir under the OS temp dir — never the user's project — trusted once via a primer Enter, output-idle-gated capture, hard-timeout backstop), and `providerUsage.js` parses the rendered panel into the common quota shape. Antigravity reports one card per model group (e.g. Gemini, Claude/GPT) with weekly + 5-hour meters and reset times, treating its bar percentage as **remaining**; Grok reports a single weekly meter treating `Weekly limit: N%` as **used**. Both scrapes are 0-token (the slash command renders synchronously, no LLM turn), user-triggered only, and cached 5 min with single-flight (each scrape costs ~12s). Parse failures degrade to a soft "no quota data" warning card rather than erroring the page. New unit tests cover both parsers, the relative-reset→ISO conversion, and the fetch/cache wiring.- **[issue-2532] Extract the Shell page's socket/session/terminal lifecycle into a `useShellSession` hook.** `pages/Shell.jsx` inlined ~750 lines of xterm setup, the Socket.IO `shell:*` protocol, and the single-subscriber PTY attach/detach contract (the `pendingAttachRef {target,generation}` guards, `claim`-vs-user-intent handling, `userIdleRef` passive-idle gating, `mountedRef` deferred-work guards, and URL sync). That cohesive concern now lives in `client/src/hooks/useShellSession.js` — which documents the full attach/detach contract at the top of the file — and the route drops to a thin presentational shell (header, quick-commands, terminal container) plus two extracted panels, `components/shell/TerminalHotKeys.jsx` and `components/shell/ShellSessionTabs.jsx`. Pure structural refactor toward the WritersRoom pattern — behavior identical, generation guards preserved byte-for-byte, no route-contract change; lint, the hooks barrel test, and the client build stay green.+- **[issue-2580] Await the canvas draw assertions in `MidiVisualization.test.jsx` to fix a CI flake.** The "paints the roll" test `await`ed the footer text (`findByText(/3 notes · /)`) then *synchronously* asserted `expect(ctx.fill).toHaveBeenCalled()`, but the roll paints in the `<MidiPianoRoll>` child a tick after the footer text commits — so CI intermittently landed the paint one tick late and the assertion failed. That draw assertion (and the zoom-controls `ctx.clearRect` assertion, which followed the fit/zoom button clicks) are now wrapped in `waitFor(...)` so they wait for the draw deterministically. Audited the sibling songs canvas tests (`PianoRoll`, `MidiPianoRoll`, `Metronome`, `RoundStack`, `PitchTuner`, `SingToScore`, `SongTraining`, `ReferenceAnalysis`, `SongRecordings`): only `MidiVisualization` gates its paint behind async data loading, so it was the only racy one — `PianoRoll`/`MidiPianoRoll` assert after a synchronous `render()`/`pump()` (no text-`findBy` gap), and the rest have no canvas assertions. Test-only; each test keeps its own explicit `getContext` mock.diff --git a/client/src/components/songs/MidiVisualization.test.jsx b/client/src/components/songs/MidiVisualization.test.jsxindex 0f8c7ef73b..ac42719c7d 100644--- a/client/src/components/songs/MidiVisualization.test.jsx+++ b/client/src/components/songs/MidiVisualization.test.jsx@@ -1,4 +1,4 @@-import { render, screen, cleanup, fireEvent } from '@testing-library/react';+import { render, screen, cleanup, fireEvent, waitFor } from '@testing-library/react';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import MidiVisualization from './MidiVisualization.jsx';import { __clearMidiNotesCache } from '../../hooks/useMidiNotes.js';@@ -71,7 +71,9 @@ describe('<MidiVisualization>', () => {// Loading state first, then the parsed roll.expect(screen.getByText(/Parsing MIDI/)).toBeTruthy();await screen.findByText(/3 notes · /);- expect(ctx.fill).toHaveBeenCalled(); // note bars painted+ // The roll paints in a child effect a tick after the footer text commits —+ // wait for the draw rather than asserting it synchronously (#2580).+ await waitFor(() => expect(ctx.fill).toHaveBeenCalled()); // note bars paintedexpect(screen.getByText(/C4–G4/)).toBeTruthy();expect(screen.getByText(/MuScriptor medium/)).toBeTruthy();// Chord lane detected the triad — toggle button present and sr summary names it.@@ -109,7 +111,7 @@ describe('<MidiVisualization>', () => {fireEvent.click(screen.getByLabelText('Zoom in'));fireEvent.click(screen.getByLabelText('Zoom out'));fireEvent.click(screen.getByLabelText('Fit to width'));- expect(ctx.clearRect).toHaveBeenCalled();+ await waitFor(() => expect(ctx.clearRect).toHaveBeenCalled());});it('play button starts the synth preview and toggles to pause (#2490)', async () => {