Skip to content

The open-source app everyone uses to manage agents at work

Fix instructions tab state on agent switch

dottaa346ad2a7350
diff --git a/ui/src/pages/AgentDetail.tsx b/ui/src/pages/AgentDetail.tsx
index ce3685fba9..01d3175866 100644
--- a/ui/src/pages/AgentDetail.tsx
+++ b/ui/src/pages/AgentDetail.tsx
@@ -998,6 +998,7 @@ export function AgentDetail() {
{activeView === "instructions" && (
<PromptsTab
+ key={agent.id}
agent={agent}
companyId={resolvedCompanyId ?? undefined}
onDirtyChange={setConfigDirty}
@@ -1617,6 +1618,20 @@ function PromptsTab({
selectedFile: string;
} | null>(null);
+ useEffect(() => {
+ setSelectedFile("AGENTS.md");
+ setShowFilePanel(false);
+ setDraft(null);
+ setBundleDraft(null);
+ setNewFilePath("");
+ setShowNewFileInput(false);
+ setPendingFiles([]);
+ setExpandedDirs(new Set());
+ setAwaitingRefresh(false);
+ lastFileVersionRef.current = null;
+ externalBundleRef.current = null;
+ }, [agent.id]);
+
const isLocal =
agent.adapterType === "claude_local" ||
agent.adapterType === "codex_local" ||