@vibefield/rosetta-room 0.1.10 → 0.1.12
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 +65 -3
- package/dist/components/Transcript.js +6 -2
- package/dist/components/file-viewer/FileViewerDialog.js +3 -2
- package/dist/components/file-viewer/diff/parse.js +7 -0
- 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/file-viewer/views/DiffBody.js +7 -2
- package/dist/components/git/CommitViewer.js +3 -2
- package/dist/components/transcript/Activity.d.ts +10 -4
- package/dist/components/transcript/Activity.js +36 -11
- package/dist/components/transcript/Anchor.js +3 -2
- package/dist/components/transcript/Compaction.d.ts +9 -0
- package/dist/components/transcript/Compaction.js +10 -5
- 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 +7 -6
- 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/components/worktree/WorktreeColumn.js +12 -1
- package/dist/components/worktree/WorktreeList.d.ts +8 -2
- package/dist/components/worktree/WorktreeList.js +200 -5
- package/dist/components/worktree/worktree-ledger.d.ts +40 -0
- package/dist/components/worktree/worktree-ledger.js +68 -0
- 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/index.d.ts +1 -1
- package/dist/lib/hooks.js +6 -1
- 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 +36 -0
- package/dist/room-context.d.ts +1 -2
- package/dist/room-context.js +11 -9
- package/dist/styles/conversation-turn.css +147 -0
- package/dist/styles/conversation.css +45 -0
- package/dist/styles/room.css +102 -12
- package/dist/styles/transcript.css +11 -2
- package/package.json +9 -4
|
@@ -17,29 +17,30 @@ import { attachmentMentions } from "../../lib/transcript/index.js";
|
|
|
17
17
|
import { parseMarkdown } from "../file-viewer/markdown/index.js";
|
|
18
18
|
import { MarkdownBlocks } from "../file-viewer/markdown/render.js";
|
|
19
19
|
import { highlight, languageFor, PLAIN_TEXT } from "../file-viewer/syntax/index.js";
|
|
20
|
+
import { useCopyText } from "../../parts-context.js";
|
|
20
21
|
import { markTerms, useMatchTerms } from "./reader-context.js";
|
|
21
22
|
/** The hover acts. Today the room has exactly one honest act on a segment —
|
|
22
23
|
* copy — so that is what it draws; the record's chip and canvas belong to
|
|
23
24
|
* vibe-field, which this room is not. */
|
|
24
25
|
export function SegmentActs({ text, onReceipt, }) {
|
|
26
|
+
const copy = useCopyText();
|
|
25
27
|
if (text.trim() === "")
|
|
26
28
|
return null;
|
|
27
29
|
return (_jsx("div", { className: "tr-acts", children: _jsx("button", { type: "button", onClick: () => {
|
|
28
|
-
|
|
29
|
-
.writeText(text)
|
|
30
|
+
copy(text)
|
|
30
31
|
.then(() => onReceipt("Copied"))
|
|
31
32
|
.catch(() => onReceipt("The clipboard refused it"));
|
|
32
33
|
}, children: "copy" }) }));
|
|
33
34
|
}
|
|
34
35
|
function CodeBar({ language, text, onReceipt, excerpt = false, }) {
|
|
35
36
|
const [copied, setCopied] = useState(false);
|
|
37
|
+
const copy = useCopyText();
|
|
36
38
|
const lines = useMemo(() => {
|
|
37
39
|
const resolved = language === null ? PLAIN_TEXT : (languageFor(`x.${language}`) ?? PLAIN_TEXT);
|
|
38
40
|
return highlight(text, resolved);
|
|
39
41
|
}, [language, text]);
|
|
40
42
|
return (_jsxs("div", { className: "tr-code", children: [_jsxs("div", { className: "tr-code__bar", children: [_jsx("span", { children: language ?? "text" }), !excerpt && _jsx("button", { type: "button", onClick: () => {
|
|
41
|
-
|
|
42
|
-
.writeText(text)
|
|
43
|
+
copy(text)
|
|
43
44
|
.then(() => {
|
|
44
45
|
setCopied(true);
|
|
45
46
|
onReceipt("Copied");
|
|
@@ -93,7 +94,7 @@ function linkedAttachments(value, source, targets, onOpen) {
|
|
|
93
94
|
nodes.push(value.slice(cursor));
|
|
94
95
|
return nodes;
|
|
95
96
|
}
|
|
96
|
-
export function Prose({ text, onReceipt, imageAttachments, imageMarkerSource = text, onOpenAttachment, excerpt = false, }) {
|
|
97
|
+
export function Prose({ text, onReceipt, imageAttachments, imageMarkerSource = text, onOpenAttachment, excerpt = false, links = "open", }) {
|
|
97
98
|
const trackSource = imageAttachments?.some(fact => fact.ref?.message_ranges?.length) ?? false;
|
|
98
99
|
const parts = useMemo(() => partition(parseMarkdown(text, trackSource)), [text, trackSource]);
|
|
99
100
|
const imageTargets = useMemo(() => attachmentMentions(imageMarkerSource, imageAttachments ?? []), [imageMarkerSource, imageAttachments]);
|
|
@@ -105,5 +106,5 @@ export function Prose({ text, onReceipt, imageAttachments, imageMarkerSource = t
|
|
|
105
106
|
const renderText = terms.length === 0
|
|
106
107
|
? linked
|
|
107
108
|
: (value, source) => markTerms(linked === undefined ? value : linked(value, source), terms);
|
|
108
|
-
return (_jsx(_Fragment, { children: parts.map((part, at) => Array.isArray(part) ? (_jsx(MarkdownBlocks, { blocks: part, renderText: renderText }, at)) : (_jsx(CodeBar, { language: part.language, text: part.text, onReceipt: onReceipt, excerpt: excerpt }, at))) }));
|
|
109
|
+
return (_jsx(_Fragment, { children: parts.map((part, at) => Array.isArray(part) ? (_jsx(MarkdownBlocks, { blocks: part, renderText: renderText, links: links }, at)) : (_jsx(CodeBar, { language: part.language, text: part.text, onReceipt: onReceipt, excerpt: excerpt }, at))) }));
|
|
109
110
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { SessionRow, TimelineEntry } from "@vibefield/rosetta-protocol";
|
|
3
|
+
import type { AttachmentFact, PathFact, TeamMemberPresentation, TeamParticipantPresentation, WorkerThreadLinks, WorkflowAttemptIndex } from "../../lib/transcript/index.js";
|
|
4
|
+
import type { EarlierState } from "../../lib/transcript/head-state.js";
|
|
5
|
+
import type { useTeamTimelines } from "../../lib/hooks.js";
|
|
6
|
+
import type { ReadingSitting } from "./activity-plan.js";
|
|
7
|
+
import type { ThreadFocus, ThreadIndex } from "./thread-index.js";
|
|
8
|
+
/** What a block calls rather than holds. One object per session; each member
|
|
9
|
+
* reads the document's latest value through a ref, so a memoised block never
|
|
10
|
+
* calls a stale handler and a new handler from the host renders no block. */
|
|
11
|
+
interface ReadingActions {
|
|
12
|
+
readonly sessionId: string;
|
|
13
|
+
readonly domIdOf: (timelineId: string) => string;
|
|
14
|
+
readonly onReceipt: (text: string) => void;
|
|
15
|
+
readonly onOpenAttachment: (fact: AttachmentFact, row?: readonly AttachmentFact[]) => void;
|
|
16
|
+
readonly onOpenPath: (path: PathFact) => void;
|
|
17
|
+
readonly getRuntimeKind: (runtimeId: string) => string;
|
|
18
|
+
readonly onFocusConsumed: () => void;
|
|
19
|
+
readonly onLoadEarlier: () => void;
|
|
20
|
+
readonly onRetryTeam: () => void;
|
|
21
|
+
readonly onOpenLinkedChild: (childId: string) => void;
|
|
22
|
+
readonly onPillPress: (element: HTMLElement, dayKey: string | null) => void;
|
|
23
|
+
}
|
|
24
|
+
type LatestReading = Omit<ReadingActions, "sessionId">;
|
|
25
|
+
/** The document's facts a block draws only when it holds team traffic, a
|
|
26
|
+
* worker's thread or a workflow run. Any other block gets none of it, so a
|
|
27
|
+
* new index or roster renders only the blocks that show them. */
|
|
28
|
+
interface ReadingScope {
|
|
29
|
+
readonly index: ThreadIndex;
|
|
30
|
+
readonly focus: ThreadFocus | null;
|
|
31
|
+
readonly revealedChildId: string | null;
|
|
32
|
+
/** Which request revealed it: each request is a force of its own. */
|
|
33
|
+
readonly revealRequest: number;
|
|
34
|
+
readonly duringBackfill: boolean;
|
|
35
|
+
readonly homeDirectory: string | null;
|
|
36
|
+
readonly workerLinks: WorkerThreadLinks;
|
|
37
|
+
readonly workflowAttempts: WorkflowAttemptIndex;
|
|
38
|
+
readonly teamMembers: ReadonlyMap<string, TeamMemberPresentation>;
|
|
39
|
+
readonly participants: ReadonlyMap<string, TeamParticipantPresentation>;
|
|
40
|
+
readonly teamIdSet: ReadonlySet<string>;
|
|
41
|
+
readonly responseRuntimesBySession: ReturnType<typeof useTeamTimelines>["responseRuntimesBySession"];
|
|
42
|
+
}
|
|
43
|
+
/** The document's own state every block reads a part of: primitives only, so
|
|
44
|
+
* an arrival that changes none of them renders no sitting it did not change. */
|
|
45
|
+
interface ReadingView {
|
|
46
|
+
readonly sessionId: string;
|
|
47
|
+
readonly runtimeKind: string;
|
|
48
|
+
readonly recentActivity: boolean;
|
|
49
|
+
readonly watermark: number | null;
|
|
50
|
+
readonly highlightedTimelineId: string | null;
|
|
51
|
+
readonly focusTimelineId: string | null;
|
|
52
|
+
readonly earlier: EarlierState["kind"];
|
|
53
|
+
readonly teamLoading: boolean;
|
|
54
|
+
readonly teamError: string | null;
|
|
55
|
+
}
|
|
56
|
+
/** Whether a row draws from the scope: team traffic, a workflow run, a team
|
|
57
|
+
* member's start, or a line that owns or names a worker's thread. */
|
|
58
|
+
declare function drawsFromScope(row: TimelineEntry, scope: ReadingScope): boolean;
|
|
59
|
+
declare function drawChild(scope: ReadingScope, actions: ReadingActions, child: SessionRow, anchored: boolean): ReactNode;
|
|
60
|
+
declare const ReadingSittingView: import("react").NamedExoticComponent<{
|
|
61
|
+
readonly entry: ReadingSitting;
|
|
62
|
+
readonly showPills: boolean;
|
|
63
|
+
readonly view: ReadingView;
|
|
64
|
+
/** Given only when one of its blocks draws from it, or a worker is placed here. */
|
|
65
|
+
readonly scope: ReadingScope | null;
|
|
66
|
+
/** Workers with no anchoring line, placed before the block they precede. */
|
|
67
|
+
readonly floating: ReadonlyMap<string, readonly SessionRow[]> | null;
|
|
68
|
+
readonly actions: ReadingActions;
|
|
69
|
+
}>;
|
|
70
|
+
export { drawChild, drawsFromScope, ReadingSittingView };
|
|
71
|
+
export type { LatestReading, ReadingActions, ReadingScope, ReadingView };
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// The reading blocks of History's document, each drawn on its own: a block,
|
|
3
|
+
// a sitting, and the drawing they alone use (a report's recorded work
|
|
4
|
+
// included). Moved out of `Document.tsx`, which keeps the document's own
|
|
5
|
+
// state and hands each sitting its scoped props.
|
|
6
|
+
import { Fragment, memo, useEffect, useMemo, useState } from "react";
|
|
7
|
+
import { collaborationStamp, linkedChildSessionIds, participantPresentation, runtimeProfile, runSummary, taskBoundedReportWork, workflowAttemptsFor, } from "../../lib/transcript/index.js";
|
|
8
|
+
import { useRoom } from "../../room-context.js";
|
|
9
|
+
import { useViewerDay } from "./viewer-day.js";
|
|
10
|
+
import { Anchor } from "./Anchor.js";
|
|
11
|
+
import { DayPill, Sitting } from "./DayPill.js";
|
|
12
|
+
import { transcriptModel } from "./document-model.js";
|
|
13
|
+
import { readingBlockRows } from "./reading-identity.js";
|
|
14
|
+
import { ActivityGroup, ContextEvent } from "./Activity.js";
|
|
15
|
+
import { messageAttachments } from "../../lib/transcript/images.js";
|
|
16
|
+
import { Ledger } from "./Ledger.js";
|
|
17
|
+
import { GapMarker, Marker, Watermark } from "./Marker.js";
|
|
18
|
+
import { Compaction } from "./Compaction.js";
|
|
19
|
+
import { Prompt } from "./Prompt.js";
|
|
20
|
+
import { SegmentActs } from "./Prose.js";
|
|
21
|
+
import { AuthoredMessage } from "./AuthoredMessage.js";
|
|
22
|
+
import { ResponseHead } from "./ResponseHead.js";
|
|
23
|
+
import { Subthread } from "./Subthread.js";
|
|
24
|
+
import { sessionContains } from "./thread-index.js";
|
|
25
|
+
import { ThoughtLine } from "./Thinking.js";
|
|
26
|
+
import { TeamEvent, TeamWorkthread } from "./Team.js";
|
|
27
|
+
import { TranscriptDocument } from "./Document.js";
|
|
28
|
+
/** Mounted only by an open work disclosure; ordinary team traffic carries no private work. */
|
|
29
|
+
function LazyReportWork({ report, ...props }) {
|
|
30
|
+
const [rows, setRows] = useState(null);
|
|
31
|
+
const [error, setError] = useState(null);
|
|
32
|
+
const { sessions } = useRoom();
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const controller = new AbortController();
|
|
35
|
+
setRows(null);
|
|
36
|
+
setError(null);
|
|
37
|
+
void sessions.run(report.session_id, (client) => client.reportWork(report.session_id, report.timeline_id, controller.signal)).then((rows) => { if (!controller.signal.aborted)
|
|
38
|
+
setRows(rows); }, (error) => { if (!controller.signal.aborted)
|
|
39
|
+
setError(error instanceof Error ? error.message : "The recorded work is unavailable"); });
|
|
40
|
+
return () => controller.abort();
|
|
41
|
+
}, [report, sessions]);
|
|
42
|
+
if (error !== null)
|
|
43
|
+
return _jsx("p", { className: "tr-quiet", children: error });
|
|
44
|
+
if (rows === null)
|
|
45
|
+
return _jsx("p", { className: "tr-quiet", children: "Loading recorded work\u2026" });
|
|
46
|
+
const work = taskBoundedReportWork(report, rows);
|
|
47
|
+
if (work === null)
|
|
48
|
+
return _jsx("p", { className: "tr-quiet", children: "The recorded work is no longer available." });
|
|
49
|
+
return (_jsxs(_Fragment, { children: [_jsxs("p", { className: "tr-quiet", children: [work.actionCount, " ", work.actionCount === 1 ? "action" : "actions"] }), _jsx(ReportWorkDocument, { ...props, rows: work.rows, startedAt: work.startedAt, endedAt: work.endedAt })] }));
|
|
50
|
+
}
|
|
51
|
+
function staticTimelineFeed(rows) {
|
|
52
|
+
const nothing = () => undefined;
|
|
53
|
+
return {
|
|
54
|
+
rows: [...rows],
|
|
55
|
+
snapshotReady: true,
|
|
56
|
+
error: null,
|
|
57
|
+
retry: nothing,
|
|
58
|
+
timelineMeta: null,
|
|
59
|
+
status: "live",
|
|
60
|
+
watermark: null,
|
|
61
|
+
earlier: { kind: "none" },
|
|
62
|
+
earlierNotice: null,
|
|
63
|
+
earlierAbove: 0,
|
|
64
|
+
landed: null,
|
|
65
|
+
holdEarlier: nothing,
|
|
66
|
+
revealEarlier: nothing,
|
|
67
|
+
retryEarlier: nothing,
|
|
68
|
+
dismissEarlierNotice: nothing,
|
|
69
|
+
canLoadEarlier: false,
|
|
70
|
+
loadEarlier: nothing,
|
|
71
|
+
loadAnchor: async () => false,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function ReportWorkDocument({ session, rows, name, color, runtime, startedAt, endedAt, index, onReceipt, onOpenAttachment, onOpenPath, getRuntimeKind, homeDirectory, }) {
|
|
75
|
+
const boundedSession = useMemo(() => ({ ...session, stream_state: "indexed" }), [session]);
|
|
76
|
+
const feed = useMemo(() => staticTimelineFeed(rows), [rows]);
|
|
77
|
+
// A pill's words are the drawing's: the model is re-derived when the viewer's day turns.
|
|
78
|
+
const viewerDay = useViewerDay();
|
|
79
|
+
const model = useMemo(() => transcriptModel(rows, boundedSession, homeDirectory, viewerDay.now), [rows, boundedSession, homeDirectory, viewerDay.now]);
|
|
80
|
+
const scopedIndex = useMemo(() => {
|
|
81
|
+
const linked = new Set(rows.flatMap((row) => linkedChildSessionIds(row)));
|
|
82
|
+
const childrenByParent = new Map(index.childrenByParent);
|
|
83
|
+
childrenByParent.set(session.id, (index.childrenByParent.get(session.id) ?? []).filter((child) => linked.has(child.id)));
|
|
84
|
+
return { byId: index.byId, childrenByParent };
|
|
85
|
+
}, [rows, session.id, index]);
|
|
86
|
+
return (_jsx(TeamWorkthread, { name: name, color: color, runtime: runtime, startedAt: startedAt, endedAt: endedAt, children: _jsx(TranscriptDocument, { session: boundedSession, model: model, feed: feed, duringBackfill: false, index: scopedIndex, focus: null, highlightedTimelineId: null, onFocusConsumed: () => undefined, onReceipt: onReceipt, onOpenAttachment: onOpenAttachment, onOpenPath: onOpenPath, getRuntimeKind: getRuntimeKind, homeDirectory: homeDirectory, onPillPress: null, nested: true }) }));
|
|
87
|
+
}
|
|
88
|
+
const EMPTY_SCOPE = {
|
|
89
|
+
index: { byId: new Map(), childrenByParent: new Map() },
|
|
90
|
+
focus: null,
|
|
91
|
+
revealedChildId: null,
|
|
92
|
+
revealRequest: 0,
|
|
93
|
+
duringBackfill: false,
|
|
94
|
+
homeDirectory: null,
|
|
95
|
+
workerLinks: { anchorRowByChild: new Map(), childrenByRow: new Map(), referencedChildIdsByRow: new Map() },
|
|
96
|
+
workflowAttempts: { byRunId: new Map(), byTimelineId: new Map() },
|
|
97
|
+
teamMembers: new Map(),
|
|
98
|
+
participants: new Map(),
|
|
99
|
+
teamIdSet: new Set(),
|
|
100
|
+
responseRuntimesBySession: new Map(),
|
|
101
|
+
};
|
|
102
|
+
/** Whether a row draws from the scope: team traffic, a workflow run, a team
|
|
103
|
+
* member's start, or a line that owns or names a worker's thread. */
|
|
104
|
+
function drawsFromScope(row, scope) {
|
|
105
|
+
return row.body.type === "collaboration"
|
|
106
|
+
|| (row.body.type === "tool_use" && row.body.tool.action.type === "workflow")
|
|
107
|
+
|| scope.teamMembers.has(row.timeline_id)
|
|
108
|
+
|| scope.workerLinks.childrenByRow.has(row.timeline_id)
|
|
109
|
+
|| scope.workerLinks.referencedChildIdsByRow.has(row.timeline_id);
|
|
110
|
+
}
|
|
111
|
+
function aliveIn(d, row) {
|
|
112
|
+
return d.aliveAfter !== null && row.session_id === d.actions.sessionId && row.ordinal > d.aliveAfter;
|
|
113
|
+
}
|
|
114
|
+
function drawChild(scope, actions, child, anchored) {
|
|
115
|
+
return (_jsx(Subthread, { session: child, anchored: anchored, duringBackfill: scope.duringBackfill, index: scope.index, focus: scope.focus, onFocusConsumed: actions.onFocusConsumed, onReceipt: actions.onReceipt, onOpenAttachment: actions.onOpenAttachment, onOpenPath: actions.onOpenPath, getRuntimeKind: actions.getRuntimeKind, homeDirectory: scope.homeDirectory }, child.id));
|
|
116
|
+
}
|
|
117
|
+
function childrenOf(scope, line) {
|
|
118
|
+
return scope.workerLinks.childrenByRow.get(line.rows[0].timeline_id) ?? [];
|
|
119
|
+
}
|
|
120
|
+
/** A search hit landed inside a worker this line owns, or the reader asked for it. */
|
|
121
|
+
function childFocused(scope, line) {
|
|
122
|
+
const focus = scope.focus;
|
|
123
|
+
return childrenOf(scope, line).some((child) => (focus !== null && sessionContains(child.id, focus.sessionId, scope.index.byId))
|
|
124
|
+
|| child.id === scope.revealedChildId);
|
|
125
|
+
}
|
|
126
|
+
/** The same two forces, each named, so that a run can tell a new one from the
|
|
127
|
+
* one it was pressed under: a search hit inside a worker is named by its row,
|
|
128
|
+
* and a reveal by its request, so revealing a worker again is a new force. */
|
|
129
|
+
function childForces(scope, line) {
|
|
130
|
+
const focus = scope.focus;
|
|
131
|
+
return childrenOf(scope, line).flatMap((child) => [
|
|
132
|
+
...(focus !== null && sessionContains(child.id, focus.sessionId, scope.index.byId)
|
|
133
|
+
? [`focus:${focus.sessionId}:${focus.timelineId}`] : []),
|
|
134
|
+
...(child.id === scope.revealedChildId ? [`worker:${child.id}:${scope.revealRequest}`] : []),
|
|
135
|
+
]);
|
|
136
|
+
}
|
|
137
|
+
function reportWorkFor(d, row) {
|
|
138
|
+
if (row.body.type !== "collaboration")
|
|
139
|
+
return null;
|
|
140
|
+
const event = row.body.event;
|
|
141
|
+
if (event.kind !== "report" || event.source_session_id === null || event.source_response_id === null
|
|
142
|
+
|| event.work_start_timeline_id === null || event.work_end_timeline_id === null)
|
|
143
|
+
return null;
|
|
144
|
+
const { scope, actions } = d;
|
|
145
|
+
const memberSession = scope.index.byId.get(event.source_session_id);
|
|
146
|
+
if (memberSession === undefined || !scope.teamIdSet.has(memberSession.id))
|
|
147
|
+
return null;
|
|
148
|
+
const participant = participantPresentation(scope.participants, event.sender, event.team);
|
|
149
|
+
return {
|
|
150
|
+
actionCount: null,
|
|
151
|
+
startedAt: null,
|
|
152
|
+
endedAt: null,
|
|
153
|
+
content: _jsx(LazyReportWork, { report: row, session: memberSession, name: event.sender, color: event.color ?? participant?.color ?? null, runtime: participant?.runtime ?? runtimeProfile([], memberSession.delegation?.configured_model ?? null, scope.responseRuntimesBySession.get(memberSession.id) ?? []), index: scope.index, onReceipt: actions.onReceipt, onOpenAttachment: actions.onOpenAttachment, onOpenPath: actions.onOpenPath, getRuntimeKind: actions.getRuntimeKind, homeDirectory: scope.homeDirectory }, `${row.session_id}:${row.timeline_id}`),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function drawSegment(d, segment, embedded = false) {
|
|
157
|
+
const { scope, actions } = d;
|
|
158
|
+
const rowId = segment.kind === "ledger" ? segment.rows[0].timeline_id : segment.row.timeline_id;
|
|
159
|
+
const hit = d.hit === rowId;
|
|
160
|
+
switch (segment.kind) {
|
|
161
|
+
case "ledger":
|
|
162
|
+
return (_jsx(Ledger, { embedded: embedded, members: segment.members, summary: segment.summary, anchor: !embedded && segment.summary.closedByDefault ? (_jsx(Anchor, { at: segment.at, sessionId: segment.rows[0].session_id, timelineId: rowId, onReceipt: actions.onReceipt })) : null, domIdOf: actions.domIdOf, highlightedTimelineId: d.hit, focusTimelineId: d.focusId, alive: (line) => aliveIn(d, line.rows[0]), hasChildren: (line) => childrenOf(scope, line).length > 0, childFocused: (line) => childFocused(scope, line), subthreadsFor: (line) => childrenOf(scope, line).map((child) => ({ childSessionId: child.id, node: drawChild(scope, actions, child, true) })), workflowAttemptsFor: (line) => workflowAttemptsFor(scope.workflowAttempts, line.rows[0]), linkedChildId: (line) => scope.workerLinks.referencedChildIdsByRow.get(line.rows[0].timeline_id)?.[0] ?? null, onOpenLinkedChild: actions.onOpenLinkedChild, teamMemberFor: (line) => line.rows
|
|
163
|
+
.map((row) => scope.teamMembers.get(row.timeline_id) ?? null)
|
|
164
|
+
.find((member) => member !== null) ?? null, onOpenPath: actions.onOpenPath, onOpenAttachment: actions.onOpenAttachment }, segment.key));
|
|
165
|
+
case "thinking":
|
|
166
|
+
// A thought alone is a run of one, drawn as its line (Q10 A).
|
|
167
|
+
return (_jsx(ThoughtLine, { text: segment.text, embedded: embedded, spanMs: segment.spanMs, domId: actions.domIdOf(rowId), timelineId: rowId, hit: hit, forceOpen: d.focusId === rowId, anchor: _jsx(Anchor, { at: segment.at, sessionId: segment.row.session_id, timelineId: rowId, onReceipt: actions.onReceipt }) }, segment.key));
|
|
168
|
+
case "marker":
|
|
169
|
+
if (segment.notice.type === "permission_requested")
|
|
170
|
+
return _jsx(Marker, { text: segment.text, tone: segment.tone, domId: actions.domIdOf(rowId), timelineId: rowId, hit: hit }, segment.key);
|
|
171
|
+
return _jsx(ContextEvent, { segment: segment, domId: actions.domIdOf(rowId), hit: hit, forceOpen: d.focusId === rowId, onReceipt: actions.onReceipt }, segment.key);
|
|
172
|
+
case "summary":
|
|
173
|
+
return _jsx(ContextEvent, { segment: segment, domId: actions.domIdOf(rowId), hit: hit, forceOpen: d.focusId === rowId, onReceipt: actions.onReceipt }, segment.key);
|
|
174
|
+
case "compaction":
|
|
175
|
+
return (_jsx(Compaction, { text: segment.text, domId: actions.domIdOf(rowId), timelineId: rowId, hit: segment.rows.some((row) => row.timeline_id === d.hit), forceOpen: segment.rows.some((row) => row.timeline_id === d.focusId), onReceipt: actions.onReceipt }, segment.key));
|
|
176
|
+
case "prose":
|
|
177
|
+
return (_jsxs("div", { className: "tr-seg tr-prose ah-syntax", id: actions.domIdOf(rowId), "data-timeline-id": rowId, "data-hit": hit || undefined, children: [_jsx(Anchor, { at: segment.at, sessionId: segment.row.session_id, timelineId: rowId, onReceipt: actions.onReceipt }), _jsx(AuthoredMessage, { text: segment.text, attachments: segment.attachments, recordedText: segment.row.body.type === "agent" ? segment.row.body.text : null, messageKey: `${segment.row.session_id}:${rowId}`, role: "agent", onReceipt: actions.onReceipt, onOpenAttachment: actions.onOpenAttachment }), segment.citationLabels.length > 0 && (_jsx("p", { className: "tr-cites", children: segment.citationLabels.map((label, at) => (_jsx("span", { children: label }, at))) })), _jsx(SegmentActs, { text: segment.text ?? "", onReceipt: actions.onReceipt })] }, segment.key));
|
|
178
|
+
case "collaboration": {
|
|
179
|
+
const sourceMember = scope.teamIdSet.has(segment.row.session_id)
|
|
180
|
+
? scope.index.byId.get(segment.row.session_id)
|
|
181
|
+
: undefined;
|
|
182
|
+
const inferredRecipient = segment.event.channel === "coordinator" && segment.event.recipient === null
|
|
183
|
+
? (sourceMember?.title ?? sourceMember?.native_session_id ?? null)
|
|
184
|
+
: segment.event.recipient;
|
|
185
|
+
const event = inferredRecipient === segment.event.recipient
|
|
186
|
+
? segment.event
|
|
187
|
+
: { ...segment.event, recipient: inferredRecipient };
|
|
188
|
+
const participant = participantPresentation(scope.participants, event.sender, event.team);
|
|
189
|
+
const recipientParticipant = participantPresentation(scope.participants, event.recipient, event.team);
|
|
190
|
+
const stamp = collaborationStamp(segment.row);
|
|
191
|
+
return (_jsx(TeamEvent, { event: event, attachments: messageAttachments(segment.row), onOpenAttachment: actions.onOpenAttachment, at: stamp.at, timeBasis: stamp.basis, domId: actions.domIdOf(rowId), timelineId: rowId, participant: participant, recipientParticipant: recipientParticipant, hit: hit, forceOpen: d.focusId === rowId, reportWork: reportWorkFor(d, segment.row), onReceipt: actions.onReceipt }, segment.key));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function drawTools(d, items, embedded) {
|
|
196
|
+
const lines = items.map(item => item.line);
|
|
197
|
+
const rows = lines.flatMap(line => line.rows);
|
|
198
|
+
return drawSegment(d, { kind: "ledger", key: items[0].key, at: rows[0].at, rows, lines,
|
|
199
|
+
members: lines.map(line => ({ kind: "line", key: line.key, line })), summary: runSummary(lines) }, embedded);
|
|
200
|
+
}
|
|
201
|
+
function drawItem(d, item) {
|
|
202
|
+
if (item.kind === "tool")
|
|
203
|
+
return drawTools(d, [item], false);
|
|
204
|
+
if (item.kind !== "prompt")
|
|
205
|
+
return drawSegment(d, item, true);
|
|
206
|
+
const row = item.prompt.row;
|
|
207
|
+
if (row.body.type === "collaboration")
|
|
208
|
+
return drawSegment(d, { kind: "collaboration", key: item.key,
|
|
209
|
+
row, at: row.at, event: row.body.event }, true);
|
|
210
|
+
return _jsx(Prompt, { prompts: [item.prompt], domIdOf: d.actions.domIdOf, landedTimelineId: d.hit, focusTimelineId: d.focusId, onReceipt: d.actions.onReceipt, onOpenAttachment: d.actions.onOpenAttachment }, item.key);
|
|
211
|
+
}
|
|
212
|
+
function drawItems(d, items) {
|
|
213
|
+
const nodes = [];
|
|
214
|
+
let tools = [];
|
|
215
|
+
const flush = () => { if (tools.length > 0)
|
|
216
|
+
nodes.push(drawTools(d, tools, true)); tools = []; };
|
|
217
|
+
for (const item of items) {
|
|
218
|
+
if (item.kind === "tool")
|
|
219
|
+
tools.push(item);
|
|
220
|
+
else {
|
|
221
|
+
flush();
|
|
222
|
+
nodes.push(drawItem(d, item));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
flush();
|
|
226
|
+
return nodes;
|
|
227
|
+
}
|
|
228
|
+
const ReadingBlockView = memo(function ReadingBlockView({ block, hit, focusId, force, aliveAfter, headOpen, runtimeKind, earlier, teamLoading, teamError, scope, actions, }) {
|
|
229
|
+
const d = { hit, focusId, aliveAfter, scope: scope ?? EMPTY_SCOPE, actions };
|
|
230
|
+
switch (block.kind) {
|
|
231
|
+
case "gap": return _jsx(GapMarker, { count: block.count, onPress: () => actions.onReceipt(`${block.count} ${block.count === 1 ? "message is" : "messages are"} in the session but not in this page`) });
|
|
232
|
+
case "watermark": return _jsx(Watermark, { text: "received since opening" });
|
|
233
|
+
case "prompt": return _jsx("div", { className: "tr-turn tr-reading-prompt", children: _jsx(Prompt, { prompts: block.prompts, domIdOf: actions.domIdOf, landedTimelineId: hit, onReceipt: actions.onReceipt, onOpenAttachment: actions.onOpenAttachment }) });
|
|
234
|
+
case "reply": return _jsxs("div", { className: block.head === null ? "tr-reading-reply" : "tr-resp tr-reading-reply", children: [block.head !== null && _jsx(ResponseHead, { head: block.head, runtimeKind: runtimeKind, open: headOpen }), drawSegment(d, block.segment)] });
|
|
235
|
+
case "request": return drawItem(d, block.item);
|
|
236
|
+
case "activity":
|
|
237
|
+
return _jsx(ActivityGroup, { items: block.items, rows: block.rows, partial: block.partial, force: force, earlier: earlier, onLoadEarlier: actions.onLoadEarlier, teamLoading: teamLoading, teamError: teamError, onRetryTeam: actions.onRetryTeam, onOpenAttachment: actions.onOpenAttachment, onReceipt: actions.onReceipt, highlightedId: hit, alive: row => aliveIn(d, row), children: () => drawItems(d, block.items) });
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
/** The block's element, with every prop scoped to what that block holds. */
|
|
241
|
+
function readingBlock(block, view, scope, actions) {
|
|
242
|
+
const rows = readingBlockRows(block);
|
|
243
|
+
const holds = (id) => id !== null && rows.some((row) => row.timeline_id === id);
|
|
244
|
+
const blockScope = scope !== null && rows.some((row) => drawsFromScope(row, scope)) ? scope : null;
|
|
245
|
+
const focusId = holds(view.focusTimelineId) ? view.focusTimelineId : null;
|
|
246
|
+
const activity = block.kind === "activity";
|
|
247
|
+
const forces = !activity ? [] : [
|
|
248
|
+
...(focusId === null ? [] : [`focus:${focusId}`]),
|
|
249
|
+
...(blockScope === null ? [] : block.items.flatMap((item) => item.kind === "tool" ? childForces(blockScope, item.line) : [])),
|
|
250
|
+
];
|
|
251
|
+
const watermark = view.watermark;
|
|
252
|
+
const aliveAfter = (activity || block.kind === "request") && view.recentActivity && watermark !== null
|
|
253
|
+
&& rows.some((row) => row.session_id === view.sessionId && row.ordinal > watermark) ? watermark : null;
|
|
254
|
+
const head = block.kind === "reply" ? block.head : null;
|
|
255
|
+
return _jsx(ReadingBlockView, { block: block, hit: holds(view.highlightedTimelineId) ? view.highlightedTimelineId : null, focusId: focusId, force: forces.length === 0 ? null : forces.join(" "), aliveAfter: aliveAfter, headOpen: head !== null && view.recentActivity && head.endedAt === null, runtimeKind: head !== null ? view.runtimeKind : "", earlier: activity && block.partial ? view.earlier : "none", teamLoading: activity && view.teamLoading, teamError: activity ? view.teamError : null, scope: blockScope, actions: actions });
|
|
256
|
+
}
|
|
257
|
+
const ReadingSittingView = memo(function ReadingSittingView({ entry, showPills, view, scope, floating, actions }) {
|
|
258
|
+
const { sitting, blocks } = entry;
|
|
259
|
+
// A block drawn from the same view, scope and actions, with no worker placed
|
|
260
|
+
// before it, is handed the element it was drawn as before: React passes over
|
|
261
|
+
// it unread, so a sitting drawn again for one arriving row makes the
|
|
262
|
+
// elements of the blocks that row changed and not of every block in it
|
|
263
|
+
// (2026-11-29, the reader's arrival cost).
|
|
264
|
+
const [drawn] = useState(() => new WeakMap());
|
|
265
|
+
const drawBlock = (block) => {
|
|
266
|
+
const placed = floating?.get(block.key);
|
|
267
|
+
if (placed !== undefined) {
|
|
268
|
+
return _jsxs(Fragment, { children: [placed.map((child) => drawChild(scope ?? EMPTY_SCOPE, actions, child, false)), readingBlock(block, view, scope, actions)] }, block.key);
|
|
269
|
+
}
|
|
270
|
+
const held = drawn.get(block);
|
|
271
|
+
if (held !== undefined && held.view === view && held.scope === scope && held.actions === actions)
|
|
272
|
+
return held.element;
|
|
273
|
+
const element = _jsx(Fragment, { children: readingBlock(block, view, scope, actions) }, block.key);
|
|
274
|
+
drawn.set(block, { view, scope, actions, element });
|
|
275
|
+
return element;
|
|
276
|
+
};
|
|
277
|
+
return (_jsxs(Sitting, { sitting: sitting, children: [showPills && (_jsx(DayPill, { sitting: sitting, onPress: (event) => actions.onPillPress(event.currentTarget, sitting.dayKey) })), blocks.map(drawBlock)] }));
|
|
278
|
+
});
|
|
279
|
+
export { drawChild, drawsFromScope, ReadingSittingView };
|
|
@@ -56,17 +56,48 @@ export interface ReadingSitting {
|
|
|
56
56
|
}
|
|
57
57
|
export declare function activityRows(item: ActivityItem): readonly TimelineEntry[];
|
|
58
58
|
export declare function activityRowKey(row: TimelineEntry): string;
|
|
59
|
+
/** A missing stretch with no drawn row after it: its rows' count, and the first
|
|
60
|
+
* row past the stretch (the block's key and time). */
|
|
61
|
+
export interface TrailingGap {
|
|
62
|
+
readonly count: number;
|
|
63
|
+
readonly row: TimelineEntry;
|
|
64
|
+
}
|
|
65
|
+
export interface ActivityCuts {
|
|
66
|
+
readonly gaps: ReadonlyMap<string, number>;
|
|
67
|
+
readonly watermarkId: string | null;
|
|
68
|
+
readonly cutBefore: ReadonlySet<string>;
|
|
69
|
+
readonly trailingGap: TrailingGap | null;
|
|
70
|
+
}
|
|
59
71
|
/** Tool lines must already have been cut at these boundaries before coalescing. */
|
|
60
|
-
export declare function activityCuts(rows: readonly TimelineEntry[], watermark: number | null, displayedRows?: readonly TimelineEntry[]):
|
|
61
|
-
|
|
62
|
-
watermarkId: string | null;
|
|
63
|
-
cutBefore: Set<string>;
|
|
64
|
-
};
|
|
65
|
-
export declare function activityPlan(plan: readonly PlannedSitting[], options: {
|
|
72
|
+
export declare function activityCuts(rows: readonly TimelineEntry[], watermark: number | null, displayedRows?: readonly TimelineEntry[]): ActivityCuts;
|
|
73
|
+
export interface ActivityPlanOptions {
|
|
66
74
|
readonly gaps: ReadonlyMap<string, number>;
|
|
67
75
|
readonly watermarkId: string | null;
|
|
68
76
|
readonly partial: boolean;
|
|
69
|
-
|
|
77
|
+
/** Required: a caller that left it out would say nothing of a stretch missing at the end. */
|
|
78
|
+
readonly trailingGap: TrailingGap | null;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* What the last plan was made from and what it made, sitting by sitting (2026-11-29, the reader's arrival cost). The
|
|
82
|
+
* plan carries three things from one sitting to the next: the turns whose head is drawn, the rows whose gap or live
|
|
83
|
+
* line is drawn, and whether the document's first content is still ahead. Each sitting records what it added and what
|
|
84
|
+
* it found, so a plan whose first sittings are the same objects, under the same options, hands their blocks back and
|
|
85
|
+
* makes only the sittings after them: one arriving row makes the last sitting, not the document.
|
|
86
|
+
*/
|
|
87
|
+
export interface ActivityPlanMemo {
|
|
88
|
+
plan: readonly PlannedSitting[];
|
|
89
|
+
options: ActivityPlanOptions | null;
|
|
90
|
+
made: ReadingSitting[];
|
|
91
|
+
headed: Set<string>;
|
|
92
|
+
bounded: Set<string>;
|
|
93
|
+
/** Per sitting: the turn keys and the row ids it added, and the first-content flag it began with. */
|
|
94
|
+
headedBy: string[][];
|
|
95
|
+
boundedBy: string[][];
|
|
96
|
+
firstBefore: boolean[];
|
|
97
|
+
firstAfter: boolean;
|
|
98
|
+
}
|
|
99
|
+
export declare function activityPlanMemo(): ActivityPlanMemo;
|
|
100
|
+
export declare function activityPlan(plan: readonly PlannedSitting[], options: ActivityPlanOptions, memo?: ActivityPlanMemo): ReadingSitting[];
|
|
70
101
|
export interface ActivitySummary {
|
|
71
102
|
readonly nouns: readonly {
|
|
72
103
|
readonly key: string;
|