Skip to content

Draw musical's keys as a keyboard in field keys, and light each one while it is held - #225

Merged
ninjudd merged 3 commits into
mainfrom
keys/keyboard-drawing
Oct 12, 2026
Merged

ninjudd merged 3 commits into
mainfrom
keys/keyboard-drawing

Conversation

@ninjudd

@ninjudd ninjudd commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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 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.
  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 of 6fb0066: https://field.amnes.ac/reviews/225

…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 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 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:4 and the new comments in position.ts and session.ts narrate their adjacent code. guidelines.md § 1 asks 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:84 calls 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.ts passed 209 tests, with 16 skipped.
  • Validation: pnpm typecheck, project check, and git diff --check passed.

@ninjudd
ninjudd marked this pull request as ready for review October 12, 2026 04:06
@ninjudd
ninjudd marked this pull request as draft October 12, 2026 04:08
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 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 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.

@ninjudd
ninjudd marked this pull request as ready for review October 12, 2026 04:15
@ninjudd
ninjudd merged commit 50a4775 into main Oct 12, 2026
7 checks passed
@ninjudd
ninjudd deleted the keys/keyboard-drawing branch October 12, 2026 04:20
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