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