gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit0814ce6b0814ce6bTickets conductor: brief 025 tickets#36 style formmre0814ce6b/reports/017-image-attachments.md

7.5 KB

  1. # Report — tickets mission 017 (tickets#27): image and file attachments in ticket comments + the API — WIP, STOPPED (quota)
  2. Worker I2 (Atlas), 2026-10-20, branch `w27` (from main f83d9c0 = live) + components.hybriel branch `w27c` (from main 13389d6),
  3. Hybriel 0f396652. Stopped by Atlas ("QUOTA STOP") in the middle of the first gate run of the new code. Not deployed, not pushed, not merged.
  4. ## State per repo
  5. - **components.hybriel `w27c`: commit 1f8d79d** (WIP). Comments block: `attach = "true"` puts the block's form INSIDE the shared
  6. FilesUpload (pick mode, unchanged, imported from `../files-upload/files-upload.hl`); `onPost(text, files)` with the waiting
  7. browser Files (without `attach` nothing changes: `onPost(text)`); a post may be files only; answering `false` keeps text + files.
  8. Members `maxFileSize`, `accept`, `attachText`, `chooseText`, `cameraText`, `filesLabel`. Each comment record may carry `files`
  9. `[{ name, url, image, size }]`: pictures = 6rem thumbnails (`a.comment-thumb`, `target=_blank`, opens the full picture), other
  10. files = rows (`a.comment-file`: kind, name, size); a file without `url` = a row without a link (`span.comment-file`). Size texts by
  11. integer maths (works on the server too — no toFixed, hybriel#182). `button.comment-post` is 44 px high now.
  12. MdEditor: `files = "off"` hides the File button and leaves pasted / dropped files to the page (they bubble on to FilesUpload);
  13. the block's attach form uses it. Demo `/comments`: attach on (2 MB per file, files kept one day via lib/uploads.hl storeMdFiles),
  14. bob's comment shows a picture + a file row, c3 a file without url.
  15. **Components gate: old 343/0; new 356 passed / 1 failed** (run before the stop). The failure is the gate check "two chosen pictures +
  16. a real Ctrl+V … the editor keeps only the text": the three thumbnails are right, but the editor's value was `""` — the typed text did
  17. not arrive. A probe (choose a file, click the editor, real keys) afterwards showed the SAME element and value `"abc"`, so it is the
  18. check's typing (its `typeText` sends keyDown with `text` but no `code`/`unmodifiedText` after `tryDo(click)`), not the block — not
  19. proven. README of comments / md-editor NOT yet updated for attach / files="off".
  20. - **tickets `w27`: commit (this one)** (WIP). Blocks copied verbatim from w27c 1f8d79d (`tools/sync-components.sh`, now also
  21. `files-upload/`, and it accepts a git worktree as source); `components/SOURCE` = 1f8d79d.
  22. - `lib/attachments.hl` (new topic file): table `storage/mpackdb/attachments.db` { event, ticket, project, user, n, name, type, image,
  23. size, file, created, deleted }; bytes in `storage/attachments/<32 hex>` (beside mpackdb, so deploy backups of `storage/` include
  24. them; `TICKETS_ATTACHMENTS` moves it). Limits: 10 files, 10 MiB each, 25 MiB per comment, no empty file. Type FROM THE CONTENT
  25. (PNG, JPEG, GIF, WebP by magic bytes; PDF; .txt/.md/.log/.csv/.json → text/plain; else octet-stream); a file that claims a picture
  26. (name or type png/jpeg/gif/webp) but is not one → refused. Who may fetch: members of the project (session, user token, or the
  27. project's app key); a deleted comment drops its files (bytes removed, rows marked, 404); an edit keeps them.
  28. - `lib/multipart.hl` (new helper): multipart/form-data parsed from `req.bytes` (boundary found in `Bytes.hex()` with native
  29. indexOf at even offsets; headers / text checked for UTF-8 before decoding).
  30. - `lib/tickets.hl addComment(ticketId, user, text, files)` (files optional; with files the text may be empty);
  31. `lib/comments.hl deleteComment` → `dropFiles`; `lib/events.hl` a comment row carries `attachments` only when it has some;
  32. `lib/mdview.hl` lists "Attachments:" lines (absolute URLs); `lib/api-helpers.hl commentFormOf` + `fileReply`;
  33. `lib/api.hl` POST …/comments takes multipart (JSON unchanged), `GET /api/attachments/:id`; `project.hl` route + `uploadMax = 10485760`.
  34. - `components/ticket.hl`: the "Respond" block has `attach = "true" maxFileSize = 10485760`; `posted(text, files)` → face
  35. `commentWithFiles(ticketId, text, files, session)` when there are files (else `commentOn` as before; a null answer = an upload the
  36. framework refused → message, files kept); `entriesOf(list, uid, see)` gives the block `files` — without `url` for non-members.
  37. - `tests/browser.mjs` "m017:" section (after m016, ~25 checks) — written, **never run to its end** (the run was stopped at check 144).
  38. It compiles and serves (dev server on an empty store: 200).
  39. ## Gates
  40. | gate | old (a7a1380 + same bin) | new |
  41. |---|---|---|
  42. | tickets `tests/browser.mjs` | 351 / 0 | not finished (stopped at 144 ok / 0 failed, before m016/m017) |
  43. | tickets `tests/events.mjs` | 52 / 0 | not run |
  44. | components `tests/browser.mjs` | 343 / 0 | 356 / 1 (see above) |
  45. Real data (copy of the newest backup, az5b2 session): **not done**. Screenshots: none of the new pages yet; I cannot view PNGs in this
  46. session anyway (no image viewer) — layout is checked through the DOM.
  47. ## Decisions (to confirm)
  48. - API: **multipart/form-data** (not JSON base64): `curl -H "Authorization: Bearer $TOKEN" -F 'text=390 px review' -F [email protected]
  49. -F [email protected] https://tickets.worldapi.org/api/projects/<slug>/tickets/<n>/comments` → 201, `event.attachments` =
  50. `[{ id, name, type, size, image, url: "/api/attachments/<id>" }]`; fetch with the same token: `curl -H "Authorization: Bearer $TOKEN"
  51. -o shot.png https://tickets.worldapi.org/api/attachments/<id>`. 413 over a limit, 400 a fake picture / unknown field, 401 no token.
  52. - Attachments are **members only** although reading a ticket is public (the brief's "a non-member cannot fetch"); non-members see name + size.
  53. - Delete drops the bytes (unlike texts, which stay); edit keeps the files and cannot add or remove any.
  54. - Served with nosniff, `Content-Security-Policy: default-src 'none'; img-src 'self'; style-src 'unsafe-inline'; sandbox`, pictures inline,
  55. everything else `attachment`; `Cache-Control: private, max-age=86400`. Thumbnails are the full pictures scaled by CSS (no resizer).
  56. - What changes for API users: only comments with files carry `attachments`; JSON posts, the event stream and every other row unchanged.
  57. ## Hybriel gaps
  58. None found so far (Bytes, req.bytes, writeFile/readBytes, Response with Bytes, files through an emit from a block's lambda, a composed
  59. component with a composed MdEditor in its slot inside another block — all worked). `from` is reserved (known, hybriel#22).
  60. ## Next steps (for the next worker)
  61. 1. components w27c: fix / explain the one gate check (type with the same key helper as the comments section, or `page.type`), run the
  62. gate (old 343/0), update `components/comments/README.md` (attach, onPost(text, files), files per comment, texts) and
  63. `components/md-editor/README.md` (files = "off"), commit, re-sync tickets (`COMPONENTS_REPO=<w27c worktree> tools/sync-components.sh <commit>`).
  64. 2. tickets w27: run `tests/browser.mjs` (ports e.g. 8713–8721) and `tests/events.mjs`; fix what m017 finds; show m017 fails on the old
  65. code (old tree in `/media/STORAGE/claude-scratch/atlas/I2/old-tickets`); look at the screenshots `gate-{phone,desktop}-attachments.png`.
  66. 3. README "Comments" / "API" (+ the curl example above), the gate count; then real data on a copy of the newest backup (old tickets unchanged:
  67. JSON byte-identical except new attachments; 390 + 1280 screenshots), LOG/STATUS final, report final.
  68. Scratch: old trees `old-tickets/`, `old-components/`, logs `logs/`, probes `probe/` under /media/STORAGE/claude-scratch/atlas/I2/.
  69. Nothing of mine runs or listens (checked with ss).

Branches

Latest commits

  • 0814ce6bTickets conductor: brief 025 tickets#36 style formmre
  • 1b6916c4Tickets conductor: Atlas handover tickets#36mre
  • aab95226Tickets conductor: worldapi-conductor paths, deploy blocker = read-only diskmre
  • 6372b06dTickets conductor: worker port slotmre
  • 836af31cTickets conductor: token pathsmre
  • b03f11b6Tickets conductor: CONDUCTOR.md (project part), short STATUS.md, old STATUS to archive/2026-10-31mre
  • a4123831tickets#42: the /connect and /login/callback error pages are app pages: the function routes redirect to /connect/failed/<code> and /login/failed/<code> (components/problem.hl, sentences in lib/problems.hl), htmlPage and its hand-written stylesheet are gone; gate tests/error-pages.mjsmre
  • cefc7b4atickets: a startup error prints its message before exit 1 (hybriel#247)mre
  • 99bd6570tickets: lib/migrate.hl writes no table of another topic any more: projects.hl rewriteSlug / addProjectNamed / hasMembers, tickets.hl moveToProject / ticketRecords / ticketRecordsOf, events.hl renameStates / eventRecords / eventRecordsOf; the migration calls them (tickets#47)mre
  • b57161e3tickets: the markup names its own rules (Style.pMessage, Style.olTickets, ...) instead of hand-written class strings that copy a stylesheet rule; the shared bodies sit in lib/looks.hl (tickets#38)mre
  • f767b24dtickets: 111 needless let became plain declarations (3 in ticket.hl, ticket_list.hl, comments.hl and 108 never-reassigned, not captured loop-body ones); the 212 really reassigned lets stay (tickets#44)mre
  • 16c0d3b5tickets: the modal window is phone first: the full-screen sheet is the base rule, the centred window sits in the min-width 60rem block (tickets#39)mre
  • 090ee809tickets: every component's styles in its own nested Style {} block; styles.hl keeps only the theme inherit, the accent and the site-wide rules (tickets#36)mre
  • d395763ftickets: ident-access gate ports 8769/8768 (8797 is taken on loreana)mre
  • afb9a403tickets: an ident access key (Authorization: Bearer idt_…) works in the API (ident#27 app side): lib/ident-access.hl copied from components, read keys GET only, ident down 503; gate tests/ident-access-tickets.mjsmre
  • 48c1ba79tickets: md-paste-files gate with the file manager casesmre
  • f04afc43tickets: MdEditor from components 59704ce (a file manager copy still attaches, pipe rows, tickets#49)mre
  • 06599fa0tickets: MdEditor from components b0f1ec2 (a clipboard with text always pastes the text, tickets#49); real Ctrl+V gatemre
  • 2e1b116ftickets: re-vendor Hybriel master acaceaf3 (framework ec8d6c1d): plugins/web patch queue while a page is built, anonymous session cookies refresh; gate waits for the comment editors to draw (W174) and clicks the form editor when it stands still; security gate: main's code runs on its own binary, lazy-session cookie checksmre
  • 361bc0fetickets: re-vendor Hybriel 7a684920 (WIP, not deployed); on Error exits 1 at startup; migrate passes its log by reference; gate checks follow lazy sessions and the 413 refusalmre