fix closing tab, remove 0/0 from credential modal

This commit is contained in:
bryan
2026-02-25 08:11:24 -08:00
parent cf5bf6f174
commit ead85dd41f
3 changed files with 20 additions and 7 deletions
@@ -248,7 +248,9 @@ export default function CredentialsModal({
{allRequiredMet ? (
<>
<Shield className="w-3.5 h-3.5" />
All required credentials connected ({connectedCount}/{rows.length} total)
{rows.length === 0
? "No required credentials!"
: `All required credentials connected (${connectedCount}/${rows.length} total)`}
</>
) : (
<>
+9
View File
@@ -2,6 +2,7 @@ import { useState, useCallback } from "react";
import { useNavigate } from "react-router-dom";
import { Crown, X } from "lucide-react";
import { loadPersistedTabs, savePersistedTabs, TAB_STORAGE_KEY, type PersistedTabState } from "@/lib/tab-persistence";
import { sessionsApi } from "@/api/sessions";
export interface TopBarTab {
agentType: string;
@@ -50,6 +51,14 @@ export default function TopBar({ tabs: tabsProp, onTabClick, onCloseTab, canClos
onCloseTab(agentType);
return;
}
// Kill the backend session (queen/judge/worker) even outside workspace
sessionsApi.list()
.then(({ sessions }) => {
const match = sessions.find(s => s.agent_path === agentType);
if (match) return sessionsApi.stop(match.session_id);
})
.catch(() => {}); // fire-and-forget
// Fallback: update localStorage directly (non-workspace pages)
setPersisted(prev => {
if (!prev) return null;
+8 -6
View File
@@ -358,6 +358,13 @@ export default function Workspace() {
});
const [activeWorker, setActiveWorker] = useState(initialAgent);
// Clear URL params after mount — they're consumed during initialization
// and leaving them causes confusion (stale ?agent= after tab switches, etc.)
useEffect(() => {
navigate("/workspace", { replace: true });
}, []);
const [credentialsOpen, setCredentialsOpen] = useState(false);
const [selectedNode, setSelectedNode] = useState<GraphNode | null>(null);
const [newTabOpen, setNewTabOpen] = useState(false);
@@ -473,10 +480,6 @@ export default function Workspace() {
...s, messages: [...s.messages, userMsg],
})),
}));
// Clean prompt from URL to prevent re-send on refresh
const params = new URLSearchParams(searchParams);
params.delete("prompt");
navigate(`/workspace?${params.toString()}`, { replace: true });
}
updateAgentState(agentType, {
@@ -623,7 +626,7 @@ export default function Workspace() {
} finally {
loadingRef.current.delete(agentType);
}
}, [updateAgentState, initialPrompt, searchParams, navigate]);
}, [updateAgentState, initialPrompt]);
// Auto-load agents when new tabs appear in sessionsByAgent
useEffect(() => {
@@ -1279,7 +1282,6 @@ export default function Workspace() {
// Pause worker execution if running (saves checkpoint), then kill the
// entire backend session so the queen and judge don't keep running.
const state = agentStates[agentType];
console.log('[closeAgentTab]', agentType, 'sessionId:', state?.sessionId, 'state:', state);
if (state?.sessionId) {
const pausePromise = (state.currentExecutionId && state.workerRunState === "running")
? executionApi.pause(state.sessionId, state.currentExecutionId)