From 304d4fa90f59f3f7ca6334e40d7ec6418262f2b7 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Thu, 11 Jun 2026 15:00:15 +0100 Subject: [PATCH] Stop slash menu printing disabled-reasons on enabled commands The availability map computes a fall-through reason string for every command whether or not it is disabled, and commandWithAvailability copied it through unconditionally. Enabled menu items then displayed false statements: '/fork ... Forking is already running.', '/copy ... Requires transcript content.' on a session with a full transcript. Carry the reason only when the command is actually disabled. --- .../__tests__/assistantSlashCommands.test.ts | 17 +++++++++++++++++ .../AI/Chat/assistantSlashCommands.ts | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/frontend-modern/src/components/AI/Chat/__tests__/assistantSlashCommands.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/assistantSlashCommands.test.ts index ee0822325..d4e4eb1e6 100644 --- a/frontend-modern/src/components/AI/Chat/__tests__/assistantSlashCommands.test.ts +++ b/frontend-modern/src/components/AI/Chat/__tests__/assistantSlashCommands.test.ts @@ -218,6 +218,23 @@ describe('assistantSlashCommands', () => { ); }); + it('drops the availability reason hint on enabled commands', () => { + const commands = filterAssistantSlashCommands('compact', undefined, { + availability: { + compact: { + disabled: false, + // The availability map always computes a fall-through reason; an + // enabled command must not display it as a false statement. + reason: 'Unavailable while another session action is running.', + }, + }, + }); + + expect(commands).toHaveLength(1); + expect(commands[0].disabled).toBe(false); + expect(commands[0].disabledReason).toBeUndefined(); + }); + it('exposes canonical and alias tokens for the picker', () => { const help = filterAssistantSlashCommands('commands')[0]; expect(getAssistantSlashCommandTokens(help)).toEqual(['help', 'commands']); diff --git a/frontend-modern/src/components/AI/Chat/assistantSlashCommands.ts b/frontend-modern/src/components/AI/Chat/assistantSlashCommands.ts index a3a20a30d..c8868ab29 100644 --- a/frontend-modern/src/components/AI/Chat/assistantSlashCommands.ts +++ b/frontend-modern/src/components/AI/Chat/assistantSlashCommands.ts @@ -248,7 +248,10 @@ const commandWithAvailability = ( return { ...command, disabled: state.disabled, - disabledReason: state.reason, + // The availability map computes a fall-through reason even when the + // command is enabled; carrying it through made the menu show false + // statements like "Forking is already running." on enabled commands. + disabledReason: state.disabled ? state.reason : undefined, }; };