Skip to content

Commit e726a08

Browse files
fix(opencode): /goal clear with no goal set finishes as a no-op (pingdotgg#35893)
1 parent 6f108e8 commit e726a08

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7526,6 +7526,30 @@ it.layer(McpProviderSessions.layer)("OpenCode2 adapter", (it) => {
75267526
}).pipe(Effect.scoped),
75277527
);
75287528

7529+
// regression: #35872
7530+
it.effect("completes /goal clear when OpenCode has no goal to clear", () =>
7531+
Effect.gen(function* () {
7532+
const { runtime, thread } = yield* resumed(
7533+
[
7534+
out("command.list", "<any>"),
7535+
reply("command.list", { location: { directory: WORK }, data: [{ name: "goal" }] }),
7536+
out("message.list", { sessionID: SESSION, order: "desc", limit: "1" }),
7537+
reply("message.list", { data: [], cursor: {} }),
7538+
out("session.command", { sessionID: SESSION, name: "goal", text: "clear" }),
7539+
reply("session.command", {
7540+
status: 500,
7541+
body: { _tag: "CommandExecutionError", command: "goal", message: "No goal is set." },
7542+
}),
7543+
],
7544+
{ version: "2.2.5" },
7545+
);
7546+
const terminal = yield* terminalOf(runtime).pipe(Effect.forkScoped);
7547+
const input = turnInput(thread);
7548+
yield* runtime.startTurn({ ...input, message: { ...input.message, text: "/goal clear" } });
7549+
assert.equal((yield* Fiber.join(terminal))?.status, "completed");
7550+
}).pipe(Effect.scoped),
7551+
);
7552+
75297553
it.effect("reads an existing OpenCode 2.2.5 goal when resuming a session", () =>
75307554
Effect.gen(function* () {
75317555
const runtime = yield* openCode2ReplayRuntime(

‎packages/provider-opencode/src/server/v2/adapter.ts‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4488,11 +4488,18 @@ export const make = Effect.fn("OpenCode2Adapter.make")(function* (instanceId: Pr
44884488
const newest = yield* client.message.list({ sessionID, order: "desc", limit: 1 });
44894489
yield* markBefore(sessionId, newest.data[0]?.id ?? null);
44904490
if (!sending()) return;
4491-
yield* client.session.command({ sessionID, ...command });
44924491
if (goalCommand?.type === "pause" || goalCommand?.type === "clear") {
4493-
yield* finishControl;
4492+
// OpenCode rejects pausing or clearing a missing goal; Codex treats that as a no-op.
4493+
yield* client.session.command({ sessionID, ...command }).pipe(
4494+
Effect.catchIf(
4495+
(error) =>
4496+
error._tag === "CommandExecutionError" && error.message === "No goal is set.",
4497+
() => Effect.void,
4498+
),
4499+
);
4500+
return yield* finishControl;
44944501
}
4495-
return;
4502+
return yield* client.session.command({ sessionID, ...command }).pipe(Effect.asVoid);
44964503
}
44974504
}
44984505
const mentions = skillMentions(text);

0 commit comments

Comments
 (0)