Skip to content

Commit 7f4d0ef

Browse files
committed
fix(opencode): keep commands pending when an OpenCode 2 scan times out
1 parent 9ce3d80 commit 7f4d0ef

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎packages/provider-opencode/src/server/driver.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,34 @@ it.layer(layer)("OpenCodeDriver runtime selection", (it) => {
117117
}).pipe(Effect.scoped),
118118
);
119119

120+
it.effect("keeps an OpenCode 2 workspace's commands pending when its scan never ends", () =>
121+
Effect.gen(function* () {
122+
const instance = yield* create(
123+
{ serverUrl: "http://127.0.0.1:4096", serverPassword: "secret" },
124+
replayOpenCodeServer(
125+
{
126+
...OPENCODE_2_RESPONSES,
127+
...OPENCODE_2_WORKSPACE_RESPONSES,
128+
"/api/command": {
129+
...OPENCODE_2_WORKSPACE_RESPONSES["/api/command"],
130+
body: '{"location":{"directory":"/work"},"data":[]}',
131+
},
132+
},
133+
"secret",
134+
),
135+
);
136+
137+
const scan = yield* instance.snapshotForCwd!("/work").pipe(Effect.forkChild);
138+
yield* TestClock.adjust("10 seconds");
139+
const workspace = yield* Fiber.join(scan);
140+
assert.includeMembers(
141+
workspace.skills.map((skill) => skill.name),
142+
["plum"],
143+
);
144+
assert.strictEqual(workspace.slashCommandsPending, true);
145+
}).pipe(Effect.scoped, Effect.provide(TestClock.layer())),
146+
);
147+
120148
it.effect("keeps an OpenCode 1.x workspace's commands pending when listing them fails", () =>
121149
Effect.gen(function* () {
122150
const openCode1Runtime = {

‎packages/provider-opencode/src/server/driver.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,9 @@ export const OpenCodeDriver: ProviderDriver<
525525
...machineSnapshot,
526526
skills: openCode2SkillsToServerProviderSkills(skills),
527527
slashCommands: openCode2CommandsToServerProviderSlashCommands(commands),
528-
slashCommandsPending: false,
528+
// A finished scan lists at least the built-ins. None means it
529+
// timed out, so the registry keeps the last ones and rescans.
530+
slashCommandsPending: commands.length === 0,
529531
})),
530532
),
531533
v1: Effect.all([

0 commit comments

Comments
 (0)