Skip to content

Commit 4551215

Browse files
committed
fix(server): retain commands during Codex health errors
1 parent fa5488c commit 4551215

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

‎apps/server/src/provider/ProviderRegistry.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,39 @@ it.layer(
669669
{ name: "replacement" },
670670
]);
671671
assert.strictEqual(recovered.workspaceSnapshots?.[0]?.slashCommandsPending, undefined);
672+
673+
const skillOnlySnapshot = {
674+
...scopedSnapshot,
675+
status: "error",
676+
slashCommands: [],
677+
skills: [{ name: "updated", path: "/project/updated/SKILL.md", enabled: true }],
678+
workspaceDiscoverySucceeded: true,
679+
} satisfies ProviderWorkspaceSnapshot;
680+
const skillOnly = ProviderRegistry.upsertProviderWorkspaceSnapshot(
681+
recovered,
682+
"/project",
683+
skillOnlySnapshot,
684+
);
685+
assert.deepStrictEqual(
686+
skillOnly.workspaceSnapshots?.[0]?.slashCommands,
687+
recovered.workspaceSnapshots?.[0]?.slashCommands,
688+
);
689+
assert.deepStrictEqual(skillOnly.workspaceSnapshots?.[0]?.skills, skillOnlySnapshot.skills);
690+
const emptied = ProviderRegistry.upsertProviderWorkspaceSnapshot(skillOnly, "/project", {
691+
...skillOnlySnapshot,
692+
skills: [],
693+
});
694+
assert.deepStrictEqual(
695+
emptied.workspaceSnapshots?.[0]?.slashCommands,
696+
recovered.workspaceSnapshots?.[0]?.slashCommands,
697+
);
698+
assert.deepStrictEqual(emptied.workspaceSnapshots?.[0]?.skills, []);
699+
const healthyEmpty = ProviderRegistry.upsertProviderWorkspaceSnapshot(emptied, "/project", {
700+
...skillOnlySnapshot,
701+
status: "ready",
702+
skills: [],
703+
});
704+
assert.deepStrictEqual(healthyEmpty.workspaceSnapshots?.[0]?.slashCommands, []);
672705
});
673706

674707
it("preserves previously discovered provider models when a refresh returns none", () => {

‎apps/server/src/provider/ProviderRegistry.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,13 @@ export function upsertProviderWorkspaceSnapshot(
186186
cwd: string,
187187
scopedSnapshot: ProviderWorkspaceSnapshot,
188188
): ServerProvider {
189+
const preserveSlashCommands =
190+
scopedSnapshot.slashCommandsPending ||
191+
(scopedSnapshot.status === "error" && scopedSnapshot.workspaceDiscoverySucceeded);
189192
const workspaceSnapshot = {
190193
cwd,
191194
checkedAt: scopedSnapshot.checkedAt,
192-
slashCommands: scopedSnapshot.slashCommandsPending
195+
slashCommands: preserveSlashCommands
193196
? (provider.workspaceSnapshots?.find((snapshot) => snapshot.cwd === cwd)?.slashCommands ??
194197
scopedSnapshot.slashCommands)
195198
: scopedSnapshot.slashCommands,

0 commit comments

Comments
 (0)