Skip to content

Commit aa41f7a

Browse files
committed
Keep chord hints stable through progress
Show every destination's complete route in the key line and inline hints. Pressed steps turn blue while pending steps keep the neutral face, so advancing through a chord does not move its keys. Remove the visual separators between adjacent keycaps while preserving the spoken "then" sequence. Cover route identity, colors, geometry, and Escape behavior in the browser suite.
1 parent 7d219d1 commit aa41f7a

13 files changed

Lines changed: 273 additions & 170 deletions

‎examples/corpus.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ <h2>Shape of the change</h2>
648648
<a href="https://github.com/example/gateway/blob/main/gateway/limits.py#L41"
649649
><code>gateway/limits.py:41</code> on GitHub</a
650650
>: the bucket key changes from the remote address to the token id when one is
651-
present. Everything else is plumbing that key through.
651+
present. Everything else is <a href="#core">plumbing that key through</a>.
652652
</p>
653653
</section>
654654

‎examples/pr-walkthrough.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h2>Shape of the change</h2>
4242
<a href="https://github.com/example/gateway/blob/main/gateway/limits.py#L41"
4343
><code>gateway/limits.py:41</code> on GitHub</a
4444
>: the bucket key changes from the remote address to the token id when one is
45-
present. Everything else is plumbing that key through.
45+
present. Everything else is <a href="#core">plumbing that key through</a>.
4646
</p>
4747
</section>
4848

‎skills/leaf/CLAUDE.md‎

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,9 +1603,9 @@ The rule holds for a sequence as much as for a surface, where the stack it is
16031603
about is the reader's rather than the dispatcher's. The address chord arms on
16041604
`g`. A panel mnemonic exchanges that window for its destination, so `g T` leaves
16051605
the Threads panel as one Escape rung. A document-list mnemonic narrows the
1606-
window instead: the key line's pressed prefix advances from `g` to `g › h`, the
1607-
page chips narrow from complete suffixes such as `h › 1` to that list's digits,
1608-
and Escape returns to the destination menu before another Escape closes it.
1606+
window instead. Each hint keeps its complete route, such as `g h 1`; `g`
1607+
starts blue, then `h` turns blue in place when it is pressed. Escape returns to
1608+
the destination menu before another Escape closes it.
16091609

16101610
A layer also owes a way out at all, over the same page the way in is live on.
16111611
`versionsOffered` (there is a menu) answers for the key, the mode binding its
@@ -2046,11 +2046,13 @@ reader's innermost scope and drops bindings shadowed there. The ordinary shortli
20462046
the first live row, then a promotable Escape or the next row; rows declaring
20472047
`linePriority: persistent` remain beside that context. An active chord instead shows
20482048
every live row in its scope, so computed bindings, ranges, and capability filtering are
2049-
the same ones dispatch and the reference use. Its pressed prefix appears once in the
2050-
accent face; the available rows keep the ordinary key face. `lineWhen` may hide only an
2051-
ordinary hint without changing the command's liveness or its place in the reference.
2052-
Hint chips are `aria-hidden` because placeholders and live announcements carry the same
2053-
facts for assistive technology.
2049+
the same ones dispatch and the reference use. Each destination row keeps its complete
2050+
chord: already pressed keys take the accent face and pending keys keep the ordinary face.
2051+
Changing progress changes only those faces, not the sequence's keys or geometry. A mode's
2052+
Escape or back row remains a separate control rather than appearing as a destination
2053+
chord. `lineWhen` may hide only an ordinary hint without changing the command's liveness
2054+
or its place in the reference. Hint chips are `aria-hidden` because placeholders and live
2055+
announcements carry the same facts for assistive technology.
20542056

20552057
The compact line wraps when persistent or chord rows need the room. Ordinary hints may
20562058
yield from the end to stay within two rows, but persistent rows and active chord rows do
@@ -2224,24 +2226,22 @@ same-document hyperlink follows and leaves focus on its fragment target, an exte
22242226
hyperlink names the tab it opens, a fold opens and takes focus, and a page-map item opens
22252227
its marker or focuses its first available action.
22262228

2227-
Arming the mode shows the available list and direct-destination mnemonics in the key line.
2228-
Each visible numbered member also shows the complete suffix still needed to reach it, such
2229-
as `h › 1`. A direct mnemonic completes the travel and moves focus inside its destination.
2230-
A numbered-list mnemonic narrows the inline hints to that list's first nine digits and
2231-
reveals the same range in the key line. The following digit selects immediately. Escape
2232-
backs out to the list menu before it closes the mode.
2229+
Arming the mode shows the available direct destinations and numbered lists in the key
2230+
line. Each row shows its complete chord. Each visible numbered member also shows its
2231+
complete address, such as `g h 1`. A direct mnemonic completes the travel and moves
2232+
focus inside its destination. A numbered-list mnemonic narrows the inline hints to that
2233+
list's first nine members without changing their labels or geometry. The following digit
2234+
selects immediately. Escape backs out to the list menu before it closes the mode.
22332235

22342236
Every sequential step has its own fixed keycap. A compact choice label such as `g / G`
2235-
remains one decision point and is spoken as “g or G”; a muted `›` means “then” visually,
2236-
and the sequence's accessible label spells that word out. In a live chord, pressed keys
2237-
take the accent ground once at the start of the line. Available keys in the line and every
2238-
unpressed key in an inline suffix remain neutral, matching ordinary bindings. The complete
2239-
reference shows every route with all steps neutral because it describes rather than enacts
2240-
them.
2237+
remains one decision point and is spoken as “g or G”; a sequence's accessible label says
2238+
“then” between adjacent keycaps. In a live chord, pressed keys take the accent ground and
2239+
pending keys remain neutral, matching ordinary bindings. The complete reference shows
2240+
every route with all steps neutral because it describes rather than enacts them.
22412241

22422242
`chordKeys` is the structured reading of how far a numbered address has come. The key
2243-
line draws that prefix once, the reference combines the standing-page prefix with each
2244-
row's `completeChordSteps`, and page chips show the complete suffix still to press.
2243+
line and page chips apply that progress to each complete route. The reference combines
2244+
the standing-page prefix with each row's `completeChordSteps` and shows the result at rest.
22452245

22462246
Numbered addresses are stable within the document and capped at nine per list. The
22472247
first nine members do not change identity as the reader scrolls. Chips are painted

‎skills/leaf/assets/leaf.js‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,10 @@
134134
* `g m 3` goes to the third page-map item in the right margin.
135135
* A following digit names a member of a document list, so `g h 3` is the third
136136
* hyperlink; `g g` and `g G` are the page's top and bottom edges.
137-
* Arming shows the destination and list mnemonics in the key line. Its one blue prefix
138-
* names the keys already pressed; the neutral entries use the ordinary binding face.
139-
* Visible members show the complete remaining suffix (`h › 3`) in that same neutral face.
140-
* A list letter narrows those inline hints to the digit still needed and reveals the range
141-
* in the line. Any other key disarms the window and keeps its
137+
* Arming shows every complete route in the key line. Pressed keys use the blue face and
138+
* pending keys use the ordinary face. Visible members show the same complete route in
139+
* adjacent fixed keycaps. A list letter narrows those inline hints without moving the
140+
* remaining routes. Any other key disarms the window and keeps its
142141
* ordinary meaning, which the dispatcher spells as disarming and walking the stack again.
143142
* Escape is a binding like any other, and the rung is whichever scope in reach binds it
144143
* first, so backing out is one layer per press and the promise cannot drift from the

‎skills/leaf/assets/runtime/chrome-style.js‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,6 @@ export function chromeStyle({
325325
white-space: nowrap; }
326326
.lf-key-sequence > kbd, .lf-key-more kbd { display: inline-flex; align-items: center;
327327
justify-content: center; }
328-
.lf-key-then { color: var(--muted); font-family: var(--sans); font-size: var(--t-6);
329-
line-height: 1; }
330328
.lf-key-sequence > kbd[data-lf-key-state="pressed"] { border-color: var(--accent);
331329
background: var(--accent); color: var(--card); }
332330
/* The leaf text box, in one rule. field-sizing does the growing, so no script
@@ -1280,19 +1278,14 @@ ${MARK_RULES}
12801278
stood (.lf-inspect); the banner takes an accent wash so the mode reads at the top
12811279
edge as well. Nothing here is something to press: pointer-events stands down so a
12821280
click still lands on the item the box outlines. */
1283-
/* The g chord's numbered document destinations. Each visible member shows the complete
1284-
suffix still needed to reach it at the corner where it starts. */
1281+
/* The g chord's numbered document destinations. Each visible member keeps the complete
1282+
route at the corner where it starts; key faces carry progress without changing its
1283+
geometry. */
12851284
.lf-addresses { position: fixed; inset: 0; z-index: 9070; pointer-events: none; }
12861285
.lf-addresses > .lf-address { position: absolute; display: block;
12871286
transform: translate(-50%, -50%); }
12881287
.lf-addresses > .lf-chord-address { min-width: 0; height: auto; padding: 0;
1289-
border: 2px solid var(--accent); border-radius: 6px; background: var(--card);
1290-
box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 20%, transparent); }
1291-
.lf-addresses > .lf-chord-address::after { position: absolute; top: 100%; left: 50%;
1292-
width: 5px; height: 5px; box-sizing: border-box;
1293-
border: 0 solid var(--accent); border-width: 0 2px 2px 0;
1294-
background: var(--card); content: "";
1295-
transform: translate(-50%, -3px) rotate(45deg); }
1288+
border: 0; background: transparent; }
12961289
/* Under the banner there is no room to straddle the corner, so the chip hangs below
12971290
the covered edge instead — the same step the legend's tag makes, and the same class
12981291
name, because it is the same fact about the same bar. */
@@ -1419,10 +1412,6 @@ ${MARK_RULES}
14191412
.lf-dot { background: CanvasText !important; }
14201413
.lf-key-sequence > kbd[data-lf-key-state="pressed"] { border-color: Highlight;
14211414
background: Highlight; color: HighlightText; }
1422-
.lf-addresses > .lf-chord-address { border-color: Highlight;
1423-
box-shadow: none; }
1424-
.lf-addresses > .lf-chord-address::after { border-color: Highlight;
1425-
background: Canvas; }
14261415
:scope :focus-visible { outline: 2px solid Highlight !important;
14271416
outline-offset: 2px !important; box-shadow: none !important; }
14281417
:scope :is([aria-pressed="true"], [aria-checked="true"], [aria-current]) {

‎skills/leaf/assets/runtime/keyboard/address.js‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { labelOf, spell } from "./bindings.js";
2-
import { keySequence } from "./presentation.js";
2+
import { keySequence, progressStates } from "./presentation.js";
33
import { isExternalPageLink } from "../presentation.js";
44

55
export function createAddress({
@@ -233,13 +233,13 @@ export function createAddress({
233233
const addressed = (entry) => entry.list().slice(0, MAX_NUMBERED_ADDRESSES);
234234
const range = (n) => (n > 1 ? `1–${n}` : "1");
235235
// How far the chord has come: `g`, and the list's letter once one has named a list. The
236-
// key line shows this prefix once; the reference combines the standing-page prefix with
237-
// each full route. Page chips omit that prefix and show the complete suffix still needed
238-
// for their target.
236+
// key line and page chips combine that progress with each full route; the reference shows
237+
// the same routes at rest.
239238
const chordKeys = () => [labelOf(GOTO), aimedList?.key].filter(Boolean);
240239
const addressChip = (entry, n) => {
240+
const steps = [labelOf(GOTO), entry.key, String(n)];
241241
const chip = el("span", "lf-address lf-chord-address");
242-
chip.append(keySequence(aimedList ? [String(n)] : [entry.key, String(n)]));
242+
chip.append(keySequence(steps, progressStates(steps, chordKeys().length)));
243243
return chip;
244244
};
245245

@@ -284,10 +284,9 @@ export function createAddress({
284284
// placed from the member's own visible box, so a chip cannot claim room the page has
285285
// already refused — a thread scrolled out of the panel's list, a card half out of a board.
286286
//
287-
// At the first stage, every visible member shows its list letter and digit, the complete
288-
// remaining suffix that distinguishes it from the other lists. Naming a list narrows those
289-
// chips to the digit still needed. Every key in a chip remains neutral because none of its
290-
// displayed suffix has been pressed.
287+
// Every visible member keeps its complete address. Naming a list narrows the members but
288+
// does not narrow their labels: the list key changes from neutral to pressed in place, so
289+
// the route's geometry stays fixed while the reader advances through it.
291290
//
292291
// The layer is the chrome's rather than the page's own markup for the reason every mark is
293292
// (see "Paint; don't wrap"): the addressable things include links set mid-sentence, and a
@@ -511,11 +510,11 @@ export function createAddress({
511510
{
512511
id: "navigation.address.back",
513512
// Two presses in, two presses out. `g` opens the window and a letter names a list
514-
// inside it — the pressed prefix grows and the page chips narrow to that list — so
515-
// one Escape gives the letter back and the next closes the window. It took both at
516-
// once, which is the same drift `c` had at the panel: a reader who had narrowed to
517-
// the wrong list wanted the other one, and cancelling put them back on the page,
518-
// pressing `g` again to reach a window that had been standing the whole time.
513+
// inside it. The complete routes stay fixed while that letter turns pressed, so one
514+
// Escape gives the letter back and the next closes the window. It took both at once,
515+
// which is the same drift `c` had at the panel: a reader who had narrowed to the
516+
// wrong list wanted the other one, and cancelling put them back on the page, pressing
517+
// `g` again to reach a window that had been standing the whole time.
519518
keys: ["Escape"],
520519
chordControl: true,
521520
does: () => (aimedList ? "Back to the lists" : "Cancel the chord"),

‎skills/leaf/assets/runtime/keyboard/keyline.js‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import {
55
commandRoutes,
66
word,
77
} from "./bindings.js";
8-
import { keySequence, neutralStates, pressedStates, rowSteps } from "./presentation.js";
8+
import {
9+
completeRowSteps,
10+
keySequence,
11+
neutralStates,
12+
progressStates,
13+
rowSteps,
14+
} from "./presentation.js";
915

1016
export function createKeyline({
1117
announce,
@@ -166,8 +172,10 @@ export function createKeyline({
166172
...referenceRows,
167173
...projectedRows.filter((row) => row.linePriority === "persistent"),
168174
];
169-
// Read where it is painted, like every other cell. A chord says its completed prefix
170-
// once; every row then keeps the ordinary face used for an available binding.
175+
// Read where it is painted, like every other cell. Every destination keeps its complete
176+
// chord while the reader advances through it: completed keys change face, but no key is
177+
// added, removed, or moved. A chord control such as Escape is a way out of the mode, not
178+
// another destination, so it keeps its ordinary one-step face.
171179
const chordScope = complete?.scope;
172180
const chord = word(chordScope?.chord) ?? [];
173181
// Everything but More, which the reader may be standing on. `textContent = ""` takes
@@ -195,13 +203,13 @@ export function createKeyline({
195203
else keylineEl.insertBefore(span, seated ? keylineMore : null);
196204
return span;
197205
};
198-
if (chord.length) {
199-
const prefix = chip(chord, "", pressedStates(chord));
200-
prefix.classList.add("lf-chord-prefix");
201-
}
202206
const drawn = ordered.map((row) => {
203-
const steps = rowSteps(row);
204-
const span = chip(steps, word(row.line), neutralStates(steps), false, row);
207+
const inChord = chord.length && !row.chordControl;
208+
const steps = inChord ? [chord[0], ...completeRowSteps(row)] : rowSteps(row);
209+
const states = inChord
210+
? progressStates(steps, chord.length)
211+
: neutralStates(steps);
212+
const span = chip(steps, word(row.line), states, false, row);
205213
span.hidden = row === referenceRow || (!shelf && !shown.has(row));
206214
return { row, span };
207215
});

‎skills/leaf/assets/runtime/keyboard/presentation.js‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ export const completeRowSteps = (row, route = null) => {
1515
return word(row.completeChordSteps) ?? rowSteps(row);
1616
};
1717

18-
export const pressedStates = (steps) => steps.map(() => "pressed");
19-
2018
export const neutralStates = (steps) => steps.map(() => "neutral");
2119

20+
export const progressStates = (steps, pressed) =>
21+
steps.map((_, i) => (i < pressed ? "pressed" : "neutral"));
22+
2223
export function keySequence(steps, states = neutralStates(steps), spokenSteps = steps) {
2324
if (
2425
!steps.length ||
@@ -37,13 +38,6 @@ export function keySequence(steps, states = neutralStates(steps), spokenSteps =
3738
steps.forEach((step, i) => {
3839
const state = states[i];
3940
if (!STATES.has(state)) throw new Error(`leaf: unknown key state ${String(state)}`);
40-
if (i) {
41-
const then = document.createElement("span");
42-
then.className = "lf-key-then";
43-
then.setAttribute("aria-hidden", "true");
44-
then.textContent = "›";
45-
sequence.append(then);
46-
}
4741
const key = document.createElement("kbd");
4842
key.dataset.lfKeyState = state;
4943
key.setAttribute("aria-hidden", "true");

‎tests/CLAUDE.md‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,12 +451,13 @@ A surface that reads the same before and after the press cannot be its own wait
451451
`expect(...).to_have_text(...)` is satisfied by the frame the press has not reached yet,
452452
and a measurement taken behind it then compares a reading with itself and passes. It is
453453
the same coalesced frame as above, but it fails differently: not late by a poll, but
454-
green because nothing was ever asserted. `test_numbered_addresses_show_the_remaining_route_in_the_ordinary_key_face`
455-
waits for the `h` row after `g` before asserting the complete inline suffixes, then waits
456-
for digit-only suffixes after `h`. When a surface does not itself change, a test whose
457-
subject is
458-
what a press does *within* it waits on some other fact of that press, and its bug-back is
459-
run more than once: a wait that is sometimes real looks exactly like a wait that is.
454+
green because nothing was ever asserted.
455+
`test_numbered_addresses_show_progress_on_complete_routes_without_moving` waits for the
456+
complete `g h 1–2` row after `g`, then waits for `h` to wear its pressed state after
457+
the next press. The route's text and geometry deliberately stay unchanged. When a surface
458+
does not itself change, a test whose subject is what a press does *within* it waits on some
459+
other fact of that press, and its bug-back is run more than once: a wait that is sometimes
460+
real looks exactly like a wait that is.
460461

461462
A retrying assertion that a paint has *not* happened is the same trap wearing the other
462463
sign, and it is worse, because retrying is what usually rescues a reader from it. A

‎tests/render_cases_navigation.py‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,23 @@ def mark_shows_beside_composer(page):
244244
)
245245
# What the chord's lists are offering, in the order they were drawn. Read through the
246246
# retrying assertion rather than evaluated: the chips are painted on a frame of the
247-
# runtime's own (paintHere), so a press and a plain read race each other. Each chip says
248-
# only the presses still needed to reach its target.
247+
# runtime's own (paintHere), so a press and a plain read race each other. Each chip keeps
248+
# its complete route while the pressed key faces show how far the reader has come.
249249
CHIPS = ".lf-addresses > .lf-address"
250250

251251

252+
def expect_address_steps(page, routes):
253+
chips = page.locator(CHIPS)
254+
expect(chips).to_have_text(["".join(route) for route in routes])
255+
assert (
256+
chips.evaluate_all(
257+
"""chips => chips.map(chip => [...chip.querySelectorAll('kbd')]
258+
.map(key => key.textContent))"""
259+
)
260+
== routes
261+
)
262+
263+
252264
NOTED_PAGE = leaf_page(
253265
"noted",
254266
"""

0 commit comments

Comments
 (0)