How atm1020/tuilaunch works
Project Type and Purpose
• This is an IntelliJ Platform Plugin (“TUILaunch”) that integrates with JetBrains IDEs to launch terminal‐based TUI applications (e.g. lazygit) inside the IDE’s built‐in terminal.
File Structure
• Top-level build & config: gradle files, GitHub workflows, plugin.xml under src/main/resources/META-INF.
• Code packages:
• action (DynamicTuiAction, SelectAppTuiAction)
• listeners (TerminalContextManagerListener)
• model (TuiAppConfig, TuiAppTableModel)
• services (TuiAppLaunchService, TuiLauncherSettings)
• ui (TuiLauncherConfiguration)
• Tests under src/test.
• Resources: plugin.xml declares extensions (actions, settings page).
Readme Insights
• Describes: settings UI, how actions are generated, how TUI apps launch in the terminal, lifecycle behaviors (auto-exit), limitations.
Main Components & Their Relationships
a. IDE Host (IntelliJ Platform)
‑ Provides Extension Points: Actions, SettingsConfigurable, StartupActivity, Terminal ToolWindow API.
b. Plugin Entry Points
‑ plugin.xml – registers:
• StartupActivity (to initialize plugin)
• Actions (dynamic action IDs)
• Settings page.
c. StartupActivity
‑ On IDE launch, reads saved app configs and registers DynamicTuiAction for each.
d. Settings UI (TuiLauncherConfiguration)
‑ Presents a table (TuiAppTableModel) for CRUD on TuiAppConfig
‑ Persists intoTuiLauncherSettings service.
e. Model & Storage
‑ TuiAppConfig – holds command, display name, tool-window preferences
‑ TuiLauncherSettings – persistent service (IDE’s PersistentStateComponent)
f. Actions (DynamicTuiAction, SelectAppTuiAction)
‑ Triggered via menu/shortcut/IdeaVim
‑ Delegate to TuiAppLaunchService
g. TuiAppLaunchService
‑ Uses IntelliJ’s Terminal ToolWindow API to open a new terminal session
‑ Executes ${command}; exit in that terminal
‑ Hooks into TerminalContextManagerListener to manage focus/cleanup
h. Listener (TerminalContextManagerListener)
‑ Observes terminal focus changes
‑ Ensures only one TUI session at a time, closes previous on new launch
i. External Process
‑ The TUI application (e.g. lazygit) launched inside the IDE’s terminal
Architectural Patterns & Principles
• Extension-Point Pattern: plugin.xml + StartupActivity + Configurable + Action EPs
• MVC-ish for Settings: UI (Configurable) ↔ Model (TuiAppTableModel) ↔ Service (TuiLauncherSettings)
• Service Locator: use IntelliJ’s service framework for persistence and launch service
• Observer: TerminalContextManagerListener observes terminal events