Implementation:23blocks OS Ai maestro Use Launch Choice Hook
| Knowledge Sources | |
|---|---|
| Domains | UI, Agent_Launch |
| Last Updated | 2026-10-26 18:00 GMT |
Overview
Concrete tool for the launch choice panel state — tool selection, permission mode, execution mode, launch options, and derived command preview — shared by the wake dialog and create wizard, provided by AI Maestro's `hooks/useLaunchChoice.ts`.
Description
The useLaunchChoice hook (F040) manages the state behind the launch choice panel. It tracks the selected program, permission mode (supervised/planOnly/etc.), execution mode (terminal/streaming), launch options, and visibility toggles. Derived state is computed from these: the modes the selected tool honours (`permissionModesFor`), the stops/freedom levels available (`stopsFor`), the valid launch option declarations (`launchOptionsFor`), and an exact command preview (`previewCommand`). The hook resets to the agent's own settings whenever `resetKey` changes (dialog open, different agent). Changing the tool falls back to a safe permission mode if the current one is not supported by the new tool.
Usage
Call with the agent's `defaultProgram`, `defaultPermissionMode`, `defaultLaunchOptions`, and a `resetKey`. Read the returned state to render the panel; use `setOption` to toggle launch options.
Code Reference
Source Location
- Repository: ai-maestro
- File: hooks/useLaunchChoice.ts
- Lines: L1-L94
Signature
export function useLaunchChoice(input: {
defaultProgram?: string
defaultPermissionMode?: AgentPermissionMode | string
defaultLaunchOptions?: LaunchOptions
resetKey?: unknown
}): {
selectedId: string
selected: ProgramChoice
permissionMode: AgentPermissionMode
execMode: 'terminal' | 'streaming'
options: LaunchOptions
modes: AgentPermissionMode[]
stops: FreedomStop[]
preview: string | null
// ...setters and toggles
}
Import
import { useLaunchChoice } from '@/hooks/useLaunchChoice'
I/O Contract
| Name | Type | Description |
|---|---|---|
| selected | ProgramChoice | The chosen tool/program |
| permissionMode | AgentPermissionMode | supervised, planOnly, etc. |
| preview | null | Exact command preview |
Usage Examples
import { useLaunchChoice } from '@/hooks/useLaunchChoice'
function WakeDialog({ agent }) {
const choice = useLaunchChoice({
defaultProgram: agent.program,
defaultPermissionMode: agent.permissionMode,
resetKey: agent.id,
})
return <div>{choice.preview}</div>
}