Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ export class ChildAgentDetailComponent implements Component, Focusable {
private toolsExpanded = false;
private killConfirmExpiresAt = 0;
private killConfirmTimer: ReturnType<typeof setTimeout> | undefined;
private backHintLabel = "back to chat";

onCancel?: () => void;
onToggleToolsExpanded?: () => void;
Expand All @@ -613,6 +614,10 @@ export class ChildAgentDetailComponent implements Component, Focusable {
this.rebuildTranscriptComponents();
}

setBackHintLabel(label: string): void {
this.backHintLabel = label;
}

setToolsExpanded(expanded: boolean): void {
this.toolsExpanded = expanded;
for (const component of this.transcriptComponents) {
Expand Down Expand Up @@ -848,7 +853,7 @@ export class ChildAgentDetailComponent implements Component, Focusable {
? theme.fg("error", `${keyText("app.agents.delete", { primaryOnly: true }).trim()} again to stop`)
: keyAction("app.agents.delete", "stop", { primaryOnly: true });
return hintLine(
[keyAction("app.agents.back", "back to chat", { primaryOnly: true }), expandAction, stopAction],
[keyAction("app.agents.back", this.backHintLabel, { primaryOnly: true }), expandAction, stopAction],
width,
);
}
Expand Down
28 changes: 22 additions & 6 deletions packages/coding-agent/src/modes/interactive/interactive-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ export class InteractiveMode {
private childAgentNodes: ChildAgentInspectorNode[] = [];
private childAgentDetailNodeId: string | undefined;
private childAgentPanelMode: "detail" | undefined;
private enteredSessionViaSubagentDetail = false;

// Tool output expansion state
private toolOutputExpanded = false;
Expand Down Expand Up @@ -682,7 +683,13 @@ export class InteractiveMode {
getHideThinkingBlock: () => this.hideThinkingBlock,
getHiddenThinkingLabel: () => this.hiddenThinkingLabel,
});
this.childAgentDetail.onCancel = () => this.closeChildAgentPanel({ selectNodeId: this.childAgentDetailNodeId });
this.childAgentDetail.onCancel = () => {
if (this.options.returnToAgentsView && this.enteredSessionViaSubagentDetail) {
void this.returnToAgentsView();
return;
}
this.closeChildAgentPanel({ selectNodeId: this.childAgentDetailNodeId });
};
this.childAgentDetail.onToggleToolsExpanded = () => this.toggleToolOutputExpansion();
this.childAgentDetail.onKill = (nodeId) => void this.killChildAgent(nodeId);
this.widgetContainerAbove = new Container();
Expand Down Expand Up @@ -974,11 +981,18 @@ export class InteractiveMode {

// Jump straight into a subagent's read-only detail view when the agents
// view opened this session targeting one of its subagents.
if (this.options.initialSubagentNodeId && !this.openChildAgentDetail(this.options.initialSubagentNodeId)) {
// The subagent can finish and get released between the agents view
// listing it and this session attaching; say so instead of silently
// landing in the parent chat.
this.showStatus("Subagent already finished; showing its parent session");
if (this.options.initialSubagentNodeId) {
if (this.openChildAgentDetail(this.options.initialSubagentNodeId)) {
if (this.options.returnToAgentsView) {
this.enteredSessionViaSubagentDetail = true;
this.childAgentDetail.setBackHintLabel("back to agents");
}
} else {
// The subagent can finish and get released between the agents view
// listing it and this session attaching; say so instead of silently
// landing in the parent chat.
this.showStatus("Subagent already finished; showing its parent session");
}
}

// Set up theme file watcher
Expand Down Expand Up @@ -4578,6 +4592,8 @@ export class InteractiveMode {
private closeChildAgentPanel(options: { selectNodeId?: string } = {}): void {
this.childAgentPanelMode = undefined;
this.childAgentDetailNodeId = undefined;
this.enteredSessionViaSubagentDetail = false;
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
this.childAgentDetail.setBackHintLabel("back to chat");
this.childAgentDetail.setNode(undefined);
this.childAgentSummary.setHidden(false);
this.restoreMainAgentView();
Expand Down