Implementation:AI QL Tuui openCommandPicker
| Knowledge Sources | |
|---|---|
| Domains | Command_Picker, Window_Management, Electron |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
Concrete tool for creating, positioning, showing, and hiding the command picker popup window at the cursor location, provided by the tuui Electron application.
Description
The openCommandPicker function positions a 300×320 frameless, always-on-top, taskbar-skipping BrowserWindow at the cursor's screen position, then shows it. prepareCommandPicker creates the window with the /popup hash route, query params, and focus management. closeCommandPicker fades the window out (opacity 0), releases focus back to the source app, and hides it. activateCommandPicker waits for the window to become visible, then attaches a blur handler that auto-closes the picker.
Usage
Import these functions when: opening the command picker after grabbing text, closing it after the user selects a prompt, or managing popup window lifecycle.
Code Reference
Source Location
- Repository: tuui
- File: src/main/aid/commands.ts
Signature
export let commandPicker: BrowserWindow
export const prepareCommandPicker: (queryParams?: anyDict) => void
export const openCommandPicker: (params: anyDict) => void
export const closeCommandPicker: (sourceApp?: Application) => Promise<void>
// Internal:
const activateCommandPicker: () => Promise<void>
Import
import {
openCommandPicker,
closeCommandPicker,
prepareCommandPicker,
commandPicker
} from './aid/commands'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| params | anyDict | Yes (openCommandPicker) | { textId, sourceApp, startTime } |
| queryParams | anyDict | No (prepareCommandPicker) | Query params for the popup URL |
| sourceApp | Application | No (closeCommandPicker) | App to return focus to |
Outputs
| Name | Type | Description |
|---|---|---|
| side effect | commandPicker | BrowserWindow shown at cursor or hidden |
| side effect | blur handler | Auto-closes on focus loss |
Usage Examples
Open the Command Picker
import { openCommandPicker } from './aid/commands'
// After grabbing text:
openCommandPicker({
textId: 'cached-text-uuid',
sourceApp: { id: 'com.apple.Terminal', name: 'Terminal', window: 'Terminal' },
startTime: Date.now()
})
// Popup appears at cursor position on /popup route with prompt template list
Close the Command Picker
import { closeCommandPicker } from './aid/commands'
await closeCommandPicker(sourceApp)
// Window fades out, focus returned to source app, window hidden