These files accumulated between commit d4a3f2b (initial dashboard) and
today's fix work. Grouping them into one commit to avoid losing history
rather than attempting to backdate individual changes.
Contents:
• dashboard gateway routes: /api/gw/* + /api/status + /api/tiger/dispatch
• dashboard components: app-sidebar, cost-monitor, kanban-board, task-dialog
• dashboard hooks/lib: use-gateway, gateway client
• dashboard shadcn/ui: dialog, progress, select
• bridge routes: gateway (gateway proxy for bridge-side control)
• next.config.ts + package.json/lock updates
Future work should commit in smaller, topical units.
49 lines
No EOL
1.4 KiB
TypeScript
49 lines
No EOL
1.4 KiB
TypeScript
const BRIDGE_URL = process.env.TIGER_BRIDGE_URL || "http://localhost:3456"
|
|
const BRIDGE_TOKEN = process.env.TIGER_BRIDGE_TOKEN || ""
|
|
|
|
export const dynamic = "force-dynamic"
|
|
|
|
export async function GET() {
|
|
const encoder = new TextEncoder()
|
|
|
|
const stream = new ReadableStream({
|
|
start(controller) {
|
|
// Send initial connected message
|
|
controller.enqueue(
|
|
encoder.encode(
|
|
`data: ${JSON.stringify({ event: "stream.connected", payload: { connected: true } })}\n\n`
|
|
)
|
|
)
|
|
|
|
// Poll tiger status instead of gateway directly
|
|
const interval = setInterval(async () => {
|
|
try {
|
|
const res = await fetch(`${BRIDGE_URL}/tiger/status`, {
|
|
headers: { "Authorization": `Bearer ${BRIDGE_TOKEN}` },
|
|
})
|
|
const data = await res.json()
|
|
controller.enqueue(
|
|
encoder.encode(
|
|
`data: ${JSON.stringify({ event: "health", payload: { status: data.status, ...data } })}\n\n`
|
|
)
|
|
)
|
|
} catch {
|
|
controller.enqueue(encoder.encode(`: keepalive\n\n`))
|
|
}
|
|
}, 10000)
|
|
|
|
;(controller as any)._cleanup = () => clearInterval(interval)
|
|
},
|
|
cancel(controller: any) {
|
|
controller?._cleanup?.()
|
|
},
|
|
})
|
|
|
|
return new Response(stream, {
|
|
headers: {
|
|
"Content-Type": "text/event-stream",
|
|
"Cache-Control": "no-cache, no-transform",
|
|
Connection: "keep-alive",
|
|
},
|
|
})
|
|
} |