Skip to content

feat(share): a QR code on Share for hosts printing posters - #492

Merged
Ardnived merged 11 commits into
mainfrom
feat/qr-poster
Nov 25, 2026
Merged

Ardnived merged 11 commits into
mainfrom
feat/qr-poster

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Share gets a closed "QR code for posters" row: a black-on-white code of the class link plus a print-size PNG.
  • The uqr encoder (0.1.3, no dependencies) is its own 3.7 KiB chunk, fetched only when the row opens.
  • On a phone, Share opens as tall as its content, so the row is in view; opening it lifts the sheet.

Change outline

Components — Share view

The row sits under the share buttons. Its panel is unmounted while closed, so nothing loads until someone opens it.

 ShareView
-  <DrawerBody className="px-gutter py-4">
+  <DrawerBody fitSheet className="px-gutter py-4">
     <ShareContent … />
+    <QrPoster label={event.title} url={url} />
+      Disclosure (new atom, Radix Collapsible)        closed row, chevron, data-vaul-no-drag
+        QrCode key={url}                              mounted only while open
+          loading → Spinner
+          ready   → <svg role="img"> black on white, "Download for printing" → saveBlob(PNG)
+          failed  → role="alert" share.qr_failed

Behaviour — the phone sheet's snap (DrawerStack)

Share now uses the fit snap the event view already had, and nothing else. useFitSnap observes the body and each of its children, so the sheet grows with the row as it opens and settles back as it closes, reaching the near-full snap only when the code needs that height.

-  const openSnap = top?.kind === 'event' ? FIT_SNAP : OPEN_SNAP
+  const fitsContent = top?.kind === 'event' || top?.kind === 'share'
+  const openSnap = fitsContent ? FIT_SNAP : OPEN_SNAP

Behaviour — Disclosure reveals itself

Opening the row scrolls its own scroll container, never the host page, just far enough to show the panel. It re-runs only when the panel grows (spinner → code), so a visitor who scrolled back up stays put.

ResizeObserver(root) while open:
  height grew? → reveal(): nearest canScroll() ancestor inside .sy-atlas → scrollBy(min(below, top))

Files

src/lib/download.ts      new: fileStem (ASCII file stem) + saveBlob, moved out of ics.ts / AddToCalendar
src/lib/share/qr.ts      new: encodeQr (lazy uqr, ECC M, 4-module quiet zone), qrSvgPath, qrPngBlob (~1200 px), qrFileName
src/config/a11y/*.json   share.qr_code, the code's spoken name, machine-translated
src/config/translations.en.json   the four share.qr_* strings from production (see notes)

Preview

  • App, Share view of a London class — preview pending
  • Ladle: Disclosure and QrPoster (incl. the failed state) — preview pending

Contract impact

Host-observable, recorded in CHANGELOG.md: a new script chunk from sahajatlas.com, fetched on open. A CSP that already allows the widget's script-src needs no change, so docs/embedding.md is unchanged. Neither in-tree host (WeMeditateWeb lib/atlas-embed.ts, the WordPress templates) needs a change.

Test results

  • Lean gate --full: ✓ lint, typecheck, 194 files / 2481 tests passed, build, size
  • Bundle: standalone 324.3 KiB of 336 KiB; uqr is not in the eager graph
  • New specs: qr.test.ts (quiet zone, finder, ECC M → version 5, PNG ≥ 1000 px, file names), Disclosure.test.tsx, QrPoster.test.tsx
  • After the review fixes: lean gate ✓ (lint, typecheck, 194 files / 2481 tests), browser lane ✓ (10 scenarios). Build and size left to CI.

Manual verification

  1. On a phone (390×844), open a class → Share. The "QR code for posters" row is visible without dragging.
  2. Open it. The sheet rises, the code appears, and "Download for printing" scrolls into view. Scan the code: it opens the same link as Copy link.
  3. Download: <class-title>-qr.png, about 1170 px square.
  4. Dark theme: the code stays black on white. Desktop: the side panel and settings cog stay put.

Notes for reviewer

  • Strings are copied, not synced, and the earlier reason given here was wrong. sync:translations never requests a compact tab — WIDGET_TABS and WIDGET_TRANSLATION_TABS list the same nine without it. The drift runs the other way: the snapshot carries compact.open, which CompactEmbedView.tsx:83 and :87 render and SahajCloud#1268 dropped upstream. So the bare command exits 1 on that drift, and a --write would rewrite the snapshot from the nine requested tabs and delete compact with it. The four keys shipped in SahajCloud#1276 and are copied verbatim from production; a sync reproduces them only once compact is settled (feat(widget): open every embed inline; expand the map over the page #466).
  • A second new dependency. @radix-ui/react-collapsible backs the new Disclosure atom, by choice over a hand-rolled row. That breaks the ticket's "uqr is the only new dependency" criterion.
  • The ticket's "Blocked by SahajCloud#783" is stale: shared links already use wemeditate.com.
  • /simplify and /code-review high ran; /security-review ran (package.json, lockfile) with no findings.
Detail

Review findings fixed: QrCode keyed on the link, so a link that changes while the row is open never shows or downloads the old code. Reveal only on growth. Disclosure reuses the Drawer's canScroll. DESIGN_SYSTEM.md lists both new components.

Dismissed:

  • Download has no error path when toBlob yields null. It yields null only for a zero-size or over-limit canvas; this one is ~1170 px with a 2d context it creates itself.
  • Reopen may not retry a failed import('uqr'). Verified in Chromium: blocking the chunk once, then closing and reopening, refetched it and drew the code. Safari and Firefox not checked.
  • Import order. Lint passes with the repo's sort rule.

Addressed from the adversarial review: the expand chain is gone (useFitSnap already lifts the fitted sheet, and at the better height), PNG_TARGET_PX is folded into qrPngScale, and the translations note above is corrected. PNG stays over uqr's renderSVG — see the review thread on qr.ts. Closing the row now also brings the sheet back down, which expand had prevented.

Measured on the dev server: 0 uqr requests before opening, exactly 1 after. The on-screen code matches an independent encode of the Copy link value. Download bottom after open: 813/844 (390×844), 651/667 (375×667), 767/800 (desktop); host scrollY stays 0.

🤖 Generated with Claude Code

Ardnived and others added 5 commits November 25, 2026 15:27
UK hosts asked twice for a QR code for their posters. Share gets a closed
"QR code for posters" row under the share buttons that opens a black-on-white
code of the class link, one line on how to use it, and a print-size PNG
download. The encoder (uqr 0.1.3, no dependencies) is its own chunk, fetched
only when the row opens.

- Disclosure atom on Radix Collapsible, for this row and the closed rows after it.
- saveBlob and the ASCII file stem move to lib/download, shared with the
  calendar file.
- On a phone, Share opens as tall as its content, like a class, so the row is
  in view; opening the row lifts the sheet to near-full. The desktop side
  panel and its settings cog stay put.
- The code's spoken name is a repo a11y string, machine-translated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
sync:translations fails on main until #466 (it still requests the dropped compact tab), so these four keys are copied from production's sy-atlas-translations verbatim.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Disclosure reuses the Drawer's canScroll rather than a second copy of it.
- DrawerControl.expand is required, a no-op outside DrawerStack.
- QrCode takes only label and url.
- QrCode is keyed on the link, so a link that changes while the row is open never shows or downloads the old code.
- An open Disclosure reveals itself only when it grows, so a visitor who scrolled back up is not pulled down by a resize.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sydevs-dispatcher

sydevs-dispatcher Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running
conflict held since 23:31Z, waiting for the base to settle

recent dispatches
  • 22:53Z address-review · attempt 1 · session · done
  • 22:53Z address-review · attempt 1 · session
  • 22:40Z review-pr · attempt 1 · session · done
  • 22:40Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 25, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The feature is the right size and the lib layer is clean, but the row costs more than the code it shows — two dependencies and three mechanisms (a Disclosure atom with its own scroll hunting, an expand verb, a snap rule) to keep a 3.7 KiB encoder behind a closed row inside an already-lazy view. One is redundant: useFitSnap grows the fitted sheet as the row opens, so expand only overshoots. With it gone, ask whether the closed row still earns the atom and the Radix dependency, or whether the code can just render in the Share body.

No ticket is linked here, so I judged the diff against its own body — which leaves its "ticket criteria" and "Blocked by" notes unverifiable. The contract holds: the four share.qr_* strings match SahajCloud's translationsSchema.json verbatim, and embedding.md needs nothing: its script-src row already covers a lazy same-origin chunk.

Findings

  • should-fix — DrawerStack.tsx:546: drop the whole expand chain; useFitSnap already does it, at the better height.
  • should-fix — qr.ts:33: uqr ships renderSVG; a printed poster wants vector.
  • should-fix — translations.en.json:275: the reason given for hand-editing the generated snapshot is wrong.

What was checked. The whole diff; qr.ts, download.ts, Disclosure.tsx, QrPoster.tsx, ShareView.tsx, shared.tsx, DrawerStack.tsx, the three new specs, plus use-fit-snap.ts, Drawer.tsx (fitSheet pre-existed), sync-translations.mjs, translations.test.ts, embedding.md § CSP and the CHANGELOG. The ladder walked both dependencies: uqr 0.1.3's declarations, and the collapsible lock entry, which adds no transitive package. The streamliner covered 23 pieces and kept 17; two of four sketches held. reveal stays for a viewport too short to fit; initial, because SSR runs no effect.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/views/DrawerStack/DrawerStack.tsx Resolved
Comment thread src/lib/share/qr.ts Resolved
Comment thread src/config/translations.en.json Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
`fitSheet` routes Share through `useFitSnap`, which observes the body and
each child and re-resolves the fit snap as the QR row opens, reaching the
near-full snap only when the content needs it. `expand` set that snap
outright, so it overshot the fitted height and left the sheet there once
the row closed again.

Gone with it: `DrawerControl.expand`, the `NO_DRAWER_CONTROL` stub, the
control memo's `direction` dependency, `QrPoster`'s `onOpen`, and
ShareView's `useDrawerControl`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjV1TjXm4oZ4aobaTjw
`PNG_TARGET_PX` had one caller. `qrPngScale` stays a named export because
the node lane has no canvas: the print-resolution guarantee is only
assertable through the arithmetic, not through `qrPngBlob`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjV1TjXm4oZ4aobaTjw
@sydevs-bot

Copy link
Copy Markdown
Contributor

Three critic threads addressed, and the branch is pushed for relay.

  • expand chain — dropped in 0ac17f1. useFitSnap also brings the sheet back down as the row closes, which expand had prevented.
  • qr.ts SVG download — PNG stays: Google Docs cannot insert an SVG, and renderSVG emits no width or height. PNG_TARGET_PX folded into its caller in 7ad6ebe.
  • the translations note — the stated cause was wrong. Rewritten against what WIDGET_TABS requests.

origin/main merged in, clean. Disclosure stays: its unmounted panel keeps uqr unfetched.

Lean gate ✓. Browser lane ✓, 10 scenarios, driving this sandbox's own Chromium.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 25, 2026

@sydevs-dispatcher sydevs-dispatcher Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for Ardnived, who wrote it: GitHub refuses an author's own approval. CI is green and the automated review has run. Enable auto-merge when you want it merged: the queue tests it against its base. 🤖 Written by the sydevs autonomous loop — see what this is

@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 25, 2026
Ardnived and others added 2 commits November 25, 2026 16:20
QrPoster takes the stories' and specs' initial state and starts open with it, so the failure copy (close and reopen) reads beside the row it refers to. QrCode is module-private again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 25, 2026
@Ardnived
Ardnived enabled auto-merge November 25, 2026 23:36
# Conflicts:
#	CHANGELOG.md
#	DESIGN_SYSTEM.md
@Ardnived
Ardnived added this pull request to the merge queue Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 25, 2026
Merged via the queue into main with commit 3d6e8b7 Nov 25, 2026
14 checks passed
@Ardnived
Ardnived deleted the feat/qr-poster branch November 25, 2026 23:45
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 25, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 26, 2026
main reworked the geocoder field (#485, #495), the drawer snaps (#492, #495)
and the panel header (#490) while this branch was open. Every hunk keeps both
sides' behaviour.

- `MapSearch` keeps this branch's controlled `value`/`onChange` — the Where
  step holds the draft's text, `SearchField` holds `?q` — and takes main's
  settle delay, measured results band and overlaying not-found message. Main's
  new spec held the text inside the field, so it now owns it the way both
  callers do; watched failing against the settle removed.
- `NavHeader` takes main's `pendingTitle`, without its `t`: the X it named is
  this branch's `CloseButton`, which brings its own.
- The mobile snap reads `opensTall(kind)` over main's `fitsContent`, so
  calendar, add and correct stay tall and event and Share still fit their own
  content. The two predicates are disjoint.
- `EventHeader` takes a `title` rather than an event since #490, so the submit
  listing and its story pass one.
- `CHANGELOG.md`, `DESIGN_SYSTEM.md` and the two import hunks are unions.
  DESIGN_SYSTEM.md is rebuilt on main's restructure, carrying this branch's
  `ProposalForm` row, `SubmitView`, `CloseButton` and the `Link` footnote note.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjY4MwaWAk4ZhpqxBB5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants