Skip to content

refactor: replace 8 Drop-built pieces with what ViteHub already ships - #267

Merged
vite-hub[bot] merged 8 commits into
mainfrom
refactor/vitehub-builtins
Nov 21, 2026
Merged

vite-hub[bot] merged 8 commits into
mainfrom
refactor/vitehub-builtins

Conversation

@onmax

@onmax onmax commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Drop still did 8 things that ViteHub at c3cfab6 already does: proxy sign-in, a fake presence document, a build step for the presence client, the dev runner, a second types step, the build commit, the host choice, and nothing told agents that server/mcp isn't ViteHub's MCP. These are findings 10, 12, 14, 15, 16, 17, 19 and 36 of the Drop × ViteHub audit. Each one is its own commit.

  • Proxy sign-in (10). proxyAuth() is now forwardAuth() from vite-hub/auth/forward. Its verify returns null when proxy mode is off, so the header signs nobody in then. It also returns null for a non-member, and keeps the GitHub identity for 5 minutes per token, since forwardAuth asks on every request that carries the header. It passes the token as accessToken only when it differs from the one on the GitHub account, because forwardAuth writes the account whenever it gets one. proxyAuth() still makes a plugin per auth lookup, because forwardAuth reuses the session it made for an identity in its plugin: one plugin per process would give a second browser of the same GitHub user the first one's session, and signing out in one would end both. Its lock for parallel first sign-ins is per plugin too, so until the GitHub account exists, the middleware runs the sign-in one at a time per GitHub identity. Overlapping first requests used to both insert the user, and one got a 403. Once the account exists, requests don't wait on each other. The middleware still answers 403 GITHUB_MEMBERSHIP_REQUIRED to non-members and clears the proxy cookie on sign-out. After it signs someone in, it puts the session cookie into the request and removes the token header, so the handlers after it read that one session and don't sign in again.
  • Presence (12, 16). The room is document: false, ViteHub's presence-only definition. /review-presence.js serves @vite-hub/realtime/client/browser.js as text, so scripts/review-presence*.ts and the virtual:review-presence plugin go. The import reads import { default as … } from "…?raw" because oxlint's import/default resolves the ?raw path to browser.js and finds no default export.
  • Dev runner (14). ViteHub's Nuxt module already sets devServer.runner ??= "node-worker" for Cloudflare.
  • Types (15). postinstall is just nuxt prepare. With .nuxt and .vitehub deleted, it writes the same .nuxt types as nuxt prepare && vitehub types prepare.
  • Build commit (17). release.commit comes from readForgeBuild() in @vite-hub/forge/build/node, now a direct dependency at the pinned URL. It reads VITEHUB_BUILD_COMMIT, then each host's commit variable, then git, so a local build logs its HEAD.
  • Host (19). deployment() calls detectHost() and maps node to vps. Vercel and Netlify need nothing, because ViteHub reads their own build variables. Deno's build and predeploy, the Dockerfile build stage and pnpm run deploy set VITEHUB_HOST. Without either, a build with DROP_DATABASE_URL still picks VPS, and any other build picks Cloudflare. An old DROP_HOST still works while VITEHUB_HOST is unset: vps reads as node, and nuxt.config.ts passes the result on as VITEHUB_HOST so ViteHub's build checks agree. An unknown value fails the build. The self-host docs say to switch to VITEHUB_HOST.
  • MCP (36). One line in AGENTS.md says server/mcp/tools and prompts use nitro-mcp-toolkit. I left the folder where it is, because moving it would touch every tool import while other PRs are open.

Checked

  • pnpm typecheck, pnpm run doctor (clean), lint and format on the changed files, and pnpm build for Cloudflare. The built route carries the client as a string literal, and the Worker's release commit is the git HEAD.
  • With nuxt dev running without devServer.runner, two tabs of one signed-in owner on a local site loaded the real review.js, got presence tickets, imported /review-presence.js across origins (text/javascript, Access-Control-Allow-Origin: *) and joined the same document: false room over WebSocket. A made-up ticket gets 403.
  • Tests, by file: auth/proxy-sign-in (member sign-in through the header, non-member 403, banned user, sign-out, no sign-in without proxy mode, one session for a first request and none left after sign-out, separate sessions for two browsers of one user, one user for overlapping first requests, no waiting once the account exists, account writes only on a rotated token), auth/content-headers, auth/content-error, auth/members-only-review, review/presence, deploy/config (including DROP_HOST), deploy/cli-migrations, deploy/deploy-cloudflare, content-origin/runtime, viewer/presence-activity, mcp/handoffs. The session, account-write and DROP_HOST cases fail on the PR's first head.
  • review/presence-browser fails about 1 run in 2 on "cursor at the heading's middle". It looks like it reads the cursor's transform before the cursor settles. That test uses its own stand-in client, and this PR doesn't touch it or review.js.

I didn't build for Vercel, Netlify, Deno or Docker, and didn't try proxy sign-in behind a real oauth2-proxy.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-21T16:16:38.912686Z
We couldn’t complete this review. Comment @codex review to try again.
e075b4c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@pullfrog pullfrog Bot 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.

Important

The proxy refactor creates two sessions on the first request and leaves one active after sign-out. It also rewrites the GitHub account on ordinary authenticated reads. Existing DROP_HOST settings can silently select a different deployment target.

Approach: Using ViteHub’s built-ins makes sense, but the proxy integration needs to preserve one session per sign-in and the host migration needs to prevent silent retargeting.

Reviewed changes across auth, realtime, build setup, deployment, and MCP documentation.

  • Proxy sign-in: Traced membership checks, GitHub identity caching, cookie propagation, and sign-out through Drop’s mounted Auth routes.
  • Realtime presence: Checked the presence-only room and the prebuilt client served to review sites.
  • Build and deployment: Checked Nuxt type generation, the dev runner, Forge release metadata, and host selection for Docker, Deno, Cloudflare, Vercel, and Netlify.
  • MCP: Checked the documentation boundary between Drop’s toolkit and ViteHub’s MCP conventions.

58 focused tests passed. The VPS build succeeded, and HTTP checks with mocked GitHub responses and real SQLite confirmed the auth regressions on the built app.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread server/middleware/0.15.proxy-session.ts Resolved
Comment thread server/utils/proxy-auth.ts Resolved
Comment thread scripts/deployment.ts Resolved
@vite-hub

vite-hub Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —
View session Starting Not started —
View session Last seen running 2026-11-21T17:54:23.201Z 0s
View session Last seen running 2026-11-21T17:36:28.873Z 0s

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

Session

Pass interrupted; current webhook state retained.

Session

Pass interrupted; current webhook state retained.

@pullfrog pullfrog Bot 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.

Important

The legacy VPS override works for standalone builds, but a conflicting provider marker still makes the build fail, contrary to the migration guide and the new test.

Reviewed changes in 572fbdc since the prior Pullfrog review.

  • Carried the proxy session forward. Verified on the built VPS app that both /api/me and /api/auth/get-session create one session on first sign-in and leave none after sign-out.
  • Skipped unchanged GitHub token writes. Verified zero account updates when the token matched and one update when it rotated.
  • Restored the legacy host override. Verified that DROP_HOST=vps alone produces the Node preset, then checked how the override interacts with ViteHub’s provider detection.

All 55 focused auth and deployment tests passed. The provider conflict surfaced in a full Nuxt build, not in the configuration test.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread scripts/deployment.ts Resolved

@pullfrog pullfrog Bot 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.

ℹ️ No P0 or P1 findings remain; one dev reload edge case is noted inline.

Reviewed changes in 62b1b3b since the prior Pullfrog review.

  • Shared the legacy host override with ViteHub. Verified that a full Nuxt build with DROP_HOST=vps VERCEL=1 and no VITEHUB_HOST now completes with the node-server preset.
  • Waited for the presence cursor to settle. Verified that the browser test still checks the original coordinates and tolerance.
  • Scoped the Doctor exception to one comment. The repository’s Doctor check reported no warnings or errors.

All 12 focused deployment and presence browser tests passed; the changed cursor test also passed three additional runs.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread nuxt.config.ts Resolved
@onmax
onmax force-pushed the refactor/vitehub-builtins branch from 62b1b3b to 1f184eb Compare November 21, 2026 17:13

@pullfrog pullfrog Bot 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.

Important

The shared proxy-auth plugin lets separate browsers inherit the same Drop session. Signing out in one invalidates the other browser’s session.

Approach: Reusing forwardAuth() still makes sense, but deduplicating a sign-in should not make separate browsers share a session.

Reviewed changes since the prior Pullfrog review at 62b1b3b.

  • Shared proxy state. Checked the process-wide forwardAuth() instance and its new parallel sign-in test against a separate-browser sign-out case.
  • Dropped two changes during the rebase. Checked the restored cursor assertion and confirmed Doctor passes without the previous exception.

All 32 focused auth and deployment tests passed, as did three runs of the presence browser suite. The separate-browser sign-out check failed with the shared plugin and passed with independent plugin state.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread server/utils/proxy-auth.ts Resolved
@onmax
onmax force-pushed the refactor/vitehub-builtins branch from 1f184eb to 282ef8a Compare November 21, 2026 17:26

@pullfrog pullfrog Bot 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.

Important

Separate browsers now keep separate sessions, but overlapping first requests for a new GitHub member can still fail with 403.

Approach: Keep session reuse scoped to each sign-in, but coordinate first-time account creation across requests.

Reviewed changes since the previous Pullfrog review at 1f184eb.

  • Restored per-instance proxy auth. Checked that the middleware still carries the session cookie through the request, and traced how the new plugin lifetime affects simultaneous first sign-ins.
  • Replaced the shared-session test. Verified that signing out of one browser leaves the other browser’s session valid.

All 50 checked-in tests in the focused auth and deployment suites passed, and pnpm run doctor was clean. A separate concurrency check through the proxy middleware reproduced the 403 using SQLite and mocked GitHub responses.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread server/utils/proxy-auth.ts Resolved
@onmax
onmax force-pushed the refactor/vitehub-builtins branch from 282ef8a to 17ae195 Compare November 21, 2026 17:44

@pullfrog pullfrog Bot 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.

Important

The new lock fixes concurrent account creation, but it also serializes session reads for members who are already signed in.

Approach: Coordinate first-time provisioning across requests while keeping browser sessions separate and established-session reads concurrent.

Reviewed changes since the prior Pullfrog review at 282ef8a.

  • Added a per-identity sign-in queue. Checked its scope on both first sign-in and ordinary requests with a valid session.
  • Added an overlapping-request regression test. Verified that both requests receive session cookies and provision one user and one GitHub account through separate Auth instances.

All 51 focused auth and deployment tests passed, and pnpm run doctor reported no warnings or errors.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread server/middleware/0.15.proxy-session.ts Resolved
onmax and others added 8 commits November 21, 2026 18:57
Drop had its own Better Auth plugin for proxy sign-in: a proxySignIn
endpoint, its own session and account writes, and a middleware that
called it. vite-hub/auth/forward does the same through forwardAuth():
it reads the forwarded header, asks verify() for the identity, and
creates or reuses the user, account and session.

proxyAuth() is now forwardAuth({ header, verify }). verify returns null
when proxy mode is off, so the header signs nobody in then, and null
for a non-member. A membership check that fails (401, 403 or GitHub
down) becomes an APIError with the same status. verify keeps the
GitHub identity for 5 minutes per token, because forwardAuth calls it
on every request that carries the header and the profile and email
lookups are 2 GitHub calls.

The middleware keeps what Better Auth can't do from a hook: it answers
403 GITHUB_MEMBERSHIP_REQUIRED for a non-member, clears the proxy
cookie on sign-out, and turns a refused sign-in into a 403. After
sessionOf() it puts the new session cookie into the request's cookie
header and removes the forwarded token header, so the handlers after it
read the session from the cookie and don't run forwardAuth again. The
request headers are immutable on Deno, so it replaces them with a copy.

proxyAuth() still makes a plugin per auth lookup. forwardAuth reuses
the session it made for an identity in the same plugin, so one plugin
for the process would give a second browser of the same GitHub user the
first browser's session, and signing out in one would end both. The
lock that forwardAuth keeps for parallel first sign-ins is per plugin
too, so two overlapping first requests could both insert the user and
one got a 403 on user.email. Until the GitHub account exists, the
middleware runs the sign-in one at a time per GitHub identity, which
keeps one user and one account. Once it exists, requests don't wait on
each other.

verify passes the token as accessToken only when it differs from the
one stored on the GitHub account, because forwardAuth writes the
account whenever it gets one. A rotated token is still stored for the
membership checks.

The tests now sign in through the handler and the middleware, and add
cases for the header without proxy mode, one session per first request
through sign-out, separate sessions for two browsers of one user, one
user for overlapping first requests, no waiting once the account
exists, and account writes only on a rotated token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The presence definition faked a document: a "drop-presence" kind that
loaded an empty body and threw on save, plus persistence: false.
ViteHub's document: false is the presence-only definition: rooms carry
awareness and no document, authorize is asked only for read, and
editor, history and persistence become type errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
review.js loads /review-presence.js on other sites. Drop built that
file itself: a Vite plugin bundled scripts/review-presence-entry.ts
into a virtual module on every build. @vite-hub/realtime already ships
the same client prebuilt as client/browser.js, one ES module with Yjs
inside and no imports, and its docs say to serve its text.

The route now imports it with ?raw and keeps the same headers
(text/javascript, CORS *, CORP cross-origin). The build script, its
entry and the virtual module's type are gone.

The import is written `import { default as ... }` because oxlint's
import/default rule resolves the ?raw specifier to browser.js, sees no
default export, and fails. The named form is the same import and
passes, without a disable comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ViteHub's Nuxt module sets devServer.runner to "node-worker" for the
Cloudflare host (devServer.runner ??= NITRO_DEV_RUNNER || "node-worker"
at c3cfab6), so Drop's own setting repeated it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ViteHub's module writes its types during nuxt prepare. With .nuxt and
.vitehub deleted, nuxt prepare alone gives the same .nuxt type files,
and pnpm typecheck passes. vitehub types prepare only added dev runtime
files under .vitehub, which nuxt dev writes anyway.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uild

The release commit came from 4 env names. readForgeBuild from
@vite-hub/forge/build/node reads VITEHUB_BUILD_COMMIT first, then each
CI and host's commit variable (Vercel, Workers Builds, Netlify, GitHub
Actions and others), then git. A local build now logs its HEAD instead
of an empty commit.

@vite-hub/forge was only a transitive dependency, so it becomes a
direct one at the same pinned URL as the other ViteHub packages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…DROP_HOST

Drop chose its host from DROP_HOST, which every host config had to set,
while ViteHub detects the same host from VITEHUB_HOST, the Nitro preset
and each host's own build variables (WORKERS_CI, NETLIFY, VERCEL,
DENO_DEPLOY). Two names for one choice could disagree, and ViteHub
fails the build when VITEHUB_HOST doesn't match its plan.

deployment() now calls detectHost() and maps ViteHub's "node" to Drop's
"vps". Without a detected host it still falls back to vps when
DROP_DATABASE_URL is set, else cloudflare. Vercel and Netlify drop
DROP_HOST because their build variables are enough. Deno and the
Dockerfile, which have none, set VITEHUB_HOST=deno and VITEHUB_HOST=node
at build time, and Deno's predeploy migration sets VITEHUB_HOST=deno.
pnpm run deploy builds with VITEHUB_HOST=cloudflare, so a .env with
DROP_DATABASE_URL still builds for Cloudflare. Nothing read DROP_HOST at runtime, so the Docker runtime
stage loses it. The self-host docs and .env.example name VITEHUB_HOST.

A build that still sets DROP_HOST keeps its host: without VITEHUB_HOST,
deployment() reads DROP_HOST as VITEHUB_HOST, with vps as node, so a
DROP_HOST=vps build without DROP_DATABASE_URL doesn't turn into a
Cloudflare build. nuxt.config.ts then sets VITEHUB_HOST to that host,
so ViteHub's build checks see the same one. An unknown DROP_HOST fails
the build. The self-host
docs say how to switch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
server/mcp/tools and server/mcp/prompts look like ViteHub's mcp folder
layout, but Drop registers them by hand with nitro-mcp-toolkit and
doesn't enable ViteHub's mcp feature. One line in AGENTS.md says so,
so an agent doesn't write vite-hub/mcp tools there. Moving the folder
would touch every tool import while other PRs are open, so it stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@onmax
onmax force-pushed the refactor/vitehub-builtins branch from 17ae195 to 28de5e2 Compare November 21, 2026 17:57

@pullfrog pullfrog Bot 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.

✅ No new issues found. No P0 or P1 findings remain.

Reviewed changes since the prior Pullfrog review at 17ae195.

  • Scoped the proxy sign-in queue to first-time provisioning. Verified that requests for an existing GitHub account no longer wait on Drop’s queue, while overlapping first sign-ins still create one user and one GitHub account.
  • Added a concurrency regression test. Verified that both requests for an existing account can enter session lookup before either finishes.

All 52 focused auth and deployment tests passed. pnpm run doctor reported no warnings or errors.

Pullfrog  | View workflow run | Using gpt-6.2-sol(high) | 𝕏

@vite-hub
vite-hub Bot merged commit ca85b60 into main Nov 21, 2026
6 checks passed
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