Skip to content

feat(ui): render the authenticated /app/* UI in PR previews (preview-session escape hatch) (#authed-route-preview) - #853

Merged
JSONbored merged 2 commits into
mainfrom
feat/authed-route-preview-session
Jun 18, 2026
Merged

feat(ui): render the authenticated /app/* UI in PR previews (preview-session escape hatch) (#authed-route-preview)#853
JSONbored merged 2 commits into
mainfrom
feat/authed-route-preview-session

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Problem

Per-PR preview screenshots (reviewbot) of the /app/* dashboard captured the sign-in wall, not the page — /app/* is guarded client-side in AppShell and the headless browser has no session (real GitHub OAuth Device Flow can't be scripted). e.g. PR #831's /app/audit preview was stuck at sign-in.

Fix

useSession().signInPreview() already mints a client-only synthetic demo session (login: 'local-preview', all roles, no real token) — but it was gated to vite dev only, so it no-op'd on deployed previews.

  • session.ts — gate signInPreview on PREVIEW_SESSION_ALLOWED = DEV || VITE_PREVIEW==='1'.
  • app-shell.tsx — when allowed + URL has ?preview=1, auto-start the synthetic session after hydration confirms no real session (self-heals via the session dep). Inert in prod / without the param.
  • ui-preview.yml — set VITE_PREVIEW=1 on the preview Build UI step. The production build (ui-deploy.yml) does not set it, so the escape hatch is dead-code-eliminated from prod.

Safety

  • Client-only synthetic session — no real token, no real API access. The prod API still enforces auth server-side; a preview visitor sees the dashboard shell, not anyone's data.
  • Compiled out of production entirely (flag only set in the preview build).
  • reviewbot appends ?preview=1 to /app/* routes (reviewbot#234); each side is inert without the other.

Scope note

This renders the authenticated shell + layout for visual review. Data panels that need a real token still show their empty/unauthenticated state — populating them with demo data is a separate, per-panel follow-up.

Verify

ui:typecheck ✓ · ui:lint ✓ · preview build (VITE_PREVIEW=1) ✓ · UI tests 7/7 ✓

…/app/* screenshots render the real UI (#authed-route-preview)

The /app/* dashboard is guarded client-side, so per-PR preview screenshots (reviewbot) captured the
sign-in wall instead of the page. useSession().signInPreview already mints a client-only synthetic demo
session (login 'local-preview', all roles, no real token) but was gated to `vite dev` only, so it was a
no-op on deployed previews.

- session.ts: gate signInPreview on PREVIEW_SESSION_ALLOWED (DEV || VITE_PREVIEW==='1'). VITE_PREVIEW is
  set ONLY by the per-PR preview build; production never sets it, so the escape hatch is dead-code-
  eliminated from prod builds.
- app-shell.tsx: when PREVIEW_SESSION_ALLOWED and the URL has ?preview=1, auto-start the synthetic session
  once hydration confirms no real session (self-heals via the session dep). Inert in prod / without the param.
- ui-preview.yml: set VITE_PREVIEW=1 on the preview Build UI step (the prod ui-deploy.yml build does not).

reviewbot appends ?preview=1 to gittensory /app/* routes (shipped separately). Each side is inert without
the other. The synthetic session is client-only and grants no real API access — data panels that require a
real token still show their unauthenticated/empty state; this renders the authenticated shell + layout for
visual review, not live data.
@dosubot dosubot Bot added the size:S label Jun 18, 2026
@ghost

ghost commented Jun 18, 2026

Copy link
Copy Markdown

Note

Gittensory Gate skipped

PR closed before full evaluation. No late first comment was created.

Signal Result Evidence Action
Gate result ⚠️ Skipped #853 is no longer open. No action.

💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.70%. Comparing base (2d443a0) to head (98f2f32).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #853   +/-   ##
=======================================
  Coverage   96.70%   96.70%           
=======================================
  Files         108      108           
  Lines       14642    14642           
  Branches     5299     5299           
=======================================
  Hits        14160    14160           
  Misses        102      102           
  Partials      380      380           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ghost

ghost commented Jun 18, 2026

Copy link
Copy Markdown

gittensory · advisory review

Reviewed 3 changed file(s) — two independent AI reviewers.

Changed files: .github/workflows/ui-preview.yml, apps/gittensory-ui/src/components/site/app-shell.tsx, apps/gittensory-ui/src/lib/api/session.ts

Suggested action: 🛠️ Request changes. (reviewers split: request changes / merge) Address the suggestions below before merging.

Reviewer A · gpt-oss-120b — recommends 🛠️ request changes
The PR introduces a synthetic preview session that auto‑signs‑in on preview builds when ?preview=1 is present, allowing screenshots of the authenticated UI. It adds the PREVIEW_SESSION_ALLOWED flag, updates the session hook, and adjusts the preview workflow to set VITE_PREVIEW=1.

Suggestions

  • Add unit/integration tests for the new PREVIEW_SESSION_ALLOWED constant and the signInPreview flow (e.g., ensure it only runs when the flag is true and creates the expected session object).
  • Verify that the preview session does not cause any API calls to leak private data; consider mocking API responses in the test to confirm graceful handling.
  • Document in the README or CI docs that VITE_PREVIEW must never be set for production builds to keep the escape hatch dead‑code eliminated.

Worth double-checking

  • If the preview flag were accidentally enabled in production, the demo session could expose UI elements that assume authentication.
  • Lack of test coverage for the new code may cause the patch‑coverage gate to fail.

Reviewer B · mistral-small-3.1-24b-instruct — recommends ✅ merge
This PR adds a preview session feature to render the authenticated /app/* UI in PR previews. The changes are well-documented and follow the project's conventions. The implementation is clean and the risk is low.

Suggestions

  • Consider adding a test to verify the behavior of the preview session in different environments (dev, preview, production).
  • Ensure that the preview session does not inadvertently expose sensitive information or bypass security checks.

Worth double-checking

  • Verify that the preview session does not interfere with the actual authentication flow in production.
  • Check that the preview session is properly disabled in production builds.
  • Ensure that the preview session does not introduce any security vulnerabilities.

Before = production · After = this PR's preview deploy.

Route Viewport Before After
/ desktop before desktop after desktop
mobile before mobile after mobile

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui 31b0920 Commit Preview URL

Branch Preview URL
Jun 18 2026, 05:08 AM

@JSONbored JSONbored self-assigned this Jun 18, 2026
@JSONbored
JSONbored merged commit 89584e2 into main Jun 18, 2026
20 checks passed
@JSONbored
JSONbored deleted the feat/authed-route-preview-session branch June 18, 2026 05:20
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.

1 participant