CommandCodeAI / CommandCodeAI/command-code
Mod slash commands that open UI require Enter twice from the slash menu
还没有人认领这个 Issue。
- 主要语言
- 没有语言数据
- 星标
- 4k
- 派生
- 350
- PR 合并指标
- 30 天内没有已合并 PR
描述
Mod slash commands that open UI require Enter twice from the slash menu
Summary
Selecting a mod-provided slash command from the TUI slash menu requires two Enter presses before its handler runs. The first Enter only inserts the completed command into the input; the second Enter dispatches it. Built-in picker commands such as /model run on the first Enter.
This makes UI-only mod commands feel less integrated and contradicts the slash-command documentation, which says Enter runs the selected command while Tab or Right Arrow inserts it.
Expected behavior
A mod command explicitly marked as action-only / execute-on-select should run its handler on the first Enter, allowing a cmd.ui.select() dialog to open immediately like /model.
Tab and Right Arrow should continue to insert the command for editing without executing it.
Actual behavior
The first Enter completes and inserts the mod command with a trailing space. The handler is only called after a second Enter. There is no public addCommand option that lets a mod opt into the built-in picker behavior.
Minimal reproduction
import type {ModApi} from '@commandcode/harness';
export default function (cmd: ModApi): void {
cmd.addCommand({
name: 'picker-test',
description: 'Open a test picker',
handler: async () => {
await cmd.ui.select({
title: 'Test picker',
options: [{label: 'One'}, {label: 'Two'}],
});
},
});
}
- Start
cmd --mod ./picker-test.ts. - Type
/picker-testor select it from the slash menu. - Press Enter once.
- Observe that the picker does not open and the command is merely inserted.
- Press Enter again; the picker opens.
- Compare with
/model, which opens its picker on the first Enter.
Environment
- Command Code 1.32.2 (latest npm release at time of report)
- Linux
- Bash
Technical analysis
The runtime keeps built-in picker commands such as /model in a private BARE_OPENS_PICKER_BUILTIN_SLASH_COMMANDS set. The input dispatcher bypasses completion for members of that set and invokes them immediately.
Mod command menu items only carry command and description, and the public command registration contract is currently {name, description?, argumentHint?, handler}. Consequently, a mod cannot request the same execution mode. transformInput is not a workaround because slash commands and individual keypresses do not route through it.
Suggested API and implementation
Add an explicit opt-in field, for example:
cmd.addCommand({
name: 'picker-test',
description: 'Open a test picker',
executeOnSelect: true,
handler: async () => { /* open UI */ },
});
Then:
- Preserve
executeOnSelectin the mod host's command menu items. - In the slash-menu Enter handler, dispatch such an item immediately.
- Keep Tab and Right Arrow as insertion-only actions.
- Keep the existing completion behavior as the default for backward compatibility.
Suggested regression coverage:
- a mod command with
executeOnSelect: trueruns exactly once on the first Enter; - a normal mod command retains its existing completion behavior;
- Tab and Right Arrow never execute either kind;
- built-in
/modelbehavior remains unchanged.
Real-world case
command-code-external-providers registers /external-providers, whose handler immediately opens a provider/model picker. It currently needs the extra Enter even though it has no arguments and behaves like a built-in picker command.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 mod 命令注册契约和 slash-menu 的 Enter 处理器开始,然后跟踪命令和描述如何传递到菜单项。添加 opt-in 执行状态,同时保留 Tab 和 Right Arrow 上的插入行为。验证列出的回归用例,包括第一次按 Enter 时执行、正常的命令补全,以及 /model 行为不变。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- api, cli, testing-qa
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 活跃
- 描述清晰度
- 描述清楚
- 新手友好度
- 72/100