Skip to content

Commit 1ecfb03

Browse files
sahrizviclaude
andauthored
fix(tui): /skills opens the Altimate skills browser, and its actions work (AltimateAI#1342)
* fix(tui): `/skills` opens the Altimate skills browser, and its actions work `/skills` was owned twice: the core prompt's `prompt.skills` (upstream's plain selector — Enter inserts `/<skill>`, no actions) and the Altimate plugin's `altimate.skill.list` both registered that slash name, so the autocomplete listed two `/skills` rows and Enter took the first. Users were in the plain selector, where ctrl+a is the input's line-home, and the only TUI route to "Publish to workspace" was unreachable (AltimateAI#1328). - The core command keeps its palette entry and loses the slash name; the Altimate browser is `/skills`. - Enter in the browser now USES the skill — inserts `/<skill> ` into the prompt, as the docs said and the core selector did. The action picker is `ctrl+a` and an "Actions" footer button. - Actions, New and Install are `DialogSelect` actions with in-dialog bindings (`ctrl+a` / `ctrl+e` / `ctrl+i`) rather than a plugin-level keymap layer the open dialog outranks; they render as Tab-reachable footer buttons, so none of them depends on a chord. New is `ctrl+e` because `ctrl+n` is every dialog's "next". The dialog actions carry their own command names so the footer labels show the chords that work there. - The plugin `DialogSelect` API gains `actions` and `bindings`, forwarded by the adapter. - `DialogSelect` computed its action list eagerly, before `selected` was declared; a function-valued `disabled` (which the browser needs to keep the synthetic Install row out of the picker) threw "Cannot access 'selected' before initialization". Evaluated lazily now. Verified under vhs on a local build: the footer reads "Actions ctrl+a · New ctrl+e · Install ctrl+i"; Down then ctrl+a opens "Actions: dbt-pr-review"; Enter on a row leaves "/dbt-pr-review " in the prompt without submitting. Six tests mount a real DialogSelect in the provider stack and press the keys (including with the global layer registered and with a function-valued `disabled`). Closes AltimateAI#1328 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6 * fix(tui): bind Install to ctrl+g — ctrl+i is Tab on the wire Most terminals send ctrl+i as byte 0x09, which the TUI receives as Tab: the footer's own key. The documented chord could move footer focus instead of opening Install. ctrl+g is free everywhere in the TUI; the plugin's global binding and the docs table follow. Test: Tab runs nothing, ctrl+g runs Install. (bot review on AltimateAI#1342) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6 * fix(tui): standalone New/Install, route every Skills entry to the browser, no global ctrl+g Codex review of AltimateAI#1342 (gpt-5.6-sol). - `DialogSelect` refused to run any action without a highlighted row, so with a filter that matched nothing — the create-from-filter flow — ctrl+e and the New/Install footer buttons did nothing. Actions can be `standalone` (discriminated union, so every existing row-bound caller types unchanged); the plugin API and adapter carry it, and New / Install set it - The core `prompt.skills` command was still a palette row and the target of a configured `prompt_skills` keybind, both opening the plain selector. It now dispatches `altimate.skill.list` when that is registered and is hidden from the palette then, so no route lands on the selector while the browser exists - The global ctrl+g binding collided with the session route's `messages_first`; Install keeps its dialog-local chord only - `docs/configure/tools/custom.md` still said ctrl+i - Tests: standalone fires with nothing matching while the row-bound action does not; the same through the plugin API adapter (a dropped forward fails it — checked by mutation); Tab then Enter activates the focused footer button Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6 * test(tui): production command names in the dialog test; exercise the adapter gate The dialog actions are named `altimate.skill.list.*` as skill-ops declares them, and the adapter test carries a row-bound action with no `disabled` function, so the adapter's own gate is what stops it with no row (a dropped gate fails the test). (bot review) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6 * test(tui): the adapter-gate case must use a chord the dialog receives ctrl+p is the palette outside a dialog and never reached the action, so the previous no-row assertion was vacuous. ctrl+o instead, with a positive control that the action fires with a row; disabling the adapter gate now fails the test. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6 --------- Co-authored-by: Claude Opus 5 <[email protected]>
1 parent 4b3b621 commit 1ecfb03

8 files changed

Lines changed: 453 additions & 26 deletions

File tree

‎docs/docs/configure/skills.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,25 +201,26 @@ altimate-code skill publish my-tool # upload every file in the skill dir
201201

202202
### TUI
203203

204-
Open the skill browser with `ctrl+i` when no other dialog is open, or type `/skills` in the prompt:
204+
Open the skill browser by typing `/skills` in the prompt (or `<leader>k`):
205205

206206
![Skill Browser](../assets/images/skills/tui-skill-browser.png)
207207

208208
**Keyboard shortcuts:**
209209

210210
| Key | Action |
211211
|-----|--------|
212-
| `ctrl+i` | Open skill browser (when no dialog is open) / Install skill (when inside browser) |
213212
| Enter | Use — inserts `/<skill-name>` into the prompt |
214213
| `ctrl+a` | Actions — show, edit, test, remove, or publish the selected skill to the linked workspace (the publish row appears only with `ALTIMATE_WORKSPACE=1`) |
215-
| `ctrl+n` | New — scaffold a new skill + CLI tool |
214+
| `ctrl+e` | New — scaffold a new skill + CLI tool (`ctrl+n` moves down the list, as in every dialog) |
215+
| `ctrl+g` | Install a skill from a GitHub repo, URL, or local path (`ctrl+i` is Tab in most terminals, so it cannot be the chord) |
216+
| Tab / Shift+Tab | Move between the **Actions · New · Install** buttons in the footer, then Enter — the same three without a chord |
216217
| Esc | Back — returns to previous screen |
217218

218-
**Create skill** (`ctrl+n`):
219+
**Create skill** (`ctrl+e`, or the **New** footer button):
219220

220221
![Create Skill Dialog](../assets/images/skills/tui-skill-create.png)
221222

222-
**Install skill** (`ctrl+i` inside browser):
223+
**Install skill** (`ctrl+g`, or the **Install** footer button):
223224

224225
![Install Skill Dialog](../assets/images/skills/tui-skill-install.png)
225226

‎docs/docs/configure/tools/custom.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ altimate-code skill install https://github.com/owner/repo/tree/main/skills/my-sk
7373
altimate-code skill remove my-skill
7474
```
7575

76-
Or use the TUI: type `/skills`, then `ctrl+i` to install or `ctrl+a` → Remove to delete.
76+
Or use the TUI: type `/skills`, then `ctrl+g` (or the **Install** footer button) to install, or `ctrl+a` → Remove to delete.
7777

7878
### Output Conventions
7979

‎packages/opencode/src/plugin/tui/altimate/skill-ops.tsx‎

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,9 +781,61 @@ function DialogSkillList(props: { api: TuiPluginApi; onCurrent: (skill: string |
781781
}
782782
// altimate_change end
783783
props.onCurrent(item.value)
784-
// Selecting a skill opens its action picker (the pre-merge default action was the picker).
784+
// altimate_change start — Enter USES the skill: it inserts `/<skill> ` into the
785+
// prompt, as the docs say and as the core selector this dialog now replaces did
786+
// (#1328). The action picker moved to ctrl+a and the "Actions" footer button.
787+
const ref = api.prompt.active()
788+
if (ref) {
789+
ref.set({ ...ref.current, input: `/${item.value} `, parts: [] })
790+
api.ui.dialog.clear()
791+
ref.focus()
792+
return
793+
}
794+
// No prompt to write into (no session mounted): fall back to the picker.
785795
openActionPicker(api, skillMap().get(item.value), item.value, () => showList(api))
796+
// altimate_change end
786797
}}
798+
// altimate_change start — the picker, create and install as DIALOG actions (#1328).
799+
// The plugin's global keymap layer registers ctrl+a / ctrl+n / ctrl+i too, but while
800+
// this dialog is open its own layer outranks that one: ctrl+a went to the filter
801+
// input's line-home and ctrl+n to `dialog.select.next`. Declared here they are bound
802+
// inside the dialog (the model dialog binds ctrl+a the same way) and rendered as
803+
// footer buttons reachable with Tab, so the picker no longer depends on a chord at
804+
// all. ctrl+n stays the dialog's own "next"; New is ctrl+e in here. Install is
805+
// ctrl+g, not ctrl+i: most terminals send ctrl+i as byte 0x09, which is Tab — the
806+
// footer's own key (bot review).
807+
actions={[
808+
{
809+
command: "altimate.skill.list.actions",
810+
title: "Actions",
811+
disabled: (option) => option === undefined || option.value === INSTALL_ACTION_VALUE,
812+
onTrigger: (item) => {
813+
if (!item || item.value === INSTALL_ACTION_VALUE) return
814+
props.onCurrent(item.value)
815+
openActionPicker(api, skillMap().get(item.value), item.value, () => showList(api))
816+
},
817+
},
818+
// New and Install need no highlighted row: typing a name that matches no
819+
// installed skill and pressing ctrl+e is the create-from-filter flow.
820+
{
821+
command: "altimate.skill.list.create",
822+
title: "New",
823+
standalone: true,
824+
onTrigger: () => showCreate(api, filter().trim() || undefined),
825+
},
826+
{
827+
command: "altimate.skill.list.install",
828+
title: "Install",
829+
standalone: true,
830+
onTrigger: () => showInstall(api, filter().trim() || undefined),
831+
},
832+
]}
833+
bindings={[
834+
{ key: "ctrl+a", cmd: "altimate.skill.list.actions" },
835+
{ key: "ctrl+e", cmd: "altimate.skill.list.create" },
836+
{ key: "ctrl+g", cmd: "altimate.skill.list.install" },
837+
]}
838+
// altimate_change end
787839
/>
788840
)
789841
}
@@ -884,11 +936,13 @@ const tui: TuiPlugin = async (api) => {
884936
// ctrl+a -> actions · ctrl+n -> create · ctrl+i -> install.
885937
// altimate_change start — restore a default key to OPEN the skills list (pre-merge skill_list
886938
// was ctrl+i, which now collides with tab/agent-cycle; use a collision-free <leader>k instead).
939+
// Install has no global chord: ctrl+i is Tab on the wire for most terminals, and
940+
// ctrl+g is the session route's "first message". Inside the browser it is ctrl+g
941+
// (a dialog-local binding, see DialogSkillList); from anywhere else, the palette.
887942
bindings: [
888943
{ key: "<leader>k", cmd: "altimate.skill.list" },
889944
{ key: "ctrl+a", cmd: "altimate.skill.actions" },
890945
{ key: "ctrl+n", cmd: "altimate.skill.create" },
891-
{ key: "ctrl+i", cmd: "altimate.skill.install" },
892946
],
893947
// altimate_change end
894948
})

‎packages/plugin/src/tui.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,32 @@ export type TuiDialogSelectProps<Value = unknown> = {
183183
// altimate_change start — a fixed-option dialog can hide the filter box entirely
184184
renderFilter?: boolean
185185
// altimate_change end
186+
// altimate_change start — dialog-level actions: footer buttons (Tab-reachable) with
187+
// keybinds that are live INSIDE the dialog, where the dialog's own layer outranks a
188+
// plugin's global keymap layer. Mirrors the host DialogSelect `actions`/`bindings`.
189+
actions?: TuiDialogSelectAction<Value>[]
190+
bindings?: { key: string; cmd: string }[]
191+
// altimate_change end
186192
current?: Value
187193
}
188194

195+
// altimate_change start
196+
export type TuiDialogSelectAction<Value = unknown> = {
197+
/** Command name the `bindings` entries refer to. */
198+
command: string
199+
title: string
200+
side?: "left" | "right"
201+
hidden?: boolean
202+
disabled?: boolean | ((option: TuiDialogSelectOption<Value> | undefined) => boolean)
203+
/** Called with the highlighted option — or with `undefined` when `standalone` is set
204+
* and no row is highlighted (empty list, nothing matches the filter). */
205+
onTrigger: (option: TuiDialogSelectOption<Value> | undefined) => void
206+
/** The action needs no highlighted row (create, install): it fires even when the
207+
* list is empty or the filter matches nothing. */
208+
standalone?: boolean
209+
}
210+
// altimate_change end
211+
189212
export type TuiPromptInfo = {
190213
input: string
191214
mode?: "normal" | "shell"

‎packages/tui/src/component/prompt/index.tsx‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,21 @@ export function Prompt(props: PromptProps) {
593593
title: "Skills",
594594
name: "prompt.skills",
595595
category: "Prompt",
596-
slashName: "skills",
596+
// altimate_change start — `/skills` belongs to the Altimate skills browser
597+
// (`altimate.skill.list`: browse, actions, create, install). This command kept the
598+
// same slash name, so autocomplete listed two `/skills` rows and Enter took this
599+
// one — the plain selector with no actions — which is why ctrl+a never opened the
600+
// picker (#1328). It has no slash name now, and its other two entry points — the
601+
// palette row and a configured `prompt_skills` keybind — hand over to the browser
602+
// when it is registered, so no route lands on the plain selector while a better
603+
// one exists. Hidden from the palette then, too: two "Skills" rows invite the
604+
// wrong one.
605+
get hidden() {
606+
return keymap.getCommands({ visibility: "registered", filter: { name: "altimate.skill.list" } }).length > 0
607+
},
597608
run: () => {
609+
if (keymap.dispatchCommand("altimate.skill.list").ok) return
610+
// altimate_change end
598611
dialog.replace(() => (
599612
<DialogSkill
600613
onSelect={(skill) => {

‎packages/tui/src/plugin/adapters.tsx‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import type { TuiDialogSelectOption, TuiPluginApi, TuiPromptRef, TuiSlotProps } from "@opencode-ai/plugin/tui"
1+
// altimate_change start — TuiDialogSelectProps for the generic DialogSelect adapter
2+
import type { TuiDialogSelectOption, TuiDialogSelectProps, TuiPluginApi, TuiPromptRef, TuiSlotProps } from "@opencode-ai/plugin/tui"
3+
// altimate_change end
24
import type { TuiConfig } from "../config"
35
import type { useEvent } from "../context/event"
46
import type { usePromptRef } from "../context/prompt"
@@ -234,7 +236,10 @@ export function createTuiApiAdapters(input: Input): Omit<TuiPluginApi, "lifecycl
234236
DialogPrompt(props) {
235237
return <DialogPrompt {...props} description={props.description} />
236238
},
237-
DialogSelect(props) {
239+
// altimate_change start — generic over the option value so the dialog-level
240+
// actions below can be typed against it
241+
DialogSelect<Value>(props: TuiDialogSelectProps<Value>) {
242+
// altimate_change end
238243
return (
239244
<DialogSelect
240245
title={props.title}
@@ -248,6 +253,29 @@ export function createTuiApiAdapters(input: Input): Omit<TuiPluginApi, "lifecycl
248253
// altimate_change start — pass the filter-box switch through to the component
249254
renderFilter={props.renderFilter}
250255
// altimate_change end
256+
// altimate_change start — dialog-level actions and their in-dialog keybinds
257+
actions={props.actions?.map((action) => ({
258+
command: action.command,
259+
title: action.title,
260+
side: action.side,
261+
hidden: action.hidden,
262+
disabled:
263+
typeof action.disabled === "function"
264+
? (option: SelectOption<Value> | undefined) =>
265+
(action.disabled as (o: TuiDialogSelectOption<Value> | undefined) => boolean)(
266+
option ? pickOption(option) : undefined,
267+
)
268+
: action.disabled,
269+
standalone: true as const,
270+
onTrigger: (option: SelectOption<Value> | undefined) => {
271+
// The plugin API's shape is the row-bound one unless `standalone`; the
272+
// core gate is applied here so a plugin action without a row is not called.
273+
if (!option && !action.standalone) return
274+
action.onTrigger(option ? pickOption(option) : undefined)
275+
},
276+
}))}
277+
bindings={props.bindings}
278+
// altimate_change end
251279
current={props.current}
252280
/>
253281
)

‎packages/tui/src/ui/dialog-select.tsx‎

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ import { getScrollAcceleration } from "../util/scroll"
2020
import { useTuiConfig } from "../config"
2121
import { formatKeyBindings, useBindings, useKeymapSelector } from "../keymap"
2222

23+
// altimate_change start — see `actions`
24+
type DialogSelectActionBase<T> = {
25+
command: string
26+
title: string
27+
side?: "left" | "right"
28+
hidden?: boolean
29+
disabled?: boolean | ((option: DialogSelectOption<T> | undefined) => boolean)
30+
}
31+
export type DialogSelectAction<T> =
32+
| (DialogSelectActionBase<T> & { standalone?: false; onTrigger: (option: DialogSelectOption<T>) => void })
33+
| (DialogSelectActionBase<T> & { standalone: true; onTrigger: (option: DialogSelectOption<T> | undefined) => void })
34+
// altimate_change end
35+
2336
export interface DialogSelectProps<T> {
2437
title: string
2538
titleView?: JSX.Element
@@ -35,14 +48,12 @@ export interface DialogSelectProps<T> {
3548
skipFilter?: boolean
3649
renderFilter?: boolean
3750
locked?: boolean
38-
actions?: {
39-
command: string
40-
title: string
41-
side?: "left" | "right"
42-
hidden?: boolean
43-
disabled?: boolean | ((option: DialogSelectOption<T> | undefined) => boolean)
44-
onTrigger: (option: DialogSelectOption<T>) => void
45-
}[]
51+
// altimate_change start — a `standalone` action needs no highlighted row (create,
52+
// install): it fires with `undefined` when the list is empty or nothing matches the
53+
// filter. The default keeps the row-bound contract every existing caller relies on,
54+
// as a discriminated union so those callers' `onTrigger` still types as row-bound.
55+
actions?: DialogSelectAction<T>[]
56+
// altimate_change end
4657
footerHints?: {
4758
title: string
4859
label: string
@@ -135,11 +146,15 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
135146
.filter((item) => item.label),
136147
...(props.footerHints ?? []),
137148
])
138-
const actionItems = createMemo(() =>
149+
// altimate_change start — evaluated lazily rather than as an eager memo: `isActionDisabled`
150+
// reads `selected()`, which is declared further down, so a function-valued `disabled`
151+
// (the Skills browser's, #1328) threw "Cannot access 'selected' before initialization"
152+
// during setup. Every existing caller passed a boolean, which never touched `selected`.
153+
const actionItems = () =>
139154
visibleActions()
140155
.filter(isActionItem)
141-
.filter((item) => !isActionDisabled(item)),
142-
)
156+
.filter((item) => !isActionDisabled(item))
157+
// altimate_change end
143158

144159
createEffect(() => {
145160
const index = focusedAction()
@@ -371,8 +386,10 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
371386
if (isActionDisabled(item)) return
372387
setStore("input", "keyboard")
373388
const option = selected()
374-
if (!option) return
375-
item.onTrigger(option)
389+
// altimate_change start — see `standalone`
390+
if (item.standalone) item.onTrigger(option)
391+
else if (option) item.onTrigger(option)
392+
// altimate_change end
376393
},
377394
})),
378395
],
@@ -434,8 +451,10 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
434451
if (!item || !isActionItem(item) || isActionDisabled(item)) return
435452
setStore("input", "keyboard")
436453
const option = selected()
437-
if (!option) return
438-
item.onTrigger(option)
454+
// altimate_change start — see `standalone`
455+
if (item.standalone) item.onTrigger(option)
456+
else if (option) item.onTrigger(option)
457+
// altimate_change end
439458
}
440459

441460
function isActionItem(item: VisibleAction): item is Action & { label: string } {

0 commit comments

Comments
 (0)