diff --git a/src/App.tsx b/src/App.tsx index af0f7f72..32927368 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -63,6 +63,7 @@ import { agents, getSessionInfo, isSessionMessagesLoading, + fetchSessions, } from "./stores/sessions" import { isSessionBusy } from "./stores/session-status" import { setupTabKeyboardShortcuts } from "./lib/keyboard" @@ -461,13 +462,24 @@ const App: Component = () => { const sessions = getSessions(instanceId) const session = sessions.find((s) => s.id === sessionId) - const isParent = session?.parentId === null + if (!session) { + return + } - if (!isParent) { + const parentSessionId = session.parentId ?? session.id + const parentSession = sessions.find((s) => s.id === parentSessionId) + + if (!parentSession || parentSession.parentId !== null) { return } clearActiveParentSession(instanceId) + + try { + await fetchSessions(instanceId) + } catch (error) { + console.error("Failed to refresh sessions after closing:", error) + } } function setupCommands() { diff --git a/src/components/message-stream.tsx b/src/components/message-stream.tsx index c3d8c12f..d0b867f9 100644 --- a/src/components/message-stream.tsx +++ b/src/components/message-stream.tsx @@ -545,15 +545,14 @@ export default function MessageStream(props: MessageStreamProps) { return (
-
+
{formattedSessionInfo()}
-
-
+
Command Palette
-
+
diff --git a/src/components/session-list.tsx b/src/components/session-list.tsx index 3e759bc3..0c72b9e1 100644 --- a/src/components/session-list.tsx +++ b/src/components/session-list.tsx @@ -225,7 +225,7 @@ const SessionList: Component = (props) => {
{ event.stopPropagation() props.onClose(rowProps.sessionId) @@ -333,11 +333,13 @@ const SessionList: Component = (props) => { role="button" aria-selected={props.activeSessionId === "info"} > -
- - Instance Info +
+
+ + Instance Info +
+ {infoShortcut && }
- {infoShortcut && }
diff --git a/src/components/tool-call.tsx b/src/components/tool-call.tsx index f5e779ff..273bde7b 100644 --- a/src/components/tool-call.tsx +++ b/src/components/tool-call.tsx @@ -699,7 +699,7 @@ export default function ToolCall(props: ToolCallProps) { } } - const shouldShowTag = (status: string) => status === "in_progress" || status === "cancelled" + const shouldShowTag = (status: string) => status === "cancelled" return (
diff --git a/src/stores/sessions.ts b/src/stores/sessions.ts index abad0b65..6596e703 100644 --- a/src/stores/sessions.ts +++ b/src/stores/sessions.ts @@ -409,15 +409,19 @@ async function fetchSessions(instanceId: string): Promise { return } + const existingSessions = sessions().get(instanceId) + for (const apiSession of response.data) { + const existingSession = existingSessions?.get(apiSession.id) + sessionMap.set(apiSession.id, { id: apiSession.id, instanceId, title: apiSession.title || "Untitled", parentId: apiSession.parentID || null, - agent: "", - model: { providerId: "", modelId: "" }, - version: apiSession.version, // Include version from SDK + agent: existingSession?.agent ?? "", + model: existingSession?.model ?? { providerId: "", modelId: "" }, + version: apiSession.version, // Include version from SDK time: { ...apiSession.time, }, @@ -429,17 +433,34 @@ async function fetchSessions(instanceId: string): Promise { diff: apiSession.revert.diff, } : undefined, - messages: [], - messagesInfo: new Map(), + messages: existingSession?.messages ?? [], + messagesInfo: existingSession?.messagesInfo ?? new Map(), }) } + const validSessionIds = new Set(sessionMap.keys()) + setSessions((prev) => { const next = new Map(prev) next.set(instanceId, sessionMap) return next }) + setMessagesLoaded((prev) => { + const next = new Map(prev) + const loadedSet = next.get(instanceId) + if (loadedSet) { + const filtered = new Set() + for (const id of loadedSet) { + if (validSessionIds.has(id)) { + filtered.add(id) + } + } + next.set(instanceId, filtered) + } + return next + }) + for (const session of sessionMap.values()) { const flag = (session.time as (Session["time"] & { compacting?: number | boolean }) | undefined)?.compacting const active = typeof flag === "number" ? flag > 0 : Boolean(flag) diff --git a/src/styles/components.css b/src/styles/components.css index b943d926..51ea6b02 100644 --- a/src/styles/components.css +++ b/src/styles/components.css @@ -545,11 +545,25 @@ button.button-primary:disabled { } .connection-status { - @apply flex justify-center items-center px-4 py-2 gap-4; + @apply grid items-center px-4 py-2 gap-4; + grid-template-columns: 1fr auto 1fr; background-color: var(--surface-secondary); border-bottom: 1px solid var(--border-base); } +.connection-status-info { + justify-self: start; +} + +.connection-status-shortcut { + justify-self: center; + text-align: center; +} + +.connection-status-meta { + justify-self: end; +} + .connection-status-text { color: var(--text-muted); }