UI without documents: every page a node, the library root the first; moving, copying, exporting and importing any node

The page has one head for whatever node is the page (crumbs from the library's title, a byline of
sections and nodes, its flags and ⋯); in panes the first pane is the page and every other pane has
a section's head, whatever node it shows. A prompt (a node whose sections cite its sentences) is
folded wherever it shows. The library root's sections open in place like any others; an address
outside the hoisted node un-hoists to the library, and Esc at a hoisted page's top steps out to its
parent's.

What acts on a node and everything under it acts on the node the reader is on (the focused
section, or the one a focused note or selection is in): M moves it under any node (the jump box as
a picker, the root offered too), /duplicate copies it just after itself, /export saves it, /import
reads a file in as its last child (place() prefixes the titles down to the parent), /linkhere scans
it, S lists its links (on the root, the whole library's), history's f filters to it and r reverts
it. Every node's ⋯ offers them.

The documents menu, its mode and keys, /new, /open, /rename and /linkdoc are gone; m is free and
the top bar's left is a plain label with the library's name. Addresses are /n/<node id>, and / the
root; an old /doc/ address shows the library.

Server: /api/docs gives way to /api/nodes/<id>/{tree,export,import}; link jobs take scope "node" or
"library" and pending lists ?node=<id>&subtree=1. Step-1 shims removed: docOf/documents, all of
core/library.ts (IMPORT_MAX and importTree move to seed.ts, address and resolve to address.ts),
docArg, and the old single-document replica check. revertDocTo is revertSubtreeTo.

The page scrolls the focus into view only when the focus, the page or the mode changed, not on a
render for something that arrived in the background; row flags give way on a narrow screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
thalladaandClaude Opus 5.5 committed 2026-11-17 01:49:12 -05:00
1 parent e6e4ad8d26
commit bed47c0c7a
31 files changed
+789 -1153

No files matched your search

+6 -6
View File
@@ -1,5 +1,5 @@
/**
* Scanning a document or the whole library in the background: one job at a time, a node at a
* Scanning a node and everything under it, or the whole library, in the background: one job at a time, a node at a
* time, at bulk priority (a person's own requests to Wikipedia go first), with progress announced
* and a cancel. Lookups are gathered across the next few nodes and asked together, 50 phrases a
* request, which is most of what keeps a bulk pass affordable. A job started with `review` also has
@@ -18,9 +18,9 @@ import type { Linker, Suggestion } from "./scan";
export interface JobState {
id: string;
scope: "doc" | "library";
/** The document scanned, for a document job. */
doc?: NodeId;
scope: "node" | "library";
/** The node scanned (with everything under it), for a node job. */
node?: NodeId;
title: string;
state: "running" | "done" | "cancelled" | "failed";
done: number;
@@ -61,14 +61,14 @@ export class Jobs {
) {}
/** Start a job over these nodes (in reading order). A running job is cancelled first. */
start(scope: "doc" | "library", nodes: NodeId[], title: string, doc?: NodeId, review = false): JobState {
start(scope: "node" | "library", nodes: NodeId[], title: string, node?: NodeId, review = false): JobState {
this.cancel();
const wiki = this.o.wiki();
const spacing = wiki?.spacingMs ?? 0;
const state: JobState = {
id: Math.random().toString(36).slice(2, 10),
scope,
...(doc ? { doc } : {}),
...(node ? { node } : {}),
title,
state: "running",
done: 0,
+24 -21
View File
@@ -7,8 +7,9 @@
* stored for it, with determinations. review ("all", or "unmarked" to leave out [[marks]],
* which a person typed) has the model reviewer judge what is undecided; `apply` is then the
* approved links handed to the caller to make, and `review` the reviewer's report
* GET /api/links/pending ?doc=<top's id or name>&node=<id>&tier=auto|suggest&limit=&offset=&all=1&claim=1
* → { total, suggestions: [{ …, nodeTitle, top, path, sentence }], apply? };
* GET /api/links/pending ?node=<id>&subtree=1&tier=auto|suggest&limit=&offset=&all=1&claim=1
* → { total, suggestions: [{ …, nodeTitle, top, path, sentence }], apply? }; node alone is
* that node, with subtree=1 everything under it too, and without node the whole library;
* all=1 lists every entry whatever was decided, with its determinations; claim=1 hands
* out the approved links no page has made yet (in `apply`), to be made by the caller
* POST /api/links/accept { ids, author? } → applied with applyLinks as one commit by "linker"
@@ -17,7 +18,8 @@
* GET /api/links/related ?node=<id> → { related, degraded }; or POST { node, text, title, top, topTitle, ancestors }
* GET /api/links/nearby ?node=<id>&k=5 → { nearby: [{ handle, title, top }] } (hybrid search on the node);
* or POST { node, text, title, ancestors }
* POST /api/links/jobs { scope: "doc" | "library", doc?, review? } → the job's state (doc: a top's id or name); it runs in the background
* POST /api/links/jobs { scope: "node" | "library", node?, review? } → the job's state (node: a node's id, scanned with
* everything under it; on the library root, the whole library); it runs in the background
* (with review, the model reviewer judges what it finds, within IE_REVIEW_CALLS calls)
* GET /api/links/jobs → { job } (the current or last one)
* DELETE /api/links/jobs → cancel the running job
@@ -27,8 +29,7 @@
*/
import type { IncomingMessage, ServerResponse } from "node:http";
import { applyLinks, type LinkSpec } from "../../src/core/links";
import { findTop } from "../../src/core/library";
import { descendants, isLibraryRoot, tops, type Doc, type NodeId, type Op, type Snap } from "../../src/core/model";
import { descendants, isLibraryRoot, label, tops, type Doc, type NodeId, type Op, type Snap } from "../../src/core/model";
import type { Embedder } from "../embed";
import { HttpError, abortOnClose, readJson as readBody, sendJson as send } from "../util";
import type { Jobs } from "./jobs";
@@ -57,12 +58,12 @@ class Bad extends HttpError {
const readJson = <T>(req: IncomingMessage) => readBody<T>(req, 4 * 1024 * 1024);
/** A child of the root by its node id or name (TEMPORARY: step 2 scopes by any node). */
const docArg = (snap: Snap, v: string | null): NodeId | null => (v ? (findTop(snap, v) ?? null) : null);
/** The nodes of a top's tree (or of the library), in reading order: sections and notes with text. */
export function scopeNodes(snap: Snap, doc: NodeId | null): NodeId[] {
const roots = doc ? [doc] : tops(snap);
/**
* A node and everything under it (or, for none or the library root, the whole library but the
* Wikipedia container), in reading order: the sections and notes with text.
*/
export function scopeNodes(snap: Snap, node: NodeId | null): NodeId[] {
const roots = node && !isLibraryRoot(snap, node) ? [node] : tops(snap);
const out: NodeId[] = [];
for (const r of roots) for (const id of [r, ...descendants(snap, r)]) if (snap.nodes[id].body.trim() && !isLibraryRoot(snap, id)) out.push(id);
return out;
@@ -99,10 +100,10 @@ export function linkRoutes(deps: LinkDeps) {
return send(res, 200, { ...r, entries: deps.pending.of(input.node), apply, review: report }), true;
}
if (route === "pending" && method === "GET") {
const docId = docArg(snap, url.searchParams.get("doc"));
if (url.searchParams.get("doc") && !docId) throw new Bad(`no document ${url.searchParams.get("doc")}`);
const node = url.searchParams.get("node") as NodeId | null;
const scope = node ? new Set([node]) : docId ? new Set(scopeNodes(snap, docId)) : undefined;
const subtree = url.searchParams.get("subtree") === "1";
if (node && subtree && !snap.nodes[node]) throw new Bad(`no node ${node}`);
const scope = node ? new Set(subtree ? scopeNodes(snap, node) : [node]) : undefined;
const tier = url.searchParams.get("tier");
const all = url.searchParams.get("all") === "1";
const apply = url.searchParams.get("claim") === "1" ? deps.pending.claim(snap, scope ?? scopeNodes(snap, null)) : undefined;
@@ -160,13 +161,15 @@ export function linkRoutes(deps: LinkDeps) {
if (method === "GET") return send(res, 200, { job: deps.jobs.current }), true;
if (method === "DELETE") return send(res, 200, { cancelled: deps.jobs.cancel(), job: deps.jobs.current }), true;
if (method === "POST") {
const input = await readJson<{ scope?: string; doc?: string; review?: boolean }>(req);
if (input.scope !== "doc" && input.scope !== "library") throw new Bad('scope is "doc" or "library"');
const docId = input.scope === "doc" ? docArg(snap, input.doc ?? null) : null;
if (input.scope === "doc" && !docId) throw new Bad(`no document ${input.doc ?? ""}`);
const nodes = scopeNodes(snap, docId);
const title = docId ? snap.nodes[docId].title : "the library";
return send(res, 202, { job: deps.jobs.start(input.scope, nodes, title, docId ?? undefined, input.review === true) }), true;
const input = await readJson<{ scope?: string; node?: string; review?: boolean }>(req);
if (input.scope !== "node" && input.scope !== "library") throw new Bad('scope is "node" or "library"');
const id = input.scope === "node" ? ((input.node ?? "") as NodeId) : null;
if (id !== null && !snap.nodes[id]) throw new Bad(`no node ${input.node ?? ""}`);
// The library root is the whole library, as a library job.
const at = id && !isLibraryRoot(snap, id) ? id : null;
const nodes = scopeNodes(snap, at);
const title = at ? label(snap, at) : "the library";
return send(res, 202, { job: deps.jobs.start(at ? "node" : "library", nodes, title, at ?? undefined, input.review === true) }), true;
}
}
if (route === "status" && method === "GET") {