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:
@@ -608,19 +608,25 @@ export function startTerminalServer() {
|
||||
}
|
||||
|
||||
// Claude status types
|
||||
type ClaudeStatus = 'idle' | 'processing' | 'toolUse' | 'toolDone' | 'reading' | 'writing' | 'sessionStart' | 'subagentStart' | 'subagentStop' | 'notification' | 'permissionRequest' | 'thinking'
|
||||
type ClaudeStatus = 'idle' | 'thinking' | 'toolUse' | 'reading' | 'writing' | 'sessionStart' | 'sessionEnd' | 'permissionRequest' | 'interrupted' | 'error'
|
||||
|
||||
// Broadcast Claude status to ALL clients across ALL sessions
|
||||
export function broadcastClaudeStatus(status: ClaudeStatus, tool?: string, agent?: string) {
|
||||
const agentName = agent || 'main'
|
||||
|
||||
// Track agent running state from sessionStart
|
||||
// Track agent running state
|
||||
if (status === 'sessionStart') {
|
||||
const state = agentSessions.get(agentName)
|
||||
if (state) {
|
||||
state.isAgentRunning = true
|
||||
console.log(`[Terminal] Agent ${agentName} marked as running (sessionStart)`)
|
||||
}
|
||||
} else if (status === 'sessionEnd') {
|
||||
const state = agentSessions.get(agentName)
|
||||
if (state) {
|
||||
state.isAgentRunning = false
|
||||
console.log(`[Terminal] Agent ${agentName} marked as stopped (sessionEnd)`)
|
||||
}
|
||||
}
|
||||
|
||||
const message = JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user