fix(web): apply migrations the way production does; let the submodule guard fetch history
main's web migration jobs fail since #15423, a fresh local database can't migrate, and one of #15423's database tests has never run. This PR fixes those, plus a CI guard flaw found while restoring main's bonsplit pin. Part of #15488.
1. Apply migrations the way production does (#15423)
#15423 added a CREATE INDEX CONCURRENTLY migration and taught the production migrator (migrate-planetscale.mjs) to run it outside a transaction. Everything else still ran drizzle-kit migrate, which wraps every migration in one transaction:
- CI's
web-db-migrationsand the requiredweb-validationjob cloud-vm-guest-installandios-streamed-validate- local
bun run db:migrate,db-local.sh testanddev-local.sh
All of them fail with CREATE INDEX CONCURRENTLY cannot run inside a transaction block (main's web-db-migrations job).
The production migrator's loop moves unchanged into web/scripts/cloud-vm/apply-migrations.mjs. A new web/scripts/db-migrate.mjs runs it against DIRECT_DATABASE_URL or DATABASE_URL. Every caller above now uses it, so CI exercises the code production runs. On a scratch Postgres 14:
- all 93 migrations applied, and a second run applied none;
cloud_vms_observed_destroy_cleanup_idxexists and is valid.
1b. The malformed cleanup-row test never ran (#15423)
With migrations working, the database behavior tests ran for the first time since #15423, and one of its tests failed (job):
(fail) Cloud VM database schema > rejects malformed transferred cleanup rows
Expected: "23514" Received: "23502" (web/tests/db-schema.test.ts:146)
The test's first malformed value is null, and postgres.js binds sql.json(null) as SQL NULL. The NOT NULL column rejects that (23502) before the check constraint the test is about. The row under test is a JSON null document, so that case now inserts 'null'::jsonb. The check then rejects it with 23514 like the other nine. Checked on a scratch Postgres 14 with postgres.js:
sql.json(null)gives23502; the JSON null gives23514.- All ten malformed values give
23514. {modelPlane: true}and{homeVolume: "v"}are accepted.
2. Let the submodule guard fetch history when GitHub can't answer (#15943)
The forward-only guard checks submodules out two commits deep. When the old pin sits deeper, it asks the GitHub compare API. That call fails whenever the repository's shared Actions token is out of quota; CLA Assistant hit "API rate limit exceeded for installation" at the same time. The guard then reported could not determine ancestry for a genuinely forward bonsplit bump, on this PR's earlier runs and on #15942's. Earlier bumps passed only because their old pin was a direct parent.
As a last resort after the compare, the guard now fetches the missing history (commits and trees, no blobs) and decides locally. It never runs when the local check or GitHub already answered. A shallow bonsplit clone at 7544622, made as CI makes it, resolves bf5f051 as forward. python3 -m unittest tests.test_submodule_forward_only passes 17 tests, two of them new.
3. Restore seats-follow-membership billing copy (#16265)
Main was also red in web/tests/dashboard-billing-screen.test.tsx: the dashboard SPA port restored the old soft-seat wording and an "Add seats" link even though subscription quantity follows team membership. I incorporated Leo Li's open #16265 as three author-preserving commits (failing regression test, implementation/locales fix, and new-team regression test), each carrying a Co-authored-by trailer. This keeps the fix separate from the migration work while crediting the upstream implementation and avoids a second translation implementation. Thanks to Leo for the diagnosis and fix.
4. Repair the pinned OpenCode proxy test hang (#16165)
The latest main and this PR also exposed the resource leak left by #16165: under Bun 1.3.14, the pinned node:http tests left keep-alive connections alive after server.close(), and Readable.fromWeb surfaced a failed client body as an unhandled stream error. The shard then timed out at 10 minutes and contaminated the following account-selection test. The test cleanup now closes active connections before each server shutdown, and the pinned transport reads the web stream directly with backpressure, destroys the upstream request on body failure, and handles the error without leaving a rejected stream unobserved. This preserves the address-pinning security behavior while making cancellation and failure cleanup deterministic. The cleanup is in 93f626c23d; the transport fix is in eeeedb2ab2, both credited to Lawrence Chen's #16165 report.
5. Follow-up review hardening
The final Cubic review identified edge cases in the combined repair and they are fixed in 82b967feb6c: concurrent-index detection now handles UNIQUE and scopes invalid-index cleanup by schema/table; the submodule fallback deepens history in bounded, timed chunks and reports fetch failures; the standalone migration runner observes idle pool errors; Spanish and Russian billing copy follows existing grammar; and pinned request-body cancellation cancels the source reader, including early reader failures.
6. Locale race and final review hardening
The current-head browser lane exposed an existing locale-cookie race: a delayed /ko background response could overwrite an explicit English choice. I incorporated Lawrence Chen's tested approach from #12719, with author credit, by centralizing locale middleware and suppressing inferred locale-cookie writes for background requests while preserving document navigation. The new middleware regression covers RSC, router prefetch, browser prefetch, normalized fetch metadata, document navigation, and unprefixed routes; the browser regression covers an old tab racing a new English selection.
The same final review round adds the migration advisory lock and the bounded fetch/ON ONLY/timeout hardening in 69adeda275d.
History
This PR began as the bonsplit re-pin for the #261 abort, and later also carried the fixes for main's other breaks from the same window. main has since fixed each of those itself:
- bonsplit pin: #15883
- CmuxSettings compile: #16190
- French localization: #16175
- web typecheck: #13322
actionReferenceIDand the.settingsummary case: #16223 and a follow-up- seats-follow-membership billing copy: incorporated from #16265 above
- pinned OpenCode proxy cleanup: repaired the #16165 transport/test regression above
- final review hardening: bounded fetch, migration safety, grammar, and cancellation fixes in
82b967feb6cand69adeda275d - locale-cookie race: adapted from #12719 in
69adeda275d
Those commits merge away with no net diff.
Verification
- Hosted main CI reproduced the billing regression at
web/tests/dashboard-billing-screen.test.tsx:440(1,055 pass, 42 skip, 1 fail) before the fix. python3 scripts/verify-local.py: 15/15 selected portable checks passed; no Swift files selected.python3 scripts/swift_file_length_budget.py: passed (0 changed Swift files).bun test --isolate web/tests/locale-cookie-race.test.ts: 7 pass, 0 fail.git diff --check: passed.python3 -m unittest tests.test_submodule_forward_only: 17 tests passed.python3 scripts/verify-local.py: 15/15 selected portable checks passed; no Swift files selected.python3 scripts/swift_file_length_budget.py: passed (0 changed Swift files).- Localization parity and catalog checks passed;
scripts/localize-changesreports 23,136 pre-existing untranslated rows and 259 pre-existing attention items outside this diff, while the changed locale keys are present across all 20 web catalogs. bunx --bun bun@1.3.14 test --isolate tests/coderouter-opencode-proxy.test.ts: 15 pass, 0 fail.PATH=/tmp/bun-1.3.14/bin:$PATH ./scripts/run-tests.sh --shard 2/4: 1,180 pass, 230 skip, 0 fail under the CI Bun version.
Changelog
none
🤖 Generated with Claude Code
Summary by CodeRabbit
- New Features
- Team subscription costs now adjust automatically as members join or leave, with billing copy updated across supported languages.
- Bug Fixes
- Migration handling now supports retrying migrations that create concurrent indexes and resolving submodule commit relationships in shallow clones.
- Over-seat billing panels no longer show a link to the billing portal.