Public page rules (radius, shadow, hover and motion) are recorded in DESIGN.md.
Hardware print connector for Merqo vendors. Prints a label for every
order, through one of three connectors (src/lib/connectors/):
cloud_poll for printers that fetch their own jobs (Star CloudPRNT; the setup page stops polling once the printer is online),
vendor_cloud for printers reached through their maker's cloud (Feie 4G),
and bridge for Bluetooth printers (NIIMBOT B1) through the Connect a Bluetooth printer page in
Chrome on an Android phone, a Windows laptop or a Mac, or the Raspberry Pi
agent in bridge-agent/. An iPad cannot drive a Bluetooth printer at all
(no Web Bluetooth, WebUSB or Web Serial on iOS), verified on a B1 on
2026-09-22. Supported models
live in a static catalog (src/lib/printer-catalog.ts), which also holds
the recommendation order: iPad-alone printers with no monthly cost first
(cheapest first), 4G printers second, Bluetooth last; labels are laid out
once (src/lib/label-layout.ts) and rendered per driver, a PNG for most,
Feie's own markup for Feie. Architecture is job-type-agnostic for later job
types (receipt, kitchen-ticket, shelf-label, invoice). Internal-only —
reached through a vendor's existing sibling-kit relationship (qkit today),
no public marketing site or pricing; / redirects straight to
/dashboard. POST /api/v1/print-jobs accepts an optional job_type,
limited to label or label_batch (anything else returns 400). The outbound
print-status callback is kit-agnostic too — configured per calling kit in
kit_api_keys (callback_url/callback_secret), not hardcoded to qkit.
The secret is only sent to an https: URL without embedded credentials;
anything else is skipped and logged.
Its body names the job source_ref, with order_id kept beside it until
every calling kit reads the new name. GET /api/v1/print-locations/status
also returns manage_url, the printkit page for that location, so a calling
kit links to it instead of building printkit paths.
GET /api/merqo/vendor-activity (bearer MERQO_METRICS_SECRET) gives merqo's
admin vendor page a vendor's printer and job activity plus recent failures
from the ops_events log (30-day retention).
POST /api/merqo/entitlement (bearer MERQO_PROVISION_SECRET) receives merqo's
per-vendor entitlement; label print jobs are allowed only with a live paid
entitlement or a running event pass.
Kit routes are rate limited per IP before auth (300/min) and per kit after (600/min), agent token routes per IP (240/min), and pairing 10/min per IP failing closed; the client IP comes from x-vercel-forwarded-for, x-real-ip, then the last x-forwarded-for hop. Kit-supplied source_ref/location_ref are capped at 128 characters.
next.config.ts keeps @napi-rs/canvas (the label rasterizer's native
module) out of the bundle and traces src/assets/fonts/ into every API
route.
Use Node 24 and pnpm 11.10.0 (the packageManager pin) for reproducible installs.
The build allowlist grants only the locked shared-UI commit, esbuild and
unrs-resolver; Sharp uses optional prebuilt packages without an install script.
See AGENTS.md for the full stack, commands, and data model. A vendor can
pair a separate physical bridge/printer to each of their booths, not just
one shared bridge per vendor — see print_locations in AGENTS.md's
data model section. The bridge page also accepts a ?booth=<id> deep link
(matched against a location's source_ref) so a calling kit — qkit's booth
settings today — can send a vendor straight to one booth's pairing panel;
see src/app/dashboard/bridge/README.md. Bluetooth pairing refuses a booth that is configured for a different printer, so a B1 never stands in for it.
Design: docs/superpowers/specs/2026-08-21-printkit-v0.1-design.md,
docs/superpowers/specs/2026-08-23-printkit-location-routing-design.md,
docs/superpowers/specs/2026-09-20-printer-connectors-design.md
Deploy and staging (printkit-staging.merqo.io, previews on the shared staging
Supabase project; main and staging deploy from git, ad-hoc previews use the vercel CLI, scripts/staging-migrate.sh): docs/DEPLOY.md. The
staging-sync workflow pushes the staging branch with the merqo-staging-sync
GitHub App token, because a ruleset limits pushes to staging to that app.
Operator cleanup of orphaned sticker logos: node scripts/cleanup-sticker-logos.mjs
is a dry run; add --apply to delete and --grace-hours N to change the
24-hour grace period (see scripts/README.md).
Migration 0015_fk_indexes.sql indexes the foreign keys the Supabase advisor
flagged; it is safe to re-run.
Migration 0018_retention_purges.sql schedules a daily purge that clears label
payloads 90 days after printing and deletes expired bridge pairing codes.
next is pinned to 16.3.8 and vitest to 4.1.11 (see CHANGELOG.md
for the security context). The Vercel build does not use
output: "standalone"; that config was dropped.
Dashboard form errors use the shared FormError from @merqo/ui. The Bridge mode flag in src/lib/bridge-mode.ts persists through the shared readStored / writeStored. Shared shadcn primitives (Badge, Button, Input, Label, Select, Switch, Tooltip, Alert, cn) come from @merqo/ui/primitives.
The Overview fills the dashboard layout's full max-w-7xl width, shows three first-run steps (booth, printer, first label) until a label has printed (a step shows done only when every earlier step is done), refreshes itself on tab focus and every 30 seconds while visible, and every dashboard page header carries a short eyebrow (Overview: "Your booths"); the designer is reached from Printers, and a "Design your label" card appears once a booth has a printer but no label design. The first step always links to qkit: set the optional NEXT_PUBLIC_QKIT_URL (see .env.example) before building to point it elsewhere than https://qkit.merqo.io. The "Your booths" eyebrow appears only once a booth exists, and the label designer shows an empty state (not a 404) for a vendor with no booth printing.
The Printers page lets a vendor remove or swap a booth's printer (with a confirm), regenerate a cloud printer's address, edit a Feie SN and KEY, and reach the designer, and print a test label to any booth's printer (it goes through the normal queue, never reaches a calling kit, and shows as "Test print" in History, and the button is disabled while the printer is offline). The page refreshes itself; an offline virtual printer gets its own hint (press Start on its page) rather than the WiFi one. Overview and printers share a vendor-scoped batch loader. Connector setup flows live in separate local components; history uses shared DataTable with Printkit-specific action eligibility.
Each page sets its own metadata.title, which the root layout's template turns into "printkit | <title>" (lowercase, like every mention outside the wordmark). Public pages open with the shared LandingNav (SiteNav, which shows Dashboard and the account menu with Sign out to a signed-in visitor; it stays a Server Component and passes no function props to the client account nav) and a dashboard page's way back is the shared BackButton. The footer is the family's shared @merqo/ui Footer in its compact single-row layout (as in qkit, with no FAQ link because printkit has no /faq), through src/components/site-footer.tsx, and /about renders the shared AboutMerqo story, with a call to action that links to the public Bluetooth printer guide. /guides is the public index of those guides, and the nav links to it. Every dashboard page is built from the shared parts in src/components/ (Panel, Notice, Steps, TextLink) and the shared @merqo/ui PageHeader, and colour comes from the tokens in src/app/globals.css, including the success/warning/info status tokens, never from raw Tailwind colours. Rows that pair a name with a status, like PrinterStatusRow, stack below the sm breakpoint so they fit a phone. A Bluetooth bridge reports its booth online only while a printer is actually paired, its test print runs one at a time, and leaving the page while a printer is paired asks first. A dashboard error shows inside the dashboard (src/app/dashboard/error.tsx); both error pages' "Try again" re-fetches from the server, and a malformed history cursor falls back to the newest page.
Shared dashboard nav/account menu, and JobStatusBadge's shared
StatusBadge shape, come from @merqo/ui
(github:merqo-io/merqo-ui#716824ed5cfff959df9d88f709df2886dbeb15f2, tagged v0.58.0, package.json; pnpm-workspace.yaml allows its build for that commit only). Its help icons take taps through a 44px touch area on touch devices, and a long tooltip wraps inside the viewport; where a help icon follows a button (Bluetooth setup) it carries a small margin so that area stays off the button. This audited source includes shared client-boundary and account-menu hardening; login uses its shared GoogleMark instead of a local copy. Earlier releases added
DashboardTours, a route-matched multi-tour router for kits with more than
one dashboard-page tour; purely additive, this kit's own DashboardTour
usage is unchanged; bumped again 2026-09-16 for per-kit terms-schedule
scoping and the founder's public-name fix, see below). The dashboard shell
also gates a signed-in vendor on a current terms/privacy acceptance
(/legal/*, own README) before rendering, redirecting a stale vendor to
/legal/accept — see src/app/legal/README.md. As of v0.24.0,
TermsAcceptanceCheckbox no longer collects a typed legal name — just the
agree checkbox.
/legal/terms now renders only printkit's own Annex schedule
(<LegalDocument doc="terms" kit="printkit" />), not every sibling kit's —
previously every kit's /legal/terms page showed the full multi-kit annex
since none passed kit context. legal/accept/actions.ts's recorded
doc_sha256 hashes that same scoped content.
Brand theme is "Ink and paper" (black-ink primary on receipt paper, warm-grey
secondary, process-magenta accent) — see src/app/globals.css's own header comment.
The shared @merqo/ui PageHeader (props eyebrow, title, description,
action, back, responsive) opens every dashboard page, and every Button
size is at least 44px tall on touch screens, so tap targets stay
finger-sized. The printer picker's sort select is 44px tall on touch screens too. The pinned @merqo/ui is 0.68.0 (5a08fd8; 0.68.0 turns the account menu's "Text size" into a "Text size · 100%" submenu with a preset list under a "Preferences" group; 0.66.0 added the shared type scale and the account menu's "Text size" control, which vendors use to scale dashboard text; 0.65.1 (35444a3) 0.65.1 evens the signed-in landing header so Dashboard sits 4px from About, as FAQ does, and 0.65.0 changes only plan-catalog and pricing pieces this kit does not use; 0.64.1 makes the shared authErrorMessage match rate-limit and network messages on word boundaries; 0.64.0 fixed the React #441 crash when Timestamp is server-rendered and normalised the legacy starter tier to qkit; 0.63.0 changes: the shared SegmentedControl and useLeaveGuard replace the local ones, AutoRefresh uses usePolling, and the 0.62.1 changes still apply: the shared AboutMerqo copy now says qkit is running in a pilot, lists printkit and drops the one-sign-in sentence, and Footer and LandingNav have 44px tap targets; Timestamp and formatDateTime (Singapore time) replace the kit's own date helper; LandingNav folds its links (About) into a burger below sm; AppLinks in the root layout gives its client components next/link, so none takes a LinkComponent prop; 0.54.0 added the shared /auth/confirm form and handler back src/app/auth/confirm/, the shared ErrorPage, NotFound, GlobalError, EmptyState and FormError replace the kit's own copies); the
remove-printer confirm uses its ConfirmDialog. See src/components/README.md.
The dashboard avatar menu has a "Bluetooth guide" link, and the dashboard
<main> uses qkit's px-5 py-7 spacing. See src/app/dashboard/README.md. Dashboard sub-pages use two width tiers: list pages max-w-lg md:max-w-4xl, form/flow pages max-w-2xl.
A vendor can now reprint an already-printed label, not just a failed
one — see src/app/dashboard/history/README.md's reprintJob entry.
Reprint first asks "Print this label again?" so a double tap cannot queue two
labels, and a failed job in History explains its failure_reason in plain
words. The printer picker cards show only the essentials, with the rest behind
a "Details" disclosure. Removing a printer asks for confirmation in a modal
dialog, and a failed setup shows one plain message while the cause goes to the
server log.
History (and the Overview's recent list) shows each label as a card on a phone
and as a table from the md (768px) breakpoint up. An "All labels / Needs a booth"
control (a client component, src/app/dashboard/history/history-filter.tsx) filters the list (?unrouted=1 still deep-links to it), test prints
have no Reprint, and the copy says "labels" rather than "jobs".
In the sticker designer (src/app/dashboard/printers/designer/), when the
label size does not match the selected printer's media, the printer-fit notice
offers a "Match printer size" button that resizes the template to the printer
(fitTemplateToSize in src/lib/sticker-fit.ts). If fields extend past the new
edge the resize is refused with a specific message instead of a generic error.
/reset-password shows its form only to the session a fresh reset link
created, within 15 minutes, through a signed recovery-window cookie set by
/auth/callback. Any other signed-in session gets the expired card. See
src/app/reset-password/README.md. A rejected weak password shows which rule
Supabase says failed (the client states no length rule of its own), and the new-password field has a tap-friendly requirements hint.
Sign-in, password reset and terms acceptance show plain sentence-case copy.
Supabase auth errors are mapped to short next-step messages in
the shared authErrorMessage from @merqo/ui (unknown ones get a generic "Try again"
rather than the raw text), the login page checks the email inline before
calling Supabase, and /legal/accept has a "Sign out instead" button so a
vendor who declines the updated terms is not stuck.
Every Supabase redirectTo is the bare /auth/callback URL, since the
shared project honours only an exact allowed Redirect URL. The login page's
return path travels in the printkit_auth_next cookie; see
src/app/auth/callback/README.md.
e2e/ holds the Playwright public smoke, auth-guard and dashboard-states specs, run with pnpm test:e2e (see its own README).
A signed-out vendor who opens a dashboard link is returned to it after
sign-in: the proxy records the path as next on /login, and the login
page and /auth/callback honour it for same-origin paths only (see
src/app/login/README.md).
Audit progress and validation limits are recorded in the October 2026 audit. Device result handlers report persistence failures and recheck delivery state in the update. Feie callbacks also bind the update to the signed attempt ID.
The AI harness follows templateCentral 7.2.2: hook commands are anchored on the project directory, and the guard against committing to main reads the branch of the directory a command runs in (a strict && chain only by the directories git runs in). The dependency audit is the fail-closed .claude/deps-gate.sh, with expiring suppressions only in .claude/dep-audit-allow.txt. The dated entry in AGENTS.md lists what was adopted.
printkit runs Next.js 16.4.6 (pinned exactly, with a matching eslint-config-next), which includes the fix for GHSA-mfr8-8qww-v76h.
cross-spawn is pinned to 7.1.2 via pnpm-workspace.yaml overrides (GHSA-ghv9-86vm-4v8m). Overrides live in pnpm-workspace.yaml, one entry per package, and a repeated key breaks pnpm install.
src/proxy.ts is the only place the CSP is set (next.config.ts emits the other security headers but no CSP; nonce on per-request routes) and X-Robots-Tag off production; see docs/security/. The landing at / centres on a tappable "one story, two devices" walkthrough (src/components/landing/print-story.tsx, the shared @merqo/ui DeviceStory with two PhoneFrames) and is the only page that search engines may index. It is indexable, and only in production (app/page.tsx robots metadata, robots.ts allow: "/$"); every other route and every preview is noindex and presents printkit as the print companion for qkit booths.
eslint.config.mjs consumes the shared @merqo/ui/eslint preset (comment and directive hygiene, size and complexity limits, no colour literals or em dashes in src). eslint.config.test.ts asserts the key rules stay at error. Colour literals are allowed only in src/lib/brand-icon.tsx. It also enables merqoNoLocalCopies, which reports any kit-local copy of a piece @merqo/ui ships; the wrappers listed in its allow array (Supabase clients, rate limiter, kit auth and callback, legal gate, brand-icon, segmented-control, and the path src/app/dashboard/error, whose boundary renders inside the dashboard layout) adapt shared code to printkit's tables and variants.
The label_batch API creates one ordinary job per item unit and reports terminal status for the whole order. Migration 0011 must be applied before rollout. See the specification for compatibility, retry semantics and the pending Kopitiam Cart physical acceptance checklist.
The Bluetooth bridge provides an optional 40 by 60 mm calibration preview and an explicitly initiated single-label sample print.
The sticker designer prototype supports configurable label geometry and a non-printing renderer preview; saved designs now print on live label jobs. Long text fits its box (wrap, shrink, then ellipsis), and a job falls back to the default label if the design cannot render. A vendor can upload one PNG or JPEG logo (up to 512 KB and 1024 by 1024 pixels) into the private sticker-logos storage bucket and place it on the sticker; the logo prints as a dithered 1-bit image and is drawn in the designer print preview, and a missing or unreadable logo is skipped without failing the job. A design is scaled to the printer's label size (contain, centered), the designer warns when the sizes differ, and Feie printers keep the standard label.
printkit-test is a reserved kit slug: test labels use it as their source_kit and never call a kit back, so create-kit-key refuses to mint a key with it.
AGENTS.md is kept under 200 lines; file layout, data model and harness detail live in docs/FILE-LAYOUT.md, docs/DATA-MODEL.md and docs/meta/.
next.config.ts also redirects the old /dashboard/dev/virtual-printer path permanently to /dashboard/printers/virtual, keeping the query string.
knip.json lists the operator scripts and their tests as entries and excludes bridge-agent/ and .claude/. knip is not a dependency; run it with the pinned command in docs/meta/2026-10-24-fresh-eyes-sweep.md.
The Wordmark in src/components/wordmark.tsx wraps @merqo/ui's Wordmark, which always sets a size class, so the nav, dashboard nav and footer pass an explicit text-* size.
The legal pages render the shared LegalPage (through a small client wrapper) and the accept page renders the shared AuthShell and AcceptTermsForm (with a local sign-out exit), and the cloud-print setup address uses the shared CopyButton.
Each dashboard route has its own loading.tsx skeleton (Printers, History, Label design, printer setup, Bridge) that mirrors the page width, and src/app/dashboard/not-found.tsx keeps a bad /dashboard/... URL inside the dashboard shell; the src/app/dashboard/[...slug] catch-all throws notFound() for unmatched URLs so that page is reached instead of the root 404.
The label designer has a "Print test label" button that saves unsaved changes first, then prints the saved design with a sample order; it is disabled with a reason when the booth has no printer or the printer is offline.
The printers "More" menu uses @merqo/ui/primitives' DropdownMenu, and the label designer's fields are keyboard-movable (see src/app/dashboard/printers/designer/README.md).
The in-browser virtual printer (/dashboard/printers/virtual) keeps polling in a background tab by running its timer in a Web Worker, resumes after a reload, and counts as online for 5 minutes after its last poll.