The best way to control Claude Code, Codex and more from any computer or phone
fix(opencode): /goal clear with no goal set finishes as a no-op (#35893)
Julius Marminge committed
Nov 12, 2026 at 19:37 UTC
e726a0898a53b8bf3a119357b8d5e34a45392580
2 files changed
+34
-3
apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts
+24
@@ -7526,6 +7526,30 @@ it.layer(McpProviderSessions.layer)("OpenCode2 adapter", (it) => {
7526
}).pipe(Effect.scoped),
7527
);
7528
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
+
7553
it.effect("reads an existing OpenCode 2.2.5 goal when resuming a session", () =>
7554
Effect.gen(function* () {
7555
const runtime = yield* openCode2ReplayRuntime(
packages/provider-opencode/src/server/v2/adapter.ts
+10
-3
@@ -4488,11 +4488,18 @@ export const make = Effect.fn("OpenCode2Adapter.make")(function* (instanceId: Pr
4488
const newest = yield* client.message.list({ sessionID, order: "desc", limit: 1 });
4489
yield* markBefore(sessionId, newest.data[0]?.id ?? null);
4490
if (!sending()) return;
4491
- yield* client.session.command({ sessionID, ...command });
4491
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;
4501
}
4495
- return;
4502
+ return yield* client.session.command({ sessionID, ...command }).pipe(Effect.asVoid);
4503
}
4504
}
4505
const mentions = skillMentions(text);