(onDone: (result?: string, options?: {
display?: CommandResultDisplay;
}) => void, context: LocalJSXCommandContext, args: string)
| 417 | return null; |
| 418 | } |
| 419 | export async function call(onDone: (result?: string, options?: { |
| 420 | display?: CommandResultDisplay; |
| 421 | }) => void, context: LocalJSXCommandContext, args: string): Promise<React.ReactNode | null> { |
| 422 | logEvent('tengu_ext_ide_command', {}); |
| 423 | const { |
| 424 | options: { |
| 425 | dynamicMcpConfig |
| 426 | }, |
| 427 | onChangeDynamicMcpConfig |
| 428 | } = context; |
| 429 | |
| 430 | // Handle 'open' argument |
| 431 | if (args?.trim() === 'open') { |
| 432 | const worktreeSession = getCurrentWorktreeSession(); |
| 433 | const targetPath = worktreeSession ? worktreeSession.worktreePath : getCwd(); |
| 434 | |
| 435 | // Detect available IDEs |
| 436 | const detectedIDEs = await detectIDEs(true); |
| 437 | const availableIDEs = detectedIDEs.filter(ide => ide.isValid); |
| 438 | if (availableIDEs.length === 0) { |
| 439 | onDone('No IDEs with Claude Code extension detected.'); |
| 440 | return null; |
| 441 | } |
| 442 | |
| 443 | // Return IDE selection component |
| 444 | return <IDEOpenSelection availableIDEs={availableIDEs} onSelectIDE={async (selectedIDE?: DetectedIDEInfo) => { |
| 445 | if (!selectedIDE) { |
| 446 | onDone('No IDE selected.'); |
| 447 | return; |
| 448 | } |
| 449 | |
| 450 | // Try to open the project in the selected IDE |
| 451 | if (selectedIDE.name.toLowerCase().includes('vscode') || selectedIDE.name.toLowerCase().includes('cursor') || selectedIDE.name.toLowerCase().includes('windsurf')) { |
| 452 | // VS Code-based IDEs |
| 453 | const { |
| 454 | code |
| 455 | } = await execFileNoThrow('code', [targetPath]); |
| 456 | if (code === 0) { |
| 457 | onDone(`Opened ${worktreeSession ? 'worktree' : 'project'} in ${chalk.bold(selectedIDE.name)}`); |
| 458 | } else { |
| 459 | onDone(`Failed to open in ${selectedIDE.name}. Try opening manually: ${targetPath}`); |
| 460 | } |
| 461 | } else if (isSupportedJetBrainsTerminal()) { |
| 462 | // JetBrains IDEs - they usually open via their CLI tools |
| 463 | onDone(`Please open the ${worktreeSession ? 'worktree' : 'project'} manually in ${chalk.bold(selectedIDE.name)}: ${targetPath}`); |
| 464 | } else { |
| 465 | onDone(`Please open the ${worktreeSession ? 'worktree' : 'project'} manually in ${chalk.bold(selectedIDE.name)}: ${targetPath}`); |
| 466 | } |
| 467 | }} onDone={() => { |
| 468 | onDone('Exited without opening IDE', { |
| 469 | display: 'system' |
| 470 | }); |
| 471 | }} />; |
| 472 | } |
| 473 | const detectedIDEs = await detectIDEs(true); |
| 474 | |
| 475 | // If no IDEs with extensions detected, check for running IDEs and offer to install |
| 476 | if (detectedIDEs.length === 0 && context.onInstallIDEExtension && !isSupportedTerminal()) { |
nothing calls this directly
no test coverage detected