From f8c6576ea1c8553c40804a955b13a2b0abca8507 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Wed, 18 Nov 2026 13:44:13 -0500 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab --- README.md | 60 ++- docs/pages.md | 433 +++++++++++++++++ docs/wikipedia.md | 70 ++- e2e/colours.spec.ts | 22 +- e2e/forks.spec.ts | 2 + e2e/helpers.ts | 64 ++- e2e/links.spec.ts | 9 +- e2e/media.spec.ts | 174 +++++++ e2e/panes.spec.ts | 16 +- e2e/panes3.spec.ts | 89 +++- e2e/research.spec.ts | 17 +- e2e/web.spec.ts | 674 ++++++++++++++++++++++++++ playwright.config.ts | 2 +- server/csp.ts | 24 + server/index.ts | 48 +- server/page.ts | 656 +++++++++++++++++++++++++ server/pageArrange.ts | 328 +++++++++++++ server/pageFetch.ts | 491 +++++++++++++++++++ server/pageHtml.ts | 987 ++++++++++++++++++++++++++++++++++++++ server/pageMock.ts | 339 +++++++++++++ server/pageRoutes.ts | 179 +++++++ server/schemas.ts | 10 + server/wiki.ts | 92 +++- server/wikiHtml.ts | 318 ++++++++++-- server/wikiMock.ts | 63 ++- server/wikiRoutes.ts | 13 + src/core/model.ts | 9 + src/core/ref.ts | 36 ++ src/core/video.ts | 67 +++ src/llm/mock.ts | 24 +- src/llm/types.ts | 11 +- src/ui/App.tsx | 48 +- src/ui/Links.tsx | 44 +- src/ui/Mouse.tsx | 33 +- src/ui/Node.tsx | 6 +- src/ui/Pages.tsx | 14 +- src/ui/Panes.tsx | 146 ++++-- src/ui/Web.tsx | 227 +++++++++ src/ui/Wiki.tsx | 113 ++++- src/ui/actions.ts | 34 +- src/ui/articleText.ts | 25 +- src/ui/keys.ts | 33 +- src/ui/store.ts | 559 ++++++++++++++++----- src/ui/style.css | 71 ++- src/ui/web.ts | 229 +++++++++ src/ui/wiki.ts | 99 +++- tests/actions.test.ts | 28 +- tests/articleText.test.ts | 29 ++ tests/core.test.ts | 35 +- tests/csp.test.ts | 17 + tests/pageArrange.test.ts | 444 +++++++++++++++++ tests/pageFetch.test.ts | 266 ++++++++++ tests/pageHtml.test.ts | 392 +++++++++++++++ tests/pageRoutes.test.ts | 266 ++++++++++ tests/web.test.ts | 247 ++++++++++ tests/wiki.test.ts | 168 ++++++- tests/wikiMock.test.ts | 43 +- tests/wikiRoutes.test.ts | 30 +- 58 files changed, 8606 insertions(+), 367 deletions(-) create mode 100644 docs/pages.md create mode 100644 e2e/media.spec.ts create mode 100644 e2e/web.spec.ts create mode 100644 server/csp.ts create mode 100644 server/page.ts create mode 100644 server/pageArrange.ts create mode 100644 server/pageFetch.ts create mode 100644 server/pageHtml.ts create mode 100644 server/pageMock.ts create mode 100644 server/pageRoutes.ts create mode 100644 src/core/video.ts create mode 100644 src/ui/Web.tsx create mode 100644 src/ui/web.ts create mode 100644 tests/csp.test.ts create mode 100644 tests/pageArrange.test.ts create mode 100644 tests/pageFetch.test.ts create mode 100644 tests/pageHtml.test.ts create mode 100644 tests/pageRoutes.test.ts create mode 100644 tests/web.test.ts diff --git a/README.md b/README.md index 1749055..94326c3 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,9 @@ use on their own machine. | `EX_LIBRARY` | `library` | Starter trees (`.md` files in the text format), written into the first library when `EX_DATA` is empty. | | `EX_USER` | your login name | The name on commits the server makes for you (the page lets you change yours with `/user`). | | `EX_WIKI` | `live` | `mock`: built-in test articles, no network (the browser tests); `off`: every `/api/wiki/*` route answers 503. | +| `EX_PAGES` | `live` | Web pages opened from a link (`/api/page/*`): `mock`: built-in test pages, no network (the browser tests); `off`: every route answers 503. Only a page you open is read, robots.txt is honoured, and the text is cached under `EX_DATA/page-cache/`, never in a library (docs/pages.md). | +| `EX_PAGES_ARRANGE` | `on` when a model is configured | `off`: `s` on a web page (a model's summary, and sections for a page divided only by length) is refused. | +| `EX_PAGE_CALLS` | `20` | Model calls a day (UTC) for arranging web pages, for the whole server, counted in `EX_DATA/page-calls.json`. Pages are also not arranged while the plan's limits are nearly used. | | `EX_HOSTS` | (none) | Extra host names the dev server answers to, comma-separated. `localhost` and `*.ts.net` (Tailscale) are always allowed. | | `EX_WIKI_LANG` | `en` | Which Wikipedia. | | `EX_WIKI_CONTACT` | unset | An email address, an `https://` URL or `User:Name` for the User-Agent of Wikipedia requests. Without it requests are spaced 6.5 s apart (the page says so once, the first time it is slow); with it, 1 s. Nothing else about you is sent. | @@ -188,8 +191,9 @@ Press `?` for every key. The short version: in a pane that is not text, a row or a link makes it the active pane; a click anywhere else, or Esc, clears a selection. Mouse resting on a pane that is cut off for any reason (covered across or down, too small a share of its column, past its foot): after a moment it peeks out whole over - its neighbours, its column across and the pane down its column, as tall as its text needs, and - stays out while the pointer is on it (the wheel scrolls it); a click makes it the active pane. A + its neighbours, its column across and the pane down its column, as tall as its text needs (a pane + longer than its column: the column less a tab for each other pane, clear of their tabs; one shown + that tall already does not peek down its column), and stays out while the pointer is on it (the wheel scrolls it); a click makes it the active pane. A pane's grip (the band above its title, by the pin and x, shown when pointed at) or its tab drags it up or down its column; Esc cancels; `Alt+Shift+k` `Alt+Shift+j` (or the pane menu's Move this pane up and down) move the active pane a place; the column keeps that order, and a pane opened @@ -216,7 +220,7 @@ Press `?` for every key. The short version: - **Curves.** A curve runs from the words, row or link each pane was opened from into the rule under the pane's title, and draws that rule, and a link's underline too, so link, curve and rule are one hairline on device pixels. Curves pass over the panes' edges and under the selection bar and the - menus; a pane peeking out covers the curves that are not its own; the focused branch's is drawn stronger. Where the title does not show (the pane + menus; a pane peeking out covers the curves that are not its own (out of a column peeking too, that column's other panes' as well); the focused branch's is drawn stronger. Where the title does not show (the pane folded to its tab, or scrolled past it), the curve runs into the tab's foot instead; out of a folded pane whose source is out of sight, it leaves from the end of that pane's tab foot. A source scrolled or covered out of sight in a pane that still shows is pointed at: the curve is dotted @@ -251,11 +255,41 @@ Press `?` for every key. The short version: then the article in full (or the node's or page's card). `h` returns to the words. - Hovering linked words, or landing on them with `Tab`, previews the target. `Enter` opens it: in panes in the next pane; in the column a preview first, then the node (Back returns) or the - article as a page of its own. `L` opens a node's own target; a web page opens in a new tab. + article as a page of its own. `L` opens a node's own target (in panes, to the right of the + node's own pane when that is open). A section that has a target and nothing else of its own (no + text, no sections) is shown as its article or page: opened, its pane reads as the article's own + (in the column, the article opens under its row), and its head takes the section's keys too + (`r` `w` `D`, and `a` or `c`, which make it a section like any other again). +- A **web page** opens the same way, read once by the server and kept in its cache: its lead, then + its sections as rows (by its headings, else its numbered or bold paragraphs, else in parts by + length), on an amber ground under ↗ and its site, with its author and date where it gives them + and where it is from at its foot. A page that cannot be read here (robots.txt, a bot check, a PDF, + a page that needs JavaScript) says why and offers the original. `W` opens the original in a new + tab. An address on wikipedia.org opens as the article. Nothing is written on a page's text: its + annotations are not kept (docs/pages.md). +- On a web page, `s` asks the model (only then, within `EX_PAGE_CALLS` calls a day) for a short + summary, shown above the page's opening and marked as the model's, and, for a page with no + headings that was divided by length, for sections of its choosing; a page with headings keeps + them. Pressed again on the same text it costs nothing. `R` reads the page again (it is otherwise + kept as first read): unchanged text keeps what the model made; a page that no longer answers + keeps the copy read before, marked stale. Both are in the page's menu too. A link's card shows + the page's title, author, date and first sentence once the page has been read, and choosing an + address in the link picker (`w`) keeps the page's title in the link. - An article is shown as a tree, so the same keys work: its sections are rows, `Tab` walks its links, `Enter` opens one. A disambiguation page lists its senses. `W` opens the article on - wikipedia.org. Article text is set apart (sans-serif, tinted, under a W) and carries its licence - line. + wikipedia.org. Article text is set apart (sans-serif, tinted, under a W), at the size of your own + text, and carries its licence line. +- **Pictures and videos** in an article or a web page are shown in it, never wider than its pane, + each with its caption under it. Every picture comes through the app's own server (it is not + an open proxy: only pictures in a page or article read here), so opening a page loads nothing + from anywhere else. A click on a web page's picture opens the picture itself in a new tab; on a + Wikipedia picture, its File page, where its author and licence are (that is its credit). A video + is a still with a play mark (YouTube's thumbnail for a YouTube video, through the same server), + and nothing plays or loads from elsewhere until you click it: then a web page's or Wikipedia's + video file plays straight from where it is, and a YouTube or Vimeo video in YouTube's + privacy-enhanced player or Vimeo's, in a sandboxed frame. Any other embedded frame is a link out. + The production page's Content-Security-Policy (`server/csp.ts`) allows exactly that: images from + the app itself, video files over https, frames from those two players' addresses only. - Under an open node, **Linked from** lists what links to it; under an article, **Mentioned in** lists the library's nodes that link to it. - **Notes on an article.** In an article's text the keys are a node's: `i` selects a sentence, then @@ -401,6 +435,8 @@ EX_DATA/libraries//links/pending.json its link suggestions, the reviewer' EX_DATA/libraries//vectors/nodes.* its sections as vectors (derived) EX_DATA/libraries/.deleted/-