refactor(opencode): stop legacy v2 event emission (#33993)
This commit is contained in:
@@ -8,7 +8,7 @@ import { FetchHttpClient } from "effect/unstable/http"
|
||||
import { expect } from "bun:test"
|
||||
import { Cause, Deferred, Duration, Effect, Exit, Fiber, Layer } from "effect"
|
||||
import path from "path"
|
||||
import { fileURLToPath, pathToFileURL } from "url"
|
||||
import { fileURLToPath } from "url"
|
||||
import { NamedError } from "@opencode-ai/core/util/error"
|
||||
import { Agent as AgentSvc } from "../../src/agent/agent"
|
||||
import { BackgroundJob } from "@/background/job"
|
||||
@@ -317,11 +317,6 @@ const writeText = Effect.fn("test.writeText")(function* (file: string, text: str
|
||||
yield* fs.writeWithDirs(file, text)
|
||||
})
|
||||
|
||||
const ensureDir = Effect.fn("test.ensureDir")(function* (dir: string) {
|
||||
const fs = yield* FSUtil.Service
|
||||
yield* fs.ensureDir(dir)
|
||||
})
|
||||
|
||||
const writeConfig = Effect.fn("test.writeConfig")(function* (dir: string, config: Partial<ConfigV1.Info>) {
|
||||
yield* writeText(
|
||||
path.join(dir, "opencode.json"),
|
||||
@@ -554,6 +549,54 @@ withMcpInstructions.instance(
|
||||
15_000,
|
||||
)
|
||||
|
||||
it.instance("legacy prompt emits message events without session.next events", () =>
|
||||
Effect.gen(function* () {
|
||||
const events = yield* EventV2Bridge.Service
|
||||
const prompt = yield* SessionPrompt.Service
|
||||
const sessions = yield* Session.Service
|
||||
const chat = yield* sessions.create({
|
||||
title: "Pinned",
|
||||
agent: "plan",
|
||||
model: { providerID: ProviderV2.ID.make("old"), id: ModelV2.ID.make("old-model") },
|
||||
})
|
||||
const seen: string[] = []
|
||||
const off = yield* events.listen((event) => {
|
||||
seen.push(event.type)
|
||||
return Effect.void
|
||||
})
|
||||
|
||||
const first = yield* prompt.prompt({
|
||||
sessionID: chat.id,
|
||||
agent: "build",
|
||||
model: ref,
|
||||
noReply: true,
|
||||
parts: [{ type: "text", text: "hello" }],
|
||||
})
|
||||
const second = yield* prompt.prompt({
|
||||
sessionID: chat.id,
|
||||
agent: "build",
|
||||
noReply: true,
|
||||
parts: [{ type: "text", text: "again" }],
|
||||
})
|
||||
yield* off
|
||||
|
||||
expect(first.info.role).toBe("user")
|
||||
expect(second.info.role).toBe("user")
|
||||
if (first.info.role === "user" && second.info.role === "user") {
|
||||
expect(first.info.model).toEqual(ref)
|
||||
expect(second.info.model).toEqual(ref)
|
||||
}
|
||||
expect(yield* sessions.get(chat.id)).toMatchObject({
|
||||
agent: "build",
|
||||
model: { providerID: ref.providerID, id: ref.modelID },
|
||||
})
|
||||
expect(seen).toContain(Session.Event.Updated.type)
|
||||
expect(seen).toContain(MessageV2.Event.Updated.type)
|
||||
expect(seen).toContain(MessageV2.Event.PartUpdated.type)
|
||||
expect(seen.filter((type) => type.startsWith("session.next."))).toEqual([])
|
||||
}),
|
||||
)
|
||||
|
||||
it.instance("loop surfaces content-filter finishes as session errors", () =>
|
||||
Effect.gen(function* () {
|
||||
const { llm } = yield* useServerConfig(providerCfg)
|
||||
|
||||
Reference in New Issue
Block a user