fix: clients sync to server terminals instead of creating new ones

- Remove auto-creation of terminal sessions from init/selectSession/switchAgent
- Clients only connect to existing alive terminals from server registry
- Remove localStorage persistence (agent/sessionId) — state derived from server
- Refine session-state types: new AgentStatus values, LastError interface
- UI improvements: AgentBadge, ChatContainer, UserInput, BashCard updates
- Simplify claude-hook routes, update session-state service
This commit is contained in:
2026-02-20 22:26:17 -06:00
parent 653c4e6d23
commit a6c68f1b9e
17 changed files with 1036 additions and 189 deletions

View File

@@ -5,14 +5,15 @@ import { ref, computed } from 'vue'
export type AgentStatus =
| 'idle'
| 'processing'
| 'thinking'
| 'reading'
| 'writing'
| 'toolUse'
| 'toolDone'
| 'permissionRequest'
| 'notification'
| 'interrupted'
| 'error'
| 'sessionStart'
| 'sessionEnd'
export interface ActiveTool {
name: string
@@ -48,6 +49,13 @@ export interface AgentTerminalInfo {
connectedClients: number
}
export interface LastError {
tool: string
message: string
interrupted: boolean
timestamp: number
}
export interface AgentSessionState {
agent: string
sessionId: string | null
@@ -59,6 +67,7 @@ export interface AgentSessionState {
currentTool: ActiveTool | null
lastActivity: number
lastStopResponse: string | null
lastError: LastError | null
pendingApprovals: PendingApproval[]
terminal: AgentTerminalInfo
notifications: SessionNotification[]
@@ -130,6 +139,14 @@ export const useSessionState = defineStore('session-state', () => {
)
)
const isProcessing = computed(() =>
agentList.value.some(a => !['idle', 'sessionStart', 'sessionEnd'].includes(a.status))
)
const hasErrors = computed(() =>
agentList.value.some(a => a.status === 'error' || a.status === 'interrupted')
)
const visibleNotifications = computed(() => {
const now = Date.now()
return agentList.value
@@ -199,6 +216,8 @@ export const useSessionState = defineStore('session-state', () => {
anyPendingApprovals,
totalPendingApprovals,
allPendingApprovals,
isProcessing,
hasErrors,
visibleNotifications,
handleMessage,
respondApproval,