mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-11 14:00:29 +00:00
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:
@@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user