[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7C4DRW0VQ1Z0PYCXETWHM1H":3,"skill-same:01M7C4DRW0VQ1Z0PYCXETWHM1H":43},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":13,"repositoryHtmlUrl":26,"repositoryHomepageUrl":26,"ownerHtmlUrl":27,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":28,"install":29,"resources":42},"01M7C4DRW0VQ1Z0PYCXETWHM1H","mobile-web-camera-upload",null,"Build mobile-web photo upload flows (camera + gallery, multi-file, client-side compression) that work reliably across Android\u002FiOS browsers. Covers the `capture` attribute trap, multi-file form handling, auto-reopen camera failures, and the one-tap-per-photo fallback. Use whenever a web app needs phone-camera photo input for inventory, listings, field data, or forms.","SillyHippy\u002Fzo-skills","SillyHippy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F159052837?v=4","01M7C43A8PDYMCDPTNFYF2RSC1","01M7C43A9CBS76QPH4PPTKXX54",0,"MIT","https:\u002F\u002Fgithub.com\u002FSillyHippy\u002Fzo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmobile-web-camera-upload\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: mobile-web-camera-upload\ndescription: Build mobile-web photo upload flows (camera + gallery, multi-file, client-side compression) that work reliably across Android\u002FiOS browsers. Covers the `capture` attribute trap, multi-file form handling, auto-reopen camera failures, and the one-tap-per-photo fallback. Use whenever a web app needs phone-camera photo input for inventory, listings, field data, or forms.\n---\n\n# Mobile Web Camera Upload\n\nClass of work: any web app where a phone user adds photos via camera or gallery (inventory, listings, field reports, receipts, ID capture). The mobile browser behaviors here are **durable platform facts**, not session-specific quirks.\n\n## The `capture` attribute trap (most important)\n\n```html\n\u003C!-- FORCES camera-only on most mobile browsers — blocks gallery -->\n\u003Cinput type=\"file\" accept=\"image\u002F*\" capture=\"environment\" \u002F>\n\n\u003C!-- ALLOWS both camera AND gallery — phone shows the standard chooser -->\n\u003Cinput type=\"file\" accept=\"image\u002F*\" \u002F>\n```\n\n`capture=\"environment\"` tells the browser \"open the rear camera immediately and skip the gallery picker.\" This is a **one-way door** on Android Chrome and Samsung Internet: the user cannot reach their gallery from that input. Verified 2026-07-30 on the booth app — girlfriend could only take live photos, never pick existing\u002FCanva-cleaned images.\n\n### When to use each\n\n| Goal | Markup |\n|---|---|\n| User is shooting items live at a booth\u002Fsite (fast snap loop) | `capture=\"environment\"` — but see auto-reopen caveat below |\n| User may pick from gallery OR shoot live | **omit `capture`** — standard chooser (Camera \u002F Gallery \u002F Files \u002F Drive) |\n| Both paths needed | Two separate buttons: one input with `capture`, one without. Don't try to make one input do both. |\n\n**Default recommendation:** omit `capture`. The standard chooser is what Facebook Marketplace, eBay, Poshmark, and every mature listing app use. Only add `capture` when the user explicitly wants a fast live-snap loop AND you've tested the auto-reopen behavior on their actual phone.\n\n## Multi-file upload: `form.get` vs `form.getAll`\n\n```ts\n\u002F\u002F BUG — only returns the FIRST file even if input has multiple\nconst photo = form.get('photo')\nif (photo instanceof File && photo.size > 0) { ... }\n\n\u002F\u002F CORRECT — returns ALL files from \u003Cinput name=\"photos\" multiple>\nconst photos = form.getAll('photos').filter(\n  (f): f is File => f instanceof File && f.size > 0\n)\n```\n\n`FormData.get(name)` returns the **first** value for a repeated field. For `\u003Cinput multiple>` you MUST use `getAll(name)`. This bug silently saves only the first photo and is invisible in manual testing if you only ever pick one photo. Verified 2026-07-30 — booth app saved 1 of 3 uploaded photos until this was fixed.\n\nAlso: the input's `name` must match what `getAll` reads. If the input is `name=\"photos\"` and the route reads `getAll('photo')`, you get an empty array with no error.\n\n## Auto-reopen camera is unreliable on Android OEMs\n\nThe \"rapid capture\" pattern — open camera, on `change` save the shot, then `setTimeout(() => input.click(), 50)` to reopen — works on **most** Android browsers but **fails on some OEM camera apps** that don't return focus to the page cleanly after a shot. Symptom: first photo saves, then the camera never reopens; the UI gets stuck on \"Compressing…\".\n\n```js\n\u002F\u002F UNRELIABLE — fails on some Samsung\u002FXiaomi\u002FPixel OEM camera apps\ninput.addEventListener('change', async () => {\n  await handleShot(input.files[0])\n  input.value = ''\n  setTimeout(() => input.click(), 50)  \u002F\u002F may never fire\n})\n```\n\n### Reliable fallback: one tap per photo\n\n```js\n\u002F\u002F RELIABLE — each tap is a fresh user-initiated camera open\nlet taken = 0\nconst MAX = 5\nbtn.addEventListener('click', () => {\n  if (taken >= MAX) return\n  input.click()  \u002F\u002F user tapped → camera opens → snap → closes\n})\ninput.addEventListener('change', async () => {\n  const f = input.files?.[0]\n  if (!f) return\n  input.value = ''  \u002F\u002F reset so same file can be re-picked\n  await handleShot(f)\n  taken++\n  btn.textContent = `📸 Take photo ${taken + 1} of ${MAX} (${taken} done)`\n  if (taken >= MAX) { btn.disabled = true; btn.textContent = `✓ ${MAX} photos taken (max)` }\n})\n```\n\nOne tap = one photo. The button relabels itself so the user always knows where they are. No auto-reopen, no Stop button, no stuck state. This is the pattern to ship by default; only attempt auto-reopen if the user explicitly wants it AND you've tested on their phone.\n\n## Client-side compression (do it, always)\n\nPhone cameras produce 4–12 MP JPEGs (3–8 MB). Uploading raw wastes bandwidth, disk, and R2 quota. Compress in the browser before upload:\n\n```js\nasync function compress(file, maxDim = 1200, quality = 0.8) {\n  const img = await loadImg(file)              \u002F\u002F new Image + URL.createObjectURL\n  let { width, height } = img\n  if (width > height && width > maxDim) { height = Math.round(height * maxDim \u002F width); width = maxDim }\n  else if (height > maxDim) { width = Math.round(width * maxDim \u002F height); height = maxDim }\n  const canvas = document.createElement('canvas')\n  canvas.width = width; canvas.height = height\n  canvas.getContext('2d').drawImage(img, 0, 0, width, height)\n  const blob = await new Promise(r => canvas.toBlob(r, 'image\u002Fjpeg', quality))\n  return new File([blob], file.name.replace(\u002F\\.[^.]+$\u002F, '.jpg'), { type: 'image\u002Fjpeg' })\n}\n```\n\n- max **1200px** longest side is plenty for web gallery thumbnails and detail pages\n- JPEG **q0.8** keeps files ~100–400 KB (from 3–8 MB originals)\n- Always **fall back to the original file** if compression throws (broken EXIF, rare format)\n- Replace the input's FileList via `DataTransfer` so the form submits the compressed blob, not the original\n\n```js\nconst dt = new DataTransfer()\ndt.items.add(compressedFile)\ninput.files = dt.files\n```\n\n## Pending-photo UI (don't lose the user's shots)\n\nShow a live thumbnail grid of queued photos with a ✕ on each to remove. Keep the queue in a JS array (`compressedFiles`), not just in the input's FileList — the FileList is fragile and re-syncing it on every remove is error-prone.\n\n```js\nfunction syncInput() {\n  const dt = new DataTransfer()\n  compressedFiles.forEach(f => dt.items.add(f))\n  input.files = dt.files\n  pending.innerHTML = compressedFiles.map((f, i) =>\n    '\u003Cdiv class=\"ph-card\">\u003Cimg src=\"' + URL.createObjectURL(f) + '\" \u002F>\u003Cbutton data-i=\"' + i + '\">✕\u003C\u002Fbutton>\u003C\u002Fdiv>'\n  ).join('')\n}\n```\n\n## Double-submit guard + the disabled-button-drops-intent trap\n\nPhone users double-tap save buttons. Guard against it — but the obvious guard introduces a **silent, nasty bug**.\n\n### The bug\n\n```js\n\u002F\u002F GUARD — disables buttons on submit\nform.addEventListener('submit', (e) => {\n  form.querySelectorAll('button[type=\"submit\"]').forEach(b => b.disabled = true)\n})\n```\n\n```html\n\u003C!-- Two submit buttons distinguished by name\u002Fvalue -->\n\u003Cbutton type=\"submit\" name=\"intent\" value=\"next\">Save &amp; add next\u003C\u002Fbutton>\n\u003Cbutton type=\"submit\" name=\"intent\" value=\"done\">Save &amp; done\u003C\u002Fbutton>\n```\n\n**A disabled submit button does NOT include its `name`\u002F`value` in the submitted form data.** So once the guard disables the buttons, `form.get('intent')` returns `null`, the route defaults to `'done'`, and \"Save & add next\" silently becomes \"Save & done\" → user lands on the dashboard instead of a fresh add form. Verified 2026-07-30 — booth \"Save & add next\" broke the moment double-submit protection was added; user saw \"Save and next goes to dashboard\" and had to escalate.\n\n### Workflow rule: never silently remove \"Save & add next\"\n\nThe two-button save pattern is **the whole point** of a batch-photographing workflow (girlfriend snapping 30 booth items in a row). When \"simplifying\" the UI, do NOT collapse the two buttons into one \"Save → dashboard\" button — that destroys the loop and forces a tap back to Add between every item. Verified 2026-07-30: I removed \"Save & add next\" during a \"simplify the buttons\" pass, the user immediately asked \"What happened to save & next button?\", and restoring it was the next task. The batch loop is a load-bearing feature, not UI clutter.\n\nThis bug is invisible in single-button forms (only one intent) and only surfaces when a second button's value matters — exactly the camera-upload batch loop where \"Save & add next\" is the whole point.\n\n### The fix: hidden intent field + `data-intent`\n\n```html\n\u003Cinput type=\"hidden\" name=\"intent\" id=\"intent-field\" value=\"done\" \u002F>\n\u003Cbutton type=\"submit\" data-intent=\"next\">Save &amp; add next\u003C\u002Fbutton>\n\u003Cbutton type=\"submit\" data-intent=\"done\">Save &amp; done\u003C\u002Fbutton>\n```\n\n```js\n\u002F\u002F Set the hidden field from data-intent BEFORE the disable fires\ndocument.querySelectorAll('button[data-intent]').forEach(btn => {\n  btn.addEventListener('click', () => {\n    document.getElementById('intent-field').value = btn.dataset.intent\n  })\n})\n\u002F\u002F Now the disable-on-submit guard is safe — the intent is already in a hidden input\nform.addEventListener('submit', (e) => {\n  form.querySelectorAll('button[type=\"submit\"]').forEach(b => b.disabled = true)\n})\n```\n\nThe hidden field is always submitted (it's never disabled), so the server reliably reads `form.get('intent')`. The buttons carry only `data-intent`, never `name`\u002F`value` that could be dropped.\n\n### Rule\n\n**Never rely on a submit button's own `name`\u002F`value` reaching the server if any double-submit guard disables buttons.** Move the distinguishing value into a hidden input set on click. This applies to ANY multi-intent form (Save & add next \u002F Save & done \u002F Save & publish \u002F etc.), not just camera flows.\n\n## Nested template-literal pitfall (Bun\u002FTS)\n\nWhen building inline `\u003Cscript>` strings inside a TS template literal, **nested backtick template literals inside the script body break the parser**:\n\n```ts\n\u002F\u002F BROKEN — the inner `${url}` is parsed as TS interpolation, not as JS\nreturn `\u003Cscript>\n  pending.innerHTML = items.map((f, i) => \\`\u003Cimg src=\"${f.url}\" \u002F>\\`).join('')\n\u003C\u002Fscript>`\n```\n\nBun errors with `Expected \";\" but found \"class\"` at the inner `\u003Cimg`. Fix: use **string concatenation** inside the embedded JS, not template literals:\n\n```ts\nreturn `\u003Cscript>\n  pending.innerHTML = items.map((f, i) => '\u003Cimg src=\"'+f.url+'\" \u002F>').join('')\n\u003C\u002Fscript>`\n```\n\nVerified 2026-07-30 — booth `ui.ts` line 642 crashed the whole service on boot until this was fixed.\n\n## Storage: photos go to R2 \u002F disk, never git\n\n- **R2** (Cloudflare object storage) or local disk on Zo — never commit inventory photos to git.\n- GitHub is fine for site\u002Fcode assets in a static site, but a **live inventory upload pipeline** (constant add\u002Fdelete) bloats clones, breaks deploys, and hits LFS limits.\n- Booth scale (~300–1000 photos @ 100–400 KB after compression) is trivial for R2 free tier (~10 GB headroom).\n\n## Cloudflare deployment note (not static Pages)\n\nA camera-upload inventory app is **not static HTML** — it needs a server (admin auth, write API, image upload endpoint). On Cloudflare free tier this means **Workers + D1 (data) + R2 (photos)**, not plain Pages. Pages Functions (Workers under the hood) also work. Plain static Pages cannot host this class of app.\n\n## End-to-end verification checklist\n\nBefore declaring a camera-upload flow \"done\", verify on a real phone (or curl-driven E2E):\n\n1. Login → cookie persists across restarts\n2. Add item with **multiple** photos → all photos save (check DB row count, not just UI)\n3. Public item page shows a **swipe gallery** with all photos\n4. **Multi-intent save:** tap \"Save & add next\" → confirm the route lands on a fresh add form (not the dashboard). Check the redirect `Location` header, not just that it saved — the disabled-button bug makes \"next\" silently become \"done\".\n5. Mark sold → item returns 404 on public, gone from gallery\n6. Delete → item + photos removed\n7. Restart service → items created this session still present (WAL checkpoint after writes)\n\nThe `form.get` vs `form.getAll` bug specifically passes step 2's UI check and only fails the DB count check — so always check the DB, not the browser. The disabled-button-drops-intent bug passes step 4's \"it saved\" check and only fails the redirect-target check — so always assert the `Location` header.\n","# Mobile Web Camera Upload\n\nClass of work: any web app where a phone user adds photos via camera or gallery (inventory, listings, field reports, receipts, ID capture). The mobile browser behaviors here are **durable platform facts**, not session-specific quirks.\n\n## The `capture` attribute trap (most important)\n\n```html\n\u003C!-- FORCES camera-only on most mobile browsers — blocks gallery -->\n\u003Cinput type=\"file\" accept=\"image\u002F*\" capture=\"environment\" \u002F>\n\n\u003C!-- ALLOWS both camera AND gallery — phone shows the standard chooser -->\n\u003Cinput type=\"file\" accept=\"image\u002F*\" \u002F>\n```\n\n`capture=\"environment\"` tells the browser \"open the rear camera immediately and skip the gallery picker.\" This is a **one-way door** on Android Chrome and Samsung Internet: the user cannot reach their gallery from that input. Verified 2026-07-30 on the booth app — girlfriend could only take live photos, never pick existing\u002FCanva-cleaned images.\n\n### When to use each\n\n| Goal | Markup |\n|---|---|\n| User is shooting items live at a booth\u002Fsite (fast snap loop) | `capture=\"environment\"` — but see auto-reopen caveat below |\n| User may pick from gallery OR shoot live | **omit `capture`** — standard chooser (Camera \u002F Gallery \u002F Files \u002F Drive) |\n| Both paths needed | Two separate buttons: one input with `capture`, one without. Don't try to make one input do both. |\n\n**Default recommendation:** omit `capture`. The standard chooser is what Facebook Marketplace, eBay, Poshmark, and every mature listing app use. Only add `capture` when the user explicitly wants a fast live-snap loop AND you've tested the auto-reopen behavior on their actual phone.\n\n## Multi-file upload: `form.get` vs `form.getAll`\n\n```ts\n\u002F\u002F BUG — only returns the FIRST file even if input has multiple\nconst photo = form.get('photo')\nif (photo instanceof File && photo.size > 0) { ... }\n\n\u002F\u002F CORRECT — returns ALL files from \u003Cinput name=\"photos\" multiple>\nconst photos = form.getAll('photos').filter(\n  (f): f is File => f instanceof File && f.size > 0\n)\n```\n\n`FormData.get(name)` returns the **first** value for a repeated field. For `\u003Cinput multiple>` you MUST use `getAll(name)`. This bug silently saves only the first photo and is invisible in manual testing if you only ever pick one photo. Verified 2026-07-30 — booth app saved 1 of 3 uploaded photos until this was fixed.\n\nAlso: the input's `name` must match what `getAll` reads. If the input is `name=\"photos\"` and the route reads `getAll('photo')`, you get an empty array with no error.\n\n## Auto-reopen camera is unreliable on Android OEMs\n\nThe \"rapid capture\" pattern — open camera, on `change` save the shot, then `setTimeout(() => input.click(), 50)` to reopen — works on **most** Android browsers but **fails on some OEM camera apps** that don't return focus to the page cleanly after a shot. Symptom: first photo saves, then the camera never reopens; the UI gets stuck on \"Compressing…\".\n\n```js\n\u002F\u002F UNRELIABLE — fails on some Samsung\u002FXiaomi\u002FPixel OEM camera apps\ninput.addEventListener('change', async () => {\n  await handleShot(input.files[0])\n  input.value = ''\n  setTimeout(() => input.click(), 50)  \u002F\u002F may never fire\n})\n```\n\n### Reliable fallback: one tap per photo\n\n```js\n\u002F\u002F RELIABLE — each tap is a fresh user-initiated camera open\nlet taken = 0\nconst MAX = 5\nbtn.addEventListener('click', () => {\n  if (taken >= MAX) return\n  input.click()  \u002F\u002F user tapped → camera opens → snap → closes\n})\ninput.addEventListener('change', async () => {\n  const f = input.files?.[0]\n  if (!f) return\n  input.value = ''  \u002F\u002F reset so same file can be re-picked\n  await handleShot(f)\n  taken++\n  btn.textContent = `📸 Take photo ${taken + 1} of ${MAX} (${taken} done)`\n  if (taken >= MAX) { btn.disabled = true; btn.textContent = `✓ ${MAX} photos taken (max)` }\n})\n```\n\nOne tap = one photo. The button relabels itself so the user always knows where they are. No auto-reopen, no Stop button, no stuck state. This is the pattern to ship by default; only attempt auto-reopen if the user explicitly wants it AND you've tested on their phone.\n\n## Client-side compression (do it, always)\n\nPhone cameras produce 4–12 MP JPEGs (3–8 MB). Uploading raw wastes bandwidth, disk, and R2 quota. Compress in the browser before upload:\n\n```js\nasync function compress(file, maxDim = 1200, quality = 0.8) {\n  const img = await loadImg(file)              \u002F\u002F new Image + URL.createObjectURL\n  let { width, height } = img\n  if (width > height && width > maxDim) { height = Math.round(height * maxDim \u002F width); width = maxDim }\n  else if (height > maxDim) { width = Math.round(width * maxDim \u002F height); height = maxDim }\n  const canvas = document.createElement('canvas')\n  canvas.width = width; canvas.height = height\n  canvas.getContext('2d').drawImage(img, 0, 0, width, height)\n  const blob = await new Promise(r => canvas.toBlob(r, 'image\u002Fjpeg', quality))\n  return new File([blob], file.name.replace(\u002F\\.[^.]+$\u002F, '.jpg'), { type: 'image\u002Fjpeg' })\n}\n```\n\n- max **1200px** longest side is plenty for web gallery thumbnails and detail pages\n- JPEG **q0.8** keeps files ~100–400 KB (from 3–8 MB originals)\n- Always **fall back to the original file** if compression throws (broken EXIF, rare format)\n- Replace the input's FileList via `DataTransfer` so the form submits the compressed blob, not the original\n\n```js\nconst dt = new DataTransfer()\ndt.items.add(compressedFile)\ninput.files = dt.files\n```\n\n## Pending-photo UI (don't lose the user's shots)\n\nShow a live thumbnail grid of queued photos with a ✕ on each to remove. Keep the queue in a JS array (`compressedFiles`), not just in the input's FileList — the FileList is fragile and re-syncing it on every remove is error-prone.\n\n```js\nfunction syncInput() {\n  const dt = new DataTransfer()\n  compressedFiles.forEach(f => dt.items.add(f))\n  input.files = dt.files\n  pending.innerHTML = compressedFiles.map((f, i) =>\n    '\u003Cdiv class=\"ph-card\">\u003Cimg src=\"' + URL.createObjectURL(f) + '\" \u002F>\u003Cbutton data-i=\"' + i + '\">✕\u003C\u002Fbutton>\u003C\u002Fdiv>'\n  ).join('')\n}\n```\n\n## Double-submit guard + the disabled-button-drops-intent trap\n\nPhone users double-tap save buttons. Guard against it — but the obvious guard introduces a **silent, nasty bug**.\n\n### The bug\n\n```js\n\u002F\u002F GUARD — disables buttons on submit\nform.addEventListener('submit', (e) => {\n  form.querySelectorAll('button[type=\"submit\"]').forEach(b => b.disabled = true)\n})\n```\n\n```html\n\u003C!-- Two submit buttons distinguished by name\u002Fvalue -->\n\u003Cbutton type=\"submit\" name=\"intent\" value=\"next\">Save &amp; add next\u003C\u002Fbutton>\n\u003Cbutton type=\"submit\" name=\"intent\" value=\"done\">Save &amp; done\u003C\u002Fbutton>\n```\n\n**A disabled submit button does NOT include its `name`\u002F`value` in the submitted form data.** So once the guard disables the buttons, `form.get('intent')` returns `null`, the route defaults to `'done'`, and \"Save & add next\" silently becomes \"Save & done\" → user lands on the dashboard instead of a fresh add form. Verified 2026-07-30 — booth \"Save & add next\" broke the moment double-submit protection was added; user saw \"Save and next goes to dashboard\" and had to escalate.\n\n### Workflow rule: never silently remove \"Save & add next\"\n\nThe two-button save pattern is **the whole point** of a batch-photographing workflow (girlfriend snapping 30 booth items in a row). When \"simplifying\" the UI, do NOT collapse the two buttons into one \"Save → dashboard\" button — that destroys the loop and forces a tap back to Add between every item. Verified 2026-07-30: I removed \"Save & add next\" during a \"simplify the buttons\" pass, the user immediately asked \"What happened to save & next button?\", and restoring it was the next task. The batch loop is a load-bearing feature, not UI clutter.\n\nThis bug is invisible in single-button forms (only one intent) and only surfaces when a second button's value matters — exactly the camera-upload batch loop where \"Save & add next\" is the whole point.\n\n### The fix: hidden intent field + `data-intent`\n\n```html\n\u003Cinput type=\"hidden\" name=\"intent\" id=\"intent-field\" value=\"done\" \u002F>\n\u003Cbutton type=\"submit\" data-intent=\"next\">Save &amp; add next\u003C\u002Fbutton>\n\u003Cbutton type=\"submit\" data-intent=\"done\">Save &amp; done\u003C\u002Fbutton>\n```\n\n```js\n\u002F\u002F Set the hidden field from data-intent BEFORE the disable fires\ndocument.querySelectorAll('button[data-intent]').forEach(btn => {\n  btn.addEventListener('click', () => {\n    document.getElementById('intent-field').value = btn.dataset.intent\n  })\n})\n\u002F\u002F Now the disable-on-submit guard is safe — the intent is already in a hidden input\nform.addEventListener('submit', (e) => {\n  form.querySelectorAll('button[type=\"submit\"]').forEach(b => b.disabled = true)\n})\n```\n\nThe hidden field is always submitted (it's never disabled), so the server reliably reads `form.get('intent')`. The buttons carry only `data-intent`, never `name`\u002F`value` that could be dropped.\n\n### Rule\n\n**Never rely on a submit button's own `name`\u002F`value` reaching the server if any double-submit guard disables buttons.** Move the distinguishing value into a hidden input set on click. This applies to ANY multi-intent form (Save & add next \u002F Save & done \u002F Save & publish \u002F etc.), not just camera flows.\n\n## Nested template-literal pitfall (Bun\u002FTS)\n\nWhen building inline `\u003Cscript>` strings inside a TS template literal, **nested backtick template literals inside the script body break the parser**:\n\n```ts\n\u002F\u002F BROKEN — the inner `${url}` is parsed as TS interpolation, not as JS\nreturn `\u003Cscript>\n  pending.innerHTML = items.map((f, i) => \\`\u003Cimg src=\"${f.url}\" \u002F>\\`).join('')\n\u003C\u002Fscript>`\n```\n\nBun errors with `Expected \";\" but found \"class\"` at the inner `\u003Cimg`. Fix: use **string concatenation** inside the embedded JS, not template literals:\n\n```ts\nreturn `\u003Cscript>\n  pending.innerHTML = items.map((f, i) => '\u003Cimg src=\"'+f.url+'\" \u002F>').join('')\n\u003C\u002Fscript>`\n```\n\nVerified 2026-07-30 — booth `ui.ts` line 642 crashed the whole service on boot until this was fixed.\n\n## Storage: photos go to R2 \u002F disk, never git\n\n- **R2** (Cloudflare object storage) or local disk on Zo — never commit inventory photos to git.\n- GitHub is fine for site\u002Fcode assets in a static site, but a **live inventory upload pipeline** (constant add\u002Fdelete) bloats clones, breaks deploys, and hits LFS limits.\n- Booth scale (~300–1000 photos @ 100–400 KB after compression) is trivial for R2 free tier (~10 GB headroom).\n\n## Cloudflare deployment note (not static Pages)\n\nA camera-upload inventory app is **not static HTML** — it needs a server (admin auth, write API, image upload endpoint). On Cloudflare free tier this means **Workers + D1 (data) + R2 (photos)**, not plain Pages. Pages Functions (Workers under the hood) also work. Plain static Pages cannot host this class of app.\n\n## End-to-end verification checklist\n\nBefore declaring a camera-upload flow \"done\", verify on a real phone (or curl-driven E2E):\n\n1. Login → cookie persists across restarts\n2. Add item with **multiple** photos → all photos save (check DB row count, not just UI)\n3. Public item page shows a **swipe gallery** with all photos\n4. **Multi-intent save:** tap \"Save & add next\" → confirm the route lands on a fresh add form (not the dashboard). Check the redirect `Location` header, not just that it saved — the disabled-button bug makes \"next\" silently become \"done\".\n5. Mark sold → item returns 404 on public, gone from gallery\n6. Delete → item + photos removed\n7. Restart service → items created this session still present (WAL checkpoint after writes)\n\nThe `form.get` vs `form.getAll` bug specifically passes step 2's UI check and only fails the DB count check — so always check the DB, not the browser. The disabled-button-drops-intent bug passes step 4's \"it saved\" check and only fails the redirect-target check — so always assert the `Location` header.\n",{"name":5,"description":7},"main","3641543f81ae80504027d6b012e0dadce4e2de40","skills\u002Fmobile-web-camera-upload","https:\u002F\u002Fgithub.com\u002FSillyHippy\u002Fzo-skills","https:\u002F\u002Fgithub.com\u002FSillyHippy","2026-09-18 11:42:22",{"source":8,"skillName":5,"commands":30,"prompt":40,"zipAvailable":41},[31,34,37],{"tool":32,"command":33},"npx","npx skills add SillyHippy\u002Fzo-skills --skill mobile-web-camera-upload",{"tool":35,"command":36},"bunx","bunx skills add SillyHippy\u002Fzo-skills --skill mobile-web-camera-upload",{"tool":38,"command":39},"pnpm","pnpm dlx skills add SillyHippy\u002Fzo-skills --skill mobile-web-camera-upload","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSillyHippy\u002Fzo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmobile-web-camera-upload\u002FSKILL.md",true,[],[44,51,58,65,72,79],{"skillNo":45,"name":46,"nameZh":6,"description":47,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":48,"categories":49,"keywords":50,"publishedAt":18},"01M7C4RK2ZCHPKQT393RVSC6ER","zopack","Export and import zo.space route setups as shareable .zopack.md files. Use when the user wants to package their zo.space routes for sharing, or when they receive a .zopack.md file to deploy. Triggers on \"export my zo.space\", \"create a zopack\", \"import this zopack\", or any mention of .zopack.md files.","https:\u002F\u002Fgithub.com\u002FSillyHippy\u002Fzo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzopack\u002FSKILL.md",[],[],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":18},"01M7C4REH5EJ22X3C1SF88X6KQ","zoho-mail-inbox","Full inbox management for Zoho Mail (info@justlegalsolutions.org) — list unread, mark all as read, delete by sender\u002Fkeyword, search, send from aliases, list folders. Fully self-contained — zero setup needed.","https:\u002F\u002Fgithub.com\u002FSillyHippy\u002Fzo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzoho-mail-inbox\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":18},"01M7C4RAJF1N9R8ZRT25GMHFBF","weekly-meeting-reminder","Get an email every Sunday evening listing your meetings for the coming week.","https:\u002F\u002Fgithub.com\u002FSillyHippy\u002Fzo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzo-weekly-meeting-reminder\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":18},"01M7C4R65Q9T6TPBRFQPWJSW4Z","twitter","Let Zo use your X (Twitter) account","https:\u002F\u002Fgithub.com\u002FSillyHippy\u002Fzo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzo-twitter\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":18},"01M7C4R358YM59EZRM3SW763VK","zo-tools","Internal process tools for Zo and Hermes — local search, document processing, OCR, and embeddings. All services run on localhost, zero HTTP slots consumed.","https:\u002F\u002Fgithub.com\u002FSillyHippy\u002Fzo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzo-tools\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":18},"01M7C4R0J4C3RQWKZ5W5W3CZ3X","ssh-setup","Sets up secure remote access to your Zo Computer so you can connect from anywhere","https:\u002F\u002Fgithub.com\u002FSillyHippy\u002Fzo-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzo-ssh-setup\u002FSKILL.md",[],[]]