A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
feat(coding-agent): add /traces subcommand autocomplete (#2208)
Florian Brand55c611fbf630
diff --git a/packages/coding-agent/.changes/traces-argument-autocomplete.md b/packages/coding-agent/.changes/traces-argument-autocomplete.mdnew file mode 100644index 0000000000..62f1a0e97b--- /dev/null+++ b/packages/coding-agent/.changes/traces-argument-autocomplete.md@@ -0,0 +1 @@+- Added subcommand autocomplete to /traces, suggesting status, on, off, preview, upload, upload-current, upload-all, and login after the command.diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.tsindex c1e6dc58b1..e1927c6f6d 100644--- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts+++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts@@ -571,6 +571,17 @@ const HEARTBEAT_ARGUMENT_COMPLETIONS: AutocompleteItem[] = [},];+const TRACES_ARGUMENT_COMPLETIONS: AutocompleteItem[] = [+ { value: "status", label: "status", description: "Show trace sharing status" },+ { value: "on", label: "on", description: "Enable automatic trace uploads" },+ { value: "off", label: "off", description: "Disable automatic trace uploads" },+ { value: "preview", label: "preview", description: "Preview the current session trace" },+ { value: "upload", label: "upload", description: "Alias of upload-current" },+ { value: "upload-current", label: "upload-current", description: "Upload the current session trace" },+ { value: "upload-all", label: "upload-all", description: "Upload all persisted traces" },+ { value: "login", label: "login", description: "Configure the Prime API key for trace uploads" },+];+const DEAD_TERMINAL_ERROR_CODES = new Set(["EIO", "EPIPE", "ENOTCONN"]);// Cap on retained pasted-image bytes (base64). Images are resized below the@@ -1362,6 +1373,12 @@ export class InteractiveMode {this.getHeartbeatArgumentCompletions(prefix);}+ const tracesCommand = slashCommands.find((command) => command.name === "traces");+ if (tracesCommand) {+ tracesCommand.getArgumentCompletions = (prefix: string): AutocompleteItem[] | null =>+ this.getTracesArgumentCompletions(prefix);+ }+const connectionCommands = this.connectionCommands;const templateCommands: SlashCommand[] = connectionCommands.filter((cmd) => cmd.source === "prompt")@@ -8013,6 +8030,14 @@ export class InteractiveMode {return filtered.length === 0 ? null : filtered;}+ private getTracesArgumentCompletions(prefix: string): AutocompleteItem[] | null {+ const term = prefix.trim().toLowerCase();+ const filtered = term+ ? TRACES_ARGUMENT_COMPLETIONS.filter((item) => item.value.toLowerCase().startsWith(term))+ : TRACES_ARGUMENT_COMPLETIONS;+ return filtered.length === 0 ? null : filtered;+ }+private currentModelSupportsFastMode(): boolean {const model = this.getCurrentModel();return model !== undefined && supportsFastMode(model);diff --git a/packages/coding-agent/test/interactive-mode-traces-command.test.ts b/packages/coding-agent/test/interactive-mode-traces-command.test.tsindex 5c5a5c70ee..85bfad43eb 100644--- a/packages/coding-agent/test/interactive-mode-traces-command.test.ts+++ b/packages/coding-agent/test/interactive-mode-traces-command.test.ts@@ -1,3 +1,4 @@+import type { AutocompleteItem } from "@earendil-works/pi-tui";import { describe, expect, it, vi } from "vitest";import type { AgentTraceUploadAllResult, AgentTraceUploadResult } from "../src/core/agent-traces.js";import { AuthStorage } from "../src/core/auth-storage.js";@@ -24,6 +25,7 @@ interface TracesCommandContext {interface TracesCommandPrototype {handleTracesCommand(this: TracesCommandContext, text: string): Promise<void>;+ getTracesArgumentCompletions(prefix: string): AutocompleteItem[] | null;}const prototype = InteractiveMode.prototype as unknown as TracesCommandPrototype;@@ -142,4 +144,48 @@ describe("InteractiveMode /traces", () => {expect(context.showStatus).not.toHaveBeenCalledWith(expect.stringContaining("Uploaded 0 of 2"));expect(context.traceUploadAllAbortController).toBeUndefined();});++ describe("argument autocomplete", () => {+ it("lists every subcommand for an empty prefix", () => {+ const items = prototype.getTracesArgumentCompletions("");++ expect(items?.map((item) => item.value)).toEqual([+ "status",+ "on",+ "off",+ "preview",+ "upload",+ "upload-current",+ "upload-all",+ "login",+ ]);+ const statusItem = items?.find((item) => item.value === "status");+ expect(statusItem?.label).toBe("status");+ expect(statusItem?.description).toBe("Show trace sharing status");+ });++ it("filters subcommands by prefix", () => {+ const items = prototype.getTracesArgumentCompletions("up");++ expect(items?.map((item) => item.value)).toEqual(["upload", "upload-current", "upload-all"]);+ });++ it("matches a single subcommand exactly", () => {+ const items = prototype.getTracesArgumentCompletions("status");++ expect(items?.map((item) => item.value)).toEqual(["status"]);+ });++ it("filters case-insensitively", () => {+ const items = prototype.getTracesArgumentCompletions("LOGIN");++ expect(items?.map((item) => item.value)).toEqual(["login"]);+ });++ it("returns null for an unknown prefix", () => {+ const items = prototype.getTracesArgumentCompletions("xyz");++ expect(items).toBeNull();+ });+ });});