fix: defer catalog validation to session execution (#38258)

This commit is contained in:
Simon Klee 2026-07-22 10:32:52 +02:00 committed by GitHub
commit 8bb1cfaa3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 229 additions and 304 deletions

View file

@ -1,6 +1,6 @@
import { afterEach, describe, expect, mock, spyOn, test } from "bun:test"
import { OpenCode } from "@opencode-ai/client/promise"
import { loadRunReferences, runProviders, waitForDefaultModel } from "../../src/mini/catalog.shared"
import { loadRunReferences, runProviders } from "../../src/mini/catalog.shared"
import { catalogModel, catalogProvider } from "./fixture/catalog"
afterEach(() => {
@ -8,26 +8,6 @@ afterEach(() => {
})
describe("run catalog shared", () => {
test("resolves the catalog-selected model for the footer", async () => {
const client = OpenCode.make({ baseUrl: "https://opencode.test" })
const selected = spyOn(client.model, "default").mockImplementation(
() =>
Promise.resolve({
location: { directory: "/tmp", project: { id: "proj_1", directory: "/tmp" } },
data: { id: "gpt-5", providerID: "openai" },
}) as never,
)
await expect(waitForDefaultModel({ sdk: client, location: { directory: "/tmp" } })).resolves.toEqual({
providerID: "openai",
modelID: "gpt-5",
})
expect(selected).toHaveBeenCalledWith(
{ location: { directory: "/tmp", workspace: undefined } },
{ signal: expect.any(AbortSignal) },
)
})
test("loads visible project references from the current reference catalog", async () => {
const client = OpenCode.make({ baseUrl: "https://opencode.test" })
const list = spyOn(client.reference, "list").mockImplementation(

View file

@ -195,6 +195,16 @@ async function renderFooter(
}
}
test("direct footer shows the generic default model before resolution", async () => {
const app = await renderFooter({ state: { model: "Default model" } })
try {
await app.renderOnce()
expect(app.captureCharFrame()).toContain("Default model")
} finally {
app.cleanup()
}
})
test("direct footer preserves a partial multi-field form draft across permission preemption", async () => {
const request: FormInfo = {
id: "frm_preempted",