@vibefield/rosetta-room 0.1.2 → 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 (107) hide show
  1. package/README.md +82 -4
  2. package/dist/HistoryRoom.d.ts +15 -2
  3. package/dist/HistoryRoom.js +82 -25
  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 +39 -3
  9. package/dist/components/ListActivityNotice.d.ts +9 -1
  10. package/dist/components/ListActivityNotice.js +9 -2
  11. package/dist/components/SummaryPanels.d.ts +5 -0
  12. package/dist/components/SummaryPanels.js +16 -5
  13. package/dist/components/Transcript.d.ts +5 -0
  14. package/dist/components/Transcript.js +20 -5
  15. package/dist/components/artifacts/ArtifactLibrary.d.ts +14 -0
  16. package/dist/components/artifacts/ArtifactLibrary.js +156 -0
  17. package/dist/components/artifacts/content.d.ts +8 -0
  18. package/dist/components/artifacts/content.js +27 -0
  19. package/dist/components/artifacts/load-all.d.ts +5 -0
  20. package/dist/components/artifacts/load-all.js +31 -0
  21. package/dist/components/artifacts/preview.d.ts +4 -0
  22. package/dist/components/artifacts/preview.js +37 -0
  23. package/dist/components/artifacts/thumbnails.d.ts +13 -0
  24. package/dist/components/artifacts/thumbnails.js +43 -0
  25. package/dist/components/projects/ProjectList.d.ts +9 -3
  26. package/dist/components/projects/ProjectList.js +3 -3
  27. package/dist/components/projects/ProjectListItem.d.ts +9 -3
  28. package/dist/components/projects/ProjectListItem.js +18 -12
  29. package/dist/components/projects/ProjectsColumn.d.ts +4 -1
  30. package/dist/components/projects/ProjectsColumn.js +23 -9
  31. package/dist/components/search/SearchSheet.d.ts +39 -2
  32. package/dist/components/search/SearchSheet.js +81 -17
  33. package/dist/components/sessions/SessionList.d.ts +6 -1
  34. package/dist/components/sessions/SessionList.js +50 -20
  35. package/dist/components/sessions/SessionListItem.d.ts +3 -1
  36. package/dist/components/sessions/SessionListItem.js +17 -7
  37. package/dist/components/sessions/SessionsColumn.d.ts +3 -1
  38. package/dist/components/sessions/SessionsColumn.js +2 -2
  39. package/dist/components/sessions/session-display.d.ts +4 -1
  40. package/dist/components/sessions/session-display.js +13 -2
  41. package/dist/components/transcript/Attachments.js +6 -1
  42. package/dist/components/transcript/Document.d.ts +6 -1
  43. package/dist/components/transcript/Document.js +19 -6
  44. package/dist/components/transcript/ImportState.d.ts +35 -0
  45. package/dist/components/transcript/ImportState.js +86 -0
  46. package/dist/components/transcript/TranscriptLoading.js +15 -5
  47. package/dist/components/transcript/attachment-file-source.d.ts +2 -0
  48. package/dist/components/transcript/attachment-file-source.js +6 -6
  49. package/dist/components/transcript/attachment-gallery.d.ts +2 -1
  50. package/dist/components/transcript/attachment-gallery.js +2 -1
  51. package/dist/components/transcript/detail-parts.js +7 -6
  52. package/dist/components/transcript/timeline-meta-file-source.d.ts +2 -1
  53. package/dist/components/transcript/timeline-meta-file-source.js +45 -5
  54. package/dist/components/ui/EmptyState.d.ts +5 -1
  55. package/dist/components/ui/EmptyState.js +2 -2
  56. package/dist/components/ui/Meter.d.ts +8 -0
  57. package/dist/components/ui/Meter.js +9 -0
  58. package/dist/components/ui/SegmentedControl.d.ts +2 -0
  59. package/dist/components/ui/SegmentedControl.js +1 -1
  60. package/dist/components/ui/Veil.d.ts +2 -1
  61. package/dist/components/ui/Veil.js +9 -2
  62. package/dist/components/ui/index.d.ts +2 -0
  63. package/dist/components/ui/index.js +1 -0
  64. package/dist/fixtures/cold-import-corpus.d.ts +76 -0
  65. package/dist/fixtures/cold-import-corpus.js +349 -0
  66. package/dist/fixtures/cold-import-daemon.d.ts +25 -0
  67. package/dist/fixtures/cold-import-daemon.js +82 -0
  68. package/dist/fixtures/cold-import-schedule.d.ts +74 -0
  69. package/dist/fixtures/cold-import-schedule.js +191 -0
  70. package/dist/fixtures/cold-import.d.ts +151 -0
  71. package/dist/fixtures/cold-import.js +786 -0
  72. package/dist/fixtures/index.d.ts +2 -0
  73. package/dist/fixtures/index.js +21 -2
  74. package/dist/lib/activity-order.d.ts +15 -0
  75. package/dist/lib/activity-order.js +24 -1
  76. package/dist/lib/conversation-readiness.d.ts +48 -0
  77. package/dist/lib/conversation-readiness.js +149 -0
  78. package/dist/lib/figure-order.d.ts +35 -0
  79. package/dist/lib/figure-order.js +68 -0
  80. package/dist/lib/hooks.d.ts +32 -10
  81. package/dist/lib/hooks.js +118 -54
  82. package/dist/lib/image-media.d.ts +12 -2
  83. package/dist/lib/image-media.js +40 -6
  84. package/dist/lib/import-state.d.ts +98 -0
  85. package/dist/lib/import-state.js +129 -0
  86. package/dist/lib/ingest-activity.d.ts +51 -0
  87. package/dist/lib/ingest-activity.js +109 -10
  88. package/dist/lib/model.d.ts +16 -0
  89. package/dist/lib/model.js +27 -1
  90. package/dist/lib/search-sheet.d.ts +43 -0
  91. package/dist/lib/search-sheet.js +56 -7
  92. package/dist/lib/session-activity.d.ts +4 -1
  93. package/dist/lib/session-activity.js +4 -1
  94. package/dist/lib/title-search.d.ts +82 -0
  95. package/dist/lib/title-search.js +194 -0
  96. package/dist/lib/transcript/images.js +2 -2
  97. package/dist/lib/use-deferred-list-order.d.ts +6 -0
  98. package/dist/lib/use-deferred-list-order.js +8 -1
  99. package/dist/lib/use-ingest-activity.d.ts +5 -1
  100. package/dist/lib/use-ingest-activity.js +54 -18
  101. package/dist/ports.d.ts +15 -2
  102. package/dist/styles/artifacts.css +66 -0
  103. package/dist/styles/history-room.css +1 -0
  104. package/dist/styles/ingest.css +26 -3
  105. package/dist/styles/room.css +15 -0
  106. package/dist/styles/search.css +17 -0
  107. package/package.json +2 -2
@@ -1,4 +1,5 @@
1
- import type { ProjectBackfill, BackfillState } from "@vibefield/rosetta-protocol";
1
+ import type { ProjectBackfill } from "@vibefield/rosetta-protocol";
2
+ import type { ConversationCount } from "../../lib/conversation-readiness.js";
2
3
  import type { ProjectViewModel } from "../../lib/model.js";
3
4
  export interface ProjectListItemProps {
4
5
  readonly project: ProjectViewModel;
@@ -10,10 +11,15 @@ export interface ProjectListItemProps {
10
11
  readonly currentTimestamp: number;
11
12
  /** Canonical publication is still pending, so aggregate figures wait. */
12
13
  readonly ingestActive: boolean;
13
- readonly runtimeStates?: readonly BackfillState[] | undefined;
14
14
  /** This project's row in the daemon's per-project backfill fold; null
15
15
  * before the plan settles, and on a daemon too old to carry it. */
16
16
  readonly backfill: ProjectBackfill | null;
17
+ /** Its conversations (root sessions, no metadata-only placeholder) and how
18
+ * many are readable, from the catalog the lists draw; absent before the
19
+ * catalog names one. */
20
+ readonly conversations?: ConversationCount | null | undefined;
17
21
  readonly onProjectSelect: (projectId: string) => void;
18
22
  }
19
- export declare function ProjectListItem({ project, maximumLifetimeCost, isSelected, homeDirectory, currentTimestamp, ingestActive, runtimeStates, backfill, onProjectSelect, }: ProjectListItemProps): import("react").JSX.Element;
23
+ /** What a cooking card says while the import runs, in the lists' unit. */
24
+ export declare function importLabel(conversations: ConversationCount | null | undefined, backfill: ProjectBackfill | null): string;
25
+ export declare function ProjectListItem({ project, maximumLifetimeCost, isSelected, homeDirectory, currentTimestamp, ingestActive, backfill, conversations, onProjectSelect, }: ProjectListItemProps): import("react").JSX.Element;
@@ -1,6 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { AgentBadges } from "../../lib/agents.js";
3
- import { progressBytes } from "../../lib/ingest-activity.js";
4
3
  import { projectBackfillProgress } from "../../lib/ingest.js";
5
4
  import { lastActive, tildePath, tokenText } from "../../lib/format.js";
6
5
  import { coverage, fmtUsd, spendDescription } from "../../lib/spend.js";
@@ -15,7 +14,21 @@ function SpendFigure({ spend, unknown, description, }) {
15
14
  const figure = spend.costMicroUsd === null ? null : fmtUsd(spend.costMicroUsd);
16
15
  return (_jsxs("span", { className: "ah-project-list-item__token-figure", "data-coverage": state, title: unknown ? undefined : description, children: [_jsx("b", { children: unknown ? "—" : figure === null ? (state === "unavailable" ? "n/p" : "—") : figure.n }), _jsx("i", { children: unknown || figure === null ? "" : `${figure.u}${state === "partial" ? "+" : ""}` })] }));
17
16
  }
18
- export function ProjectListItem({ project, maximumLifetimeCost, isSelected, homeDirectory, currentTimestamp, ingestActive, runtimeStates, backfill, onProjectSelect, }) {
17
+ /** What a cooking card says while the import runs, in the lists' unit. */
18
+ export function importLabel(conversations, backfill) {
19
+ if (!conversations || conversations.total === 0)
20
+ return "Waiting for conversations";
21
+ const { readable, total } = conversations;
22
+ const noun = total === 1 ? "conversation" : "conversations";
23
+ // Figures are cross-session scans, which wait for publication.
24
+ if (readable >= total)
25
+ return total === 1 ? "Readable · figures after the import" : `All ${total.toLocaleString()} readable · figures after the import`;
26
+ // Nothing of it read yet: the board has streamed none of its bytes.
27
+ if (readable === 0 && (backfill === null || backfill.bytes_streamed === 0))
28
+ return "Not reached yet";
29
+ return `${readable.toLocaleString()} of ${total.toLocaleString()} ${noun} readable`;
30
+ }
31
+ export function ProjectListItem({ project, maximumLifetimeCost, isSelected, homeDirectory, currentTimestamp, ingestActive, backfill, conversations, onProjectSelect, }) {
19
32
  // The cooking card: identity (name, path, agents) renders as itself from
20
33
  // the first skim; only the quantitative slots carry the processing state.
21
34
  const isCooking = ingestActive || !project.statsReady;
@@ -24,17 +37,10 @@ export function ProjectListItem({ project, maximumLifetimeCost, isSelected, home
24
37
  const ingestFill = isCooking && backfill !== null
25
38
  ? projectBackfillProgress(backfill)
26
39
  : null;
40
+ // While the import runs the card counts what a reader can open, in the
41
+ // conversations the lists draw; after it, only the figures are waited for.
27
42
  const cookingLabel = isCooking
28
- ? backfill !== null
29
- ? backfill.sessions_done >= backfill.sessions_total
30
- ? "Preparing activity summaries"
31
- : runtimeStates?.includes("streaming")
32
- ? ingestFill !== null
33
- ? `Reading conversations · ${Math.floor(ingestFill * 100)}%`
34
- : `Reading conversations · ${progressBytes(backfill.bytes_streamed)}`
35
- : runtimeStates?.some((state) => state === "preparing" || state === "applying")
36
- ? "Organizing conversations" : "Waiting for conversations"
37
- : project.readiness === "ready" ? "Preparing activity summaries" : "Waiting for conversations"
43
+ ? ingestActive ? importLabel(conversations, backfill) : "Preparing activity summaries"
38
44
  : null;
39
45
  const lifetimeCost = project.lifetimeSpend.costMicroUsd ?? 0;
40
46
  const spendShare = maximumLifetimeCost > 0
@@ -2,6 +2,7 @@ import type { IngestProgress } from "@vibefield/rosetta-protocol";
2
2
  import type { ProjectViewModel } from "../../lib/model.js";
3
3
  import type { ActivityOrder } from "../../lib/activity-order.js";
4
4
  import type { IngestActivity } from "../../lib/ingest-activity.js";
5
+ import type { ConversationReadiness } from "../../lib/conversation-readiness.js";
5
6
  export type ProjectSort = "recent" | "token";
6
7
  export interface ProjectsColumnProps {
7
8
  readonly projects: readonly ProjectViewModel[];
@@ -14,6 +15,8 @@ export interface ProjectsColumnProps {
14
15
  /** The daemon's cold-start block; null on a daemon too old to carry it. */
15
16
  readonly ingest: IngestProgress | null;
16
17
  readonly activity: IngestActivity | null;
18
+ /** The room's fold of readable conversations, from the rows it draws. */
19
+ readonly conversations?: ConversationReadiness | undefined;
17
20
  readonly onProjectSelect: (projectId: string) => void;
18
21
  }
19
- export declare function ProjectsColumn({ projects, activityOrder, selectedProjectId, sort, onSortChange, homeDirectory, currentTimestamp, ingest, activity, onProjectSelect, }: ProjectsColumnProps): import("react").JSX.Element;
22
+ export declare function ProjectsColumn({ projects, activityOrder, selectedProjectId, sort, onSortChange, homeDirectory, currentTimestamp, ingest, activity, conversations, onProjectSelect, }: ProjectsColumnProps): import("react").JSX.Element;
@@ -2,19 +2,24 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useMemo } from "react";
3
3
  import { isCensusRunning, isIngestActive, projectBackfills } from "../../lib/ingest.js";
4
4
  import { UNASSIGNED_PROJECT_ID } from "../../lib/model.js";
5
- import { compareActivityRanks } from "../../lib/activity-order.js";
5
+ import { compareProjectOrder } from "../../lib/activity-order.js";
6
6
  import { PortfolioSummaryPanel } from "../SummaryPanels.js";
7
7
  import { ListSummaryHeader, ListToolbar, SegmentedControl } from "../ui/index.js";
8
- import { IngestStatus } from "../IngestStatus.js";
8
+ import { IngestStatus, IngestStatusFold } from "../IngestStatus.js";
9
9
  import { ProjectList } from "./ProjectList.js";
10
10
  import { useHostInputs } from "../../host-inputs.js";
11
11
  import { arrangeSections } from "../../lib/sections.js";
12
12
  import { FilterChips } from "../FilterChips.js";
13
- const PROJECT_SORT_OPTIONS = [
13
+ /** Spend figures load only after publication, so until then a token sort
14
+ * would rank every project at zero, by id: it waits, and says why. */
15
+ const TOKEN_SORT_WAITS = "Spend ranks arrive after the import";
16
+ const projectSortOptions = (importing) => [
14
17
  { value: "recent", label: "recent" },
15
- { value: "token", label: "token" },
18
+ importing
19
+ ? { value: "token", label: "token", disabled: true, title: TOKEN_SORT_WAITS, accessibleLabel: `token: ${TOKEN_SORT_WAITS}` }
20
+ : { value: "token", label: "token" },
16
21
  ];
17
- export function ProjectsColumn({ projects, activityOrder, selectedProjectId, sort, onSortChange, homeDirectory, currentTimestamp, ingest, activity, onProjectSelect, }) {
22
+ export function ProjectsColumn({ projects, activityOrder, selectedProjectId, sort, onSortChange, homeDirectory, currentTimestamp, ingest, activity, conversations, onProjectSelect, }) {
18
23
  const ingestActive = isIngestActive(ingest);
19
24
  // Metadata can arrive progressively; the status panel explains this
20
25
  // without covering projects that are already available.
@@ -25,12 +30,21 @@ export function ProjectsColumn({ projects, activityOrder, selectedProjectId, sor
25
30
  // "Spend" is estimated USD (§4.1.3); tokens only break ties, so wholly
26
31
  // unpriced projects still order among themselves.
27
32
  const maximumLifetimeCost = useMemo(() => projects.reduce((maximum, project) => Math.max(maximum, project.lifetimeSpend.costMicroUsd ?? 0), 0), [projects]);
28
- const visibleProjects = useMemo(() => [...projects].sort((left, right) => sort === "recent"
29
- ? compareActivityRanks(activityOrder.projects.get(left.row.id === UNASSIGNED_PROJECT_ID ? null : left.row.id)?.rankAt ?? null, activityOrder.projects.get(right.row.id === UNASSIGNED_PROJECT_ID ? null : right.row.id)?.rankAt ?? null, left.row.id, right.row.id)
33
+ // The import's order holds until publication: the token sort waits, and
34
+ // a token choice reads as recent meanwhile.
35
+ const importing = activityOrder.bootstrapping;
36
+ const effectiveSort = importing ? "recent" : sort;
37
+ const visibleProjects = useMemo(() => [...projects].sort((left, right) => effectiveSort === "recent"
38
+ ? compareProjectOrder(activityOrder, left.row.id === UNASSIGNED_PROJECT_ID ? null : left.row.id, right.row.id === UNASSIGNED_PROJECT_ID ? null : right.row.id, left.row.id, right.row.id)
30
39
  : (right.lifetimeSpend.costMicroUsd ?? 0) - (left.lifetimeSpend.costMicroUsd ?? 0)
31
- || right.lifetimeTokens - left.lifetimeTokens || left.row.id.localeCompare(right.row.id)), [projects, sort, activityOrder]);
40
+ || right.lifetimeTokens - left.lifetimeTokens || left.row.id.localeCompare(right.row.id)), [projects, effectiveSort, activityOrder]);
32
41
  // R3: the host's sections over the room's own order.
33
42
  const { projectSections, projectFilters } = useHostInputs();
34
43
  const sections = useMemo(() => (projectSections === undefined ? null : arrangeSections(projectSections, visibleProjects, (p) => p.row.id)), [projectSections, visibleProjects]);
35
- return (_jsxs("div", { className: "ah-col", children: [activity !== null ? (_jsx(ListSummaryHeader, { label: "Projects", count: projects.length, singularNoun: "project" })) : (_jsx(PortfolioSummaryPanel, { projects: projects, selectedProjectId: selectedProjectId, ingestActive: ingestActive, censusRunning: censusRunning, onProjectSelect: onProjectSelect })), _jsx(IngestStatus, { activity: activity }), _jsxs(ListToolbar, { children: [projectFilters !== undefined && projectFilters.length > 0 && _jsx(FilterChips, { filters: projectFilters }), _jsx(SegmentedControl, { value: sort, options: PROJECT_SORT_OPTIONS, accessibleLabel: "Rank projects by", className: "ah-sortseg", onValueChange: onSortChange })] }), _jsx("div", { className: "ah-veilhost", children: _jsx(ProjectList, { projects: visibleProjects, orderScope: `projects:${sort}`, selectedProjectId: selectedProjectId, maximumLifetimeCost: maximumLifetimeCost, homeDirectory: homeDirectory, currentTimestamp: currentTimestamp, ingestActive: ingestActive, runtimes: ingest?.runtimes, projectBackfills: backfills, pending: censusRunning, onProjectSelect: onProjectSelect, sections: sections }) })] }));
44
+ // The portfolio panel shows once figures land, whatever search is doing,
45
+ // and the import or search card sits under its head; so the end folds the
46
+ // card away under a head that is already there. Before any figure there
47
+ // is nothing to chart: the bare count heads the column.
48
+ const figuresLanded = useMemo(() => projects.some((project) => project.statsReady), [projects]);
49
+ return (_jsxs("div", { className: "ah-col", children: [activity === null || figuresLanded ? (_jsx(PortfolioSummaryPanel, { projects: projects, selectedProjectId: selectedProjectId, ingestActive: ingestActive, censusRunning: censusRunning, onProjectSelect: onProjectSelect })) : (_jsx(ListSummaryHeader, { label: "Projects", count: projects.length, singularNoun: "project" })), _jsx(IngestStatusFold, { activity: activity, children: _jsx(IngestStatus, { activity: activity }) }), _jsxs(ListToolbar, { children: [projectFilters !== undefined && projectFilters.length > 0 && _jsx(FilterChips, { filters: projectFilters }), _jsx(SegmentedControl, { value: effectiveSort, options: projectSortOptions(importing), accessibleLabel: "Rank projects by", className: "ah-sortseg", onValueChange: onSortChange })] }), _jsx("div", { className: "ah-veilhost", children: _jsx(ProjectList, { projects: visibleProjects, orderScope: `projects:${effectiveSort}`, selectedProjectId: selectedProjectId, maximumLifetimeCost: maximumLifetimeCost, homeDirectory: homeDirectory, currentTimestamp: currentTimestamp, ingestActive: ingestActive, importing: importing, projectBackfills: backfills, projectConversations: conversations?.byProject, pending: censusRunning, onProjectSelect: onProjectSelect, sections: sections }) })] }));
36
50
  }
@@ -2,7 +2,8 @@ import type { SearchBuildProgress, SearchHit, SearchReadiness, SessionRow } from
2
2
  import type { SearchFeed } from "../../lib/hooks.js";
3
3
  import type { ProjectViewModel } from "../../lib/model.js";
4
4
  import type { SearchResultsViewModel } from "../../lib/search-results.js";
5
- import type { SearchFilters } from "../../lib/search-sheet.js";
5
+ import type { TitleMatches } from "../../lib/title-search.js";
6
+ import type { SearchFilters, SheetOption } from "../../lib/search-sheet.js";
6
7
  export interface SearchSheetProps {
7
8
  readonly open: boolean;
8
9
  readonly onClose: () => void;
@@ -16,6 +17,9 @@ export interface SearchSheetProps {
16
17
  readonly progress: SearchBuildProgress | null;
17
18
  readonly canonicalReady: boolean | null;
18
19
  readonly ingestPaused: boolean;
20
+ /** An import is running: a Pending title row says it is not imported yet,
21
+ * as its session row does (the session list's `duringBackfill`). */
22
+ readonly duringBackfill?: boolean;
19
23
  /** Runtime families the daemon reads, for the agent chip and the scope line. */
20
24
  readonly agentKinds: readonly string[];
21
25
  /** The selected project, so the sheet can offer to stay inside it. */
@@ -24,6 +28,39 @@ export interface SearchSheetProps {
24
28
  readonly nowMs: number;
25
29
  readonly getRuntimeKind: (runtimeId: string) => string;
26
30
  readonly onOpenHit: (session: SessionRow, hit: SearchHit) => void;
31
+ /** Threads whose titles match, while full text cannot answer yet; null
32
+ * otherwise, and then the sheet is exactly the full-text sheet. */
33
+ readonly titles: TitleMatches | null;
34
+ /** Opens a title match's thread, as a hit's, with no message to land on. */
35
+ readonly onOpenSession: (session: SessionRow) => void;
27
36
  }
28
37
  export declare function headDomId(sessionId: string): string;
29
- export declare function SearchSheet({ open, onClose, query, onQuery, filters, onFilters, feed, results, readiness, progress, canonicalReady, ingestPaused, agentKinds, currentProject, homeDirectory, nowMs, getRuntimeKind, onOpenHit, }: SearchSheetProps): import("react").JSX.Element;
38
+ /** A full-text hit. `data-hit-kind` (inert, for the DOM contract) tells it
39
+ * from a title row, which says `title`. */
40
+ export declare function OptionRow({ option, active, home, nowMs, runtimeKind, onHover, onOpen, }: {
41
+ readonly option: SheetOption;
42
+ readonly active: boolean;
43
+ readonly home: string | null;
44
+ readonly nowMs: number;
45
+ readonly runtimeKind: string;
46
+ readonly onHover: () => void;
47
+ readonly onOpen: () => void;
48
+ }): import("react").JSX.Element;
49
+ /**
50
+ * The list while full text cannot answer: the titles that match, then the
51
+ * line that says what full text waits for (`note`, from `titlesNote`) — or,
52
+ * with none, a quiet that says both. Opening one opens its thread, which
53
+ * shows its own import state.
54
+ */
55
+ export declare function SheetTitles({ titles, query, active, nowMs, getRuntimeKind, onHover, onOpen, note, duringBackfill, }: {
56
+ readonly titles: TitleMatches;
57
+ readonly query: string;
58
+ readonly active: number;
59
+ readonly nowMs: number;
60
+ readonly getRuntimeKind: (runtimeId: string) => string;
61
+ readonly onHover: (index: number) => void;
62
+ readonly onOpen: (session: SessionRow) => void;
63
+ readonly note?: string;
64
+ readonly duringBackfill?: boolean;
65
+ }): import("react").JSX.Element;
66
+ export declare function SearchSheet({ open, onClose, query, onQuery, filters, onFilters, feed, results, readiness, progress, canonicalReady, ingestPaused, duringBackfill, agentKinds, currentProject, homeDirectory, nowMs, getRuntimeKind, onOpenHit, titles, onOpenSession, }: SearchSheetProps): import("react").JSX.Element;
@@ -17,9 +17,11 @@ import { sessionLastActive } from "../../lib/session-activity.js";
17
17
  import { SEARCH_LIMIT } from "../../lib/hooks.js";
18
18
  import { SearchGlyph } from "../../lib/icons.js";
19
19
  import { parseSnippet } from "../../lib/model.js";
20
- import { KIND_FILTER_OPTIONS, buildSheetLines, cleanSnippet, forgetQuery, hitWhen, isCursorKey, kindWord, moveCursor, moveSection, readRecentQueries, sessionCrumb, stateSentence, } from "../../lib/search-sheet.js";
20
+ import { NOT_IMPORTED_LABEL } from "../../lib/import-state.js";
21
+ import { FULL_TEXT_PENDING, titleCountLabel, titlesNote } from "../../lib/title-search.js";
22
+ import { KIND_FILTER_OPTIONS, buildSheetLines, cleanSnippet, forgetQuery, hitWhen, isCursorKey, keptTitleCursor, kindWord, moveCursor, moveSection, readRecentQueries, sessionCrumb, sheetMeter, shownTitleMatches, stateSentence, } from "../../lib/search-sheet.js";
21
23
  import { ActivityGlyph } from "../transcript/glyphs.js";
22
- import { SegmentedControl } from "../ui/index.js";
24
+ import { Meter, SegmentedControl } from "../ui/index.js";
23
25
  import { hasPrimaryModifier } from "./shortcut.js";
24
26
  import { useRoom, useRoomOverlay, useRoomPortal } from "../../room-context.js";
25
27
  const LIST_ID = "ah-sheet-listbox";
@@ -47,21 +49,46 @@ function HeadLine({ head, runtimeKind, nowMs, }) {
47
49
  const crumb = sessionCrumb(head.session);
48
50
  return (_jsxs("div", { id: headDomId(head.session.id), className: "ah-sheet__head", role: "presentation", style: { "--tint": head.project.tint }, children: [_jsx("i", { "aria-hidden": "true" }), _jsxs("span", { className: "ah-sheet__crumb", children: [_jsx("b", { children: head.project.row.name }), _jsx("i", { "aria-hidden": "true", children: "\u203A" }), _jsx("span", { "data-mono": crumb.mono || undefined, title: crumb.mono ? `Native session ${head.session.native_session_id}` : crumb.text, children: crumb.text })] }), _jsx(AgentMark, { kind: runtimeKind }), _jsxs("span", { className: "ah-sheet__headmeta", children: [_jsxs("span", { children: [head.hitCount, " ", head.hitCount === 1 ? "hit" : "hits"] }), _jsx("span", { "aria-hidden": "true", children: "\u00B7" }), _jsx("span", { children: dayLabel(sessionLastActive(head.session), nowMs) })] })] }));
49
51
  }
50
- function OptionRow({ option, active, home, nowMs, runtimeKind, onHover, onOpen, }) {
52
+ /** A full-text hit. `data-hit-kind` (inert, for the DOM contract) tells it
53
+ * from a title row, which says `title`. */
54
+ export function OptionRow({ option, active, home, nowMs, runtimeKind, onHover, onOpen, }) {
51
55
  const { hit, project, session } = option;
52
56
  const parts = parseSnippet(cleanSnippet(hit.snippet, home));
53
57
  const who = kindWord(hit.kind, agentLabel(runtimeKind));
54
58
  const when = hitWhen(hit.at, nowMs);
55
59
  const crumb = sessionCrumb(session);
56
60
  const spoken = parts.map((part) => part.text).join("");
57
- return (_jsxs("div", { id: option.id, role: "option", "aria-selected": active, "aria-label": `${who}: ${spoken} · ${when} · ${project.row.name} › ${crumb.text}`, className: "ah-sheet__row", onPointerMove: onHover, onClick: onOpen, children: [_jsx("span", { className: "ah-sheet__who", title: who, "aria-hidden": "true", children: _jsx(WhoGlyph, { kind: hit.kind, runtimeKind: runtimeKind }) }), _jsx("p", { className: "ah-sheet__snippet", children: parts.map((part, at) => part.mark ? _jsx("mark", { children: part.text }, at) : _jsx("span", { children: part.text }, at)) }), _jsx("span", { className: "ah-sheet__when", children: when })] }));
61
+ return (_jsxs("div", { id: option.id, role: "option", "aria-selected": active, "aria-label": `${who}: ${spoken} · ${when} · ${project.row.name} › ${crumb.text}`, className: "ah-sheet__row", "data-hit-kind": "fulltext", onPointerMove: onHover, onClick: onOpen, children: [_jsx("span", { className: "ah-sheet__who", title: who, "aria-hidden": "true", children: _jsx(WhoGlyph, { kind: hit.kind, runtimeKind: runtimeKind }) }), _jsx("p", { className: "ah-sheet__snippet", children: parts.map((part, at) => part.mark ? _jsx("mark", { children: part.text }, at) : _jsx("span", { children: part.text }, at)) }), _jsx("span", { className: "ah-sheet__when", children: when })] }));
62
+ }
63
+ /** A title match: the thread's name with the query marked, its project, and
64
+ * when it was last active — what a session row says, in a search row's shape.
65
+ * A thread the running import has not reached says so, as its session row
66
+ * does, rather than "Activity unknown". */
67
+ function TitleRow({ match, active, nowMs, duringBackfill, runtimeKind, onHover, onOpen, }) {
68
+ const { project, session, parts } = match;
69
+ const notImported = duringBackfill && session.stream_state === "pending";
70
+ const when = notImported ? NOT_IMPORTED_LABEL : dayLabel(sessionLastActive(session), nowMs);
71
+ const spoken = parts.map((part) => part.text).join("");
72
+ return (_jsxs("div", { id: match.id, role: "option", "aria-selected": active, "aria-label": `${spoken} · ${project.row.name} · ${when}`, className: "ah-sheet__row", "data-title": "", "data-hit-kind": "title", "data-standing": notImported ? "not-imported" : "ready", style: { "--tint": project.tint }, onPointerMove: onHover, onClick: onOpen, children: [_jsx("span", { className: "ah-sheet__who", title: agentLabel(runtimeKind), "aria-hidden": "true", children: _jsx(AgentMark, { kind: runtimeKind }) }), _jsxs("p", { className: "ah-sheet__snippet", children: [_jsxs("span", { className: "ah-sheet__project", children: [_jsx("i", { "aria-hidden": "true" }), project.row.name] }), parts.map((part, at) => part.mark ? _jsx("mark", { children: part.text }, at) : _jsx("span", { children: part.text }, at))] }), _jsx("span", { className: "ah-sheet__when", children: when })] }));
58
73
  }
59
74
  function Quiet({ title, children }) {
60
75
  return (_jsxs("div", { className: "ah-sheet__quiet", role: "presentation", children: [_jsx("strong", { children: title }), _jsx("p", { children: children })] }));
61
76
  }
77
+ /**
78
+ * The list while full text cannot answer: the titles that match, then the
79
+ * line that says what full text waits for (`note`, from `titlesNote`) — or,
80
+ * with none, a quiet that says both. Opening one opens its thread, which
81
+ * shows its own import state.
82
+ */
83
+ export function SheetTitles({ titles, query, active, nowMs, getRuntimeKind, onHover, onOpen, note = FULL_TEXT_PENDING, duringBackfill = false, }) {
84
+ if (titles.matches.length === 0) {
85
+ return (_jsxs(Quiet, { title: "No titles match", children: ["No session title contains every word of ", _jsx("code", { children: query.trim() }), ". ", note] }));
86
+ }
87
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "ah-sheet__recent-head ah-sheet__titles-head", role: "presentation", children: [_jsx("span", { children: "Titles that match" }), _jsx("span", { children: titleCountLabel(titles) })] }), titles.matches.map((match) => (_jsx(TitleRow, { match: match, active: match.index === active, nowMs: nowMs, duringBackfill: duringBackfill, runtimeKind: getRuntimeKind(match.session.runtime_id), onHover: () => onHover(match.index), onOpen: () => onOpen(match.session) }, match.id))), _jsx("p", { className: "ah-sheet__pending", role: "presentation", children: note })] }));
88
+ }
62
89
  const GRAMMAR_HINT = (_jsxs(_Fragment, { children: ["Every word must match. Put a phrase in quotes to match it exactly \u2014 ", _jsx("code", { children: "\"cargo test\"" }), ". Opening a result lands the transcript on that message."] }));
63
90
  // @atlas step search-query.sheet
64
- export function SearchSheet({ open, onClose, query, onQuery, filters, onFilters, feed, results, readiness, progress, canonicalReady, ingestPaused, agentKinds, currentProject, homeDirectory, nowMs, getRuntimeKind, onOpenHit, }) {
91
+ export function SearchSheet({ open, onClose, query, onQuery, filters, onFilters, feed, results, readiness, progress, canonicalReady, ingestPaused, duringBackfill = false, agentKinds, currentProject, homeDirectory, nowMs, getRuntimeKind, onOpenHit, titles, onOpenSession, }) {
65
92
  useRoomOverlay(open);
66
93
  const container = useRoomPortal();
67
94
  const { storage } = useRoom();
@@ -77,20 +104,46 @@ export function SearchSheet({ open, onClose, query, onQuery, filters, onFilters,
77
104
  if (open)
78
105
  setRecent(readRecentQueries(storage));
79
106
  }, [open]);
107
+ // While full text cannot answer, the list is the titles that match — unless
108
+ // the index did answer with hits after all, which always win.
109
+ const titleMatches = shownTitleMatches(query, titles, lines.length);
80
110
  // New rows → the first one is the cursor, so Enter lands at once. Keyed on
81
111
  // the rows' identities, not the array: the model is rebuilt on every clock
82
112
  // tick, and a cursor that jumped home every thirty seconds would be a bug.
83
- const walking = emptyQuery ? recent.length : options.length;
84
- const rowsKey = emptyQuery ? `recent\n${recent.join("\n")}` : options.map((o) => o.id).join("\n");
113
+ const walking = emptyQuery
114
+ ? recent.length
115
+ : titleMatches !== null
116
+ ? titleMatches.length
117
+ : options.length;
118
+ const rowsKey = emptyQuery
119
+ ? `recent\n${recent.join("\n")}`
120
+ : titleMatches !== null
121
+ ? `titles\n${titleMatches.map((m) => m.id).join("\n")}`
122
+ : options.map((o) => o.id).join("\n");
123
+ // Titles re-rank under an unchanged query while an import lands activity
124
+ // and new rows: the cursor stays on its thread rather than jumping home.
125
+ const titleCursor = useRef({ query: "", id: null });
85
126
  useEffect(() => {
127
+ const kept = keptTitleCursor(titleMatches, titleCursor.current, query);
128
+ if (kept >= 0) {
129
+ setActive(kept);
130
+ return;
131
+ }
86
132
  movedBy.current = "keyboard";
87
- setActive(rowsKey === "" || rowsKey === "recent\n" ? -1 : 0);
133
+ setActive(walking === 0 ? -1 : 0);
88
134
  }, [rowsKey]);
135
+ useEffect(() => {
136
+ titleCursor.current = { query, id: titleMatches?.[active]?.id ?? null };
137
+ }, [active, titleMatches, query]);
89
138
  const listRef = useRef(null);
90
139
  useEffect(() => {
91
140
  if (movedBy.current !== "keyboard" || active < 0)
92
141
  return;
93
- const id = emptyQuery ? `ah-sheet-recent-${active}` : options[active]?.id;
142
+ const id = emptyQuery
143
+ ? `ah-sheet-recent-${active}`
144
+ : titleMatches !== null
145
+ ? titleMatches[active]?.id
146
+ : options[active]?.id;
94
147
  const list = listRef.current;
95
148
  const row = id === undefined ? null : document.getElementById(id);
96
149
  if (list === null || row === null)
@@ -104,7 +157,7 @@ export function SearchSheet({ open, onClose, query, onQuery, filters, onFilters,
104
157
  list.scrollTop = top - headroom;
105
158
  else if (rect.bottom > frame.bottom)
106
159
  list.scrollTop = top - (list.clientHeight - rect.height) + 4;
107
- }, [active, emptyQuery, options]);
160
+ }, [active, emptyQuery, options, titleMatches]);
108
161
  const hover = (index) => {
109
162
  if (index === active)
110
163
  return;
@@ -149,6 +202,12 @@ export function SearchSheet({ open, onClose, query, onQuery, filters, onFilters,
149
202
  onQuery(remembered);
150
203
  return;
151
204
  }
205
+ if (titleMatches !== null) {
206
+ const match = titleMatches[active];
207
+ if (match !== undefined)
208
+ onOpenSession(match.session);
209
+ return;
210
+ }
152
211
  const option = options[active];
153
212
  if (option !== undefined)
154
213
  onOpenHit(option.session, option.hit);
@@ -164,17 +223,17 @@ export function SearchSheet({ open, onClose, query, onQuery, filters, onFilters,
164
223
  counts: results?.counts ?? null,
165
224
  limit: SEARCH_LIMIT,
166
225
  });
167
- const meter = building && progress !== null && progress.documents_total > 0
168
- ? `${Math.min(100, Math.max(2, (100 * progress.documents_done) / progress.documents_total)).toFixed(1)}%`
169
- : building
170
- ? "8%"
171
- : null;
226
+ // A real document count fills the meter, work without one sweeps, and
227
+ // nothing is drawn while nothing moves (a paused import, a failed index).
228
+ const meter = sheetMeter({ readiness, progress, canonicalReady, ingestPaused });
172
229
  const scopeLine = agentKinds.length === 0 ? "your whole agentic past" : `across ${agentKinds.join(" · ")}`;
173
230
  const activeId = emptyQuery
174
231
  ? active >= 0 && recent[active] !== undefined
175
232
  ? `ah-sheet-recent-${active}`
176
233
  : undefined
177
- : options[active]?.id;
234
+ : titleMatches !== null
235
+ ? titleMatches[active]?.id
236
+ : options[active]?.id;
178
237
  const scopeOptions = useMemo(() => {
179
238
  if (currentProject === null)
180
239
  return null;
@@ -195,6 +254,11 @@ export function SearchSheet({ open, onClose, query, onQuery, filters, onFilters,
195
254
  setRecent(forgetQuery(storage, remembered));
196
255
  }, children: "\u00D7" })] }, remembered)))] })), _jsx(Quiet, { title: recent.length > 0 ? "Or search for something new" : "Search your whole agentic past", children: GRAMMAR_HINT })] }));
197
256
  }
257
+ else if (titleMatches !== null && titles !== null) {
258
+ // Titles the room already holds, while the full-text index is still on
259
+ // its way.
260
+ body = (_jsx(SheetTitles, { titles: titles, query: query, active: active, nowMs: nowMs, getRuntimeKind: getRuntimeKind, onHover: hover, onOpen: onOpenSession, note: titlesNote(readiness, canonicalReady), duringBackfill: duringBackfill }));
261
+ }
198
262
  else if (lines.length === 0) {
199
263
  body = feed.error !== null ? (_jsx(Quiet, { title: "Search failed", children: feed.error })) : building && results === null ? (_jsx(Quiet, { title: canonicalReady ? "Search is still being prepared" : "History is still being imported", children: sentence })) : results !== null ? (_jsxs(Quiet, { title: "Nothing matched", children: ["No indexed message contains every word of ", _jsx("code", { children: feed.query }), ". Try fewer words, or a phrase in quotes."] })) : null;
200
264
  }
@@ -227,5 +291,5 @@ export function SearchSheet({ open, onClose, query, onQuery, filters, onFilters,
227
291
  }, children: "\u00D7" })), _jsx("kbd", { className: "ah-kbd", "aria-hidden": "true", children: "esc" })] }), _jsxs("div", { className: "ah-sheet__scope", children: [scopeOptions !== null && (_jsx(SegmentedControl, { value: filters.scope, options: scopeOptions, accessibleLabel: "Where to search", onValueChange: (scope) => narrow({ ...filters, scope }) })), _jsx(SegmentedControl, { value: filters.kind, options: KIND_FILTER_OPTIONS, accessibleLabel: "Which kind of message", onValueChange: (kind) => narrow({ ...filters, kind }) }), agentKinds.length > 1 && (_jsxs("select", { className: "ah-chipselect", "data-set": filters.agent !== null || undefined, "aria-label": "Which agent", value: filters.agent ?? "", onChange: (event) => narrow({
228
292
  ...filters,
229
293
  agent: event.target.value === "" ? null : event.target.value,
230
- }), children: [_jsx("option", { value: "", children: "any agent" }), agentKinds.map((kind) => (_jsx("option", { value: kind, children: agentLabel(kind) }, kind)))] }))] }), _jsx("div", { ref: listRef, className: "ah-sheet__list", id: LIST_ID, role: "listbox", "aria-label": emptyQuery ? "Recent searches" : "Search results", "data-stale": feed.searching && results !== null ? "" : undefined, children: body }), _jsxs("div", { className: "ah-sheet__foot", children: [meter !== null && (_jsx("div", { className: "ah-meter", "aria-hidden": "true", children: _jsx("i", { style: { width: meter } }) })), _jsx("span", { className: "ah-sheet__count", role: "status", "aria-live": "polite", "data-tone": feed.error !== null ? "warn" : undefined, children: feed.searching && results === null && !emptyQuery ? "searching…" : sentence }), _jsx("span", { className: "ah-sheet__scopeline", title: scopeLine, children: scopeLine }), _jsxs("span", { className: "ah-sheet__keys", "aria-hidden": "true", children: [_jsxs("span", { children: [_jsx("kbd", { className: "ah-kbd", children: "\u2191\u2193" }), " move"] }), _jsxs("span", { children: [_jsx("kbd", { className: "ah-kbd", children: "\u21B5" }), " open"] }), _jsxs("span", { children: [_jsx("kbd", { className: "ah-kbd", children: "esc" }), " close"] })] })] })] })] }) }));
294
+ }), children: [_jsx("option", { value: "", children: "any agent" }), agentKinds.map((kind) => (_jsx("option", { value: kind, children: agentLabel(kind) }, kind)))] }))] }), _jsx("div", { ref: listRef, className: "ah-sheet__list", id: LIST_ID, role: "listbox", "aria-label": emptyQuery ? "Recent searches" : titleMatches !== null ? "Titles that match" : "Search results", "data-stale": feed.searching && results !== null && titleMatches === null ? "" : undefined, children: body }), _jsxs("div", { className: "ah-sheet__foot", children: [meter !== undefined && _jsx(Meter, { fraction: meter }), _jsx("span", { className: "ah-sheet__count", role: "status", "aria-live": "polite", "data-tone": feed.error !== null ? "warn" : undefined, children: feed.searching && results === null && !emptyQuery ? "searching…" : sentence }), _jsx("span", { className: "ah-sheet__scopeline", title: scopeLine, children: scopeLine }), _jsxs("span", { className: "ah-sheet__keys", "aria-hidden": "true", children: [_jsxs("span", { children: [_jsx("kbd", { className: "ah-kbd", children: "\u2191\u2193" }), " move"] }), _jsxs("span", { children: [_jsx("kbd", { className: "ah-kbd", children: "\u21B5" }), " open"] }), _jsxs("span", { children: [_jsx("kbd", { className: "ah-kbd", children: "esc" }), " close"] })] })] })] })] }) }));
231
295
  }
@@ -8,8 +8,13 @@ export interface SessionListProps {
8
8
  readonly getRuntimeKind: (runtimeId: string) => string;
9
9
  readonly selectedSessionId: string | null;
10
10
  readonly currentTimestamp: number;
11
- /** A backfill is running — unindexed sessions cook rather than lie. */
11
+ /** A backfill is running — unindexed sessions cook rather than lie, and
12
+ * the ones it has not reached are drawn in date-free groups, "Still
13
+ * importing" on top and "Not imported yet" at the foot. */
12
14
  readonly duringBackfill: boolean;
15
+ /** Ids some session names as its parent (`parentIds`): a Pending row with
16
+ * children and no metadata of its own has no transcript to import. */
17
+ readonly parentIds?: ReadonlySet<string> | undefined;
13
18
  /** The census is still naming sessions: the empty state yields to the
14
19
  * section's veil, because only the ready may claim emptiness. */
15
20
  readonly pending: boolean;
@@ -2,55 +2,85 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { dayLabel } from "../../lib/format.js";
3
3
  import { sessionLastActive } from "../../lib/session-activity.js";
4
4
  import { useListMotion } from "../../lib/use-list-motion.js";
5
- import { activityDay } from "../../lib/activity-order.js";
5
+ import { activityDay, compareNotImported } from "../../lib/activity-order.js";
6
+ import { arrivalsLabel, importStanding, newestReadableSource, NOT_IMPORTED_LABEL, notImportedAround, STILL_IMPORTING_LABEL, } from "../../lib/import-state.js";
6
7
  import { useDeferredListOrder } from "../../lib/use-deferred-list-order.js";
7
8
  import { ListActivityNotice } from "../ListActivityNotice.js";
8
9
  import { FoldLine, SectionHead, useOpenFolds } from "../ListSections.js";
9
10
  import { EmptyState } from "../ui/index.js";
10
11
  import { SessionListItem } from "./SessionListItem.js";
11
12
  const sessionId = (session) => session.id;
13
+ const NO_PARENTS = new Set();
12
14
  function groupSessionsByDay(positions, sessions, currentTimestamp) {
13
15
  const groups = [];
14
- for (const { id, day } of positions) {
16
+ for (const { id, day, pending = false, importing = false } of positions) {
15
17
  const session = sessions.get(id);
16
18
  if (!session)
17
19
  continue;
18
- const label = dayLabel(day, currentTimestamp);
19
20
  const currentGroup = groups.at(-1);
20
- if (currentGroup?.day === day) {
21
+ if (currentGroup?.day === day && currentGroup.pending === pending && currentGroup.importing === importing) {
21
22
  currentGroup.sessions.push(session);
22
23
  }
23
24
  else {
24
- groups.push({ day, label, sessions: [session] });
25
+ const label = !pending ? dayLabel(day, currentTimestamp) : importing ? STILL_IMPORTING_LABEL : NOT_IMPORTED_LABEL;
26
+ groups.push({ day, pending, importing, label, sessions: [session] });
25
27
  }
26
28
  }
27
- return groups;
29
+ // A not-imported head counts its rows: "Still importing · 2".
30
+ return groups.map(group => group.pending
31
+ ? { ...group, label: `${group.label} · ${group.sessions.length.toLocaleString()}` } : group);
28
32
  }
29
33
  export function SessionList(props) {
30
34
  const scope = `browse:${props.sessions[0]?.project_id ?? "empty"}`;
31
35
  const sections = props.sections ?? null;
32
36
  const folds = useOpenFolds(sections, sessionId, props.selectedSessionId);
33
- const position = (session) => ({ id: session.id, day: activityDay(sessionLastActive(session)) });
37
+ const parents = props.parentIds ?? NO_PARENTS;
38
+ const standing = (session) => importStanding(session, props.duringBackfill, parents.has(session.id));
39
+ const notImported = (session) => standing(session) === "not-imported";
40
+ // The sessions the import has not reached have no recorded activity to
41
+ // rank or date them, so they sit in two date-free groups, newest source
42
+ // first: the ones newer than every readable row above those rows ("Still
43
+ // importing"), the rest at the foot ("Not imported yet"). A flip then
44
+ // moves a top row a short way down into its day.
45
+ const newestReadable = newestReadableSource(props.sessions, session => standing(session) === null);
46
+ const stillImporting = (session) => newestReadable === null || session.updated_at > newestReadable;
47
+ const position = (session) => !notImported(session)
48
+ ? { id: session.id, day: activityDay(sessionLastActive(session)) }
49
+ : stillImporting(session) ? { id: session.id, day: null, pending: true, importing: true }
50
+ : { id: session.id, day: null, pending: true };
51
+ const roomOrder = (rows) => notImportedAround(rows, notImported, stillImporting, compareNotImported);
34
52
  // A folded section's rows are the reader's to open, so they never wait on
35
53
  // the held geometry: only the open runs go through it.
36
54
  const layout = useDeferredListOrder(sections === null
37
- ? props.sessions.map(position)
55
+ ? roomOrder(props.sessions).map(position)
38
56
  : sections.flatMap(entry => entry.section.fold !== undefined ? [] :
39
- entry.rows.map(session => ({ ...position(session), section: entry.index }))), scope);
57
+ (entry.order === "room" ? roomOrder(entry.rows) : entry.rows)
58
+ .map(session => ({ ...position(session), section: entry.index }))), scope);
40
59
  const byId = new Map(props.sessions.map(session => [session.id, session]));
41
60
  const days = groupSessionsByDay(layout.items, byId, props.currentTimestamp);
42
61
  const motionRef = useListMotion(JSON.stringify(layout.items), scope, layout.scrollRef);
43
- const drawRow = (session) => (_jsx(SessionListItem, { session: session, facts: props.factsBySessionId.get(session.id) ?? null, runtimeKind: props.getRuntimeKind(session.runtime_id), isSelected: session.id === props.selectedSessionId, currentTimestamp: props.currentTimestamp, duringBackfill: props.duringBackfill, onSessionSelect: props.onSessionSelect }, `session:${session.id}`));
62
+ const drawRow = (session) => (_jsx(SessionListItem, { session: session, facts: props.factsBySessionId.get(session.id) ?? null, runtimeKind: props.getRuntimeKind(session.runtime_id), isSelected: session.id === props.selectedSessionId, currentTimestamp: props.currentTimestamp, duringBackfill: props.duringBackfill, metadataOnly: standing(session) === "unavailable", onSessionSelect: props.onSessionSelect }, `session:${session.id}`));
63
+ // A held group whose rows moved on says why until the reader applies the
64
+ // new order: a not-imported group counts the rows the import opened, and
65
+ // only a new date is "Activity updated".
66
+ const head = (group) => {
67
+ if (group.pending) {
68
+ const imported = group.sessions.filter(session => !notImported(session)).length;
69
+ return imported > 0 ? arrivalsLabel({ count: imported, older: false }) : group.label;
70
+ }
71
+ return group.sessions.some(session => notImported(session) || activityDay(sessionLastActive(session)) !== group.day)
72
+ ? "Activity updated" : group.label;
73
+ };
44
74
  // Headers and rows share one key space. Moving from Yesterday to Today
45
75
  // preserves the actual button, its keyboard focus and its animation.
46
76
  const drawDays = (groups, keyPrefix) => groups.flatMap((group) => [
47
- _jsx("div", { className: "ah-day", children: group.sessions.some(session => activityDay(sessionLastActive(session)) !== group.day)
48
- ? "Activity updated" : group.label }, `day:${keyPrefix}${group.day}`),
77
+ _jsx("div", { className: "ah-day", "data-not-imported": !group.pending ? undefined : group.importing ? "top" : "foot", children: head(group) }, `day:${keyPrefix}${!group.pending ? group.day : group.importing ? "still-importing" : "not-imported"}`),
49
78
  ...group.sessions.map(drawRow),
50
79
  ]);
51
- const drawRun = (entry, rows) => entry.order === "room"
52
- ? drawDays(groupSessionsByDay(rows.map(position), byId, props.currentTimestamp), `${entry.index}:`)
53
- : rows.map(drawRow);
80
+ // An open run draws the held geometry; a folded one, the room's order now.
81
+ const drawRun = (entry, positions) => entry.order === "room"
82
+ ? drawDays(groupSessionsByDay(positions, byId, props.currentTimestamp), `${entry.index}:`)
83
+ : positions.flatMap(item => byId.get(item.id) ?? []).map(drawRow);
54
84
  const sectioned = sections === null ? null : sections.flatMap((entry) => {
55
85
  if (entry.section.fold !== undefined) {
56
86
  if (entry.rows.length === 0 && entry.section.fold.count === undefined)
@@ -58,19 +88,19 @@ export function SessionList(props) {
58
88
  const open = folds.isOpen(entry.section.key);
59
89
  return [
60
90
  _jsx(FoldLine, { arranged: entry, open: open, onToggle: () => folds.toggle(entry.section.key) }, `section:${entry.section.key}`),
61
- ...(open ? drawRun(entry, entry.rows) : []),
91
+ ...(open ? drawRun(entry, (entry.order === "room" ? roomOrder(entry.rows) : entry.rows).map(position)) : []),
62
92
  ];
63
93
  }
64
- const rows = layout.items.flatMap(item => item.section === entry.index ? byId.get(item.id) ?? [] : []);
65
- if (rows.length === 0)
94
+ const positions = layout.items.filter(item => item.section === entry.index && byId.has(item.id));
95
+ if (positions.length === 0)
66
96
  return [];
67
97
  return [
68
98
  ...(entry.section.title === undefined ? [] : [
69
99
  _jsx(SectionHead, { sectionKey: entry.section.key, children: entry.section.title }, `section:${entry.section.key}`),
70
100
  ]),
71
- ...drawRun(entry, rows),
101
+ ...drawRun(entry, positions),
72
102
  ];
73
103
  });
74
104
  return (_jsxs("div", { className: "ah-list-view", ...layout.hostProps, children: [_jsxs("div", { className: "ah-scroll ah-session-list ah-motion-list", ref: motionRef, onScroll: layout.onScroll, children: [sectioned ?? drawDays(days, ""), props.sessions.length === 0 && !props.pending && (_jsx(EmptyState, { title: props.emptyState?.title ?? "No sessions here yet", description: props.emptyState?.description ??
75
- "Sessions appear as rosettad reads this project's agent stores." }))] }), _jsx(ListActivityNotice, { pending: layout.pending, onShow: layout.apply, noun: "sessions" })] }));
105
+ "Sessions appear as rosettad reads this project's agent stores." }))] }), _jsx(ListActivityNotice, { pending: layout.pending, onShow: layout.apply, noun: "sessions", arrivals: layout.arrivals })] }));
76
106
  }
@@ -8,6 +8,8 @@ export interface SessionListItemProps {
8
8
  readonly currentTimestamp: number;
9
9
  /** A backfill is running — an unindexed session's dot says "indexing". */
10
10
  readonly duringBackfill: boolean;
11
+ /** No transcript of its own was found; see `isMetadataOnly`. */
12
+ readonly metadataOnly?: boolean;
11
13
  readonly onSessionSelect: (session: SessionRow) => void;
12
14
  }
13
- export declare function SessionListItem({ session, facts, runtimeKind, isSelected, currentTimestamp, duringBackfill, onSessionSelect, }: SessionListItemProps): import("react").JSX.Element;
15
+ export declare function SessionListItem({ session, facts, runtimeKind, isSelected, currentTimestamp, duringBackfill, metadataOnly, onSessionSelect, }: SessionListItemProps): import("react").JSX.Element;