Phials developer documentation
User guide
AI Notice: Most documentation right now was auto-generated by an LLM. Handwritten documentation will be implemented over time on the road to 1.0

Command

A command is a discrete action that can be invoked via:

  • Keyboard shortcut
  • Command bar
  • Context menu
  • Toolbar button
  • Programmatically

Signature

interface Command {
    id: string;
    label: string;
    description?: string;
    tooltip?: string;
    icon?: string;
    contextKeys?: CommandContextKey[];
    when?: (ctx: CommandContext) => boolean;
    disabled?: (ctx: CommandContext) => boolean;
    action: (ctx: CommandContext) => void | Promise<void>;
    toastData?: import("phoundry-ui").ToastEntry | ((ctx: CommandContext) => import("phoundry-ui").ToastEntry | null | undefined);
    shortcut?: CommandShortcut;
    defaultPlacements?: CommandPlacement[];
    category?: string;
    searchAliases?: string[];
    children?: Command[];
    renderSnippet?: (ctx: CommandContext) => import("svelte").Snippet;
}

Members

NameTypeRequiredDescription
idstringyesUnique command identifier (e.g., ‘core.file.delete’, ‘plugin.terminal.toggle’)
labelstringyesHuman-readable label
descriptionstringnoOptional description for command bar/settings
tooltipstringnoTooltip text shown on hover (defaults to label if not set)
iconstringnoIcon for UI display
contextKeysCommandContextKey[]noContext keys required for this command to be visible. Used for fast pre-filtering before evaluating when(). If omitted or contains ‘always’, command is always considered.
when(ctx: CommandContext) => booleannoFine-grained visibility check. Only called if contextKeys pass (or are not specified). Return false to hide the command.
disabled(ctx: CommandContext) => booleannoWhether the command is disabled (visible but not executable). Return true to disable.
action(ctx: CommandContext) => void | Promise<void>yesThe action to execute
toastDataimport("phoundry-ui").ToastEntry | (ctx: CommandContext) => import("phoundry-ui").ToastEntry | null | undefinednoOptional toast shown after the action completes successfully (no throw). Static entry or a function of the same context passed to action.
shortcutCommandShortcutnoKeyboard shortcut configuration
defaultPlacementsCommandPlacement[]noWhere this command appears by default. Users can override these in settings.
categorystringnoCategory for grouping in command bar. E.g., ‘File’, ‘Edit’, ‘View’, ‘Navigation’, ‘Tabs’
searchAliasesstring[]noAlternative search terms for command bar fuzzy search
childrenCommand[]noChild commands for dropdown/submenu patterns. When a command has children, its action typically does nothing and the UI shows a dropdown menu of child commands instead.
renderSnippet(ctx: CommandContext) => import("svelte").SnippetnoCustom render snippet for context menu. When provided, the command renders as a custom menu item instead of a standard action item. Useful for inline controls like ratings.