Skip to content

Commit 0a65672

Browse files
committed
fix($skill): SDK method fallback for skill list bootstrap
Code review pass #3 fix: sdk.app.skills() may not exist if SDK wasn't regenerated with /skill endpoint. Added typeof check with raw fetch() fallback. .catch(() => {}) ensures graceful degradation to empty state in popover.
1 parent cf9f5cd commit 0a65672

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/app/src/context/global-sync/bootstrap.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,12 @@ export async function bootstrapDirectory(input: {
152152
input.sdk.path.get().then((x) => input.setStore("path", x.data!)),
153153
input.sdk.command.list().then((x) => input.setStore("command", x.data ?? [])),
154154
// Load available skills for $ popover (non-blocking — popover shows empty state until loaded)
155-
input.sdk.app.skills().then((x) => input.setStore("skill", x.data ?? [])).catch(() => {}),
155+
// Code review fix: sdk.app.skills() may not exist if SDK wasn't regenerated with /skill endpoint.
156+
// Fallback to raw fetch if method doesn't exist. .catch() ensures graceful degradation.
157+
(typeof input.sdk.app.skills === "function"
158+
? input.sdk.app.skills().then((x) => input.setStore("skill", x.data ?? []))
159+
: fetch(`${input.sdk.baseUrl ?? ""}/skill`).then((r) => r.json()).then((data) => input.setStore("skill", data ?? []))
160+
).catch(() => {}),
156161
input.sdk.session.status().then((x) => input.setStore("session_status", x.data!)),
157162
input.loadSessions(input.directory),
158163
input.sdk.mcp.status().then((x) => input.setStore("mcp", x.data!)),

0 commit comments

Comments
 (0)