feat: native second-level picker for custom commands #270
Replies: 5 comments 1 reply
|
I tend to decline this request. Not a flat no to the idea, I just don't see what justifies a much more complicated keymap structure and the code to support it, when both halves of what you want already work today. for a static second level, don't nest it, flatten it and let the palette do the narrowing. Name the commands with a common prefix: the palette's fuzzy search splits your query on whitespace and requires every term to match, order-independent, so for a second level that is live data, i.e., the tmux sessions on the host you just picked, you can't enumerate it upfront, so run a picker in an overlay: the overlay's shell gets agterm covers a sensible minimum out of the box, and anything past that gets built over the control API and CLI rather than shipped as a built-in. To be concrete about the cost here: a btw, for open-ended ideas like this one, Discussions (Ideas) is a better place than an issue. |
|
revisiting this now that 0.19.0 is out. what I pushed back on was the what changed is the other half of that reply, that anything past the built-in minimum gets built over the control API. 0.19.0 adds that covers your use case without a keymap change: a custom command runs a shell line, and each level is another
|
|
Thank you for delivering this, it covers the majority of my pain points. But as always, there is a room for improvement, so I'll throw a few proposals below for your review. For context, I use a custom palette to manage my local/remote tmux sessions (one master node manages sessions locally and on multiple remote spokes over SSH) and in certain scenarios, for example when you would like to kill all sessions on the host or create a new one, I show some modal windows ("enter session name", "are you sure you want to do that?", "what spoke do you want to create a session on?" etc.). And with this new pick option, I'm trying to ditch my custom ANSI modal window and stick to a native one provided by
Two smaller notes: after a lost or interrupted pick open |
|
taking the ordering and display-only ones, splitting the free-form one, declining the last two. ordering. Agreed, and it is closer to a bug than a gap. display-only text. Also taking it, but not as a per-item flag. Your confirm case is real: "no" hits "cannot be undone" as a substring at offset 3 and misses "Cancel" entirely, so a refusal deletes the safe row and preselects the destructive one. The fix is to stop ranking subtitles for caller-supplied pickers at all, rather than adding a knob to opt each row out. Built-in palettes keep matching on session cwd, explicit picks match what the label says. If you want extra search text you can append it to the label, which is not something you can do in the other direction. Both of those are default changes, not flags. free-form answers. Prefilled query and the empty item list, yes. Prefill becomes Committing an empty answer I'll leave out. There is no query text to echo, so echo '[{"id":"__auto","label":"Generate a name"}]' | agtermctl pick --allow-custom --prompt "Session name"empty query matches everything, so Enter on an untouched field picks the seed row, and typing anything else gives you the custom result. decision context. Declining. Row labels have no line limit, only subtitles are clamped to one line, so the unbounded text region is the label itself, put the consequence there. You are right that the prompt is a poor place for a question, it is the field placeholder and disappears the moment anyone types, but that argues for keeping the prompt short rather than for a message pane. Drawing one would be the first thing the picker renders beyond rows. correlation breadcrumb. Also declining, and the obvious shape is worse than no fix. Letting the caller mint the id breaks a uniqueness assumption that |
|
merged in #339, so all four are in master now. two things you can delete. The ported ranker copy in your test suite has nothing left to prove: caller rows match their label only, so a subtitle can carry "cannot be undone" and no refusal word can isolate the destructive row. Worth knowing the exact shape before you rewrite those tests, since it is not what either of us assumed at the start: typing The ANSI input dialog and its temp-file protocol can go too. Empty items plus new=$(agtermctl pick --allow-custom --query "$current" --prompt "Rename" < /dev/null | jq -r '.query')
On ordering: an empty query now keeps your array order, so the preselected row is the one you put first. A prefilled What I left out, and why. Committing an empty answer needs a caller-supplied label for the row, since there is no query text to echo, and that is more API than the other two together. The context pane I still think is unnecessary: row labels have no line limit, only subtitles are clamped to one line, so the consequence text goes in the destructive row's own label. The correlation tag I did reconsider and still declined, but for a sharper reason than last time. The obvious shape, letting the caller mint the id, breaks a uniqueness assumption that The subtitle behavior and the ordering were both undocumented before this, in either direction. They are written down now in the reference and the bundled skill, along with both error strings. |
Uh oh!
There was an error while loading. Please reload this page.
Use case
I work across several remote hosts, each running tmux with a handful of sessions. I'd like to attach to
any of them from agterm's command palette.
Today I can add one custom
command "Attach <host>" …per host, so the palette (⌃⇧O) already gives me anice native top-level list of hosts. What's missing is the second level: after I pick a host, I want a
native list of that host's sessions to choose from — exactly the two-level flow Change Theme uses
(pick the action, then a modal list of themes).
There's currently no way for a custom command to present a native second-level list of items, so the only
option is to pop my own shell menu, which feels foreign next to agterm's built-in pickers.
The ask
A way for a custom command to hand agterm a list of items (produced at open time) and have agterm show its
native picker for them, returning the chosen one. For example:
Selecting the parent runs the submenu command, agterm shows a native modal of those items (the Change-Theme
drill-in), and the chosen item's id is passed to the command.
All reactions