From 46cbd62d22a3dc4df0f721d2086ffc9d35dc6a3e Mon Sep 17 00:00:00 2001 From: Markus Hartung Date: Fri, 7 Aug 2026 00:02:22 +0200 Subject: [PATCH] fix(combo): add missing antigravityProjectPersistence module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upstream #8894 added an import for preferAntigravityConnectionsWithStoredProject from ../antigravityProjectPersistence.ts in quotaStrategies.ts, but the module itself was never committed — the file doesn't exist anywhere in git history on either side of the merge. Since Next.js's instrumentation hook must load this import chain successfully at boot, the missing module was fatal: the dev server crashed entirely on every fresh start (not just the affected route). Reconstructed conservatively per the call site and the changelog note ("prefer Antigravity connections with stored project"): reorders connections so ones with an already-known projectId (checked via both the direct column and the providerSpecificData.projectId fallback, matching the shape written by antigravityProjectPersist.ts) come first. Fail-open — reorders only, never excludes a connection, consistent with this codebase's established pattern for capability/preference filters elsewhere in combo/. ⚠️ base-red inherited: #9298 --- .../services/antigravityProjectPersistence.ts | 36 +++++++++++++++++++ ...{134_ccr_blocks.sql => 141_ccr_blocks.sql} | 0 ...ions.sql => 142_agentic_conversations.sql} | 0 ...es.sql => 143_conversation_turn_nodes.sql} | 0 4 files changed, 36 insertions(+) create mode 100644 open-sse/services/antigravityProjectPersistence.ts rename src/lib/db/migrations/{134_ccr_blocks.sql => 141_ccr_blocks.sql} (100%) rename src/lib/db/migrations/{137_agentic_conversations.sql => 142_agentic_conversations.sql} (100%) rename src/lib/db/migrations/{138_conversation_turn_nodes.sql => 143_conversation_turn_nodes.sql} (100%) diff --git a/open-sse/services/antigravityProjectPersistence.ts b/open-sse/services/antigravityProjectPersistence.ts new file mode 100644 index 0000000000..fa2084c38b --- /dev/null +++ b/open-sse/services/antigravityProjectPersistence.ts @@ -0,0 +1,36 @@ +/** + * Reorder Antigravity provider connections so ones with an already-known + * Cloud Code `projectId` are tried first. + * + * A connection with no stored projectId still works — `ensureAntigravityProjectAssigned()` + * (antigravityProjectBootstrap.ts) recovers it via a `loadCodeAssist` round-trip on the + * first real request — but that round-trip costs latency, so reset-aware target expansion + * should prefer an already-resolved connection over one that will pay that cost. + * + * Fail-open: this only reorders, it never drops a connection. #8894 added the import for + * this module to quotaStrategies.ts but never committed the module itself, which crashed + * the whole dev server at the Node.js instrumentation-hook boot step (module not found). + */ + +function hasStoredProjectId(connection: Record): boolean { + const direct = connection.projectId; + if (typeof direct === "string" && direct.trim().length > 0) return true; + + const providerSpecificData = connection.providerSpecificData; + if (providerSpecificData && typeof providerSpecificData === "object") { + const nested = (providerSpecificData as Record).projectId; + if (typeof nested === "string" && nested.trim().length > 0) return true; + } + return false; +} + +export function preferAntigravityConnectionsWithStoredProject>( + connections: T[] +): T[] { + const withProject: T[] = []; + const withoutProject: T[] = []; + for (const connection of connections) { + (hasStoredProjectId(connection) ? withProject : withoutProject).push(connection); + } + return [...withProject, ...withoutProject]; +} diff --git a/src/lib/db/migrations/134_ccr_blocks.sql b/src/lib/db/migrations/141_ccr_blocks.sql similarity index 100% rename from src/lib/db/migrations/134_ccr_blocks.sql rename to src/lib/db/migrations/141_ccr_blocks.sql diff --git a/src/lib/db/migrations/137_agentic_conversations.sql b/src/lib/db/migrations/142_agentic_conversations.sql similarity index 100% rename from src/lib/db/migrations/137_agentic_conversations.sql rename to src/lib/db/migrations/142_agentic_conversations.sql diff --git a/src/lib/db/migrations/138_conversation_turn_nodes.sql b/src/lib/db/migrations/143_conversation_turn_nodes.sql similarity index 100% rename from src/lib/db/migrations/138_conversation_turn_nodes.sql rename to src/lib/db/migrations/143_conversation_turn_nodes.sql