feat(rex): Ask pickers in Rex's command palette

Merged
DE
4d ago
+552-5

Rex's control API 17 lets a Lua action ask in the command palette (rex.ui.pick). Open Document, Choose Agent and Change Voice now ask there.

  • Open Document…: recent documents first, then .., folders and documents. Picking a folder opens it in place; a typed path or link opens directly.
  • Choose Agent…: saves the picked agent with leaf agents --set.
  • Change Voice…: tells the reader pane to switch voice.
  • Falls back to leaf's terminal popover when the prompt is unsupported/failed or rex.ui is missing. Cancel and timeout do nothing; busy reports an error.
  • Remote sessions keep the popover, since files and agents are on the host.

New commands for the plugin (JSON on stdout):

  • leaf open --list DIR [--recent] → {kind: "folder", dir, title, items} or {kind: "document", target}
  • leaf voices --list (built-in voices if Microsoft's list takes over 6s)
  • leaf agents --list, leaf agents --set NAME|any

Testing

  • cargo test passes; new tests in src/palette.rs.
  • rex config check passes on the plugin.
  • Live: Rex app build 2044 answers unsupported, so the popover fallback ran. The palette path is untested until the app supports prompts.

🤖 Generated with Claude Code


Summary by cubic

Open Document, Choose Agent and Change Voice now ask in Rex's command palette (rex.ui.pick, add-on API 17) instead of leaf's terminal popover. The popover still opens when no app can show the prompt or the list command fails, and for remote sessions, since files and agents live on the host. Cancel and timeout do nothing; a busy prompt reports an error.

New commands (JSON on stdout for the plugin):

  • leaf open --list DIR [--recent] lists a folder or resolves to a document; recent documents come first, picking a folder opens it in place, and typed paths or links open directly.
  • leaf agents --list and leaf agents --set NAME|any list installed agents and save the pick.
  • leaf voices --list lists voices, using the built-ins if Microsoft's list takes over 6 seconds.

Fallbacks

  • Choose Agent and Change Voice check for rex.ui.pick before listing, so an older Rex goes straight to the popover without waiting on the voice list; a failed listing falls back too.
  • Open Document opens the home screen when the first listing fails (e.g. the folder is gone); a bad typed path keeps the folder shown and puts the reason in the title.
  • Rows for non-UTF-8 paths are skipped, and a non-UTF-8 folder reports that instead.