Fix duplicate slash alias crash - #805
giattijunior wants to merge 1 commit into
Conversation
Greptile SummaryThis PR fixes a renderer crash that occurred when the backend command catalog exposed the same name (e.g.,
Confidence Score: 4/5The change is safe to merge; it eliminates a real crash with minimal surface area, and the new test directly reproduces the failure scenario. The crash fix is correct and well-scoped. Two minor concerns: (1) the silent The Important Files Changed
|
| if (byName.has(aliasKey) || aliases.has(aliasKey)) { | ||
| throw new Error(`Duplicate slash command alias: /${aliasKey}`); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Silent alias-vs-alias conflict silently drops second mapping
The early return now fires both when the alias key collides with a canonical command (the intended fix) and when it collides with an already-registered alias pointing to a different target. In the second case — e.g., if agent commands and desktop commands each define "/r" → different targets — the second registration silently loses with no observable feedback. The upstream agentCommandsFromCatalog protects against this today because Object.entries de-dupes object keys, but future callers that supply aliases from two independent sources could hit it and get the wrong resolution without any warning. A dev-mode console.warn on the aliases.has(aliasKey) branch would make this detectable.
|
Thanks for tracking this down and for the regression test — the diagnosis of the This has since been fixed on We deliberately kept the fix out of Closing as superseded by #808. Thanks again for the report and the clean repro — it helped confirm the fix covers this exact case. |
Fix duplicate slash alias crash when agent catalog includes
/compactSummary
The renderer crashed when the backend command catalog exposed
/compactboth as:pairscompact -> compressincanoncreateSlashCatalog()registered the command first, thenregisterAlias()threwDuplicate slash command alias: /compact, which broke the Chat screen on connection.Fix
Ignore duplicate alias registrations when the canonical command is already present instead of throwing.
Validation
pairs: /compact, /compresspluscanon: compact -> compressnpm test -- src/renderer/src/screens/Chat/slash/commandCatalog.test.tsResult:
1 passed,4 passed