xonecas.io
64875
Mc

mini-coder / commit 89b38f5

feat: add / + Tab command autocomplete overlay

Tab in TextInput when input starts with / shows a Select overlay
with all 11 commands and descriptions. Selection executes the
command directly. Uses COMMANDS from input.ts as source of truth.

xonecas2026-04-05 89b38f53c99558b7d0e213ee2c394b9668826a2e parent f18e758

1 file changed

src/ui.ts+47−1
@@ -43,7 +43,7 @@ import {
4343 saveOAuthCredentials,
4444 shutdown,
4545 } from "./index.ts";
46-import { parseInput } from "./input.ts";
46+import { COMMANDS, parseInput } from "./input.ts";
4747 import {
4848 appendMessage,
4949 computeStats,
@@ -974,6 +974,48 @@ function handleLogoutCommand(state: AppState): void {
974974 cel.render();
975975 }
976976
977+/** Command descriptions for the autocomplete overlay. */
978+const COMMAND_DESCRIPTIONS: Record<string, string> = {
979+ model: "Select a model",
980+ effort: "Set reasoning effort",
981+ session: "Resume a session",
982+ new: "New session",
983+ fork: "Fork session",
984+ undo: "Undo last turn",
985+ reasoning: "Toggle thinking display",
986+ verbose: "Toggle full output",
987+ login: "OAuth login",
988+ logout: "OAuth logout",
989+ help: "Show help",
990+};
991+
992+/** Show command autocomplete overlay. */
993+function showCommandAutocomplete(state: AppState): void {
994+ const items = COMMANDS.map((cmd) => ({
995+ label: `/${cmd} ${COMMAND_DESCRIPTIONS[cmd] ?? ""}`,
996+ value: cmd,
997+ filterText: cmd,
998+ }));
999+
1000+ const select = Select({
1001+ items,
1002+ maxVisible: OVERLAY_MAX_VISIBLE,
1003+ placeholder: "type to filter commands...",
1004+ focused: true,
1005+ highlightColor: "color06",
1006+ onSelect: (value) => {
1007+ dismissOverlay();
1008+ handleInput(`/${value}`, state);
1009+ },
1010+ onBlur: dismissOverlay,
1011+ });
1012+
1013+ inputFocused = false;
1014+ inputValue = "";
1015+ activeOverlay = { select, title: "Commands" };
1016+ cel.render();
1017+}
1018+
9771019 /** Dispatch a parsed command. Returns true if handled. */
9781020 function handleCommand(command: string, state: AppState): boolean {
9791021 switch (command) {
@@ -1261,6 +1303,10 @@ export function startUI(state: AppState): void {
12611303 handleInput(raw, state);
12621304 return false;
12631305 }
1306+ if (key === "tab" && inputValue.startsWith("/")) {
1307+ showCommandAutocomplete(state);
1308+ return false;
1309+ }
12641310 },
12651311 }),
12661312 ]),