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
- a6ddccd2re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
- 81e036b7docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
- 5d8d2cf6deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- 58e8c02cmission 024: report, LOG, STATUS, e2e fixmre
- 50778073tests/e2e-route-marker.mjs: first paint marker, comments post/edit redrawmre
- c5203298mission 024: MainMenu marks the page from the route (layouts 0bcc629 main-menu.hl); browser-side marker removed; gate: marker in the server HTMLmre
- b1a4c270re-vendor Hybriel master f9614007: bin/ (git-ignored) and plugins wholemre
- 866397a0mission 023: theme from layouts 76f99f6 (current marker, menu count badge), components from 3794c59 (MdEditor keys); Inbox count as badge, current by address; gates and E2E; reportmre
- 7ed2e5e5deploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the script silently (grep under pipefail), as gitoria/layoutsmre
- bf9064a3mission 022: tickets on the layouts theme (step 1): shell, styles, gates, audit, E2E; reportmre
- f3d61711mission 022 WIP: tickets on the layouts theme (dbe3de7): AppHeader/MainMenu/UserMenu/Sidebar/ContentFirst shell, styles reduced to the app's own, check-theme in the gates, 390 audit + real-Chrome walk scriptmre
- 31cabfccmission 021: E2E script, report, LOG, STATUSmre
- 6aea8683editor look: .empty rule only for p.empty, files off where tickets has no upload, state note one line, events test scrolls the editor into view; synced md-editor (components d702d76+6f27ad3); gate 377/0, events 52/0mre
- dce6ffa6Merge branch 'w28-deflake'mre
- 536092a1tickets (mission 019): de-flake the m016 comment clicks (B: unliked) — calmClick waits until the button stops moving; test only, no app changemre
- 9c5fd42amission 020: attachments E2E proof (lisbeth Chrome, real-data copy), reportmre
- 1206404fREADME attachments, report 018, LOG/STATUSmre
- 3d9e7f3ctests: m017 gate fixes (list count, waits before delete clicks); gate 373/0mre
- dd41d5bcre-sync components 15be2ac; mission 018mre
- 420ad1bbtickets (mission 017 WIP, tickets#27): comment attachments — lib/attachments.hl (storage/attachments, limits, type by content, members-only GET /api/attachments/:id, delete drops, edit keeps), multipart POST …/comments (lib/multipart.hl), Respond block in FilesUpload (blocks verbatim from components w27c 1f8d79d), gate m017 checks written (not yet run); report, LOG, STATUSmre