feat: Add transcript-debug page with multi-agent support, hooks approval, and message selection

- Transcript debug: JSONL viewer, parsed chat view, realtime WebSocket updates, session selector
- Multi-agent: ejecutor, nucleo000, and claude (global ~/.claude/projects/) with agent switcher
- Hooks approval: permission/plan request forwarding via PowerShell hooks, long-poll API, UI modals
- Chat features: session ID copy, select mode with checkboxes, multi-select copy, select all/deselect all
- File watchers for all agent transcript directories with polling fallback on Windows
This commit is contained in:
2026-02-18 23:55:09 -06:00
parent d0fdd04132
commit 9bd6123f97
37 changed files with 5663 additions and 30 deletions

View File

@@ -8,6 +8,9 @@
import { PORT_GIT, WORKING_DIR } from '../config'
import { setupGitWatcher, handleGitClient, cleanupGitWatcher } from './handlers/git-handler'
import { setupComponentsWatcher, cleanupComponentsWatcher } from './handlers/components-handler'
import { setupTranscriptDebugWatcher, cleanupTranscriptDebugWatcher } from './handlers/transcript-debug-handler'
import { setTranscriptDebugBroadcast } from '../routes/transcript-debug'
import { setHooksApprovalBroadcast } from '../routes/hooks-approval'
import { handleTorchMessage, handleTorchConnect, handleTorchDisconnect, getTorchStatus, cleanupTorchHandler } from './handlers/torch-handler'
// Connected clients
@@ -31,13 +34,13 @@ export function getClients() {
export function startSyncServer() {
const server = Bun.serve({
port: PORT_GIT,
fetch(req, server) {
async fetch(req, server) {
const url = new URL(req.url)
// CORS headers
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, OPTIONS',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type'
}
@@ -45,6 +48,18 @@ export function startSyncServer() {
return new Response(null, { headers: corsHeaders })
}
// Broadcast endpoint (used by API server cross-process)
if (url.pathname === '/broadcast' && req.method === 'POST') {
try {
const message = await req.text()
console.log(`[Sync] /broadcast received (${message.length} bytes) → ${clients.size} clients`)
broadcast(message)
return Response.json({ ok: true, clients: clients.size }, { headers: corsHeaders })
} catch (e: any) {
return Response.json({ error: e.message }, { status: 400, headers: corsHeaders })
}
}
// Health check
if (url.pathname === '/health') {
const torchStatus = getTorchStatus()
@@ -100,6 +115,11 @@ export function startSyncServer() {
// Start file watchers
setupGitWatcher(WORKING_DIR, broadcast)
setupComponentsWatcher(WORKING_DIR, broadcast)
setupTranscriptDebugWatcher(WORKING_DIR, broadcast)
// Give the route handler access to broadcast for process-complete notifications
setTranscriptDebugBroadcast(broadcast)
setHooksApprovalBroadcast(broadcast)
return server
}
@@ -107,6 +127,7 @@ export function startSyncServer() {
export function stopSyncServer() {
cleanupGitWatcher()
cleanupComponentsWatcher()
cleanupTranscriptDebugWatcher()
cleanupTorchHandler()
clients.clear()
}