Skip to content

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

Rust

polish subagent model labels and viewer hints (#470)

ktb77a30ccebf8
diff --git a/packages/coding-agent/src/modes/interactive/components/child-agent-inspector.ts b/packages/coding-agent/src/modes/interactive/components/child-agent-inspector.ts
index 1627a212ad..98f3bf8892 100644
--- a/packages/coding-agent/src/modes/interactive/components/child-agent-inspector.ts
+++ b/packages/coding-agent/src/modes/interactive/components/child-agent-inspector.ts
@@ -1,3 +1,4 @@
+import { getModels, type KnownProvider } from "@earendil-works/pi-ai";
import {
type Component,
type Focusable,
@@ -193,7 +194,20 @@ function padTableCell(value: string, width: number, ellipsis = ""): string {
return truncated + " ".repeat(Math.max(0, width - visibleWidth(truncated)));
}
-function truncateModelSelector(value: string, width: number): string {
+function childAgentModelLabel(selector: string | undefined): string {
+ if (!selector) {
+ return "";
+ }
+ const separatorIndex = selector.indexOf("/");
+ if (separatorIndex === -1) {
+ return selector;
+ }
+ const provider = selector.slice(0, separatorIndex);
+ const modelId = selector.slice(separatorIndex + 1);
+ return getModels(provider as KnownProvider).find((model) => model.id === modelId)?.name ?? modelId;
+}
+
+function truncateModelLabel(value: string, width: number): string {
if (visibleWidth(value) <= width) {
return value;
}
@@ -470,10 +484,10 @@ export class ChildAgentSummaryComponent implements Component, Focusable {
const agentCell = theme.fg("muted", padTableCell(agentLabel, agentWidth));
const promptCell = this.elidePrompt(this.entryLabel(entry), sharedPrefix, sharedSuffix, promptWidth);
const recapCell = theme.fg("muted", padTableCell(childAgentRecap(entry.node), recapWidth, "…"));
- const model = entry.node.model ?? "";
+ const model = childAgentModelLabel(entry.node.model);
const tokens = entry.node.tokenCount === undefined ? "" : `${formatTokenCount(entry.node.tokenCount)} tok`;
const duration = formatChildAgentDuration(entry.node.durationMs);
- const modelCell = padTableCell(truncateModelSelector(model, SUMMARY_MODEL_WIDTH), SUMMARY_MODEL_WIDTH);
+ const modelCell = padTableCell(truncateModelLabel(model, SUMMARY_MODEL_WIDTH), SUMMARY_MODEL_WIDTH);
const tokensCell = padTableCell(tokens, SUMMARY_TOKENS_WIDTH, "…");
const durationCell = padTableCell(duration, SUMMARY_DURATION_WIDTH, "…");
const metrics = `${modelCell} ${tokensCell}${" ".repeat(SUMMARY_TOKEN_TIME_GAP)}${durationCell}`;
@@ -833,10 +847,9 @@ export class ChildAgentDetailComponent implements Component, Focusable {
const actions = [backAction, expandAction, stopAction];
const separatorWidth = visibleWidth(joinHints(["", ""]));
const modelWidth = Math.max(0, width - visibleWidth(joinHints(actions)) - separatorWidth);
+ const modelLabel = childAgentModelLabel(this.node?.model);
const model =
- this.node?.model && modelWidth >= 4
- ? theme.fg("muted", truncateToWidth(this.node.model, modelWidth, "…"))
- : undefined;
+ modelLabel && modelWidth >= 4 ? theme.fg("muted", truncateToWidth(modelLabel, modelWidth, "…")) : undefined;
return hintLine([backAction, model, expandAction, stopAction], width);
}
diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
index 218b164dcf..f9c8bf8cc5 100644
--- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts
+++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
@@ -2977,6 +2977,9 @@ export class InteractiveMode {
private startFeatureHintPresentation(): void {
this.clearFeatureHintPresentation();
+ if (this.childAgentPanelMode) {
+ return;
+ }
if (this.featureHintEligibleAt === 0) {
this.featureHintEligibleAt = Date.now() + FEATURE_HINT_DELAY_MS;
}
@@ -3038,6 +3041,16 @@ export class InteractiveMode {
}
}
+ private resumeFeatureHintPresentation(): void {
+ if (
+ this.loadingAnimation &&
+ this.shouldShowWorkingLoader() &&
+ this.statusContainer.children.includes(this.loadingAnimation)
+ ) {
+ this.startFeatureHintPresentation();
+ }
+ }
+
private endFeatureHintRun(): void {
this.clearFeatureHintPresentation();
this.currentFeatureHint = undefined;
@@ -3637,8 +3650,9 @@ export class InteractiveMode {
this.enteredSessionViaSubagentDetail = false;
this.childAgentDetail.setBackHintLabel("back to chat");
this.childAgentDetail.setNode(undefined);
+ this.childAgentPanelMode = undefined;
+ this.resumeFeatureHintPresentation();
}
- this.childAgentPanelMode = undefined;
this.childAgentSummary.setHidden(false);
// Save text from current editor before switching
@@ -5518,6 +5532,7 @@ export class InteractiveMode {
return false;
}
this.childAgentPanelMode = "detail";
+ this.clearFeatureHintPresentation();
this.childAgentDetailNodeId = nodeId;
this.childAgentDetail.setNode(node);
this.childAgentDetail.setBodyComponents([]);
@@ -5656,6 +5671,7 @@ export class InteractiveMode {
this.childAgentDetail.setBodyComponents([]);
this.childAgentSummary.setHidden(false);
this.restoreMainAgentView();
+ this.resumeFeatureHintPresentation();
// Restore the parent recap that was suppressed while the panel was open.
this.renderRecap();
// Re-render queued previews cleared on panel entry; the queue may still hold messages.
diff --git a/packages/coding-agent/test/child-agent-summary-list.test.ts b/packages/coding-agent/test/child-agent-summary-list.test.ts
index 699af06685..02482e9475 100644
--- a/packages/coding-agent/test/child-agent-summary-list.test.ts
+++ b/packages/coding-agent/test/child-agent-summary-list.test.ts
@@ -57,17 +57,18 @@ describe("ChildAgentSummaryComponent inline list", () => {
const summary = new ChildAgentSummaryComponent();
summary.setNodes([{ ...node("a"), model: "openai/gpt-5.4", toolUseCount: 3, tokenCount: 41_000 }]);
const out = stripAnsi(summary.render(80).join("\n"));
- expect(out).toContain("openai/gpt-5.4");
+ expect(out).toContain("GPT-5.4");
+ expect(out).not.toContain("openai/gpt-5.4");
expect(out).toContain("41k tok");
expect(out).not.toContain("tools");
});
- it("preserves the model suffix when its selector is truncated", () => {
+ it("preserves nested model ids when the label is truncated", () => {
const summary = new ChildAgentSummaryComponent();
summary.setNodes([{ ...node("a"), model: "prime-inference/internal/glm-5.2-fast" }]);
const out = stripAnsi(summary.render(80).join("\n"));
- expect(out).toContain("prime-…/glm-5.2-fast");
- expect(out).not.toContain("prime-inference/int…");
+ expect(out).toContain("intern…/glm-5.2-fast");
+ expect(out).not.toContain("prime-inference");
});
it("shows recaps in a fixed column and falls back to activity", () => {
@@ -199,8 +200,9 @@ describe("ChildAgentSummaryComponent inline list", () => {
detail.setNode({ ...node("a"), model: "anthropic/claude-opus-4-7" });
const hint = stripAnsi(detail.render(100).at(-1) ?? "");
expect(hint).toContain("back to chat");
- expect(hint).toContain("anthropic/claude-opus-4-7");
- expect(hint.indexOf("anthropic/claude-opus-4-7")).toBeGreaterThan(hint.indexOf("back to chat"));
+ expect(hint).toContain("Claude Opus 4.7");
+ expect(hint).not.toContain("anthropic/claude-opus-4-7");
+ expect(hint.indexOf("Claude Opus 4.7")).toBeGreaterThan(hint.indexOf("back to chat"));
});
it("truncates long models before hiding detail actions", () => {
@@ -211,7 +213,8 @@ describe("ChildAgentSummaryComponent inline list", () => {
});
const hint = stripAnsi(detail.render(60).at(-1) ?? "");
expect(hint).toContain("back to chat");
- expect(hint).toContain("provider-…");
+ expect(hint).toContain("model-wit…");
+ expect(hint).not.toContain("provider-with-a-long-name");
expect(hint).toContain("to expand");
expect(hint).toContain("stop");
});
diff --git a/packages/coding-agent/test/interactive-mode-feature-hints.test.ts b/packages/coding-agent/test/interactive-mode-feature-hints.test.ts
index d5d12b7877..4a671b75f5 100644
--- a/packages/coding-agent/test/interactive-mode-feature-hints.test.ts
+++ b/packages/coding-agent/test/interactive-mode-feature-hints.test.ts
@@ -43,6 +43,7 @@ function createMode() {
featureHintAnimationTimer: undefined,
featureHintComponent: undefined,
featureHintRunPending: false,
+ childAgentPanelMode: undefined,
options: { returnToAgentsView: true },
ui: { requestRender },
};
@@ -170,6 +171,48 @@ describe("InteractiveMode feature hints", () => {
expect(requestRender).not.toHaveBeenCalled();
});
+ it("suspends hints in subagent detail and resumes them in the parent view", () => {
+ const { mode, featureHintContainer, featureHintDeck } = createMode();
+ Reflect.set(mode, "childAgentPanelMode", "detail");
+
+ callPrivate(mode, "startFeatureHintPresentation");
+ vi.advanceTimersByTime(5_000);
+ expect(featureHintContainer.children).toHaveLength(0);
+ expect(featureHintDeck.next).not.toHaveBeenCalled();
+
+ Reflect.set(mode, "childAgentPanelMode", undefined);
+ callPrivate(mode, "resumeFeatureHintPresentation");
+ vi.advanceTimersByTime(5_000);
+ expect(featureHintContainer.children).toHaveLength(1);
+ expect(featureHintDeck.next).toHaveBeenCalledOnce();
+ });
+
+ it("resumes hints when an editor switch closes subagent detail", () => {
+ const resumeFeatureHintPresentation = vi.fn();
+ const defaultEditor = { setText: vi.fn() };
+ const mode = {
+ childAgentPanelMode: "detail",
+ childAgentDetailNodeId: "subagent-1",
+ enteredSessionViaSubagentDetail: true,
+ childAgentDetail: { setBackHintLabel: vi.fn(), setNode: vi.fn() },
+ childAgentSummary: { setHidden: vi.fn() },
+ editor: { getText: () => "draft" },
+ defaultEditor,
+ editorContainer: { clear: vi.fn(), addChild: vi.fn() },
+ ui: { setFocus: vi.fn(), requestRender: vi.fn() },
+ restoreMainAgentView: vi.fn(),
+ updatePendingMessagesDisplay: vi.fn(),
+ resumeFeatureHintPresentation,
+ };
+ Object.setPrototypeOf(mode, InteractiveMode.prototype);
+
+ Reflect.get(InteractiveMode.prototype, "setCustomEditorComponent").call(mode, undefined);
+
+ expect(Reflect.get(mode, "childAgentPanelMode")).toBeUndefined();
+ expect(defaultEditor.setText).toHaveBeenCalledWith("draft");
+ expect(resumeFeatureHintPresentation).toHaveBeenCalledOnce();
+ });
+
it("retains the hint and remaining delay when the loader is recreated", () => {
const { mode, statusContainer, featureHintContainer, featureHintDeck } = createMode();
diff --git a/packages/coding-agent/test/marquee-components.test.ts b/packages/coding-agent/test/marquee-components.test.ts
index 103f77f77e..f181d84578 100644
--- a/packages/coding-agent/test/marquee-components.test.ts
+++ b/packages/coding-agent/test/marquee-components.test.ts
@@ -459,7 +459,8 @@ describe("marquee TUI components", () => {
expect(summaryText).toContain("37% context left");
expect(summaryText).toContain("S1");
expect(summaryText).toContain("inspect train…");
- expect(summaryText).toContain("openai/gpt-5.4");
+ expect(summaryText).toContain("GPT-5.4");
+ expect(summaryText).not.toContain("openai/gpt-5.4");
const infoRow = summary.render(90)[0] ?? "";
expect(visibleWidth(infoRow)).toBe(90);
@@ -488,7 +489,8 @@ describe("marquee TUI components", () => {
expect(detail).toContain("inspect training logs");
expect(detail).toContain("reading shard metrics");
expect(detail).toContain("← back to chat");
- expect(stripAnsi(detailComponent.render(80).at(-1) ?? "")).toContain("openai/gpt-5.4");
+ expect(stripAnsi(detailComponent.render(80).at(-1) ?? "")).toContain("GPT-5.4");
+ expect(stripAnsi(detailComponent.render(80).at(-1) ?? "")).not.toContain("openai/gpt-5.4");
expect(detail).not.toContain("user: inspect training logs");
expect(detail).not.toContain("assistant: reading shard metrics");
});