Web pages: a link to any address opens as an article, as Wikipedia's do

A url link now opens in the app instead of the browser. The server fetches
the page (robots.txt honoured, public addresses only, size and time caps),
keeps a snapshot on disk until it is reloaded, and cuts it into a lead and
sections: by its headings, else by pseudo-headings, else in chunks, or by a
model when asked (s), within a daily budget. The pane has its own amber
ground, the author and date in its head when the page gives them, and the
source in its foot. W opens the original, R reads it again. See
docs/pages.md.

Pictures and videos are kept, in web pages and in Wikipedia articles:
pictures through the server (only addresses seen in a page that was read),
videos as a still that loads the player on a click.

A section that is only a link (a target, no text, no sections) opens as
its article at once, and L opens a target to the right of the node's own
pane, never under it.

Article text is sized to read like the reader's own.

Panes: a pane that already has all its column can give beside the others'
tabs no longer peeks over them on hover, and the curves of tabs under a
peeking pane are no longer drawn over it. The keypress timing test judges
each of its two passes on its own, so a stall from outside the app does
not fail it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
thalladaandClaude Fable 5.2 committed 2026-11-18 13:44:13 -05:00
1 parent a3f25fbdcc
commit f8c6576ea1
58 files changed
+8606 -367

No files matched your search

+34 -1
View File
@@ -1,6 +1,6 @@
import { UndoManager } from "loro-crdt";
import { describe, expect, it } from "vitest";
import { Doc, SYSTEM_ORIGIN, ancestorsBelowRoot, isStale, retitleOps, staleness, sections, notesOf, topOf, tops, type NodeId } from "../src/core/model";
import { Doc, SYSTEM_ORIGIN, ancestorsBelowRoot, isStale, linkOnly, retitleOps, staleness, sections, notesOf, topOf, tops, type NodeId } from "../src/core/model";
import { healAnchors, history, verifyHistory, revertTo, revertSubtreeTo, mergeBranch, mergeUpdate, resolveConflict, reopenConflict, at, touched, Repo } from "../src/core/repo";
import { formFor, paragraphs, sentences, sha256, words } from "../src/core/text";
@@ -401,3 +401,36 @@ describe("library", () => {
expect(found.conflicts.map((c) => [c.type, c.node])).toEqual([["edit-edit", bLeaf]]);
});
});
describe("a section that is only a link", () => {
it("is a section with a Wikipedia or web target and nothing of its own: no text, no sections", () => {
const { doc, root, one } = fixture();
const { created } = doc.apply(
[
{ op: "create", parent: root, title: "Octopuses", body: "", ref: { kind: "wiki", title: "Octopus", lang: "en" } },
{ op: "create", parent: root, title: "A trace", body: "", ref: { kind: "url", url: "https://tracing.example.org/posts/following-a-request" } },
{ op: "create", parent: root, title: "Elsewhere", body: "", ref: { kind: "node", id: one } },
{ op: "create", parent: root, title: "Nothing", body: "" },
],
"Add links",
);
const [wiki, web, node, plain] = created;
expect(linkOnly(doc.snap(), wiki)).toBe(true);
expect(linkOnly(doc.snap(), web)).toBe(true);
// A link to a node is not an article; a section with no target is not a link.
expect(linkOnly(doc.snap(), node)).toBe(false);
expect(linkOnly(doc.snap(), plain)).toBe(false);
expect(linkOnly(doc.snap(), root)).toBe(false);
// Text of its own (not just white space), or a section inside, makes it a section like any other.
doc.apply([{ op: "update", id: wiki, body: " \n " }], "Blank");
expect(linkOnly(doc.snap(), wiki)).toBe(true);
doc.apply([{ op: "update", id: wiki, body: "Eight arms." }], "Text");
expect(linkOnly(doc.snap(), wiki)).toBe(false);
doc.apply([{ op: "create", parent: web, title: "Inside", body: "" }], "Inside");
expect(linkOnly(doc.snap(), web)).toBe(false);
// A note is never one, whatever it links to; nor is a node that is gone.
const [note] = doc.apply([{ op: "create", parent: one, kind: "note", quote: "first", body: "", ref: { kind: "wiki", title: "First", lang: "en" } }], "Link").created;
expect(linkOnly(doc.snap(), note)).toBe(false);
expect(linkOnly(doc.snap(), "nope" as NodeId)).toBe(false);
});
});