gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmainc028ac61Merge branch 'notes-pr7-kunibert' into mainAtlasmain/reports/007-offline-pure-hybriel-2.md

8.7 KB

  1. # notes mission 007 — notes#4: offline and sync in pure Hybriel — BUILT, one Hybriel gap (the editor offline)
  2. **notes-offline.js and sw.js are deleted**, along with their routes. The notes page is now plain Hybriel
  3. (`components/notes.hl`). `project.hl` has `offline = [Notes]`, so hl:web's generated worker, its kept state per user and
  4. its queue do the offline work. No hand-written JS is added (login.js and the vendored md-editor.js stay, as before).
  5. Branch w7. Not pushed, not deployed.
  6. ## Hybriel #166 first (repros of mission 005, re-run on the vendored 0f396652)
  7. - `repro-rowkidless`: `client booted (window.__hl): true rows: one,two`. It was `false` + a TypeError on a832f73b.
  8. - `repro-rehydrate`: `offline reload: client booted (window.__hl): true rows: one,new`. Fixed.
  9. - `proto` (the design probe): an offline put is queued, kept over an offline reload, and replayed when back online. The
  10. server has both puts.
  11. ## What was built (design of report 001)
  12. - `lib/notes.hl`: `notesFor(user)` gives the page's list. A save carries `by` (the login tag) and `since`; a save whose
  13. `by` + `base` match the note's `by` + `since` CONTINUES that browser's run, so queued saves made from one old base do
  14. not conflict with each other. The conflict rule is unchanged: the later edit wins and the other version becomes a
  15. copy. A browser that lost keeps writing into ITS copy (`copyOf`, `by`, `since`) instead of making a new copy for
  16. every save. `removeNote` finds a never-synced note by `local`. The field is named `since` because `from` is a
  17. reserved word.
  18. - `components/notes.hl`: `notes` (server-fed, kept offline). `rows` = notes, then `__hlQueue`, then this tab's
  19. `edits`, derived in the browser (the helper statics stay in this file). Statement-form faces `notesPut` and
  20. `notesDrop` are queued offline. Push `notesChanged(user, list)` goes to every tab of that user (audience in
  21. project.hl). A 1 s CSS tick (`notesTick`) sends what was typed 0.6 s ago and calls the value-form `notesPull` every
  22. 10 s and on `reconnected`. Sidebar links are claimed in place (`e.preventDefault()` + `history.replaceState`). A note
  23. made offline has the id `l…` until its first save lands; then the address follows the server id. Log-out is the face
  24. `notesLogOut`, after which hl:web forgets that user's state, queue and documents. The UI keeps the same tags and ids.
  25. - The JSON API `/api/notes` stays (the gate uses it to read the server), now with `by` = '' (no continuation).
  26. ## Works offline (gate, real Chrome, CDP offline on the page AND its worker, always RELOADED offline first)
  27. The kept page boots from hl:web's worker with no socket. It shows the list and the open note, and says "Offline — …".
  28. An existing note was edited and a new note written, both with real keys. Both wait in hl:web's queue and the server
  29. has neither. After another offline reload both are still there. Back online, the server has both, the new note has a
  30. server id (in the address too), and device B shows the edit in its open note. Two devices both offline (server
  31. stopped): B's later edit is the note and A's is kept as a copy. One device offline in Chrome and one online: the online
  32. edit wins, the offline one becomes a copy, and A's editor then shows the winner. Log-out: no note text is left in any
  33. IndexedDB database, the queue is empty, and no kept document holds a note. PWA: manifest, icons, installable, and
  34. exactly one worker (`/__hl/sw.js`); `/sw.js` and `/notes-offline.js` answer 404.
  35. ## Hybriel gap (Atlas → Anton) — this part is stopped, no workaround
  36. **hl:web offline keeps no app `file`/`directory` route, and an app cannot add a URL to the worker's precache.**
  37. - The page boots offline, but a script it loads from its own route (notes: `/md-editor.js`, the Markdown editor)
  38. fails to load.
  39. - Without the script the note opens in the plain `<textarea>` that `<md-editor>` wraps. Typing, the queue and sync all
  40. work, but there is no Markdown view or toolbar until a reload online. Today's sw.js kept it.
  41. - Cause: `worker.hl answer()` → "everything else goes to the network untouched". `WebFramework.hl precacheList()`
  42. holds only the runtime, the package halves, the stylesheet, the modules, the manifest, the icons, the favicon and
  43. the kept pages.
  44. - Repro: `notes-w7/.scratch/w7/repro-appfile/`. Run `REPRO_PORT=8731 ../../../bin/hybriel project.hl`, then
  45. `node run.mjs`. Output: `online: … widget.js ran: true` / `kept by the worker: /__hl/hl-runtime.js /__hl/app.css
  46. /__hl/web/client.js /page.hl /__hl/manifest.webmanifest /` / `offline: page shown: true widget.js ran: false`.
  47. - Proposal: an `offlineFiles = ['/md-editor.js', …]` setting, or keep every `file` route a kept page's View loads
  48. (`script { src }` / `link { href }` literals).
  49. - The gate checks this and FAILS on it (2 checks, below). I did not change the md-editor route's cache headers: that
  50. would be a workaround.
  51. ## Gate (`NOTES_GATE_PORT=8720 NOTES_GATE_IDENT_PORT=8721 NOTES_GATE_CHROME=8722-8729 node tests/browser.mjs`)
  52. - Old code, old gate: **57 passed, 0 failed**.
  53. - New code, new gate: **62 passed, 2 failed** (64 checks). Both failures are the gap: "the Markdown editor is there
  54. offline" and "tables: offline … with the table" (the text itself is there).
  55. - Rewritten (they tested the JS files):
  56. - the worker keeps the page and the shell (`hl-shell-*`);
  57. - exactly one worker, `/__hl/sw.js`; `/sw.js` and `/notes-offline.js` answer 404;
  58. - the offline section now runs on Chrome offline instead of a stopped server;
  59. - the sync waits: socket open and hl:web's queue empty (was `__notesOffline.sync()`);
  60. - log-out scans every IndexedDB and every kept document.
  61. - New checks:
  62. - no hand-written notes JS on the page;
  63. - the offline reload booted from the worker with no socket;
  64. - the editor is there offline;
  65. - the offline edits wait in the queue while the server has neither;
  66. - three checks for one device offline and one online.
  67. - **Fails on old code** (the new gate against `git archive 0176c4b`, `NOTES_GATE_SOFT=1` so that a timed-out wait does
  68. not stop the run): 58 passed, 6 failed. That run was 59/6; the +1 is the check removed later, which passed
  69. there. The failures:
  70. - hl:web worker keeps the page and shell;
  71. - one `/__hl/sw.js` worker;
  72. - no hand-written JS;
  73. - the sidebar says it is offline (old JS never says it under CDP offline);
  74. - the edits wait in hl:web's queue;
  75. - the one-offline precondition (A's edit waits in the queue).
  76. - Passing on old code as well, as they should (same behaviour as today): the one-offline conflict outcome, both log-out
  77. checks, and "the editor is there offline" (old sw.js kept md-editor.js; the new code fails it = the gap).
  78. - The log-out check passes on old code, so I ran it on a mutated copy where `client.hl forget()` returns at once:
  79. it fails (61/3; the run was 62/3 with the since-removed check passing).
  80. - A check that did not fail under that mutation ("offline reload after log-out shows no notes") was removed.
  81. - Flake: "B follows the delete" timed out in 1 of 6 runs and did not come back in the later runs.
  82. `NOTES_GATE_DEBUG=1` dumps both devices' state if it happens again.
  83. ## Real data (`node tests/realdata-offline.mjs <newest backup> 8720 8722-8726`)
  84. - Data: `notes.worldapi.org-20261019-2028.tgz`, storage/mpackdb only, as a copy (deleted after: `copy deleted: true`).
  85. The session is a file for az5b2 → 0muh6o5a3kkd.
  86. - **6 passed, 0 failed**:
  87. - all **28** live notes are listed by id;
  88. - after an offline reload, 28 are listed with no socket;
  89. - an edit typed offline with real keys is not on the server while offline;
  90. - back online, it is in the SAME note (no copy, still 28 notes);
  91. - the server logged no error.
  92. - The mission said 49 notes. This backup has 42 note records: 28 live and 14 tombstones.
  93. ## Screenshots: checked as text and colours (computed styles + PNG pixel counts, no image viewer)
  94. - Every shot: header rgb(15,20,25) (token `darker`), page rgb(25,30,35), brand rgb(220,220,170) yellow, no
  95. horizontal overflow.
  96. - 1280: list 320 px beside the reader 889 px.
  97. - 390: the list is hidden while a note is open, the reader is 358 px.
  98. - Offline: the md-editor surface rgb(35,40,45) is gone (phone 3.9 % → 0 %); the plain textarea (dark, 358/889 px)
  99. shows instead (the gap).
  100. - Files: `.scratch/gate-*.png` and `.scratch/realdata-{390,1280}-{online,offline}.png`.
  101. ## Not covered
  102. - A log-out made while offline: `notesLogOut` is a statement-form face of the shell, not of the kept page.
  103. - Text typed less than ~1 s before Log out is not sent: the tick has not fired yet. The old JS sent it first.
  104. ## Commits (branch w7)
  105. 510aff7 server continuation · e5785b0 the page in Hybriel · 52a2aca gate · 632223f delete notes-offline.js + sw.js ·
  106. 7f6a409 README + realdata-offline · 2cce9c9 code order (`let` 0 never reassigned) + gate soft/debug · (this report).
  107. Nothing of mine is left running on 8720–8739.

Branches

Latest commits

  • c028ac61Merge branch 'notes-pr7-kunibert' into mainAtlas
  • 9cc92bdfKeep conflict and history fixes while awaiting queued save supportAtlas
  • a5c27cb6Allow real edits back to earlier text and honor configured identAtlas
  • 15c46ced|||PR Preserve note edits, conflict bases and visible historyAtlas
  • 4c6e0bf6Merge branch 'notes13-day61' into mainAtlas
  • eb51864f|||PR Back/Forward via navigate, server drafts, Hybriel day61Atlas
  • 3537cf7eMerge branch 'vendor-day59' into mainAtlas
  • c13d188b|||PR Vendor Hybriel day59Atlas
  • 24c95433Merge branch 'notes17-ghost-note' into mainAtlas
  • ae1075b2Preserve rejected drafts during note ID adoptionAtlas
  • 383cce23|||PR Prevent saved local edits from restoring deleted notesAtlas
  • 99ca1cf6Merge branch 'vendor-day56' into mainAtlas
  • 649cef37|||PR Vendor Hybriel day56Atlas
  • aadd0abcMerge branch 'hl-standard-2' into mainAtlas
  • 52ffac9f|||PR Keyboard and reload checks for the notes gate (HL-STANDARD F21, F5)Atlas
  • 617ee8c0Merge branch 'hl-standard' into mainAtlas
  • 452458ee|||PR Type the function parameters of notes' own .hl files (HL-STANDARD L10)Atlas
  • 23758cd6Re-vendor complete Hybriel plugins and runtime to day44mre
  • 5d7cc700Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
  • 3e07b1cfVendor complete Hybriel day39 plugin sources and librariesmre