gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmain5d144817Merge branch 'records-t40' into mainTicketsmain/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

  • 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