CommandCodeAI / CommandCodeAI/command-code
Mod slash commands that open UI require Enter twice from the slash menu
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Không có dữ liệu ngôn ngữ
- Star
- 4k
- Fork
- 350
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với contract đăng ký command của mod và handler Enter của slash-menu, sau đó theo dõi cách command và description đến được các mục trong menu. Thêm trạng thái thực thi opt-in, đồng thời giữ nguyên việc chèn bằng Tab và Right Arrow. Xác minh các trường hợp hồi quy được liệt kê, bao gồm việc thực thi khi nhấn Enter lần đầu, hoàn tất command thông thường và hành vi không thay đổi của /model.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- api, cli, testing-qa
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 72/100