Skip to content

Start a MIDI take where the knobs are: field keys publishes what it sent, and the daemon chases it to the take's first sample (instrument-knobs.md chunk 3) - #212

Merged
ninjudd merged 8 commits into
mainfrom
knobs/chase
Oct 11, 2026

Conversation

@ninjudd

@ninjudd ninjudd commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

A MIDI take records only the messages that arrive once it has started. So a knob you turned before pressing record, such as juno's cutoff dialed down for a darker pad, played live but rendered at its default in the take until you happened to turn it again. The same gap hit the modulation wheel, and keyboard-instrument.md §14.5 left it open. This third chunk of the instrument-knobs plan (#202) closes it in the daemon, with MIDI alone, so it works for any source.

There are three parts:

  • field keys publishes what it has sent. Run inside a project, it keeps every controller from 0 to 119 it has sent, by channel, in .field/keys.json, written to a temporary file and renamed over the last on each control change, and removed when it quits. A field keys removes the file only if it wrote it, so two in one project do not delete each other's. One that cannot write the file keeps playing and names the error on the status line, and a take then starts without its knobs.
  • field record passes them in arm. When it arms a MIDI take, in the one-track form or with tracks, and the field keys that wrote the file is still running, it adds controllers to arm. It does so only for a daemon that lists the new midi-chase feature, so an older daemon never sees the field.
  • The daemon chases controllers. From the arm, it keeps the latest value of each controller from 0 to 119 on each channel: the ones arm passed, then every control change that arrives, a count-in included, whether before the take, during it, or past its until. Before this change it dropped those that arrived before the start. At the take's first sample it writes one line per channel and controller at at: 0, ahead of every other line, in the order the values last arrived, in each MIDI take of the pass. Controllers 120 to 127 are channel mode messages and are never chased. A hardware knob moved after the arm counts too. A change the take records enters the table only after those lines, so a second take on one arm, which arming.md chunk 3's lasting arm will make, starts each controller where the first take left it.

On the audio thread, the chase is a fixed table of 16 channels by 120 controllers, updated in constant time per message wherever the callback used to discard arrivals before the start. arm hands its seeds to the callback under a spin lock that the callback only ever tries, so it never blocks, and each arm starts the table over. The lines go in just before the take's first stamped message. So an arrival in the start block that falls before the start sample is chased before the lines are written, and the lines still lead the file. arm refuses controllers out of range, as it refuses a bad input channel. A block whose pull ran before record's request, which #204 lets wait for the next block to start the take, chases what it drains too, because that arrived before the start.

#209 and #210, chunks 1 and 2, are on main, and this branch is rebased onto it, #213's host monitoring included. armSet takes the chase's seeds and then #213's connection owner, and the tracks form of arm passes both. With this, every chunk of the plan is built, and what remains is the criteria to check by hand. §11 of the plan records what implementation settled.

Testing

I ran these on macOS, from the root of a checkout of this branch, after pnpm install, pnpm build, and pnpm build:native. pnpm build:native matters here, since this change is in the daemon. Against a daemon built before it, the midi-chase tests fail on client.supports('midi-chase').

  1. pnpm typecheck prints nothing and exits 0.
  2. pnpm vitest run reports 91 test files, 1216 tests passed and 1 skipped.
  3. pnpm vitest run src/commands/record-midi-daemon.test.ts src/commands/record-plan.test.ts passes 16 tests and skips 1, which runs only where there is no MIDI service. The daemon tests publish a CoreMIDI source of their own, Field Keys Capture <pid> …, for a few seconds, and arm a daemon of their own in null-output mode; they touch no running daemon. The chase test seeds cc 110 = 10 and cc 111 = 20 on channel 16 at the arm. Before the start, it sends cc 112 = 30 on channel 15, cc 110 = 40 on 16, and CC 120; after the start, cc 111 = 50. The take's lines at at: 0 must be cc 111 = 20, cc 112 = 30, cc 110 = 40, in that order, with no CC 120, and cc 111 = 50 must land later at its own time. Lines in another order mean the chase no longer orders by last arrival. A cc 110 = 10 line means a seed was not replaced. The field record test publishes .field/keys.json as its own process and checks that the landed notes file has { at: 0, cc: 113, value: 23, channel: 16 }. The latch test sets FIELD_AUDIOD_LATCH_STALL_MS=8 and sends a controller just before each of ten records on one arm. "the controller sent before take N: expected [] to have a length of 1" means a block whose pull ran before record's request dropped what it drained instead of chasing it. The carry test records twice on one arm, with cc 114 = 20 before the first take and cc 114 = 50 during it, and the second take's line at at: 0 must be cc 114 = 50. cc 114 = 20 there means a change the take recorded never reached the chase.

What I could not run is criteria 20 and 21 by hand, which need a kitty terminal and ears. From examples/bloom, give creek a track keys with instrument: juno. In one terminal, run node ../../dist/cli.js keys juno and turn cutoff down. In another, run node ../../dist/cli.js record creek/track:keys --at 17, play without touching a knob, stop, build, and play. The take should render dark from its first note, and its notes file's first controls row should be { at: 0, cc: 74, value: … }. Both terminals need this branch's dist and daemon: a daemon left running from another build answers without midi-chase, so run field transport quit first. With --count-in 1, turning res during the count-in should start the take with that res.

📽️ Projector summary of 68d929f: https://field.amnes.ac/reviews/212

@ninjudd
ninjudd added this pull request to stack #211 October 11, 2026 19:59

@ninjudd ninjudd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📽️ Projector review · 0.7.7 · model claude-opus-5-5 · effort xhigh · CHANGES REQUESTED · took 16m 59s

A MIDI take records only what arrives once it has started, so a knob turned before you pressed record played live but rendered at its default. This change, chunk 3 of the instrument-knobs plan, closes that gap. field keys writes the controllers it has sent to .field/keys.json, and field record passes them as controllers in arm to a daemon that lists midi-chase. The daemon keeps the latest value of each controller from the arm to the take's start, hardware arrivals and the count-in included, and writes those values at at: 0 ahead of every other line. Criteria 20 and 21, which need a kitty terminal and ears, stay owed by hand.

3 finding threads: 0 resolved, 3 open

Covered 16 of 16 changed files; none generated.

  • The head was reviewed by reading only. The commit's Co-Authored-By trailer names the claude login, whose permission on this repository is read. A commit that names an author without write or admin access makes the head untrusted, even though project review setup reported it trusted. So I ran no code from the head: no pnpm install, pnpm typecheck, native build, vitest run, or daemon probe. I did run project check, which validates the plan files without executing anything from the head, and it passed.
  • CI ran this head, and the review did not. CI passed on linux and windows, including pnpm typecheck, pnpm build:native, and pnpm test. On both, record-midi-daemon.test.ts ran 3 of its 8 tests and skipped the 5 that need a MIDI source, among them the chase test and the field record end-to-end test. So only the author's macOS run has exercised the chase itself. record-plan.test.ts (6 tests) and session.test.ts (44 tests) passed on both.

Suggestions

  • native/audiod/src/player.cpp:1393: call chaseArrival for each arrival stampMidiBlock pushes, not only for those before the start. As it stands, a second record on one arm starts a controller turned during the first take at its value from before that take. field record arms once per take, so nothing reaches this today, but the lasting arm in arming.md chunk 3 would.
  • src/commands/keys.ts:288: catch a failed publishControllers write inside send. A write error, such as EACCES on a .field/ that a sudo run left owned by root, throws out of the stdin handler, which nothing catches, and ends the field keys session on the next knob turn.
  • src/commands/record-plan.test.ts:95: the comment calls 2147483646 "the largest a 32-bit pid_t holds", which is 2147483647. Change the value or the comment.

What was checked

  • The publish channel follows §2.8. field keys publishes a file, not a daemon op, so published state is tied to a process, not to a daemon connection. A reader ignores a file whose pid has exited, and a field keys that quits removes the file only when it wrote it last. Two field keys in one project publish last-writer-wins, as the plan's one-pid file implies.
  • The chase follows §2.8 and §11.1. Every arrival before the start goes through chaseArrival: between arm and record, during a count-in or a punch-in's run-up, and inside the start block before the start sample. The 16-by-120 table keys each value by channel and controller, ordered by last arrival with seeds first, and drops controllers 120 to 127. A MIDI primary and an audio primary's MIDI companions both write the lines through stampMidiBlock, so every MIDI take of a pass gets them. MIDI loop takes, and loop takes with companions, are still refused, so #204's handoff is untouched. A take with no field keys running gets an arm with no controllers, which still resets the table, and chases only hardware arrivals.
  • The callback stays real-time safe. The seed handoff uses only a try-lock on the audio thread. The table, the sort scratch, and the seed array are fixed-size members, std::sort runs in place, and the MIDI take's 16,384-message fifo holds a full 1,920-line chase.
  • The recording path reads the lines back. notesFromMessages keeps controls in file order, and renderEvents sorts stably by time and then rank, so chased rows land as controls rows at at: 0 in #182's notes format, before any note at 0 and before a live change at 0.

Comment thread native/audiod/src/player.h Resolved
Comment thread docs/project-model.md Resolved
Comment thread docs/keys.md Resolved

@ninjudd ninjudd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📽️ Projector review · 0.7.8 · model claude-opus-5-5 · effort xhigh · CHANGES REQUESTED · took 5m 52s

This head carries chunk 3 of the instrument-knobs plan, rebased onto #210's new head, plus five commits that answer the first review. ChaseSeed moves above Player's comment, and project-model.md's paragraph is rewrapped. keyboard-instrument.md §14.5 gains a dated note that a take now starts where field keys left the wheel. field keys keeps playing and names the error when it cannot write .field/keys.json, and a test comment is corrected. The chase itself is unchanged: a MIDI take starts with each controller's latest value from the arm, the published ones first, written at at: 0.

4 finding threads: 3 resolved, 1 open

Covered 17 of 17 changed files; none generated.

  • The head is trusted. Justin ruled that a Co-Authored-By: Claude trailer on his own commits does not withhold trust, and every commit's git author and committer is ninjudd. The first review treated the head as untrusted for that trailer and ran nothing.
  • What ran at this head. pnpm install --frozen-lockfile, pnpm typecheck, a release build of field-audiod against JUCE 8.0.4, and vitest run src/commands/record-plan.test.ts src/keys/session.test.ts (51 tests) all pass.
  • A probe of the chase, with no MIDI port and no audio device. A harness runs this head's Player in null-output mode, arms through armSet, and injects control changes through handleIncomingMidiMessage. In each of these, the take starts with the lines §2.8 describes, in the order it describes: a MIDI take, a count-in on a file bed, a MIDI companion of an audio take, and a re-arm with no seeds. I did not run record-midi-daemon.test.ts, which arms every MIDI source on the machine.
  • CI fails on linux and windows in pnpm build:native. The thread on player.cpp covers it.

Suggestions

  • native/audiod/src/player.cpp:1393: call chaseArrival for each arrival stampMidiBlock pushes, too. The probe shows a second record on one arm starting a controller at its value from before the first take (20) rather than where the first take left it (50). Nothing records twice on one arm today, but arming.md chunk 3's lasting arm would.

Comment thread native/audiod/src/player.cpp Resolved
Base automatically changed from knobs/type to main October 11, 2026 21:33
…ent, and the daemon chases it to the take's first sample (instrument-knobs.md chunk 3)

A take recorded only what arrived after it started, so a knob turned
before the take rendered at its default. field keys now keeps the
controllers it has sent in .field/keys.json, field record passes them
in arm to a daemon that lists midi-chase, and the daemon keeps the
latest value of each controller from the arm, those it was passed and
each control change before the start, a count-in included. It writes
them at the take's first sample, ahead of every other line, in the
order their values last arrived.
ChaseSeed and its comment sat between Player's comment and class Player,
so Player's comment read as the start of ChaseSeed's and the class had
none above it. ChaseSeed now follows the forward declarations.
A failed write of the published controllers, such as EACCES on a
.field that a sudo run left owned by root, threw out of send, which
the stdin handler and the turn timer call and nothing catches, so the
next knob turn ended the session. publishControllers now returns why
the write failed, field keys puts that on the status line and keeps
playing, and docs/keys.md says a take then starts without those knobs.
2147483646 is one below 2147483647, the largest a 32-bit pid_t holds.
…ld keys left the wheel

The plan's still-owed list said a wheel left up before a take renders
at mod 0, citing advice in docs/keys.md that chunk 3 replaces. A dated
note now says a take starts where field keys left the wheel and that
only a hardware wheel moved before the arm is still missed, and
instrument-knobs.md §2.9 names the note.
…s pull

#204 added a branch to recordMidiBlock for a block whose pull ran before
record's request: that block does not start the take, and it drained
its MIDI through a discard lambda. This change replaces that lambda with
chaseEach, so on main the stack no longer compiled ("use of undeclared
identifier 'discard'"). What the branch drains arrived before the take
starts, which the chase keeps, so it now drains through chaseEach too.

A daemon test sets #204's FIELD_AUDIOD_LATCH_STALL_MS seam to 8 ms,
which holds each block between its pull and its latch, and sends a
controller just before each of ten records on one arm. With a
discarding drain in that branch, a controller was missing from a take
in 4 of 4 runs; with chaseEach, every take had it in 6 of 6 runs.

@ninjudd ninjudd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📽️ Projector review · 0.7.9 · model claude-opus-5-5 · effort xhigh · CLEAN · took 11m 02s

This head rebases chunk 3 of the instrument-knobs plan and its review fixes onto main, which now holds #209, #210, #204, and #213, and adds one commit for the merge. #204 gave recordMidiBlock a branch for a block whose pull ran before record's request, and that branch drained its MIDI through the discard lambda this change renamed. That branch now drains through chaseEach, because what it drains arrived before the take starts. A new daemon test sends a controller just before each of ten records under #204's latch stall. The rest is the change as reviewed before: a MIDI take starts with each controller's latest value from the arm, the values field keys published first, written at at: 0.

4 finding threads: 4 resolved, 0 open

Covered 17 of 17 changed files; none generated. This review reads the pull request's own change against main at e791a11.

  • The head is trusted by Justin's ruling on the Co-Authored-By: Claude trailer. Every commit's git author and committer is ninjudd.
  • What ran at this head. pnpm install --frozen-lockfile, pnpm typecheck, a release build of field-audiod against JUCE 8.0.4, and vitest run src/commands/record-plan.test.ts src/keys/session.test.ts (51 tests) all pass. I did not run record-midi-daemon.test.ts, the new test included, because it arms every MIDI source on the machine.
  • A probe of the chase, with no MIDI port and no audio device. It runs this head's Player in null-output mode, arms through armSet, and injects control changes through handleIncomingMidiMessage. On this head, a MIDI take, a count-in on a file bed, a MIDI companion of an audio take, and a re-arm with no seeds each start with the lines §2.8 describes. Under #204's latch stall, a control change queued just before record lands at at: 0 in 5 of 5 takes.

Suggestions

  • native/audiod/src/player.cpp:1480: call chaseArrival for each arrival stampMidiBlock pushes, too. A second record on one arm starts a controller at its value from before the first take, not where that take left it; the probe and the new daemon test both record several takes on one arm. field record still arms once per take, so nothing reaches this yet, but arming.md chunk 3's lasting arm would.

What was checked

  • Every drain before a start chases, and every start writes the chase. At this head, MIDI that arrives before a take starts goes through chaseArrival on each path: armed and idle, a count-in or punch-in short of its position, the block whose pull missed record's request, and arrivals inside the start block before the start sample. Both the MIDI-primary latch and the audio primary's latch for MIDI companions set chasePending. The one drain that still discards runs after a stop has detached the companions.
  • The rebase keeps #213's arm owner. armSet takes the seeds before owner, and the server passes both. arm and armMidi pass no owner, as on main, and field record's monitored arm passes the controllers.
  • #204's loop handoff is untouched. MIDI loop takes, and loop takes with companions, are still refused, so the skipped-pass path never meets a MIDI take.
  • Earlier findings are settled. The four finding threads are fixed at this head and resolved: ChaseSeed sits above Player's comment, docs/project-model.md is rewrapped, keyboard-instrument.md §14.5 has its dated note, and the ! blockSawRequest branch drains through chaseEach.
  • CI passes on linux and windows, including pnpm build:native and pnpm test. There, record-midi-daemon.test.ts ran 3 of its 9 tests and skipped the 6 that need a MIDI source, the new latch test among them, so the probe is what exercised that branch at this head.

@ninjudd
ninjudd marked this pull request as ready for review October 11, 2026 21:58
@ninjudd
ninjudd marked this pull request as draft October 11, 2026 22:13
…starts where the first left each controller

The chase table took only the control changes that arrived before a
take started. A change the take recorded never reached it, so a second
record on one arm started that controller at its value from before the
first take. field record arms once per take, but arming.md chunk 3's
lasting arm keeps one arm across takes.

stampMidiBlock now chases every arrival once the take's lines at at: 0
are written, so a change the take records is never written twice. It
also chases a change past until, and recordMidiCompanions chases what
arrives in the block where a stop detaches the companions. Each belongs
to no take, as a change after the take ends does, and those were
already chased. Each is one table write on the audio thread.

A daemon test records twice on one arm, with cc 114 = 20 before the
first take and cc 114 = 50 during it. The second take's line at at: 0
was cc 114 = 20 before this change and is cc 114 = 50 with it.
docs/audio-engine.md and the plan's §2.8 and §11 say so.

@ninjudd ninjudd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📽️ Projector review · 0.7.9 · model claude-opus-5-5 · effort xhigh · CLEAN · took 6m 26s

This head adds one commit to the clean 03c89f8, on the same base (main at e791a11). The chase table now follows every control change from the arm, not only those before the start. stampMidiBlock chases each arrival it stamps, right after the take's chased lines are written, and the drain after a stop detaches an audio take's MIDI companions chases too. So a second take on one arm starts each controller where the first take left it. A new daemon test covers two takes on one arm, and the docs and the plan record the rule.

4 finding threads: 4 resolved, 0 open

Covered 17 of 17 changed files; none generated. The commit touches 4 of them, and the other 13 are as the full review of 03c89f8 read them.

  • The head is trusted by Justin's ruling on the Co-Authored-By: Claude trailer. Every commit's git author and committer is ninjudd.
  • What ran at this head. pnpm install --frozen-lockfile, pnpm typecheck, a release build of field-audiod against JUCE 8.0.4, and vitest run src/commands/record-plan.test.ts src/keys/session.test.ts (51 tests) all pass. I did not run record-midi-daemon.test.ts, the new test included, because it arms every MIDI source on the machine.
  • A probe of the chase, with no MIDI port and no audio device. It runs this head's Player in null-output mode, arms through armSet, and injects control changes through handleIncomingMidiMessage. On this head, a second record on one arm starts 16/111 at 50, where the first take left it. At 03c89f8 it started at 20, its value before the first take. The first take's lines at at: 0 still leave out the 50 it records at its own time. A change past a punch-out's until stays out of that take and starts the next take on the arm. A count-in, a MIDI companion of an audio take, a re-arm with no seeds, and a control change queued just before record under #204's latch stall (5 of 5 takes) behave as at 03c89f8.

What was checked

  • A recorded change is never written twice. In stampMidiBlock, writeChase runs before chaseArrival for the first stamped arrival, and chasePending is false for every later one. So the take's lines at at: 0 never hold a change the take also records at its own time.
  • Nothing else reads the table mid-take. writeChase is the table's only reader, and it runs once per take at the start. Each arm starts the table over, so chasing during a take changes only a later take on the same arm.
  • The callback stays real-time safe. The added work is one constant-time table write per arrival, in a drain the callback already runs.
  • The docs match the code. audio-engine.md's "MIDI capture", the plan's dated amendment at §2.8, and §11.1 say what the code does, and the edits keep the wrapping around them.
  • CI passes on linux, and fails on windows in two tests this change does not touch. src/commands/clone.test.ts and src/commands/pull.test.ts timed out ("Test timed out in 5000ms", "Hook timed out in 10000ms"). Tests in the same two files timed out on windows on main (run 38176898514) and on #215's branch (run 38173650201), and passed here at 03c89f8, so I count them as a windows flake. CI skipped the daemon tests that need a MIDI source, the new one included.

@ninjudd
ninjudd marked this pull request as ready for review October 11, 2026 22:25
@ninjudd
ninjudd merged commit 9e369a3 into main Oct 11, 2026
6 of 7 checks passed
@ninjudd
ninjudd deleted the knobs/chase branch October 11, 2026 22:34
ninjudd added a commit that referenced this pull request Oct 12, 2026
…ows-portability.md §7.2) (#220)

The `windows` CI job still fails every few runs after #197, on `main`
and on branches alike, and every failure since is a vitest timeout in
`src/commands/clone.test.ts`, `push.test.ts`, or `pull.test.ts`. Each
test in those files sets up a project, a commit, and a bare remote, one
git or git-lfs process after another, and several then clone, push, or
pull. Starting a process is slow on the Windows runner, so on a run that
passes vitest reports 3 to 7 s for one of these tests, setup included,
against its 5 s test default and 10 s hook default. A process-start
stall then tips one over. #197 gave `clone.test.ts`'s `beforeEach` 30 s
for this reason, but left the test bodies and the other two files at the
defaults.

These are the six windows runs that timed out this way on 2026-10-11:

- **`main` at `e791a11`**
([run](https://github.com/okamnesiac/field/actions/runs/38176898514)):
clone's "accepts a full URL" and push's "pushes, then offers every entry
beneath main", each at 5 s.
- **#212**
([run](https://github.com/okamnesiac/field/actions/runs/38179875094)):
clone's "expands the short name" at 5 s, reported at 9.1 s, and pull's
`beforeEach` at 10 s, reported at 11.0 s.
- **#219**
([run](https://github.com/okamnesiac/field/actions/runs/38189357197)):
push's "pushes, then offers every entry beneath main" at 5 s, reported
at 14.2 s.
- **`live/monitor`**
([run](https://github.com/okamnesiac/field/actions/runs/38173858309)):
push's "pushes without a remote" at 5 s.
- **`projector-agents-v4`**
([run](https://github.com/okamnesiac/field/actions/runs/38173650201)):
pull's `beforeEach` at 10 s.
- **`install/release-installer`**
([run](https://github.com/okamnesiac/field/actions/runs/38171418583)):
push's "offers nothing for a working tree with uncommitted changes" at 5
s.

These read as slow runs rather than hangs. Vitest can fire a timeout
only when the event loop is free, and these tests spend long stretches
in synchronous git calls. So a test reported well past its limit, such
as the 14.2 s push on #219, was still making progress until the timer
fired. On that run the whole push file took 33 s against 17.6 s on
`main`'s passing run, so the runner was slow across the board.

All three files now give their `beforeEach` and every test in their
`describe` 30 s, through one `GIT_HEAVY_MS` constant per file, as
`release.test.ts` gives its git-heavy tests. `clone.test.ts`'s
`SETUP_TIMEOUT_MS` becomes that constant. 30 s is twice the slowest
timed-out test, so a timeout there now means a stall twice as long as
any seen, or a real hang. This differs from the "runner stalls" #197
left alone in `project.test.ts` and `live-session.test.ts`, whose hooks
are cheap and stalled once or twice. These tests use most of their
budget on runs where nothing stalls. Raising vitest's `testTimeout` for
the whole suite would also stop these failures, but it would hide real
hangs everywhere else. The Windows plan records the item in §7.2 as
done. The change touches tests and the plan, and no product code.

## Testing

From the root of a checkout of `windows/remote-test-timeouts`, after
`pnpm install --frozen-lockfile`. These three files need no native
build.

```sh
pnpm typecheck
pnpm exec vitest run src/commands/clone.test.ts src/commands/push.test.ts src/commands/pull.test.ts
project check
```

You should see `tsc --noEmit` print nothing, then `Test Files 3 passed
(3)` and `Tests 22 passed (22)`, then "Project plans are valid." On
macOS these tests pass with or without this change, so this only shows
nothing broke.

To see that the budget reaches both the hooks and the tests, shrink it
and watch the timeout messages name the new value:

```sh
sed -i '' 's/^const GIT_HEAVY_MS = 30_000;$/const GIT_HEAVY_MS = 100;/' src/commands/{clone,push,pull}.test.ts
pnpm exec vitest run src/commands/clone.test.ts src/commands/push.test.ts src/commands/pull.test.ts 2>&1 | grep -oE '(Test|Hook) timed out in [0-9]+ms' | sort | uniq -c
git checkout -- src/commands
sed -i '' 's/{ timeout: GIT_HEAVY_MS }/{ timeout: 100 }/' src/commands/{clone,push,pull}.test.ts
pnpm exec vitest run src/commands/clone.test.ts src/commands/push.test.ts src/commands/pull.test.ts 2>&1 | grep -oE '(Test|Hook) timed out in [0-9]+ms|Tests +[0-9].*' | sort | uniq -c
git checkout -- src/commands
```

The first run should report only `Hook timed out in 100ms`, because
every setup hook now fails first. The second should report `Test timed
out in 100ms` and `Tests 9 failed | 13 passed (22)`, beside the tail of
vitest's `Failed Tests 9` banner: the nine tests that wait on a real
clone, push, or pull time out, and the rest finish synchronously. A
`5000ms` or `10000ms` in either run means a hook or test still runs on
vitest's default, and the change is wrong. The `sed -i ''` form is BSD
sed, as on macOS. Each `git checkout -- src/commands` puts the files
back, and the tests remove their own temp projects, so nothing is left
behind.

The real check is this pull request's `windows` CI job, which cannot run
by hand here. Its `pnpm test` step should pass all three files. A `Test
timed out in 5000ms` or `Hook timed out in 10000ms` naming
`clone.test.ts`, `push.test.ts`, or `pull.test.ts` means the change is
wrong. A `30000ms` timeout there would be a new finding: a stall longer
than 30 s, or a hang. One green run proves little against a failure that
came every few runs, so the evidence builds over the next runs on
`main`.

<!-- projector-summary v=1 sha=205b0caa95d297c0823c7746b262708791e78577
-->
📽️ **Projector summary** of 205b0ca: https://field.amnes.ac/reviews/220
ninjudd added a commit that referenced this pull request Oct 12, 2026
…hile it is held (#225)

`field keys` told you what you were playing only as note names at the
end of the status line, so finding a key, or seeing which keys a chord
used, meant reading text. This change draws the keyboard in the
terminal: the keys that play notes, as keycaps with their letters, laid
out so the black keys sit between the white keys as they do on a piano.
Each key lights in reverse video while you hold it.

```
  ┌───┬───┐   ┌───┬───┬───┐   ┌───┬───┐   ┌───┐
  │ W │ E │   │ T │ Y │ U │   │ O │ P │   │ ] │
┌─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┘
│ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
mod   0
Field Keys · musical · transpose 0 · velocity 100 · bend +0 · –
```

The drawing sits between the instrument's line and the knob line, and
redraws in place from the first line that changes, as those lines
already do. The row above the home row sits half a key to the left, so
`W` falls between `A` and `S`. A key that plays nothing, such as `Q`,
`R`, `I`, or `[` in `musical`, leaves a gap, which is what makes it read
as a piano. `src/keys/keyboard.ts` lays each key out as a rectangle on a
character grid and picks each box-drawing character from the lines that
meet in its cell. That keeps the junctions right where the offset row
meets the home row.

As Justin asked, this does the work for `musical` only for now. It draws
a keymap whose notes are all on the home row and the row above it, and
draws nothing for `tracker` and `fourths`, whose notes span four rows
and start elsewhere; they can come later. It also draws nothing on a
terminal too narrow for it, rather than draw it broken. `musical`'s
drawing is 47 columns wide, and `field keys` draws in one column less
than the terminal has, so it needs a terminal of 48 columns.

`musical` gains F#5 on `]`. It is the next black key after `'` (F5), so
it completes the pattern the drawing shows, and Justin listed it among
the keys to draw. Every other key plays what it did.

## Testing

I ran these on macOS from the root of a checkout of this branch, after
`pnpm install` and `pnpm build`.

1. `pnpm typecheck` prints nothing and exits 0; `project check` reports
the plans valid; `git diff --check` is clean.
2. `pnpm vitest run src/keys src/schema src/commands/keys.test.ts`
passes 225 tests. `src/keys/keyboard.test.ts` pins `musical`'s drawing
line by line, the reverse video on a held key on each row (and on no
other line), no drawing for `tracker`, `fourths`, or a width of 46
columns, which is what a 47-column terminal gives the drawing, and a
keymap of your own with three keys. A changed line in the first test
means the layout or a junction moved.
3. The full suite, `pnpm vitest run`, against a `field-audiod` built
from this branch's `main`: 92 test files, 1308 tests passed and 1
skipped. A daemon built before #212 and #213 fails ten daemon tests for
their features, the second-take chase and host monitoring, with nothing
to do with this change.
4. `node dist/cli.js keys --print` shows `F#5` on `]` in `musical`'s
diagram.

I also drove `field keys` in a pseudo-terminal with the kitty protocol's
key events, against a stand-in for `field-audiod --keys` that logs what
it is sent and publishes no MIDI source. The first screen drew the
keyboard above `mod 0` and the status line. Holding `A` put `A`'s face
in reverse video and the status line read `C4`; adding `W` lit both and
read `C4 C#4`; releasing both cleared them, and the stand-in logged two
note-ons and two note-offs.

To see it yourself, run this in Ghostty or iTerm2 from `examples/bloom`,
with no other `field keys` running: `node ../../dist/cli.js keys juno`.
Hold a few keys: each lights while held and goes dark on release, and
`]` plays F#5. `--keymap tracker` shows no drawing, as expected for now.

<!-- projector-summary v=1 sha=6fb0066d533a2c262981b33f3fa72588c15d96aa
-->
📽️ **Projector summary** of 6fb0066: https://field.amnes.ac/reviews/225

This branch was previously deployed

1 inactive deployment
github-pages — 68d929f4 Deployed Oct 11, 2026 by ninjudd via publish #158
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant