Repository navigation
Follow up the UI's review: a patched Electron, the token out of argv, mute in explain, and the port bound first - #187
Conversation
electron 43.4.1 carries GHSA-qmv3-fv6v-rmhq (high), fixed in 43.5.0, and the undici 7.29.0 that @electron/get pulls in has advisories fixed in 7.29.1. Neither is reachable from a shell that loads only field ui's local page, but a lockfile refresh within the existing ranges clears both: electron is now ^43.7.9 and undici resolves to 7.30.0. pnpm regenerated the lockfile.
…shared path field ui passed the session URL, token included, to the Electron shell as a command-line argument, which other users can read from /proc on a shared Linux host and from ps elsewhere. The URL now travels in the shell's environment as FIELD_UI_URL. The shell's profile directory was a fixed name under the shared temp directory, field-ui-profile-<uid>, which another user could create first and so own. It is now made fresh by mkdtemp on each launch and removed when the app quits; the window keeps nothing worth a second launch.
runUi loaded the song into the daemon, which replaces whatever it was playing, and only then listened on --port, with no error listener. A taken port therefore cost the playing session and then crashed the process with an unhandled EADDRINUSE. The client-build check sat after the load too. The server now binds first, before connecting to the daemon: a taken port is refused with a message naming --port, and a missing client build is refused next, closing the port. A failure while connecting or loading closes the port as well. The new ui.test.ts case holds a port and runs field ui against it; before the fix it timed out with an unhandled EADDRINUSE after spawning a daemon, and after it the refusal comes first and no daemon is running for the project.
A muted placement is left out of the mix, but field explain listed the
paths through it at their placement gains, and field arrangement listed
the placement like any other, so both said the track was audible where
it was silent.
explain's reaches now mark a path that passes through a muted placement
("muted on this path, so it is silent here") and keep listing it, since
"placed, but muted" is the answer to why a track is quiet and dropping
the path would read as nothing placing it. arrangement labels a muted
placement "muted". New tests mute one of keys' two homes, and a vox
placement on main; before the change neither output said so.
A cable whose every sender placement is muted is kept, joined but with no arrivals, and field explain spelled it "0 arrivals at samples " with nothing after it. Both ends now say it is silent because the sender's placements are muted. The new test mutes keys' only placement and reads the cable from either end; before the change the receive side printed the empty list.
A record: entry fell through the timeline's naming to "input N", so a track with two record entries showed "input 1" and "input 2". Name it as the graph does, by generatorName: the owning track's name, or "<track>-<id>" when the entry has an id. The new test places a track with two record entries and one with a bare entry; before the change they read "input 1" and "input 2".
The insert panel drew the EQ curve and its auto-gain at the session rate, but a track with its own rate: designs its filters at that rate, and a biquad's response near Nyquist depends on it. Each timeline lane that places a track now carries trackRate, the track's own rate or the song's (graph.ts's rule), and the panel draws at it. The new test places a 96 kHz track, a track with no rate, and an audio clip, and expects 96000, the song's 48000, and null.
The mute sentence landed between "the render daemon" and its mix-assembly §1 citation, so the citation read as backing the mute claim, which mix-assembly does not make. The citation now follows the sentence it cites, and the mute sentence follows it.
Every snapshot carried lanes, the first version's flat lane list, and the main file's sha256, which cost a parse of main's inputs and a second read of the file each time. The client reads neither: the timeline's lanes replaced the flat list, and every edit carries its own lane's file and hash. The snapshot keeps file.path, which the footer shows, and UiLane goes.
While the song plays, every timeline row re-renders on each frame because the playhead moves, and each rebuilt its 1,200-bucket waveform path string. The path is now built once per envelope array and cached in a WeakMap keyed on it; the array stays the same object until a snapshot replaces it, so React sees the same attribute and leaves the DOM alone. Wrapping Row in React.memo would not help, since the playhead prop changes every frame.
ui/ asked for vite ^6 while vitest at the root resolves vite 7, so the lockfile carried both, and with them two esbuild builds and their platform packages. ui/ now asks for vite ^7.3.6, and pnpm dedupe drops vite 6.4.3 and esbuild 0.25.12. @vitejs/plugin-react 4.7.0 already accepts vite 7, and the UI builds unchanged.
Three describe blocks in ui-edits.test.ts each built the same 120 bpm, 4/4, 48 kHz tempo and meter maps, the bar constants, and the same full() helper for a parsed entry. They are defined once at the top now, with a comment saying what the clock is, and one test drops a local barTicks that shadowed the shared one with the same value. No test changes what it asserts.
ui.ts's localMaps and ui-timeline.ts's lane projection each built an owner track's tempo map, its own or the song's, so the view and the edits it sends could drift apart. ownerClock in ui-timeline.ts now builds both maps and both call it. It stays at the session rate, and its comment says why: every position the view draws and every offset an edit carries is in session samples.
ninjudd
left a comment
There was a problem hiding this comment.
📽️ Projector review · 0.7.4 · model claude-opus-5-5 · effort xhigh · CHANGES REQUESTED · took 38m 19s
This change works through the suggestions the #163 reviews left on the UI's first version. It moves the app shell to a patched electron and undici, hands the session URL to the shell in its environment instead of on its command line, and gives the shell a fresh mkdtemp profile on each launch. field ui now binds its port before the daemon loads the song. field explain and field arrangement show muted placements, and an explained cable says when it is silent. The timeline names record lanes the way the graph does and draws a track's EQ at that track's own rate. Three items are left for a product decision: a mute that makes a receiver's parents disagree, a soloed row inside a bus that loses the bus's sends, and cross-rate owners and record lanes drawn in session samples.
2 finding threads: 0 resolved, 2 open
Covered 17 of 18 changed files; 1 lockfile skipped as generated. Its moved packages were still checked for advisories, as listed below.
- The shell was read, not launched. The
FIELD_UI_URLhandoff and the per-launch profile were checked by readingui/shell.cjs,runUi, and thecli.jsthat Electron 43.7.9 installs, which spawns the binary with the inherited environment and onlyshell.cjson its arguments. Neither the window nor the profile cleanup was run. The Windows finding onui/shell.cjsrests on Electron's shutdown order, SQLite's Windows share mode, and the samermSyncfailing in this repository's Windows CI, not on a run of the shell on Windows. - The Windows CI job fails, but not on this change. It fails in
src/commands/record-midi-daemon.test.tsandsrc/keys/voice-host.test.ts, the same tests that fail inmain's own Windows run ata6c1031. The six test files this change touches pass on Windows and on Linux. - Advisories for the moved packages. The lockfile moves
electron43.4.1 to 43.7.9,undici7.29.0 to 7.30.0, andvite6.4.3 to 7.3.6, and dropsesbuild0.25.12. The GitHub advisory database lists no advisory for[email protected],[email protected], or[email protected], and it confirms GHSA-qmv3-fv6v-rmhq on[email protected]and ten advisories on[email protected], all fixed in 7.29.1.pnpm auditreports none in a package this change moves.
Suggestions
docs/tracks.md:153describes howfield explainanswers the level question, and themute: trueparagraph atdocs/tracks.md:89says what a mute does. Neither says thatfield explainkeeps a muted path and marks it "muted on this path", or thatfield arrangementlabels a muted placementmuted. One sentence beside either would keep the docs in step with both commands.src/commands/ui.ts:846is unchanged by this change.--browserand the shell's fallback still pass the URL, with its token, toopen,xdg-open, orcmd /c starton the command line, and on Linux a browser thatxdg-openstarts keeps the URL in its own arguments for as long as it runs. So the argv fix covers the app window only. A one-use launch code that the server exchanges for the session token on the first load would close it. Short of that, the--browserrow indocs/cli.mdcould say so.src/commands/ui-timeline.ts:232is unchanged by this change. Asupercollider:orgenerative:lane still readssupercolliderorgenerative, while the graph names those entries bygeneratorName, as it does the record entries this change fixes. Two generators in one track therefore show two identical lane names. Passing them throughgeneratorNamewould match the graph.pnpm-lock.yamlstill carries six advisories thatpnpm auditreports, all in dev tooling at the base's versions. Two high ones,nanoid3.3.17 andsource-map-js1.2.1 underpostcss8.5.25, have fixes insidepostcss's own ranges, so a lockfile refresh takes them. The two criticaltinypool1.1.1 advisories and the@vitest/mockerone needvitest4.1.11 or later.
The shell removed its own profile on Electron's quit event, but quit fires before the main loop stops and before the default session closes its stores, so Chromium still holds the profile's files open. Windows refuses to delete an open file, so rmSync threw, the uncaught throw raised Electron's "A JavaScript error occurred in the main process" dialog on every close, field ui waited on the dialog, and the directory stayed behind. field ui now makes the profile with mkdtemp, hands it to the shell as FIELD_UI_PROFILE, and removes it once the shell process has exited, when Electron has let go of it. A teardown that kills the shell waits up to two seconds for that exit. The shell only uses the directory it is given.
Moving the mix-assembly citation back beside its claim left one line at 100 characters in prose that wraps near 72. The paragraph is re-wrapped at 72; the only short line left is the one before the citation's link, which is 70 characters on its own and cannot break.
tracks.md's mute paragraph now says that field explain keeps a path through a muted placement and marks it, and that field arrangement labels a muted placement, so the docs match both commands. cli.md now says that the app window gets the session URL in its environment, while --browser and the browser fallback pass it, token included, to open, xdg-open, or start on the command line, and how to avoid that.
The timeline named a supercollider: or generative: lane by its kind, so two in one track showed two identical names, while the graph names them by generatorName, as it does the record entries the previous change fixed. All three generator kinds now go through generatorName. The new test places two supercollider entries with ids; before the change both lanes read "supercollider".
pnpm audit reported two high advisories in dev tooling under vitest's vite: nanoid 3.3.17 (fixed in 3.3.18) and source-map-js 1.2.1 (fixed in 1.2.2), both reached through postcss. postcss's own ranges allow the fixes, so a refresh within them takes nanoid 3.3.20 and source-map-js 1.2.2, and the audit's high count drops to zero. The two critical tinypool advisories and the vitest one need vitest 4.1.11, a major upgrade left for its own change.
ninjudd
left a comment
There was a problem hiding this comment.
📽️ Projector review · 0.7.4 · model claude-opus-5-5 · effort xhigh · CHANGES REQUESTED · took 4m 05s
This change works through the suggestions the #163 reviews left on the UI's first version. It moves the app shell to a patched electron and undici, and hands the shell the session URL in its environment instead of on its command line. field ui now makes the shell's profile with mkdtemp and removes it after the shell exits, and it binds its port before the daemon loads the song. field explain and field arrangement show muted placements, and an explained cable says when it is silent. The timeline names generator lanes the way the graph does and draws a track's EQ at that track's own rate. Since the last review, this head moves the profile cleanup into field ui and re-wraps docs/build-graph.md. It also documents the mute labels and what --browser does with the token, names supercollider: and generative: lanes by their generator name, and refreshes nanoid and source-map-js. Three items are still left for a product decision: a mute that makes a receiver's parents disagree, a soloed row inside a bus that loses the bus's sends, and cross-rate owners and record lanes drawn in session samples.
3 finding threads: 2 resolved, 1 open
Covered 19 of 20 changed files; 1 lockfile skipped as generated. Its moved packages were still checked for advisories, as listed below.
- Both earlier findings are fixed at this head.
ui/shell.cjsno longer deletes its profile onquit.field uicreates the profile, passes it asFIELD_UI_PROFILE, and removes it inside atryonce the shell's process exits.docs/build-graph.mdis re-wrapped, and no line is over 74 characters. Line 195 stays short only because the next line is a 73-character link. - The shell was read, not launched. The profile's lifecycle was checked by reading
ui/shell.cjs,runUi, and thecli.jsthat Electron 43.7.9 installs, and with a Node reproduction of the exit order. Neither the window norfield uiwas run. - The Windows CI job was still running at publication. The Linux job passed. On the previous head, the Windows job failed only in
src/commands/record-midi-daemon.test.tsandsrc/keys/voice-host.test.ts, the same tests that fail inmain's own Windows run, while the test files this change touches passed. - Advisories for the moved packages. Across the pull request the lockfile moves
electron43.4.1 to 43.7.9,undici7.29.0 to 7.30.0,vite6.4.3 to 7.3.6,nanoid3.3.17 to 3.3.20, andsource-map-js1.2.1 to 1.2.2, and it dropsesbuild0.25.12. The GitHub advisory database lists no advisory for any of the new versions.pnpm auditnow reports four advisories, all invitest3.2.7'stinypool1.1.1 and@vitest/mocker, which this change leaves at the base's versions.
Suggestions
src/commands/ui.ts:887removes the profile in one attempt. PassingmaxRetries, which makesrmSyncretryEBUSYandEPERMwith a backoff, would keep a Chromium helper that is still exiting on Windows from leaving the directory behind.pnpm-lock.yaml: the four remainingpnpm auditadvisories, two of them critical intinypool, needvitest4.1.11 or later, which a later change could take.
The teardown raced the shell's exit against a two-second timer that was never cleared, so Node waited for the timer after runUi returned and every session, with or without a shell, ended with the prompt about two seconds late. The race bought nothing for the profile either: a shell that is still running keeps the process alive until its exit handler has removed the profile. The race is gone. In a scratch project with null output, field ui --no-open took 2.11 s to exit after ctrl-c before the change and 0.08 s after it.
The shell's exit handler removed the profile in one attempt. On Windows a Chromium helper can still be closing the profile's files as the shell exits, so rmSync now retries EBUSY and EPERM five times, 100 ms apart, before it gives the directory up to the OS.
ninjudd
left a comment
There was a problem hiding this comment.
📽️ Projector review · 0.7.4 · model claude-opus-5-5 · effort xhigh · CLEAN · took 3m 36s
This change works through the suggestions the #163 reviews left on the UI's first version. It moves the app shell to a patched electron and undici, and hands the shell the session URL in its environment instead of on its command line. field ui makes the shell's profile with mkdtemp and removes it when the shell exits, and it binds its port before the daemon loads the song. field explain and field arrangement show muted placements, and an explained cable says when it is silent. The timeline names generator lanes the way the graph does and draws a track's EQ at that track's own rate. Since the last review, this head drops the two-second wait at the end of a session and retries the profile removal. Three items are still left for a product decision: a mute that makes a receiver's parents disagree, a soloed row inside a bus that loses the bus's sends, and cross-rate owners and record lanes drawn in session samples.
3 finding threads: 3 resolved, 0 open
Covered 19 of 20 changed files; 1 lockfile skipped as generated. Its moved packages were still checked for advisories, as listed below.
- The shell was read, not launched. The profile's lifecycle was checked by reading
ui/shell.cjs,runUi, and thecli.jsthat Electron 43.7.9 installs, and with a Node reproduction of the session's end. Neither the window norfield uiwas run. - The Windows CI job was still running at publication. The Linux job passed. On an earlier head, the Windows job failed only in
src/commands/record-midi-daemon.test.tsandsrc/keys/voice-host.test.ts, the same tests that fail inmain's own Windows run, while the test files this change touches passed.
Suggestions
pnpm-lock.yaml:pnpm auditstill reports four advisories, two of them critical, invitest3.2.7'stinypool1.1.1 and@vitest/mocker. This change leaves them at the base's versions, and they needvitest4.1.11 or later.
What was checked
- The ending of a session. The two-second race is gone, so nothing holds
field uiopen after its teardown. A reduced copy of the new code exits at 0 ms with no shell. With a shell that takes 1.5 s to stop after Ctrl-C, the teardown finishes at 203 ms, and the still-running shell keeps Node alive. The shell'sexithandler then removes the profile at 1,707 ms, and the process exits in the same millisecond. - The profile on every path.
field uicreates the profile only when it launches Electron, passes it asFIELD_UI_PROFILE, and removes it in the shell'sexithandler. That runs after a normal close, a Ctrl-C, a crash, and a failed start that falls back to a browser. The removal retries five times and catches a final failure, so it cannot crash the CLI. - The token.
runUispawns Electron'scli.jswith onlyshell.cjsas an argument, and Electron 43.7.9'scli.jsspawns the binary with the inherited environment, soFIELD_UI_URLnever reaches a command line.docs/cli.mdsays that--browserand the fallback to a browser still do. - The port.
runUibinds the port and checks the client build before it connects to the daemon, andcompileSessiondoes not touch the daemon.src/commands/ui.test.tsholds a port and sees the refusal with no daemon spawned. - Mute in the CLI. A path through any muted placement is marked muted, matching
planForingraph.ts, which drops a muted entry before planning. A cable with no audible arrivals reads as silent from both ends.docs/tracks.mddescribes both labels. - The timeline.
trackRatefollowsgraph.ts, a track's ownrate:or else the song's. Record,supercollider:, andgenerative:lanes takegeneratorName, the name the graph gives their nodes.ownerClockbuilds the same maps the view and the edits used before. - The protocol. The client imports
UiSnapshotfromui-protocol.ts, and theuitypecheck passes, so nothing reads the removedlanesorfile.sha256. - Dependencies.
electron43.7.9,undici7.30.0,vite7.3.6,nanoid3.3.20, andsource-map-js1.2.2 have no advisory in the GitHub advisory database.pnpm --dir ui buildsucceeds withvite7.3.6. - Runs at this head.
pnpm install --frozen-lockfile --ignore-scripts,pnpm typecheck, andpnpm --dir ui typecheckwere clean. The six changed test files passed 106 tests, withFIELD_AUDIODset for the two daemon renders insrc/model/cables.test.ts.pnpm --dir ui buildsucceeded.
The reviews of #163, the UI's first version, ended clean but left a list of suggestions that the pull request merged without. This change works through that list. It takes the security-shaped items first, then the ones that make the view or the CLI say something untrue, then the tidying. Three items need a musical or product decision rather than a code change, and they are listed at the end with their options.
Security
electron43.4.1 carries GHSA-qmv3-fv6v-rmhq (high), fixed in 43.5.0, and theundici7.29.0 that@electron/getpulls in has advisories fixed in 7.29.1. Neither is reachable from a shell that loads only the local page, but a refresh within the existing ranges clears both:electronis now^43.7.9andundiciresolves to 7.30.0, and pnpm regenerated the lockfile.field uipassed the session URL, token included, to the shell on its command line, where other users can read it from/procon a shared Linux host and frompselsewhere. It now travels in the shell's environment asFIELD_UI_URL.field-ui-profile-<uid>directory under the shared temp directory, which another user could create first and so own.field uinow makes it withmkdtempon each launch, hands it to the shell asFIELD_UI_PROFILE, and removes it after the shell has exited. Removing it on Electron's quit, as a first version of this change did, fails on Windows, where Chromium still holds the profile's files open at that point.Correctness
field uiloaded the song into the daemon, which replaces whatever it was playing, and only then listened on--port, with no error listener. A taken port cost the playing session and then crashed the process with an unhandledEADDRINUSE. The server now binds first and refuses a taken port with a message naming--port. The missing-client-build check moved ahead of the daemon too, and any failure while connecting closes the port.field explainlisted the paths through a muted placement at their placement gains, andfield arrangementlisted a muted placement like any other. explain now marks such a path "muted on this path, so it is silent here" and keeps listing it, because "placed, but muted" is the answer to why a track is quiet. arrangement labels the placement "muted".0 arrivals at samplesinfield explain. Both ends now say the cable is silent because the sender's placements are muted.rate:designs its filters at that rate. Each lane now carriestrackRate, the track's own rate or the song's, asgraph.tsdecides it, and the panel draws at that rate.record:entry was labelledinput Nin the timeline, and twosupercollider:orgenerative:entries in one track showed the same name. All three are now named as the graph names them: the track's name, or<track>-<id>.--browserdo.docs/tracks.mdsays thatfield explainandfield arrangementmark muted placements, anddocs/cli.mdsays that--browserpasses the token-bearing URL on a command line.Tidying
build-graph.md. The mix-assembly §1 citation now sits beside the sentence it backs, not after the mute sentence.lanesor the main file's hash, which the view never read and which cost a parse and a second file read on every snapshot.React.memoon the row would not help, because the playhead prop changes every frame.vite ^7, so the lockfile carries the single vite 7 that vitest already uses, and one esbuild.ownerClockhelper.full()helper are hoisted.Left for a decision
A mute that makes a receiver's parents disagree (
cables.ts, the audible pass). When a receiver is placed in two parents and a muted sender placement leaves the parents hearing different arrivals, the second pass keeps the first parent's arrivals silently, so the receiver's reverb is either kept or silenced in both homes, depending on file order. The options are to report it as an error, which turns the song red when you mute; to treat the cable as silent in both homes; or to keep today's first-parent answer and say so. Which one is right is a musical call.A soloed row inside a bus loses the bus's sends (
solo.ts). Carriers keep their send cables, but the receivers of those cables never become audible, so soloing a row inside a bus with a reverb send drops the bus reverb. The options are to root those receivers, so the solo is heard through the bus's reverb, as many DAWs' solo-in-place does; or to narrow the header comment to say a carrier's sends are not heard. That is a product call.Cross-rate owners and record lanes in the timeline. The view and its edits work in session samples. An absolute position inside a track whose own
rate:differs from the session's is therefore drawn and edited unscaled, and a record lane is still drawn from its entry's window, not from where its chosen take sounds. Fixing either needs the drawn block separated from the window arithmetic that trims and splits send back, which is a protocol change worth its own plan rather than a follow-up item.vitest 4.
pnpm auditstill reports two criticaltinypooladvisories and a moderatevitestone, all in the test runner, and fixed only from vitest 4.1.11. A major upgrade of the test runner belongs in its own change. The two high advisories underpostcss(nanoid,source-map-js) are fixed here by a refresh within their ranges.The browser path's token.
--browserand the browser fallback still pass the token-bearing URL on a command line;docs/cli.mdnow says so. Closing it needs a one-use launch code that the server exchanges for the session token, which is a protocol change of its own.Testing
Run these from the root of a checkout of
ui/review-followups.pnpm build:nativebuilds the daemon intonative/audiod/build, which the daemon tests need.pnpm --dir ui buildwrites the client toui/dist. Nothing else changes in the tree.ELECTRON_SKIP_BINARY_DOWNLOAD=1 pnpm install --frozen-lockfile pnpm build:native pnpm typecheck pnpm test pnpm --dir ui build project checkYou should see a clean typecheck,
Test Files 77 passed (77)andTests 992 passed | 1 skipped (993), a Vite build that ends✓ built, andProject plans are valid.The tests for the behavior changes are:src/commands/ui.test.ts. The port case holds a port, runsfield uiagainst it, and expects the refusal with no daemon running for the project. Before this change it timed out on an unhandledEADDRINUSEafter spawning a daemon.src/model/levels.test.tsandsrc/commands/arrangement.test.ts. They check the muted labels.src/model/cables.test.ts. It checks the silent cable's wording from both ends.src/commands/ui-timeline.test.ts. It checkstrackRateand the record lane names.A failure in any of these means the change regressed.
The shell's changes (
FIELD_UI_URLand themkdtempprofile) cannot be exercised by these tests, which never start Electron. To check them by hand on macOS, runfield ui <song>in a project with a built daemon. The window should open on the session and play. While it is open,ps -ax | grep shell.cjsshould show no?t=token in the shell's arguments, andls "$TMPDIR"should show afield-ui-profile-directory with a random suffix that disappears after you close the window, without an error dialog. On Windows, that missing dialog is the check that matters, and these tests cannot make it.🤖 Generated with Claude Code
📽️ Projector summary of 9857529: https://field.amnes.ac/reviews/187