From 952657d55c5aabcb930d060ea4f89b3f4a738e08 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 6 Jan 2026 08:41:04 +0100 Subject: [PATCH] feat(tui): add /elev alias --- CHANGELOG.md | 1 + docs/tui.md | 1 + src/tui/commands.test.ts | 16 ++++++++++++++++ src/tui/commands.ts | 19 ++++++++++++++++++- 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/tui/commands.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index d16843996..021462476 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ - Gmail: stop restart loop when `gog gmail watch serve` fails to bind (address already in use). - Linux: auto-attempt lingering during onboarding (try without sudo, fallback to sudo) and prompt on install/restart to keep the gateway alive after logout/idle. Thanks @tobiasbischoff for PR #237. - TUI: migrate key handling to the updated pi-tui Key matcher API. +- TUI: add `/elev` alias for `/elevated`. - Logging: redact sensitive tokens in verbose tool summaries by default (configurable patterns). - macOS: prefer gateway config reads/writes in local mode (fall back to disk if the gateway is unavailable). - macOS: local gateway now connects via tailnet IP when bind mode is `tailnet`/`auto`. diff --git a/docs/tui.md b/docs/tui.md index de0479788..3cfcc35b6 100644 --- a/docs/tui.md +++ b/docs/tui.md @@ -52,6 +52,7 @@ Use SSH tunneling or Tailscale to reach the Gateway WS. - `/think ` - `/verbose ` - `/elevated ` +- `/elev ` - `/activation ` - `/deliver ` - `/new` or `/reset` diff --git a/src/tui/commands.test.ts b/src/tui/commands.test.ts new file mode 100644 index 000000000..2c0fde55d --- /dev/null +++ b/src/tui/commands.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, it } from "vitest"; + +import { parseCommand } from "./commands.js"; + +describe("tui slash commands", () => { + it("treats /elev as an alias for /elevated", () => { + expect(parseCommand("/elev on")).toEqual({ name: "elevated", args: "on" }); + }); + + it("normalizes alias case", () => { + expect(parseCommand("/ELEV off")).toEqual({ + name: "elevated", + args: "off", + }); + }); +}); diff --git a/src/tui/commands.ts b/src/tui/commands.ts index 60b299779..032b04ce6 100644 --- a/src/tui/commands.ts +++ b/src/tui/commands.ts @@ -11,11 +11,19 @@ export type ParsedCommand = { args: string; }; +const COMMAND_ALIASES: Record = { + elev: "elevated", +}; + export function parseCommand(input: string): ParsedCommand { const trimmed = input.replace(/^\//, "").trim(); if (!trimmed) return { name: "", args: "" }; const [name, ...rest] = trimmed.split(/\s+/); - return { name: name.toLowerCase(), args: rest.join(" ").trim() }; + const normalized = name.toLowerCase(); + return { + name: COMMAND_ALIASES[normalized] ?? normalized, + args: rest.join(" ").trim(), + }; } export function getSlashCommands(): SlashCommand[] { @@ -53,6 +61,14 @@ export function getSlashCommands(): SlashCommand[] { (value) => ({ value, label: value }), ), }, + { + name: "elev", + description: "Alias for /elevated", + getArgumentCompletions: (prefix) => + ELEVATED_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map( + (value) => ({ value, label: value }), + ), + }, { name: "activation", description: "Set group activation", @@ -88,6 +104,7 @@ export function helpText(): string { "/think ", "/verbose ", "/elevated ", + "/elev ", "/activation ", "/deliver ", "/new or /reset",