Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AI QL Tuui Commander

From Leeroopedia
Knowledge Sources
Domains Command_Picker, Automation, Electron
Last Updated 2026-10-24 00:00 GMT

Overview

Concrete tool for initializing the platform automator and executing the command picker shortcut flow to grab selected text and open the popup, provided by the tuui Electron application.

Description

The Commander class has two static methods. init() creates a platform-dispatching Automator instance to verify nut-js is available. initCommand() is the shortcut callback: it creates an Automator, grabs the selected text via Automation.grabSelectedText (falling back to clipboard), caches it via putCachedText (returns a UUID), gets the foremost app, and opens the command picker popup with the text ID and source app. In Mac App Store (MAS) builds, it shows a limitations dialog instead.

Usage

Import Commander when bootstrapping the global shortcut system (call init() to verify automator, then bind initCommand as the shortcut callback).

Code Reference

Source Location

  • Repository: tuui
  • File: src/main/aid/commander.ts

Signature

export default class Commander {
  static init: () => Promise<boolean>
  static initCommand: (timeout?: number) => Promise<void>
}

Import

import Commander from './aid/commander'

I/O Contract

Inputs

Name Type Required Description
timeout number No (initCommand, default 1000) Text grab polling timeout in ms

Outputs

Name Type Description
init Promise<boolean> True if automator initialized; false on error
initCommand Promise<void> Opens command picker popup; no return value
side effect putCachedText Grabbed text cached with UUID key
side effect openCommandPicker Popup window shown at cursor

Usage Examples

Bootstrap the Command Picker

import Commander from './aid/commander'
import * as shortcuts from './aid/shortcuts'

const initState = await Commander.init()
if (initState) {
  shortcuts.registerShortcuts({
    command: () => Commander.initCommand()
  })
}
// Ctrl+Alt+T now triggers the command picker

initCommand Flow

// When Ctrl+Alt+T is pressed:
// 1. Create Automator (platform-dispatching)
// 2. Grab selected text (poll clipboard after copy command)
// 3. Fall back to clipboard.readText() if selection empty
// 4. Cache text with putCachedText() → returns UUID textId
// 5. Get foremost app via automator.getForemostApp()
// 6. Open command picker with { textId, sourceApp, startTime }

Related Pages

Implements Principle

Uses Heuristic

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment