Skip to content

fix(agent): guard undefined availableCommands in useAcpSlashCommands - #165

Merged
Yuqing (mydmdm) merged 1 commit into
mainfrom
fix/issue-164
Sep 7, 2026
Merged

fix(agent): guard undefined availableCommands in useAcpSlashCommands#165
Yuqing (mydmdm) merged 1 commit into
mainfrom
fix/issue-164

Conversation

@mydmdm

Copy link
Copy Markdown
Contributor

Fixes #164

Root cause

useAcpSlashCommands.ts called setCommands(response.availableCommands) without a fallback. GET /threads/:threadId/cached-meta can return a body where availableCommands is entirely absent (a live ACP session entry that hasn't populated it yet serializes without the key), so commands became undefined and a later .length read crashed CanvasPage with an uncaught TypeError. No route-level error boundary exists, so the whole Space became unopenable.

Fix

Default to [] when the field is missing: setCommands(response.availableCommands ?? []).

Testing

  • Added a regression test in useAcpSlashCommands.test.tsx covering a cached-meta response without availableCommands.
  • pnpm --dir apps/web exec vitest run src/hooks/useAcpSlashCommands.test.tsx — 3/3 pass.
  • pnpm typecheck — clean.
  • pnpm format / pnpm lint:fix — no changes beyond the fix itself.

The cached-meta response can omit `availableCommands` entirely (a live
ACP session entry that hasn't populated the field yet is serialized
without the key), even though the response type declares it
non-optional. `setCommands(response.availableCommands)` then set
`commands` to `undefined`, and a later `.length` read crashed
CanvasPage with an uncaught TypeError and no error boundary, making
the whole Space unopenable.

Default to `[]` when the field is missing, and add a regression test
covering a response without `availableCommands`.

Fixes #164

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mydmdm
Yuqing (mydmdm) merged commit d83dfde into main Sep 7, 2026
5 checks passed
@mydmdm
Yuqing (mydmdm) deleted the fix/issue-164 branch September 7, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent question node crashes canvas: useAcpSlashCommands doesn't guard undefined availableCommands

1 participant