gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit39cf9fdf39cf9fdfre-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)mre39cf9fdf/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

  • 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
  • 21c8f65dnotes mission 012: STATUSmre
  • 0bbb3dd9notes mission 012: delete section of the browser gate de-flaked (openAsk: calm wait, press again when the question closes by itself); report 012mre
  • f431bdf8notes mission 011: notes on the layouts theme (ListFirst shell), styles cut, check-theme gate, E2E extended; reportmre
  • 1a8603d1notes mission 011 WIP: deploy.sh gate summary also matches check-theme, browser.mjs logout via the user menumre
  • dae2e508notes mission 011 WIP: theme dbe3de7, shell on AppHeader/MainMenu/UserMenu/Sidebar + ListFirst, styles cut to the app's own, check-theme gate, e2e auditmre
  • fd36da27notes mission 010: the note editor is the Hybriel MdEditor block (components.hybriel 1442e58, verbatim); md-editor.js, its route, script tag and offlineFiles retired; gate 66/0, realdata-offline 12/0, round-trip and Chrome E2E tests; report 010mre