- Refactor session state to use ptySessionId as primary key across all components - Add SessionStateManager with PTY-scoped hook processing, approval tracking, notifications - Add sync-engine debug panel (AgentStatesSection, HookTimelineSection, TerminalRegistrySection, WsMonitorSection) - Add useLifecycleStates composable for continuous state chips (session, responding, tool, subagent, compacting) - Add WS monitor endpoint and composable for real-time connection health - Enhance SessionLifecycleStatus with animated state chips and badge counts - Enhance SystemMessage with expanded content and better formatting - Update hooks (approval-permission, approval-plan, notify) with pty_session injection - Update approval system to derive pending lists from PTY-scoped state - Update ChatContainer with PTY-derived agent status and lifecycle events - Update AgentBadge with PTY-scoped status colors - Improve PiP window, approval window, and loading window handling
36 lines
1.5 KiB
PowerShell
36 lines
1.5 KiB
PowerShell
# Long-poll hooks-approval for PermissionRequest decisions
|
|
# Reads hook stdin, POSTs to backend, waits up to 125s for UI response
|
|
# Returns hookSpecificOutput JSON per Claude Code PermissionRequest docs
|
|
param([string]$agent = "")
|
|
if ($agent) { $logFile = "$PSScriptRoot/../.claude-$agent/debug/hooks.log" }
|
|
else { $logFile = "$PSScriptRoot/../.claude/debug/hooks.log"; $agent = "local" }
|
|
$ts = Get-Date -Format "HH:mm:ss.fff"
|
|
$b = [Console]::In.ReadToEnd()
|
|
Add-Content $logFile "[$ts] [PERM] Hook fired for agent=$agent stdin_len=$($b.Length)"
|
|
try {
|
|
$j = $b | ConvertFrom-Json
|
|
Add-Content $logFile "[$ts] [PERM] tool=$($j.tool_name) session=$($j.session_id)"
|
|
} catch {
|
|
Add-Content $logFile "[$ts] [PERM] WARN: stdin not valid JSON"
|
|
}
|
|
$url = 'http://localhost:4101/api/hooks-approval/permission'
|
|
$sep = '?'
|
|
$pty = $env:AGENT_UI_PTY_SESSION
|
|
if ($pty) { $url += "${sep}pty_session=$pty"; $sep = '&' }
|
|
if ($agent -and $agent -ne 'local') { $url += "${sep}agent=$agent" }
|
|
try {
|
|
Add-Content $logFile "[$ts] [PERM] POSTing to backend..."
|
|
$r = Invoke-RestMethod -Uri $url -Method POST -Body $b -ContentType 'application/json' -TimeoutSec 125
|
|
$ts2 = Get-Date -Format "HH:mm:ss.fff"
|
|
if ($r -and $r.hookSpecificOutput) {
|
|
$out = $r | ConvertTo-Json -Depth 10 -Compress
|
|
Add-Content $logFile "[$ts2] [PERM] Got response: $out"
|
|
$out
|
|
} else {
|
|
Add-Content $logFile "[$ts2] [PERM] Empty/timeout response (no hookSpecificOutput)"
|
|
}
|
|
} catch {
|
|
$ts2 = Get-Date -Format "HH:mm:ss.fff"
|
|
Add-Content $logFile "[$ts2] [PERM] ERROR: $($_.Exception.Message)"
|
|
}
|