Skip to content

Phase 11 completion: the missing §47/§48 mobile + image-performance items - #25

Merged
ManoharPaturi merged 2 commits into
mainfrom
feat/phase11-mobile-performance
Oct 9, 2026
Merged

ManoharPaturi merged 2 commits into
mainfrom
feat/phase11-mobile-performance

Conversation

@Pushpak731

Copy link
Copy Markdown
Contributor

Summary

Phase 11 (Production Hardening) shipped in #23, but an audit against the actual spec checklist (§46-§49) found four §47/§48 items that were never delivered. This PR completes them. App code only — no migration, no schema touch.

Audit → fix map

Spec item State before This PR
§47 responsive image sizes single fixed w_600 URL for every viewport responsiveImageSrcSet() + sizes on cards and gallery
§48 sticky Add to Cart / Buy Now buttons scroll away on mobile mobile-only fixed purchase bar (price + both actions, same handlers)
§48 bottom-sheet filters sidebar form always stacked above the grid on mobile dialog-style bottom sheet on mobile; sidebar stays on desktop; noscript restores it
§48 swipe gallery single image + thumbnail rail, no swiping scroll-snap strip, one photo per view, touch swipe with zero JS; keyboard parity kept

Already complete and untouched: rate limits, CSP/headers, sitemap/robots, lazy loading, LCP fetchPriority, reduced-motion CSS, backup workflow, runbooks.

Changes

  • lib/media/optimized-url.ts — new pure responsiveImageSrcSet(url, widths): f_auto,q_auto,w_<n> candidates per width; returns null for non-Cloudinary hosts (a srcset of identical URLs would only waste bytes — plain src already covers those).
  • product-card.tsx — primary and hover images now carry srcSet (400/600/800) + sizes matching the 2-up/3-up/4-up grid: phones fetch small derivatives, desktops large ones.
  • product-gallery.tsx — main image becomes a horizontal snap-x snap-mandatory strip: swipe on touch with no JS, thumbnails scroll to a photo, ← → keys keep working, first image stays the LCP (fetchPriority=high, eager; rest lazy + responsive). Pinch-zoom intentionally remains native browser zoom — no custom gesture code to break.
  • add-to-cart.tsx — sm:hidden fixed bar with selected variant price, availability, Add to Cart and Buy Now reusing the exact handlers; a flow spacer reserves the bar's height so the footer is never obscured.
  • filters-sheet.tsx (new) + catalog-view.tsx — mobile gets a "Filters" trigger (active-count badge) opening a role="dialog" sheet: aria-modal, Escape closes, backdrop click closes, focus moves into the sheet and returns to the trigger. The same GET form renders in sidebar (desktop) and sheet (mobile); a <noscript> style override restores the sidebar on mobile when JavaScript is off — filtering never depends on JS.

Testing

  • npm run typecheck — clean (after clearing stale .next from another branch's build)
  • eslint on all seven touched files — clean
  • npm test — 217/217 (213 on main + 4 new responsiveImageSrcSet tests)
  • npm run build — compiles
  • Mobile click-through on a device/DevTools — left to review (gallery swipe + sheet are the things to feel)

Notes for review

Audit of Phase 11 against §46-§49 found four spec items never delivered:

- §47 responsive image sizes: new responsiveImageSrcSet() builds
  f_auto,q_auto,w_<n> candidates per layout width; product cards fetch
  400/600/800 with a sizes attribute matching the 2/3/4-up grid, and the
  gallery hero 600-1400 at 50vw/100vw — phones stop paying for desktop
  derivatives
- §48 sticky Add to Cart / Buy Now: mobile-only fixed purchase bar on the
  product page mirroring the same handlers and price, with a flow spacer
  so the footer is never obscured; hidden from sm up
- §48 bottom-sheet filters: FiltersSheet renders the same GET form in a
  dialog-style sheet on mobile (aria-modal, Escape, focus return);
  desktop keeps the sidebar, and a noscript override restores it when JS
  is off — filtering still works without JavaScript
- §48 swipe gallery: the main image becomes a scroll-snap strip (one
  photograph per view, touch swiping with zero JS), thumbnails scroll it,
  keyboard arrows keep parity; pinch-zoom deliberately stays native

Tests: 213 → 217 (responsiveImageSrcSet unit suite). App code only, no
migration.
Copilot AI balanced review requested due to automatic review settings October 9, 2026 17:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sri-vartali-commerce Ready Ready Preview Oct 9, 2026 5:14pm UTC

@ManoharPaturi

Copy link
Copy Markdown
Contributor

@copilot review

Copilot AI commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@copilot review

I reviewed the current PR changes and didn’t find any blocking issues in the implementation. The code paths for responsive images, mobile sticky purchase bar, mobile filter sheet accessibility, and swipe gallery behavior look consistent with the stated scope. Remaining check is manual mobile interaction QA as noted in the PR description.

@ManoharPaturi
ManoharPaturi merged commit 406575c into main Oct 9, 2026
4 checks passed
@ManoharPaturi
ManoharPaturi deleted the feat/phase11-mobile-performance branch October 9, 2026 17:14
ManoharPaturi added a commit that referenced this pull request Oct 9, 2026
## Summary

Phase 12: the **§9 Super Admin panel** (previously a placeholder stub)
and **§39 realtime for the client dashboard**. One migration
(idempotent, **pre-applied on this branch and verified by read-back**),
no new dependencies. Branch cut from `main` @ `32afb57` (after #24);
zero file overlap with open PR #25.

## A. Super Admin area (§9) — all routes

proxy.ts gates `/admin/*` to SUPER_ADMIN and RLS gates every query
beneath — both kept; each page additionally renders a notice instead of
data for non-super-admins (defense in depth).

| Route | What it does |
|---|---|
| `/admin` | Today's order/payment counters (same `dashboardStats`
surface, RLS-scoped), integration rollup (set/not set), 8 newest audit
events |
| `/admin/users` | Profiles directory: email, name, phone, role, joined.
Role picker → `setUserRole` action |
| `/admin/roles` | Role distribution matrix + the same audited
assignment table |
| `/admin/client` | Read-only client team + §30 store settings (edits
stay in /client/settings) |
| `/admin/integrations/whatsapp` | Status only — which env vars are set;
honest "behaviour while unwired" section; **never values**; wiring stays
owner-deferred |
| `/admin/integrations/cloudinary` | Status only + how signed uploads
flow (secret never client-side) |
| `/admin/logs` | `whatsapp_messages` browser with status filter;
NOT_CONFIGURED failures show honestly; order links |
| `/admin/webhooks` | `webhook_events` list + guarded **"Mark
resolved"** (see actions below) |
| `/admin/audit` | `audit_logs` newest-first, filter chips derived from
real actions |
| `/admin/system` | `/api/health` mirror, env matrix (set/not set),
backup posture summary |

**Actions** (`lib/admin/actions.ts`, SUPER_ADMIN-only session gate, RLS
beneath, audit-logged via the service-role client — the
payment-verification pattern):

- `setUserRole` — validates against `roleChangeGuard` (pure,
unit-tested): real roles only, same-role = no-op, and **the last active
SUPER_ADMIN can never be demoted**. Writes `admin.role_change` to
audit_logs with old/new role.
- `markWebhookEventResolved` — only RECEIVED/FAILED rows
(`isResolvableWebhookStatus`, unit-tested); sets PROCESSED +
processed_at, keeps the error text for history, writes
`admin.webhook_mark_resolved` to audit_logs. **This is the 04-OPEN-ITEMS
§5 cleanup path — the two stuck rows get closed by the owner's clicks,
one at a time, never by SQL.**

## B. Realtime (§39) — client dashboard only

- **Migration `20261009190000_realtime_phase12.sql`** (idempotent):
`orders` added to `supabase_realtime` (duplicate_object tolerated);
`orders` replica identity **full** so payloads carry the old row for
status diffing; `profiles.email` added + backfilled from auth.users (the
admin users/roles pages need it — the API surface can't join auth.users)
and kept in sync by the signup trigger.
- **`OrdersLive`** on `/client` and `/client/orders`: session-scoped
`postgres_changes` subscription on `orders`; INSERT (new order) and
UPDATE where payment/fulfilment status moved → `router.refresh()` + an
aria-live toast. `describeOrderChange` is pure and unit-tested;
untracked updates, deletes, and missing-old payloads stay silent.
Storefront pages never subscribe (§39 rule). Degrades silently if
realtime can't connect.

## Verification

- [x] `npm run typecheck` — clean
- [x] `eslint` on all new/changed files — clean
- [x] `npm test` — **242/242** (229 on main + 13 new: role guards,
webhook resolvability, change describer)
- [x] `npm run build` — all 10 admin routes compile
- [x] Migration **pre-applied on this branch** via "Apply DB migration"
([run
37965908811](https://github.com/manohar-test123/sri-vartali-commerce/actions/runs/37965908811))
and **verified by read-back** ([run
37966011783](https://github.com/manohar-test123/sri-vartali-commerce/actions/runs/37966011783)):
`supabase_realtime` lists `public.orders`; `orders.relreplident = f`;
`profiles`: 1 row, 1 with email. The read-back SQL rides the branch as
`supabase/ops/20261009_realtime_readback.sql` (SELECT-only).
- [ ] **Local e2e on :3123 not run here** — this machine has no
`.env.local` (owner-transferred). Owner ritual: two tabs, place a
clearly-named test order in one, watch the dashboard toast + refresh in
the other; then clean the test order up.

## Notes for review

- On merge, the Supabase integration re-applies the migration —
idempotent, so a no-op (publication already contains orders).
- No new dependencies; toast and dialog patterns are hand-rolled like
the rest of the codebase.
- Rollback: revert the squash (app code) — the migration's DB effects
are additive/harmless to leave (publication membership + a nullable
column), or reversible with one-line SQL if ever wanted.
- Non-goals honoured: no Meta wiring, no paid plans, nothing weakened,
service-role key never near client code (`lib/db/admin.ts` window guard
untouched).

---------

Co-authored-by: Manohar Paturi <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — 94b61c7b Deployed Oct 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants