feat(tui): add /elev alias

This commit is contained in:
Peter Steinberger
2026-01-06 08:41:04 +01:00
parent 882048d90b
commit 952657d55c
4 changed files with 36 additions and 1 deletions

View File

@@ -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`.

View File

@@ -52,6 +52,7 @@ Use SSH tunneling or Tailscale to reach the Gateway WS.
- `/think <off|minimal|low|medium|high>`
- `/verbose <on|off>`
- `/elevated <on|off>`
- `/elev <on|off>`
- `/activation <mention|always>`
- `/deliver <on|off>`
- `/new` or `/reset`

16
src/tui/commands.test.ts Normal file
View File

@@ -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",
});
});
});

View File

@@ -11,11 +11,19 @@ export type ParsedCommand = {
args: string;
};
const COMMAND_ALIASES: Record<string, string> = {
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 <off|minimal|low|medium|high>",
"/verbose <on|off>",
"/elevated <on|off>",
"/elev <on|off>",
"/activation <mention|always>",
"/deliver <on|off>",
"/new or /reset",