gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmain5d144817Merge branch 'records-t40' into mainTicketsmain/reports/016-comments-block.md

10.6 KB

  1. # Report — tickets mission 016: the ticket page's comments through the shared Comments block (layouts#2)
  2. Worker A2 (Atlas), 2026-10-20, branch `wc` (from main e4c3475 = live, Hybriel 0f396652). Not deployed, not pushed, not merged.
  3. ## What works
  4. - **The ticket page** (`components/ticket.hl`): the history is as it was. Only the comments in it are drawn by the shared Comments
  5. block (`components/comments/`, copied BYTE-VERBATIM with `components/md-editor/` from components.hybriel.worldapi.org 9db927d
  6. by `tools/sync-components.sh`, which is modelled on layouts' and writes `components/SOURCE`; `--check` compares). Every run of comments that follow each
  7. other is one block in its place between the state changes, edits, assigns and links (`entriesOf`). "Write a comment" under
  8. "Respond" is one more block that shows only its form: typed in the MdEditor, sent with the Comment button or Ctrl+Enter.
  9. Signed out or not a member: `user = ''` (read only: no form, no Edit / Delete, the like does nothing).
  10. - **Edit** (the author only): Save stores the new text. The earlier versions stay and fold out under "edited" ("Edited once").
  11. **Delete** (the author only): the block asks "Delete this comment?" (Keep / Delete). **Like** (any member): one per user, a
  12. second press takes it back; the count and "liked" are per viewer. Every open page follows live (push `commentChanged`).
  13. - **Server** (`lib/comments.hl`, its own topic file; `lib/tickets.hl changeComment` finds the ticket and the event and wraps it like
  14. its other writes): append-only `comment-changes` table (edit / delete) + `comment-likes` table, both created empty at the first
  15. start, no migration. The comment event stays the history event with its FIRST text (`events` is still append only).
  16. Rights are checked by user id: edit / delete = the comment's `user` while still a member of the project; like = any member. A comment from before
  17. the login (no `user`) cannot be changed. The faces `ticketCommentEdit` / `ticketCommentDelete` / `ticketCommentLike` and the API
  18. (below) refuse everybody else.
  19. - **Decision, a deleted comment**: it leaves ONE line in its place, "alice commented (deleted 2026-10-20 11:40)", with no text. A
  20. later state change or reply then still reads in order. The text is gone from pages, pushes, JSON and the Markdown view; the
  21. stored texts stay (append only). It is written down in README "Comments".
  22. - **Decision, the event stream** (`/api/events`): unchanged. Edits, deletions and likes are not history events, so no new event
  23. kind is sent. They do not change the ticket's `updated` or `events` either. If programs should hear edits, that is a new kind
  24. `comment-edit` later (Atlas / the creator decide).
  25. ## Why the old editor had to go (scope)
  26. The shell loaded `shared/md-editor.js`, which defines the custom element `md-editor` for the whole document. On a page with the
  27. block it took over the block's own `<md-editor>` elements (MdEditor's root tag). Measured in a prototype (`probe/p3.mjs`): every comment
  28. editor got the JS editor's shadow DOM, became 236 px tall with its toolbar, and the comment text was 1 px wide. Pages change
  29. without a reload, so loading it only on some pages does not work. All five Markdown fields therefore use the Hybriel MdEditor now:
  30. the comment form (the block), the state note, the edit summary, the new-ticket summary and a project's description. `/md-editor.js`
  31. and `shared/md-editor.js` are removed. Each field is an `<md-field>` (caption + editor), NOT a `<label>`: a label hands its clicks to
  32. the editor's first button, "B". The editor is built once per element, so a page binds a start value and gives a form a new key to
  33. empty it (the block's own trick).
  34. ## Gaps
  35. - **Block (components.hybriel), not Hybriel**: Comments has no switch for its count line ("2 comments"), its empty line or its
  36. form. A host that puts runs of comments between other entries hides them with its own CSS (`components/styles.hl`, `#events
  37. comments-block …`). The copies stay verbatim. Wish for components.hybriel: `showCount` / `showForm` (or a "segment" mode).
  38. Also: a push that changes a run's list builds that block anew, so an Edit someone has open in the same run closes (hl:web
  39. builds a composed child anew when a bound value changes; the block README says so).
  40. - **Hybriel**: no gap found. (Note: `comments = []` on a reference is refused, "a binding is a literal, a member or a field
  41. path"; the clear message names the fix, `noComments = []` at the root.)
  42. - **Found, not changed (it was already there in the old code)**: the ticket page's member `me = userOfSession(session)` is the
  43. whole user record, so the signed-in user's OWN page seed carries their ident id (`"identity":"az5b2"` on a copy, both old and
  44. new). Only that user sees it, but README says it is never in a page except `/you`. Fix later: `me` = `{ id, name }`.
  45. ## API changes for API users (README "Comments"; for the tickets-for-sessions doc)
  46. - New: `POST /api/tickets/:ref/comments/:comment/edit {text}`, `…/delete` (body empty or `{}`), `…/like` (body empty or `{}`;
  47. again = take it back), also under `/api/projects/:slug/tickets/:number/comments/:comment/…`. `:comment` = the comment's event
  48. `id`. Answer 200 `{ticket, event, liked?}`; 401 no token, 403 not the author / not a member, 404 no such ticket / comment,
  49. 400 empty / unchanged text, a deleted comment, a non-comment entry, a bad body (strict as all POSTs). Token as for a comment
  50. (a connected app's key + `X-Tickets-Identity` works too).
  51. - Event rows: **an untouched comment keeps exactly its old keys** (gate check + real data: 922/922 JSON answers byte-identical).
  52. Only a changed comment carries more: edited → `text` = the newest, `edited: true`, `editedWhen`, `earlier: [{when, text}]`;
  53. deleted → `text: ""`, `hasText: false`, `deleted: true`, `deletedWhen`, `label: "commented (deleted …)"`; liked → `likes`
  54. (only when > 0). The Markdown view says "commented (edited …)" and shows the newest text; a deleted comment shows its label
  55. only. The event stream is unchanged (nothing for edits / deletions / likes). New push for pages: `commentChanged(ticketId, event)`.
  56. ## Gates (slot 8700–8739; old = e4c3475 + brief, as an archive tree with the same bin)
  57. | gate | old | new |
  58. |---|---|---|
  59. | `tests/browser.mjs` | 326 passed, 0 failed | **351 passed, 0 failed** (+21 "m016:" checks, 4 ported, PWA list +1 ticket) |
  60. | `tests/events.mjs` | 52 / 0 | **52 / 0** (its browser comment is typed into the block's MdEditor) |
  61. | `tests/connect.mjs` | — | 60 / 0 |
  62. - New checks with real clicks / keys: post (real keys, Shift+Enter, Ctrl+Enter), edit (End + keys, Save; B follows live; a
  63. click on "edited" folds out the earlier version), delete asks (Keep keeps; Delete removes it in A and B and leaves its line), like
  64. toggle (B ♥ 1 / A ♡ 1 live, again ♡ 0), Edit / Delete only on your own comment, comments in place (created, comment, state,
  65. comment), a non-member reads only (no form / Edit / Delete, the like does nothing) and the server refuses them (four faces with
  66. bob's own session, three API calls → 403), another user's comment refused (faces + API 403), the API table, the keys of an
  67. untouched comment, no overflow at 390 / 1280 px. The ported comment and table checks now type into the block. Tables in a comment are
  68. drawn by MdEditor (the table scrolls in its own box). The server's HTML carries a comment's Markdown escaped in the block's hidden
  69. field; comments are no longer formatted on the server.
  70. - **They can fail**: old code + new gate → 234 ok, then FAIL at the first new check ("the comment editor is live"; the ported
  71. history checks pass on the old code too — they check that the history is unchanged). A mutant of the new code (no member check,
  72. no author check in lib/comments.hl, `writer = meName` for everybody) → 277 passed, 6 failed: every m016 rights check (non-member
  73. like, faces, API; another user's comment).
  74. - Screenshots `.scratch/gate-{phone,desktop}-comments.png` (+ the existing ones). **I could not look at PNGs** (no image viewer in
  75. this session). I checked the layout in the DOM instead: no horizontal overflow at 390 / 1280 px, every comment text drawn with height > 0, at most
  76. one visible comment form, no visible count lines inside the history. The creator should look at them once.
  77. - Code order: `tests/letcount.py` → 1 root .hl, `let` never reassigned 0.
  78. ## Real data (copy of deploy backup tickets.worldapi.org-20261020-0216.tgz, storage/mpackdb only; an az5b2 session in the copy)
  79. - `tests/realdata-baseline.mjs` old vs new, each on its own fresh copy, 2,875 answers: **JSON 922/922 byte-identical**, Markdown
  80. 922/922 identical up to the server's port in the URLs, refusals 17/17 identical. Pages (898 of 928) differ as expected: every
  81. page carries hl:web's route table (6 new API routes, 2 new component modules, `/md-editor.js` gone) and no `<script
  82. src="/md-editor.js">`. Ticket pages draw comments with the block. Writes (`realdata-compare-writes.py`, port masked): 66/72 identical; the 6 others are
  83. intended: the page push of a new comment carries `likedBy: []`, the face `ticketRights` also answers `name` + `userId` (the blocks'
  84. user after a login), and 4 pages (shell / ticket page). All API write answers are identical.
  85. - Chrome, old vs new page by page, signed in as az5b2: **all 401 tickets** (2,468 history entries, 650 comments):
  86. 401 the same — the same entries in the same order, the same authors and times, the same comment text as drawn (old: markdown.hl,
  87. new: the block's MdEditor; whitespace-normalised innerText), the same header / summary / relations; the new pages have no
  88. horizontal overflow at 1280 px or 390 px; no console errors (`probe/compare.mjs` in the scratch dir).
  89. The creator's long tickets included (antcolony #20: 36 entries / 12 comments; calendar #3, components #2/#4/#5, tickets #23).
  90. On a copy, as az5b2: post (Ctrl+Enter), edit, like / unlike, delete on hybriel #53 all worked; his own comments carry Edit / Delete, others' do not.
  91. - Copies deleted after the runs.
  92. ## Commits (branch wc)
  93. - eef80f5 the mission (code, gates, README)
  94. - this report + LOG + STATUS
  95. ## Test steps for the creator (on a copy or after a deploy)
  96. 1. Open a ticket with comments and state changes: the comments sit where they were, between the state lines; your own carry
  97. Edit / Delete, the others only ♡.
  98. 2. Write a comment in the form under "Respond" and press Ctrl+Enter. Then Edit it, add a word, Save: "edited" appears, and a click shows the earlier text.
  99. A second tab follows without a reload.
  100. 3. Press ♡ on someone's comment (♥ 1), press again (♡ 0). Delete your comment: it asks first; after Delete, one line
  101. "… commented (deleted …)" stays in its place.
  102. 4. Log out: the comments stay readable, no form, no Edit / Delete.

Branches

Latest commits

  • 5d144817Merge branch 'records-t40' into mainTickets
  • 44ee6f06|||PR records: #43 #45 livemre
  • b8fdeee9Merge branch 'p39-routes' into mainTickets
  • a0187a0a|||PR Remove redundant route-order loopmre
  • 369e4b9cMerge branch 'k40-lists' into mainTickets
  • 9af8e780|||PR Use keyed list mutations for live ticket updatesmre
  • 610d8e8aMerge branch 'records-t39' into mainTickets
  • 32bcdf24|||PR records: GO P39 K40mre
  • 4123c6d1Merge branch 'records-t38' into mainTickets
  • cd3641a1|||PR records: day72 deploy live, tickets closedmre
  • 7d44d852Merge branch 'records-t37' into mainTickets
  • 926f7061|||PR records: merges, D36 deploymre
  • bf58534eMerge branch 'l33-final' into mainTickets
  • 759a9ac3|||PR thin login (tickets#46, #45): merge main, route entry cleanupmre
  • 239436d8Merge remote-tracking branch 'origin/main' into l33-finalmre
  • 5822cb3aMerge branch 'o34-clean' into mainTickets
  • 0870653c|||PR offline note from __hlOnline, no polling (tickets#41)mre
  • 14cf96b4Merge branch 'records-t36' into mainTickets
  • 07749fa1|||PR records: day72 + #40 mergedmre
  • ecd7e226|||PR Consolidate login and move handler logic into topic libraries (partial)mre