@vibefield/rosetta-room 0.1.9 → 0.1.11

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 CHANGED
@@ -52,7 +52,7 @@ sockets stay the simulator's.
52
52
  | `CatalogPort` | `subscribeMeta` (runtimes, projects, every session row, live: one snapshot then mutations) · `status` → `CatalogStatus` · `projectStats(projectId, window)` → `ProjectStats` (per-day heat and per-session facts) · `usage` · `dayUsage` · `search(CatalogSearch)` · optional `onConnectionChange`, `unavailable` (the host's own words for why the index cannot answer), `boost` and `projectStatsBatch` (every listed project's figures in one ask; present, the room asks it once per refresh instead of `projectStats` per project) | its client's REST and `/ws/meta` (`catalogOver`) |
53
53
  | `SessionPort` | `open(sessionId)` → a `SessionClient` bound to that session (its live subscription, child threads and team members each open their own; entries, report work, commands, plans, file targets, stored members), or a promise of one; `close(sessionId)` | the one client for every session; close is nothing |
54
54
  | `AssetSource` | `imageAssetUrl(asset, variant)` → a URL, null, or a promise of either · `attachmentAssetUrl(asset)` → the attachment's address, for identity and can-open only · optional `mediaAssetUrl(asset)` → an address a `<video src>` can load, null, or a promise of either | the daemon's own URLs |
55
- | `HostPort` (optional) | `homeDir` · `platform` · `openInBrowser(name, bytes, browserId?)` · optional `browsers()` · `favicon(site)` · optional `worktree: { open, gitFacts, fileAction, ports }` | the Electron bridge (`hostPortOver`) |
55
+ | `HostPort` (optional) | `homeDir` · `platform` · `openInBrowser(name, bytes, browserId?)` · optional `browsers()` · `favicon(site)` · optional `copyText(text)` (0.1.11: every copy the room makes, for a shell whose page may not write the clipboard) · optional `worktree: { open, gitFacts, fileAction, ports }`, with optional `worktreeSizes(root, generation, paths)` (0.1.11: what the worktrees on screen hold on disk, asked by name) | the Electron bridge (`hostPortOver`) |
56
56
 
57
57
  - **The room opens a session at most once at a time and follows every `open`
58
58
  with exactly one `close`**, when nothing in it reads that session any more.
@@ -19,7 +19,9 @@ import { useFileContent } from "./use-file-content.js";
19
19
  import { FileViewerBrowsers } from "./FileViewerBrowsers.js";
20
20
  import { FileViewerHeader } from "./FileViewerHeader.js";
21
21
  import { fmtBytes } from "../../lib/format.js";
22
+ import { useCopyText } from "../../room-context.js";
22
23
  export function FileViewerDialog({ handle, source, tint, homeDirectory, onClose, onReceipt, openInBrowser, listBrowsers, asDiff = false, renderMarkdown, gallery, }) {
24
+ const copy = useCopyText();
23
25
  const [attempt, setAttempt] = useState(0);
24
26
  const content = useFileContent(handle, source, asDiff, attempt, Boolean(gallery));
25
27
  const retry = () => { gallery?.onRetry(); setAttempt(value => value + 1); };
@@ -56,8 +58,7 @@ export function FileViewerDialog({ handle, source, tint, homeDirectory, onClose,
56
58
  label: "Copy path",
57
59
  glyph: "copy",
58
60
  run: () => {
59
- void navigator.clipboard
60
- .writeText(path)
61
+ void copy(path)
61
62
  .then(() => onReceipt?.("path copied"))
62
63
  .catch(() => onReceipt?.("the clipboard refused"));
63
64
  },
@@ -35,6 +35,13 @@ export function parseDiff(text) {
35
35
  if (text.trim() === "")
36
36
  return EMPTY;
37
37
  const lines = text.split("\n");
38
+ // git ends its output with a newline, so the split's last piece is the end
39
+ // of the text, not a line of it. Left in, it reads below as a blank context
40
+ // line git dropped the space of: one phantom row under every diff, numbered
41
+ // one past its last hunk. A blank line that IS in the hunk comes before it
42
+ // and stays.
43
+ if (lines[lines.length - 1] === "")
44
+ lines.pop();
38
45
  const hunks = [];
39
46
  let oldPath = null;
40
47
  let newPath = null;
@@ -16,7 +16,12 @@ import { useMemo, useRef } from "react";
16
16
  import { useVirtualizer } from "@tanstack/react-virtual";
17
17
  import { parseDiff } from "../diff/index.js";
18
18
  import { highlight, languageFor, PLAIN_TEXT } from "../syntax/index.js";
19
- /** Matches `--ah-code-line`; the virtualizer scrolls by it. */
19
+ /** One visual row's minimum and unmeasured estimate, in CSS px. Matches
20
+ * `--ah-code-line`. A line longer than the pane wraps (the stylesheet's
21
+ * `pre-wrap`), so a row is as tall as its text: the virtualizer measures each
22
+ * drawn row from its DOM box and places the rows after it by that, as the
23
+ * code view does. A row held to this height would spill a long line over its
24
+ * neighbours. */
20
25
  const LINE_HEIGHT = 19;
21
26
  const OVERSCAN = 24;
22
27
  const MARK = {
@@ -72,6 +77,6 @@ export function DiffBody({ unified, name }) {
72
77
  const gutter = `${String(Math.max(...rows.map((row) => row.kind === "line" ? Math.max(row.line.oldNumber ?? 0, row.line.newNumber ?? 0) : 0))).length}ch`;
73
78
  return (_jsxs("div", { className: "ah-fileview__scroll ah-code ah-diff", ref: scrollerRef, style: { "--ah-code-digits": gutter }, children: [_jsxs("p", { className: "ah-diff__stat", children: [_jsxs("span", { className: "tnum", children: ["+", parsed.added, " \u2212", parsed.deleted] }), parsed.renamedFrom !== null && (_jsxs("span", { className: "ah-diff__renamed", title: parsed.renamedFrom, children: ["renamed from ", parsed.renamedFrom] }))] }), _jsx("div", { className: "ah-code__sizer", style: { height: virtualizer.getTotalSize() }, children: virtualizer.getVirtualItems().map((item) => {
74
79
  const row = rows[item.index];
75
- return (_jsx("div", { className: "ah-code__line", "data-diff": row.kind === "line" ? row.line.kind : "hunk", style: { height: LINE_HEIGHT, transform: `translateY(${item.start}px)` }, children: row.kind === "hunk" ? (_jsxs("span", { className: "ah-diff__hunk", children: [_jsx("span", { className: "ah-diff__range tnum", children: row.range }), row.header !== "" && _jsx("span", { className: "ah-diff__context", children: row.header })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "ah-code__num", children: row.line.oldNumber ?? "" }), _jsx("span", { className: "ah-code__num", children: row.line.newNumber ?? "" }), _jsx("span", { className: "ah-diff__mark", children: MARK[row.line.kind] }), _jsx("code", { children: row.line.kind === "note" ? (_jsx("em", { children: row.line.text })) : (row.tokens.map((token, at) => token.kind === "plain" ? (token.text) : (_jsx("span", { "data-t": token.kind, children: token.text }, at)))) })] })) }, item.key));
80
+ return (_jsx("div", { className: "ah-code__line", "data-index": item.index, "data-diff": row.kind === "line" ? row.line.kind : "hunk", ref: virtualizer.measureElement, style: { transform: `translateY(${item.start}px)` }, children: row.kind === "hunk" ? (_jsxs("span", { className: "ah-diff__hunk", children: [_jsx("span", { className: "ah-diff__range tnum", children: row.range }), row.header !== "" && _jsx("span", { className: "ah-diff__context", children: row.header })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "ah-code__num", children: row.line.oldNumber ?? "" }), _jsx("span", { className: "ah-code__num", children: row.line.newNumber ?? "" }), _jsx("span", { className: "ah-diff__mark", children: MARK[row.line.kind] }), _jsx("code", { children: row.line.kind === "note" ? (_jsx("em", { children: row.line.text })) : (row.tokens.map((token, at) => token.kind === "plain" ? (token.text) : (_jsx("span", { "data-t": token.kind, children: token.text }, at)))) })] })) }, item.key));
76
81
  }) })] }));
77
82
  }
@@ -15,12 +15,14 @@ import { useEffect, useMemo, useState } from "react";
15
15
  import { DiffBody } from "../file-viewer/index.js";
16
16
  import { AgentMark } from "../../lib/agents.js";
17
17
  import { clockShort, dayLabel } from "../../lib/format.js";
18
+ import { useCopyText } from "../../room-context.js";
18
19
  import { CopyGlyph, CloseGlyph } from "../../lib/icons.js";
19
20
  import { DialogShell } from "../ui/index.js";
20
21
  import { ChangeTree } from "./ChangeTree.js";
21
22
  import { creditedAgents } from "./co-author.js";
22
23
  import { buildPathTree } from "./path-tree.js";
23
24
  export function CommitViewer({ commit, files, client, sessionPaths, currentTimestamp, onClose, onReceipt, }) {
25
+ const copy = useCopyText();
24
26
  const rows = useMemo(() => buildPathTree((files ?? []).map((file) => file.path)), [files]);
25
27
  const letters = useMemo(() => {
26
28
  const out = new Map();
@@ -68,8 +70,7 @@ export function CommitViewer({ commit, files, client, sessionPaths, currentTimes
68
70
  const people = [commit.author, ...commit.coAuthors.map((author) => author.name)].filter((name) => name !== "" && !drawn.has(name));
69
71
  const selectedName = selected === null ? null : selected.slice(selected.lastIndexOf("/") + 1);
70
72
  return (_jsxs(DialogShell, { title: `${commit.short} — ${commit.subject}`, onClose: onClose, wide: true, children: [_jsxs("header", { className: "ah-fileview__head ah-commitview__head", children: [_jsx("div", { className: "ah-fileview__title", children: _jsx("strong", { className: "ah-commitview__subject", title: commit.subject, children: commit.subject }) }), _jsxs("div", { className: "ah-fileview__acts", children: [_jsx("button", { type: "button", className: "ah-iconbtn", title: "Copy the full sha", "aria-label": "Copy the full sha", onClick: () => {
71
- void navigator.clipboard
72
- .writeText(commit.sha)
73
+ void copy(commit.sha)
73
74
  .then(() => onReceipt("sha copied"))
74
75
  .catch(() => onReceipt("the clipboard refused"));
75
76
  }, children: _jsx(CopyGlyph, {}) }), _jsx("button", { type: "button", className: "ah-iconbtn", title: "Close (Esc)", "aria-label": "Close", onClick: onClose, children: _jsx(CloseGlyph, {}) })] }), _jsxs("p", { className: "ah-commitview__meta", children: [people.map((name) => (_jsx("span", { children: name }, name))), agents.map((agent) => (_jsx(AgentMark, { kind: agent.kind, note: agent.label }, agent.kind))), _jsx("code", { children: commit.short }), !commit.merge && (_jsxs("span", { className: "tnum", children: ["+", commit.added, " \u2212", commit.deleted] })), _jsxs("time", { className: "tnum", dateTime: new Date(commit.timestampMs).toISOString(), children: [dayLabel(commit.timestampMs, currentTimestamp), " ", clockShort(commit.timestampMs)] })] })] }), _jsxs("div", { className: "ah-commitview", children: [_jsxs("div", { className: "ah-commitview__files", children: [_jsx("div", { className: "ah-group", children: files === null
@@ -10,13 +10,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
10
10
  // resumption, the anchor keeps HH:MM:SS. Time decomposes — day, sitting,
11
11
  // second — and no level repeats another's fact.
12
12
  import { clock } from "../../lib/format.js";
13
+ import { useCopyText } from "../../room-context.js";
13
14
  export function Anchor({ at, sessionId, timelineId, onReceipt }) {
15
+ const copy = useCopyText();
14
16
  if (at === null)
15
17
  return null;
16
18
  const stamp = clock(at);
17
19
  return (_jsx("button", { type: "button", className: "tr-anchor", title: "Copy an anchor to this message", onClick: () => {
18
- navigator.clipboard
19
- .writeText(`${sessionId}#${timelineId}`)
20
+ copy(`${sessionId}#${timelineId}`)
20
21
  .then(() => onReceipt(`Anchor copied · ${stamp}`))
21
22
  .catch(() => onReceipt("The clipboard refused the anchor"));
22
23
  }, children: stamp }));
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // §03 G — generated continuation context belongs to the system marker.
3
3
  import { useEffect, useState } from "react";
4
- import { useReadingSession, useRoom } from "../../room-context.js";
4
+ import { useCopyText, useReadingSession, useRoom } from "../../room-context.js";
5
5
  import { MessagePreview } from "./MessagePreview.js";
6
6
  import { LineChevron } from "./glyphs.js";
7
7
  import { useRowDisclosure } from "./disclosure-state.js";
@@ -11,6 +11,7 @@ function SummaryBody({ canonical, messageKey, matched, onReceipt, }) {
11
11
  const [loaded, setLoaded] = useState(null);
12
12
  const [attempt, setAttempt] = useState(0);
13
13
  const { sessions } = useRoom();
14
+ const copy = useCopyText();
14
15
  const readingSession = useReadingSession();
15
16
  useEffect(() => {
16
17
  if (canonical.type === "inline")
@@ -35,7 +36,7 @@ function SummaryBody({ canonical, messageKey, matched, onReceipt, }) {
35
36
  }, [canonical, attempt, sessions, readingSession]);
36
37
  const text = canonical.type === "inline" ? canonical.text : loaded?.text ?? null;
37
38
  return (_jsxs("div", { className: "tr-compaction__body", children: [_jsxs("div", { className: "tr-compaction__byline", children: [_jsx("span", { children: "Agent-generated context for continuing this session." }), text !== null && (_jsx("button", { type: "button", onClick: () => {
38
- navigator.clipboard.writeText(text)
39
+ copy(text)
39
40
  .then(() => onReceipt("Copied summary"))
40
41
  .catch(() => onReceipt("The clipboard refused it"));
41
42
  }, children: "copy summary" }))] }), text !== null ? (_jsx("div", { className: "tr-prose ah-syntax", children: _jsx(MessagePreview, { messageKey: messageKey, role: "agent", title: "Compaction summary", matched: matched, text: text, onReceipt: onReceipt }) })) : loaded?.error ? (_jsxs("p", { className: "tr-compaction__status", role: "status", children: ["Could not load the full summary. ", loaded.error, " ", _jsx("button", { type: "button", onClick: () => setAttempt(attempt + 1), children: "Retry" })] })) : (_jsx("p", { className: "tr-compaction__status", role: "status", children: "Loading full summary\u2026" }))] }));
@@ -17,29 +17,30 @@ import { attachmentMentions } from "../../lib/transcript/index.js";
17
17
  import { parseMarkdown } from "../file-viewer/markdown/index.js";
18
18
  import { MarkdownBlocks } from "../file-viewer/markdown/render.js";
19
19
  import { highlight, languageFor, PLAIN_TEXT } from "../file-viewer/syntax/index.js";
20
+ import { useCopyText } from "../../room-context.js";
20
21
  import { markTerms, useMatchTerms } from "./reader-context.js";
21
22
  /** The hover acts. Today the room has exactly one honest act on a segment —
22
23
  * copy — so that is what it draws; the record's chip and canvas belong to
23
24
  * vibe-field, which this room is not. */
24
25
  export function SegmentActs({ text, onReceipt, }) {
26
+ const copy = useCopyText();
25
27
  if (text.trim() === "")
26
28
  return null;
27
29
  return (_jsx("div", { className: "tr-acts", children: _jsx("button", { type: "button", onClick: () => {
28
- navigator.clipboard
29
- .writeText(text)
30
+ copy(text)
30
31
  .then(() => onReceipt("Copied"))
31
32
  .catch(() => onReceipt("The clipboard refused it"));
32
33
  }, children: "copy" }) }));
33
34
  }
34
35
  function CodeBar({ language, text, onReceipt, excerpt = false, }) {
35
36
  const [copied, setCopied] = useState(false);
37
+ const copy = useCopyText();
36
38
  const lines = useMemo(() => {
37
39
  const resolved = language === null ? PLAIN_TEXT : (languageFor(`x.${language}`) ?? PLAIN_TEXT);
38
40
  return highlight(text, resolved);
39
41
  }, [language, text]);
40
42
  return (_jsxs("div", { className: "tr-code", children: [_jsxs("div", { className: "tr-code__bar", children: [_jsx("span", { children: language ?? "text" }), !excerpt && _jsx("button", { type: "button", onClick: () => {
41
- navigator.clipboard
42
- .writeText(text)
43
+ copy(text)
43
44
  .then(() => {
44
45
  setCopied(true);
45
46
  onReceipt("Copied");
@@ -59,6 +59,17 @@ export function WorktreeColumn({ projectRoot, tint, homeDirectory, sessionPaths,
59
59
  ? null
60
60
  : commits.filter((commit) => commit.pushed === false).length, [commits]);
61
61
  const host = useRoom().host;
62
+ // The ledger's figures: asked of the host for the rows on screen, for this
63
+ // exact root and generation. A new root is a new asker, and the list starts
64
+ // its answers over.
65
+ const measureRoot = live?.root ?? null;
66
+ const measureGeneration = live?.generation ?? null;
67
+ const measure = useMemo(() => {
68
+ const worktree = host?.worktree;
69
+ if (worktree?.worktreeSizes === undefined || measureRoot === null || measureGeneration === null)
70
+ return undefined;
71
+ return (paths) => worktree.worktreeSizes?.(measureRoot, measureGeneration, paths) ?? Promise.resolve([]);
72
+ }, [host, measureRoot, measureGeneration]);
62
73
  const hasShell = host?.worktree !== undefined;
63
74
  const listBrowsers = useMemo(() => host?.browsers?.bind(host), [host]);
64
75
  const openInBrowser = useMemo(() => (host === null ? null : (name, bytes, browserId) => host.openInBrowser(name, bytes, browserId)), [host]);
@@ -146,7 +157,7 @@ export function WorktreeColumn({ projectRoot, tint, homeDirectory, sessionPaths,
146
157
  // with no children, which an empty directory also is.
147
158
  if (isOpenable(entry))
148
159
  setOpen({ handle: handleFor(engine, entry), diff: false });
149
- } }), hasSiblingWorktrees && (_jsx(WorktreeList, { facts: facts, openRoot: shownRoot, homeDirectory: homeDirectory }))] }))) : connection === null ? (_jsx(EmptyState, { title: "Reading the repository", description: "Asking git for its status." })) : tab === "changes" ? (_jsx(GitChanges, { entries: entries, sessionPaths: sessionPaths, selection: selection, onSelect: showDiff, onStage: client === null ? null : (paths) => act("Staged", paths, client.stage), onUnstage: client === null ? null : (paths) => act("Unstaged", paths, client.unstage), onDiscard: client === null ? null : setPendingDiscard })) : (_jsx(GitHistory, { commits: commits, selectedSha: openCommit, onSelect: showCommit, currentTimestamp: currentTimestamp })), openCommit !== null && (_jsx(CommitViewer, { commit: openCommit, files: commitFiles, client: client, sessionPaths: sessionPaths, currentTimestamp: currentTimestamp, onReceipt: onReceipt, onClose: () => {
160
+ } }), hasSiblingWorktrees && (_jsx(WorktreeList, { facts: facts, openRoot: shownRoot, homeDirectory: homeDirectory, onReceipt: onReceipt, measure: measure }))] }))) : connection === null ? (_jsx(EmptyState, { title: "Reading the repository", description: "Asking git for its status." })) : tab === "changes" ? (_jsx(GitChanges, { entries: entries, sessionPaths: sessionPaths, selection: selection, onSelect: showDiff, onStage: client === null ? null : (paths) => act("Staged", paths, client.stage), onUnstage: client === null ? null : (paths) => act("Unstaged", paths, client.unstage), onDiscard: client === null ? null : setPendingDiscard })) : (_jsx(GitHistory, { commits: commits, selectedSha: openCommit, onSelect: showCommit, currentTimestamp: currentTimestamp })), openCommit !== null && (_jsx(CommitViewer, { commit: openCommit, files: commitFiles, client: client, sessionPaths: sessionPaths, currentTimestamp: currentTimestamp, onReceipt: onReceipt, onClose: () => {
150
161
  setOpenCommit(null);
151
162
  setCommitFiles(null);
152
163
  } })), _jsx(ConfirmDialog, { question: pendingDiscard === null
@@ -1,8 +1,14 @@
1
- import type { GitFacts } from "../../ports.js";
1
+ import type { GitFacts, WorktreeSize } from "../../ports.js";
2
2
  export interface WorktreeListProps {
3
3
  readonly facts: GitFacts;
4
4
  /** The root the tree is showing, which earns the dirty count. */
5
5
  readonly openRoot: string | null;
6
6
  readonly homeDirectory: string | null;
7
+ /** The room's receipt line, so a copy is never silent. */
8
+ readonly onReceipt: (text: string) => void;
9
+ /** Ask the host what these worktrees hold on disk. Its identity is the
10
+ * open root's: a new one starts the list's answers over. Absent: the host
11
+ * measures nothing, and the list draws only the figures git facts carried. */
12
+ readonly measure?: ((paths: readonly string[]) => Promise<readonly WorktreeSize[]>) | undefined;
7
13
  }
8
- export declare function WorktreeList({ facts, openRoot, homeDirectory }: WorktreeListProps): import("react").JSX.Element;
14
+ export declare function WorktreeList({ facts, openRoot, homeDirectory, onReceipt, measure, }: WorktreeListProps): import("react").JSX.Element;
@@ -1,12 +1,207 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { tildePath } from "../../lib/format.js";
3
- export function WorktreeList({ facts, openRoot, homeDirectory }) {
2
+ // The repository's other checkouts, under the tree that is showing one of
3
+ // them. Only worth drawing when there is more than one: a repository with a
4
+ // single worktree has nothing to disambiguate, and a list of one is a label.
5
+ //
6
+ // It is a ledger of disk. A repository's worktrees hold the same tracked
7
+ // files, so what tells them apart on a disk is what git does not track (the
8
+ // installed packages, the build output), and a reader deciding which checkout
9
+ // to let go of wants that figure first. So the rows stand heaviest first,
10
+ // each a name with its size at the edge over a bar scaled to the heaviest;
11
+ // where the folder is and how dirty the open one is are on the row's hover.
12
+ //
13
+ // A FIGURE IS A WALK OF A FOLDER, AND A REPOSITORY CAN HAVE HUNDREDS OF
14
+ // WORKTREES. So the list asks its host only for the rows that are on screen,
15
+ // again as the reader scrolls, and a host keeps what it measured: the next
16
+ // opening shows those figures at once and walks nothing. A row whose figure
17
+ // is owed shows that it is being weighed, never a blank.
18
+ //
19
+ // Figures arrive one at a time while the list is being read. A row keeps its
20
+ // place until the list is at rest (at its top, no pointer or keyboard in it);
21
+ // only then does it take its rank (`settleOrder`).
22
+ //
23
+ // A row is named by its branch, or, with no branch, by its folder's own name
24
+ // with its commit beside it. The whole path of a branchless checkout was four
25
+ // lines of this column, with the one part that told two apart at the very end.
26
+ //
27
+ // A press copies the name. That is the room's one act here: switching
28
+ // worktrees is an act on a repository, and this room reads history.
29
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
30
+ import { fmtBytes, tildePath } from "../../lib/format.js";
31
+ import { CopyGlyph } from "../../lib/icons.js";
32
+ import { useCopyText } from "../../room-context.js";
33
+ import { ledgerOf, settleOrder } from "./worktree-ledger.js";
34
+ /** How long a scroll settles before the rows on screen are asked for. */
35
+ const SETTLE_MS = 160;
36
+ /** How often the rows on screen that are still being weighed are asked again. */
37
+ const POLL_MS = 1500;
38
+ /** Rows one ask names at most: more than a column shows at once. */
39
+ const ASK_ROWS = 32;
40
+ /** Rows just off screen that count as shown, so a short scroll finds them weighed. */
41
+ const NEAR = "96px 0px";
42
+ export function WorktreeList({ facts, openRoot, homeDirectory, onReceipt, measure, }) {
43
+ const copy = useCopyText();
44
+ const [answers, setAnswers] = useState(new Map());
45
+ useEffect(() => setAnswers(new Map()), [measure]);
46
+ const ledger = useMemo(() => {
47
+ const sizeOf = (worktree) => {
48
+ const said = answers.get(worktree.path);
49
+ // a figure the host already held stands while the folder is walked again
50
+ const kept = typeof worktree.sizeBytes === "number" ? worktree.sizeBytes : undefined;
51
+ if (said !== undefined)
52
+ return said === "none" ? undefined : (said ?? kept ?? null);
53
+ if (kept !== undefined)
54
+ return kept;
55
+ // owed: asked for once the row is on screen
56
+ return measure === undefined ? undefined : null;
57
+ };
58
+ return ledgerOf(facts.worktrees, openRoot, sizeOf);
59
+ }, [facts.worktrees, openRoot, answers, measure]);
60
+ const byPath = useMemo(() => new Map(ledger.rows.map((row) => [row.path, row])), [ledger]);
61
+ const ranked = useMemo(() => ledger.rows.map((row) => row.path), [ledger]);
62
+ // ── the drawn order: the ledger's while at rest, each row's own place otherwise
63
+ const scroller = useRef(null);
64
+ const held = useRef({ pointer: false, keyboard: false, scrolled: false });
65
+ const [restTick, setRestTick] = useState(0);
66
+ const atRest = () => !held.current.pointer && !held.current.keyboard && !held.current.scrolled;
67
+ const hold = (what, value) => {
68
+ if (held.current[what] === value)
69
+ return;
70
+ held.current[what] = value;
71
+ if (atRest())
72
+ setRestTick((tick) => tick + 1);
73
+ };
74
+ const [order, setOrder] = useState([]);
75
+ // biome-ignore lint/correctness/useExhaustiveDependencies: restTick is the rest's own signal
76
+ useEffect(() => {
77
+ setOrder((drawn) => settleOrder(drawn, ranked, atRest()));
78
+ }, [ranked, restTick]);
79
+ const drawn = useMemo(() => settleOrder(order, ranked, false), [order, ranked]);
80
+ // ── the rows on screen, and what the host is asked of them
81
+ const shown = useRef(new Set());
82
+ const [seenTick, setSeenTick] = useState(0);
83
+ useEffect(() => {
84
+ const root = scroller.current;
85
+ if (root === null || measure === undefined)
86
+ return;
87
+ const rows = [...root.querySelectorAll("[data-worktree]")];
88
+ if (typeof IntersectionObserver === "undefined") {
89
+ shown.current = new Set(rows.slice(0, 12).map((row) => row.dataset["worktree"] ?? ""));
90
+ setSeenTick((tick) => tick + 1);
91
+ return;
92
+ }
93
+ let timer;
94
+ const observer = new IntersectionObserver((entries) => {
95
+ for (const entry of entries) {
96
+ const path = entry.target.dataset["worktree"];
97
+ if (path === undefined)
98
+ continue;
99
+ if (entry.isIntersecting)
100
+ shown.current.add(path);
101
+ else
102
+ shown.current.delete(path);
103
+ }
104
+ window.clearTimeout(timer);
105
+ timer = window.setTimeout(() => setSeenTick((tick) => tick + 1), SETTLE_MS);
106
+ }, { root, rootMargin: NEAR });
107
+ shown.current = new Set();
108
+ for (const row of rows)
109
+ observer.observe(row);
110
+ return () => {
111
+ window.clearTimeout(timer);
112
+ observer.disconnect();
113
+ };
114
+ }, [drawn, measure]);
115
+ const settled = useRef(new Set());
116
+ const asking = useRef(false);
117
+ const [pollTick, setPollTick] = useState(0);
118
+ const gone = useMemo(() => new Set(ledger.rows.filter((row) => row.gone).map((row) => row.path)), [ledger]);
119
+ // biome-ignore lint/correctness/useExhaustiveDependencies: the ticks are the signals
120
+ useEffect(() => {
121
+ if (measure === undefined || asking.current)
122
+ return;
123
+ const want = drawn
124
+ .filter((path) => shown.current.has(path) && !gone.has(path) && !settled.current.has(path))
125
+ .slice(0, ASK_ROWS);
126
+ if (want.length === 0)
127
+ return;
128
+ let live = true;
129
+ let again;
130
+ asking.current = true;
131
+ measure(want)
132
+ .then((said) => {
133
+ if (!live)
134
+ return;
135
+ let owed = false;
136
+ const next = new Map();
137
+ for (const path of want) {
138
+ const row = said.find((one) => one.path === path);
139
+ const size = row?.sizeBytes;
140
+ if (typeof size === "number")
141
+ next.set(path, size);
142
+ else if (size === null)
143
+ next.set(path, null);
144
+ else
145
+ next.set(path, "none");
146
+ if (size === null)
147
+ owed = true;
148
+ else
149
+ settled.current.add(path);
150
+ }
151
+ setAnswers((before) => {
152
+ const merged = new Map(before);
153
+ for (const [path, answer] of next)
154
+ merged.set(path, answer);
155
+ return merged;
156
+ });
157
+ if (owed)
158
+ again = window.setTimeout(() => setPollTick((tick) => tick + 1), POLL_MS);
159
+ })
160
+ .catch(() => {
161
+ // the host could not say: the rows stay as they are, and the next
162
+ // scroll asks again
163
+ })
164
+ .finally(() => {
165
+ asking.current = false;
166
+ });
167
+ return () => {
168
+ live = false;
169
+ window.clearTimeout(again);
170
+ };
171
+ }, [seenTick, pollTick, measure, gone]);
172
+ useEffect(() => {
173
+ settled.current = new Set();
174
+ }, [measure]);
175
+ const press = useCallback((name) => {
176
+ void copy(name)
177
+ .then(() => onReceipt("worktree name copied"))
178
+ .catch(() => onReceipt("the clipboard refused"));
179
+ }, [copy, onReceipt]);
4
180
  // `ah-rail*` is the design record's name for this column; room.css is a
5
181
  // port of the proto and keeps its vocabulary.
6
- return (_jsxs("div", { className: "ah-railfoot", children: [_jsx("div", { className: "ah-railsplit", children: _jsx("span", { className: "ah-eyebrow", children: "Worktrees" }) }), _jsx("div", { className: "ah-railfoot__list", role: "region", "aria-label": "Worktrees", tabIndex: 0, children: facts.worktrees.map((worktree) => {
182
+ return (_jsxs("div", { className: "ah-railfoot", onPointerEnter: () => hold("pointer", true), onPointerLeave: () => hold("pointer", false), onFocusCapture: (event) => {
183
+ if (event.target.matches(":focus-visible"))
184
+ hold("keyboard", true);
185
+ }, onBlurCapture: (event) => {
186
+ if (!event.currentTarget.contains(event.relatedTarget))
187
+ hold("keyboard", false);
188
+ }, children: [_jsxs("div", { className: "ah-railsplit", children: [_jsx("span", { className: "ah-eyebrow", children: "Worktrees" }), _jsxs("span", { className: "ah-railsplit__sum tnum", children: [ledger.rows.length, ledger.totalBytes !== null &&
189
+ ` · ${fmtBytes(ledger.totalBytes)}${ledger.partial ? "+" : ""}`] })] }), _jsx("div", { className: "ah-railfoot__list", role: "list", "aria-label": "Worktrees", ref: scroller, onScroll: (event) => hold("scrolled", event.currentTarget.scrollTop > 0), children: drawn.map((path) => {
190
+ const row = byPath.get(path);
191
+ if (row === undefined)
192
+ return null;
7
193
  // The count belongs to the checkout the shell actually read, and
8
194
  // git reports it for one worktree at a time.
9
- const dirty = worktree.path === openRoot ? facts.dirty : null;
10
- return (_jsxs("div", { className: "ah-worktree", title: worktree.path, children: [_jsx("span", { children: worktree.branch ?? tildePath(worktree.path, homeDirectory) }), dirty !== null && (_jsx("code", { "data-dirty": dirty > 0 ? "" : undefined, className: "tnum", children: dirty > 0 ? `${dirty} dirty` : "clean" }))] }, worktree.path));
195
+ const dirty = row.open ? facts.dirty : null;
196
+ const weighing = row.sizeBytes === null;
197
+ const hover = [
198
+ tildePath(row.path, homeDirectory),
199
+ row.gone ? "its folder is gone" : null,
200
+ dirty === null ? null : dirty > 0 ? `${dirty} dirty` : "clean",
201
+ "Press to copy the name",
202
+ ]
203
+ .filter((part) => part !== null)
204
+ .join(" · ");
205
+ return (_jsx("div", { role: "listitem", children: _jsxs("button", { type: "button", className: "ah-worktree", title: hover, "data-worktree": row.path, "data-open": row.open ? "" : undefined, "data-gone": row.gone ? "" : undefined, "data-weighing": weighing ? "" : undefined, "aria-busy": weighing || undefined, onClick: () => press(row.name), children: [_jsxs("span", { className: "ah-worktree__name", children: [_jsx("span", { className: "ah-worktree__label", children: row.name }), row.commit !== null && _jsx("code", { children: row.commit }), _jsx("span", { className: "ah-worktree__copy", children: _jsx(CopyGlyph, {}) })] }), _jsx("span", { className: "ah-worktree__size tnum", children: row.gone ? ("gone") : typeof row.sizeBytes === "number" ? (fmtBytes(row.sizeBytes)) : weighing ? (_jsx("span", { className: "ah-worktree__wait", role: "img", "aria-label": "measuring" })) : null }), (row.share !== null || weighing) && (_jsx("span", { className: "ah-worktree__bar", "aria-hidden": "true", children: row.share !== null && (_jsx("span", { style: { width: `${Math.max(row.share * 100, 1.5).toFixed(2)}%` } })) }))] }) }, row.path));
11
206
  }) })] }));
12
207
  }
@@ -0,0 +1,40 @@
1
+ import type { GitWorktree } from "../../ports.js";
2
+ /** One drawn row. */
3
+ export interface LedgerRow {
4
+ readonly path: string;
5
+ /** What the row says and what a press copies: the branch, or for a checkout
6
+ * with no branch its folder's own name. */
7
+ readonly name: string;
8
+ /** The commit beside a folder's name, abbreviated; null beside a branch,
9
+ * which already names what is checked out. */
10
+ readonly commit: string | null;
11
+ readonly open: boolean;
12
+ readonly gone: boolean;
13
+ /** Bytes; null while the figure is owed (asked for, or to be asked once the
14
+ * row is on screen); undefined when there will be none. */
15
+ readonly sizeBytes: number | null | undefined;
16
+ /** The bar: this row's share of the heaviest row, 0 to 1. null with no figure. */
17
+ readonly share: number | null;
18
+ }
19
+ export interface Ledger {
20
+ /** Measured rows heaviest first, then the ones owed a figure in git's own
21
+ * order, then the ones whose folder is gone. */
22
+ readonly rows: readonly LedgerRow[];
23
+ /** The sum of the figures there are; null while there is none. */
24
+ readonly totalBytes: number | null;
25
+ /** True while some row is owed a figure, so the sum is a floor. */
26
+ readonly partial: boolean;
27
+ }
28
+ /** The ledger over what git listed. `sizeOf` says each worktree's figure as
29
+ * the list knows it now (the host's kept figure, or a later answer): bytes,
30
+ * null while owed, undefined when there will be none. Absent, the figure is
31
+ * the one the worktree came with. */
32
+ export declare function ledgerOf(worktrees: readonly GitWorktree[], openRoot: string | null, sizeOf?: (worktree: GitWorktree) => number | null | undefined): Ledger;
33
+ /** The order the rows are DRAWN in. The ledger's own order is by weight, but
34
+ * figures arrive one at a time while the list is being read, and a row that
35
+ * leaves for its rank the moment it is weighed takes the reader's place with
36
+ * it. So the drawn order follows the ledger only while the list is at rest
37
+ * (at its top, with no pointer or focus in it); otherwise each row stays
38
+ * where it was, a row new to the list goes after them in the ledger's order,
39
+ * and a row no longer listed goes. */
40
+ export declare function settleOrder(drawn: readonly string[], ledger: readonly string[], atRest: boolean): readonly string[];
@@ -0,0 +1,68 @@
1
+ // The worktree list as a ledger of disk: who holds how much, heaviest first.
2
+ // Pure, so the order and the bars are testable without a window.
3
+ /** git's abbreviation length, the one `git log --oneline` prints. */
4
+ const COMMIT_CHARS = 7;
5
+ function folderName(path) {
6
+ const trimmed = path.replace(/[\\/]+$/, "");
7
+ const at = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));
8
+ const name = at === -1 ? trimmed : trimmed.slice(at + 1);
9
+ return name === "" ? path : name;
10
+ }
11
+ /** The ledger over what git listed. `sizeOf` says each worktree's figure as
12
+ * the list knows it now (the host's kept figure, or a later answer): bytes,
13
+ * null while owed, undefined when there will be none. Absent, the figure is
14
+ * the one the worktree came with. */
15
+ export function ledgerOf(worktrees, openRoot, sizeOf = (w) => w.sizeBytes) {
16
+ const sized = worktrees.map((worktree, at) => ({
17
+ worktree,
18
+ at,
19
+ gone: worktree.gone === true,
20
+ size: worktree.gone === true ? undefined : sizeOf(worktree),
21
+ }));
22
+ const heaviest = sized.reduce((most, row) => (typeof row.size === "number" ? Math.max(most, row.size) : most), 0);
23
+ const rank = (row) => row.gone ? 2 : typeof row.size === "number" ? 0 : 1;
24
+ const rows = [...sized]
25
+ .sort((a, b) => {
26
+ const byRank = rank(a) - rank(b);
27
+ if (byRank !== 0)
28
+ return byRank;
29
+ if (rank(a) === 0) {
30
+ const bySize = b.size - a.size;
31
+ if (bySize !== 0)
32
+ return bySize;
33
+ }
34
+ return a.at - b.at;
35
+ })
36
+ .map(({ worktree, gone, size }) => ({
37
+ path: worktree.path,
38
+ name: worktree.branch ?? folderName(worktree.path),
39
+ commit: worktree.branch === null && typeof worktree.head === "string" && worktree.head !== ""
40
+ ? worktree.head.slice(0, COMMIT_CHARS)
41
+ : null,
42
+ open: worktree.path === openRoot,
43
+ gone,
44
+ sizeBytes: size,
45
+ share: typeof size === "number" ? (heaviest > 0 ? size / heaviest : 0) : null,
46
+ }));
47
+ const measured = sized.filter((row) => typeof row.size === "number");
48
+ return {
49
+ rows,
50
+ totalBytes: measured.length === 0 ? null : measured.reduce((sum, row) => sum + row.size, 0),
51
+ partial: sized.some((row) => !row.gone && row.size === null),
52
+ };
53
+ }
54
+ /** The order the rows are DRAWN in. The ledger's own order is by weight, but
55
+ * figures arrive one at a time while the list is being read, and a row that
56
+ * leaves for its rank the moment it is weighed takes the reader's place with
57
+ * it. So the drawn order follows the ledger only while the list is at rest
58
+ * (at its top, with no pointer or focus in it); otherwise each row stays
59
+ * where it was, a row new to the list goes after them in the ledger's order,
60
+ * and a row no longer listed goes. */
61
+ export function settleOrder(drawn, ledger, atRest) {
62
+ if (atRest || drawn.length === 0)
63
+ return ledger;
64
+ const listed = new Set(ledger);
65
+ const kept = drawn.filter((path) => listed.has(path));
66
+ const seen = new Set(kept);
67
+ return [...kept, ...ledger.filter((path) => !seen.has(path))];
68
+ }
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export type { ImportSign, ImportSignAgent, ImportSignPart, ImportSignSpace, Impo
7
7
  /** The reader (PK3): one session's transcript, read-only, at a line. */
8
8
  export { TranscriptReader } from "./TranscriptReader.js";
9
9
  export type { ReaderAddress, TranscriptReaderProps } from "./TranscriptReader.js";
10
- export type { AssetSource, AssetUrl, CatalogPort, CatalogSearch, CatalogStatus, Closable, CollaborationFeed, FigureWindow, GitFacts, GitWorktree, HostPort, InstalledBrowser, IngestionPort, RoomPorts, SessionClient, SessionFeed, SessionPort, WorktreeFileActionRequest, WorktreeFileActionResult, WorktreeHostEvent, WorktreeHostPort, WorktreeOpenResult, } from "./ports.js";
10
+ export type { AssetSource, AssetUrl, CatalogPort, CatalogSearch, CatalogStatus, Closable, CollaborationFeed, FigureWindow, GitFacts, GitWorktree, HostPort, InstalledBrowser, IngestionPort, RoomPorts, SessionClient, SessionFeed, SessionPort, WorktreeFileActionRequest, WorktreeFileActionResult, WorktreeHostEvent, WorktreeHostPort, WorktreeOpenResult, WorktreeSize, } from "./ports.js";
11
11
  export type { SummaryTab } from "./room-context.js";
12
12
  export type { ProjectStats } from "./lib/model.js";
13
13
  export type { KeyValueStore } from "./lib/room-storage.js";
package/dist/lib/hooks.js CHANGED
@@ -109,7 +109,12 @@ export function useDaemonStatus(catalog, asked = 0) {
109
109
  // intentional pauses; an unanswered first request retries promptly.
110
110
  const paused = status.ingest?.run?.state === "paused" || status.ingest?.run?.state === "failed" ||
111
111
  phase === "metadata_ready" || phase === "awaiting_consent";
112
- const complete = status.canonicalReady && status.searchReadiness === "ready";
112
+ // An import can run over a published archive (an agent brought in
113
+ // after the first import): canonical and search are ready throughout
114
+ // it, and it is not complete until its phase is live again.
115
+ const importing = phase !== undefined && phase !== "live" &&
116
+ phase !== "awaiting_consent" && phase !== "metadata_ready";
117
+ const complete = status.canonicalReady && status.searchReadiness === "ready" && !importing;
113
118
  // An unshown grant comes first: a daemon awaiting consent may still
114
119
  // report a complete archive from before, and must not wait 30 s.
115
120
  delay = unshown ? 100 : complete ? 30_000 : paused ? 2_500 : 500;
package/dist/ports.d.ts CHANGED
@@ -122,6 +122,26 @@ export interface GitWorktree {
122
122
  readonly path: string;
123
123
  /** Absent on a detached HEAD. */
124
124
  readonly branch: string | null;
125
+ /** The commit it has checked out, as git names it (a hex object id). What
126
+ * a checkout with no branch is told apart by. Absent: the host does not
127
+ * say; null: git named none (an unborn branch). */
128
+ readonly head?: string | null | undefined;
129
+ /** git still lists it, and its folder is gone (`prunable`). */
130
+ readonly gone?: boolean | undefined;
131
+ /** What the folder holds on disk, as a walk of it counts: everything under
132
+ * it, ignored files and build output included. It is NOT what removing the
133
+ * worktree would free (files cloned from a package store share their
134
+ * blocks), and a linked folder is not followed. Here it is the figure the
135
+ * host ALREADY holds (kept from an earlier walk); git facts start no walk.
136
+ * A figure the host does not hold is asked for by name, for the rows on
137
+ * screen only (`WorktreeHostPort.worktreeSizes`). */
138
+ readonly sizeBytes?: number | null | undefined;
139
+ }
140
+ /** One asked worktree's figure: bytes; null while the host is walking the
141
+ * folder (ask again shortly); absent when no figure can be had. */
142
+ export interface WorktreeSize {
143
+ readonly path: string;
144
+ readonly sizeBytes?: number | null | undefined;
125
145
  }
126
146
  /** Read-only git facts for one root. Every field is nullable because a folder
127
147
  * without a repository is a fact, not a failure: the room says less rather
@@ -177,6 +197,13 @@ export interface WorktreeHostPort {
177
197
  /** Branch · dirty count · worktrees for the open root, or null when the
178
198
  * folder is not a repository. */
179
199
  gitFacts(root: string, generation: number): Promise<GitFacts | null>;
200
+ /** What these worktrees of the open root's repository hold on disk, in the
201
+ * order asked. Asking is what makes a host walk a folder, and a walk is
202
+ * work: the room names only the rows it is showing, each ask REPLACES what
203
+ * the last one was owed, and a host keeps what it measured so that the next
204
+ * opening walks nothing. Absent: this host measures nothing, and the list
205
+ * draws no figure it was not given. */
206
+ worktreeSizes?(root: string, generation: number, paths: readonly string[]): Promise<readonly WorktreeSize[]>;
180
207
  /** Copy absolute path text or reveal one entry in the native file manager. */
181
208
  fileAction(request: WorktreeFileActionRequest): Promise<WorktreeFileActionResult>;
182
209
  /** The engine's events. A host replays what arrived before the room
@@ -205,6 +232,12 @@ export interface HostPort {
205
232
  artifactThumbnail?(html: string): Promise<string | null>;
206
233
  /** Re-read installed browsers. Absent on hosts with only a default action. */
207
234
  browsers?(): Promise<readonly InstalledBrowser[]>;
235
+ /** Put words on the system clipboard through the desktop's own copy door.
236
+ * A host whose page may not write the clipboard itself (a shell that grants
237
+ * its window no clipboard permission) gives this, and every copy the room
238
+ * makes goes through it; it rejects when the copy is refused. Absent: the
239
+ * room writes the page's clipboard, as a browser tab does. */
240
+ copyText?(text: string): Promise<void>;
208
241
  /** One site's own icon as an image URL, or null for every honest no — a
209
242
  * refused host, no icon, a timeout. The room draws the globe for all. */
210
243
  favicon(host: string): Promise<string | null>;
@@ -55,6 +55,11 @@ export declare function useRoom(): Room;
55
55
  export declare function useRoomOverlay(open: boolean): void;
56
56
  /** Whether any of the room's dialogs is open. */
57
57
  export declare function useRoomOverlayOpen(): boolean;
58
+ /** The room's one way to put words on the system clipboard: the host's copy
59
+ * door when it has one, else the page's own clipboard. It rejects when either
60
+ * refuses, and the part that asked says so in its receipt. A part mounted
61
+ * outside any room (a harness) writes the page's clipboard. */
62
+ export declare function useCopyText(): (text: string) => Promise<void>;
58
63
  /** Where the room portals its dialogs: the host's container, or the body. */
59
64
  export declare function useRoomPortal(): HTMLElement | undefined;
60
65
  export declare const ReadingSessionProvider: import("react").Provider<string | null>;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  // The ports, as the room's parts read them. `HistoryRoom` provides them; a
3
3
  // harness that mounts one column on its own wraps it in `RoomProvider`.
4
- import { createContext, useContext, useEffect, useMemo, useSyncExternalStore } from "react";
4
+ import { createContext, useCallback, useContext, useEffect, useMemo, useSyncExternalStore } from "react";
5
5
  import { createSessionLeases } from "./lib/session-leases.js";
6
6
  import { createFaviconStore } from "./lib/transcript/favicons.js";
7
7
  import { browserStorage, createRoomStorage, DEFAULT_STORAGE_PREFIX } from "./lib/room-storage.js";
@@ -75,6 +75,14 @@ export function useRoomOverlayOpen() {
75
75
  const { overlays } = useRoom();
76
76
  return useSyncExternalStore(overlays.subscribe, () => overlays.count() > 0, () => false);
77
77
  }
78
+ /** The room's one way to put words on the system clipboard: the host's copy
79
+ * door when it has one, else the page's own clipboard. It rejects when either
80
+ * refuses, and the part that asked says so in its receipt. A part mounted
81
+ * outside any room (a harness) writes the page's clipboard. */
82
+ export function useCopyText() {
83
+ const host = useContext(RoomContext)?.host ?? null;
84
+ return useCallback((text) => host?.copyText !== undefined ? host.copyText(text) : navigator.clipboard.writeText(text), [host]);
85
+ }
78
86
  /** Where the room portals its dialogs: the host's container, or the body. */
79
87
  export function useRoomPortal() {
80
88
  return useContext(RoomContext)?.portalContainer ?? undefined;
@@ -652,7 +652,13 @@
652
652
  Files take 70% of the area below the tabs and worktrees take 30%, including
653
653
  their heading. Both scroll independently; expanding a folder never moves
654
654
  the divider. With no sibling worktrees, files take the whole area. */
655
- .ah-railbody { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr); }
655
+ /* One column that is exactly the rail's width. Left to size itself, the
656
+ column grows to its widest row (a long branch name), and the rail then
657
+ cuts every row's right edge: the size, the head's sum. */
658
+ .ah-railbody {
659
+ flex: 1; min-height: 0; display: grid;
660
+ grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
661
+ }
656
662
  .ah-railbody[data-split] { grid-template-rows: minmax(0, 7fr) minmax(0, 3fr); }
657
663
  .ah-railtree { height: 100%; min-height: 0; padding: 6px 6px 0; }
658
664
  .ah-railtree[data-mille-theme] [role="tree"] {
@@ -663,21 +669,101 @@
663
669
  /* the engine lags a project switch: the old tree dims rather than lies */
664
670
  .ah-railtree[data-stale] { opacity: 0.45; transition: opacity 160ms; }
665
671
  /* Keep the worktree heading fixed above its scrollable list. */
666
- .ah-railfoot { display: flex; flex-direction: column; min-height: 0; }
672
+ .ah-railfoot { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
667
673
  .ah-railfoot__list {
668
674
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: thin;
669
675
  padding: 0 6px var(--ah-scroll-foot, 32px);
670
676
  scroll-padding-bottom: var(--ah-scroll-foot, 32px);
671
677
  }
672
- .ah-railfoot__list:focus-visible { outline: 2px solid var(--vf-select); outline-offset: -2px; }
673
- .ah-railsplit { flex: none; margin: 12px 12px 6px; padding-top: 12px; border-top: 1px solid var(--vf-hairline); }
678
+ .ah-railsplit {
679
+ flex: none; margin: 12px 12px 4px; padding-top: 12px; border-top: 1px solid var(--vf-hairline);
680
+ display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0;
681
+ }
682
+ .ah-railsplit .ah-eyebrow { flex: 0 1 auto; min-width: 0; }
683
+ .ah-railsplit__sum {
684
+ flex: none; color: var(--vf-text-faint); font-family: var(--vf-font-mono); font-size: 10px;
685
+ white-space: nowrap;
686
+ }
687
+
688
+ /* The worktree ledger. A row is a name with its size at the edge, over a bar
689
+ as wide as the row: every bar starts and ends on the same two lines, so
690
+ their lengths compare, and every size ends on the same edge. The bar is
691
+ neutral — hue says which project or which state (DESIGN.md §8), and a share
692
+ of disk is neither. The row is a button: a press copies its name. */
674
693
  .ah-worktree {
675
- display: flex; align-items: center; justify-content: space-between; gap: 8px;
676
- width: 100%; padding: 7px 9px; border: 0; border-radius: 9px; background: transparent;
677
- color: var(--vf-text-secondary); font-size: 11.5px; text-align: left;
694
+ display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline;
695
+ column-gap: 12px; row-gap: 5px;
696
+ width: 100%; padding: 6px 9px 7px; border: 0; border-radius: 9px; background: transparent;
697
+ color: var(--vf-text-secondary); font: inherit; font-size: 11.5px; line-height: 15px;
698
+ text-align: left; cursor: pointer;
699
+ }
700
+ .ah-worktree:hover { background: var(--vf-fill); }
701
+ .ah-worktree:focus-visible { outline: 2px solid var(--vf-select); outline-offset: -2px; }
702
+ .ah-worktree[data-open] { color: var(--vf-text-primary); }
703
+ .ah-worktree[data-gone] { color: var(--vf-text-faint); }
704
+ .ah-worktree__name { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
705
+ .ah-worktree__label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
706
+ /* the open one's mark: the room's own dot, before the name */
707
+ .ah-worktree[data-open] .ah-worktree__label::before {
708
+ content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 6px 1px 0;
709
+ border-radius: 50%; background: var(--vf-select); vertical-align: middle;
710
+ }
711
+ .ah-worktree code {
712
+ flex: none; font-family: var(--vf-font-mono); font-size: 10px; color: var(--vf-text-faint);
713
+ font-variant-numeric: tabular-nums;
714
+ }
715
+ .ah-worktree__copy {
716
+ flex: none; align-self: center; display: grid; place-items: center; width: 11px; height: 11px;
717
+ color: var(--vf-text-faint); opacity: 0;
718
+ }
719
+ .ah-worktree__copy svg { width: 11px; height: 11px; display: block; }
720
+ .ah-worktree:hover .ah-worktree__copy,
721
+ .ah-worktree:focus-visible .ah-worktree__copy { opacity: 1; }
722
+ .ah-worktree__size {
723
+ justify-self: end; font-family: var(--vf-font-mono); font-size: 10.5px;
724
+ color: var(--vf-text-tertiary); font-variant-numeric: tabular-nums; white-space: nowrap;
725
+ }
726
+ .ah-worktree[data-open] .ah-worktree__size { color: var(--vf-text-secondary); }
727
+ .ah-worktree[data-gone] .ah-worktree__size { color: var(--vf-text-faint); }
728
+ .ah-worktree__bar {
729
+ grid-column: 1 / -1; display: block; height: 3px; border-radius: 2px; overflow: hidden;
730
+ background: var(--vf-fill);
731
+ }
732
+ .ah-worktree:hover .ah-worktree__bar { background: var(--vf-hairline-strong); }
733
+ .ah-worktree__bar > span {
734
+ display: block; height: 100%; border-radius: 2px; background: var(--vf-text-tertiary);
735
+ transition: width 240ms var(--vf-ease-island);
736
+ }
737
+ .ah-worktree[data-open] .ah-worktree__bar > span { background: var(--vf-text-secondary); }
738
+
739
+ /* Being weighed: the bar's track and the size's place carry a slow sheen, so
740
+ a row that is owed a figure says so. Never a blank, and never a spinner per
741
+ row: thirty of those in a column is noise. */
742
+ .ah-worktree__wait {
743
+ display: block; width: 34px; height: 7px; border-radius: 4px; background: var(--vf-fill);
744
+ }
745
+ .ah-worktree[data-weighing] .ah-worktree__bar,
746
+ .ah-worktree[data-weighing] .ah-worktree__wait {
747
+ background:
748
+ linear-gradient(
749
+ 90deg,
750
+ transparent 0%,
751
+ color-mix(in srgb, var(--vf-text-primary) 16%, transparent) 50%,
752
+ transparent 100%
753
+ )
754
+ 0 0 / 45% 100% no-repeat,
755
+ var(--vf-fill);
756
+ animation: ah-weigh 1.5s ease-in-out infinite;
757
+ }
758
+ @keyframes ah-weigh {
759
+ from { background-position: -45% 0, 0 0; }
760
+ to { background-position: 145% 0, 0 0; }
761
+ }
762
+ @media (prefers-reduced-motion: reduce) {
763
+ .ah-worktree[data-weighing] .ah-worktree__bar,
764
+ .ah-worktree[data-weighing] .ah-worktree__wait { animation: none; background: var(--vf-hairline-strong); }
765
+ .ah-worktree__bar > span { transition: none; }
678
766
  }
679
- .ah-worktree code { font-size: 10px; color: var(--vf-text-faint); font-variant-numeric: tabular-nums; }
680
- .ah-worktree code[data-dirty] { color: var(--vf-cyan); }
681
767
 
682
768
  /* a receipt, so a copy or an act is never silent */
683
769
  .ah-receipt {
@@ -1267,8 +1353,10 @@
1267
1353
 
1268
1354
  /* A diff's rows are as wide as the column, not as wide as their longest
1269
1355
  line: the ground behind an added line says "this whole line is new", and a
1270
- ground that stops at the text says it about the text only. The code itself
1271
- still scrolls sideways inside the row. */
1356
+ ground that stops at the text says it about the text only. A line longer
1357
+ than the column wraps inside its row, as the code view's does, and the row
1358
+ grows with it (DiffBody.tsx measures each row), so the ground covers every
1359
+ visual line of it. */
1272
1360
  .ah-diff .ah-code__sizer { width: 100%; }
1273
1361
  .ah-diff .ah-code__line { width: 100%; }
1274
1362
  .ah-diff .ah-code__line code { flex: 1; min-width: 0; }
@@ -1295,7 +1383,9 @@
1295
1383
  flex: none; width: 16px; text-align: center; user-select: none;
1296
1384
  color: var(--vf-text-faint);
1297
1385
  }
1298
- .ah-diff .ah-code__line { align-items: center; }
1386
+ /* The gutters and the mark sit on a wrapped line's FIRST visual line: a row
1387
+ stretches its children (the code view's own alignment), it does not centre
1388
+ them. Centred, a wrapped line's numbers would float beside its middle. */
1299
1389
  .ah-diff .ah-code__line[data-diff="add"] { background: color-mix(in srgb, var(--vf-green) 11%, transparent); }
1300
1390
  .ah-diff .ah-code__line[data-diff="del"] { background: color-mix(in srgb, var(--vf-red) 11%, transparent); }
1301
1391
  .ah-diff .ah-code__line[data-diff="add"] .ah-diff__mark { color: var(--vf-green); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibefield/rosetta-room",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "type": "module",
5
5
  "description": "rosetta's History room as a package: the projects, sessions and worktree columns, the panels and charts, and the transcript, behind injected ports. It dials nothing.",
6
6
  "main": "./dist/index.js",
@@ -35,7 +35,7 @@
35
35
  "@radix-ui/react-context-menu": "^2.3.7",
36
36
  "@radix-ui/react-dialog": "^1.1.23",
37
37
  "@radix-ui/react-tooltip": "^1.2.16",
38
- "@vibefield/rosetta-protocol": "^0.1.9",
38
+ "@vibefield/rosetta-protocol": "^0.1.11",
39
39
  "@tanstack/react-virtual": "^3.14.10",
40
40
  "@vibecook/mille": "^0.3.4",
41
41
  "@vibecook/mille-ui": "^0.3.4"