Skip to content

feat(notebook): add the OpenNotes notebook app (first cut) - #17

Draft
coletebou wants to merge 129 commits into
mainfrom
feat/notebook-app
Draft

coletebou wants to merge 129 commits into
mainfrom
feat/notebook-app

Conversation

@coletebou

@coletebou coletebou commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

OpenNotes: a free-form notebook app (first cut)

A notebook application beside Word, Excel, PowerPoint, Visio and Teams, structured exactly like
the team workspace: DOM-free logic in src/core/notebook, the app as Lit elements in
src/ui/src/notebook (ooxml-ui/notebook), the React binding, demo, browser tests and docs under
viewers/notebook, demos/notebook and e2e/notebook, and a Notebook tile in the Office suite.

What works

  • Structure: notebooks, section groups and coloured sections, pages with subpages (two
    levels). Create, rename (inline), recolour, reorder (menus, Alt+Arrow, drag and drop) and
    delete with Undo. Each page shows its title and creation date.
  • Free-form pages: click anywhere to place a text container; drag it by its grip and resize
    it. Pictures go in by paste, drop or Insert > Picture; new items go below what is on the page.
    Pictures and files are in the tab order and move with the arrow keys. Ink has a pen, a
    highlighter and a whole-stroke eraser (pointer events with pressure) and draws over everything
    on the page. Word, Excel, Visio and PowerPoint files are shown live and read-only by the
    existing viewers, with Open and Download; files over 32 MB are refused before they are read.
  • Rich text (ProseMirror through y-prosemirror, reusing Word's mark specs): bold, italic,
    underline, strikethrough, highlight, links (http, https, mailto), headings 1 to 3, bullets and
    numbering with nesting, to-do checkboxes, and undo/redo through one notebook-wide undo manager
    that never reverts a collaborator.
  • Search across page titles and text (case and accent insensitive, with snippets), and a To Do
    list of every checkbox tag.
  • Local-first storage: IndexedDB, one database per suite profile (ooxml-suite-notebooks[-id]),
    surviving reloads. A write only counts once its transaction commits; a failed save keeps the
    changes unsaved, says so, and is retried on the next change or when the page closes.
  • Real-time collaboration through collab (Yjs): two tabs share a notebook over
    BroadcastChannel with presence (who is on which page and in which container, and their carets).
    A server mode speaks the y-websocket protocol through the shared collab WebSocket transport
    the team workspace uses; this cut tests it only through that transport's own tests, not against
    a running server.
  • Export: a page to .docx through the docx area. Containers go in reading order (top to
    bottom, then left to right). Lists become Word numbering, to-dos become checkbox content
    controls, pictures stay pictures, and the page's ink becomes one PNG drawn by a canvas. Anything
    approximated is reported. A whole notebook exports to and imports from a zip archive (JSON
    manifest plus media).
  • Ribbon (Home, Insert, Draw, View) from the shared ribbon primitives, with KeyTips and
    keyboard navigation; light and dark themes through the shared tokens (the page stays paper
    white, as Word's does); every string in en, de, es, fr and zh-CN.
  • <notebook-app>, the opennotes-react-viewer binding (<Notebook> plus useNotebook raw
    hooks), a React demo, a docs site under /ooxml/notebook/, and the suite tile, route and
    standalone app.

Small shared extractions made on the way (each re-exported, no API change): reorderFractional
moved from xlsx/collab to collab/ordering; detectOfficeKind moved from teams to opc; the
safe localStorage helper moved out of the teams app.

How it was verified

  • bun run verify on the final commit (the CI plan for these commits, with CI's Bun 1.4.2): all 49
    steps passed. They cover lint, the formatter on changed files, the core and ooxml-ui builds,
    both core typechecks and the ooxml-ui typecheck, the full core suite (1989 files, 33301 tests),
    the ooxml-ui suite (1337 files, 14600 tests), the script and MCP tests, and the own checks of
    every viewer the change reaches (docx, xlsx, visio, teams, notebook and the pptx packages).
    Browser suites are not part of it; the notebook's is listed below.
  • Notebook unit tests: core 8 files / 49 tests (structure rules, rich text including compatibility
    with y-prosemirror's own converters, canvas and ink, the search index, .docx export read back
    through loadDocx, archive round trip and hostile archives, the client with two simulated tabs
    syncing with presence, local-only undo and a failed save that is retried, editor commands and
    input rules). UI 6 files / 48 tests: a happy-dom integration test mounts <notebook-app> and
    drives typing, the ribbon, links at the cursor, paste, ink, export, delete and Undo across
    notebooks, and German; plus the locale contract (5 locales), tokens-only CSS, the React prop
    mapping, file intake, and IndexedDB storage including a transaction that aborts after its write
    succeeded.
  • Browser suite (viewers/notebook, Playwright on Chrome), 6 specs, green twice in a row on the
    final commit: rich text that survives a reload; sections, pages and subpages with an undone
    delete; search and the to-do list; pen, eraser and undo; a picture moved with the keyboard and a
    live Word document, exported to .docx; two tabs editing one page in real time with presence.
  • Viewer: typecheck, unit tests, script tests, frozen-lockfile install, package builds,
    check:published and the local pack smoke test; the Pages build with the docs site and demo.
  • Suite: build:suite and headless checks of the tile, route, profile isolation, theme and an
    embedded .docx opening in the Word editor.
  • Extensive multi-model review of the whole branch, then again of the fixes: 16 distinct
    findings, each confirmed against the code and fixed with a regression test. Among them: edits
    lost after a failed save, media amplification in archive import, links not editable at the
    cursor, numbered list starts lost in Word export, Undo restoring in the wrong notebook, pictures
    out of keyboard reach, IndexedDB commit failures reported as saved, oversize files read into
    memory, and paste into the page title.
  • The demo checked by hand in light and dark themes and with two tabs.

Not done (follow-ups)

  • Vue, Angular, Svelte, Solid and vanilla bindings (the element API is built for them).
  • An end-to-end test of the server mode against a running y-websocket server.
  • Importing legacy notebook files (.one, .onepkg): that codec belongs in its own package,
    like ole2.
  • Audio notes, OCR, page templates, sharing permissions, a recycle-bin view and docs translations.
  • The Notebook link in the product nav line of every package README (a repo-wide edit).
  • Extracting the read-only PowerPoint preview from the team workspace into a shared element (the
    notebook reuses it today).
  • The first npm publish of opennotes-react-viewer needs the maintainer bootstrap described in
    docs/releasing.md; the binding needs core and ui released with ./notebook first.

Known baseline failure (not from this branch)

scripts/suite-regression-check.mjs stops at about line 103 on the selector
.pptxv-options-dialog, which no longer exists in the source (and an old #dialog start
screen); neither exists anywhere in the source any more, independent of this branch.

The minimal fractional reordering that the xlsx binding uses for sheet order is format-neutral, so it moves to collab/ordering as reorderFractional with its tests. The xlsx sheets module re-exports it under its old name; the notebook area orders sections, pages and notebooks with it.
Which Office viewer opens a file is not specific to the team workspace, so OfficeKind and detectOfficeKind move from teams/model to opc/office-kind with their test. The teams model re-exports both, so ooxml-core/teams is unchanged; the notebook area shows embedded files with them.
A free-form notebook model on Yjs: notebooks hold section groups and
sections, sections hold pages with subpages, and every page is a canvas
of rich-text containers, pictures, embedded Office files and ink.

- One Y.Doc per notebook with top-level maps only; ids minted per
  client, fields set one by one, everything a peer wrote re-validated
  on read, deterministic rules for missing parents, group cycles and
  subpage levels, soft deletes restored by trash batch.
- createNotebookClient: one immutable state and plain actions in the
  Teams shape, local-first storage, a per-device notebook list shared
  between tabs, local (BroadcastChannel) or y-websocket sync, presence,
  and undo that only reverts local edits.
- Search across titles and text and a to-do summary over a cached
  text index; page export to .docx through the docx area in reading
  order (lists, checkbox controls, marks, pictures, ink as a picture
  from a host rasteriser) and a zip archive with JSON and media.
- ooxml-core/notebook/editor: the ProseMirror schema (Word's mark
  specs), commands, keymap, input rules and the y-prosemirror binding,
  kept out of the main entry. Adds prosemirror-schema-list and
  prosemirror-inputrules.
The guarded localStorage wrapper of the team workspace is not specific to it. It moves to src/ui/src/safe-storage.ts and the teams app storage re-exports it, so another product can remember small per-browser settings without importing the team workspace and its core.
<notebook-app> (ooxml-ui/notebook) composes the notebook over the core
client: a navigation pane (notebooks, section groups and coloured
section tabs, pages with subpages, search, inline rename, keyboard
moves and drag and drop), the page canvas (title and date, click to
place text containers, drag and resize, pictures by paste, drop or
insert, live read-only Word, Excel, Visio and PowerPoint embeds with
download, pressure-sensitive pen, highlighter and eraser) and the To Do
pane. Text containers are ProseMirror editors bound through
y-prosemirror with collaborators' carets, accessible to-do checkboxes
and Ctrl+Z through the notebook's undo manager.

The ribbon (Home, Insert, Draw, View) is built from the shared ribbon
primitives with KeyTips; menus, dialogs, presence and tokens are the
shared ones, light and dark follow the theme, and every string ships
in English, German, Spanish, French and Simplified Chinese. Documents
live in a profile-scoped IndexedDB database. Page export rasterises ink
through a canvas; notebook archives export and import.
A ribbon section created before its class was registered kept its groups as an own property, so the notebook's ribbon was empty when it was the first ribbon on a page; the app's definer now registers the shared controls, its parts and its glyphs (no longer a side-effect import a bundler drops) before the app itself. Buttons outside the ribbon get a command (a shared button only emits office-command with one), hidden ribbon panels stay hidden, embedded viewers render only once defined (so read-only and the hidden toolbar apply), and the open-file event carries the container id.
Text containers took the dark theme's light text colour on the white page, and default black ink would vanish on a dark page. The page now carries the token defaults (the light values) as Word's page does, so text, ink and highlights look as they print and export; the app's chrome still follows the theme.
y-prosemirror queues a caret update on a timer and delivers it even when the view was destroyed meanwhile (its binding never marks itself destroyed), which threw from dispatchTransaction after a page switch. Collaborators' carets are also hidden from assistive technology now, so a name is not read as text.
viewers/notebook mirrors the team workspace viewer: the private notebook-viewer web component package (bindNotebook, pickNotebookProps), the opennotebook-react-viewer binding with the Notebook component and the useNotebook raw hooks, a React demo (demos/notebook/react) and a VitePress docs site under /ooxml/notebook/. The viewer is registered with the CI planner, the release package table, the Pages build, the preview templates and the labeler.
A Notebook tile, rail button, launcher entry, tab and #/notebook route mount <notebook-app> with this profile's own notebook database (ooxml-suite-notebooks), the suite profile's name and the suite theme. An embedded Word, Excel, PowerPoint or Visio file opens in the suite's editor as a library copy keyed by its container; the standalone apps gain apps/notebook.
Rich text and persistence across reloads, sections, subpages and undo of a delete, search and the To Do list, pen and eraser, pictures, a live Word embed and .docx export, and two tabs editing one notebook with presence.
The notebook product is OpenNotes and its packages opennotes-<framework>-viewer (first opennotes-react-viewer, docs opennotes-docs). The core and ui areas keep the neutral notebook name and the element stays <notebook-app>.
y-prosemirror 1.3.7 measures the local selection with the view root's createRange while it applies a remote change; a ShadowRoot has none, so applying a collaborator's edit to a focused text container threw and the edit was lost (the other way round worked while the receiving editor was unfocused). Each editor view's own root now gets the document's createRange.
Synthetic Cmd+A followed at once by an arrow key does not always collapse the selection before the next key, so typing replaced the text. The specs put the cursor at the end through the editor; the rich-text spec now also expects a to-do tag to carry over on Enter and drop on an empty line, and the to-do list spec ticks an item rather than the filter.
Passing undefined for the IndexedDB factory fell back to the global one, so the memory-only mode depended on what else had installed a global IndexedDB (another test in the same worker did). null now means none; an omitted argument still means the browser's.
The open-file event now carries the embedded file's container id; the binding test and the viewer docs list it.
A save cleared the dirty flag before writing and swallowed the error, so
flush() resolved and the next flush or close skipped the snapshot: a
storage failure followed by closing the app lost the edits. The notebook
and the device's notebook list now stay unsaved after a failed write, the
next change, flush or close tries again, and flush() rejects.

IndexedDB writes resolved when the request succeeded, before the
transaction committed; they now wait for completion and reject when the
transaction aborts (quota or disk errors surface at commit). Save and load
failures are reported as save-failed and open-failed instead of the
collaboration error.
Every container decoded its media entry again and kept the result, so a
small archive whose manifest names one 1 MiB entry two thousand times
stayed under the zip limits and still allocated about 2 GiB. Each media
path is now inflated once, and the media all containers take together is
held to a budget (512 MiB by default, maxMediaBytes to change it); going
over it fails the import with NotebookArchiveError.
Changing the style of a selection read the to-do tag of its first block
and gave it to every block, so turning a plain line and a done to-do into
a heading cleared the to-do (or tagged every line). Each block now keeps
its own tag; only the type and level change.

With the cursor inside a link, Insert > Link pre-filled the address but
Remove link removed nothing and a new address was inserted as a second
link. linkRangeAt finds the link around the cursor, setLink edits or
removes all of it, and the dialog only offers an address a viewer may
open (a collaborator can store any). The text field is only typed in
when a new link is inserted at the cursor; for a selection or a link
the text comes from the page.
A stroke counted as a dot when its bounds were no wider than the pen, so
a straight vertical line (constant x) of any length was drawn as a dot
at its first point. It is now a dot only when it moved in neither
direction.
Moving a page always lifted its block to the top level, so reordering a
subpage under the same parent made it a page of its own. The levels are
now only reset when the block moves to another section.
A list typed as "3. " starts at 3 in the editor, but the export created
its numbering from the list kind alone and restarted it at 1. The new
numbering instance now overrides the first level's start.
The React binding only passed a config on to the element when it was
set, so removing the prop kept the previous server configuration and the
notebook went on syncing with that server. Omitting it now resets the
element to local mode, as documented.
The notice's Undo restored the trash batch in whichever notebook was open
when it was clicked, so deleting a page or section, switching notebooks
and pressing Undo searched the wrong notebook and the page stayed
deleted. Undo now reopens the notebook the delete came from first.
The ink layer worked out the page's zoom from its SVG's layout width,
which not every browser reports (some give 0 for SVG elements), and
then drew and erased at the wrong place on a zoomed page. The page now
passes its zoom, as it does for its own pointer positions.
@coletebou

Copy link
Copy Markdown
Owner Author

Seventeenth review round (d79b15e): two seats clean; 6 distinct findings (one from three seats), each checked against the code. Five confirmed and fixed with tests that fail on the old code:

  • Lists pasted deeper than the indent command allows, whose innermost text reading then left out: the editor holds such an edit back, export reports such a box over the limit, and import refuses one, counting list levels as the editor does (cdc85d3). This also covers the Claude review's P3 on depth in richTextFits, and a real gap the new test found: the import counted list levels against the element depth, about twice too deep.
  • Rename notebook doing nothing with the navigation pane hidden (b01e4a6).
  • A right click on a to-do's box ticking it (afbdac8).
  • The ink layer inferring the zoom from the SVG's layout width; the page now passes its zoom (abe4af7).

Not reproduced: undo of a new section leaving the section behind. Each action is its own undo step (stopCapturing before and after), and undo removes the section with its first page, and a text box added with its text, in one step each; both are now pinned by tests (b315875).

Local: core notebook and geometry 121, UI notebook and Teams app 196, viewer unit 22, browser 12/12, both typechecks, oxlint and oxfmt clean.

Comment thread apps/office-suite/src/main.js Outdated
beforeSwitch: async () => {
for (const id of sessions.sessions.keys()) await sessions.save(id);
teams?.client?.flushStorage();
await notebook?.client?.flush();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Switching or adding a profile can stay blocked until the page is reloaded. NotebookClient.flush() runs registry.flush(), and that rethrows the stored failed error. When the notebook list could not be read at startup, client-registry.ts sets readFailed, sets failed to the load error and never clears it, because save() returns early while readFailed is true. From then on every flush() rejects. So beforeSwitch throws, and mountProfile's switchTo and the add-profile form abort every time, even though nothing new can be saved. A notebook save that keeps failing (storage full) has the same effect. The Teams flush above is not awaited and does not block a switch.

Fix: either let the registry's flush() resolve when the only error is the unreadable list (there is nothing it could save), or catch the notebook flush here and ask the user to confirm instead of refusing the switch outright.

A notebook list that could not be read made every later flush fail with
that load error, even with nothing changed, so the suite could never
switch or add a profile until a reload. The list's flush now fails only
while changes are unsaved. The suite still waits for unsaved notes
before it reloads for another profile, which would lose them, and now
says so in plain words.
An export wrote a picture or file over the 32 MB an import accepts,
making a backup no import could open. Export now refuses it.
Opening a notebook stored in more than one piece always compacted it,
so after any session's edits the next open re-encoded and wrote the
whole notebook, pictures and files included. Opening now compacts only
an older version's single copy, several bases (clients that compacted
at once), a log past the usual threshold, or a store that has shrunk:
when the live document encodes to less than half of what is stored,
as after deleting a large file, which a smaller base then replaces.
@coletebou

Copy link
Copy Markdown
Owner Author

Eighteenth review round (abe4af7): five of six seats clean; 3 findings, each checked against the code, all confirmed and fixed with tests that fail on the old code:

  • The suite's profile switch held up for good after the notebook list failed to load: that list's flush rethrew the load error with nothing unsaved. It now fails only while changes are unsaved. The suite still waits for genuinely unsaved notes, since it reloads for the other profile and would lose them, and now says why in plain words (8509aad).
  • An export could write a file over the 32 MB an import takes (cedf7e4).
  • Opening a notebook after any session's edits rewrote it whole. It now compacts on open only for an older copy, several bases, a log past the usual threshold, or a store that has shrunk (live document under half of what is stored, as after deleting a large file) (87d7ead).

Local: core notebook and geometry 123, UI notebook and Teams app 196, viewer unit 22, script tests 205, browser 12/12, core typecheck, oxlint and oxfmt clean.

A picture's type came from the shared document, checked only for its
shape, and the page showed the picture from a blob URL of the app's
own origin. A peer could store an SVG with a script, or label a picture
text/html, and opening the picture on its own (Open image in new tab)
then ran that script in the app's origin, with every notebook on the
device in reach. A picture's type is now one of the image types the
notebook takes, else PNG, and an SVG is shown as a PNG drawn from it
at its frame's size, so the page never hands out a URL that runs.
Renaming or recolouring a closed notebook set one pending flag, and
the next open wrote both the cached name and colour into the shared
document, so recolouring it reverted a collaborator's rename made
meanwhile. The name and the colour are now pending one by one, and
only what changed is written; an earlier flag still stands for both.
Without IndexedDB the status said notebooks last until the tab closes,
but they live in the page's memory, so a reload loses them too. The
status says so in every language.
@coletebou

Copy link
Copy Markdown
Owner Author

Nineteenth review round (87d7ead): four seats clean (the Claude review job did not finish); 3 findings, each checked against the code, all confirmed and fixed with tests that fail on the old code:

  • A peer's picture shown from a blob URL of the app's origin, so opening it on its own ran a script in an SVG, or anything labelled text/html. Picture types are now limited to the image types the notebook takes (else PNG), and an SVG is shown as a PNG drawn from it at its frame's size; a browser test checks the shown URL is a PNG (32f1a7b).
  • A colour change made while a notebook was closed writing the cached name back over a collaborator's rename: the name and colour are now pending one by one (1ac4505).
  • The memory-only status promising notebooks last until the tab closes, when a reload loses them too; fixed in every language (7fbeacf).

Local: core notebook and geometry 125, UI notebook and Teams app 196, viewer unit 22, browser 13/13, both typechecks, oxlint and oxfmt clean.

Comment thread src/core/notebook/client.ts Outdated
},
});
if (destroyed) return void (await next.close());
if (entry.pending.name || entry.pending.color) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] entry here is the registry entry read at line 258, before the awaits on previous.flush(), previous.close() and openNotebook(). While those run, open is null, so a renameNotebook or setNotebookColor on this notebook only sets pending in the list (line 414/418). Two things can then go wrong:

  • If the stale entry had no pending flag, the new name is never written into the document. Its pending flag also stays set, so afterCompute stops mirroring, and the document and collaborators keep the old name until the notebook is reopened.
  • If the stale entry did have a pending name, the old name is written and pending is cleared. afterCompute then copies that old name back over the list, so the rename is lost.

Fix: after await openNotebook(...), read the entry again with readRegistry(reg).find(...) and use that fresh entry for pending, name, color, lastSection and lastPage.


override disconnectedCallback(): void {
super.disconnectedCallback();
this.#destroy();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] The editor is torn down whenever its frame moves in the DOM. Containers are sorted by z (read.ts:196) and drawn with keyed repeat in page-canvas.ts. When a z order changes (Bring to front from the menu, a collaborator raising a box, or undo/redo of either), Lit moves the frames with insertBefore. That fires disconnectedCallback and then connectedCallback, so the EditorView is destroyed and rebuilt. The user loses focus, the selection and any IME composition in progress in the box they are typing in.

Fix: defer #destroy() to a microtask and skip it if isConnected is true again by then. Alternatively, render frames in a stable order (for example by id) and apply stacking only through z-index.

this.paragraph(runs, { ...(style ? { style } : {}), ...item });
} else if (node.type === 'bullet_list' || node.type === 'ordered_list') {
const kind = node.type === 'bullet_list' ? 'bullet' : 'decimal';
const level = list ? Math.min(8, list.level + 1) : 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] The level is capped at 8, but the editor allows up to 32 list levels (MAX_LIST_LEVELS). Take a same-kind list nested under a level-8 list: it reuses the parent's numId (line 192) at the same level 8, so in Word it shares the parent's counter. For example, the parent item is "1.", the nested items are "2." and "3.", and the next parent item is "4.". Nothing is added to the report either. Fix: once list.level >= 8, start a new list definition (or write plain indented paragraphs) and record the approximation in report.skipped.

Comment thread src/core/notebook/docx-export.ts Outdated

picture(picture: ExportPicture, mime: string, name: string, alt: string, maxWidth: number): void {
const ext = WORD_PICTURES[mime] ?? 'png';
const scale = picture.width > maxWidth ? maxWidth / picture.width : 1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Pictures are scaled down only to fit the width, never the height. The page's ink is exported as one PNG, so a page whose ink spans a few thousand px (or a tall, narrow picture) becomes an inline picture much taller than the page's text area. Word does not shrink inline pictures, so the picture is cut off at the bottom of the page. Fix: also limit the height to the page's text height, with Math.min(maxWidth / w, maxHeight / h, 1).

Comment thread src/core/notebook/client.ts Outdated
if (!open) throw new Error('No notebook is open');
// The archive is built from the open document; a save that failed was announced already.
await open.flush().catch(() => undefined);
return exportArchive(open);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] exportArchive(open) reads the shared open again after await open.flush(). If a switch or delete runs during the flush, this either exports a different notebook or throws a TypeError on null. Also, unlike exportPage, a failure never sends 'export-failed', so the errors exportNotebookArchive throws on purpose (a picture missing from this device, too large, too many items) never reach the UI as a notice. Fix: capture const target = open before the await, and wrap the call in the same try/catch with notice('export-failed', error).

}
return create(
{ name: snapshot.name, color: snapshot.color },
(ctx) => void writeSnapshot(ctx, snapshot),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] writeSnapshot returns how many items it could not write, but void throws that count away. For example, a stroke left with fewer than 3 usable points after inkTriples drops non-numeric values is refused by addStroke. Such items vanish from the imported notebook without a word, although archive.ts otherwise refuses rather than drops ("never drops part of a notebook unsaid"). Fix: report the count through a notice or the return value, or have importNotebookArchive reject these strokes.

const cutoff = options.now() - PURGE_AFTER_MS;
for (const entry of readRegistry(doc)) {
if (!entry.deleted || entry.deleted > cutoff) continue;
unregisterNotebook(doc, entry.id);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] The entry is removed from the list before its stored copy is deleted. If removeNotebookCopy fails (a transient IndexedDB error, or a connection closed by onversionchange), only an error is reported. Because the notebook is no longer listed, no later purge will find it, and its log and media stay on the device for good. Fix: delete the stored copy first, and unregister the entry only once that succeeds.

The undo filter took the topmost history entry as the one being
undone, but Yjs skips an entry that changes nothing (a box a
collaborator deleted) and undoes the next. The filter then judged the
next entry's fields against the wrong one and let undo strip the page
and position of a box a collaborator had written in, hiding their text.
It now reads the entry in hand: Yjs pops each before processing it.
An archive could list a page in a section it does not have (or in a
group), or an item on a page it does not have. It imported, but such a
page or item never showed, and the next export left it out. An import
now refuses such an archive.
Opening a notebook used the list entry read before it waited for the
open, so a rename made meanwhile was never written, or was reverted;
it now reads the entry again. Exporting a notebook read the open one
again after its save, which could be another by then; it keeps the
one asked for. And a purge took a notebook off the list before
removing its stored copy, so a removal that failed left the copy on
the device for good; the copy now goes first, and a failure keeps the
notebook listed in the bin for the next try.
An export still running when the app switched to another profile
handed its file to the host when it finished, so a host that uploads
exports under the account on screen could receive the previous
account's notebook. A finished export is now dropped once another
client is on screen.
The shortcuts left any focused input alone, including a to-do's
checkbox, so undo and redo did nothing right after ticking a to-do.
Only inputs that take typing hold the shortcuts back now.
Frames were drawn in stacking order, so bringing a box to the front (or
a collaborator restacking, or undo) moved its element in the page,
which ended its editor: the focus, the selection and any input method
composition were lost. Frames now keep a fixed order (by id) and
stacking only sets their z-index. The collaboration spec finds a box
by its text instead of by its place in the page, which no longer
follows stacking.
Pictures and ink were scaled down to the page's text width but never
to its height, so a tall one ran off the page. They now fit both.
@coletebou

coletebou commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner Author

Twentieth review round (7fbeacf): four seats clean; 11 findings across two seats and the Claude review (6 P2, 5 P3), each checked against the code. Fixed, with tests that fail on the old code unless noted:

  • Undo judged by the topmost history entry while Yjs had skipped it and was undoing the next, stripping a collaborator's box of its page and position (65973d3).
  • Archives with a page outside its sections or an item outside its pages importing invisibly (d8c48db).
  • Across waits in the client: a rename made while a notebook opens was lost or reverted; export re-read the open notebook after its save (guarded; the race did not reproduce in the test); a purge unlisted a notebook before removing its copy, so a failed removal left it on the device for good (eff5b06).
  • An export finishing after a profile switch handed the old profile's file to the host (c9c51b4).
  • Undo and redo held back while a to-do checkbox had the focus (ed879e3).
  • Bringing a text box to the front moved its element in the DOM and ended its editor (focus, selection, composition); frames now keep a fixed order and stacking only sets z-index. The collaboration spec now finds a box by its text, since the DOM order no longer follows stacking (8b9cf91).
  • Tall pictures running off the Word page (b0cec76).

Answered, not changed:

  • Word list levels: Word numbering has nine levels, so a list nested past them continues on the ninth level. That is a limit of the format, kept as is.
  • The count of items writeSnapshot skips: archives are validated item by item before anything is written (the guards above and in earlier rounds refuse what would be dropped); the last case, a stroke without a single point, is now refused too (1cc95fe), so that count stays zero for any archive an import accepts.

Local: core notebook and geometry 131, UI notebook and Teams app 199, viewer unit 22, browser 13/13, both typechecks, oxlint and oxfmt clean.

A stroke with no whole point imported and was then skipped when the
notebook was written, without a word. An import now refuses it, so an
import that succeeds writes every item it read.
@coletebou

coletebou commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner Author

Twenty-first review round (1cc95fe): all six Hydra seats clean, no findings.

The Claude review did not finish, twice (the second run was a re-run): the PR is over GitHub's 20,000-line diff limit, and its four parallel sub-reviews did not report back in the job's time. It posted no findings. Its recommended areas were checked by hand instead: the archive import goes through the shared zip limits (opc/zip-limits, 512 MB) before inflating, reads media only from media/ entries by in-memory lookup, and re-validates the manifest field by field; every link goes through isOpenableHyperlinkHref (editor command, schema, rich-text reads); the Word export's checkbox controls and numbering have round-trip tests; and ooxml-core/notebook, ooxml-core/notebook/editor and ooxml-ui/notebook are in exports and in the tsup entries.

CI on 1cc95fe: green. The first attempt failed one PowerPoint browser test ("Rounded selection is absent from fallback PNG export", a click timeout, in pptx e2e (vanilla 4/10); the same shard passes on upstream main at the commit this branch merged) and cancelled viewer (visio); re-running the failed jobs passed both (attempt 2), so the test was flaky. This PR changes no PowerPoint code.

@coletebou

Copy link
Copy Markdown
Owner Author

Held (2026-11-25). Not merged, and merging into this fork's main is not the way this should land.

What I checked:

  • Where it would go. This fork's main is a mirror of upstream plus one CI commit (98052412a), and it has never taken a feature merge: everything shipped so far went in as pull requests to upstream. Merging a 21,700-line app here would make the mirror diverge for good, and nothing consumes this fork's main. The mirror itself is 668 commits behind upstream today.
  • How stale the branch is. 129 commits ahead of main and 1,728 behind it (last commit 2026-10-22). A trial merge of main conflicts in 16 files: AGENTS.md, PROVENANCE.md, apps/office-suite/{README.md,src/main.js,src/ui.js}, bun.lock, docs/suite-integration.md, package.json, scripts/ci-plan.mjs, scripts/ci-plan.test.mjs, site/docs/index.html, src/core/opc/index.ts, src/core/package.json, src/ui/package.json, src/ui/src/teams/app/storage.ts, src/ui/tsup.config.ts. Against upstream main it is the same 16. Most are registries (suite tiles, package exports, the CI plan, the lockfile); opc/index.ts and the teams storage module are shared code that changed underneath it. I did not resolve them: upstream moves fast enough that a catch-up done today would be stale again before this can be proposed, and a merge of 1,700 commits says nothing until the app is rebuilt and its browser tests run.
  • Review. 28 review threads are open and none is answered. One is P1: when storage.load rejects or the stored update fails to apply, the notebook opens on an empty document and the debounced save then writes that over the stored notebook (src/core/notebook/session.ts). Nine are P2 (unvalidated nodes from an imported archive reaching writeRichText, switchTo running twice at once, a failed compaction rewriting the whole notebook on every save, the editor torn down when its frame moves in the DOM, quadratic archive import, and others). I read them but did not verify each against the current head.

What is left, in order:

  1. Sync this fork's main with upstream, then merge it into this branch and resolve the 16 files (regenerate bun.lock with the pinned Bun rather than editing it).
  2. Build, lint, unit tests and e2e/notebook on the result.
  3. Settle the 28 threads, the P1 first.
  4. Propose it upstream as a stack of smaller pull requests (core, then UI, then the suite tile and docs), within the two-at-a-time limit agreed with the maintainers. That step is the owner's to start.

The branch is untouched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size/L 500+ lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant