Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
13 changes: 12 additions & 1 deletion packages/coding-agent/src/modes/components/agent-dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ export class AgentDashboard extends Container {

onClose?: () => void;
onRequestRender?: () => void;
onApplySystemPrompt?: (agentName: string, prompt: string) => void;

private constructor(
private readonly cwd: string,
Expand Down Expand Up @@ -552,6 +553,12 @@ export class AgentDashboard extends Container {
this.#buildLayout();
}

#applySelectedAgentPrompt(): void {
const selected = this.#selectedAgent();
if (!selected?.systemPrompt) return;
this.onApplySystemPrompt?.(selected.name, selected.systemPrompt);
}

#beginCreateFlow(): void {
if (this.#createGenerating) return;
this.#createError = null;
Expand Down Expand Up @@ -975,7 +982,7 @@ export class AgentDashboard extends Container {
new Text(
theme.fg(
"dim",
" ↑/↓: navigate Space: toggle Enter: model override N: new agent Tab: source Ctrl+R: reload Esc: close",
" ↑/↓: navigate Space: toggle Enter: model override S: apply prompt N: new agent Tab: source Ctrl+R: reload Esc: close",
),
0,
0,
Expand Down Expand Up @@ -1090,6 +1097,10 @@ export class AgentDashboard extends Container {
this.#beginModelEdit();
return;
}
if (data.toLowerCase() === "s") {
this.#applySelectedAgentPrompt();
return;
}
if (data.toLowerCase() === "n") {
this.#beginCreateFlow();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ export class SelectorController {
dashboard.onRequestRender = () => {
this.ctx.ui.requestRender();
};
dashboard.onApplySystemPrompt = (agentName, prompt) => {
this.ctx.session.applyAgentSystemPrompt(agentName, prompt);
this.ctx.showStatus(`Applied ${agentName} agent prompt`);
done();
this.ctx.ui.requestRender();
};
return { component: dashboard, focus: dashboard };
});
}
Expand Down
15 changes: 15 additions & 0 deletions packages/coding-agent/src/session/agent-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3840,6 +3840,21 @@ export class AgentSession {
this.settings.set("interruptMode", mode);
}

/**
* Apply an agent's system prompt to the current session.
* Updates the agent's system prompt and appends a custom message entry.
*/
applyAgentSystemPrompt(agentName: string, prompt: string): void {
this.agent.setSystemPrompt(prompt);
this.sessionManager.appendCustomMessageEntry(
"agent-prompt-override",
`Agent prompt override: ${agentName}`,
false,
{ agentName },
"agent",
);
}

// =========================================================================
// Compaction
// =========================================================================
Expand Down