diff --git a/apps/radio/scripts/check-node-chunk.ts b/apps/radio/scripts/check-node-chunk.ts index 40fd9ce54..d4db24bb4 100644 --- a/apps/radio/scripts/check-node-chunk.ts +++ b/apps/radio/scripts/check-node-chunk.ts @@ -200,8 +200,8 @@ for (const [name, source] of flowChunks) { } // The canvas is Node mode's only door to React Flow: the chunk that lazily -// loads it also draws the Stage, Rack and inspector, which a phone opens -// first, so it must not reach React Flow through static imports. +// loads it also draws the Rack and inspector, which load without React +// Flow, so it must not reach React Flow through static imports. const canvasChunks = [...chunks.keys()].filter( (name) => name.startsWith("node-canvas-") || name.startsWith("immutable-node-canvas-") diff --git a/apps/radio/src/components/radio/NODE_MODE_PROPOSAL.md b/apps/radio/src/components/radio/NODE_MODE_PROPOSAL.md index 24e5528c1..69683ae27 100644 --- a/apps/radio/src/components/radio/NODE_MODE_PROPOSAL.md +++ b/apps/radio/src/components/radio/NODE_MODE_PROPOSAL.md @@ -1,6 +1,6 @@ # Node Mode v1 -Node Mode replaces Multiple with a React Flow patch editor, Stage and Rack over +Node Mode replaces Multiple with a React Flow patch editor and a desktop Rack over radio's managed playback engine. This is the current implementation contract for agents changing Node Mode. The product release is **v1**; its persisted graph schema is **version 2**, which added source strips. Schema versions and the @@ -142,8 +142,9 @@ release; insertion and cable surgery commit one undoable graph change. Cancellin or pinching a drag clears its insertion target. Removing a Merge is refused when healing would break a working lane's routes. -Stage and Rack provide source controls outside the zoomed canvas. Rack also lists -loose, empty or invalid modules and shows graph issues when no lane compiles. +On desktop, the Rack provides source controls outside the zoomed canvas. It also lists +loose, empty or invalid modules and shows graph issues when no lane compiles. A phone +shows the canvas alone. Inspect opens shared source, device, native, FX or output settings; desktop Inspect expands a collapsed Rack panel and phones use the inspector drawer. Local files that cannot survive reload expose Pick again. @@ -175,7 +176,7 @@ throttled graph or engine writes. | Persistence, migration and local NAM retention | [`playback-sessions.ts`](../../lib/collections/playback-sessions.ts), [`migrations/`](../../lib/collections/migrations/) | | Backup validation, preview and application | [`export-import.ts`](../../lib/db/export-import.ts), [`nam-backup.ts`](../../lib/db/nam-backup.ts) | | Canvas, palette and cable editing | [`node-canvas.tsx`](node/node-canvas.tsx), [`node-palette.tsx`](node/node-palette.tsx), [`connect-dialog.tsx`](node/connect-dialog.tsx), [`rewire-dialog.tsx`](node/rewire-dialog.tsx) | -| Stage, Rack, inspector and shared source forms | [`node-stage.tsx`](node/node-stage.tsx), [`node-rack.tsx`](node/node-rack.tsx), [`node-inspector.tsx`](node/node-inspector.tsx); source/device `*-content.tsx` files beside them | +| Rack, inspector and shared source forms | [`node-rack.tsx`](node/node-rack.tsx), [`node-inspector.tsx`](node/node-inspector.tsx); source/device `*-content.tsx` files beside them | | Shared knobs, sliders and control gestures | [`knob.tsx`](../../../../../packages/ui/src/components/knob.tsx), [`slider.tsx`](../../../../../packages/ui/src/components/slider.tsx) | | Node MIDI identities and actions | [`node-midi-actions.ts`](../../lib/midi/node-midi-actions.ts), [`use-node-midi.ts`](../../lib/hooks/use-node-midi.ts) | diff --git a/apps/radio/src/components/radio/node/audio-input-controls.tsx b/apps/radio/src/components/radio/node/audio-input-controls.tsx index 4404f2f89..128787bcf 100644 --- a/apps/radio/src/components/radio/node/audio-input-controls.tsx +++ b/apps/radio/src/components/radio/node/audio-input-controls.tsx @@ -29,9 +29,9 @@ import type { NodeDevice } from "./use-node-devices"; /** * Audio Input Controls * - * The pieces an Audio input shows on the canvas and in the Stage and Rack, + * The pieces an Audio input shows on the canvas and in the Rack, * in DJ's words: Go live and Pause input, Paused and Live, the device and its - * channels. None of them import React Flow, so the Stage and Rack can load + * channels. None of them import React Flow, so the Rack can load * them without the canvas chunk. */ diff --git a/apps/radio/src/components/radio/node/branch-edge.tsx b/apps/radio/src/components/radio/node/branch-edge.tsx index 6ec96aa72..80f32743a 100644 --- a/apps/radio/src/components/radio/node/branch-edge.tsx +++ b/apps/radio/src/components/radio/node/branch-edge.tsx @@ -23,7 +23,7 @@ import { keepControlKeys } from "./module-frame"; * carries that branch's gain, pan, mute and solo. It draws as a plain wire * with a small tag at its middle ("2", "L", "Mid", plus what is set), and * the tag opens the branch's controls. The inspector lists the same - * controls for every branch, so a phone reaches them from the Rack. + * controls for every branch, so a phone reaches them from its drawer. */ export type BranchFlowEdge = FlowEdge; diff --git a/apps/radio/src/components/radio/node/cable-surgery.ts b/apps/radio/src/components/radio/node/cable-surgery.ts index 5c12202d3..b293c7a4c 100644 --- a/apps/radio/src/components/radio/node/cable-surgery.ts +++ b/apps/radio/src/components/radio/node/cable-surgery.ts @@ -8,7 +8,7 @@ * or else a node picked from the palette; * - Cmd+D (Ctrl+D elsewhere) duplicates the selected nodes. * Keys act from the canvas or with nothing focused, never from a field, a - * dialog, the Stage or the Rack. Lives outside the canvas chunk's React + * dialog, the Rack or the inspector. Lives outside the canvas chunk's React * Flow imports, so it is testable without them. */ diff --git a/apps/radio/src/components/radio/node/device-nodes.test.tsx b/apps/radio/src/components/radio/node/device-nodes.test.tsx index e28809cb0..305d19b6d 100644 --- a/apps/radio/src/components/radio/node/device-nodes.test.tsx +++ b/apps/radio/src/components/radio/node/device-nodes.test.tsx @@ -414,7 +414,7 @@ describe("Audio input node", () => { expect(onEchoCancellationChange.mock.calls[0]?.[0]).toBe(true); }); - test("the Stage row pauses a live input whose device is unplugged", async () => { + test("the Rack row pauses a live input whose device is unplugged", async () => { media.permission = "granted"; const controls = { setPlaying: mock(async (_nodeId: string, _playing: boolean) => undefined), diff --git a/apps/radio/src/components/radio/node/docs/acceptance.md b/apps/radio/src/components/radio/node/docs/acceptance.md index 36ad73949..b2d32eb2f 100644 --- a/apps/radio/src/components/radio/node/docs/acceptance.md +++ b/apps/radio/src/components/radio/node/docs/acceptance.md @@ -41,17 +41,22 @@ rows explicitly identify DOM events injected into the running app. | Desktop inspector | **Passed:** empty Station search, File picker/URL tabs, Output device selection and Gate parameters opened from Rack. | | Collapsed desktop Rack | **Passed:** separator End collapsed the panel to 0px; Gate → All settings expanded it to 240px and exposed parameters. | | Desktop Rewire and Undo | **Passed:** keyboard selected Output device as the Station cable destination. Apply preserved cable identity, gain and mute; one Undo restored Speakers. | -| Phone layout and inspector | **Passed in Chromium viewport:** Stage/Rack/Patch accessible; Rack opened the Audio input drawer. Drawer showed Off and the browser's blocked-microphone message. No document-level horizontal overflow. | +| Phone layout and inspector | **Passed in Chromium viewport:** the canvas was accessible; Inspect opened the Audio input drawer. Drawer showed Off and the browser's blocked-microphone message. No document-level horizontal overflow. | | Phone Rewire | **Passed in Chromium viewport:** focused cable selected with Enter; toolbar opened a 358px dialog inside the 390px viewport. Keyboard destination selection and Apply stored the correct route. | | Knob keyboard accumulation | **Passed:** five ArrowUp presses moved Gate threshold from −6 to −3.5; five synthetic key events before a render reached the same stored value. | | Knob reset | **Passed with synthetic events:** double-click and Ctrl+primary pointer-down restored Gate threshold to −6 in both UI and stored graph. | | Knob fine wheel | **Passed with synthetic wheel:** one upward event changed threshold from −6 to −5.99 and persisted it. | -| Slider fine wheel and reset | **Passed with synthetic events:** phone Stage master slider moved from 0.99 to 0.98 for one downward wheel event; Ctrl+primary reset UI and stored master volume to 1. | +| Slider fine wheel and reset | **Passed with synthetic events:** phone master slider moved from 0.99 to 0.98 for one downward wheel event; Ctrl+primary reset UI and stored master volume to 1. | The local feedback availability request returned HTTP 502. It did not prevent these Node interactions. No audio playback, permission grant or hardware routing success is inferred from this run. +The phone rows above were recorded when a phone reached Node through separate +views. A phone now opens Node on the canvas alone, with settings in the +inspector drawer. The drawer and master controls those rows exercised are +unchanged, but the rows were not re-run. + ## Recorded modulation checks Checked on 2026-10-07 in T3 Code's collaborative preview with Chromium diff --git a/apps/radio/src/components/radio/node/docs/design-history.md b/apps/radio/src/components/radio/node/docs/design-history.md index b290c875c..47b07170d 100644 --- a/apps/radio/src/components/radio/node/docs/design-history.md +++ b/apps/radio/src/components/radio/node/docs/design-history.md @@ -64,8 +64,7 @@ Pressing `/`, double-clicking the canvas, or dropping a cable on empty space ope palette, and a station picked there is wired in ahead of time. Pressing play makes the cables carrying signal brighten with their live level. -On a phone the same patch opens on the **Stage** tab: each source with play and volume, and -the master. Rack and Patch are one tap away (§6). +On a phone the same patch opens on the canvas alone; settings open in a bottom drawer (§6). **The one memorable thing: the Dial.** Drop a Dial node between your stations and Speakers and you get one big knob. Turning it tunes across the connected stations like an analogue @@ -87,7 +86,7 @@ carries the four universal wrapper params: enabled, dryWet, inputGain and output | Category | Name | Inputs | Outputs | Params | For | Ship | |---|---|---|---|---|---|---| | Source | Station | control: volume, pan, station | audio; control: song-change (pulse), title-hash (v2) | radio ref (snapshot), volume, muted, play | A saved or session station as a lane: one managed sound through `createManagedSound` (`apps/radio/src/lib/playback-actions-shared.ts:85-104`). **Its empty state is the search**: with no station, the body is an inline `SearchField`, and the chosen result fills the slot. A pasted radio stream link becomes a session station; a pasted platform link loads and hands off to a Track (a session radio keeps the green `#00d084/40` stripe; session radios are tab-scoped, `apps/radio/src/lib/collections/session-radios.ts:14-37`). There is no separate Search node | v1 | -| Source | File | control: volume (v2) | audio | radio (like a Station's), volume, muted, play | One of the Source family with Station and Track: same data, frame and strip slot (`components/radio/node/source-node-frame.tsx`). A local file through a `blob:` URL (`apps/radio/src/lib/audio/file-metadata.ts:74-76`) or a static audio URL (MP3, M3U, PLS) resolved in the browser (`lib/audio/client-static-audio-resolver.ts`). Its empty body is DJ's `FileForm`. Restore skips local files (`isRestorableRadio`), and a local file's lane is live only for object URLs picked in this page (`lib/node-graph/sources.ts`), so after a reload the File keeps its name, has no lane and says "Pick the file again"; its Rack row under Pick again, and a row for it on the Stage, show the File on the Patch. A URL survives the reload. Albums and M3U playlists advance to the next track at the end of one | v1 | +| Source | File | control: volume (v2) | audio | radio (like a Station's), volume, muted, play | One of the Source family with Station and Track: same data, frame and strip slot (`components/radio/node/source-node-frame.tsx`). A local file through a `blob:` URL (`apps/radio/src/lib/audio/file-metadata.ts:74-76`) or a static audio URL (MP3, M3U, PLS) resolved in the browser (`lib/audio/client-static-audio-resolver.ts`). Its empty body is DJ's `FileForm`. Restore skips local files (`isRestorableRadio`), and a local file's lane is live only for object URLs picked in this page (`lib/node-graph/sources.ts`), so after a reload the File keeps its name, has no lane and says "Pick the file again"; its Rack row under Pick again shows the File. A URL survives the reload. Albums and M3U playlists advance to the next track at the end of one | v1 | | Source | Audio input (`deviceIn`, DJ's word) | none | audio | device, channel pair of the first 2 channels, echo cancellation, volume, mute, Go live | `createDeviceSource` (`apps/radio/src/lib/audio/playback/device-source.ts:581`) via `AudioManager.playDeviceSound`, getUserMedia → splitter/merger. The start is DJ's own, shared as `apps/radio/src/lib/device-input-playback.ts` (`startDeviceInput`: `playDeviceSound(soundId, deviceId, { echoCancellation })`, then `setDeviceChannelSelection`). An input with no device has no lane, like an empty Station. Its channel carries DJ's device-input radio (`dj-library-sources.ts`), and restore skips it (`isRestorableRadio`), so a reload never opens the mic: only Go live does. Realtime path, so it skips the main delay (`apps/radio/src/lib/audio/routing/browser-output-adapter.ts:39-42`). Not a stream, so the playing budget ignores it. Its body: Allow microphone (a gesture), "Microphone blocked…", the device select with Refresh, the channel select, "Unplugged: plug it back in or pick another" (the lane pauses), Off / Live with Go live and Mute, and while it reaches an output an amber "Use headphones: a mic into speakers can howl" with an Echo cancellation switch. It is never wired on its own when added | v1 | | Source | Track (`platform`) | control: volume (v2) | audio | radio (like a Station's), search chip, volume, muted, play | A YouTube, SoundCloud or Bandcamp track, album or playlist. Its empty body is DJ's `ExternalSearch`, unlocked ("Search all") or locked by a platform chip taken from `PLATFORM_SOURCE_DEFINITIONS`; a pick or a pasted link loads through `useDjTrackLoad`, and a `yt:` track is resolved first. A radio link hands off: filling any Source with another kind of radio turns it into the one that plays it, in place (`setSourceRadio`). `validateRadioForMode` allows platform radios in `"node"` (Single stays refused). An expired stream is renewed through DJ's refresh, shared as `lib/platform-stream-refresh.ts`, and resumes at its position. At the end of a track in an album or playlist the lane loads `findNextTrack`; the inspector lists the tracklist (DJ's `TracklistView`) | v1 | | Source | Static | control: level | audio | colour (white or pink), bandwidth | Looping noise `AudioBufferSourceNode` → Biquad bandpass. Native and cheap on Safari. Used by the Dial and the roulette bridge | v2 | @@ -636,10 +635,8 @@ same edit (`withFxColumn`). The gaps stay short because a phone fit stops at 0.6 three-column patch already overflows a phone, and its left edge shows first. An output goes in the Speakers column, below the lowest node there, so a cable into it runs beside Speakers' rather than through it, and the patch stays as wide as it was. A reveal after an add waits for the new node's measured -size and keeps it clear of the canvas hint. On a phone, anything but a filled source added -from the Stage or Rack (an empty slot, an Audio input, an FX, a routing node or an output) -opens the Patch on it, as neither lists it; one added on the Patch stays where it was put. Selecting an -empty slot keeps the Rack: it has no strip to inspect until it holds something. +size and keeps it clear of the canvas hint. A phone has no other view, so the reveal is +always on the canvas. ``` ┌──────────────────────────────────────┐ @@ -653,28 +650,19 @@ empty slot keeps the Rack: it has no strip to inspect until it holds something. label on hover/focus; the "on" state = border-primary/20 bg-primary/5 ``` -**Phone** (< 768 px). Tabs choose between Stage, Rack and Patch, following the DJ mobile -pattern of tabs plus stacking plus accordion: +**Phone** (< 768 px). The canvas is the only view; there are no tabs. The search bar, a ++ button and a ⋯ menu (Fit view, Templates, Undo and Redo) sit above it, and the inspector +and palette open as vaul bottom Drawers: ``` ┌ header ───────────────────────┐ -│ [ Stage | Rack | Patch ] │ +│ [search sources…] [+] ⋯ │ ├───────────────────────────────┤ -│ Stage (default) │ performance surface: -│ ▶ Play all (3) master ━━●━ │ master, pinned macros as big -│ ◔ Dial ◔ Macro 1 │ knobs (PR 6), every source with -│ ▸ KEXP ▶ ━━●━━ ▂▃ │ play and volume -│ ▸ NTS 1 ▶ ━━━●━ ▂▅ │ -├───────────────────────────────┤ -│ Rack │ the compiled EnginePlan, listed -│ ▸ Bus: Dial (3 in) │ by bus → lanes; each lane shows -│ ┌ StationRow ▶ vol ─────┐ │ its FX as chips that open the -│ │ [Comp] [Delay] [+] │ │ inspector in a bottom Drawer -│ └─────────────────────────┘ │ -│ ▸ Direct to Speakers │ +│ canvas │ +│ pinch zoom, │ +│ tap-port-then-tap-port │ +│ to connect │ └───────────────────────────────┘ - Patch tab = canvas, pinch zoom, tap-port-then-tap-port to connect, - add-node palette and inspector as vaul bottom Drawers. ``` ### Review against defaults @@ -694,7 +682,7 @@ What this design does instead: - No grid, or at most an optional `border/30` 24 px dot at zoom ≥ 1. - Category comes from the lucide icon tile and the port shape, not header colour. -- No minimap in v1; fit-view is on `F`, and on a phone on tapping the open Patch tab again. +- No minimap in v1; fit-view is on `F`, and on a phone in the ⋯ menu. A phone fit stops at zoom 0.6, where text reads and ports take a tap, and the patch pans instead of shrinking past it; a patch still too tall opens on its top (Speakers and the first sources), not its middle. @@ -777,8 +765,8 @@ What this design does instead: - **MIDI in** (PR 6) makes those mappings visible: its CC cables are the mappings, and deleting a cable clears one. **Macro** cables carry a `MidiTransform` and reuse `applyTransform` and the existing transform editor, so there is no new curve UI. -- **Phone.** Stage is the default tab; Rack is the full accessible path. Patch uses 20-28 px - handles, pinch zoom and tap-tap connect. The inspector and palette open as bottom Drawers. +- **Phone.** The canvas is the only view. It uses 20-28 px handles, pinch zoom and tap-tap + connect. The inspector and palette open as bottom Drawers. Budgets drop to 4 playing streams, with a clear message on the fifth play. ## 8. Persistence and migration @@ -906,8 +894,8 @@ runs **before** any mutation of either collection. It is idempotent. | Touch point | Action / replacement | |---|---| -| `apps/radio/src/components/radio/multiple/index.tsx` (17-219) | Delete. Replaced by `components/radio/node/index.tsx` (canvas + Stage + Rack + Speakers bar, ClientOnly + `React.lazy`). Space and search-add behaviours move there | -| `apps/radio/src/components/radio/multiple/multiple-global-controls.tsx` | Delete. Play all (N), master VolumeControl and mute move into `node/speakers-node.tsx` and the Stage tab | +| `apps/radio/src/components/radio/multiple/index.tsx` (17-219) | Delete. Replaced by `components/radio/node/index.tsx` (canvas + Rack + Speakers bar, ClientOnly + `React.lazy`). Space and search-add behaviours move there | +| `apps/radio/src/components/radio/multiple/multiple-global-controls.tsx` | Delete. Play all (N), master VolumeControl and mute move into `node/speakers-node.tsx` | | `apps/radio/src/components/radio/multiple/multiple-radio-card.tsx` | Delete. The body is repurposed as `node/station-node.tsx` (RadioNowPlaying with viewport-gated polling, RadioItemActions, InlineError, PlayPauseButton, VolumeControl, session stripe; SearchField when empty) | | `apps/radio/src/components/radio/multiple/use-multiple-radio-management.ts` | Delete. Edit, delete, save-discovered and hide-restore move to `node/use-node-radio-management.ts`. Hiding a saved station **disables its Station node** (greyed, lane released) instead of removing it, because membership is now user-curated | | `apps/radio/src/components/radio/multiple/use-multiple-radio-management.test.tsx` | Delete; new tests for the node management hook | @@ -973,8 +961,8 @@ isolation). listeners. - Add `node-store.ts` (TanStack Store), `node-playback.ts` (lanes go straight to `connectMain`, so no engine change yet), `use-node-session`, and the canvas with Station - (including its empty search state) and Speakers, plus the Stage (sources and master) and - Rack tabs. + (including its empty search state) and Speakers, plus the Rack (the Stage view this step first + added was later removed). - Add the "Start from Multiple" template, undo, the Connect… dialog, media session and skeleton. - ModeSelect shows Node instead of Multiple. @@ -1039,7 +1027,7 @@ isolation). | Bespoke Synth | Signal shown on the cable, target highlighting, level→control bridge | Full oscilloscope cables (too costly at 6 streams on mobile); an empty start | n/a | | Pure Data | Keyboard surgery: insert, bypass, swap, all undoable | Fan-out ordering ambiguity (audio sums are order-free; control fan-out is evaluated in edge order and shown) | n/a | | VCV Rack | Thicker stereo cables, per-cable colour override | Clock and reset spaghetti (Clock fan-out is drawn as one cable plus a count) | n/a | -| Max/MSP and Mira | A separate performance surface: Stage on phones and as a desktop strip | Presentation modes that hide cords entirely (Stage can overlay them) | n/a | +| Max/MSP and Mira | A separate performance surface: a Stage strip, proposed and not built | Presentation modes that hide cords entirely (Stage can overlay them) | n/a | | Reaktor Blocks | Anti-pattern: swapping must keep modulation, and ports must not all be audio-rate | Everything else | n/a | | Patchcab and BlokDust | Named templates, global play plus master, share by URL | Tiny knobs (coarse-pointer sizing is used instead) | n/a | | NoiseCraft, Kabelsalat, Strudel, Hydra, Cardinal | Warnings: test WebKit early, no main-thread work on audio paths during resize, active-path highlighting; single-sample feedback shows loops are musical (the Loop node) | All code (GPL/AGPL); whole-graph single-worklet compilation | n/a | @@ -1105,13 +1093,13 @@ isolation). with a ring on the shared Knob, and a large v1 ships LFO, Clock, Random, Dice, Macro, File and Mic alongside the swap. Buses become full `SoundInstance`s through a new `bus` playback-source kind, so they get strips, faders and FX for free. It lost because its third PR bundled the -migration, every removal, about 25 node types, the palette, undo and phone tabs into one +migration, every removal, about 25 node types, the palette, undo and the phone layout into one unreviewable slice; because it added four signal tokens and changed the shared Knob, moving away from one product across modes; and because bus sounds carry a fader that global volume multiplies, which forces `setGlobalVolume(1)` and diverges from `setManagedSessionMasterVolume` (`managed-playback-internals.ts:204-215`). Its best ideas -survive here: TanStack Store, the Loop guard, song-change and title-hash outputs, the Stage -tab, the Dérive static bridge, Tape Warp, Sundial and the cross-tab listener. +survive here: TanStack Store, the Loop guard, song-change and title-hash outputs, the Dérive +static bridge, Tape Warp, Sundial and the cross-tab listener. **Canon-native ("Single and DJ with cables added").** Station nodes are the Multiple card, the cable is the meter, and buses wait for v2. It is the most faithful to the existing UI. diff --git a/apps/radio/src/components/radio/node/flow-adapter.ts b/apps/radio/src/components/radio/node/flow-adapter.ts index ba6978920..54859548e 100644 --- a/apps/radio/src/components/radio/node/flow-adapter.ts +++ b/apps/radio/src/components/radio/node/flow-adapter.ts @@ -5,7 +5,7 @@ * through these names, so a React Flow 13 migration (colorMode, `useStore`, * CSS layers) changes this file and not the canvas. It is reachable only * from the lazy client canvas chunk, never from the Worker bundle: modules - * the Stage, Rack or inspector also load import only its types, and node + * the Rack or inspector also load import only its types, and node * ports get their Handle from the canvas through `FlowPortsProvider`. */ diff --git a/apps/radio/src/components/radio/node/flow-elements.ts b/apps/radio/src/components/radio/node/flow-elements.ts index 890813247..894c5985c 100644 --- a/apps/radio/src/components/radio/node/flow-elements.ts +++ b/apps/radio/src/components/radio/node/flow-elements.ts @@ -184,7 +184,7 @@ export function feedsOutput( } /** - * An Audio input's feedback guard for a Stage or Rack row: set while its + * An Audio input's feedback guard for a Rack row: set while its * audio reaches an output, null otherwise or for any other node. */ export function inputFeedback( diff --git a/apps/radio/src/components/radio/node/module-frame.tsx b/apps/radio/src/components/radio/node/module-frame.tsx index 6d8af17ac..c3fe2edb1 100644 --- a/apps/radio/src/components/radio/node/module-frame.tsx +++ b/apps/radio/src/components/radio/node/module-frame.tsx @@ -564,7 +564,7 @@ export function nodePortState({ /** * React Flow's Position, and the canvas's port, handed down by the canvas. - * Node bodies and their controls also render in the Stage, Rack and + * Node bodies and their controls also render in the Rack and * inspector, which load without React Flow, so this module only imports * its types; ports render on the canvas, inside `FlowPortsProvider`. */ diff --git a/apps/radio/src/components/radio/node/node-canvas.tsx b/apps/radio/src/components/radio/node/node-canvas.tsx index 8cc7020db..b5781acc0 100644 --- a/apps/radio/src/components/radio/node/node-canvas.tsx +++ b/apps/radio/src/components/radio/node/node-canvas.tsx @@ -454,7 +454,7 @@ export type NodeCanvasProps = { /** * Bumped to fit the patch in view, e.g. after a template loads. A * request is fitted once, then handed back through `onFitHandled`, so a - * canvas mounted again (a phone back on Patch) keeps its pan and zoom. + * canvas mounted again keeps its pan and zoom. */ fitRequest: number; onFitHandled?: () => void; @@ -1119,7 +1119,7 @@ function Canvas({ // Delete heals, B bypasses, I inserts into a cable and Cmd+D duplicates. // React Flow's own delete key would listen on the whole document, so a - // Backspace in the Stage, the Rack or a dialog deleted the selection. + // Backspace in the Rack, the inspector or a dialog deleted the selection. useCableSurgeryShortcuts({ canvasRef: wrapperRef, onInsertInto: onOpenPalette, diff --git a/apps/radio/src/components/radio/node/node-palette.tsx b/apps/radio/src/components/radio/node/node-palette.tsx index 2e77fed4c..c22bb1c55 100644 --- a/apps/radio/src/components/radio/node/node-palette.tsx +++ b/apps/radio/src/components/radio/node/node-palette.tsx @@ -122,7 +122,7 @@ const CANVAS_KEY_IGNORED_CONTROLS = /** * Canvas keys (C, Delete) act from the canvas, or with nothing focused; - * not from a field, a dialog, a control on a node, the Stage or the Rack. + * not from a field, a dialog, a control on a node, the Rack or the inspector. */ export function isCanvasKey( target: EventTarget | null, diff --git a/apps/radio/src/components/radio/node/node-source-row.tsx b/apps/radio/src/components/radio/node/node-source-row.tsx index 28518575a..0a1192141 100644 --- a/apps/radio/src/components/radio/node/node-source-row.tsx +++ b/apps/radio/src/components/radio/node/node-source-row.tsx @@ -42,7 +42,7 @@ import { import { useNodeActions } from "./node-actions"; import { isUnplugged, useNodeDevices } from "./use-node-devices"; -/** What a Stage or Rack row drives on its lane. */ +/** What a Rack row drives on its lane. */ export type NodeLaneControls = Pick< NodePlayback, "setPlaying" | "setVolume" | "toggleMute" diff --git a/apps/radio/src/components/radio/node/node-stage.test.tsx b/apps/radio/src/components/radio/node/node-stage.test.tsx deleted file mode 100644 index f41c55d16..000000000 --- a/apps/radio/src/components/radio/node/node-stage.test.tsx +++ /dev/null @@ -1,385 +0,0 @@ -import { - afterEach, - beforeAll, - beforeEach, - describe, - expect, - mock, - test, -} from "bun:test"; -import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -// @ts-expect-error jsdom types are not installed in this workspace. -import { JSDOM } from "jsdom"; - -const dom = new JSDOM("", { - pretendToBeVisual: true, - url: "https://radio.test", -}); - -class ObserverStub { - disconnect() { - // JSDOM does not perform layout. - } - - observe() { - // JSDOM does not perform layout. - } - - unobserve() { - // JSDOM does not perform layout. - } -} - -for (const [key, value] of Object.entries({ - CustomEvent: dom.window.CustomEvent, - document: dom.window.document, - Element: dom.window.Element, - fetch: () => Promise.reject(new Error("offline")), - getComputedStyle: dom.window.getComputedStyle, - HTMLElement: dom.window.HTMLElement, - HTMLFormElement: dom.window.HTMLFormElement, - IntersectionObserver: ObserverStub, - localStorage: dom.window.localStorage, - MutationObserver: dom.window.MutationObserver, - Node: dom.window.Node, - navigator: dom.window.navigator, - ResizeObserver: ObserverStub, - sessionStorage: dom.window.sessionStorage, - window: dom.window, -})) { - Object.defineProperty(globalThis, key, { - configurable: true, - value, - writable: true, - }); -} - -Object.defineProperty(globalThis, "IS_REACT_ACT_ENVIRONMENT", { - configurable: true, - value: true, - writable: true, -}); - -// React DOM checks for input events when it loads, so it loads after the DOM. -const { cleanup, fireEvent, render, waitFor, within } = await import( - "@testing-library/react" -); - -let NodeStage: typeof import("./node-stage")["NodeStage"]; -let compile: typeof import("@/lib/node-graph/compile")["compile"]; -let deriveNodeChannels: typeof import("@/lib/node-graph/session-channels")["deriveNodeChannels"]; -let nodeGraphSchema: typeof import("@/lib/node-graph/schema")["nodeGraphSchema"]; -let buildNodeSessionFromTemplate: typeof import("@/lib/node-graph/template-sessions")["buildNodeSessionFromTemplate"]; -let playbackSessionsCollection: typeof import("@/lib/collections/playback-sessions")["playbackSessionsCollection"]; -let resetAllPlaybackRuntime: typeof import("@/lib/stores/playback-runtime-store")["resetAllPlaybackRuntime"]; -let setPlaybackChannelRuntime: typeof import("@/lib/stores/playback-runtime-store")["setPlaybackChannelRuntime"]; - -beforeAll(async () => { - ({ NodeStage } = await import("./node-stage")); - ({ compile } = await import("@/lib/node-graph/compile")); - ({ deriveNodeChannels } = await import("@/lib/node-graph/session-channels")); - ({ nodeGraphSchema } = await import("@/lib/node-graph/schema")); - ({ buildNodeSessionFromTemplate } = await import( - "@/lib/node-graph/template-sessions" - )); - ({ playbackSessionsCollection } = await import( - "@/lib/collections/playback-sessions" - )); - ({ resetAllPlaybackRuntime, setPlaybackChannelRuntime } = await import( - "@/lib/stores/playback-runtime-store" - )); -}); - -beforeEach(async () => { - await playbackSessionsCollection.stateWhenReady(); - for (const sessionId of Array.from(playbackSessionsCollection.state.keys())) { - playbackSessionsCollection.delete(sessionId); - } - resetAllPlaybackRuntime(); -}); - -afterEach(() => { - cleanup(); - localStorage.clear(); - sessionStorage.clear(); -}); - -const kexp = { - id: "kexp", - name: "KEXP", - streamUrl: "https://radio.example/kexp.mp3", -}; -const nts = { - id: "nts", - name: "NTS 1", - streamUrl: "https://radio.example/nts.mp3", -}; - -const REPICK_ROW = /Pick the file again/; -const BULK_TRANSPORT = /^(Play|Pause) all/; - -function renderStage() { - const controls = { - setPlaying: mock(async (_nodeId: string, _playing: boolean) => undefined), - setVolume: mock((_nodeId: string, _volume: number) => undefined), - toggleMute: mock((_nodeId: string) => undefined), - }; - const client = new QueryClient({ - defaultOptions: { queries: { enabled: false, retry: false } }, - }); - const view = render( - - - - ); - return { controls, view }; -} - -describe("NodeStage", () => { - test("shows the master and every source with play and volume", async () => { - playbackSessionsCollection.insert( - buildNodeSessionFromTemplate("start-from-multiple", { - session: [kexp, nts], - }) - ); - const { controls, view } = renderStage(); - - const sources = await waitFor(() => - view.getByRole("list", { name: "Sources" }) - ); - expect(view.getByRole("slider", { name: "Volume all" })).toBeTruthy(); - expect(view.getByRole("button", { name: "Mute all" })).toBeTruthy(); - expect(view.queryByRole("button", { name: BULK_TRANSPORT })).toBeNull(); - - expect(within(sources).getAllByRole("listitem")).toHaveLength(2); - for (const radio of [kexp, nts]) { - const nodeId = `src-${radio.id}`; - fireEvent.click( - within(sources).getByRole("button", { name: `Play ${radio.name}` }) - ); - expect(controls.setPlaying).toHaveBeenLastCalledWith(nodeId, true); - - const volume = within(sources).getByRole("slider", { - name: `Volume ${radio.name}`, - }); - fireEvent.keyDown(volume, { key: "ArrowLeft" }); - expect(controls.setVolume).toHaveBeenLastCalledWith(nodeId, 0.99); - } - }); - - test("keeps individual pause and the master meter while a source plays", async () => { - playbackSessionsCollection.insert( - buildNodeSessionFromTemplate("start-from-multiple", { - session: [kexp, nts], - }) - ); - setPlaybackChannelRuntime("n:src-nts", () => ({ isPlaying: true })); - const { controls, view } = renderStage(); - - const pause = await waitFor(() => - view.getByRole("button", { name: "Pause NTS 1" }) - ); - expect(view.getByTitle("Master level")).toBeTruthy(); - expect(view.queryByRole("button", { name: BULK_TRANSPORT })).toBeNull(); - fireEvent.click(pause); - expect(controls.setPlaying).toHaveBeenLastCalledWith("src-nts", false); - }); - - test("lists an Audio input next to the Stations, with Go live and volume", async () => { - const session = buildNodeSessionFromTemplate("start-from-multiple", { - session: [kexp], - }); - const graph = nodeGraphSchema.parse({ - ...session.graph, - edges: [ - ...(session.graph?.edges ?? []), - { - id: "mic->speakers", - source: "mic", - sourceHandle: "out:audio:main", - target: "speakers", - targetHandle: "in:audio:main", - }, - ], - nodes: [ - ...(session.graph?.nodes ?? []), - { - data: { deviceId: "mic", deviceLabel: "Desk mic" }, - id: "mic", - position: { x: 0, y: 200 }, - type: "deviceIn", - }, - ], - }); - playbackSessionsCollection.insert({ - ...session, - channels: deriveNodeChannels( - compile(graph, { crossOriginIsolated: false }) - ), - graph, - }); - const { controls, view } = renderStage(); - - const sources = await waitFor(() => - view.getByRole("list", { name: "Sources" }) - ); - expect(within(sources).getAllByRole("listitem")).toHaveLength(2); - fireEvent.click( - within(sources).getByRole("button", { name: "Go live Desk mic" }) - ); - expect(controls.setPlaying).toHaveBeenLastCalledWith("mic", true); - fireEvent.keyDown( - within(sources).getByRole("slider", { name: "Volume Desk mic" }), - { key: "ArrowLeft" } - ); - expect(controls.setVolume).toHaveBeenLastCalledWith("mic", 0.99); - // Cabled to Speakers, the phone says what the canvas says. - expect( - within(sources).getByText("Use headphones: a mic into speakers can howl") - ).toBeTruthy(); - }); - - // A Spotify tab saved before Spotify became a platform: Browser tab audio - // under its old name. - test("shared audio uses Go live without microphone feedback controls", async () => { - const session = buildNodeSessionFromTemplate("starter"); - const graph = nodeGraphSchema.parse({ - ...session.graph, - edges: [ - { - id: "tab->speakers", - source: "tab", - sourceHandle: "out:audio:main", - target: "speakers", - targetHandle: "in:audio:main", - }, - ], - nodes: [ - { - data: { - capture: "display", - deviceId: "display", - deviceLabel: "Spotify", - sourceUrl: "https://open.spotify.com/", - }, - id: "tab", - position: { x: 0, y: 0 }, - type: "deviceIn", - }, - { - data: {}, - id: "speakers", - position: { x: 300, y: 0 }, - type: "speakers", - }, - ], - }); - playbackSessionsCollection.insert({ - ...session, - channels: deriveNodeChannels( - compile(graph, { crossOriginIsolated: false }) - ), - graph, - }); - const { controls, view } = renderStage(); - const sources = await waitFor(() => - view.getByRole("list", { name: "Sources" }) - ); - expect(within(sources).getByText("Shared tab audio")).toBeTruthy(); - fireEvent.click( - within(sources).getByRole("button", { name: "Go live Spotify" }) - ); - expect(controls.setPlaying).toHaveBeenLastCalledWith("tab", true); - expect(within(sources).queryByText("Echo cancellation")).toBeNull(); - }); - - test("an empty patch points at the search", async () => { - const { view } = renderStage(); - - await waitFor(() => - expect(view.getByText("Search to add a station")).toBeTruthy() - ); - expect(view.getByRole("slider", { name: "Volume all" })).toBeTruthy(); - expect(view.queryByRole("button", { name: BULK_TRANSPORT })).toBeNull(); - }); - - test("a File to pick again after a reload shows, and opens its File", async () => { - const { NodeActionsProvider } = await import("./node-actions"); - const { buildNodeSessionFromGraph } = await import( - "@/lib/node-graph/template-sessions" - ); - const { forgetLocalFileUrls, localFileRadio } = await import( - "@/lib/node-graph/sources" - ); - const radio = localFileRadio("tone", { - displayName: "tone", - duration: 10, - fileName: "tone.wav", - fileSize: 100, - mimeType: "audio/wav", - objectUrl: "blob:https://radio.test/tone", - }); - forgetLocalFileUrls(); - const position = { x: 0, y: 0 }; - playbackSessionsCollection.insert( - buildNodeSessionFromGraph( - nodeGraphSchema.parse({ - edges: [], - nodes: [ - { data: { radio }, id: "tone", position, type: "file" }, - { data: {}, id: "speakers", position, type: "speakers" }, - ], - version: 2, - viewport: { x: 0, y: 0, zoom: 1 }, - }) - ) - ); - const revealNode = mock((_nodeId: string) => undefined); - const noop = () => undefined; - const asyncNoop = async () => undefined; - const client = new QueryClient({ - defaultOptions: { queries: { enabled: false, retry: false } }, - }); - const view = render( - - null, - handleDeleteRadio: noop, - handleEditRadio: noop, - handleSaveSessionRadio: noop, - handleToggleRadio: asyncNoop, - inspectNode: noop, - radios: [], - removeNode: noop, - revealNode, - saveDiscoveredStation: noop, - selectDiscoveredForStation: noop, - swapEffect: noop, - }} - > - - - - ); - - const row = await waitFor(() => - view.getByRole("button", { name: REPICK_ROW }) - ); - expect(view.queryByText("Search to add a station")).toBeNull(); - fireEvent.click(row); - expect(revealNode.mock.calls).toEqual([["tone"]]); - }); - - test("the Starter patch's empty slot still points at the search", async () => { - playbackSessionsCollection.insert(buildNodeSessionFromTemplate("starter")); - const { view } = renderStage(); - - await waitFor(() => - expect(view.getByText("Search to add a station")).toBeTruthy() - ); - expect(view.queryByRole("list", { name: "Sources" })).toBeNull(); - }); -}); diff --git a/apps/radio/src/components/radio/node/node-stage.tsx b/apps/radio/src/components/radio/node/node-stage.tsx deleted file mode 100644 index 1e09a7c7a..000000000 --- a/apps/radio/src/components/radio/node/node-stage.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import { - useNodeSessionGraph, - useNodeSources, -} from "@/lib/hooks/use-node-session"; -import { getNodePlayback } from "@/lib/node-playback"; -import { EmptyHint } from "../empty-hint"; -import { inputFeedback } from "./flow-elements"; -import { NodeMasterControls } from "./node-master"; -import { - type NodeLaneControls, - NodeSourceRow, - RepickFileRow, - repickFiles, -} from "./node-source-row"; - -/** - * The performance surface on a phone: the master first, then every source - * (Stations and Audio inputs) with its play or Go live and volume, and a - * File to pick again after a reload. Routing lives in the Rack and on the - * Patch. - */ -export function NodeStage({ - controls = getNodePlayback(), -}: { - controls?: NodeLaneControls; -}) { - const graph = useNodeSessionGraph(); - const { sources } = useNodeSources(); - // A gone file has no lane; one still in a stale lane cache shows once. - const repick = repickFiles(graph).filter( - (file) => !sources.some((source) => source.id === file.id) - ); - - return ( -
- - {sources.length > 0 || repick.length > 0 ? ( -
    - {sources.map((source) => ( -
  • - -
  • - ))} - {repick.map((file) => ( - - ))} -
- ) : ( - Search to add a station - )} -
- ); -} diff --git a/apps/radio/src/components/radio/node/split-nodes.test.tsx b/apps/radio/src/components/radio/node/split-nodes.test.tsx index 4157878ed..2f8e98e00 100644 --- a/apps/radio/src/components/radio/node/split-nodes.test.tsx +++ b/apps/radio/src/components/radio/node/split-nodes.test.tsx @@ -416,7 +416,7 @@ describe("split ports", () => { /> ); - // The Stage, Rack and inspector have no React Flow, so no ports. + // The Rack and inspector have no React Flow, so no ports. const bare = render(split(["branch-1", "branch-2"])); expect(bare.container.querySelector("[data-handle]")).toBeNull(); bare.unmount(); diff --git a/apps/radio/src/lib/collections/playback-sessions.test.ts b/apps/radio/src/lib/collections/playback-sessions.test.ts index 6bbc77f9e..1b5ec1b3e 100644 --- a/apps/radio/src/lib/collections/playback-sessions.test.ts +++ b/apps/radio/src/lib/collections/playback-sessions.test.ts @@ -1397,7 +1397,7 @@ describe("session persistence and init", () => { (node) => node.id === "src-rg_picked" ); expect(station?.data).toMatchObject({ radio: picked, volume: 0.5 }); - // Its lane stays, so Play all and the Stage have it. + // Its lane stays, so Play all and the Rack have it. expect(nodeSession?.channels.map((channel) => channel.id)).toEqual([ "n:src-kexp", "n:src-rg_picked", diff --git a/apps/radio/src/lib/hooks/use-node-session.ts b/apps/radio/src/lib/hooks/use-node-session.ts index 714ac9e5a..4f9427542 100644 --- a/apps/radio/src/lib/hooks/use-node-session.ts +++ b/apps/radio/src/lib/hooks/use-node-session.ts @@ -6,7 +6,7 @@ import { isDeviceInputMetadata } from "@/lib/platform-types"; import { playbackRuntimeStore } from "@/lib/stores/playback-runtime-store"; import { usePlaybackSessionSelector } from "./use-dj-session"; -/** A source lane as the Speakers, Stage and Rack views render it. */ +/** A source lane as the Speakers and Rack views render it. */ export type NodeSourceState = { /** The Station, Track, File or Audio input node id. */ id: string;