tickets
All repositories: gitoria
10.6 KB
# Report — tickets mission 016: the ticket page's comments through the shared Comments block (layouts#2)Worker A2 (Atlas), 2026-10-20, branch `wc` (from main e4c3475 = live, Hybriel 0f396652). Not deployed, not pushed, not merged.## What works- **The ticket page** (`components/ticket.hl`): the history is as it was. Only the comments in it are drawn by the shared Commentsblock (`components/comments/`, copied BYTE-VERBATIM with `components/md-editor/` from components.hybriel.worldapi.org 9db927dby `tools/sync-components.sh`, which is modelled on layouts' and writes `components/SOURCE`; `--check` compares). Every run of comments that follow eachother is one block in its place between the state changes, edits, assigns and links (`entriesOf`). "Write a comment" under"Respond" is one more block that shows only its form: typed in the MdEditor, sent with the Comment button or Ctrl+Enter.Signed out or not a member: `user = ''` (read only: no form, no Edit / Delete, the like does nothing).- **Edit** (the author only): Save stores the new text. The earlier versions stay and fold out under "edited" ("Edited once").**Delete** (the author only): the block asks "Delete this comment?" (Keep / Delete). **Like** (any member): one per user, asecond press takes it back; the count and "liked" are per viewer. Every open page follows live (push `commentChanged`).- **Server** (`lib/comments.hl`, its own topic file; `lib/tickets.hl changeComment` finds the ticket and the event and wraps it likeits other writes): append-only `comment-changes` table (edit / delete) + `comment-likes` table, both created empty at the firststart, no migration. The comment event stays the history event with its FIRST text (`events` is still append only).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 beforethe login (no `user`) cannot be changed. The faces `ticketCommentEdit` / `ticketCommentDelete` / `ticketCommentLike` and the API(below) refuse everybody else.- **Decision, a deleted comment**: it leaves ONE line in its place, "alice commented (deleted 2026-10-20 11:40)", with no text. Alater state change or reply then still reads in order. The text is gone from pages, pushes, JSON and the Markdown view; thestored texts stay (append only). It is written down in README "Comments".- **Decision, the event stream** (`/api/events`): unchanged. Edits, deletions and likes are not history events, so no new eventkind is sent. They do not change the ticket's `updated` or `events` either. If programs should hear edits, that is a new kind`comment-edit` later (Atlas / the creator decide).## Why the old editor had to go (scope)The shell loaded `shared/md-editor.js`, which defines the custom element `md-editor` for the whole document. On a page with theblock it took over the block's own `<md-editor>` elements (MdEditor's root tag). Measured in a prototype (`probe/p3.mjs`): every commenteditor got the JS editor's shadow DOM, became 236 px tall with its toolbar, and the comment text was 1 px wide. Pages changewithout a reload, so loading it only on some pages does not work. All five Markdown fields therefore use the Hybriel MdEditor now:the comment form (the block), the state note, the edit summary, the new-ticket summary and a project's description. `/md-editor.js`and `shared/md-editor.js` are removed. Each field is an `<md-field>` (caption + editor), NOT a `<label>`: a label hands its clicks tothe 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 toempty it (the block's own trick).## Gaps- **Block (components.hybriel), not Hybriel**: Comments has no switch for its count line ("2 comments"), its empty line or itsform. A host that puts runs of comments between other entries hides them with its own CSS (`components/styles.hl`, `#eventscomments-block …`). The copies stay verbatim. Wish for components.hybriel: `showCount` / `showForm` (or a "segment" mode).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:webbuilds a composed child anew when a bound value changes; the block README says so).- **Hybriel**: no gap found. (Note: `comments = []` on a reference is refused, "a binding is a literal, a member or a fieldpath"; the clear message names the fix, `noComments = []` at the root.)- **Found, not changed (it was already there in the old code)**: the ticket page's member `me = userOfSession(session)` is thewhole user record, so the signed-in user's OWN page seed carries their ident id (`"identity":"az5b2"` on a copy, both old andnew). Only that user sees it, but README says it is never in a page except `/you`. Fix later: `me` = `{ id, name }`.## API changes for API users (README "Comments"; for the tickets-for-sessions doc)- New: `POST /api/tickets/:ref/comments/:comment/edit {text}`, `…/delete` (body empty or `{}`), `…/like` (body empty or `{}`;again = take it back), also under `/api/projects/:slug/tickets/:number/comments/:comment/…`. `:comment` = the comment's event`id`. Answer 200 `{ticket, event, liked?}`; 401 no token, 403 not the author / not a member, 404 no such ticket / comment,400 empty / unchanged text, a deleted comment, a non-comment entry, a bad body (strict as all POSTs). Token as for a comment(a connected app's key + `X-Tickets-Identity` works too).- Event rows: **an untouched comment keeps exactly its old keys** (gate check + real data: 922/922 JSON answers byte-identical).Only a changed comment carries more: edited → `text` = the newest, `edited: true`, `editedWhen`, `earlier: [{when, text}]`;deleted → `text: ""`, `hasText: false`, `deleted: true`, `deletedWhen`, `label: "commented (deleted …)"`; liked → `likes`(only when > 0). The Markdown view says "commented (edited …)" and shows the newest text; a deleted comment shows its labelonly. The event stream is unchanged (nothing for edits / deletions / likes). New push for pages: `commentChanged(ticketId, event)`.## Gates (slot 8700–8739; old = e4c3475 + brief, as an archive tree with the same bin)| gate | old | new ||---|---|---|| `tests/browser.mjs` | 326 passed, 0 failed | **351 passed, 0 failed** (+21 "m016:" checks, 4 ported, PWA list +1 ticket) || `tests/events.mjs` | 52 / 0 | **52 / 0** (its browser comment is typed into the block's MdEditor) || `tests/connect.mjs` | — | 60 / 0 |- New checks with real clicks / keys: post (real keys, Shift+Enter, Ctrl+Enter), edit (End + keys, Save; B follows live; aclick on "edited" folds out the earlier version), delete asks (Keep keeps; Delete removes it in A and B and leaves its line), liketoggle (B ♥ 1 / A ♡ 1 live, again ♡ 0), Edit / Delete only on your own comment, comments in place (created, comment, state,comment), a non-member reads only (no form / Edit / Delete, the like does nothing) and the server refuses them (four faces withbob's own session, three API calls → 403), another user's comment refused (faces + API 403), the API table, the keys of anuntouched comment, no overflow at 390 / 1280 px. The ported comment and table checks now type into the block. Tables in a comment aredrawn by MdEditor (the table scrolls in its own box). The server's HTML carries a comment's Markdown escaped in the block's hiddenfield; comments are no longer formatted on the server.- **They can fail**: old code + new gate → 234 ok, then FAIL at the first new check ("the comment editor is live"; the portedhistory checks pass on the old code too — they check that the history is unchanged). A mutant of the new code (no member check,no author check in lib/comments.hl, `writer = meName` for everybody) → 277 passed, 6 failed: every m016 rights check (non-memberlike, faces, API; another user's comment).- Screenshots `.scratch/gate-{phone,desktop}-comments.png` (+ the existing ones). **I could not look at PNGs** (no image viewer inthis session). I checked the layout in the DOM instead: no horizontal overflow at 390 / 1280 px, every comment text drawn with height > 0, at mostone visible comment form, no visible count lines inside the history. The creator should look at them once.- Code order: `tests/letcount.py` → 1 root .hl, `let` never reassigned 0.## Real data (copy of deploy backup tickets.worldapi.org-20261020-0216.tgz, storage/mpackdb only; an az5b2 session in the copy)- `tests/realdata-baseline.mjs` old vs new, each on its own fresh copy, 2,875 answers: **JSON 922/922 byte-identical**, Markdown922/922 identical up to the server's port in the URLs, refusals 17/17 identical. Pages (898 of 928) differ as expected: everypage carries hl:web's route table (6 new API routes, 2 new component modules, `/md-editor.js` gone) and no `<scriptsrc="/md-editor.js">`. Ticket pages draw comments with the block. Writes (`realdata-compare-writes.py`, port masked): 66/72 identical; the 6 others areintended: the page push of a new comment carries `likedBy: []`, the face `ticketRights` also answers `name` + `userId` (the blocks'user after a login), and 4 pages (shell / ticket page). All API write answers are identical.- Chrome, old vs new page by page, signed in as az5b2: **all 401 tickets** (2,468 history entries, 650 comments):401 the same — the same entries in the same order, the same authors and times, the same comment text as drawn (old: markdown.hl,new: the block's MdEditor; whitespace-normalised innerText), the same header / summary / relations; the new pages have nohorizontal overflow at 1280 px or 390 px; no console errors (`probe/compare.mjs` in the scratch dir).The creator's long tickets included (antcolony #20: 36 entries / 12 comments; calendar #3, components #2/#4/#5, tickets #23).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.- Copies deleted after the runs.## Commits (branch wc)- eef80f5 the mission (code, gates, README)- this report + LOG + STATUS## Test steps for the creator (on a copy or after a deploy)1. Open a ticket with comments and state changes: the comments sit where they were, between the state lines; your own carryEdit / Delete, the others only ♡.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.A second tab follows without a reload.3. Press ♡ on someone's comment (♥ 1), press again (♡ 0). Delete your comment: it asks first; after Delete, one line"… commented (deleted …)" stays in its place.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