@vibefield/rosetta-room 0.1.11 → 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.
Files changed (87) hide show
  1. package/README.md +64 -2
  2. package/dist/components/Transcript.js +6 -2
  3. package/dist/components/file-viewer/kinds.d.ts +22 -0
  4. package/dist/components/file-viewer/kinds.js +57 -0
  5. package/dist/components/file-viewer/markdown/render.d.ts +7 -1
  6. package/dist/components/file-viewer/markdown/render.js +16 -12
  7. package/dist/components/file-viewer/registry.d.ts +2 -2
  8. package/dist/components/file-viewer/registry.js +20 -59
  9. package/dist/components/transcript/Activity.d.ts +10 -4
  10. package/dist/components/transcript/Activity.js +36 -11
  11. package/dist/components/transcript/Compaction.d.ts +9 -0
  12. package/dist/components/transcript/Compaction.js +8 -4
  13. package/dist/components/transcript/Document.js +150 -208
  14. package/dist/components/transcript/PromptJump.js +28 -8
  15. package/dist/components/transcript/Prose.d.ts +5 -1
  16. package/dist/components/transcript/Prose.js +3 -3
  17. package/dist/components/transcript/ReadingBlocks.d.ts +71 -0
  18. package/dist/components/transcript/ReadingBlocks.js +279 -0
  19. package/dist/components/transcript/activity-plan.d.ts +38 -7
  20. package/dist/components/transcript/activity-plan.js +198 -28
  21. package/dist/components/transcript/attachment-file-source.d.ts +1 -2
  22. package/dist/components/transcript/attachment-file-source.js +7 -5
  23. package/dist/components/transcript/disclosure-state.d.ts +2 -0
  24. package/dist/components/transcript/disclosure-state.js +6 -2
  25. package/dist/components/transcript/document-model.js +53 -9
  26. package/dist/components/transcript/document-plan.js +263 -98
  27. package/dist/components/transcript/reading-identity.d.ts +14 -1
  28. package/dist/components/transcript/reading-identity.js +126 -10
  29. package/dist/conversation/ConversationGallery.d.ts +11 -0
  30. package/dist/conversation/ConversationGallery.js +14 -0
  31. package/dist/conversation/ConversationMedia.d.ts +44 -0
  32. package/dist/conversation/ConversationMedia.js +210 -0
  33. package/dist/conversation/ConversationProse.d.ts +13 -0
  34. package/dist/conversation/ConversationProse.js +6 -0
  35. package/dist/conversation/ConversationRunRows.d.ts +57 -0
  36. package/dist/conversation/ConversationRunRows.js +84 -0
  37. package/dist/conversation/ConversationTurnView.d.ts +64 -0
  38. package/dist/conversation/ConversationTurnView.js +169 -0
  39. package/dist/conversation/ConversationView.d.ts +3 -0
  40. package/dist/conversation/ConversationView.js +257 -0
  41. package/dist/conversation/feed-reads.d.ts +36 -0
  42. package/dist/conversation/feed-reads.js +155 -0
  43. package/dist/conversation/feed.d.ts +106 -0
  44. package/dist/conversation/feed.js +884 -0
  45. package/dist/conversation/index.d.ts +11 -0
  46. package/dist/conversation/index.js +25 -0
  47. package/dist/conversation/model.d.ts +108 -0
  48. package/dist/conversation/model.js +257 -0
  49. package/dist/conversation/ports.d.ts +194 -0
  50. package/dist/conversation/ports.js +9 -0
  51. package/dist/conversation/rosetta-client.d.ts +8 -0
  52. package/dist/conversation/rosetta-client.js +1 -0
  53. package/dist/conversation/use-conversation-feed.d.ts +16 -0
  54. package/dist/conversation/use-conversation-feed.js +41 -0
  55. package/dist/conversation/use-conversation-window.d.ts +50 -0
  56. package/dist/conversation/use-conversation-window.js +336 -0
  57. package/dist/conversation/words.d.ts +51 -0
  58. package/dist/conversation/words.js +79 -0
  59. package/dist/fixtures/conversation.d.ts +34 -0
  60. package/dist/fixtures/conversation.js +723 -0
  61. package/dist/fixtures/index.d.ts +2 -0
  62. package/dist/fixtures/index.js +1 -0
  63. package/dist/lib/session-leases.d.ts +11 -8
  64. package/dist/lib/transcript/collaboration.js +53 -19
  65. package/dist/lib/transcript/head-of-document.js +9 -3
  66. package/dist/lib/transcript/index.d.ts +1 -1
  67. package/dist/lib/transcript/index.js +1 -1
  68. package/dist/lib/transcript/prompt-jump.d.ts +2 -0
  69. package/dist/lib/transcript/prompt-jump.js +5 -1
  70. package/dist/lib/transcript/sittings.d.ts +2 -1
  71. package/dist/lib/transcript/sittings.js +72 -10
  72. package/dist/lib/transcript/tail-state.d.ts +9 -0
  73. package/dist/lib/transcript/tail-state.js +25 -1
  74. package/dist/lib/transcript/turns.d.ts +5 -0
  75. package/dist/lib/transcript/turns.js +221 -57
  76. package/dist/lib/transcript/use-transcript-tail.js +17 -3
  77. package/dist/lib/transcript/vocabulary.d.ts +2 -1
  78. package/dist/lib/transcript/vocabulary.js +11 -1
  79. package/dist/parts-context.d.ts +25 -0
  80. package/dist/parts-context.js +32 -0
  81. package/dist/ports.d.ts +3 -0
  82. package/dist/room-context.d.ts +1 -7
  83. package/dist/room-context.js +12 -18
  84. package/dist/styles/conversation-turn.css +147 -0
  85. package/dist/styles/conversation.css +45 -0
  86. package/dist/styles/transcript.css +11 -2
  87. package/package.json +9 -4
package/README.md CHANGED
@@ -51,7 +51,7 @@ sockets stay the simulator's.
51
51
  |---|---|---|
52
52
  | `CatalogPort` | `subscribeMeta` (runtimes, projects, every session row, live: one snapshot then mutations) · `status` → `CatalogStatus` · `projectStats(projectId, window)` → `ProjectStats` (per-day heat and per-session facts) · `usage` · `dayUsage` · `search(CatalogSearch)` · optional `onConnectionChange`, `unavailable` (the host's own words for why the index cannot answer), `boost` and `projectStatsBatch` (every listed project's figures in one ask; present, the room asks it once per refresh instead of `projectStats` per project) | its client's REST and `/ws/meta` (`catalogOver`) |
53
53
  | `SessionPort` | `open(sessionId)` → a `SessionClient` bound to that session (its live subscription, child threads and team members each open their own; entries, report work, commands, plans, file targets, stored members), or a promise of one; `close(sessionId)` | the one client for every session; close is nothing |
54
- | `AssetSource` | `imageAssetUrl(asset, variant)` → a URL, null, or a promise of either · `attachmentAssetUrl(asset)` → the attachment's address, for identity and can-open only · optional `mediaAssetUrl(asset)` → an address a `<video src>` can load, null, or a promise of either | the daemon's own URLs |
54
+ | `AssetSource` | `imageAssetUrl(asset, variant)` → a URL, null, or a promise of either · `attachmentAssetUrl(asset)` → the attachment's address, for identity and can-open only · optional `mediaAssetUrl(asset)` → an address a `<video src>` can load, null, or a promise of either · optional `mediaFirstFrame` (true: that address honours byte ranges and may be asked before play; the conversation view draws a video's first frame from it) | the daemon's own URLs |
55
55
  | `HostPort` (optional) | `homeDir` · `platform` · `openInBrowser(name, bytes, browserId?)` · optional `browsers()` · `favicon(site)` · optional `copyText(text)` (0.1.11: every copy the room makes, for a shell whose page may not write the clipboard) · optional `worktree: { open, gitFacts, fileAction, ports }`, with optional `worktreeSizes(root, generation, paths)` (0.1.11: what the worktrees on screen hold on disk, asked by name) | the Electron bridge (`hostPortOver`) |
56
56
 
57
57
  - **The room opens a session at most once at a time and follows every `open`
@@ -93,7 +93,8 @@ sockets stay the simulator's.
93
93
  address a `<video src>` can load. A host answers one only for an address
94
94
  that honours byte ranges: served whole, without ranges, a video plays but
95
95
  cannot seek, and no error tells the room to fall back. The daemon serves a
96
- member whole, so rosetta's app leaves `mediaAssetUrl` out. A host without
96
+ member by byte range (a ranged ask answers 206), and rosetta's app answers
97
+ its own address for an mp4 or mov member. A host without
97
98
  it, one that answers null, or one whose address the element cannot load
98
99
  needs nothing more: the room reads the member's bytes through the reading
99
100
  session's `readAsset` and plays an object URL it makes and revokes itself,
@@ -357,6 +358,67 @@ address, and draws the room's own document with nothing around it.
357
358
  `--vf-fill-hover` wash at 500, a `--vf-text-tertiary` edge — and never the
358
359
  select hue the room's landing ring wears for a moment.
359
360
 
361
+ ## The conversation view (`@vibefield/rosetta-room/conversation`)
362
+
363
+ One conversation read by turns, over an ordered chain of sessions: each
364
+ prompt, the agent's replies, its runs of work as one line, its pictures and
365
+ videos. It is an entry of its own, so a host that draws a conversation loads
366
+ neither the room nor its file viewer, charts, worktree, git or search (the
367
+ entry's static imports are React and `@tanstack/react-virtual`, and a test
368
+ walks them).
369
+
370
+ ```tsx
371
+ import { ConversationView } from "@vibefield/rosetta-room/conversation";
372
+ import "@vibefield/rosetta-room/styles/conversation.css"; // after the host's --vf-* tokens
373
+
374
+ <ConversationView sessionPort={sessionPort} assets={assets} chain={["s1", "s2"]} />;
375
+ ```
376
+
377
+ - **It binds to rosetta's client.** `sessionPort.open(sessionId)` answers a
378
+ `ConversationSessionClient`, and a `RosettaClient` is one: the room's build
379
+ holds the two together at compile time (`src/conversation/rosetta-client.ts`),
380
+ and a test reads the daemon's own turn pages, outline and socket frames
381
+ through the real client into the view. A host with one client over every
382
+ session writes `{ open: () => client, close() {} }`; a host that needs a
383
+ credential per session answers a client that carries it, or a promise of one.
384
+ The view opens each session once for its turn reads and its parts together,
385
+ and follows every `open` with exactly one `close`.
386
+ - **It needs the turn reads.** A client without them, or a daemon that has none
387
+ (`TurnsUnsupportedError`, told by its name through `isTurnsUnsupported`), is
388
+ drawn as unavailable, never as an empty conversation.
389
+ - **It opens at the end** from the newest session's first snapshot, follows the
390
+ foot while the reader is there, holds the reader's place within a pixel when
391
+ older turns land above, and jumps to a turn (`handle.jumpTo`, `scrollToLatest`).
392
+ Only the chain's last session is subscribed; earlier ones are read as the
393
+ reader reaches them. It holds at most 400 turn bodies and 8 MiB of reply text
394
+ beyond what is in reach, and three open sessions.
395
+ - **The host places its own things** among the turns by time (`items`,
396
+ `renderItem`), draws a prompt, an end-of-turn node or a chain boundary in its
397
+ own way (`renderPrompt`, `renderAfterTurn`, `renderBoundary`), leads the
398
+ agent's rows with its own mark (`agentLead`, `runLead`), and says every line
399
+ the view draws in its own words: `runWords`, `runRowWords`, `requestWords`,
400
+ `outcomeWords`, `dayWords`, `compactionWords` and `words` (the run's, the
401
+ parts' and the media's lines, each the whole line). Absent, they are
402
+ rosetta's plain words (`CONVERSATION_WORDS`). `conversationRowsOf` and
403
+ `conversationLeads` are the pure functions the view places its rows with, so
404
+ a host's tests and another client can take the same placement.
405
+ - **Every state is drawn.** `data-conv-state` on the root is `reading`,
406
+ `ready`, `catching-up` (after a reset or a dropped socket it keeps what it
407
+ holds until the fresh outline lands) or `unavailable`, each with a slot
408
+ (`reading`, `catchingUp`, `empty`, `unavailable`).
409
+ - **Pictures and videos.** One picture draws as wide as the reply, up to
410
+ `--tr-conv-media-max`; several draw as the shared rail. A video draws its
411
+ first frame, length and size and plays in place when the host's
412
+ `AssetSource` sets `mediaFirstFrame: true`, which says its `mediaAssetUrl`
413
+ honours byte ranges and may be asked before play; without it the video is
414
+ the rail's tile and its address is asked on play.
415
+ - **The host's tokens** are `--tr-conv-*` (column, gap, pad, text and quiet
416
+ sizes, bubble, lead, media, run lead gap), each with a default; colours and
417
+ fonts are the `--vf-*` names the room already reads.
418
+ - **`createConversationDemo`** (`@vibefield/rosetta-room/fixtures`) is a
419
+ synthetic, deterministic chain over a session port, with `append`, `reset`
420
+ and `unsupported`, for a host's tests and a bench.
421
+
360
422
  ## What the package never does
361
423
 
362
424
  - **No fetch and no socket.** Every byte arrives through a port.
@@ -305,10 +305,14 @@ function SessionTranscript({ session, duringBackfill, importCourse, importAgent,
305
305
  }
306
306
  }, [targetTimelineId, targetIsMeta, metaFocus, session, feed, model, onFocusConsumed, onReceipt, reader]);
307
307
  // The pill pins while the reader is inside its day, and returns to its
308
- // hairline the moment that day scrolls back into view.
308
+ // hairline the moment that day scrolls back into view. The pills are stamped
309
+ // again when the sittings drawn change, and as the column scrolls: a row that
310
+ // arrives inside the last sitting moves no pill, so it reads none of them
311
+ // (2026-11-29, the reader's arrival cost).
312
+ const pillKeys = model.plan.map((entry) => entry.sitting.key).join("\u0000");
309
313
  useEffect(() => {
310
314
  markStuckPills(scrollRef.current);
311
- }, [model.plan]);
315
+ }, [pillKeys]);
312
316
  // A session the import has not reached has no messages to count and no
313
317
  // activity to range over yet: the head says so instead.
314
318
  const notImported = session !== null &&
@@ -0,0 +1,22 @@
1
+ import type { Language } from "./syntax/index.js";
2
+ /** The views a name can choose. A diff is never chosen by a name: the caller
3
+ * asks for one (`registry.diffKind`). */
4
+ export type NamedViewerId = "code" | "html" | "markdown" | "image" | "svg" | "binary";
5
+ /** What a name says a file is, before any view is chosen. */
6
+ export interface NamedKind {
7
+ readonly viewer: NamedViewerId;
8
+ /** The chip beside the name: "TypeScript", "Markdown", "PNG". */
9
+ readonly label: string;
10
+ /** Set when the view highlights source. */
11
+ readonly language: Language | null;
12
+ /** Set when the view needs a blob: `image/png`, `image/svg+xml`. */
13
+ readonly mime: string | null;
14
+ }
15
+ export declare const IMAGE_TYPES: ReadonlyMap<string, string>;
16
+ /** Extensions worth refusing to decode as text before reading a byte. An
17
+ * unknown extension is NOT on this list: it is read as text and downgraded if
18
+ * the bytes disagree, because most unfamiliar extensions in a repository are
19
+ * somebody's config file. */
20
+ export declare const BINARY_EXTENSIONS: ReadonlySet<string>;
21
+ /** What a file name says the file is. */
22
+ export declare function kindOfName(name: string): NamedKind;
@@ -0,0 +1,57 @@
1
+ // What a file's name says the file is, and which view would show it.
2
+ //
3
+ // The table alone, importing no view: the registry turns each answer into the
4
+ // view that draws it, and a part that only needs to know a file's kind (an
5
+ // attachment's name, a stored member's) reads it here without loading the
6
+ // viewer. Extension only — see `syntax/languages` for why the bytes get no
7
+ // vote here.
8
+ import { extensionOf, languageFor, PLAIN_TEXT } from "./syntax/index.js";
9
+ export const IMAGE_TYPES = new Map([
10
+ ["png", "image/png"],
11
+ ["jpg", "image/jpeg"],
12
+ ["jpeg", "image/jpeg"],
13
+ ["gif", "image/gif"],
14
+ ["webp", "image/webp"],
15
+ ["avif", "image/avif"],
16
+ ["bmp", "image/bmp"],
17
+ ["ico", "image/x-icon"],
18
+ ["apng", "image/apng"],
19
+ ]);
20
+ /** Extensions worth refusing to decode as text before reading a byte. An
21
+ * unknown extension is NOT on this list: it is read as text and downgraded if
22
+ * the bytes disagree, because most unfamiliar extensions in a repository are
23
+ * somebody's config file. */
24
+ export const BINARY_EXTENSIONS = new Set([
25
+ "zip", "gz", "tgz", "bz2", "xz", "zst", "7z", "rar", "tar", "jar", "war",
26
+ "pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "key", "numbers", "pages",
27
+ "so", "dylib", "dll", "a", "o", "obj", "exe", "bin", "wasm", "node", "rlib", "pdb",
28
+ "woff", "woff2", "ttf", "otf", "eot",
29
+ "mp3", "mp4", "m4a", "wav", "aiff", "flac", "ogg", "webm", "mov", "avi", "mkv",
30
+ "db", "sqlite", "sqlite3", "rdb", "pack", "idx", "class", "pyc", "pyo",
31
+ "psd", "sketch", "fig", "ai", "heic", "tiff", "tif", "dmg", "iso", "img",
32
+ ]);
33
+ /** What a file name says the file is. */
34
+ export function kindOfName(name) {
35
+ const extension = extensionOf(name);
36
+ if (extension === "svg") {
37
+ return { viewer: "svg", label: "SVG", language: languageFor(name), mime: "image/svg+xml" };
38
+ }
39
+ const mime = IMAGE_TYPES.get(extension);
40
+ if (mime !== undefined) {
41
+ return { viewer: "image", label: extension.toUpperCase(), language: null, mime };
42
+ }
43
+ if (BINARY_EXTENSIONS.has(extension)) {
44
+ return { viewer: "binary", label: extension === "" ? "Binary" : extension.toUpperCase(), language: null, mime: null };
45
+ }
46
+ const language = languageFor(name);
47
+ // Text with no language behind it: read, shown, nothing claimed about it.
48
+ if (language === null)
49
+ return { viewer: "code", label: "Text", language: PLAIN_TEXT, mime: null };
50
+ if (language.id === "markdown") {
51
+ return { viewer: "markdown", label: language.label, language, mime: null };
52
+ }
53
+ if (language.id === "html") {
54
+ return { viewer: "html", label: language.label, language, mime: "text/html" };
55
+ }
56
+ return { viewer: "code", label: language.label, language, mime: null };
57
+ }
@@ -1,9 +1,15 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type { Block } from "./types.js";
3
3
  export type InlineTextRenderer = (value: string, source?: readonly number[]) => ReactNode;
4
- export declare function MarkdownBlocks({ blocks, renderText, }: {
4
+ /** What a link draws. `"open"`: a link the shell can open, as above. `"inert"`:
5
+ * every link is its words alone, for a host that opens nothing from a message
6
+ * it shows. */
7
+ export type MarkdownLinks = "open" | "inert";
8
+ export declare function MarkdownBlocks({ blocks, renderText, links, }: {
5
9
  readonly blocks: readonly Block[];
6
10
  /** Optional decoration for plain text nodes. Code and link targets remain
7
11
  * literal, so callers cannot accidentally nest an action inside a link. */
8
12
  readonly renderText?: InlineTextRenderer | undefined;
13
+ /** What a link draws. Default `"open"`. */
14
+ readonly links?: MarkdownLinks | undefined;
9
15
  }): import("react").JSX.Element;
@@ -28,18 +28,22 @@ function safeHref(href) {
28
28
  const trimmed = href.trim();
29
29
  return /^https?:\/\//i.test(trimmed) ? trimmed : null;
30
30
  }
31
- function InlineNodes({ nodes, renderText, }) {
32
- return (_jsx(_Fragment, { children: nodes.map((node, at) => (_jsx(Fragment, { children: node.type === "text" ? (renderText === undefined ? node.value : renderText(node.value, node.source)) : node.type === "code" ? (_jsx("code", { children: node.value })) : node.type === "strong" ? (_jsx("strong", { children: _jsx(InlineNodes, { nodes: node.children, renderText: renderText }) })) : node.type === "emphasis" ? (_jsx("em", { children: _jsx(InlineNodes, { nodes: node.children, renderText: renderText }) })) : node.type === "strike" ? (_jsx("s", { children: _jsx(InlineNodes, { nodes: node.children, renderText: renderText }) })) : node.type === "break" ? (_jsx("br", {})) : node.type === "image" ? (_jsx("span", { className: "ah-md__image", title: node.src, children: node.alt === "" ? node.src : node.alt })) : (_jsx(LinkOrText, { node: node })) }, at))) }));
31
+ function InlineNodes({ nodes, renderText, links, }) {
32
+ return (_jsx(_Fragment, { children: nodes.map((node, at) => (_jsx(Fragment, { children: node.type === "text" ? (renderText === undefined ? node.value : renderText(node.value, node.source)) : node.type === "code" ? (_jsx("code", { children: node.value })) : node.type === "strong" ? (_jsx("strong", { children: _jsx(InlineNodes, { nodes: node.children, renderText: renderText, links: links }) })) : node.type === "emphasis" ? (_jsx("em", { children: _jsx(InlineNodes, { nodes: node.children, renderText: renderText, links: links }) })) : node.type === "strike" ? (_jsx("s", { children: _jsx(InlineNodes, { nodes: node.children, renderText: renderText, links: links }) })) : node.type === "break" ? (_jsx("br", {})) : node.type === "image" ? (_jsx("span", { className: "ah-md__image", title: node.src, children: node.alt === "" ? node.src : node.alt })) : (_jsx(LinkOrText, { node: node, links: links })) }, at))) }));
33
33
  }
34
- /** A link the shell can open, or the text it was going to be. */
35
- function LinkOrText({ node }) {
34
+ /** A link the shell can open, or the text it was going to be. Inert, every
35
+ * link is its words: no address on hover, nothing to press. */
36
+ function LinkOrText({ node, links }) {
37
+ if (links === "inert") {
38
+ return (_jsx("span", { className: "ah-md__deadlink", children: _jsx(InlineNodes, { nodes: node.children, links: links }) }));
39
+ }
36
40
  const href = safeHref(node.href);
37
41
  if (href === null) {
38
- return (_jsx("span", { className: "ah-md__deadlink", title: node.href, children: _jsx(InlineNodes, { nodes: node.children }) }));
42
+ return (_jsx("span", { className: "ah-md__deadlink", title: node.href, children: _jsx(InlineNodes, { nodes: node.children, links: links }) }));
39
43
  }
40
44
  // The shell's window-open handler sends http(s) to the browser; the room
41
45
  // itself never navigates away.
42
- return (_jsx("a", { href: href, target: "_blank", rel: "noreferrer", children: _jsx(InlineNodes, { nodes: node.children }) }));
46
+ return (_jsx("a", { href: href, target: "_blank", rel: "noreferrer", children: _jsx(InlineNodes, { nodes: node.children, links: links }) }));
43
47
  }
44
48
  function CodeFence({ language, text }) {
45
49
  // A fence names its language the way a file name does, so the same table
@@ -49,30 +53,30 @@ function CodeFence({ language, text }) {
49
53
  const lines = highlight(text, resolved);
50
54
  return (_jsx("pre", { className: "ah-md__code", "data-language": language ?? undefined, children: _jsx("code", { children: lines.map((line, row) => (_jsxs(Fragment, { children: [row > 0 && "\n", line.map((token, at) => token.kind === "plain" ? (_jsx(Fragment, { children: token.text }, at)) : (_jsx("span", { "data-t": token.kind, children: token.text }, at)))] }, row))) }) }));
51
55
  }
52
- export function MarkdownBlocks({ blocks, renderText, }) {
56
+ export function MarkdownBlocks({ blocks, renderText, links = "open", }) {
53
57
  return (_jsx(_Fragment, { children: blocks.map((block, at) => {
54
58
  switch (block.type) {
55
59
  case "heading": {
56
60
  const Tag = `h${Math.min(block.level, 6)}`;
57
- return (_jsx(Tag, { children: _jsx(InlineNodes, { nodes: block.children, renderText: renderText }) }, at));
61
+ return (_jsx(Tag, { children: _jsx(InlineNodes, { nodes: block.children, renderText: renderText, links: links }) }, at));
58
62
  }
59
63
  case "paragraph":
60
- return (_jsx("p", { children: _jsx(InlineNodes, { nodes: block.children, renderText: renderText }) }, at));
64
+ return (_jsx("p", { children: _jsx(InlineNodes, { nodes: block.children, renderText: renderText, links: links }) }, at));
61
65
  case "code":
62
66
  return _jsx(CodeFence, { language: block.language, text: block.text }, at);
63
67
  case "quote":
64
- return (_jsx("blockquote", { children: _jsx(MarkdownBlocks, { blocks: block.children, renderText: renderText }) }, at));
68
+ return (_jsx("blockquote", { children: _jsx(MarkdownBlocks, { blocks: block.children, renderText: renderText, links: links }) }, at));
65
69
  case "rule":
66
70
  return _jsx("hr", {}, at);
67
71
  case "list": {
68
- const items = block.items.map((item, index) => (_jsx("li", { children: _jsx(MarkdownBlocks, { blocks: item, renderText: renderText }) }, index)));
72
+ const items = block.items.map((item, index) => (_jsx("li", { children: _jsx(MarkdownBlocks, { blocks: item, renderText: renderText, links: links }) }, index)));
69
73
  return block.ordered ? (_jsx("ol", { start: block.start, "data-tight": block.tight ? "" : undefined, children: items }, at)) : (_jsx("ul", { "data-tight": block.tight ? "" : undefined, children: items }, at));
70
74
  }
71
75
  case "table":
72
76
  return (
73
77
  // A wide table scrolls inside its own box; the document's
74
78
  // measure is not the table's to widen.
75
- _jsx("div", { className: "ah-md__tablebox", children: _jsxs("table", { children: [_jsx("thead", { children: _jsx("tr", { children: block.head.map((cell, column) => (_jsx("th", { style: { textAlign: block.align[column] ?? undefined }, children: _jsx(InlineNodes, { nodes: cell, renderText: renderText }) }, column))) }) }), _jsx("tbody", { children: block.rows.map((row, index) => (_jsx("tr", { children: row.map((cell, column) => (_jsx("td", { style: { textAlign: block.align[column] ?? undefined }, children: _jsx(InlineNodes, { nodes: cell, renderText: renderText }) }, column))) }, index))) })] }) }, at));
79
+ _jsx("div", { className: "ah-md__tablebox", children: _jsxs("table", { children: [_jsx("thead", { children: _jsx("tr", { children: block.head.map((cell, column) => (_jsx("th", { style: { textAlign: block.align[column] ?? undefined }, children: _jsx(InlineNodes, { nodes: cell, renderText: renderText, links: links }) }, column))) }) }), _jsx("tbody", { children: block.rows.map((row, index) => (_jsx("tr", { children: row.map((cell, column) => (_jsx("td", { style: { textAlign: block.align[column] ?? undefined }, children: _jsx(InlineNodes, { nodes: cell, renderText: renderText, links: links }) }, column))) }, index))) })] }) }, at));
76
80
  }
77
81
  }) }));
78
82
  }
@@ -8,8 +8,8 @@ export declare const BINARY_KIND: FileKind;
8
8
  * caller knows which act it is serving.
9
9
  */
10
10
  export declare function diffKind(name: string): FileKind;
11
- /** What a file name says the file is. Extension only — see `syntax/languages`
12
- * for why the bytes get no vote here. */
11
+ /** What a file name says the file is, and the view that draws it. Extension
12
+ * only — see `syntax/languages` for why the bytes get no vote here. */
13
13
  export declare function resolveKind(name: string): FileKind;
14
14
  /** Only for a source-proven image slot; extensionless tool captures need the
15
15
  * same format hint whether opened from a loaded tile or reached with Next. */
@@ -1,10 +1,12 @@
1
1
  // Which view a file gets, and what the dialog is allowed to do with it.
2
2
  //
3
- // One table, read once per open. Adding a format is an entry here — never a
4
- // branch inside a view, and never a condition in the dialog, which is the
5
- // point of the whole arrangement: the dialog knows there are views, and it
6
- // does not know what any of them are.
7
- import { extensionOf, languageFor, PLAIN_TEXT } from "./syntax/index.js";
3
+ // Two tables, read once per open: what a name says a file is (`kinds.ts`,
4
+ // which imports no view) and the view that draws each kind (here). Adding a
5
+ // format is an entry in them — never a branch inside a view, and never a
6
+ // condition in the dialog, which is the point of the whole arrangement: the
7
+ // dialog knows there are views, and it does not know what any of them are.
8
+ import { languageFor } from "./syntax/index.js";
9
+ import { kindOfName } from "./kinds.js";
8
10
  import { BinaryView } from "./views/BinaryView.js";
9
11
  import { CodeView } from "./views/CodeView.js";
10
12
  import { DiffView } from "./views/DiffView.js";
@@ -81,43 +83,21 @@ const BINARY = {
81
83
  actions: ["copy-path"],
82
84
  Body: BinaryView,
83
85
  };
84
- const IMAGE_TYPES = new Map([
85
- ["png", "image/png"],
86
- ["jpg", "image/jpeg"],
87
- ["jpeg", "image/jpeg"],
88
- ["gif", "image/gif"],
89
- ["webp", "image/webp"],
90
- ["avif", "image/avif"],
91
- ["bmp", "image/bmp"],
92
- ["ico", "image/x-icon"],
93
- ["apng", "image/apng"],
94
- ]);
95
- /** Extensions worth refusing to decode as text before reading a byte. An
96
- * unknown extension is NOT on this list: it is read as text and downgraded if
97
- * the bytes disagree, because most unfamiliar extensions in a repository are
98
- * somebody's config file. */
99
- const BINARY_EXTENSIONS = new Set([
100
- "zip", "gz", "tgz", "bz2", "xz", "zst", "7z", "rar", "tar", "jar", "war",
101
- "pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "key", "numbers", "pages",
102
- "so", "dylib", "dll", "a", "o", "obj", "exe", "bin", "wasm", "node", "rlib", "pdb",
103
- "woff", "woff2", "ttf", "otf", "eot",
104
- "mp3", "mp4", "m4a", "wav", "aiff", "flac", "ogg", "webm", "mov", "avi", "mkv",
105
- "db", "sqlite", "sqlite3", "rdb", "pack", "idx", "class", "pyc", "pyo",
106
- "psd", "sketch", "fig", "ai", "heic", "tiff", "tif", "dmg", "iso", "img",
107
- ]);
86
+ /** The view that draws each kind a name can say. */
87
+ const VIEWER_OF = {
88
+ code: CODE,
89
+ html: HTML,
90
+ markdown: MARKDOWN,
91
+ image: IMAGE,
92
+ svg: SVG,
93
+ binary: BINARY,
94
+ };
108
95
  export const BINARY_KIND = {
109
96
  viewer: BINARY,
110
97
  label: "Binary",
111
98
  language: null,
112
99
  mime: null,
113
100
  };
114
- /** Text with no language behind it: read, shown, nothing claimed about it. */
115
- const UNKNOWN_TEXT_KIND = {
116
- viewer: CODE,
117
- label: "Text",
118
- language: PLAIN_TEXT,
119
- mime: null,
120
- };
121
101
  /**
122
102
  * The kind for a change rather than a file.
123
103
  *
@@ -128,30 +108,11 @@ const UNKNOWN_TEXT_KIND = {
128
108
  export function diffKind(name) {
129
109
  return { viewer: DIFF, label: "Diff", language: languageFor(name), mime: null };
130
110
  }
131
- /** What a file name says the file is. Extension only — see `syntax/languages`
132
- * for why the bytes get no vote here. */
111
+ /** What a file name says the file is, and the view that draws it. Extension
112
+ * only — see `syntax/languages` for why the bytes get no vote here. */
133
113
  export function resolveKind(name) {
134
- const extension = extensionOf(name);
135
- if (extension === "svg") {
136
- return { viewer: SVG, label: "SVG", language: languageFor(name), mime: "image/svg+xml" };
137
- }
138
- const mime = IMAGE_TYPES.get(extension);
139
- if (mime !== undefined) {
140
- return { viewer: IMAGE, label: extension.toUpperCase(), language: null, mime };
141
- }
142
- if (BINARY_EXTENSIONS.has(extension)) {
143
- return { ...BINARY_KIND, label: extension === "" ? "Binary" : extension.toUpperCase() };
144
- }
145
- const language = languageFor(name);
146
- if (language === null)
147
- return UNKNOWN_TEXT_KIND;
148
- if (language.id === "markdown") {
149
- return { viewer: MARKDOWN, label: language.label, language, mime: null };
150
- }
151
- if (language.id === "html") {
152
- return { viewer: HTML, label: language.label, language, mime: "text/html" };
153
- }
154
- return { viewer: CODE, label: language.label, language, mime: null };
114
+ const kind = kindOfName(name);
115
+ return { viewer: VIEWER_OF[kind.viewer], label: kind.label, language: kind.language, mime: kind.mime };
155
116
  }
156
117
  /** Only for a source-proven image slot; extensionless tool captures need the
157
118
  * same format hint whether opened from a loaded tile or reached with Next. */
@@ -5,21 +5,27 @@ import type { AttachmentFact, Segment } from "../../lib/transcript/index.js";
5
5
  import type { EarlierState } from "../../lib/transcript/head-state.js";
6
6
  import "../../styles/transcript-activity.css";
7
7
  export declare function revealActivityTarget(element: HTMLElement): void;
8
- export declare function ActivityGroup({ items, rows, partial, forceOpen, highlightedId, alive, onOpenAttachment, onReceipt, earlier, onLoadEarlier, teamLoading, teamError, onRetryTeam, children }: {
8
+ /** A run's head, its rail and its list. The list draws its children only while
9
+ * the run is open: a closed run mounts none of its rows, so `children` is a
10
+ * function the group calls when it opens. */
11
+ export declare function ActivityGroup({ items, rows, partial, force, highlightedId, alive, onOpenAttachment, onReceipt, earlier, onLoadEarlier, teamLoading, teamError, onRetryTeam, children }: {
9
12
  readonly items: readonly ActivityItem[];
10
13
  readonly rows: readonly TimelineEntry[];
11
14
  readonly partial: boolean;
12
- readonly earlier: EarlierState;
15
+ readonly earlier: EarlierState["kind"];
13
16
  readonly onLoadEarlier: () => void;
14
17
  readonly teamLoading: boolean;
15
18
  readonly teamError: string | null;
16
19
  readonly onRetryTeam: () => void;
17
- readonly forceOpen: boolean;
20
+ /** The forces standing on this run besides a highlight (a landing, a search
21
+ * hit inside a worker, a revealed worker), each named so that another one
22
+ * reads as new; null when none stands. */
23
+ readonly force: string | null;
18
24
  readonly highlightedId: string | null;
19
25
  readonly alive: (row: TimelineEntry) => boolean;
20
26
  readonly onOpenAttachment: (fact: AttachmentFact, row?: readonly AttachmentFact[]) => void;
21
27
  readonly onReceipt: (text: string) => void;
22
- readonly children: ReactNode;
28
+ readonly children: () => ReactNode;
23
29
  }): import("react").JSX.Element;
24
30
  /** The second disclosure is independent of the room's outer fold preference. */
25
31
  export declare function ActivityEvent({ domId, timelineId, label, summary, at, glyph, hit, forceOpen, failed, children }: {
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useEffect, useId, useMemo, useRef } from "react";
2
+ import { useEffect, useId, useMemo, useRef, useState } from "react";
3
3
  import { clock } from "../../lib/format.js";
4
4
  import { activityRowKey, summarizeActivity } from "./activity-plan.js";
5
5
  import { useGroupDisclosure, useRowDisclosure } from "./disclosure-state.js";
@@ -20,19 +20,38 @@ export function revealActivityTarget(element) {
20
20
  : element.querySelector("summary, button, [tabindex]");
21
21
  target?.focus({ preventScroll: true });
22
22
  }
23
- export function ActivityGroup({ items, rows, partial, forceOpen, highlightedId, alive, onOpenAttachment, onReceipt, earlier, onLoadEarlier, teamLoading, teamError, onRetryTeam, children }) {
23
+ function nextForced(held, force) {
24
+ if (held.force === force)
25
+ return held;
26
+ if (force !== null)
27
+ return { force, open: true, pressed: held.force !== null && held.pressed, carry: false };
28
+ return { force: null, open: false, pressed: false, carry: !held.pressed };
29
+ }
30
+ /** A run's head, its rail and its list. The list draws its children only while
31
+ * the run is open: a closed run mounts none of its rows, so `children` is a
32
+ * function the group calls when it opens. */
33
+ export function ActivityGroup({ items, rows, partial, force, highlightedId, alive, onOpenAttachment, onReceipt, earlier, onLoadEarlier, teamLoading, teamError, onRetryTeam, children }) {
24
34
  const preference = useFoldPreference();
25
- const keys = rows.map(activityRowKey);
35
+ const keys = useMemo(() => rows.map(activityRowKey), [rows]);
26
36
  const [override, setOverride] = useGroupDisclosure(keys, preference.revision);
27
- const expanded = override ?? (!preference.folded || forceOpen || highlightedId !== null);
37
+ const standing = highlightedId === null ? force : `${force === null ? "" : `${force} `}hit:${highlightedId}`;
38
+ // Worked out in render, never by an effect: a search landing inside a run the
39
+ // reader closed finds its row's element in the commit that lands, since a
40
+ // closed run has none.
41
+ const [held, setHeld] = useState(() => ({ force: standing, open: standing !== null, pressed: false, carry: false }));
42
+ const forced = nextForced(held, standing);
43
+ if (forced !== held)
44
+ setHeld(forced);
45
+ const expanded = forced.force !== null ? forced.open : forced.carry || (override ?? !preference.folded);
28
46
  const listId = useId();
29
47
  const root = useRef(null);
30
48
  useEffect(() => {
31
- if (forceOpen || highlightedId !== null)
32
- setOverride(true);
33
- // Arrival patches change keys, but must not reopen a deliberately shut run.
34
- // eslint-disable-next-line react-hooks/exhaustive-deps
35
- }, [forceOpen, highlightedId]);
49
+ if (!forced.carry)
50
+ return;
51
+ // The run stays open in render already; this makes that open the store's.
52
+ setOverride(true);
53
+ setHeld(current => current.carry ? { ...current, carry: false } : current);
54
+ }, [forced.carry, setOverride]);
36
55
  useEffect(() => {
37
56
  if (highlightedId === null || !expanded)
38
57
  return;
@@ -56,8 +75,14 @@ export function ActivityGroup({ items, rows, partial, forceOpen, highlightedId,
56
75
  return _jsxs("div", { className: "tr-seg tr-activity", ref: root, "data-partial": partial || undefined, children: [_jsxs("button", { type: "button", className: "tr-line tr-fold tr-activity__head", "aria-expanded": expanded, "aria-controls": listId, "aria-label": label, title: label, onClick: () => {
57
76
  if (!expanded && partial)
58
77
  onLoadEarlier();
59
- setOverride(!expanded);
60
- }, children: [_jsx("span", { className: "tr-line__g chev", children: _jsx(LineChevron, {}) }), _jsxs("span", { className: "tr-line__v", children: [partial && _jsx("span", { children: "More activity to load \u00B7 " }), teamLoading && _jsx("span", { children: "Loading team activity \u00B7 " }), summary.nouns.map((noun, index) => _jsxs("span", { children: [index > 0 && " · ", noun.text, noun.names.length > 0 && _jsxs(_Fragment, { children: [" ", _jsxs("span", { className: "names", children: [noun.names.join(", "), noun.more > 0 ? ` … ${noun.more} more` : ""] })] })] }, noun.key))] }), _jsxs("span", { className: "tr-line__r", children: [summary.failed > 0 && _jsxs("b", { children: [summary.failed, " failed"] }), summary.interrupted > 0 && _jsxs("span", { children: [summary.interrupted, " interrupted"] }), summary.cancelled > 0 && _jsxs("span", { children: [summary.cancelled, " cancelled"] }), running && _jsxs("span", { className: "tr-activity__running", children: [_jsx("i", { "aria-hidden": "true" }), "Running"] }), range !== null && _jsx("span", { className: "t", children: range })] })] }), _jsx(Attachments, { facts: images, onOpenAttachment: openImage, reveal: reveal }), _jsx(ActivityImagesContext.Provider, { value: openImage, children: _jsxs("div", { id: listId, className: "tr-activity__list", hidden: !expanded, children: [partial && _jsx("div", { className: "tr-activity__loading", role: "status", children: earlier.kind === "fetching" || earlier.kind === "revealing" ? "Loading earlier activity…" : _jsxs(_Fragment, { children: [_jsx("span", { children: earlier.kind === "failed" ? "Could not load earlier activity." : "This activity continues in earlier history." }), _jsx("button", { type: "button", onClick: onLoadEarlier, children: earlier.kind === "failed" ? "Retry" : "Load more activity" })] }) }), (teamLoading || teamError !== null) && _jsxs("div", { className: "tr-activity__loading", role: "status", children: [_jsx("span", { children: teamError !== null ? "Could not load team messages." : "Loading team messages…" }), teamError !== null && _jsx("button", { type: "button", onClick: onRetryTeam, children: "Retry" })] }), children] }) })] });
78
+ if (forced.force !== null)
79
+ setHeld({ ...forced, open: !expanded, pressed: true });
80
+ else {
81
+ setOverride(!expanded);
82
+ if (forced.carry)
83
+ setHeld({ ...forced, carry: false });
84
+ }
85
+ }, children: [_jsx("span", { className: "tr-line__g chev", children: _jsx(LineChevron, {}) }), _jsxs("span", { className: "tr-line__v", children: [partial && _jsx("span", { children: "More activity to load \u00B7 " }), teamLoading && _jsx("span", { children: "Loading team activity \u00B7 " }), summary.nouns.map((noun, index) => _jsxs("span", { children: [index > 0 && " · ", noun.text, noun.names.length > 0 && _jsxs(_Fragment, { children: [" ", _jsxs("span", { className: "names", children: [noun.names.join(", "), noun.more > 0 ? ` … ${noun.more} more` : ""] })] })] }, noun.key))] }), _jsxs("span", { className: "tr-line__r", children: [summary.failed > 0 && _jsxs("b", { children: [summary.failed, " failed"] }), summary.interrupted > 0 && _jsxs("span", { children: [summary.interrupted, " interrupted"] }), summary.cancelled > 0 && _jsxs("span", { children: [summary.cancelled, " cancelled"] }), running && _jsxs("span", { className: "tr-activity__running", children: [_jsx("i", { "aria-hidden": "true" }), "Running"] }), range !== null && _jsx("span", { className: "t", children: range })] })] }), _jsx(Attachments, { facts: images, onOpenAttachment: openImage, reveal: reveal }), _jsx(ActivityImagesContext.Provider, { value: openImage, children: _jsx("div", { id: listId, className: "tr-activity__list", hidden: !expanded, children: expanded && _jsxs(_Fragment, { children: [partial && _jsx("div", { className: "tr-activity__loading", role: "status", children: earlier === "fetching" || earlier === "revealing" ? "Loading earlier activity…" : _jsxs(_Fragment, { children: [_jsx("span", { children: earlier === "failed" ? "Could not load earlier activity." : "This activity continues in earlier history." }), _jsx("button", { type: "button", onClick: onLoadEarlier, children: earlier === "failed" ? "Retry" : "Load more activity" })] }) }), (teamLoading || teamError !== null) && _jsxs("div", { className: "tr-activity__loading", role: "status", children: [_jsx("span", { children: teamError !== null ? "Could not load team messages." : "Loading team messages…" }), teamError !== null && _jsx("button", { type: "button", onClick: onRetryTeam, children: "Retry" })] }), children()] }) }) })] });
61
86
  }
62
87
  /** The second disclosure is independent of the room's outer fold preference. */
63
88
  export function ActivityEvent({ domId, timelineId, label, summary, at, glyph, hit = false, forceOpen = false, failed = false, children }) {
@@ -1,4 +1,13 @@
1
1
  import type { CanonicalText } from "@vibefield/rosetta-protocol";
2
+ /** Loaded only on disclosure. Oversized summaries are content-addressed;
3
+ * their preview must never be presented or copied as the complete recap. A
4
+ * stored summary is read through the reading session's client. */
5
+ export declare function SummaryBody({ canonical, messageKey, matched, onReceipt, }: {
6
+ readonly canonical: CanonicalText;
7
+ readonly messageKey: string;
8
+ readonly matched: boolean;
9
+ readonly onReceipt: (message: string) => void;
10
+ }): import("react").JSX.Element;
2
11
  export declare function Compaction({ text, domId, timelineId, hit, forceOpen, onReceipt, }: {
3
12
  readonly text: CanonicalText;
4
13
  readonly domId: string;
@@ -1,16 +1,20 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // §03 G — generated continuation context belongs to the system marker.
3
+ //
4
+ // The marker and its body read the parts' own context, never the room's: the
5
+ // body is drawn by History's reader and by a view with no room around it.
3
6
  import { useEffect, useState } from "react";
4
- import { useCopyText, useReadingSession, useRoom } from "../../room-context.js";
7
+ import { useCopyText, useParts, useReadingSession } from "../../parts-context.js";
5
8
  import { MessagePreview } from "./MessagePreview.js";
6
9
  import { LineChevron } from "./glyphs.js";
7
10
  import { useRowDisclosure } from "./disclosure-state.js";
8
11
  /** Loaded only on disclosure. Oversized summaries are content-addressed;
9
- * their preview must never be presented or copied as the complete recap. */
10
- function SummaryBody({ canonical, messageKey, matched, onReceipt, }) {
12
+ * their preview must never be presented or copied as the complete recap. A
13
+ * stored summary is read through the reading session's client. */
14
+ export function SummaryBody({ canonical, messageKey, matched, onReceipt, }) {
11
15
  const [loaded, setLoaded] = useState(null);
12
16
  const [attempt, setAttempt] = useState(0);
13
- const { sessions } = useRoom();
17
+ const { sessions } = useParts();
14
18
  const copy = useCopyText();
15
19
  const readingSession = useReadingSession();
16
20
  useEffect(() => {