notes
All repositories: gitoria
5.3 KB
# w051 — notes.worldapi.org#4: offline in pure Hybriel — STOPPED at Hybriel gaps**Nothing moved.** notes-offline.js and sw.js stay, and no app file changed (only a new top entry in STATUS.md on Loreana).I measured hl:web's offline realm (`offline = [...]`: generated worker, kept state, durable queue) on a minimal repro withthe vendored ff51cf46 in real Chrome. Two things notes needs are missing, so switching now would ship a half-offline notes,which the mission forbids.Repro: `loreana:/media/STORAGE/projects/notes.worldapi.org/.scratch/w051/repro/`. It has one page component at `/` and`/p/:id`, a server-fed `count` that a push updates, and a queued `emit server`. Run it with `node run.mjs` (port 8762,Chrome 8767-8769). Output:```online /p/1 after 3 bumps: count = 3offline /p/1 reload: count = 3 (kept for this URL)offline / reload: count = 0 (server said 3 before the outage)offline /p/7 (never visited): "Unavailable offline"offline bump, then reload: queued = 1 count = 3server back (fresh, count 0): count = 1 queued = 0 (the queued bump replayed)link with on click { e.preventDefault() }: location = / handler ran: yes```What works: the queue survives a reload and replays, `__hlQueue` can show offline edits again after a reload, and an inlinehandler can claim a link.## Hybriel ticket texts**H1 — hl:web offline: a kept page's state is stored per URL, so a page with several URLs shows stale data offline.**`client.hl stateKey()` = `<component>|<pathname+search>`. `remember()` writes each push under the URL the tab is on atthat moment. Repro above: 3 pushes on `/p/1`, then go offline and load `/`: it shows 0, while `/p/1` shows 3. For notes, thelist (`notes = notesFor(session)`) is the same at `/` and every `/note/:id`. A user who edits at `/note/A` and then reloads`/` offline sees an old list, and an edit to a stale note becomes a conflict copy.Proposal: keep a need that does not read a route parameter per component, and one that does read it per URL. The graphalready knows what each need reads.**H2 — hl:web offline: a param page of a kept component that was never loaded as a document is "Unavailable offline".**`worker.hl navigation()` only answers from `caches.match(path)`. Repro: `/p/7` offline gives 503 "Unavailable offline",although `Page` is kept. For notes: a note created offline (`/note/l…`), or a note opened in-app, cannot be reloadedoffline. Today's sw.js serves one kept shell for every `/note/*`.Proposal: for a kept route with parameters, fall back to any kept document of the same route component, and boot it withthe URL's parameters and the kept state (H1).**H3 — hl:web offline: kept state, kept documents and the queue belong to no user and cannot be forgotten.**The IndexedDB `hl-offline` store (`state`, `queue`) has no user or session in its keys. The `hl-shell-*` cache keeps SSRdocuments, and their seed carries the page state, which for notes is the notes themselves. The package exports only`navigate` and `notify*`, so there is no way to drop any of this. Effects for notes:- After a log-out, the notes stay readable in this browser. Today notes-offline.js deletes its copy at log-out, and thegate checks that.- A queue left by user A replays under whichever session opens the next socket.Proposal: key the state and the queue by the session's user, drop that user's state, queue and documents at log-out, orexport `forgetOffline()` from hl:web.## App design for when H1–H3 land (worked out, not built)- `components/notes.hl` (kept):- Server-fed `notes = notesFor(session)`, with the full text of every note.- `__hlQueue`, and `mine` (this tab's edits the server has not acknowledged yet).- `rows` is derived on the client from notes, then `__hlQueue`, then `mine`. The helper functions must live in thecomponent file, because a braced import makes the derivation `srv` and it is never re-derived.- The editor is a `for` over a one-row list keyed by a stable id (the local id if the note has one). It is rebuilt onlywhen a different note is selected.- Statement-form faces `notesPut({owner,id,local,text,base,when})` and `notesDrop(...)` are queued offline. The push`notesChanged(user, list, done)` has an audience of the same user. Use `when`, not `at`: `__hlQueue` rows overwrite `at`.- Catch-up after a reconnect: a value-form `notesPull` (never queued). A null answer means offline, which drives thestatus line. A CSS-animation tick runs the pull, as tickets/tracker already do.- Server, `notes.hl`: queued saves from one device all carry the same old `base`, so the second one would conflict.- Fix: store `by` (the session tag) and `from` (the base of the last accepted save). A save with the same `by` and `from`is accepted as a continuation, not a conflict.- A losing device's further saves update its existing copy (`copyOf`, `by`, `from`) instead of making a new copy eachtime.## GateThe existing gate on the unchanged app:`NOTES_GATE_PORT=8760 NOTES_GATE_IDENT_PORT=8761 NOTES_GATE_CHROME=8767-8769 node tests/browser.mjs` → **50 passed, 0 failed**.No new gate checks, because nothing was built. Afterwards nothing is left running on 8760–8769 (8765/8766 are thecreator's services and were already running).## Open- notes#4 waits for H1–H3. Please file them in project hybriel; I did not post them.- The repro stays in `.scratch/w051/repro/` for the hybriel worker.
Branches
Latest commits
- c92e4a0ftests/e2e-outside.mjs: real-Chrome E2E, a note pushed from another device while open, then typingmre
- 0516b4ccmd-editor.hl: verbatim copy of components f3-mdvalue (an older text handed back is kept)mre
- 38cc11ecmd-editor.hl: verbatim copy of components f3-mdvalue (an outside value change is shown by the editor)mre
- 3e7e79f5reports/H1-hydrate.mdmre
- d98775e8tests/browser.mjs: wait for hydration before the clicks after a goto('/') (tables new note, phone sidebar)mre
- 1f3198b6tests/cdp.mjs: HL_CPU_THROTTLE=<rate> optional CPU throttling for gate runsmre
- 39cf9fdfre-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
- db07aa84tests: short-id-switch ports from env (NOTES_SWITCH_IDENT_PORT/_PORT), defaults unchangedmre
- ef9f9feere-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
- 5485467cdocker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
- 86ea4a85deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- edeab20fnotes mission 015: mission, report, LOG, STATUSmre
- 542a0383notes mission 015: e2e-chrome E2E_HOST (own cookie jar in the shared Chrome)mre
- 8b30f510notes mission 015: main-menu from layouts 0bcc629, current = true kept (route marks only /), server-HTML marker checksmre
- 84b574c4notes mission 015: re-vendor plugins from hybriel f9614007 (incl. web, #117)mre
- 447da53dnotes mission 014: report — remaining gates and lisbeth E2E proofmre
- fd9f92c3notes mission 014: report (partial), LOG, STATUSmre
- b2501360notes mission 014: open() sets asking=false before flush(0) (hybriel#196)mre
- 9414ce59notes mission 014: merge theme 76f99f6, components 3794c59, strict single-press openAsk (fails on old open())mre
- c08c655anotes 013: theme re-copied from layouts 76f99f6 (menu marks the current page), current = true on the menu item, e2e marker checks, reportmre