Repository navigation
Draw musical's keys as a keyboard in field keys, and light each one while it is held - #225
Conversation
…hile it is held field keys now draws the keys that play notes above the knob line, as keycaps with their letters: the home row, and the row above it half a key to the left, so its keys sit between the home row's as a piano's black keys do. A held key shows in reverse video until its release. It draws a keymap whose notes are all on those two rows, which musical's are, on a terminal wide enough for it; other keymaps go without it for now. musical gains F#5 on `]`, the next black key after `'`.
ninjudd
left a comment
There was a problem hiding this comment.
📽️ Projector review of af0210c · 0.7.10 · model gpt-6 · CLEAN · took 1m 43s
This change draws the note keys above field keys' status line and lights each held key. It supports keymaps confined to the home and top rows, and adds F#5 on ] to musical; the other built-ins keep playing without a drawing.
0 finding threads: 0 resolved, 0 open
Covered 9 of 9 changed files; no generated files skipped.
The scratch checkout has no native build, so 16 native-helper and daemon-routing tests skipped.
Suggestions
- Comments:
src/keys/keyboard.ts:4and the new comments inposition.tsandsession.tsnarrate their adjacent code.guidelines.md § 1asks for constraints or reasons instead. The merged keys code uses the same explanatory style throughout, so this is a gap between the rule and repository practice, rather than a blocking finding on this change. - Width wording:
docs/keys.md:84calls 47 columns the terminal minimum, but the command reserves one terminal column; a 47-column terminal supplies width 46 and omits the drawing. Describe the terminal minimum as 48 columns or distinguish usable width from terminal width.
Checks:
- Behavior: Read the renderer, the session's press/release and reload paths, position resolution, and the command's redraw call. Reverse video is confined to key faces; unsupported rows omit the drawing.
- Tests:
pnpm vitest run src/keys src/schema src/commands/keys.test.tspassed 209 tests, with 16 skipped. - Validation:
pnpm typecheck,project check, andgit diff --checkpassed.
The comments on `keyboard.ts`, `US_LABELS`, and `heldPositions` described what the code beneath them does. The one reason among them stays beside `ROWS`: the top row sits half a key to the left so its keys fall between the home row's, as a piano's black keys do.
The drawing is 47 columns wide, but `field keys` draws in one column less than the terminal has, so a 47-column terminal shows no keyboard.
ninjudd
left a comment
There was a problem hiding this comment.
📽️ Projector review of 6fb0066 · 0.7.10 · model gpt-6 · CLEAN · incremental from af0210c · took 0m 20s
Incremental review of the change since the full review of af0210c: +3 −11 lines in 4 files.
The update corrects the documented terminal minimum to 48 columns and removes comments that restated the adjacent code. The remaining renderer comment records why the top row has its offset. I read all four changed files' hunks and checked the width statement against the command's reserved column. Executable code is unchanged.
field keystold 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.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
Wfalls betweenAandS. A key that plays nothing, such asQ,R,I, or[inmusical, leaves a gap, which is what makes it read as a piano.src/keys/keyboard.tslays 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
musicalonly for now. It draws a keymap whose notes are all on the home row and the row above it, and draws nothing fortrackerandfourths, 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, andfield keysdraws in one column less than the terminal has, so it needs a terminal of 48 columns.musicalgains 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 installandpnpm build.pnpm typecheckprints nothing and exits 0;project checkreports the plans valid;git diff --checkis clean.pnpm vitest run src/keys src/schema src/commands/keys.test.tspasses 225 tests.src/keys/keyboard.test.tspinsmusical's drawing line by line, the reverse video on a held key on each row (and on no other line), no drawing fortracker,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.pnpm vitest run, against afield-audiodbuilt from this branch'smain: 92 test files, 1308 tests passed and 1 skipped. A daemon built before 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 and Hear a microphone through its track while it records: field record --monitoring host (live-supercollider.md chunk 4) #213 fails ten daemon tests for their features, the second-take chase and host monitoring, with nothing to do with this change.node dist/cli.js keys --printshowsF#5on]inmusical's diagram.I also drove
field keysin a pseudo-terminal with the kitty protocol's key events, against a stand-in forfield-audiod --keysthat logs what it is sent and publishes no MIDI source. The first screen drew the keyboard abovemod 0and the status line. HoldingAputA's face in reverse video and the status line readC4; addingWlit both and readC4 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 otherfield keysrunning:node ../../dist/cli.js keys juno. Hold a few keys: each lights while held and goes dark on release, and]plays F#5.--keymap trackershows no drawing, as expected for now.📽️ Projector summary of 6fb0066: https://field.amnes.ac/reviews/225