@vibefield/rosetta-room 0.1.1 → 0.1.3

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 (115) hide show
  1. package/README.md +82 -4
  2. package/dist/HistoryRoom.d.ts +15 -2
  3. package/dist/HistoryRoom.js +84 -27
  4. package/dist/TranscriptReader.d.ts +7 -0
  5. package/dist/TranscriptReader.js +4 -4
  6. package/dist/components/ColdStart.js +1 -1
  7. package/dist/components/IngestStatus.d.ts +13 -0
  8. package/dist/components/IngestStatus.js +40 -3
  9. package/dist/components/IngestionControls.d.ts +6 -0
  10. package/dist/components/IngestionControls.js +75 -0
  11. package/dist/components/ListActivityNotice.d.ts +9 -1
  12. package/dist/components/ListActivityNotice.js +9 -2
  13. package/dist/components/SummaryPanels.d.ts +5 -0
  14. package/dist/components/SummaryPanels.js +16 -5
  15. package/dist/components/Transcript.d.ts +5 -0
  16. package/dist/components/Transcript.js +20 -5
  17. package/dist/components/artifacts/ArtifactLibrary.d.ts +14 -0
  18. package/dist/components/artifacts/ArtifactLibrary.js +156 -0
  19. package/dist/components/artifacts/content.d.ts +8 -0
  20. package/dist/components/artifacts/content.js +27 -0
  21. package/dist/components/artifacts/load-all.d.ts +5 -0
  22. package/dist/components/artifacts/load-all.js +31 -0
  23. package/dist/components/artifacts/preview.d.ts +4 -0
  24. package/dist/components/artifacts/preview.js +37 -0
  25. package/dist/components/artifacts/thumbnails.d.ts +13 -0
  26. package/dist/components/artifacts/thumbnails.js +43 -0
  27. package/dist/components/projects/ProjectList.d.ts +9 -3
  28. package/dist/components/projects/ProjectList.js +3 -3
  29. package/dist/components/projects/ProjectListItem.d.ts +9 -3
  30. package/dist/components/projects/ProjectListItem.js +18 -12
  31. package/dist/components/projects/ProjectsColumn.d.ts +4 -1
  32. package/dist/components/projects/ProjectsColumn.js +23 -9
  33. package/dist/components/search/SearchSheet.d.ts +39 -2
  34. package/dist/components/search/SearchSheet.js +82 -17
  35. package/dist/components/sessions/SessionList.d.ts +6 -1
  36. package/dist/components/sessions/SessionList.js +50 -20
  37. package/dist/components/sessions/SessionListItem.d.ts +3 -1
  38. package/dist/components/sessions/SessionListItem.js +17 -7
  39. package/dist/components/sessions/SessionsColumn.d.ts +3 -1
  40. package/dist/components/sessions/SessionsColumn.js +2 -2
  41. package/dist/components/sessions/session-display.d.ts +4 -1
  42. package/dist/components/sessions/session-display.js +13 -2
  43. package/dist/components/transcript/Attachments.js +6 -1
  44. package/dist/components/transcript/Document.d.ts +6 -1
  45. package/dist/components/transcript/Document.js +19 -6
  46. package/dist/components/transcript/ImportState.d.ts +35 -0
  47. package/dist/components/transcript/ImportState.js +86 -0
  48. package/dist/components/transcript/TranscriptLoading.js +15 -5
  49. package/dist/components/transcript/attachment-file-source.d.ts +2 -0
  50. package/dist/components/transcript/attachment-file-source.js +6 -6
  51. package/dist/components/transcript/attachment-gallery.d.ts +2 -1
  52. package/dist/components/transcript/attachment-gallery.js +2 -1
  53. package/dist/components/transcript/detail-parts.js +7 -6
  54. package/dist/components/transcript/timeline-meta-file-source.d.ts +2 -1
  55. package/dist/components/transcript/timeline-meta-file-source.js +45 -5
  56. package/dist/components/ui/EmptyState.d.ts +5 -1
  57. package/dist/components/ui/EmptyState.js +2 -2
  58. package/dist/components/ui/Meter.d.ts +8 -0
  59. package/dist/components/ui/Meter.js +9 -0
  60. package/dist/components/ui/SegmentedControl.d.ts +2 -0
  61. package/dist/components/ui/SegmentedControl.js +1 -1
  62. package/dist/components/ui/Veil.d.ts +2 -1
  63. package/dist/components/ui/Veil.js +9 -2
  64. package/dist/components/ui/index.d.ts +2 -0
  65. package/dist/components/ui/index.js +1 -0
  66. package/dist/fixtures/cold-import-corpus.d.ts +76 -0
  67. package/dist/fixtures/cold-import-corpus.js +349 -0
  68. package/dist/fixtures/cold-import-daemon.d.ts +25 -0
  69. package/dist/fixtures/cold-import-daemon.js +82 -0
  70. package/dist/fixtures/cold-import-schedule.d.ts +74 -0
  71. package/dist/fixtures/cold-import-schedule.js +191 -0
  72. package/dist/fixtures/cold-import.d.ts +151 -0
  73. package/dist/fixtures/cold-import.js +786 -0
  74. package/dist/fixtures/index.d.ts +2 -0
  75. package/dist/fixtures/index.js +21 -2
  76. package/dist/index.d.ts +1 -1
  77. package/dist/index.js +5 -0
  78. package/dist/lib/activity-order.d.ts +15 -0
  79. package/dist/lib/activity-order.js +24 -1
  80. package/dist/lib/conversation-readiness.d.ts +48 -0
  81. package/dist/lib/conversation-readiness.js +149 -0
  82. package/dist/lib/figure-order.d.ts +35 -0
  83. package/dist/lib/figure-order.js +68 -0
  84. package/dist/lib/hooks.d.ts +32 -10
  85. package/dist/lib/hooks.js +122 -55
  86. package/dist/lib/image-media.d.ts +12 -2
  87. package/dist/lib/image-media.js +40 -6
  88. package/dist/lib/import-state.d.ts +98 -0
  89. package/dist/lib/import-state.js +129 -0
  90. package/dist/lib/ingest-activity.d.ts +52 -0
  91. package/dist/lib/ingest-activity.js +127 -12
  92. package/dist/lib/ingest.d.ts +3 -0
  93. package/dist/lib/ingest.js +10 -0
  94. package/dist/lib/model.d.ts +16 -0
  95. package/dist/lib/model.js +27 -1
  96. package/dist/lib/search-sheet.d.ts +43 -0
  97. package/dist/lib/search-sheet.js +56 -7
  98. package/dist/lib/session-activity.d.ts +4 -1
  99. package/dist/lib/session-activity.js +4 -1
  100. package/dist/lib/title-search.d.ts +82 -0
  101. package/dist/lib/title-search.js +194 -0
  102. package/dist/lib/transcript/images.js +2 -2
  103. package/dist/lib/use-deferred-list-order.d.ts +6 -0
  104. package/dist/lib/use-deferred-list-order.js +8 -1
  105. package/dist/lib/use-ingest-activity.d.ts +5 -1
  106. package/dist/lib/use-ingest-activity.js +56 -20
  107. package/dist/ports.d.ts +21 -2
  108. package/dist/room-context.d.ts +1 -0
  109. package/dist/room-context.js +3 -2
  110. package/dist/styles/artifacts.css +66 -0
  111. package/dist/styles/history-room.css +1 -0
  112. package/dist/styles/ingest.css +32 -3
  113. package/dist/styles/room.css +15 -0
  114. package/dist/styles/search.css +17 -0
  115. package/package.json +2 -2
@@ -0,0 +1,82 @@
1
+ import type { SearchReadiness, SearchResponse, SessionRow } from "@vibefield/rosetta-protocol";
2
+ import type { ProjectViewModel, SnippetPart } from "./model.js";
3
+ /** The line the sheet prints under title matches during the import. */
4
+ export declare const FULL_TEXT_PENDING = "Full-text search arrives when the import finishes.";
5
+ /** …after publication, while the index builds its first generation. */
6
+ export declare const FULL_TEXT_BUILDING = "Full-text search arrives when its index is built.";
7
+ /** …and when the index failed. */
8
+ export declare const FULL_TEXT_FAILED = "Full-text search is unavailable.";
9
+ /** The line under title matches: what full text is waiting for, never a
10
+ * time. Before publication the import is the gate; after it, the index. */
11
+ export declare function titlesNote(readiness: SearchReadiness | null, canonicalReady: boolean | null): string;
12
+ /** How many titles the sheet can search: top-level conversations that have a
13
+ * name to match. Metadata-only placeholders carry none, so they never count
14
+ * — the same unit the import card counts in (conversations). */
15
+ export declare function searchableTitleCount(sessions: readonly SessionRow[]): number;
16
+ /** How many title matches the sheet lists; the count says when there are more. */
17
+ export declare const TITLE_MATCH_LIMIT = 50;
18
+ /**
19
+ * Full text cannot answer: the canonical projection is unpublished (the
20
+ * daemon answers every query with zero hits and `building`), the detached
21
+ * index has no generation yet (`building`), or the index failed (it serves
22
+ * no hits; crates/search/src/sidecar.rs `serves_hits`). A catching-up index
23
+ * does answer — partially — and keeps the ordinary sheet. Unknown (null) is
24
+ * no claim either way.
25
+ */
26
+ export declare function fullTextUnavailable(readiness: SearchReadiness | null, canonicalReady: boolean | null): boolean;
27
+ /**
28
+ * Titles stand in while full text cannot answer, and after it can, until
29
+ * the answer on screen is one full text gave. The zero hits an unpublished
30
+ * index answered with (`building`) would otherwise read as "nothing matched"
31
+ * in the moment between the import finishing and the re-asked query landing.
32
+ */
33
+ export declare function titlesStandIn(readiness: SearchReadiness | null, canonicalReady: boolean | null, response: SearchResponse | null): boolean;
34
+ /** Lower-cased, accents and other combining marks removed. */
35
+ export declare function foldText(text: string): string;
36
+ /**
37
+ * The query's terms, folded: each word, and a quoted phrase as one term —
38
+ * the sheet's printed grammar ("every word must match", quotes for a
39
+ * phrase), read loosely. A quote left open is just part of a word here.
40
+ * Duplicates fold away; order is kept.
41
+ */
42
+ export declare function titleTerms(query: string): string[];
43
+ /** The name a session's row shows, when it has one to search. */
44
+ export declare function sessionTitleText(session: SessionRow): string | null;
45
+ /**
46
+ * The title as parts, every occurrence of every term marked — the same
47
+ * shape `parseSnippet` gives a full-text hit, so both draw alike.
48
+ */
49
+ export declare function markTitle(title: string, terms: readonly string[]): SnippetPart[];
50
+ export interface TitleMatch {
51
+ /** The DOM id `aria-activedescendant` points at. */
52
+ readonly id: string;
53
+ /** Position in the walkable list. */
54
+ readonly index: number;
55
+ /** A top-level thread — what opening navigates to. */
56
+ readonly session: SessionRow;
57
+ readonly project: ProjectViewModel;
58
+ readonly parts: readonly SnippetPart[];
59
+ }
60
+ export interface TitleMatches {
61
+ readonly matches: readonly TitleMatch[];
62
+ /** Every thread whose title matched, before the cap. */
63
+ readonly total: number;
64
+ }
65
+ /** The sheet's own narrowing, applied to titles. The kind chip (prompts,
66
+ * replies) narrows messages; a title is neither, so it does not apply. */
67
+ export interface TitleScope {
68
+ /** A canonical project id, or null for everywhere. */
69
+ readonly project: string | null;
70
+ /** A runtime family (`claude-code`, …), or null for every agent. */
71
+ readonly agent: string | null;
72
+ readonly runtimeKind: (runtimeId: string) => string;
73
+ }
74
+ export declare function titleOptionId(sessionId: string): string;
75
+ /**
76
+ * Top-level threads whose title contains every term, newest known activity
77
+ * first (the session list's own tie-breaks), capped at `limit`. Threads in a
78
+ * project the room does not show are left out, as full-text hits are.
79
+ */
80
+ export declare function matchSessionTitles(query: string, sessions: readonly SessionRow[], projectsById: ReadonlyMap<string, ProjectViewModel>, scope: TitleScope, limit?: number): TitleMatches;
81
+ /** `3 titles`, or `first 50 of 132 titles` when the list is capped. */
82
+ export declare function titleCountLabel(result: TitleMatches): string;
@@ -0,0 +1,194 @@
1
+ import { projectKey } from "./model.js";
2
+ import { compareSessionActivity } from "./session-activity.js";
3
+ /** The line the sheet prints under title matches during the import. */
4
+ export const FULL_TEXT_PENDING = "Full-text search arrives when the import finishes.";
5
+ /** …after publication, while the index builds its first generation. */
6
+ export const FULL_TEXT_BUILDING = "Full-text search arrives when its index is built.";
7
+ /** …and when the index failed. */
8
+ export const FULL_TEXT_FAILED = "Full-text search is unavailable.";
9
+ /** The line under title matches: what full text is waiting for, never a
10
+ * time. Before publication the import is the gate; after it, the index. */
11
+ export function titlesNote(readiness, canonicalReady) {
12
+ if (canonicalReady === false)
13
+ return FULL_TEXT_PENDING;
14
+ return readiness === "failed" ? FULL_TEXT_FAILED : FULL_TEXT_BUILDING;
15
+ }
16
+ /** How many titles the sheet can search: top-level conversations that have a
17
+ * name to match. Metadata-only placeholders carry none, so they never count
18
+ * — the same unit the import card counts in (conversations). */
19
+ export function searchableTitleCount(sessions) {
20
+ let count = 0;
21
+ for (const session of sessions) {
22
+ if (session.parent_session_id === null && sessionTitleText(session) !== null)
23
+ count += 1;
24
+ }
25
+ return count;
26
+ }
27
+ /** How many title matches the sheet lists; the count says when there are more. */
28
+ export const TITLE_MATCH_LIMIT = 50;
29
+ /**
30
+ * Full text cannot answer: the canonical projection is unpublished (the
31
+ * daemon answers every query with zero hits and `building`), the detached
32
+ * index has no generation yet (`building`), or the index failed (it serves
33
+ * no hits; crates/search/src/sidecar.rs `serves_hits`). A catching-up index
34
+ * does answer — partially — and keeps the ordinary sheet. Unknown (null) is
35
+ * no claim either way.
36
+ */
37
+ export function fullTextUnavailable(readiness, canonicalReady) {
38
+ return canonicalReady === false || readiness === "building" || readiness === "failed";
39
+ }
40
+ /**
41
+ * Titles stand in while full text cannot answer, and after it can, until
42
+ * the answer on screen is one full text gave. The zero hits an unpublished
43
+ * index answered with (`building`) would otherwise read as "nothing matched"
44
+ * in the moment between the import finishing and the re-asked query landing.
45
+ */
46
+ export function titlesStandIn(readiness, canonicalReady, response) {
47
+ return fullTextUnavailable(readiness, canonicalReady) || response?.state.readiness === "building";
48
+ }
49
+ /* ── folding: case- and accent-insensitive, the way the index tokenizes ── */
50
+ const ASCII = /^[\x00-\x7f]*$/;
51
+ const MARKS = /\p{M}+/gu;
52
+ function foldChar(ch) {
53
+ return ch.normalize("NFKD").replace(MARKS, "").toLowerCase();
54
+ }
55
+ function foldUncached(text) {
56
+ if (ASCII.test(text))
57
+ return text.toLowerCase();
58
+ // Code point by code point, so a match maps back onto the original title
59
+ // (`markTitle`) through exactly the same fold.
60
+ let out = "";
61
+ for (const ch of text)
62
+ out += foldChar(ch);
63
+ return out;
64
+ }
65
+ // Titles repeat across every metadata update of an import; folding is a pure
66
+ // function of the text, so a bounded memo keeps keystrokes O(sessions) cheap.
67
+ const FOLD_CACHE_CAP = 65_536;
68
+ const folded = new Map();
69
+ /** Lower-cased, accents and other combining marks removed. */
70
+ export function foldText(text) {
71
+ const hit = folded.get(text);
72
+ if (hit !== undefined)
73
+ return hit;
74
+ const value = foldUncached(text);
75
+ if (folded.size >= FOLD_CACHE_CAP)
76
+ folded.clear();
77
+ folded.set(text, value);
78
+ return value;
79
+ }
80
+ /**
81
+ * The query's terms, folded: each word, and a quoted phrase as one term —
82
+ * the sheet's printed grammar ("every word must match", quotes for a
83
+ * phrase), read loosely. A quote left open is just part of a word here.
84
+ * Duplicates fold away; order is kept.
85
+ */
86
+ export function titleTerms(query) {
87
+ const terms = [];
88
+ for (const match of query.matchAll(/"([^"]*)"|(\S+)/g)) {
89
+ const raw = match[1] ?? match[2].replace(/^"+|"+$/g, "");
90
+ const term = foldText(raw.trim());
91
+ if (term !== "" && !terms.includes(term))
92
+ terms.push(term);
93
+ }
94
+ return terms;
95
+ }
96
+ /** The name a session's row shows, when it has one to search. */
97
+ export function sessionTitleText(session) {
98
+ return session.title ?? session.summary;
99
+ }
100
+ /**
101
+ * The title as parts, every occurrence of every term marked — the same
102
+ * shape `parseSnippet` gives a full-text hit, so both draw alike.
103
+ */
104
+ export function markTitle(title, terms) {
105
+ let foldedTitle = "";
106
+ const from = [];
107
+ const to = [];
108
+ for (let at = 0; at < title.length;) {
109
+ const ch = String.fromCodePoint(title.codePointAt(at));
110
+ const fold = ASCII.test(ch) ? ch.toLowerCase() : foldChar(ch);
111
+ for (let unit = 0; unit < fold.length; unit += 1) {
112
+ from.push(at);
113
+ to.push(at + ch.length);
114
+ }
115
+ foldedTitle += fold;
116
+ at += ch.length;
117
+ }
118
+ const ranges = [];
119
+ for (const term of terms) {
120
+ for (let at = foldedTitle.indexOf(term); at !== -1; at = foldedTitle.indexOf(term, at + 1)) {
121
+ ranges.push([from[at], to[at + term.length - 1]]);
122
+ }
123
+ }
124
+ ranges.sort((left, right) => left[0] - right[0] || left[1] - right[1]);
125
+ const merged = [];
126
+ for (const range of ranges) {
127
+ const last = merged[merged.length - 1];
128
+ if (last !== undefined && range[0] <= last[1])
129
+ last[1] = Math.max(last[1], range[1]);
130
+ else
131
+ merged.push([range[0], range[1]]);
132
+ }
133
+ const parts = [];
134
+ let cursor = 0;
135
+ for (const [start, end] of merged) {
136
+ if (start > cursor)
137
+ parts.push({ text: title.slice(cursor, start), mark: false });
138
+ parts.push({ text: title.slice(start, end), mark: true });
139
+ cursor = end;
140
+ }
141
+ if (cursor < title.length)
142
+ parts.push({ text: title.slice(cursor), mark: false });
143
+ return parts;
144
+ }
145
+ export function titleOptionId(sessionId) {
146
+ return `ah-sheet-title-${sessionId}`;
147
+ }
148
+ /**
149
+ * Top-level threads whose title contains every term, newest known activity
150
+ * first (the session list's own tie-breaks), capped at `limit`. Threads in a
151
+ * project the room does not show are left out, as full-text hits are.
152
+ */
153
+ export function matchSessionTitles(query, sessions, projectsById, scope, limit = TITLE_MATCH_LIMIT) {
154
+ const terms = titleTerms(query);
155
+ if (terms.length === 0)
156
+ return { matches: [], total: 0 };
157
+ const found = [];
158
+ for (const session of sessions) {
159
+ if (session.parent_session_id !== null)
160
+ continue;
161
+ const title = sessionTitleText(session);
162
+ if (title === null)
163
+ continue;
164
+ const key = projectKey(session);
165
+ if (scope.project !== null && key !== scope.project)
166
+ continue;
167
+ if (scope.agent !== null && scope.runtimeKind(session.runtime_id) !== scope.agent)
168
+ continue;
169
+ const text = foldText(title);
170
+ if (!terms.every((term) => text.includes(term)))
171
+ continue;
172
+ const project = projectsById.get(key);
173
+ if (project === undefined)
174
+ continue;
175
+ found.push({ session, project, title });
176
+ }
177
+ found.sort((left, right) => compareSessionActivity(left.session, right.session));
178
+ const matches = found.slice(0, Math.max(0, limit)).map(({ session, project, title }, index) => ({
179
+ id: titleOptionId(session.id),
180
+ index,
181
+ session,
182
+ project,
183
+ parts: markTitle(title, terms),
184
+ }));
185
+ return { matches, total: found.length };
186
+ }
187
+ /** `3 titles`, or `first 50 of 132 titles` when the list is capped. */
188
+ export function titleCountLabel(result) {
189
+ const total = result.total.toLocaleString("en-US");
190
+ const noun = result.total === 1 ? "title" : "titles";
191
+ return result.matches.length < result.total
192
+ ? `first ${result.matches.length.toLocaleString("en-US")} of ${total} ${noun}`
193
+ : `${total} ${noun}`;
194
+ }
@@ -1,7 +1,7 @@
1
1
  import { projectAction } from "./families.js";
2
2
  import { readAttachments } from "./turns.js";
3
3
  import { resourceLabel, splitPath } from "./vocabulary.js";
4
- import { isOptimizedImageAsset } from "../image-media.js";
4
+ import { isRecordedImageAsset } from "../image-media.js";
5
5
  function resourcePath(resource) {
6
6
  const label = resourceLabel(resource);
7
7
  return { label, ...splitPath(label), resource };
@@ -21,7 +21,7 @@ function rowImages(row) {
21
21
  : [];
22
22
  return [...recorded, ...paths.flatMap((path, index) => {
23
23
  const resource = path.resource;
24
- if (resource.type !== "asset" || !isOptimizedImageAsset(resource.asset))
24
+ if (resource.type !== "asset" || !isRecordedImageAsset(resource.asset))
25
25
  return [];
26
26
  const asset = resource.asset;
27
27
  const key = `${row.session_id}:${row.timeline_id}:resource:${index}`;
@@ -4,12 +4,18 @@ export interface ListPosition {
4
4
  readonly day: number | null;
5
5
  /** Which of a host's sections the row is drawn in (R3); absent without them. */
6
6
  readonly section?: number;
7
+ /** Drawn in one of the import's not-imported groups; absent otherwise. */
8
+ readonly pending?: boolean;
9
+ /** That group is the top one, "Still importing"; absent otherwise. */
10
+ readonly importing?: boolean;
7
11
  }
8
12
  /** Hold geometry, never row data. Pointer, keyboard and scroll activity all
9
13
  * protect the same snapshot, including day membership and new insertions. */
10
14
  export declare function useDeferredListOrder(desired: readonly ListPosition[], scope: string): {
11
15
  items: readonly ListPosition[];
12
16
  pending: boolean;
17
+ /** Held not-imported rows the wanted order draws as imported. */
18
+ arrivals: import("./import-state.js").ImportArrivals | null;
13
19
  scrollRef: import("react").RefObject<HTMLDivElement | null>;
14
20
  hostProps: {
15
21
  onPointerEnter: (event: PointerEvent<HTMLDivElement>) => void;
@@ -1,4 +1,5 @@
1
1
  import { useEffect, useLayoutEffect, useRef, useState } from "react";
2
+ import { importArrivals } from "./import-state.js";
2
3
  const idle = (scope) => ({
3
4
  scope, hovered: false, focused: false, pressed: false, away: false, scrolling: false,
4
5
  });
@@ -107,9 +108,15 @@ export function useDeferredListOrder(desired, scope) {
107
108
  timer.current = null;
108
109
  }, 180);
109
110
  };
111
+ const pending = current.signature !== wanted;
112
+ // The rows at the top of the reader's view, as the last commit or scroll
113
+ // left them: what "below" means for the import's arrivals.
114
+ const anchorIds = anchor.current?.scope === scope ? anchor.current.rows.map(row => row.id) : [];
110
115
  return {
111
116
  items: current.items,
112
- pending: current.signature !== wanted,
117
+ pending,
118
+ /** Held not-imported rows the wanted order draws as imported. */
119
+ arrivals: pending ? importArrivals(current.items, desired, anchorIds) : null,
113
120
  scrollRef,
114
121
  hostProps: {
115
122
  onPointerEnter: (event) => {
@@ -1,2 +1,6 @@
1
1
  import type { ActivityFeed, IngestActivity } from "./ingest-activity.js";
2
- export declare function useIngestActivity(feed: ActivityFeed): IngestActivity | null;
2
+ import type { ConversationReadiness } from "./conversation-readiness.js";
3
+ export declare const LEAVING_MS = 360;
4
+ /** `conversations` is the room's fold of the catalog it draws the rows from,
5
+ * so the card's counts change in the same render as the rows. */
6
+ export declare function useIngestActivity(given: ActivityFeed, conversations?: ConversationReadiness | null): IngestActivity | null;
@@ -1,39 +1,75 @@
1
- import { useEffect, useRef, useState } from "react";
2
- import { activityPhase, progressBytes, progressDuration, sampleActivity } from "./ingest-activity.js";
3
- export function useIngestActivity(feed) {
1
+ import { useEffect, useMemo, useState } from "react";
2
+ import { activityIdentity, activityPhase, progressBytes, progressDuration, resumedRun, sampleActivity } from "./ingest-activity.js";
3
+ /** How long "Search ready" stays, and how long its fold takes (ingest.css,
4
+ * `.ah-ingest-fold`), before the card goes. */
5
+ const COMPLETION_MS = 5_000;
6
+ export const LEAVING_MS = 360;
7
+ /** `conversations` is the room's fold of the catalog it draws the rows from,
8
+ * so the card's counts change in the same render as the rows. */
9
+ export function useIngestActivity(given, conversations = null) {
10
+ // A resumed build is known by its runtimes' course, or, from a daemon that
11
+ // names none, by the restoring phase it passed through; the mark outlives
12
+ // that phase until the import goes live.
13
+ const [resumedKey, setResumedKey] = useState(null);
14
+ const nextResumedKey = resumedRun(resumedKey, given);
15
+ if (nextResumedKey !== resumedKey)
16
+ setResumedKey(nextResumedKey);
17
+ const resumed = nextResumedKey !== null;
18
+ const polled = useMemo(() => (resumed ? { ...given, resumed } : given), [given, resumed]);
19
+ // The counts move with every metadata delivery; the samples and the clock
20
+ // follow the status poll alone, so a delivery costs the room no second render.
21
+ const feed = useMemo(() => (conversations === null ? polled : { ...polled, conversations }), [polled, conversations]);
4
22
  const phase = activityPhase(feed);
5
23
  const [samples, setSamples] = useState(null);
6
24
  const [now, setNow] = useState(Date.now);
7
- const sawWork = useRef(false);
8
- const [showCompletion, setShowCompletion] = useState(false);
25
+ // The end: "Search ready" shows on one line for five seconds, then the
26
+ // card folds its height away (`leaving`), then it goes. Only a run seen
27
+ // working ends this way; a room opened on a finished archive shows none.
28
+ const [sawWork, setSawWork] = useState(false);
29
+ const [end, setEnd] = useState(null);
9
30
  const key = phase?.key;
31
+ if (key !== undefined && key !== "ready" && key !== "paused") {
32
+ if (!sawWork)
33
+ setSawWork(true);
34
+ if (end !== null)
35
+ setEnd(null);
36
+ }
37
+ // Decided in the render that first draws "ready", so the card never
38
+ // blinks out for a frame on its way there.
39
+ if (key === "ready" && end === null)
40
+ setEnd(sawWork ? "shown" : "gone");
10
41
  useEffect(() => {
11
- const current = activityPhase(feed);
42
+ const current = activityPhase(polled);
12
43
  if (current)
13
- setSamples((previous) => sampleActivity(previous, feed, current));
44
+ setSamples((previous) => sampleActivity(previous, polled, current));
14
45
  setNow(Date.now());
15
- }, [feed]);
46
+ }, [polled]);
16
47
  useEffect(() => {
17
- if (key && key !== "ready" && key !== "paused")
18
- sawWork.current = true;
19
- if (key !== "ready")
48
+ if (end !== "shown" && end !== "leaving")
20
49
  return;
21
- setShowCompletion(sawWork.current);
22
- const timer = window.setTimeout(() => { setShowCompletion(false); sawWork.current = false; }, 5_000);
50
+ const timer = window.setTimeout(() => {
51
+ if (end === "shown")
52
+ setEnd("leaving");
53
+ else {
54
+ setEnd("gone");
55
+ setSawWork(false);
56
+ }
57
+ }, end === "shown" ? COMPLETION_MS : LEAVING_MS);
23
58
  return () => window.clearTimeout(timer);
24
- }, [key]);
59
+ }, [end]);
60
+ const finished = key === "ready" && end !== "shown" && end !== "leaving";
25
61
  useEffect(() => {
26
- if (!key || (key === "ready" && !showCompletion))
62
+ if (!key || finished)
27
63
  return;
28
64
  const timer = window.setInterval(() => setNow(Date.now()), 1_000);
29
65
  return () => window.clearInterval(timer);
30
- }, [key, showCompletion]);
31
- if (!phase || (key === "ready" && !showCompletion))
66
+ }, [key, finished]);
67
+ if (!phase || finished)
32
68
  return null;
33
69
  const sinceAnswer = Math.max(0, now - (feed.receivedAt ?? now));
34
70
  const elapsed = `${progressDuration(feed.uptimeMs + (phase.active ? sinceAnswer : 0))} elapsed`;
35
71
  const sinceChange = Math.max(0, now - (samples?.changedAt ?? now));
36
- const rate = sinceChange < 4_000 && samples?.identity === `${feed.startedAt}:${phase.key}:${phase.unit}`
72
+ const rate = sinceChange < 4_000 && samples?.identity === activityIdentity(feed, phase)
37
73
  ? samples.rate : null;
38
74
  let footer = "Connected";
39
75
  if (feed.connectionError)
@@ -44,6 +80,6 @@ export function useIngestActivity(feed) {
44
80
  else if (phase.unit && sinceChange >= 10_000)
45
81
  footer = `Connected · No new counts for ${progressDuration(sinceChange)}`;
46
82
  else if (!phase.active)
47
- footer = key === "ready" ? "Complete" : key === "paused" ? "Paused" : "Ready to browse";
48
- return { phase, feed, footer, elapsed };
83
+ footer = key === "ready" ? "Complete" : key === "paused" ? "Paused" : key === "failed" ? "Stopped" : "Ready to browse";
84
+ return { phase, feed, footer, elapsed, leaving: key === "ready" && end === "leaving" };
49
85
  }
package/dist/ports.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AssetRef, CollaborationSubscriptionHandlers, CommandResponse, DayUsageResponse, ImageVariant, IngestProgress, MetaSubscriptionHandlers, SearchBuildProgress, SearchReadiness, SearchResponse, SessionSubscriptionHandlers, TimelineEntry, TimelineMetaPlanSource, TimelinePage, UsageResponse } from "@vibefield/rosetta-protocol";
1
+ import type { AssetRef, ArtifactListRequest, ArtifactPage, CollaborationSubscriptionHandlers, CommandResponse, DayUsageResponse, ImageVariant, IngestProgress, Ingestion, IngestionCommand, MetaSubscriptionHandlers, SearchBuildProgress, SearchReadiness, SearchResponse, SessionSubscriptionHandlers, TimelineEntry, TimelineMetaPlanSource, TimelinePage, UsageResponse } from "@vibefield/rosetta-protocol";
2
2
  import type { ProjectStats } from "./lib/model.js";
3
3
  /** A live subscription the room can end. */
4
4
  export interface Closable {
@@ -59,6 +59,12 @@ export interface CatalogPort {
59
59
  /** One day of that project, hour by hour. */
60
60
  dayUsage(projectId: string, day: string, offsetMinutes: number, signal?: AbortSignal): Promise<DayUsageResponse>;
61
61
  search(request: CatalogSearch, signal?: AbortSignal): Promise<SearchResponse>;
62
+ /** Explicitly presented HTML deliverables across the index. Optional for
63
+ * hosts that expose only a session or use an older catalog. */
64
+ readonly artifacts?: {
65
+ list(request: ArtifactListRequest, signal?: AbortSignal): Promise<ArtifactPage>;
66
+ read(sessionId: string, publicationId: string, signal?: AbortSignal): Promise<Uint8Array>;
67
+ };
62
68
  /** Advisory: read this still-queued session next. Optional — a grant never
63
69
  * opens a write, so only a host that holds the daemon's bearer offers it;
64
70
  * without it the index keeps its own order. */
@@ -88,6 +94,7 @@ export interface SessionClient {
88
94
  command(sessionId: string, timelineId: string, signal?: AbortSignal): Promise<CommandResponse>;
89
95
  readFileTarget(sessionId: string, timelineId: string, targetIndex: number, signal?: AbortSignal): Promise<Uint8Array>;
90
96
  readPlan(sessionId: string, source: TimelineMetaPlanSource, signal?: AbortSignal): Promise<Uint8Array>;
97
+ readArtifact?(sessionId: string, publicationId: string, signal?: AbortSignal): Promise<Uint8Array>;
91
98
  readTextAsset(asset: AssetRef, signal?: AbortSignal): Promise<string>;
92
99
  readAsset(asset: AssetRef, signal?: AbortSignal): Promise<Uint8Array>;
93
100
  }
@@ -184,6 +191,9 @@ export interface HostPort {
184
191
  /** Hand the exact HTML/SVG bytes to the chosen installed browser. Omitting
185
192
  * the id retains the default-browser action for hosts without discovery. */
186
193
  openInBrowser(name: string, bytes: Uint8Array, browserId?: string): Promise<boolean>;
194
+ /** Render one bounded HTML document into a cached static PNG data URL.
195
+ * Hosts without a screenshot renderer leave the grid preview unavailable. */
196
+ artifactThumbnail?(html: string): Promise<string | null>;
187
197
  /** Re-read installed browsers. Absent on hosts with only a default action. */
188
198
  browsers?(): Promise<readonly InstalledBrowser[]>;
189
199
  /** One site's own icon as an image URL, or null for every honest no — a
@@ -204,7 +214,10 @@ export interface AssetSource {
204
214
  * and answers an object URL — a promise while it fetches — bounding and
205
215
  * revoking what it made. The room asks on every mount and every retry, so
206
216
  * an evicted URL is asked for again, never reused, and a host must not
207
- * keep a failure.
217
+ * keep a failure. Every variant, `full` included, names a WebP the daemon
218
+ * encoded (`RosettaClient.imageAssetUrl`): a recorded original's plain
219
+ * member URL returns its recorded bytes, for opening or saving, and is
220
+ * never an image's address.
208
221
  */
209
222
  imageAssetUrl(asset: AssetRef, variant: ImageVariant): AssetUrl;
210
223
  /** The address that names one stored attachment member, or null when the
@@ -213,10 +226,16 @@ export interface AssetSource {
213
226
  attachmentAssetUrl(asset: AssetRef): string | null;
214
227
  }
215
228
  /** Everything a host hands the room. */
229
+ export interface IngestionPort {
230
+ pause(id: string, command: IngestionCommand, signal?: AbortSignal): Promise<Ingestion>;
231
+ resume(id: string, command: IngestionCommand, signal?: AbortSignal): Promise<Ingestion>;
232
+ }
216
233
  export interface RoomPorts {
217
234
  readonly catalog: CatalogPort;
218
235
  readonly sessions: SessionPort;
219
236
  readonly assets: AssetSource;
237
+ /** Optional daemon-level authority. Absence leaves history observation-only. */
238
+ readonly ingestion?: IngestionPort | null;
220
239
  /** Absent: a browser tab, which the room states rather than papers over. */
221
240
  readonly host?: HostPort | null;
222
241
  }
@@ -27,6 +27,7 @@ export interface OverlayCount {
27
27
  count(): number;
28
28
  }
29
29
  export interface Room {
30
+ readonly ingestion: RoomPorts["ingestion"];
30
31
  readonly catalog: CatalogPort;
31
32
  readonly sessions: SessionLeases;
32
33
  readonly assets: AssetSource;
@@ -39,6 +39,7 @@ function createOverlayCount() {
39
39
  const RoomContext = createContext(null);
40
40
  export function RoomProvider({ ports, options = {}, children, }) {
41
41
  const { catalog, sessions: sessionPort, assets } = ports;
42
+ const ingestion = ports.ingestion;
42
43
  const host = ports.host ?? null;
43
44
  const initialSummaryTab = options.initialSummaryTab ?? "activity";
44
45
  const portalContainer = options.portalContainer ?? null;
@@ -51,9 +52,9 @@ export function RoomProvider({ ports, options = {}, children, }) {
51
52
  const tints = useMemo(() => createTintDealer(storage), [storage]);
52
53
  const fold = useMemo(() => createFoldPreference(storage), [storage]);
53
54
  const room = useMemo(() => ({
54
- catalog, sessions, assets, host, initialSummaryTab, favicons, portalContainer, overlays,
55
+ catalog, sessions, assets, ingestion, host, initialSummaryTab, favicons, portalContainer, overlays,
55
56
  storage, tints, fold,
56
- }), [catalog, sessions, assets, host, initialSummaryTab, favicons, portalContainer, overlays, storage, tints, fold]);
57
+ }), [catalog, sessions, assets, ingestion, host, initialSummaryTab, favicons, portalContainer, overlays, storage, tints, fold]);
57
58
  return _jsx(RoomContext.Provider, { value: room, children: children });
58
59
  }
59
60
  export function useRoom() {
@@ -0,0 +1,66 @@
1
+ .ah-artifacts-launcher { display: flex; align-items: center; gap: 5px; margin-left: 8px; height: 32px; padding: 0 12px; border: 1px solid var(--vf-hairline); border-radius: 999px; background: var(--vf-fill); color: var(--vf-text-secondary); font-size: 12px; white-space: nowrap; -webkit-app-region: no-drag; }
2
+ .ah-artifacts-launcher svg { width: 16px; height: 16px; }
3
+ .ah-artifacts-launcher:hover { background: var(--vf-fill-hover); color: var(--vf-text-primary); }
4
+ .ah-artifacts { position: fixed; z-index: 61; inset: 5vh 4vw; max-width: 1320px; margin: auto; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--vf-hairline-strong); border-radius: var(--vf-radius-card, 14px); background: var(--vf-sheet-surface); color: var(--vf-text-primary); font-family: var(--vf-font-sans, system-ui, sans-serif); box-shadow: 0 24px 80px #0003; -webkit-app-region: no-drag; }
5
+ .ah-artifacts button, .ah-artifacts input, .ah-artifacts select { font: inherit; }
6
+ .ah-artifacts button, .ah-artifacts select { cursor: pointer; }
7
+ .ah-artifacts button:disabled { cursor: default; opacity: .5; }
8
+ .ah-artifacts button:focus-visible, .ah-artifacts input:focus-visible, .ah-artifacts select:focus-visible { outline: 2px solid var(--vf-select); outline-offset: -2px; }
9
+ .ah-artifacts__head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--vf-hairline); }
10
+ .ah-artifacts__head > svg { width: 28px; height: 28px; color: var(--vf-text-secondary); }
11
+ .ah-artifacts__head h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
12
+ .ah-artifacts__head p { margin: 0; font-size: 12px; color: var(--vf-text-secondary); }
13
+ .ah-artifacts__close { margin-left: auto; border: 0; border-radius: 8px; width: 30px; height: 30px; background: var(--vf-fill); color: inherit; font-size: 22px !important; }
14
+ .ah-artifacts__filters { display: flex; gap: 8px; padding: 12px 20px; align-items: center; border-bottom: 1px solid var(--vf-hairline); font-size: 12px; }
15
+ .ah-artifacts__filters input { flex: 1; min-width: 120px; }
16
+ .ah-artifacts__filters strong { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
17
+ .ah-artifacts__filters :is(input, select, button), .ah-artifacts__detailhead button, .ah-artifacts__toolbar button, .ah-artifacts__message button { border: 1px solid var(--vf-hairline); border-radius: 7px; background: var(--vf-fill); color: inherit; padding: 6px 9px; }
18
+ .ah-artifacts__filters select { max-width: 200px; }
19
+ .ah-artifacts__body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
20
+ .ah-artifacts__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); grid-auto-rows: max-content; align-content: start; gap: 18px; flex: 1; overflow: auto; padding: 20px; }
21
+ .ah-artifacts__list[hidden] { display: none; }
22
+ .ah-artifacts__list > :is(.ah-artifacts__empty, .ah-artifacts__message) { grid-column: 1 / -1; }
23
+ .ah-artifacts__item { display: flex; flex-direction: column; border: 1px solid var(--vf-hairline); border-radius: 12px; overflow: hidden; min-width: 0; background: var(--vf-fill); }
24
+ .ah-artifacts__item:hover { background: var(--vf-fill); }
25
+ .ah-artifacts__item[data-selected] { background: var(--vf-fill-hover); border-color: var(--vf-hairline-strong); }
26
+ .ah-artifacts__select { display: flex; flex-direction: column; flex-shrink: 0; gap: 7px; width: 100%; padding: 0 0 14px; border: 0; text-align: left; background: transparent; color: inherit; font-size: 12px !important; }
27
+ .ah-artifacts__select > :not(.ah-artifacts__thumbnail) { margin-inline: 14px; max-width: calc(100% - 28px); }
28
+ .ah-artifacts__thumbnail { display: block; position: relative; flex-shrink: 0; width: 100%; aspect-ratio: 16 / 10; overflow: hidden; background: #fff; border-bottom: 1px solid var(--vf-hairline); margin-bottom: 8px; pointer-events: none; }
29
+ .ah-artifacts__thumbnail img { display: block; width: 100%; height: 100%; object-fit: cover; }
30
+ .ah-artifacts__placeholder { display: flex; width: 100%; height: 100%; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--vf-text-tertiary); background: var(--vf-sheet-surface); font-size: 12px; }
31
+ .ah-artifacts__placeholder svg { width: 32px; height: 32px; opacity: .6; }
32
+ .ah-artifacts__cardactions { display: flex; flex-shrink: 0; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 14px; margin-top: auto; border-top: 1px solid var(--vf-hairline); }
33
+ .ah-artifacts__cardactions :is(button, a) { border: 0; padding: 0; background: transparent; color: var(--vf-text-secondary); text-decoration: none; font-size: 11px !important; }
34
+ .ah-artifacts a:hover, .ah-artifacts__cardactions button:hover { color: var(--vf-text-primary); text-decoration: underline; }
35
+ .ah-artifacts a:focus-visible { outline: 2px solid var(--vf-select); outline-offset: 3px; }
36
+ .ah-artifacts__itemtitle { display: flex; align-items: center; gap: 7px; max-width: 100%; }
37
+ .ah-artifacts__itemtitle svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--vf-text-secondary); }
38
+ .ah-artifacts__itemtitle strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 550; }
39
+ .ah-artifacts__filename { display: block; max-width: 100%; font-family: var(--vf-font-mono, monospace); font-size: 11px; color: var(--vf-text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
40
+ .ah-artifacts__itemmeta { display: flex; align-items: center; gap: 5px; color: var(--vf-text-secondary); font-size: 11px; }
41
+ .ah-artifacts__itemmeta svg, .ah-artifacts__provenance svg { width: 13px; height: 13px; }
42
+ .ah-artifacts__history { margin: 0; background: transparent; border: 0; padding: 0; color: var(--vf-text-secondary); font-size: 11px !important; }
43
+ .ah-artifacts__detail { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
44
+ .ah-artifacts__detailhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 10px; }
45
+ .ah-artifacts__detailhead > div { min-width: 0; }
46
+ .ah-artifacts__detailhead h3 { margin: 0 0 5px; font-size: 17px; font-weight: 600; }
47
+ .ah-artifacts__detailhead button { white-space: nowrap; font-size: 12px; }
48
+ .ah-artifacts__provenance { display: flex; flex-wrap: wrap; gap: 5px 16px; padding: 0 20px 12px; color: var(--vf-text-tertiary); font-size: 11px; }
49
+ .ah-artifacts__provenance span { display: flex; align-items: center; gap: 4px; overflow-wrap: anywhere; max-width: 100%; }
50
+ .ah-artifacts__toolbar { display: flex; justify-content: space-between; padding: 8px 16px; border-block: 1px solid var(--vf-hairline); font-size: 12px; }
51
+ .ah-artifacts__toolbar > div { display: flex; gap: 4px; }
52
+ .ah-artifacts__toolbar button { background: transparent; border-color: transparent; }
53
+ .ah-artifacts__toolbar button[aria-pressed=true] { background: var(--vf-fill-hover); border-color: var(--vf-hairline); }
54
+ .ah-artifacts__toolbar a, .ah-artifacts__published { color: var(--vf-text-primary); text-decoration: none; padding: 7px 10px; border: 1px solid var(--vf-hairline); border-radius: 7px; background: var(--vf-fill); }
55
+ .ah-artifacts__toolbar { gap: 8px; flex-wrap: wrap; align-items: center; }
56
+ .ah-artifacts__toolbar > div[hidden] { display: none; }
57
+ .ah-artifacts__preview { border: 0; background: white; flex: 1; min-height: 150px; width: 100%; }
58
+ .ah-artifacts__source { flex: 1; margin: 0; padding: 20px; overflow: auto; font-size: 12px; line-height: 1.6; tab-size: 2; background: var(--vf-fill); white-space: pre-wrap; overflow-wrap: anywhere; }
59
+ .ah-artifacts__empty { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; padding: 32px 24px; text-align: center; color: var(--vf-text-secondary); font-size: 13px; flex: 1; }
60
+ .ah-artifacts__empty > svg { width: 34px; height: 34px; color: var(--vf-text-tertiary); }
61
+ .ah-artifacts__empty h3 { font-weight: 500; font-size: 15px; margin: 5px 0; }
62
+ .ah-artifacts__empty p { max-width: 330px; line-height: 1.6; margin: 0; }
63
+ .ah-artifacts__message { margin: 0; padding: 12px 20px; font-size: 12px; color: var(--vf-text-secondary); }
64
+ .ah-artifacts__note { margin: 0; padding: 9px 16px; font-size: 10px; color: var(--vf-text-tertiary); border-top: 1px solid var(--vf-hairline); }
65
+ @media (max-width: 800px) { .ah-artifacts { inset: 10px; } .ah-artifacts__filters { flex-wrap: wrap; } .ah-artifacts__filters select { max-width: 140px; } .ah-artifacts__list { padding: 14px; gap: 14px; } }
66
+ @media (max-width: 580px) { .ah-artifacts__detailhead { padding-inline: 12px; flex-wrap: wrap; } .ah-artifacts__head { padding: 12px; } }
@@ -10,6 +10,7 @@
10
10
  @import "./ingest.css";
11
11
  @import "./transcript.css";
12
12
  @import "./search.css";
13
+ @import "./artifacts.css";
13
14
  @import "./reader.css";
14
15
  @import "./host-inputs.css";
15
16
  /* The worktree guest's tree: mille's token surface and the VibeField theme,