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.
This commit is contained in:
rcourtman
2026-06-11 15:00:15 +01:00
parent 3f37da8b17
commit 304d4fa90f
2 changed files with 21 additions and 1 deletions
@@ -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']);
@@ -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,
};
};