The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 19:30 UTC
fix(opencode): cancelled todos no longer keep the todo list running (#22938)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
MarcoDotIO committed
Oct 21, 2026 at 18:14 UTC
2333f168845f853f9ef358d1c4e6cf75189f4e8b
2 files changed
+75
-11
packages/provider-opencode/src/server/adapter.test.ts
+56
@@ -840,6 +840,62 @@ describe("OpenCodeAdapterV2", () => {
840
),
841
);
842
843
+ it.effect("drops cancelled OpenCode todos so a finished list completes", () =>
844
+ Effect.gen(function* () {
845
+ const nativeEvents = asyncEventStream();
846
+ const nativeSessionId = "native-opencode-todos";
847
+ const harness = yield* makeOpenCodeRuntimeHarness("todos", nativeSessionId, {
848
+ event: {
849
+ subscribe: async (_input: unknown, options: { signal?: AbortSignal }) => {
850
+ options.signal?.addEventListener("abort", () => nativeEvents.close(), { once: true });
851
+ return { stream: nativeEvents.stream };
852
+ },
853
+ },
854
+ mcp: { status: async () => ({ data: {} }) },
855
+ session: {
856
+ create: async () => ({
857
+ data: { id: nativeSessionId, time: { created: 1, updated: 1 } },
858
+ }),
859
+ promptAsync: async () => ({ data: true }),
860
+ },
861
+ });
862
+ yield* harness.startTurn();
863
+ const received = yield* harness.runtime.events.pipe(
864
+ Stream.takeUntil((event) => event.type === "plan.updated"),
865
+ Stream.runCollect,
866
+ Effect.forkScoped,
867
+ );
868
+ yield* Effect.promise(() =>
869
+ nativeEvents.push({
870
+ type: "todo.updated",
871
+ properties: {
872
+ sessionID: nativeSessionId,
873
+ todos: [
874
+ { content: "Write the fix", status: "completed", priority: "high" },
875
+ { content: "Try another approach", status: "cancelled", priority: "low" },
876
+ { content: "Add a test", status: "completed", priority: "medium" },
877
+ ],
878
+ },
879
+ }),
880
+ );
881
+ const plan = (yield* Fiber.join(received)).flatMap((event) =>
882
+ event.type === "plan.updated" ? [event.plan] : [],
883
+ )[0];
884
+ assert.ok(plan?.kind === "todo_list");
885
+ assert.deepEqual(
886
+ plan.steps.map((step) => ({ text: step.text, status: step.status })),
887
+ [
888
+ { text: "Write the fix", status: "completed" },
889
+ { text: "Add a test", status: "completed" },
890
+ ],
891
+ );
892
+ assert.equal(plan.status, "completed");
893
+ }).pipe(
894
+ Effect.provide(Layer.merge(IdAllocator.layer, McpProviderSessions.layer)),
895
+ Effect.scoped,
896
+ ),
897
+ );
898
+
899
it.effect("presents OpenCode MCP calls without treating remote tools as local edits", () =>
900
Effect.gen(function* () {
901
const output =
packages/provider-opencode/src/server/adapter.ts
+19
-11
@@ -1665,17 +1665,25 @@ export const makeOpenCodeAdapterV2 = Effect.fn("makeOpenCodeAdapterV2")(function
1665
driver: OPENCODE_PROVIDER,
1666
nativeItemId,
1667
});
1668
- const steps: Array<OrchestrationV2PlanStep> = todos.map((todo, index) => ({
1669
- id: `${nativeItemId}:${index + 1}`,
1670
- text: todo.content.trim() || `Todo ${index + 1}`,
1671
- status:
1672
- todo.status === "completed"
1673
- ? "completed"
1674
- : todo.status === "in_progress"
1675
- ? "running"
1676
- : "pending",
1677
- }));
1678
- const completed = steps.length > 0 && steps.every((step) => step.status === "completed");
1668
+ // A cancelled todo is not outstanding work, and plan steps have no
1669
+ // cancelled status, so drop it rather than show it as pending.
1670
+ const steps: Array<OrchestrationV2PlanStep> = todos.flatMap((todo, index) =>
1671
+ todo.status === "cancelled"
1672
+ ? []
1673
+ : [
1674
+ {
1675
+ id: `${nativeItemId}:${index + 1}`,
1676
+ text: todo.content.trim() || `Todo ${index + 1}`,
1677
+ status:
1678
+ todo.status === "completed"
1679
+ ? "completed"
1680
+ : todo.status === "in_progress"
1681
+ ? "running"
1682
+ : "pending",
1683
+ },
1684
+ ],
1685
+ );
1686
+ const completed = todos.length > 0 && steps.every((step) => step.status === "completed");
1687
yield* emitProviderEvent({
1688
type: "node.updated",
1689
driver: OPENCODE_PROVIDER,