CommandCodeAI / CommandCodeAI/command-code

Mod slash commands that open UI require Enter twice from the slash menu

オープン
#744 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
言語のデータがありません
スター
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'}],
      });
    },
  });
}
  1. Start cmd --mod ./picker-test.ts.
  2. Type /picker-test or select it from the slash menu.
  3. Press Enter once.
  4. Observe that the picker does not open and the command is merely inserted.
  5. Press Enter again; the picker opens.
  6. 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:

  1. Preserve executeOnSelect in the mod host's command menu items.
  2. In the slash-menu Enter handler, dispatch such an item immediately.
  3. Keep Tab and Right Arrow as insertion-only actions.
  4. Keep the existing completion behavior as the default for backward compatibility.

Suggested regression coverage:

  • a mod command with executeOnSelect: true runs 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 /model behavior 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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

mod コマンドの登録契約と slash-menu の Enter ハンドラーから始め、次にコマンドと説明がどのようにメニュー項目へ到達するかを追跡します。Tab と Right Arrow での挿入を維持しながら、opt-in の実行状態を追加します。最初の Enter での実行、通常のコマンド補完、/model の動作が変わらないことを含め、列挙された回帰ケースを検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
api, cli, testing-qa
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
明確に書かれている
初心者へのやさしさ
72/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。