@vibefield/rosetta-room 0.1.2 → 0.1.4
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 +82 -4
- package/dist/HistoryRoom.d.ts +15 -2
- package/dist/HistoryRoom.js +82 -25
- package/dist/TranscriptReader.d.ts +7 -0
- package/dist/TranscriptReader.js +4 -4
- package/dist/components/ColdStart.js +1 -1
- package/dist/components/IngestStatus.d.ts +13 -0
- package/dist/components/IngestStatus.js +39 -3
- package/dist/components/ListActivityNotice.d.ts +9 -1
- package/dist/components/ListActivityNotice.js +9 -2
- package/dist/components/SummaryPanels.d.ts +5 -0
- package/dist/components/SummaryPanels.js +16 -5
- package/dist/components/Transcript.d.ts +5 -0
- package/dist/components/Transcript.js +20 -5
- package/dist/components/artifacts/ArtifactLibrary.d.ts +14 -0
- package/dist/components/artifacts/ArtifactLibrary.js +156 -0
- package/dist/components/artifacts/content.d.ts +8 -0
- package/dist/components/artifacts/content.js +27 -0
- package/dist/components/artifacts/load-all.d.ts +5 -0
- package/dist/components/artifacts/load-all.js +31 -0
- package/dist/components/artifacts/preview.d.ts +4 -0
- package/dist/components/artifacts/preview.js +37 -0
- package/dist/components/artifacts/thumbnails.d.ts +13 -0
- package/dist/components/artifacts/thumbnails.js +43 -0
- package/dist/components/projects/ProjectList.d.ts +9 -3
- package/dist/components/projects/ProjectList.js +3 -3
- package/dist/components/projects/ProjectListItem.d.ts +9 -3
- package/dist/components/projects/ProjectListItem.js +18 -12
- package/dist/components/projects/ProjectsColumn.d.ts +4 -1
- package/dist/components/projects/ProjectsColumn.js +23 -9
- package/dist/components/search/SearchSheet.d.ts +39 -2
- package/dist/components/search/SearchSheet.js +81 -17
- package/dist/components/sessions/SessionList.d.ts +6 -1
- package/dist/components/sessions/SessionList.js +50 -20
- package/dist/components/sessions/SessionListItem.d.ts +3 -1
- package/dist/components/sessions/SessionListItem.js +17 -7
- package/dist/components/sessions/SessionsColumn.d.ts +3 -1
- package/dist/components/sessions/SessionsColumn.js +2 -2
- package/dist/components/sessions/session-display.d.ts +4 -1
- package/dist/components/sessions/session-display.js +13 -2
- package/dist/components/transcript/Attachments.js +6 -1
- package/dist/components/transcript/Document.d.ts +6 -1
- package/dist/components/transcript/Document.js +19 -6
- package/dist/components/transcript/ImportState.d.ts +35 -0
- package/dist/components/transcript/ImportState.js +86 -0
- package/dist/components/transcript/TranscriptLoading.js +15 -5
- package/dist/components/transcript/attachment-file-source.d.ts +2 -0
- package/dist/components/transcript/attachment-file-source.js +6 -6
- package/dist/components/transcript/attachment-gallery.d.ts +2 -1
- package/dist/components/transcript/attachment-gallery.js +2 -1
- package/dist/components/transcript/detail-parts.js +7 -6
- package/dist/components/transcript/timeline-meta-file-source.d.ts +2 -1
- package/dist/components/transcript/timeline-meta-file-source.js +45 -5
- package/dist/components/ui/EmptyState.d.ts +5 -1
- package/dist/components/ui/EmptyState.js +2 -2
- package/dist/components/ui/Meter.d.ts +8 -0
- package/dist/components/ui/Meter.js +9 -0
- package/dist/components/ui/SegmentedControl.d.ts +2 -0
- package/dist/components/ui/SegmentedControl.js +1 -1
- package/dist/components/ui/Veil.d.ts +2 -1
- package/dist/components/ui/Veil.js +9 -2
- package/dist/components/ui/index.d.ts +2 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/fixtures/cold-import-corpus.d.ts +76 -0
- package/dist/fixtures/cold-import-corpus.js +349 -0
- package/dist/fixtures/cold-import-daemon.d.ts +25 -0
- package/dist/fixtures/cold-import-daemon.js +82 -0
- package/dist/fixtures/cold-import-schedule.d.ts +74 -0
- package/dist/fixtures/cold-import-schedule.js +191 -0
- package/dist/fixtures/cold-import.d.ts +151 -0
- package/dist/fixtures/cold-import.js +786 -0
- package/dist/fixtures/index.d.ts +2 -0
- package/dist/fixtures/index.js +21 -2
- package/dist/lib/activity-order.d.ts +15 -0
- package/dist/lib/activity-order.js +24 -1
- package/dist/lib/conversation-readiness.d.ts +48 -0
- package/dist/lib/conversation-readiness.js +149 -0
- package/dist/lib/figure-order.d.ts +35 -0
- package/dist/lib/figure-order.js +68 -0
- package/dist/lib/hooks.d.ts +32 -10
- package/dist/lib/hooks.js +118 -54
- package/dist/lib/image-media.d.ts +12 -2
- package/dist/lib/image-media.js +40 -6
- package/dist/lib/import-state.d.ts +98 -0
- package/dist/lib/import-state.js +129 -0
- package/dist/lib/ingest-activity.d.ts +51 -0
- package/dist/lib/ingest-activity.js +109 -10
- package/dist/lib/model.d.ts +16 -0
- package/dist/lib/model.js +27 -1
- package/dist/lib/search-sheet.d.ts +43 -0
- package/dist/lib/search-sheet.js +56 -7
- package/dist/lib/session-activity.d.ts +4 -1
- package/dist/lib/session-activity.js +4 -1
- package/dist/lib/title-search.d.ts +82 -0
- package/dist/lib/title-search.js +194 -0
- package/dist/lib/transcript/images.js +2 -2
- package/dist/lib/transcript/sittings.d.ts +7 -4
- package/dist/lib/transcript/sittings.js +14 -8
- package/dist/lib/use-deferred-list-order.d.ts +6 -0
- package/dist/lib/use-deferred-list-order.js +8 -1
- package/dist/lib/use-ingest-activity.d.ts +5 -1
- package/dist/lib/use-ingest-activity.js +54 -18
- package/dist/ports.d.ts +15 -2
- package/dist/styles/artifacts.css +66 -0
- package/dist/styles/history-room.css +1 -0
- package/dist/styles/ingest.css +26 -3
- package/dist/styles/room.css +15 -0
- package/dist/styles/search.css +17 -0
- package/package.json +2 -2
package/dist/fixtures/index.d.ts
CHANGED
|
@@ -22,3 +22,5 @@ export declare function createDemoPorts(demo?: RoomDemo): RoomPorts;
|
|
|
22
22
|
export declare function demoProjectViewModels(demo?: RoomDemo): ProjectViewModel[];
|
|
23
23
|
/** The order the projects and sessions column would settle on for the demo. */
|
|
24
24
|
export declare function demoActivityOrder(demo?: RoomDemo): ActivityOrder;
|
|
25
|
+
export { createColdImport } from "./cold-import.js";
|
|
26
|
+
export type { ColdCorpus, ColdCorpusOptions, ColdImport, ColdImportController, ColdImportLog, ColdImportOptions, ColdPhase, ColdTrailEntry, ColdTree, FlipBatch, FlipKind, ResyncMode, RuntimeTimes, SessionKind, } from "./cold-import.js";
|
package/dist/fixtures/index.js
CHANGED
|
@@ -52,7 +52,8 @@ function member(seed) {
|
|
|
52
52
|
const digest = digestOf(seed);
|
|
53
53
|
return { url: `/api/assets/${digest}.webp`, digest, media_type: "image/webp", byte_len: 2048 };
|
|
54
54
|
}
|
|
55
|
-
/**
|
|
55
|
+
/** A legacy WebP bundle (a projection built before deferred renditions): a
|
|
56
|
+
* member and its four renditions, every one encoded at ingestion. */
|
|
56
57
|
function image(id, seed, name, width, height) {
|
|
57
58
|
const full = member(seed);
|
|
58
59
|
return {
|
|
@@ -63,6 +64,16 @@ function image(id, seed, name, width, height) {
|
|
|
63
64
|
dimensions: { width, height }, message_ranges: [],
|
|
64
65
|
};
|
|
65
66
|
}
|
|
67
|
+
/** A recorded original: the image's own bytes as one member, with no rendition
|
|
68
|
+
* map. The room draws it only through the host's renditions. */
|
|
69
|
+
function original(id, seed, name, width, height) {
|
|
70
|
+
const digest = digestOf(seed);
|
|
71
|
+
const asset = { url: `/api/assets/${digest}.png`, digest, media_type: "image/png", byte_len: 48_213 };
|
|
72
|
+
return {
|
|
73
|
+
id, kind: "image", label: `[Image #${id}]`, name, media_type: asset.media_type, byte_len: asset.byte_len,
|
|
74
|
+
source: { type: "asset", asset }, dimensions: { width, height }, message_ranges: [],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
66
77
|
function transcript(sessionId, startedAt) {
|
|
67
78
|
const rows = [];
|
|
68
79
|
const add = (body, kind, model = null) => {
|
|
@@ -146,7 +157,10 @@ export function createRoomDemo(now = Date.now()) {
|
|
|
146
157
|
// Two transcripts: the conversation first, its activity one press away.
|
|
147
158
|
const timelines = new Map();
|
|
148
159
|
const one = transcript("s0", sessions[0].started_at);
|
|
149
|
-
one.user("Port the latest Godview look and rosetta's History view into the four-views frame, and fix the old flaws while we're there: the keys in the file pill, and the two plus buttons in the composer line.",
|
|
160
|
+
one.user("Port the latest Godview look and rosetta's History view into the four-views frame, and fix the old flaws while we're there: the keys in the file pill, and the two plus buttons in the composer line.",
|
|
161
|
+
// A projection built before deferred renditions keeps its bundle beside
|
|
162
|
+
// the original a newer import recorded: one transcript holds both.
|
|
163
|
+
[image("1", "frame-before", "frame-before.png", 1440, 900), original("2", "frame-after", "frame-after.png", 900, 1200)]);
|
|
150
164
|
one.agent("I'll read DESIGN.md and the composer record first, then capture Godview from the catalog and History from rosetta's own components, so the page shows each view as it really looks.");
|
|
151
165
|
one.tool("Read", read("DESIGN.md"));
|
|
152
166
|
one.tool("Read", read("draft/composer/compact.md"));
|
|
@@ -290,3 +304,8 @@ export function demoProjectViewModels(demo = createRoomDemo()) {
|
|
|
290
304
|
export function demoActivityOrder(demo = createRoomDemo()) {
|
|
291
305
|
return advanceActivityOrder(null, demo.meta.sessions, { now: demo.now, live: false, bootstrapping: false });
|
|
292
306
|
}
|
|
307
|
+
/* ── a cold import, simulated ───────────────────────────────────────────── */
|
|
308
|
+
// The same room through a first import: ports over a seeded synthetic
|
|
309
|
+
// archive and a controller a harness steps through simulated time
|
|
310
|
+
// (`cold-import.ts`). clients/app's cold-import characterization drives it.
|
|
311
|
+
export { createColdImport } from "./cold-import.js";
|
|
@@ -13,6 +13,11 @@ export interface ActivityOrder {
|
|
|
13
13
|
readonly sessions: ReadonlyMap<string, SessionPosition>;
|
|
14
14
|
readonly projects: ReadonlyMap<string | null, ActivityPosition>;
|
|
15
15
|
readonly bootstrapping: boolean;
|
|
16
|
+
/** While bootstrapping only: each project's newest root `updated_at`, the
|
|
17
|
+
* order among projects no recorded activity ranks yet (see
|
|
18
|
+
* `compareProjectOrder`). Empty once activity alone orders. Optional, so
|
|
19
|
+
* an order built without it keeps the id fallback. */
|
|
20
|
+
readonly sourceAt?: ReadonlyMap<string | null, number>;
|
|
16
21
|
}
|
|
17
22
|
export interface ActivityOrderOptions {
|
|
18
23
|
readonly now: number;
|
|
@@ -26,7 +31,17 @@ export interface ActivityOrderOptions {
|
|
|
26
31
|
export declare function advanceActivityOrder(previous: ActivityOrder | null, rows: readonly SessionRow[], options: ActivityOrderOptions): ActivityOrder;
|
|
27
32
|
/** Known timestamps precede unknowns; identity deterministically breaks ties. */
|
|
28
33
|
export declare function compareActivityRanks(a: number | null, b: number | null, aId: string, bId: string): number;
|
|
34
|
+
/** The project list's `recent` order. Activity-ranked projects come first,
|
|
35
|
+
* by rank. While the room bootstraps (decision D1, 2026-11-03), the
|
|
36
|
+
* projects no recorded activity can rank yet follow by their newest root's
|
|
37
|
+
* `updated_at` (source freshness), then id, where they would otherwise
|
|
38
|
+
* fall back to id alone; it never outranks recorded activity, and once the
|
|
39
|
+
* import publishes, activity and id alone order again. */
|
|
40
|
+
export declare function compareProjectOrder(order: ActivityOrder, left: string | null, right: string | null, leftId: string, rightId: string): number;
|
|
29
41
|
/** Local calendar day, rather than a 24-hour duration (including across DST). */
|
|
30
42
|
export declare function activityDay(at: number | null): number | null;
|
|
43
|
+
/** The import's "Not imported yet" group has no recorded activity to
|
|
44
|
+
* rank by: its newest source first (`updated_at`), then identity. */
|
|
45
|
+
export declare function compareNotImported(left: SessionRow, right: SessionRow): number;
|
|
31
46
|
export declare function compareOrderedSessions(left: SessionRow, right: SessionRow, order: ActivityOrder): number;
|
|
32
47
|
export {};
|
|
@@ -18,6 +18,7 @@ export function advanceActivityOrder(previous, rows, options) {
|
|
|
18
18
|
const live = options.live && !seed;
|
|
19
19
|
const sessions = new Map();
|
|
20
20
|
const projectActivity = new Map();
|
|
21
|
+
const sourceAt = new Map();
|
|
21
22
|
const advances = new Map();
|
|
22
23
|
for (const row of rows) {
|
|
23
24
|
const at = sessionLastActive(row);
|
|
@@ -37,6 +38,9 @@ export function advanceActivityOrder(previous, rows, options) {
|
|
|
37
38
|
if (row.parent_session_id !== null)
|
|
38
39
|
continue;
|
|
39
40
|
projectActivity.set(row.project_id, latest(projectActivity.get(row.project_id) ?? null, at));
|
|
41
|
+
if (options.bootstrapping && Number.isFinite(row.updated_at)) {
|
|
42
|
+
sourceAt.set(row.project_id, latest(sourceAt.get(row.project_id) ?? null, row.updated_at));
|
|
43
|
+
}
|
|
40
44
|
if (live && sameOwner && advanced) {
|
|
41
45
|
const events = advances.get(row.project_id) ?? [];
|
|
42
46
|
events.push(at);
|
|
@@ -57,7 +61,7 @@ export function advanceActivityOrder(previous, rows, options) {
|
|
|
57
61
|
}
|
|
58
62
|
projects.set(id, { seenAt: latest(seenAt, at), rankAt });
|
|
59
63
|
}
|
|
60
|
-
return { sessions, projects, bootstrapping: options.bootstrapping };
|
|
64
|
+
return { sessions, projects, bootstrapping: options.bootstrapping, sourceAt };
|
|
61
65
|
}
|
|
62
66
|
/** Known timestamps precede unknowns; identity deterministically breaks ties. */
|
|
63
67
|
export function compareActivityRanks(a, b, aId, bId) {
|
|
@@ -67,6 +71,20 @@ export function compareActivityRanks(a, b, aId, bId) {
|
|
|
67
71
|
return -1;
|
|
68
72
|
return (a !== null && b !== null ? b - a : 0) || aId.localeCompare(bId);
|
|
69
73
|
}
|
|
74
|
+
/** The project list's `recent` order. Activity-ranked projects come first,
|
|
75
|
+
* by rank. While the room bootstraps (decision D1, 2026-11-03), the
|
|
76
|
+
* projects no recorded activity can rank yet follow by their newest root's
|
|
77
|
+
* `updated_at` (source freshness), then id, where they would otherwise
|
|
78
|
+
* fall back to id alone; it never outranks recorded activity, and once the
|
|
79
|
+
* import publishes, activity and id alone order again. */
|
|
80
|
+
export function compareProjectOrder(order, left, right, leftId, rightId) {
|
|
81
|
+
const a = order.projects.get(left)?.rankAt ?? null;
|
|
82
|
+
const b = order.projects.get(right)?.rankAt ?? null;
|
|
83
|
+
if (a === null && b === null && order.bootstrapping && order.sourceAt !== undefined) {
|
|
84
|
+
return compareActivityRanks(order.sourceAt.get(left) ?? null, order.sourceAt.get(right) ?? null, leftId, rightId);
|
|
85
|
+
}
|
|
86
|
+
return compareActivityRanks(a, b, leftId, rightId);
|
|
87
|
+
}
|
|
70
88
|
/** Local calendar day, rather than a 24-hour duration (including across DST). */
|
|
71
89
|
export function activityDay(at) {
|
|
72
90
|
if (at === null)
|
|
@@ -75,6 +93,11 @@ export function activityDay(at) {
|
|
|
75
93
|
date.setHours(0, 0, 0, 0);
|
|
76
94
|
return Number.isFinite(date.getTime()) ? date.getTime() : null;
|
|
77
95
|
}
|
|
96
|
+
/** The import's "Not imported yet" group has no recorded activity to
|
|
97
|
+
* rank by: its newest source first (`updated_at`), then identity. */
|
|
98
|
+
export function compareNotImported(left, right) {
|
|
99
|
+
return right.updated_at - left.updated_at || left.id.localeCompare(right.id);
|
|
100
|
+
}
|
|
78
101
|
export function compareOrderedSessions(left, right, order) {
|
|
79
102
|
const aDay = activityDay(sessionLastActive(left));
|
|
80
103
|
const bDay = activityDay(sessionLastActive(right));
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { SessionRow } from "@vibefield/rosetta-protocol";
|
|
2
|
+
export interface ConversationCount {
|
|
3
|
+
readonly readable: number;
|
|
4
|
+
readonly total: number;
|
|
5
|
+
}
|
|
6
|
+
/** Counted roots whose `updated_at` (source freshness, not activity) lies
|
|
7
|
+
* within a span of the reader's clock. */
|
|
8
|
+
export interface ConversationHorizons {
|
|
9
|
+
readonly day: ConversationCount;
|
|
10
|
+
readonly week: ConversationCount;
|
|
11
|
+
}
|
|
12
|
+
export interface ConversationReadiness extends ConversationCount {
|
|
13
|
+
/** Per project, keyed by `projectKey` (the unassigned bucket included). */
|
|
14
|
+
readonly byProject: ReadonlyMap<string, ConversationCount>;
|
|
15
|
+
readonly horizons: ConversationHorizons;
|
|
16
|
+
}
|
|
17
|
+
export declare const NO_CONVERSATIONS: ConversationReadiness;
|
|
18
|
+
/**
|
|
19
|
+
* The fold, kept across deliveries. The SDK keeps an unchanged row's object
|
|
20
|
+
* identity, so a delivery costs one map lookup per unchanged row and real
|
|
21
|
+
* work only for the rows that changed; the result is always what a full
|
|
22
|
+
* count of the given rows would say, whatever order they come in (a render
|
|
23
|
+
* that draws an older delivery again folds back to it).
|
|
24
|
+
*/
|
|
25
|
+
export declare class ConversationFold {
|
|
26
|
+
private readonly entries;
|
|
27
|
+
/** Direct children per parent id: what tells a placeholder apart. */
|
|
28
|
+
private readonly children;
|
|
29
|
+
private readonly projects;
|
|
30
|
+
/** Counted roots only, for the horizons. */
|
|
31
|
+
private readonly roots;
|
|
32
|
+
private readable;
|
|
33
|
+
private total;
|
|
34
|
+
private pass;
|
|
35
|
+
private lastRows;
|
|
36
|
+
private lastNow;
|
|
37
|
+
private last;
|
|
38
|
+
private changed;
|
|
39
|
+
read(rows: readonly SessionRow[], now: number): ConversationReadiness;
|
|
40
|
+
private fold;
|
|
41
|
+
/** Recompute what an entry adds, from its row and its children, and add it. */
|
|
42
|
+
private settle;
|
|
43
|
+
private apply;
|
|
44
|
+
/** A child arrived under (or left) `parent`: whether the parent is a
|
|
45
|
+
* placeholder can change only when it gains its first or loses its last. */
|
|
46
|
+
private adopt;
|
|
47
|
+
private horizons;
|
|
48
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { isMetadataOnly } from "./import-state.js";
|
|
2
|
+
import { projectKey } from "./model.js";
|
|
3
|
+
export const NO_CONVERSATIONS = {
|
|
4
|
+
readable: 0, total: 0, byProject: new Map(),
|
|
5
|
+
horizons: { day: { readable: 0, total: 0 }, week: { readable: 0, total: 0 } },
|
|
6
|
+
};
|
|
7
|
+
const DAY_MS = 86_400_000;
|
|
8
|
+
/**
|
|
9
|
+
* The fold, kept across deliveries. The SDK keeps an unchanged row's object
|
|
10
|
+
* identity, so a delivery costs one map lookup per unchanged row and real
|
|
11
|
+
* work only for the rows that changed; the result is always what a full
|
|
12
|
+
* count of the given rows would say, whatever order they come in (a render
|
|
13
|
+
* that draws an older delivery again folds back to it).
|
|
14
|
+
*/
|
|
15
|
+
export class ConversationFold {
|
|
16
|
+
entries = new Map();
|
|
17
|
+
/** Direct children per parent id: what tells a placeholder apart. */
|
|
18
|
+
children = new Map();
|
|
19
|
+
projects = new Map();
|
|
20
|
+
/** Counted roots only, for the horizons. */
|
|
21
|
+
roots = new Set();
|
|
22
|
+
readable = 0;
|
|
23
|
+
total = 0;
|
|
24
|
+
pass = 0;
|
|
25
|
+
lastRows = null;
|
|
26
|
+
lastNow = null;
|
|
27
|
+
last = NO_CONVERSATIONS;
|
|
28
|
+
changed = true;
|
|
29
|
+
read(rows, now) {
|
|
30
|
+
if (rows !== this.lastRows)
|
|
31
|
+
this.fold(rows);
|
|
32
|
+
if (!this.changed && now === this.lastNow)
|
|
33
|
+
return this.last;
|
|
34
|
+
this.lastNow = now;
|
|
35
|
+
this.changed = false;
|
|
36
|
+
this.last = {
|
|
37
|
+
readable: this.readable,
|
|
38
|
+
total: this.total,
|
|
39
|
+
byProject: new Map([...this.projects].map(([key, tally]) => [key, { ...tally }])),
|
|
40
|
+
horizons: this.horizons(now),
|
|
41
|
+
};
|
|
42
|
+
return this.last;
|
|
43
|
+
}
|
|
44
|
+
fold(rows) {
|
|
45
|
+
this.lastRows = rows;
|
|
46
|
+
const pass = ++this.pass;
|
|
47
|
+
for (const row of rows) {
|
|
48
|
+
const entry = this.entries.get(row.id);
|
|
49
|
+
if (entry !== undefined && entry.row === row) {
|
|
50
|
+
entry.pass = pass;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
this.changed = true;
|
|
54
|
+
if (entry === undefined) {
|
|
55
|
+
const added = { row, pass, project: projectKey(row), counted: false, readable: false };
|
|
56
|
+
this.entries.set(row.id, added);
|
|
57
|
+
this.settle(added);
|
|
58
|
+
if (row.parent_session_id !== null)
|
|
59
|
+
this.adopt(row.parent_session_id, 1);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const parent = entry.row.parent_session_id;
|
|
63
|
+
this.apply(entry, -1);
|
|
64
|
+
entry.row = row;
|
|
65
|
+
entry.pass = pass;
|
|
66
|
+
entry.project = projectKey(row);
|
|
67
|
+
this.settle(entry);
|
|
68
|
+
if (parent !== row.parent_session_id) {
|
|
69
|
+
if (parent !== null)
|
|
70
|
+
this.adopt(parent, -1);
|
|
71
|
+
if (row.parent_session_id !== null)
|
|
72
|
+
this.adopt(row.parent_session_id, 1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (this.entries.size === rows.length)
|
|
76
|
+
return;
|
|
77
|
+
// Rows the delivery no longer holds (a removal or a smaller snapshot).
|
|
78
|
+
for (const [id, entry] of this.entries) {
|
|
79
|
+
if (entry.pass === pass)
|
|
80
|
+
continue;
|
|
81
|
+
this.changed = true;
|
|
82
|
+
this.apply(entry, -1);
|
|
83
|
+
this.entries.delete(id);
|
|
84
|
+
if (entry.row.parent_session_id !== null)
|
|
85
|
+
this.adopt(entry.row.parent_session_id, -1);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Recompute what an entry adds, from its row and its children, and add it. */
|
|
89
|
+
settle(entry) {
|
|
90
|
+
const row = entry.row;
|
|
91
|
+
const root = row.parent_session_id === null;
|
|
92
|
+
entry.counted = root && !isMetadataOnly(row, (this.children.get(row.id) ?? 0) > 0);
|
|
93
|
+
entry.readable = entry.counted && row.stream_state !== "pending";
|
|
94
|
+
this.apply(entry, 1);
|
|
95
|
+
}
|
|
96
|
+
apply(entry, sign) {
|
|
97
|
+
if (!entry.counted)
|
|
98
|
+
return;
|
|
99
|
+
const readable = entry.readable ? sign : 0;
|
|
100
|
+
this.total += sign;
|
|
101
|
+
this.readable += readable;
|
|
102
|
+
const tally = this.projects.get(entry.project) ?? { readable: 0, total: 0 };
|
|
103
|
+
tally.total += sign;
|
|
104
|
+
tally.readable += readable;
|
|
105
|
+
if (tally.total === 0)
|
|
106
|
+
this.projects.delete(entry.project);
|
|
107
|
+
else
|
|
108
|
+
this.projects.set(entry.project, tally);
|
|
109
|
+
if (sign === 1)
|
|
110
|
+
this.roots.add(entry);
|
|
111
|
+
else
|
|
112
|
+
this.roots.delete(entry);
|
|
113
|
+
}
|
|
114
|
+
/** A child arrived under (or left) `parent`: whether the parent is a
|
|
115
|
+
* placeholder can change only when it gains its first or loses its last. */
|
|
116
|
+
adopt(parent, delta) {
|
|
117
|
+
const before = this.children.get(parent) ?? 0;
|
|
118
|
+
const after = before + delta;
|
|
119
|
+
if (after <= 0)
|
|
120
|
+
this.children.delete(parent);
|
|
121
|
+
else
|
|
122
|
+
this.children.set(parent, after);
|
|
123
|
+
if ((before > 0) === (after > 0))
|
|
124
|
+
return;
|
|
125
|
+
const entry = this.entries.get(parent);
|
|
126
|
+
if (entry === undefined)
|
|
127
|
+
return;
|
|
128
|
+
this.apply(entry, -1);
|
|
129
|
+
this.settle(entry);
|
|
130
|
+
}
|
|
131
|
+
horizons(now) {
|
|
132
|
+
const day = { readable: 0, total: 0 };
|
|
133
|
+
const week = { readable: 0, total: 0 };
|
|
134
|
+
for (const entry of this.roots) {
|
|
135
|
+
const age = now - entry.row.updated_at;
|
|
136
|
+
if (age > 7 * DAY_MS)
|
|
137
|
+
continue;
|
|
138
|
+
week.total += 1;
|
|
139
|
+
if (entry.readable)
|
|
140
|
+
week.readable += 1;
|
|
141
|
+
if (age > DAY_MS)
|
|
142
|
+
continue;
|
|
143
|
+
day.total += 1;
|
|
144
|
+
if (entry.readable)
|
|
145
|
+
day.readable += 1;
|
|
146
|
+
}
|
|
147
|
+
return { day, week };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** A project card as the list draws it. */
|
|
2
|
+
export interface DrawnCard {
|
|
3
|
+
/** The project id (the unassigned bucket's id included). */
|
|
4
|
+
readonly id: string;
|
|
5
|
+
/** Any part of the card lies inside its scrolling list. */
|
|
6
|
+
readonly onScreen: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Every id in `ids`, once: the selected project, then the on-screen cards
|
|
10
|
+
* top to bottom, then the other drawn cards top to bottom, then the
|
|
11
|
+
* projects the list does not draw (folded sections, rows not mounted), by
|
|
12
|
+
* id. Cards for projects not in `ids` are ignored.
|
|
13
|
+
*/
|
|
14
|
+
export declare function figureOrder(ids: readonly string[], selected: string | null, drawn: readonly DrawnCard[]): string[];
|
|
15
|
+
/**
|
|
16
|
+
* The project cards under `root`, top to bottom, each marked whether it
|
|
17
|
+
* shows inside its scrolling list. One layout read per card; the hook asks
|
|
18
|
+
* once per round, never per project.
|
|
19
|
+
*/
|
|
20
|
+
export declare function drawnProjectCards(root: ParentNode | null | undefined): DrawnCard[];
|
|
21
|
+
/** First retry after a failed figure, in ms. */
|
|
22
|
+
export declare const FIGURE_RETRY_MS = 8000;
|
|
23
|
+
/** The longest wait between retries, in ms. */
|
|
24
|
+
export declare const FIGURE_RETRY_CAP_MS = 120000;
|
|
25
|
+
/**
|
|
26
|
+
* How long to wait before asking a failed project again: 8 s after the
|
|
27
|
+
* first failure, doubling with each one after, at most two minutes — a
|
|
28
|
+
* daemon mid-restart is back within seconds, a project that keeps failing
|
|
29
|
+
* is not hammered, and it is still asked again while the panel says
|
|
30
|
+
* "retrying". Only the failed projects are asked again.
|
|
31
|
+
*/
|
|
32
|
+
export declare function figureRetryDelay(failures: number): number;
|
|
33
|
+
/** The portfolio's line for figures that failed, e.g.
|
|
34
|
+
* `figures for 1 project failed · retrying`. */
|
|
35
|
+
export declare function failedFiguresLine(count: number): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// The order project figures hydrate in after publication, and how a failed
|
|
2
|
+
// one is asked again (ux:X6). Figures wait on one global gate — the daemon
|
|
3
|
+
// publishes aggregates only once the whole import has finished — so the
|
|
4
|
+
// minute after it is when they all land at once, four at a time. The reader
|
|
5
|
+
// is looking at one project and a screenful of cards: those go first, then
|
|
6
|
+
// the rest of the list as drawn, then any project the list does not draw.
|
|
7
|
+
// Nothing here changes what is asked, only when.
|
|
8
|
+
/**
|
|
9
|
+
* Every id in `ids`, once: the selected project, then the on-screen cards
|
|
10
|
+
* top to bottom, then the other drawn cards top to bottom, then the
|
|
11
|
+
* projects the list does not draw (folded sections, rows not mounted), by
|
|
12
|
+
* id. Cards for projects not in `ids` are ignored.
|
|
13
|
+
*/
|
|
14
|
+
export function figureOrder(ids, selected, drawn) {
|
|
15
|
+
const wanted = new Set(ids);
|
|
16
|
+
const order = [];
|
|
17
|
+
const take = (id) => {
|
|
18
|
+
if (!wanted.delete(id))
|
|
19
|
+
return;
|
|
20
|
+
order.push(id);
|
|
21
|
+
};
|
|
22
|
+
if (selected !== null)
|
|
23
|
+
take(selected);
|
|
24
|
+
for (const card of drawn)
|
|
25
|
+
if (card.onScreen)
|
|
26
|
+
take(card.id);
|
|
27
|
+
for (const card of drawn)
|
|
28
|
+
take(card.id);
|
|
29
|
+
for (const id of [...wanted].sort())
|
|
30
|
+
take(id);
|
|
31
|
+
return order;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The project cards under `root`, top to bottom, each marked whether it
|
|
35
|
+
* shows inside its scrolling list. One layout read per card; the hook asks
|
|
36
|
+
* once per round, never per project.
|
|
37
|
+
*/
|
|
38
|
+
export function drawnProjectCards(root) {
|
|
39
|
+
if (root === null || root === undefined)
|
|
40
|
+
return [];
|
|
41
|
+
const cards = Array.from(root.querySelectorAll(".ah-project-list-item[data-motion-key]"), (card) => {
|
|
42
|
+
const box = card.getBoundingClientRect();
|
|
43
|
+
const view = card.closest(".ah-scroll")?.getBoundingClientRect() ?? null;
|
|
44
|
+
const onScreen = box.height > 0 && (view === null || (box.bottom > view.top && box.top < view.bottom));
|
|
45
|
+
return { id: card.dataset.motionKey ?? "", top: box.top, onScreen };
|
|
46
|
+
}).filter((card) => card.id !== "");
|
|
47
|
+
cards.sort((left, right) => left.top - right.top);
|
|
48
|
+
return cards.map(({ id, onScreen }) => ({ id, onScreen }));
|
|
49
|
+
}
|
|
50
|
+
/** First retry after a failed figure, in ms. */
|
|
51
|
+
export const FIGURE_RETRY_MS = 8_000;
|
|
52
|
+
/** The longest wait between retries, in ms. */
|
|
53
|
+
export const FIGURE_RETRY_CAP_MS = 120_000;
|
|
54
|
+
/**
|
|
55
|
+
* How long to wait before asking a failed project again: 8 s after the
|
|
56
|
+
* first failure, doubling with each one after, at most two minutes — a
|
|
57
|
+
* daemon mid-restart is back within seconds, a project that keeps failing
|
|
58
|
+
* is not hammered, and it is still asked again while the panel says
|
|
59
|
+
* "retrying". Only the failed projects are asked again.
|
|
60
|
+
*/
|
|
61
|
+
export function figureRetryDelay(failures) {
|
|
62
|
+
return Math.min(FIGURE_RETRY_CAP_MS, FIGURE_RETRY_MS * 2 ** Math.max(0, failures - 1));
|
|
63
|
+
}
|
|
64
|
+
/** The portfolio's line for figures that failed, e.g.
|
|
65
|
+
* `figures for 1 project failed · retrying`. */
|
|
66
|
+
export function failedFiguresLine(count) {
|
|
67
|
+
return `figures for ${count.toLocaleString("en-US")} ${count === 1 ? "project" : "projects"} failed · retrying`;
|
|
68
|
+
}
|
package/dist/lib/hooks.d.ts
CHANGED
|
@@ -10,7 +10,13 @@ export interface MetaFeed {
|
|
|
10
10
|
status: SubscriptionStatus;
|
|
11
11
|
error: ApiError | null;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
13
|
+
export interface MetaFeedOptions {
|
|
14
|
+
/** Land each metadata change as a React transition: the renders it causes
|
|
15
|
+
* yield to input, and a burst coalesces into the newest state. The room
|
|
16
|
+
* asks for it while an import runs; what renders is unchanged, only when. */
|
|
17
|
+
readonly transition?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function useMeta(catalog: CatalogPort, options?: MetaFeedOptions): MetaFeed;
|
|
14
20
|
export interface DaemonStatusFeed {
|
|
15
21
|
/** A connection or startup failure suitable for the disconnected state. */
|
|
16
22
|
readonly connectionError: string | null;
|
|
@@ -25,16 +31,28 @@ export interface DaemonStatusFeed {
|
|
|
25
31
|
readonly uptimeMs: number;
|
|
26
32
|
readonly receivedAt: number | null;
|
|
27
33
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
export declare function useDaemonStatus(catalog: CatalogPort, asked?: number): DaemonStatusFeed;
|
|
35
|
+
/** Project figures as they land, and the projects whose latest ask failed. */
|
|
36
|
+
export interface ProjectFigures {
|
|
37
|
+
readonly stats: Map<string, ProjectStats>;
|
|
38
|
+
/** Each earns a retry (`figureRetryDelay`); empty when none failed. */
|
|
39
|
+
readonly failed: ReadonlySet<string>;
|
|
40
|
+
}
|
|
41
|
+
/** Which project to ask next: `first` (the selected project) is read at
|
|
42
|
+
* every ask, so a click mid-hydration jumps the queue; `order` (the list as
|
|
43
|
+
* drawn, `figureOrder`) is read once per round. */
|
|
44
|
+
export interface FigurePriority {
|
|
45
|
+
readonly first: string | null;
|
|
46
|
+
readonly order: () => readonly string[];
|
|
47
|
+
}
|
|
33
48
|
/** Per-project heatmaps and contributions. These are global derived reads,
|
|
34
49
|
* so they begin only after the daemon's canonical publication gate. Four
|
|
35
|
-
* workers hydrate the list progressively
|
|
36
|
-
*
|
|
37
|
-
|
|
50
|
+
* workers hydrate the list progressively — the selected project first, then
|
|
51
|
+
* the cards on screen, then the rest (`priority`) — and unbounded
|
|
52
|
+
* Promise.all here once launched two full-corpus queries per project and
|
|
53
|
+
* starved cold ingestion. A project that fails is asked again on its own,
|
|
54
|
+
* with backoff; the others wait for the quiet periodic refresh. */
|
|
55
|
+
export declare function useProjectStats(catalog: CatalogPort, projectIds: string[], ready?: boolean, priority?: FigurePriority): ProjectFigures;
|
|
38
56
|
/** The selected project's usage decomposition — per-model days and the
|
|
39
57
|
* hour-of-day profile, over the same 53-week window the heatmap draws. */
|
|
40
58
|
export declare function useProjectUsage(catalog: CatalogPort, projectId: string | null, ready?: boolean): UsageResponse | null;
|
|
@@ -114,5 +132,9 @@ export declare const SEARCH_LIMIT = 200;
|
|
|
114
132
|
* while its successor is in flight — a list that blanks on every keystroke
|
|
115
133
|
* reads as a search that keeps failing — and only the newest request may
|
|
116
134
|
* land: a superseded one is aborted and its late result ignored.
|
|
135
|
+
*
|
|
136
|
+
* A change of `askAgain` re-asks an unchanged query. The room passes whether
|
|
137
|
+
* full text can answer, so the empty answer an unpublished index gave is
|
|
138
|
+
* replaced as soon as the index can answer.
|
|
117
139
|
*/
|
|
118
|
-
export declare function useSearch(catalog: CatalogPort, query: string, facets?: SearchFacets): SearchFeed;
|
|
140
|
+
export declare function useSearch(catalog: CatalogPort, query: string, facets?: SearchFacets, askAgain?: string | number | boolean): SearchFeed;
|