Skip to content

Commit de0f296

Browse files
authored
Make thread transitions, focus, and resolution consistent (#213)
Submitting a selection comment could close the Threads panel, shift the document, and leave keyboard focus unclear. Keep the new conversation in the reader's chosen view and focus its reply box. Wide live pages reserve conversation space before the first comment so sending and resolving leave the document column in place. Opening a conversation enters its reply, while explicit thread navigation stays on cards. Escape returns from a panel reply to its card, and Enter resumes typing. Stronger input focus styling distinguishes these modes, and long threads reveal the reply field with Send and Resolve together. Later typing or selection retains focus when a request completes. Inline and panel views now share Resolve/Reopen controls, immediate pending feedback, and duplicate-submission protection through the outbox. Settlement preserves focus when replacing controls, including page-seated threads that have no reply box. A CSS validation regression also checks changed theme values and syntax against unchanged authored HTML. Validation: the everyday suite, focused browser suites covering conversations, navigation, margins, and drafts, and pre-commit checks. Regression cases include version-response seats without a reply box and a filtered panel receiving a comment after the reader selects another passage. Inspected the live examples at narrow and wide sizes in light and dark themes. Updated the ship-review example, regenerated its corpus, and aligned the runtime guidance. > _This was written by Codex on behalf of max-sixty_
1 parent 9b1e082 commit de0f296

18 files changed

Lines changed: 664 additions & 243 deletions

‎examples/corpus.html‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,13 +1568,12 @@ <h3>Is that enough for the first patch?</h3>
15681568
<section id="off-conversation">
15691569
<h2>The objection that matters</h2>
15701570
<p id="off-conversation-note">
1571-
The standalone page opens mid-review: its anchored thread asks whether a
1572-
one-in-forty failure compounds enough to block launch, and carries the
1573-
follow-up work the approver wants ready if the vendor's release slips.
1574-
Approval records the direction; task statuses change when the agent publishes
1575-
the resulting version. Codex opens this full page in its browser pane;
1576-
comments and option choices enter the durable page log and return to the same
1577-
agent task.
1571+
Open the comment on the reconnect stall to read the objection and the
1572+
follow-up work proposed if the vendor's release slips. Reply beside the
1573+
passage, or keep Threads open to review the whole conversation. Select another
1574+
passage to add a comment; it appears in the view you are using. Resolve a
1575+
thread when its question is answered. Approval records the direction; task
1576+
statuses change when the agent publishes the resulting version.
15781577
</p>
15791578
</section>
15801579
</lf-tab>

‎examples/ship-review.html‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,12 @@ <h3>Is that enough for the first patch?</h3>
8282
<section id="off-conversation">
8383
<h2>The objection that matters</h2>
8484
<p id="off-conversation-note">
85-
The standalone page opens mid-review: its anchored thread asks whether a
86-
one-in-forty failure compounds enough to block launch, and carries the
87-
follow-up work the approver wants ready if the vendor's release slips.
88-
Approval records the direction; task statuses change when the agent publishes
89-
the resulting version. Codex opens this full page in its browser pane;
90-
comments and option choices enter the durable page log and return to the same
91-
agent task.
85+
Open the comment on the reconnect stall to read the objection and the
86+
follow-up work proposed if the vendor's release slips. Reply beside the
87+
passage, or keep Threads open to review the whole conversation. Select another
88+
passage to add a comment; it appears in the view you are using. Resolve a
89+
thread when its question is answered. Approval records the direction; task
90+
statuses change when the agent publishes the resulting version.
9291
</p>
9392
</section>
9493
</main>

‎skills/leaf/CLAUDE.md‎

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ cross-widget projected-datum travel;
119119
`runtime/conversation/replies.js` owns reply drafts, mirrored send state, and delivery;
120120
`runtime/conversation/inline.js` owns conversation seats rendered into the page;
121121
`runtime/conversation/box.js` owns page-seated first-message boxes;
122-
`runtime/conversation/folding.js` owns resolution-fold state and motion;
122+
`runtime/conversation/folding.js` owns shared Resolve/Reopen controls and resolution-fold
123+
state and motion;
123124
`runtime/conversation/landing.js` owns conversation input discovery, focus travel,
124125
and panel arrival;
125126
`runtime/conversation/narrowing.js` owns comment-panel search and waiting-on-reader
@@ -1098,16 +1099,16 @@ parts. It reads the focus, through `closest`, rather than being written where a
10981099
travel left the reader — the argument `markHere` makes for the decision ring, and for
10991100
the same reason. Every route that puts the reader in a thread therefore paints
11001101
it: the quote's press, the `t`/`T` walk, a click on the card, a reply box. A
1101-
press on a page mark reaches `showThread`, which focuses the thread
1102-
with `preventScroll` before its deliberate reveal; the page and card therefore
1103-
both say which comment that press opened, and the next key belongs to the thread
1104-
scope. `paintHere` repaints it beside the decision ring, and `paintAnchors` repaints
1102+
press on a page mark reaches `showThread`, which focuses the reply box before its
1103+
deliberate reveal. Escape returns to the card; `t`/`T` then walk the threads.
1104+
`paintHere` repaints it beside the decision ring, and `paintAnchors` repaints
11051105
it after rebuilding the ranges it holds.
11061106

11071107
The panel paints the same fact on the card, through `.lf-thread:focus-within` —
11081108
the same predicate, so the two halves cannot disagree about which comment the
11091109
reader is in. `:focus-visible` instead answers which input modality should draw
1110-
the browser's focus indicator.
1110+
the browser's focus indicator. While typing, the reply box carries the strong
1111+
focus ring and the enclosing thread keeps a subdued outline.
11111112

11121113
`lf-mark-hover` answers a different question — which thread the pointer is
11131114
indicating — and reads both surfaces in one frame. A card is the thread's view in
@@ -2299,7 +2300,9 @@ under a standing thread cuts its ring again, and nothing re-lands it: the reader
22992300
is moving away from what they were standing in, and a control under something is
23002301
a fact about where it was put. A thread taller than the list's own scrollport is
23012302
the excepted case in both directions — there is no scroll that shows all of it,
2302-
which is the same thing the ring reading declines to report.
2303+
which is the same thing the ring reading declines to report. Landing in a reply
2304+
inside such a thread reveals its composer and actions together; an editor too
2305+
tall to fit with its actions reveals the focused control itself.
23032306

23042307
`test_no_ring_the_panel_draws_on_a_walk_down_its_list_is_cut_or_covered`,
23052308
`test_a_comment_the_pointer_lands_on_comes_out_from_under_the_run_heading`, and
@@ -2669,6 +2672,12 @@ or disclosure state. Reconciliation preserves node identity; the list's own
26692672
hold, rather than the browser's scroll anchoring, preserves viewport position.
26702673
Tests pin the thread's box rather than a particular scroll offset.
26712674

2675+
Panel and inline settlement controls read pending work from the outbox. Their busy
2676+
labels reserve their width, keep focus, and prevent another submission while the
2677+
request is pending. The accepted projection decides when the thread resolves or
2678+
reopens. Resolving the last thread in an inline card closes it and returns focus
2679+
to page navigation; a conversation seated in the page keeps a Reopen control.
2680+
26722681
`renderThreads` holds one live card through every list mutation. It chooses the
26732682
card under the pointer while the pointer is in the list, then the card containing
26742683
focus, then the topmost visible card. It records later visible cards before the
@@ -2747,10 +2756,10 @@ landing in a thread in front of them — and takes the list as it stands.
27472756
`showThread` insists: a press out on the page or in a message knows nothing of
27482757
the narrowing it would be asking past, and a comment the reader has just written
27492758
cannot vanish into a narrowing it does not match, so the narrowing goes instead.
2750-
It focuses the containing thread before `revealThread` scrolls it, making the
2751-
thread the standing result rather than a card flashed while focus remains on the
2752-
page. `preventScroll` keeps that focus call out of the scroll, so the list's own
2753-
landing and then the reveal place the thread, in that order.
2759+
It focuses the reply box, or the card when the thread is resolved, before
2760+
`revealThread` places it. A thread too tall for its scrollport reveals its reply
2761+
area. The explicit `t`/`T` walk remains on cards; Enter starts a reply and Escape
2762+
returns to the card. A general-comment send keeps focus in its originating box.
27542763
A reveal that widened for a reply would take the reader's narrowing away for
27552764
having been used, which is how the waiting-on-you list is emptied.
27562765

@@ -2789,10 +2798,15 @@ outcome from `composerOpen`, `pendingAnchor`, and `fabAnchor`; `openComposer`'s
27892798
option decides focus independently. Outside clicks and Escape hide without discarding
27902799
words. A successful send or an explicit draft close discards the local record.
27912800

2792-
An accepted anchored comment opens its inline thread. `--thread-card-floor` is how
2793-
narrow the room right of its marker may get before that thread comes off the marker
2794-
and covers the page in its bounded card; it does not substitute the Threads panel. The send focuses the reply box only when no later selection, edit, or
2795-
typing gesture stands.
2801+
An accepted anchored comment continues in the open Threads panel, widening a filter
2802+
that would hide it. With the panel closed, it opens the inline thread beside its
2803+
passage. A page marker uses an already-open panel; with the panel closed, it opens
2804+
inline where the layout has room and uses the panel at narrower widths.
2805+
The send focuses the reply box only when no later selection, edit, or typing gesture
2806+
stands. Live pages reserve conversation room at the wide layout's existing floors,
2807+
so the first comment and the last resolution leave the document column in place.
2808+
`--thread-card-floor` bounds an inline card when the remaining margin is too narrow;
2809+
the card then covers the page rather than becoming an unreadable sliver.
27962810
News arriving without the reader's send gesture may show a notice and count but
27972811
does not move focus or scroll the panel. `notice` is the one visible surface for a
27982812
moment's news — a recorded gesture, an arrived version, a refused send — and it

‎skills/leaf/assets/leaf.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,7 @@ selectionComposerRuntime = createSelectionComposer(runtime, {
13881388
loadDraft,
13891389
mayLandTyping,
13901390
openInlineThread: (...args) => livingMargin?.openInlineThread(...args) ?? null,
1391+
panelIsOpen,
13911392
paintAnchors,
13921393
paintHere,
13931394
post,
@@ -1478,7 +1479,7 @@ const syncGeneral = wireInput(generalInput, {
14781479
);
14791480
if (!sent) return;
14801481
const shouldLand = mayLandTyping(generalInput);
1481-
showThread(sent.id, { stand: shouldLand });
1482+
showThread(sent.id, { stand: false });
14821483
if (shouldLand) landTyping(generalInput); // both send routes end where typing was
14831484
},
14841485
});
@@ -2430,7 +2431,7 @@ const THREAD = {
24302431
Boolean(focusedThread()?.querySelector(":scope > .lf-compose")) ||
24312432
Boolean(
24322433
focusedThread()?.querySelector(
2433-
":scope > .lf-thread-actions > .lf-reopen:not(:disabled)",
2434+
':scope > .lf-thread-actions > .lf-reopen:not(:disabled, [aria-disabled="true"])',
24342435
),
24352436
),
24362437
// Find the thread's own compose row rather than the first textarea: a message may
@@ -2464,13 +2465,13 @@ const THREAD = {
24642465
when: () =>
24652466
Boolean(
24662467
focusedThread()?.querySelector(
2467-
":scope > .lf-thread-actions > :is(.lf-resolve, .lf-reopen):not(:disabled)",
2468+
':scope > .lf-compose > .lf-thread-actions > .lf-resolve:not(:disabled, [aria-disabled="true"]), :scope > .lf-thread-actions > .lf-reopen:not(:disabled, [aria-disabled="true"])',
24682469
),
24692470
),
24702471
run: () =>
24712472
focusedThread()
24722473
.querySelector(
2473-
":scope > .lf-thread-actions > :is(.lf-resolve, .lf-reopen):not(:disabled)",
2474+
':scope > .lf-compose > .lf-thread-actions > .lf-resolve:not(:disabled, [aria-disabled="true"]), :scope > .lf-thread-actions > .lf-reopen:not(:disabled, [aria-disabled="true"])',
24742475
)
24752476
.click(),
24762477
},

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,8 @@ export function chromeStyle({
440440
border-radius: 6px; background: var(--card); color: inherit; resize: none;
441441
field-sizing: content; max-height: 50vh; overflow-y: auto; }
442442
.lf-ui textarea:where(:not(.lf-fab-input)):is(:focus, .lf-focus),
443-
textarea.lf-ui:where(:not(.lf-fab-input)):is(:focus, .lf-focus) { outline: none;
444-
border-color: color-mix(in srgb, var(--accent) 45%, var(--card));
445-
box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
443+
textarea.lf-ui:where(:not(.lf-fab-input)):is(:focus, .lf-focus) { outline: var(--here-ring);
444+
--lf-here-ring: text-box; outline-offset: 1px; border-color: var(--accent); }
446445
${MARK_RULES}
447446
body.lf-over-mark { cursor: pointer; }
448447
/* Holding ⌥ changes what a click means, and nothing on the page said so — the chord's
@@ -1183,6 +1182,10 @@ ${MARK_RULES}
11831182
the box itself is within. */
11841183
.lf-thread:is(:focus-within, .lf-focus-within) { outline: var(--here-ring); --lf-here-ring: thread;
11851184
outline-offset: calc(-1 * var(--here-ring-w)); }
1185+
/* The strong ring names the control receiving keys. Keep the thread's standing
1186+
visible while typing, with the reply box carrying the active ring itself. */
1187+
.lf-thread:has(> .lf-compose textarea:is(:focus, .lf-focus)) {
1188+
outline-color: color-mix(in srgb, var(--accent) 25%, transparent); }
11861189
.lf-quote { margin: 0 0 8px; padding: 2px 8px; border-left: 3px solid var(--mark-ink); color: var(--muted); font-style: italic; cursor: pointer; overflow-wrap: anywhere; }
11871190
.lf-quote:is(:hover, :focus-visible, .lf-focus-visible) { color: var(--ink-2); }
11881191
.lf-quote:is(:focus-visible, .lf-focus-visible) { outline: var(--here-ring); --lf-here-ring: quote;
@@ -1474,7 +1477,7 @@ ${MARK_RULES}
14741477
.lf-margin-thread { min-width: 0; padding-top: 10px; border-top: 1px solid var(--rule); }
14751478
.lf-margin-thread:first-child { padding-top: 0; border-top: 0; }
14761479
.lf-margin-thread .lf-conversation-msg:first-child { margin-top: 0; }
1477-
.lf-margin-thread .lf-say { align-items: flex-end; }
1480+
.lf-margin-thread .lf-say { align-items: stretch; }
14781481
.lf-margin-thread .lf-say textarea { min-width: 0; }
14791482
.lf-page-map-action { width: 100%; min-width: 0;
14801483
display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px;

‎skills/leaf/assets/runtime/composing/selection.js‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function createSelectionComposer(runtime, dependencies) {
2020
loadDraft,
2121
mayLandTyping,
2222
openInlineThread,
23+
panelIsOpen,
2324
paintAnchors,
2425
paintHere,
2526
post,
@@ -127,17 +128,19 @@ export function createSelectionComposer(runtime, dependencies) {
127128
if (inFlight === flight) inFlight = null;
128129
}
129130
if (!sent) return;
130-
// A later edit is still the reader's standing gesture. The earlier comment may
131-
// render in another conversation view, but it may not close or move the composer
132-
// holding that edit.
133-
if (composerEpoch !== flight.epoch || loadDraft(ctx) !== null) return;
134131
let reply = threadsBox.querySelector(`.lf-thread[data-id="${sent.id}"] textarea`);
135-
const shouldLand = mayLandTyping(reply, composerInput);
136-
// Opening an inline view closes the panel and moves focus. Decide from the standing
137-
// view first, so a later gesture in another reply box survives an earlier send.
138-
const inlineReply = shouldLand ? openInlineThread(sent.id) : null;
132+
// A later draft or selection keeps its focus. The accepted comment still belongs
133+
// in an open panel, including when revealing it must widen the panel's filter.
134+
const shouldLand =
135+
composerEpoch === flight.epoch &&
136+
loadDraft(ctx) === null &&
137+
mayLandTyping(reply, composerInput);
138+
// Continue in the surface already in use. Closing an open panel here reflows the
139+
// passage just as the reader's comment moves across it to a new floating card.
140+
const inlineReply =
141+
shouldLand && !panelIsOpen() ? openInlineThread(sent.id) : null;
139142
reply = inlineReply ?? reply;
140-
if (!inlineReply) {
143+
if (!inlineReply && (shouldLand || panelIsOpen())) {
141144
showThread(sent.id, { stand: shouldLand });
142145
reply ??= threadsBox.querySelector(`.lf-thread[data-id="${sent.id}"] textarea`);
143146
}

‎skills/leaf/assets/runtime/conversation/folding.js‎

Lines changed: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,77 @@
1+
import { outbox } from "../outbox.js";
2+
import { measure, reserve } from "../widget-elements.js";
3+
4+
/* Settlement controls share the outbox across panel and inline views. */
5+
export function createThreadSettlement({ keys, offer, paintKeys, post, PRESS }) {
6+
const news = "lf-thread-settlement";
7+
const pendingSettlement = (id) =>
8+
outbox.find(
9+
({ event }) =>
10+
event.parent === id && (event.kind === "resolve" || event.kind === "unresolve"),
11+
);
12+
const busy = (id) => Boolean(pendingSettlement(id));
13+
const tell = (id) =>
14+
document.dispatchEvent(new CustomEvent(news, { detail: { id } }));
15+
16+
function settlementControl(t, { prepareLanding } = {}) {
17+
const id = t.root.id;
18+
const reopen = Boolean(t.resolved);
19+
const kind = reopen ? "unresolve" : "resolve";
20+
const word = reopen ? "Reopen" : "Resolve";
21+
const pendingWord = reopen ? "Reopening…" : "Resolving…";
22+
const button = offer(
23+
"button",
24+
reopen ? "lf-btn lf-reopen lf-thread-action" : "lf-btn lf-resolve",
25+
word,
26+
);
27+
const sync = () => {
28+
// A fold owns its accepted outcome until it removes the old control.
29+
if (button.closest(".lf-going")) return;
30+
const pending = pendingSettlement(id);
31+
button.setAttribute("aria-disabled", String(Boolean(pending)));
32+
button.setAttribute("aria-busy", String(Boolean(pending)));
33+
button.textContent = pending?.event.kind === kind ? pendingWord : word;
34+
};
35+
const update = (ev) => {
36+
if (!button.isConnected) return document.removeEventListener(news, update);
37+
if (ev.detail.id !== id) return;
38+
sync();
39+
};
40+
document.addEventListener(news, update);
41+
button.onclick = async () => {
42+
if (busy(id)) return;
43+
const land = prepareLanding?.();
44+
const sent = post({ kind, parent: id });
45+
tell(id);
46+
paintKeys();
47+
try {
48+
if (await sent) land?.();
49+
} finally {
50+
tell(id);
51+
paintKeys();
52+
}
53+
};
54+
keys(button, `On a thread's ${word} button`, [
55+
{
56+
id: reopen ? "thread.reopen" : "thread.resolve",
57+
keys: [...PRESS, "x"],
58+
does: `${word} it`,
59+
line: word.toLowerCase(),
60+
when: () => !busy(id),
61+
run: () => button.click(),
62+
},
63+
]);
64+
// Showing one view can release a hidden control's measurement during resize
65+
// delivery. Reserve outside that delivery because its thread also observes size.
66+
const fit = () => reserve(button, [word, pendingWord, "✓ Resolved"]);
67+
measure(button, () => requestAnimationFrame(() => measure(button, fit)));
68+
sync();
69+
return button;
70+
}
71+
72+
return { settlementControl };
73+
}
74+
175
/* Resolution-fold state and motion for comment-panel threads. */
276
export function createThreadFolding({ FOLD_MS, motion, renderPanel, threadsBox }) {
377
// A thread the log has resolved and the open list is still holding. Its place is not
@@ -58,12 +132,13 @@ export function createThreadFolding({ FOLD_MS, motion, renderPanel, threadsBox }
58132
to.opacity = 0;
59133
const played = motion(node, [from, to], FOLD_MS);
60134
if (!played) return null;
61-
// The control the press was made on states the outcome where it stood. It needs no
62-
// reservation for the longer word: Send and Resolve hold the two edges, so the
63-
// longer outcome takes room from the gap and moves neither edge. Send stays in the
64-
// row with visibility hidden, keeping the same room without reading as live.
65-
node.querySelector(":scope > .lf-thread-actions > .lf-resolve").textContent =
66-
"✓ Resolved";
135+
// The pressed control states the outcome in the room it already reserved. Send
136+
// stays in the row with visibility hidden, keeping its room without reading as live.
137+
const resolve = node.querySelector(
138+
":scope > .lf-compose > .lf-thread-actions > .lf-resolve",
139+
);
140+
resolve.textContent = "✓ Resolved";
141+
resolve.setAttribute("aria-busy", "false");
67142
node.className = "lf-going";
68143
if (node.matches(":focus-within")) threadsBox.focus({ preventScroll: true });
69144
node.inert = true;

0 commit comments

Comments
 (0)