(host: SlashCommandHost, args: string)
| 46 | } |
| 47 | |
| 48 | export async function handlePlanCommand(host: SlashCommandHost, args: string): Promise<void> { |
| 49 | const session = host.session; |
| 50 | if (session === undefined) { |
| 51 | host.showError(NO_ACTIVE_SESSION_MESSAGE); |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | const subcmd = args.trim().toLowerCase(); |
| 56 | if (subcmd === 'clear') { |
| 57 | await session.clearPlan(); |
| 58 | host.showNotice('Plan cleared'); |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | let enabled: boolean; |
| 63 | if (subcmd.length === 0) enabled = !host.state.appState.planMode; |
| 64 | else if (subcmd === 'on') enabled = true; |
| 65 | else if (subcmd === 'off') enabled = false; |
| 66 | else { |
| 67 | host.showError(`Unknown plan subcommand: ${subcmd}`); |
| 68 | return; |
| 69 | } |
| 70 | |
| 71 | await applyPlanMode(host, session, enabled); |
| 72 | } |
| 73 | |
| 74 | async function applyPlanMode(host: SlashCommandHost, session: Session, enabled: boolean): Promise<void> { |
| 75 | try { |
no test coverage detected