feat: refresh agent session state on terminal switch
Add refreshAgentState() to session-state store that fetches fresh state
(hookHistory, status, etc.) via GET /session-state/{agent} from the
terminal server. Called in switchToTerminal() to ensure the UI shows
accurate hook counts when changing between terminals.
This commit is contained in:
@@ -254,6 +254,12 @@ export function useTranscriptDebug() {
|
|||||||
await fetchSessions()
|
await fetchSessions()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Refresh agent session state (hookHistory, status, etc.) from server
|
||||||
|
const targetAgent = entry?.agent || selectedAgent.value
|
||||||
|
if (targetAgent) {
|
||||||
|
await sessionStore.refreshAgentState(targetAgent)
|
||||||
|
}
|
||||||
|
|
||||||
// Load the target session's transcript (skip for __new__ — no transcript yet)
|
// Load the target session's transcript (skip for __new__ — no transcript yet)
|
||||||
selectedSessionId.value = transcriptSessionId
|
selectedSessionId.value = transcriptSessionId
|
||||||
if (transcriptSessionId === '__new__') {
|
if (transcriptSessionId === '__new__') {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
import { terminalApiUrl } from '../config/endpoints'
|
||||||
|
|
||||||
// ── Types (mirror server/services/session-state.ts) ──
|
// ── Types (mirror server/services/session-state.ts) ──
|
||||||
|
|
||||||
@@ -210,6 +211,16 @@ export const useSessionState = defineStore('session-state', () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function refreshAgentState(agent: string) {
|
||||||
|
try {
|
||||||
|
const res = await fetch(terminalApiUrl(`/session-state/${agent}`))
|
||||||
|
if (!res.ok) return
|
||||||
|
const state = await res.json() as AgentSessionState
|
||||||
|
agents.value = { ...agents.value, [agent]: state }
|
||||||
|
lastUpdate.value = Date.now()
|
||||||
|
} catch { /* silent — WS patches will catch up */ }
|
||||||
|
}
|
||||||
|
|
||||||
function setConnected(value: boolean) {
|
function setConnected(value: boolean) {
|
||||||
connected.value = value
|
connected.value = value
|
||||||
}
|
}
|
||||||
@@ -229,6 +240,7 @@ export const useSessionState = defineStore('session-state', () => {
|
|||||||
hasErrors,
|
hasErrors,
|
||||||
visibleNotifications,
|
visibleNotifications,
|
||||||
handleMessage,
|
handleMessage,
|
||||||
|
refreshAgentState,
|
||||||
respondApproval,
|
respondApproval,
|
||||||
respondPlanApproval,
|
respondPlanApproval,
|
||||||
setConnected,
|
setConnected,
|
||||||
|
|||||||
Reference in New Issue
Block a user