Skip to content

Commit 0d7e0d0

Browse files
committed
Open threads beside their source
Reserve a readable right-margin card for anchored threads when the page container has room. Keep the document visible, put the Threads handoff in the card header, and fall back to the global panel at narrower postures. Teach the shared margin layout about authored sidebars and standing trays, and cover the wide, compact, and grouped-thread cases in browser tests.
1 parent 726382c commit 0d7e0d0

9 files changed

Lines changed: 453 additions & 46 deletions

File tree

‎skills/leaf/CLAUDE.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ and tray panels;
4545
`runtime/trays.js` owns the left tray edge, active tray, registration, restore, and
4646
shared tray furniture;
4747
`runtime/live-leaves.js` owns the machine-leaves tray's rows, presence words, and walk;
48-
`runtime/living-margin.js` owns the page map, compact map sheet, inline margin threads,
48+
`runtime/living-margin.js` owns the page map, compact map sheet, anchored margin threads,
4949
and the one aggregated action, communication, and information item for each page target;
5050
content modules contribute live controls and semantics through its registration seam but
5151
never place their own RHS rows;

‎skills/leaf/assets/leaf.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ const el = (tag, cls, text) => {
667667
return node;
668668
};
669669
let chromeLayout;
670+
let livingMargin = null;
670671
const syncLayout = (...args) => chromeLayout.syncLayout(...args);
671672
const setPanel = (...args) => chromeLayout.setPanel(...args);
672673
const drawnEdge = createDrawnEdge({ el, keys, readerStore, syncLayout });
@@ -741,6 +742,7 @@ const {
741742
readerStore,
742743
renderDecisions: () => renderDecisions(openDecisions()),
743744
syncLayout,
745+
trayChanged: () => livingMargin?.render(),
744746
walkRows,
745747
});
746748
const { leavesOffered, othersLinks, renderOthers } = createLiveLeaves({
@@ -1143,6 +1145,9 @@ chromeLayout = createChromeLayout({
11431145
pageShifted: (...args) => pageShifted(...args),
11441146
paintHere,
11451147
panel,
1148+
panelChanged: (open) => {
1149+
if (open) livingMargin?.closePreview();
1150+
},
11461151
panelFocusTarget: threadsBox,
11471152
panelFoot,
11481153
panelList: threadsBox,
@@ -1895,7 +1900,6 @@ const { commentOnItem, glideTo, placeThreadEdge, seenScroller, stepPage, stepThr
18951900
const landInThreadReply = (thread) =>
18961901
landIn({ held: thread, box: thread.querySelector(SAY_BOX) });
18971902

1898-
let livingMargin = null;
18991903
const { GO, GOTO, isChordArmed, paintAddresses, setChord } = createAddress({
19001904
EVERYTHING,
19011905
addressLayer,
@@ -3413,12 +3417,14 @@ livingMargin = createLivingMargin({
34133417
keys,
34143418
offer,
34153419
openDecisions,
3420+
panelIsOpen: chromeLayout.panelIsOpen,
34163421
pageScroller,
34173422
paintKeys,
34183423
placedAt,
34193424
renderMarginThread: conversationRuntime.renderMarginThread,
34203425
scrollBehavior,
34213426
scrollToElement,
3427+
setPanel,
34223428
showThread,
34233429
stateProjection,
34243430
threads: () => conversationRuntime.threadList,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export function createChromeLayout({
5151
pageShifted,
5252
paintHere,
5353
panel,
54+
panelChanged,
5455
panelFocusTarget,
5556
panelFoot,
5657
panelList,
@@ -217,6 +218,7 @@ export function createChromeLayout({
217218
syncGeneral(); // a restored draft has to reach the Send button's disabled state
218219
} else if (panel.open) panel.close();
219220
syncLayout();
221+
panelChanged(open);
220222
readerStore.set(PANEL_KEY, open ? "1" : "0");
221223
paintHere();
222224
// The panel is one of the two surfaces the hover reads, so its arriving or going away

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,9 +1175,23 @@ ${MARK_RULES}
11751175
scroll-padding-block: var(--here-ring-room);
11761176
margin: 0 8px; padding: 12px; border: 1px solid var(--border-2); border-radius: 10px;
11771177
background: var(--paper); color: var(--ink); box-shadow: 0 12px 36px rgba(0,0,0,.18); }
1178+
/* A compact preview follows its marker through native anchor positioning. The full
1179+
conversation instead has its fixed top measured from that marker: the card also
1180+
changes the document's container posture, and asking both layout systems to
1181+
resolve that boundary can leave the browser oscillating between the two. */
1182+
.lf-margin-preview[data-lf-thread] { position-anchor: auto; position-area: none;
1183+
position-try-fallbacks: none;
1184+
inset: var(--lf-thread-top, calc(var(--lf-banner-h) + 8px)) 8px auto auto;
1185+
width: min(var(--thread-card), calc(100vw - 24px));
1186+
max-height: calc(100vh - var(--lf-banner-h) - 16px); margin: 0; }
11781187
.lf-margin-preview-head, .lf-page-map-head { display: flex; align-items: center;
1179-
justify-content: space-between; gap: 12px; }
1180-
.lf-margin-preview-title { font-size: var(--t-5); line-height: 1.35; }
1188+
gap: 8px; }
1189+
.lf-margin-thread-action { flex: none; margin: 0; padding: 2px 7px;
1190+
border-color: var(--rule); background: transparent; color: var(--muted);
1191+
font-size: var(--t-6); }
1192+
.lf-margin-thread-action[hidden] { display: none; }
1193+
.lf-margin-preview-title { flex: 1; min-width: 0; font-size: var(--t-5);
1194+
line-height: 1.35; }
11811195
.lf-margin-preview-close { flex: none; min-width: 30px; padding-inline: 7px; }
11821196
.lf-margin-preview-kinds { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
11831197
.lf-margin-kind { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px;
@@ -1189,8 +1203,6 @@ ${MARK_RULES}
11891203
.lf-margin-thread .lf-conversation-msg:first-child { margin-top: 0; }
11901204
.lf-margin-thread .lf-say { align-items: flex-end; }
11911205
.lf-margin-thread .lf-say textarea { min-width: 0; }
1192-
.lf-margin-thread-open { display: block; margin: 8px 0 0 auto; color: var(--muted);
1193-
font-size: var(--t-6); }
11941206
.lf-margin-preview-action, .lf-page-map-action { width: 100%; min-width: 0;
11951207
display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px;
11961208
align-items: baseline; border: 0; border-radius: var(--r); background: transparent;

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function createInlineConversations({
1515
turns,
1616
wireReply,
1717
}) {
18-
function conversationMessageNode(thread, message) {
18+
function conversationMessageNode(thread, message, { openInThreads = true } = {}) {
1919
let node = thread.querySelector(
2020
`:scope > .lf-conversation-msg[data-event="${message.id}"]`,
2121
);
@@ -46,15 +46,19 @@ export function createInlineConversations({
4646
else body.innerHTML = renderMessageMarkdown(message.text);
4747
node.lfRevision = message.edited?.id ?? "";
4848
node.append(head, body);
49-
if (message.markup) {
50-
const open = offer("button", "lf-btn lf-conversation-open", "Open in Threads");
49+
if (message.markup && openInThreads) {
50+
const open = offer(
51+
"button",
52+
"lf-btn lf-conversation-open",
53+
"Open interactive reply in Threads",
54+
);
5155
open.onclick = () => showThread(message.id);
5256
node.append(open);
5357
}
5458
return node;
5559
}
5660

57-
function conversationThreadNode(host, t) {
61+
function conversationThreadNode(host, t, { openInThreads = true } = {}) {
5862
let thread = host.querySelector(
5963
`:scope > .lf-conversation-thread[data-thread="${t.root.id}"]`,
6064
);
@@ -66,7 +70,7 @@ export function createInlineConversations({
6670
// Turns only: a reaction on a message is the panel's strip to show, and the seat is
6771
// the textual projection of the exchange.
6872
const messages = turns(t).map((message) =>
69-
conversationMessageNode(thread, message),
73+
conversationMessageNode(thread, message, { openInThreads }),
7074
);
7175
let tail;
7276
if (t.resolved) {
@@ -127,7 +131,7 @@ export function createInlineConversations({
127131
}
128132

129133
function renderMarginThread(host, thread) {
130-
const node = conversationThreadNode(host, thread);
134+
const node = conversationThreadNode(host, thread, { openInThreads: false });
131135
setChildren(host, [node]);
132136
return node;
133137
}

0 commit comments

Comments
 (0)