(onDone: LocalJSXCommandOnDone, context: LocalJSXCommandContext, args: string)
| 62 | return t5; |
| 63 | } |
| 64 | export async function call(onDone: LocalJSXCommandOnDone, context: LocalJSXCommandContext, args: string): Promise<React.ReactNode> { |
| 65 | const { |
| 66 | getAppState, |
| 67 | setAppState |
| 68 | } = context; |
| 69 | const appState = getAppState(); |
| 70 | const currentMode = appState.toolPermissionContext.mode; |
| 71 | |
| 72 | // If not in plan mode, enable it |
| 73 | if (currentMode !== 'plan') { |
| 74 | handlePlanModeTransition(currentMode, 'plan'); |
| 75 | setAppState(prev => ({ |
| 76 | ...prev, |
| 77 | toolPermissionContext: applyPermissionUpdate(prepareContextForPlanMode(prev.toolPermissionContext), { |
| 78 | type: 'setMode', |
| 79 | mode: 'plan', |
| 80 | destination: 'session' |
| 81 | }) |
| 82 | })); |
| 83 | const description = args.trim(); |
| 84 | if (description && description !== 'open') { |
| 85 | onDone('Enabled plan mode', { |
| 86 | shouldQuery: true |
| 87 | }); |
| 88 | } else { |
| 89 | onDone('Enabled plan mode'); |
| 90 | } |
| 91 | return null; |
| 92 | } |
| 93 | |
| 94 | // Already in plan mode - show the current plan |
| 95 | const planContent = getPlan(); |
| 96 | const planPath = getPlanFilePath(); |
| 97 | if (!planContent) { |
| 98 | onDone('Already in plan mode. No plan written yet.'); |
| 99 | return null; |
| 100 | } |
| 101 | |
| 102 | // If user typed "/plan open", open in editor |
| 103 | const argList = args.trim().split(/\s+/); |
| 104 | if (argList[0] === 'open') { |
| 105 | const result = await editFileInEditor(planPath); |
| 106 | if (result.error) { |
| 107 | onDone(`Failed to open plan in editor: ${result.error}`); |
| 108 | } else { |
| 109 | onDone(`Opened plan in editor: ${planPath}`); |
| 110 | } |
| 111 | return null; |
| 112 | } |
| 113 | const editor = getExternalEditor(); |
| 114 | const editorName = editor ? toIDEDisplayName(editor) : undefined; |
| 115 | const display = <PlanDisplay planContent={planContent} planPath={planPath} editorName={editorName} />; |
| 116 | |
| 117 | // Render to string and pass to onDone like local commands do |
| 118 | const output = await renderToString(display); |
| 119 | onDone(output); |
| 120 | return null; |
| 121 | } |
nothing calls this directly
no test coverage detected