Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

add /rename alias and agents-view rename shortcut (#226)

kte855bbaeea10
diff --git a/packages/coding-agent/src/core/keybindings.ts b/packages/coding-agent/src/core/keybindings.ts
index 46f6b72dec..3647350444 100644
--- a/packages/coding-agent/src/core/keybindings.ts
+++ b/packages/coding-agent/src/core/keybindings.ts
@@ -35,6 +35,7 @@ export interface AppKeybindings {
"app.agents.reply": true;
"app.agents.delete": true;
"app.agents.program": true;
+ "app.agents.rename": true;
"app.tree.foldOrUp": true;
"app.tree.unfoldOrDown": true;
"app.tree.editLabel": true;
@@ -118,6 +119,7 @@ export const KEYBINDINGS = {
"app.agents.reply": { defaultKeys: "space", description: "Reply to selected agent" },
"app.agents.delete": { defaultKeys: "ctrl+x", description: "Stop or delete selected agent" },
"app.agents.program": { defaultKeys: "ctrl+o", description: "Show the program that spawned subagents" },
+ "app.agents.rename": { defaultKeys: "ctrl+r", description: "Rename selected agent session" },
"app.tree.foldOrUp": {
defaultKeys: ["ctrl+left", "alt+left"],
description: "Fold tree branch or move up",
@@ -263,6 +265,7 @@ const KEYBINDING_NAME_MIGRATIONS = {
agentsReply: "app.agents.reply",
agentsDelete: "app.agents.delete",
agentsProgram: "app.agents.program",
+ agentsRename: "app.agents.rename",
treeFoldOrUp: "app.tree.foldOrUp",
treeUnfoldOrDown: "app.tree.unfoldOrDown",
treeEditLabel: "app.tree.editLabel",
diff --git a/packages/coding-agent/src/core/slash-commands.ts b/packages/coding-agent/src/core/slash-commands.ts
index 25e8c9c803..ddd48981e8 100644
--- a/packages/coding-agent/src/core/slash-commands.ts
+++ b/packages/coding-agent/src/core/slash-commands.ts
@@ -79,6 +79,7 @@ const CANONICAL_BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [
const BUILTIN_SLASH_COMMAND_ALIASES: ReadonlyArray<BuiltinSlashCommandAlias> = [
{ name: "clear", aliasFor: "new" },
{ name: "usage", aliasFor: "context" },
+ { name: "rename", aliasFor: "name" },
];
function buildBuiltinSlashCommands(): ReadonlyArray<BuiltinSlashCommand> {
diff --git a/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts b/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts
index bf9d9c7409..f5c10beb2d 100644
--- a/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts
+++ b/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts
@@ -300,6 +300,7 @@ class AgentsViewMode implements Component, Focusable {
private replyHeaderTime = "";
private pendingDeleteAgent: PendingDeleteAgent | undefined;
private pendingKillSubagent: PendingKillSubagent | undefined;
+ private renameTarget: { activeSessionId: string; identity: string } | undefined;
private readonly inactiveAgentIdentities = new Set<string>();
private statusMessage: string | undefined;
private statusMessageTone: "muted" | "error" | "warning" = "muted";
@@ -398,10 +399,24 @@ class AgentsViewMode implements Component, Focusable {
handleInput(data: string): void {
this.clearStickyStatusMessage();
+ // While renaming, the editor holds the proposed name: Escape cancels, Enter
+ // (via onSubmit) confirms, everything else edits the text.
+ if (this.renameTarget) {
+ if (this.keybindings.matches(data, "tui.select.cancel")) {
+ this.exitRenameMode();
+ return;
+ }
+ this.editor.handleInput(data);
+ return;
+ }
if (this.keybindings.matches(data, "app.clear")) {
this.handleCtrlC();
return;
}
+ if (this.keybindings.matches(data, "app.agents.rename") && this.editor.getText().length === 0) {
+ this.enterRenameMode();
+ return;
+ }
if (this.keybindings.matches(data, "app.agents.delete") && this.editor.getText().length === 0) {
this.clearCtrlCExitHint({ render: false });
void this.handleDeleteSelected();
@@ -722,6 +737,10 @@ class AgentsViewMode implements Component, Focusable {
}
private async submit(value: string): Promise<void> {
+ if (this.renameTarget) {
+ await this.confirmRename(value);
+ return;
+ }
const text = value.trim();
if (!text) {
if (this.replyActiveSessionId) {
@@ -1077,6 +1096,62 @@ class AgentsViewMode implements Component, Focusable {
this.ui.requestRender();
}
+ private enterRenameMode(): void {
+ const row = this.rows[this.selectedIndex];
+ // Only top-level agents carry a renameable session; subagents do not.
+ if (row?.kind !== "agent" || !row.selectable) {
+ return;
+ }
+ const activeSessionId = row.summary.activeSessionId;
+ if (!activeSessionId) {
+ this.setStatusMessage("This agent has no active session to rename");
+ return;
+ }
+ this.setReplyTarget(undefined);
+ this.pendingDeleteAgent = undefined;
+ this.pendingKillSubagent = undefined;
+ this.renameTarget = { activeSessionId, identity: getSummaryIdentity(row.summary) };
+ this.editor.setPlaceholder("Name this agent session");
+ this.editor.setText(row.summary.sessionName ?? "");
+ this.ui.requestRender();
+ }
+
+ private exitRenameMode(): void {
+ this.renameTarget = undefined;
+ this.editor.setText("");
+ this.editor.setPlaceholder(DEFAULT_PROMPT_PLACEHOLDER);
+ this.ui.requestRender();
+ }
+
+ private async confirmRename(value: string): Promise<void> {
+ const target = this.renameTarget;
+ if (!target) {
+ return;
+ }
+ const name = value.trim();
+ if (!name) {
+ this.exitRenameMode();
+ return;
+ }
+ this.exitRenameMode();
+ this.setStatusMessage("Renaming agent...");
+ try {
+ await this.requireClient().request({
+ type: "rename",
+ activeSessionId: target.activeSessionId,
+ name,
+ });
+ this.setStatusMessage(`Renamed to ${name}`, { render: false });
+ await this.refreshSessions();
+ } catch (error) {
+ this.setStatusMessage(
+ isUnknownDaemonCommandError(error, "rename")
+ ? "Failed to rename: the daemon is running an older build; restart the daemon and try again"
+ : formatError("Failed to rename agent", error),
+ );
+ }
+ }
+
private getReplyHeaderTime(activeSessionId: string): string {
const summary = this.findSummaryByActiveSessionId(activeSessionId);
return formatAgentsViewRelativeTime(summary?.modified ?? summary?.created);
@@ -1087,6 +1162,9 @@ class AgentsViewMode implements Component, Focusable {
}
private renderReplyHeaderLine(): string | undefined {
+ if (this.renameTarget) {
+ return theme.fg("warning", "Rename agent session");
+ }
if (!this.replyActiveSessionId) {
return undefined;
}
@@ -1644,6 +1722,10 @@ class AgentsViewMode implements Component, Focusable {
if (this.statusMessage) {
return truncateToWidth(theme.fg(this.statusMessageTone, this.statusMessage), width);
}
+ if (this.renameTarget) {
+ const hint = `${keyText("tui.select.confirm")} save ${keyText("tui.select.cancel")} cancel`;
+ return truncateToWidth(theme.fg("muted", hint), width);
+ }
// Replying is reserved for top-level agents; subagents can be stopped.
const selectedRow = this.rows[this.selectedIndex];
const selectedAgent = selectedRow?.kind === "agent";
@@ -1653,6 +1735,7 @@ class AgentsViewMode implements Component, Focusable {
`${keyText("tui.select.confirm")} open/send`,
"/ commands",
selectedAgent ? `${keyText("app.agents.reply")} reply` : undefined,
+ selectedAgent ? `${keyText("app.agents.rename")} rename` : undefined,
selectedAgent ? `${keyText("app.agents.delete")} stop/deactivate` : undefined,
selectedSubagent ? `${keyText("app.agents.delete")} stop` : undefined,
this.selectedRowCanShowProgram() ? `${keyText("app.agents.program")} program` : undefined,
diff --git a/packages/coding-agent/test/slash-commands.test.ts b/packages/coding-agent/test/slash-commands.test.ts
index c2b1ace4a3..2cc9b6df72 100644
--- a/packages/coding-agent/test/slash-commands.test.ts
+++ b/packages/coding-agent/test/slash-commands.test.ts
@@ -20,6 +20,7 @@ describe("slash command aliases", () => {
test("keeps aliases hidden on canonical command entries", () => {
expect(BUILTIN_SLASH_COMMANDS.find((command) => command.name === "clear")).toBeUndefined();
expect(BUILTIN_SLASH_COMMANDS.find((command) => command.name === "usage")).toBeUndefined();
+ expect(BUILTIN_SLASH_COMMANDS.find((command) => command.name === "rename")).toBeUndefined();
expect(BUILTIN_SLASH_COMMANDS.find((command) => command.name === "new")).toMatchObject({
description: "Start a new session",
aliases: ["clear"],
@@ -28,6 +29,23 @@ describe("slash command aliases", () => {
description: "Show token, cost, and context usage for agent and sub-agents",
aliases: ["usage"],
});
+ expect(BUILTIN_SLASH_COMMANDS.find((command) => command.name === "name")).toMatchObject({
+ description: "Set session display name",
+ aliases: ["rename"],
+ });
+ });
+
+ test("resolves /rename to /name through the alias path", () => {
+ const parsed = parseSlashCommand("/rename my session");
+
+ expect(isBuiltinSlashCommandName("rename")).toBe(true);
+ expect(resolveBuiltinSlashCommandName("rename")).toBe("name");
+ expect(resolveSlashCommand(parsed!)).toEqual({
+ name: "name",
+ args: "my session",
+ originalName: "rename",
+ isAlias: true,
+ });
});
test("resolves /clear to /new through the alias path", () => {