@vibefield/rosetta-room 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -2
- package/dist/components/Transcript.js +6 -2
- package/dist/components/file-viewer/kinds.d.ts +22 -0
- package/dist/components/file-viewer/kinds.js +57 -0
- package/dist/components/file-viewer/markdown/render.d.ts +7 -1
- package/dist/components/file-viewer/markdown/render.js +16 -12
- package/dist/components/file-viewer/registry.d.ts +2 -2
- package/dist/components/file-viewer/registry.js +20 -59
- package/dist/components/transcript/Activity.d.ts +10 -4
- package/dist/components/transcript/Activity.js +36 -11
- package/dist/components/transcript/Compaction.d.ts +9 -0
- package/dist/components/transcript/Compaction.js +8 -4
- package/dist/components/transcript/Document.js +150 -208
- package/dist/components/transcript/PromptJump.js +28 -8
- package/dist/components/transcript/Prose.d.ts +5 -1
- package/dist/components/transcript/Prose.js +3 -3
- package/dist/components/transcript/ReadingBlocks.d.ts +71 -0
- package/dist/components/transcript/ReadingBlocks.js +279 -0
- package/dist/components/transcript/activity-plan.d.ts +38 -7
- package/dist/components/transcript/activity-plan.js +198 -28
- package/dist/components/transcript/attachment-file-source.d.ts +1 -2
- package/dist/components/transcript/attachment-file-source.js +7 -5
- package/dist/components/transcript/disclosure-state.d.ts +2 -0
- package/dist/components/transcript/disclosure-state.js +6 -2
- package/dist/components/transcript/document-model.js +53 -9
- package/dist/components/transcript/document-plan.js +263 -98
- package/dist/components/transcript/reading-identity.d.ts +14 -1
- package/dist/components/transcript/reading-identity.js +126 -10
- package/dist/conversation/ConversationGallery.d.ts +11 -0
- package/dist/conversation/ConversationGallery.js +14 -0
- package/dist/conversation/ConversationMedia.d.ts +44 -0
- package/dist/conversation/ConversationMedia.js +210 -0
- package/dist/conversation/ConversationProse.d.ts +13 -0
- package/dist/conversation/ConversationProse.js +6 -0
- package/dist/conversation/ConversationRunRows.d.ts +57 -0
- package/dist/conversation/ConversationRunRows.js +84 -0
- package/dist/conversation/ConversationTurnView.d.ts +64 -0
- package/dist/conversation/ConversationTurnView.js +169 -0
- package/dist/conversation/ConversationView.d.ts +3 -0
- package/dist/conversation/ConversationView.js +257 -0
- package/dist/conversation/feed-reads.d.ts +36 -0
- package/dist/conversation/feed-reads.js +155 -0
- package/dist/conversation/feed.d.ts +106 -0
- package/dist/conversation/feed.js +884 -0
- package/dist/conversation/index.d.ts +11 -0
- package/dist/conversation/index.js +25 -0
- package/dist/conversation/model.d.ts +108 -0
- package/dist/conversation/model.js +257 -0
- package/dist/conversation/ports.d.ts +194 -0
- package/dist/conversation/ports.js +9 -0
- package/dist/conversation/rosetta-client.d.ts +8 -0
- package/dist/conversation/rosetta-client.js +1 -0
- package/dist/conversation/use-conversation-feed.d.ts +16 -0
- package/dist/conversation/use-conversation-feed.js +41 -0
- package/dist/conversation/use-conversation-window.d.ts +50 -0
- package/dist/conversation/use-conversation-window.js +336 -0
- package/dist/conversation/words.d.ts +51 -0
- package/dist/conversation/words.js +79 -0
- package/dist/fixtures/conversation.d.ts +34 -0
- package/dist/fixtures/conversation.js +723 -0
- package/dist/fixtures/index.d.ts +2 -0
- package/dist/fixtures/index.js +1 -0
- package/dist/lib/session-leases.d.ts +11 -8
- package/dist/lib/transcript/collaboration.js +53 -19
- package/dist/lib/transcript/head-of-document.js +9 -3
- package/dist/lib/transcript/index.d.ts +1 -1
- package/dist/lib/transcript/index.js +1 -1
- package/dist/lib/transcript/prompt-jump.d.ts +2 -0
- package/dist/lib/transcript/prompt-jump.js +5 -1
- package/dist/lib/transcript/sittings.d.ts +2 -1
- package/dist/lib/transcript/sittings.js +72 -10
- package/dist/lib/transcript/tail-state.d.ts +9 -0
- package/dist/lib/transcript/tail-state.js +25 -1
- package/dist/lib/transcript/turns.d.ts +5 -0
- package/dist/lib/transcript/turns.js +221 -57
- package/dist/lib/transcript/use-transcript-tail.js +17 -3
- package/dist/lib/transcript/vocabulary.d.ts +2 -1
- package/dist/lib/transcript/vocabulary.js +11 -1
- package/dist/parts-context.d.ts +25 -0
- package/dist/parts-context.js +32 -0
- package/dist/ports.d.ts +3 -0
- package/dist/room-context.d.ts +1 -7
- package/dist/room-context.js +12 -18
- package/dist/styles/conversation-turn.css +147 -0
- package/dist/styles/conversation.css +45 -0
- package/dist/styles/transcript.css +11 -2
- package/package.json +9 -4
|
@@ -230,8 +230,21 @@ function thinkingSegment(row, nextAtOf) {
|
|
|
230
230
|
spanMs: row.at !== null && next !== null && next > row.at ? next - row.at : null,
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
|
+
/** A row the fold draws nothing for: a turn's end whose outcome is finished.
|
|
234
|
+
* Whoever anchors a line or a count on a row asks this first (`activityCuts`,
|
|
235
|
+
* the tail's arrivals, the sittings), so no line or count is anchored on a
|
|
236
|
+
* finished end. */
|
|
237
|
+
export function drawsNoMarker(row) {
|
|
238
|
+
return row.body.type === "notice" && row.body.notice.type === "turn_ended" &&
|
|
239
|
+
row.body.notice.outcome === "finished";
|
|
240
|
+
}
|
|
241
|
+
/** A notice row's hairline marker. A turn that finished draws none: its reply is
|
|
242
|
+
* there, so the end says nothing more. The fold skips a null segment before it
|
|
243
|
+
* cuts a run, so such a row adds nothing to a run and counts nothing; a cut its
|
|
244
|
+
* caller places on the row (`cutBefore`) still closes the run there. A failed
|
|
245
|
+
* end, a stopped end and an outcome this reader does not know are drawn as ever. */
|
|
233
246
|
function markerSegment(row) {
|
|
234
|
-
if (row.body.type !== "notice")
|
|
247
|
+
if (row.body.type !== "notice" || drawsNoMarker(row))
|
|
235
248
|
return null;
|
|
236
249
|
const notice = row.body.notice;
|
|
237
250
|
return {
|
|
@@ -242,6 +255,7 @@ function markerSegment(row) {
|
|
|
242
255
|
notice,
|
|
243
256
|
text: noticeText(notice),
|
|
244
257
|
tone: notice.type === "runtime_error" ||
|
|
258
|
+
(notice.type === "turn_ended" && notice.outcome === "failed") ||
|
|
245
259
|
(notice.type === "async_task" && ["failed", "denied", "timed_out"].includes(notice.status))
|
|
246
260
|
? "failed"
|
|
247
261
|
: "plain",
|
|
@@ -462,38 +476,68 @@ function buildSegments(rows, nextAtOf, context, cutBefore) {
|
|
|
462
476
|
*/
|
|
463
477
|
export function documentTurns(rows, options = {}) {
|
|
464
478
|
const context = options.context ?? {};
|
|
465
|
-
|
|
479
|
+
const cutBefore = options.cutBefore ?? NO_CUTS;
|
|
480
|
+
// Rows that extend the last ones folded resume the fold at the last turn
|
|
481
|
+
// they began (2026-11-29, the reader's arrival cost): the turns before it are
|
|
482
|
+
// handed back as they were, so one arriving row reads the turn it joins and
|
|
483
|
+
// not every row of the document. `resumable` says when that is exact.
|
|
484
|
+
const head = rows[0];
|
|
485
|
+
const folds = head === undefined ? undefined : turnFolds.get(head);
|
|
486
|
+
const held = folds?.find((fold) => resumable(fold, rows, options, cutBefore));
|
|
487
|
+
const from = held?.lastStart ?? 0;
|
|
488
|
+
const firstIndex = held?.firstIndex ?? new Map();
|
|
489
|
+
let lastStamped = held?.lastStamped ?? -1;
|
|
490
|
+
for (let index = held?.rows.length ?? 0; index < rows.length; index += 1) {
|
|
491
|
+
const row = rows[index];
|
|
492
|
+
if (!firstIndex.has(row.timeline_id))
|
|
493
|
+
firstIndex.set(row.timeline_id, index);
|
|
494
|
+
if (row.at !== null)
|
|
495
|
+
lastStamped = index;
|
|
496
|
+
}
|
|
497
|
+
// The next stamped row, for a reasoning segment's span: only a reasoning
|
|
498
|
+
// segment reads it, so only the ids of reasoning rows are kept, each from
|
|
499
|
+
// the last row that carries the id (2026-11-29, the reader's arrival cost).
|
|
500
|
+
// A resumed fold reads the rows it folds again: no row before them carries
|
|
501
|
+
// one of their ids, and each row before them has a stamped row after it.
|
|
466
502
|
const nextAt = new Map();
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
503
|
+
const thinkingIds = new Set();
|
|
504
|
+
for (let index = from; index < rows.length; index += 1) {
|
|
505
|
+
const row = rows[index];
|
|
506
|
+
if (row.body.type === "thinking")
|
|
507
|
+
thinkingIds.add(row.timeline_id);
|
|
508
|
+
}
|
|
509
|
+
if (thinkingIds.size > 0) {
|
|
510
|
+
let following = null;
|
|
511
|
+
for (let index = rows.length - 1; index >= from; index -= 1) {
|
|
512
|
+
const row = rows[index];
|
|
513
|
+
if (thinkingIds.has(row.timeline_id) && !nextAt.has(row.timeline_id))
|
|
514
|
+
nextAt.set(row.timeline_id, following);
|
|
515
|
+
if (row.at !== null)
|
|
516
|
+
following = row.at;
|
|
476
517
|
}
|
|
477
|
-
nextAt.set(rowAt(index).timeline_id, found);
|
|
478
518
|
}
|
|
479
519
|
const nextAtOf = (row) => nextAt.get(row.timeline_id) ?? null;
|
|
480
520
|
// Group the rows into turns, absorbing a command prompt's `command_output`
|
|
481
521
|
// notice as we go — the pair is one object, decided by adjacency and nothing
|
|
482
522
|
// else, so the notice never also draws as a marker.
|
|
483
|
-
const groups = [];
|
|
484
|
-
|
|
523
|
+
const groups = held === undefined ? [] : held.groups.slice(0, -1);
|
|
524
|
+
let lastStart = held === undefined ? 0 : from;
|
|
525
|
+
for (let index = from; index < rows.length; index += 1) {
|
|
526
|
+
const row = rows[index];
|
|
485
527
|
if (opensTurn(row, options)) {
|
|
486
528
|
groups.push({ prompt: row, output: null, body: [] });
|
|
529
|
+
lastStart = index;
|
|
487
530
|
continue;
|
|
488
531
|
}
|
|
489
532
|
const current = groups.at(-1);
|
|
490
533
|
if (current === undefined) {
|
|
491
534
|
groups.push({ prompt: null, output: null, body: [row] });
|
|
535
|
+
lastStart = index;
|
|
492
536
|
continue;
|
|
493
537
|
}
|
|
494
538
|
const promptRow = current.prompt;
|
|
495
539
|
if (promptRow !== null &&
|
|
496
|
-
!
|
|
540
|
+
!cutBefore.has(row.timeline_id) &&
|
|
497
541
|
current.output === null &&
|
|
498
542
|
current.body.length === 0 &&
|
|
499
543
|
row.body.type === "notice" &&
|
|
@@ -506,57 +550,177 @@ export function documentTurns(rows, options = {}) {
|
|
|
506
550
|
}
|
|
507
551
|
current.body.push(row);
|
|
508
552
|
}
|
|
509
|
-
const turns = [];
|
|
510
|
-
let
|
|
511
|
-
let
|
|
512
|
-
let
|
|
513
|
-
|
|
514
|
-
const
|
|
515
|
-
const
|
|
516
|
-
const body = group.body;
|
|
517
|
-
const prompt = promptRow === null ? null : buildPrompt(promptRow, outputRow);
|
|
518
|
-
const segments = buildSegments(body, nextAtOf, context, options.cutBefore ?? new Set());
|
|
519
|
-
const agentRows = body.filter(isAgentAuthored);
|
|
520
|
-
const head = agentRows.length === 0
|
|
521
|
-
? null
|
|
522
|
-
: {
|
|
523
|
-
model: agentRows.find((row) => row.model !== null)?.model ?? null,
|
|
524
|
-
effort: agentRows.find((row) => row.effort !== null)?.effort ?? null,
|
|
525
|
-
tokens: reportedTokens(agentRows),
|
|
526
|
-
cost: reportedCost(agentRows),
|
|
527
|
-
startedAt: firstStamp(body),
|
|
528
|
-
endedAt: lastStamp(body),
|
|
529
|
-
spanMs: stampSpan(body),
|
|
530
|
-
};
|
|
531
|
-
const headIndex = Math.max(0, segments.findIndex((segment) => segment.kind !== "marker" && segment.kind !== "compaction"));
|
|
532
|
-
const at = promptRow?.at ?? firstStamp(body);
|
|
553
|
+
const turns = held === undefined ? [] : held.turns.slice(0, -1);
|
|
554
|
+
let state = held === undefined ? FIRST_CLUSTER_STATE : held.beforeLast;
|
|
555
|
+
let beforeLast = state;
|
|
556
|
+
for (let at = turns.length; at < groups.length; at += 1) {
|
|
557
|
+
beforeLast = state;
|
|
558
|
+
const built = builtTurn(groups[at], nextAtOf, context, cutBefore, turns.length);
|
|
559
|
+
const prompt = built.turn.prompt;
|
|
533
560
|
const clusteredWithPrevious = prompt !== null &&
|
|
534
561
|
prompt.setting !== null &&
|
|
535
562
|
!prompt.fromParent &&
|
|
536
|
-
previousWasHumanSetting &&
|
|
537
|
-
!previousHadReply &&
|
|
538
|
-
withinPromptCluster(previousPromptAt, prompt.at);
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
563
|
+
state.previousWasHumanSetting &&
|
|
564
|
+
!state.previousHadReply &&
|
|
565
|
+
withinPromptCluster(state.previousPromptAt, prompt.at);
|
|
566
|
+
if (clusteredWithPrevious)
|
|
567
|
+
built.clustered ??= { ...built.turn, clusteredWithPrevious: true };
|
|
568
|
+
turns.push(clusteredWithPrevious ? built.clustered : built.turn);
|
|
569
|
+
if (prompt !== null) {
|
|
570
|
+
state = {
|
|
571
|
+
previousPromptAt: prompt.at,
|
|
572
|
+
previousHadReply: built.replied,
|
|
573
|
+
previousWasHumanSetting: prompt.setting !== null && !prompt.fromParent,
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
if (head !== undefined) {
|
|
578
|
+
const fold = {
|
|
579
|
+
rows: rows.slice(),
|
|
580
|
+
cwd: context.cwd ?? null,
|
|
581
|
+
home: context.home ?? null,
|
|
582
|
+
shared: options.sharedCollaborationSessionIds === undefined ? null : [...options.sharedCollaborationSessionIds],
|
|
583
|
+
cuts: [...cutBefore],
|
|
584
|
+
firstIndex,
|
|
585
|
+
lastStamped,
|
|
586
|
+
lastStart,
|
|
587
|
+
groups,
|
|
588
|
+
turns: turns.slice(),
|
|
589
|
+
beforeLast,
|
|
590
|
+
};
|
|
591
|
+
// Two folds per conversation: its column and its document may fold two
|
|
592
|
+
// chronologies that begin with the same row, one after the other.
|
|
593
|
+
const others = (folds ?? []).filter((fold) => fold !== held).slice(0, 1);
|
|
594
|
+
turnFolds.set(head, [fold, ...others]);
|
|
595
|
+
}
|
|
596
|
+
return turns;
|
|
597
|
+
}
|
|
598
|
+
const NO_CUTS = new Set();
|
|
599
|
+
const FIRST_CLUSTER_STATE = {
|
|
600
|
+
previousPromptAt: null,
|
|
601
|
+
previousHadReply: true,
|
|
602
|
+
previousWasHumanSetting: false,
|
|
603
|
+
};
|
|
604
|
+
/** The last folds of each conversation, by its first row (2026-11-29, the reader's arrival cost). */
|
|
605
|
+
const turnFolds = new WeakMap();
|
|
606
|
+
/**
|
|
607
|
+
* Whether `rows` resume `fold` at its last turn and fold into what a fold of
|
|
608
|
+
* every row makes. The rows begin with every row it read, as the same objects;
|
|
609
|
+
* the options are the same, but for cuts placed on the rows it folds again;
|
|
610
|
+
* no row from its last turn on carries the id of a row before that turn; and a
|
|
611
|
+
* row before that turn has a stamped row after it, so no reasoning span before
|
|
612
|
+
* the last turn moves.
|
|
613
|
+
*/
|
|
614
|
+
function resumable(fold, rows, options, cutBefore) {
|
|
615
|
+
const read = fold.rows;
|
|
616
|
+
if (fold.lastStart === 0 || read.length > rows.length || fold.lastStamped < fold.lastStart)
|
|
617
|
+
return false;
|
|
618
|
+
if ((options.context?.cwd ?? null) !== fold.cwd || (options.context?.home ?? null) !== fold.home)
|
|
619
|
+
return false;
|
|
620
|
+
const shared = options.sharedCollaborationSessionIds;
|
|
621
|
+
if (shared === undefined ? fold.shared !== null
|
|
622
|
+
: fold.shared === null || fold.shared.length !== shared.size || !fold.shared.every((id) => shared.has(id))) {
|
|
623
|
+
return false;
|
|
624
|
+
}
|
|
625
|
+
for (let index = read.length - 1; index >= 0; index -= 1)
|
|
626
|
+
if (read[index] !== rows[index])
|
|
627
|
+
return false;
|
|
628
|
+
const before = (id) => {
|
|
629
|
+
const first = fold.firstIndex.get(id);
|
|
630
|
+
return first !== undefined && first < fold.lastStart;
|
|
631
|
+
};
|
|
632
|
+
for (let index = fold.lastStart; index < read.length; index += 1) {
|
|
633
|
+
if (fold.firstIndex.get(read[index].timeline_id) !== index)
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
for (let index = read.length; index < rows.length; index += 1) {
|
|
637
|
+
if (fold.firstIndex.has(rows[index].timeline_id))
|
|
638
|
+
return false;
|
|
639
|
+
}
|
|
640
|
+
const was = new Set(fold.cuts);
|
|
641
|
+
for (const id of cutBefore)
|
|
642
|
+
if (!was.delete(id) && before(id))
|
|
643
|
+
return false;
|
|
644
|
+
for (const id of was)
|
|
645
|
+
if (before(id))
|
|
646
|
+
return false;
|
|
647
|
+
return true;
|
|
648
|
+
}
|
|
649
|
+
/** Turns kept by their first row (2026-11-29, the reader's arrival cost). A turn
|
|
650
|
+
* is a function of its own rows, the next stamp after each, the cuts among them
|
|
651
|
+
* and the paths' context; rows are replaced, never changed in place, so a turn
|
|
652
|
+
* whose inputs are all the same is handed back as the same object. One arriving
|
|
653
|
+
* row then derives the turn it joins, not the document, and every block drawn
|
|
654
|
+
* from an unchanged turn keeps its identity. */
|
|
655
|
+
const builtTurns = new WeakMap();
|
|
656
|
+
function builtTurn(group, nextAtOf, context, cutBefore, index) {
|
|
657
|
+
const { prompt: promptRow, output: outputRow, body } = group;
|
|
658
|
+
const first = promptRow ?? body[0];
|
|
659
|
+
const cwd = context.cwd ?? null;
|
|
660
|
+
const home = context.home ?? null;
|
|
661
|
+
const key = promptRow?.timeline_id ?? body[0]?.timeline_id ?? `turn-${index}`;
|
|
662
|
+
const held = first === undefined ? undefined : builtTurns.get(first);
|
|
663
|
+
if (held !== undefined && held.output === outputRow && held.key === key && held.cwd === cwd && held.home === home &&
|
|
664
|
+
sameInputs(held, body, nextAtOf, cutBefore)) {
|
|
665
|
+
return held;
|
|
666
|
+
}
|
|
667
|
+
const nextAts = body.map((row) => (row.body.type === "thinking" ? nextAtOf(row) : null));
|
|
668
|
+
const cuts = body.map((row) => cutBefore.has(row.timeline_id));
|
|
669
|
+
const prompt = promptRow === null ? null : buildPrompt(promptRow, outputRow);
|
|
670
|
+
const segments = buildSegments(body, nextAtOf, context, cutBefore);
|
|
671
|
+
const agentRows = body.filter(isAgentAuthored);
|
|
672
|
+
const head = agentRows.length === 0
|
|
673
|
+
? null
|
|
674
|
+
: {
|
|
675
|
+
model: agentRows.find((row) => row.model !== null)?.model ?? null,
|
|
676
|
+
effort: agentRows.find((row) => row.effort !== null)?.effort ?? null,
|
|
677
|
+
tokens: reportedTokens(agentRows),
|
|
678
|
+
cost: reportedCost(agentRows),
|
|
679
|
+
startedAt: firstStamp(body),
|
|
680
|
+
endedAt: lastStamp(body),
|
|
681
|
+
spanMs: stampSpan(body),
|
|
682
|
+
};
|
|
683
|
+
const headIndex = Math.max(0, segments.findIndex((segment) => segment.kind !== "marker" && segment.kind !== "compaction"));
|
|
684
|
+
const allRows = [
|
|
685
|
+
...(prompt === null ? [] : prompt.rows),
|
|
686
|
+
...body,
|
|
687
|
+
];
|
|
688
|
+
const built = {
|
|
689
|
+
output: outputRow,
|
|
690
|
+
body: [...body],
|
|
691
|
+
nextAts,
|
|
692
|
+
cuts,
|
|
693
|
+
cwd,
|
|
694
|
+
home,
|
|
695
|
+
key,
|
|
696
|
+
replied: agentRows.length > 0,
|
|
697
|
+
clustered: null,
|
|
698
|
+
turn: {
|
|
699
|
+
key: prompt?.key ?? allRows[0]?.timeline_id ?? `turn-${index}`,
|
|
545
700
|
prompt,
|
|
546
701
|
head,
|
|
547
702
|
segments,
|
|
548
703
|
headIndex,
|
|
549
704
|
rows: allRows,
|
|
550
|
-
at,
|
|
551
|
-
clusteredWithPrevious,
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
705
|
+
at: promptRow?.at ?? firstStamp(body),
|
|
706
|
+
clusteredWithPrevious: false,
|
|
707
|
+
},
|
|
708
|
+
};
|
|
709
|
+
if (first !== undefined)
|
|
710
|
+
builtTurns.set(first, built);
|
|
711
|
+
return built;
|
|
712
|
+
}
|
|
713
|
+
/** The same body rows, each with the same next stamp and the same cut before it. */
|
|
714
|
+
function sameInputs(held, body, nextAtOf, cutBefore) {
|
|
715
|
+
if (held.body.length !== body.length)
|
|
716
|
+
return false;
|
|
717
|
+
for (let index = 0; index < body.length; index += 1) {
|
|
718
|
+
const row = body[index];
|
|
719
|
+
if (held.body[index] !== row || held.cuts[index] !== cutBefore.has(row.timeline_id) ||
|
|
720
|
+
(row.body.type === "thinking" && !Object.is(held.nextAts[index], nextAtOf(row))))
|
|
721
|
+
return false;
|
|
558
722
|
}
|
|
559
|
-
return
|
|
723
|
+
return true;
|
|
560
724
|
}
|
|
561
725
|
function firstStamp(rows) {
|
|
562
726
|
for (const row of rows)
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { useCallback, useLayoutEffect, useRef, useState } from "react";
|
|
2
2
|
import { REDUCED_MOTION_QUERY, SETTLE_EASING } from "../motion.js";
|
|
3
|
-
import { TailArrivals } from "./tail-state.js";
|
|
3
|
+
import { TailArrivals, countedArrivals } from "./tail-state.js";
|
|
4
4
|
import { TailScroll } from "./tail-scroll.js";
|
|
5
5
|
const EMPTY = { away: false, unseen: 0 };
|
|
6
|
+
/** Whether a row with this id is drawn, read from the foot, where a row that just arrived is. */
|
|
7
|
+
function drawnFromEnd(rows, id) {
|
|
8
|
+
for (let index = rows.length - 1; index >= 0; index -= 1)
|
|
9
|
+
if (rows[index].timeline_id === id)
|
|
10
|
+
return true;
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
6
13
|
export function useTranscriptTail(scrollerRef, sessionId, enabled, seeking, opening = false) {
|
|
7
14
|
const [state, setState] = useState(EMPTY);
|
|
8
15
|
const controller = useRef(null);
|
|
@@ -41,8 +48,15 @@ export function useTranscriptTail(scrollerRef, sessionId, enabled, seeking, open
|
|
|
41
48
|
scroll.update(false, 0);
|
|
42
49
|
return;
|
|
43
50
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
51
|
+
const arrived = arrivals.update(next.observedRows ?? next.rows);
|
|
52
|
+
// Only the arrived rows are looked up, so a set of every drawn row is made
|
|
53
|
+
// only when many arrive at once (2026-11-29, the reader's arrival cost).
|
|
54
|
+
const displayed = arrived.length === 0
|
|
55
|
+
? new Set()
|
|
56
|
+
: arrived.length > 8
|
|
57
|
+
? new Set(next.rows.map(row => row.timeline_id))
|
|
58
|
+
: new Set(arrived.filter(row => drawnFromEnd(next.rows, row.timeline_id)).map(row => row.timeline_id));
|
|
59
|
+
const fresh = countedArrivals(arrived, displayed);
|
|
46
60
|
for (const id of next.readySessionIds)
|
|
47
61
|
arrivals.prime(id);
|
|
48
62
|
scroll.update(true, fresh.length, openingRef.current);
|
|
@@ -97,7 +97,8 @@ export declare function attachmentLabel(attachment: AttachmentRef): string;
|
|
|
97
97
|
export declare function citationLabel(citation: CitationRef): string;
|
|
98
98
|
/**
|
|
99
99
|
* Every `Notice` is a hairline marker, never a filled alarm (§03 G). This is
|
|
100
|
-
* its one line of text; a `runtime_error`
|
|
100
|
+
* its one line of text; a `runtime_error` or a failed turn's end earns red
|
|
101
|
+
* text and nothing more.
|
|
101
102
|
*/
|
|
102
103
|
export declare function noticeText(notice: Notice): string;
|
|
103
104
|
/**
|
|
@@ -206,7 +206,8 @@ export function citationLabel(citation) {
|
|
|
206
206
|
}
|
|
207
207
|
/**
|
|
208
208
|
* Every `Notice` is a hairline marker, never a filled alarm (§03 G). This is
|
|
209
|
-
* its one line of text; a `runtime_error`
|
|
209
|
+
* its one line of text; a `runtime_error` or a failed turn's end earns red
|
|
210
|
+
* text and nothing more.
|
|
210
211
|
*/
|
|
211
212
|
export function noticeText(notice) {
|
|
212
213
|
switch (notice.type) {
|
|
@@ -239,6 +240,15 @@ export function noticeText(notice) {
|
|
|
239
240
|
}
|
|
240
241
|
case "runtime_error":
|
|
241
242
|
return `runtime error · ${notice.kind.replaceAll("_", " ")} · ${notice.summary}`;
|
|
243
|
+
case "turn_ended":
|
|
244
|
+
if (notice.outcome === "failed") {
|
|
245
|
+
return notice.reason ? `turn failed · ${notice.reason}` : "turn failed";
|
|
246
|
+
}
|
|
247
|
+
if (notice.outcome === "stopped")
|
|
248
|
+
return "stopped";
|
|
249
|
+
// An outcome a newer writer names and this reader does not know: say only
|
|
250
|
+
// that the turn ended, never that it finished.
|
|
251
|
+
return notice.outcome === "finished" ? "turn finished" : "turn ended";
|
|
242
252
|
}
|
|
243
253
|
}
|
|
244
254
|
/* ── spans ───────────────────────────────────────────────────────────────── */
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AssetSource, HostPort, SessionClient } from "./ports.js";
|
|
2
|
+
import type { SessionLeases } from "./lib/session-leases.js";
|
|
3
|
+
import type { RoomStorage } from "./lib/room-storage.js";
|
|
4
|
+
/** The reads a part makes through a session: a stored member's bytes or text. */
|
|
5
|
+
export type PartsClient = Pick<SessionClient, "readAsset" | "readTextAsset">;
|
|
6
|
+
/** What a part asks of a desktop: its copy door and its home directory. */
|
|
7
|
+
export type PartsHost = Pick<HostPort, "copyText" | "homeDir">;
|
|
8
|
+
export interface PartsContext {
|
|
9
|
+
readonly assets: AssetSource;
|
|
10
|
+
/** One lease per session. Under the room, the room's own leases. */
|
|
11
|
+
readonly sessions: SessionLeases<PartsClient>;
|
|
12
|
+
/** Absent: a browser tab, which copies through the page's own clipboard. */
|
|
13
|
+
readonly host: PartsHost | null;
|
|
14
|
+
/** The host's store under the host's prefix. */
|
|
15
|
+
readonly storage: RoomStorage;
|
|
16
|
+
}
|
|
17
|
+
export declare const PartsContext: import("react").Context<PartsContext | null>;
|
|
18
|
+
export declare function useParts(): PartsContext;
|
|
19
|
+
/** The one way a part puts words on the system clipboard: the host's copy
|
|
20
|
+
* door when it has one, else the page's own clipboard. It rejects when either
|
|
21
|
+
* refuses, and the part that asked says so in its receipt. A part mounted
|
|
22
|
+
* outside any provider (a harness) writes the page's clipboard. */
|
|
23
|
+
export declare function useCopyText(): (text: string) => Promise<void>;
|
|
24
|
+
export declare const ReadingSessionProvider: import("react").Provider<string | null>;
|
|
25
|
+
export declare function useReadingSession(): string | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// What the transcript's shared parts read: the host's asset addresses, the
|
|
2
|
+
// stored members a session's client reads, the host's copy door and home, the
|
|
3
|
+
// host's store, and the session whose words are being read.
|
|
4
|
+
//
|
|
5
|
+
// The room provides it from its own ports (`RoomProvider`), so History draws
|
|
6
|
+
// the parts as it always has. A lighter view with no room around it provides
|
|
7
|
+
// it alone. A part that reads only this never needs the room above it, and
|
|
8
|
+
// never imports the room's own context.
|
|
9
|
+
import { createContext, useCallback, useContext } from "react";
|
|
10
|
+
export const PartsContext = createContext(null);
|
|
11
|
+
export function useParts() {
|
|
12
|
+
const parts = useContext(PartsContext);
|
|
13
|
+
if (parts === null) {
|
|
14
|
+
throw new Error("The transcript's parts read their ports from <PartsContext>, which <HistoryRoom> and <RoomProvider> provide.");
|
|
15
|
+
}
|
|
16
|
+
return parts;
|
|
17
|
+
}
|
|
18
|
+
/** The one way a part puts words on the system clipboard: the host's copy
|
|
19
|
+
* door when it has one, else the page's own clipboard. It rejects when either
|
|
20
|
+
* refuses, and the part that asked says so in its receipt. A part mounted
|
|
21
|
+
* outside any provider (a harness) writes the page's clipboard. */
|
|
22
|
+
export function useCopyText() {
|
|
23
|
+
const host = useContext(PartsContext)?.host ?? null;
|
|
24
|
+
return useCallback((text) => host?.copyText !== undefined ? host.copyText(text) : navigator.clipboard.writeText(text), [host]);
|
|
25
|
+
}
|
|
26
|
+
/** The session whose document is being read here. Reads that name no session
|
|
27
|
+
* of their own — a stored text member, an attachment's bytes — ride its client. */
|
|
28
|
+
const ReadingSessionContext = createContext(null);
|
|
29
|
+
export const ReadingSessionProvider = ReadingSessionContext.Provider;
|
|
30
|
+
export function useReadingSession() {
|
|
31
|
+
return useContext(ReadingSessionContext);
|
|
32
|
+
}
|
package/dist/ports.d.ts
CHANGED
|
@@ -280,6 +280,9 @@ export interface AssetSource {
|
|
|
280
280
|
* `attachmentAssetUrl` stays the member's identity and is never loaded.
|
|
281
281
|
*/
|
|
282
282
|
mediaAssetUrl?(asset: AssetRef): AssetUrl;
|
|
283
|
+
/** True: `mediaAssetUrl` honours byte ranges and may be asked BEFORE play, to draw a video's first frame from a
|
|
284
|
+
* `<video preload="metadata">`. Absent or false: asked only on play, as today. */
|
|
285
|
+
readonly mediaFirstFrame?: boolean;
|
|
283
286
|
}
|
|
284
287
|
/** Everything a host hands the room. */
|
|
285
288
|
export interface IngestionPort {
|
package/dist/room-context.d.ts
CHANGED
|
@@ -55,12 +55,6 @@ export declare function useRoom(): Room;
|
|
|
55
55
|
export declare function useRoomOverlay(open: boolean): void;
|
|
56
56
|
/** Whether any of the room's dialogs is open. */
|
|
57
57
|
export declare function useRoomOverlayOpen(): boolean;
|
|
58
|
-
|
|
59
|
-
* door when it has one, else the page's own clipboard. It rejects when either
|
|
60
|
-
* refuses, and the part that asked says so in its receipt. A part mounted
|
|
61
|
-
* outside any room (a harness) writes the page's clipboard. */
|
|
62
|
-
export declare function useCopyText(): (text: string) => Promise<void>;
|
|
58
|
+
export { ReadingSessionProvider, useCopyText, useReadingSession } from "./parts-context.js";
|
|
63
59
|
/** Where the room portals its dialogs: the host's container, or the body. */
|
|
64
60
|
export declare function useRoomPortal(): HTMLElement | undefined;
|
|
65
|
-
export declare const ReadingSessionProvider: import("react").Provider<string | null>;
|
|
66
|
-
export declare function useReadingSession(): string | null;
|
package/dist/room-context.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
// The ports, as the room's parts read them. `HistoryRoom` provides them; a
|
|
3
|
-
// harness that mounts one column on its own wraps it in `RoomProvider`.
|
|
4
|
-
|
|
3
|
+
// harness that mounts one column on its own wraps it in `RoomProvider`. The
|
|
4
|
+
// room also provides the transcript's shared parts their own context
|
|
5
|
+
// (`PartsContext`) from the same values, so a part that reads only that one
|
|
6
|
+
// draws the same here as under a view with no room around it.
|
|
7
|
+
import { createContext, useContext, useEffect, useMemo, useSyncExternalStore } from "react";
|
|
8
|
+
import { PartsContext } from "./parts-context.js";
|
|
5
9
|
import { createSessionLeases } from "./lib/session-leases.js";
|
|
6
10
|
import { createFaviconStore } from "./lib/transcript/favicons.js";
|
|
7
11
|
import { browserStorage, createRoomStorage, DEFAULT_STORAGE_PREFIX } from "./lib/room-storage.js";
|
|
@@ -55,7 +59,8 @@ export function RoomProvider({ ports, options = {}, children, }) {
|
|
|
55
59
|
catalog, sessions, assets, ingestion, host, initialSummaryTab, favicons, portalContainer, overlays,
|
|
56
60
|
storage, tints, fold,
|
|
57
61
|
}), [catalog, sessions, assets, ingestion, host, initialSummaryTab, favicons, portalContainer, overlays, storage, tints, fold]);
|
|
58
|
-
|
|
62
|
+
const parts = useMemo(() => ({ assets, sessions, host, storage }), [assets, sessions, host, storage]);
|
|
63
|
+
return (_jsx(RoomContext.Provider, { value: room, children: _jsx(PartsContext.Provider, { value: parts, children: children }) }));
|
|
59
64
|
}
|
|
60
65
|
export function useRoom() {
|
|
61
66
|
const room = useContext(RoomContext);
|
|
@@ -75,22 +80,11 @@ export function useRoomOverlayOpen() {
|
|
|
75
80
|
const { overlays } = useRoom();
|
|
76
81
|
return useSyncExternalStore(overlays.subscribe, () => overlays.count() > 0, () => false);
|
|
77
82
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
export function useCopyText() {
|
|
83
|
-
const host = useContext(RoomContext)?.host ?? null;
|
|
84
|
-
return useCallback((text) => host?.copyText !== undefined ? host.copyText(text) : navigator.clipboard.writeText(text), [host]);
|
|
85
|
-
}
|
|
83
|
+
// The room's one way to put words on the system clipboard, and the session
|
|
84
|
+
// being read here, live beside the parts that read them; the room's own parts
|
|
85
|
+
// keep importing them from here.
|
|
86
|
+
export { ReadingSessionProvider, useCopyText, useReadingSession } from "./parts-context.js";
|
|
86
87
|
/** Where the room portals its dialogs: the host's container, or the body. */
|
|
87
88
|
export function useRoomPortal() {
|
|
88
89
|
return useContext(RoomContext)?.portalContainer ?? undefined;
|
|
89
90
|
}
|
|
90
|
-
/** The session whose document is being read here. Reads that name no session
|
|
91
|
-
* of their own — a stored text member, an attachment's bytes — ride its client. */
|
|
92
|
-
const ReadingSessionContext = createContext(null);
|
|
93
|
-
export const ReadingSessionProvider = ReadingSessionContext.Provider;
|
|
94
|
-
export function useReadingSession() {
|
|
95
|
-
return useContext(ReadingSessionContext);
|
|
96
|
-
}
|