fix: add SSE streaming proxy and robust make try startup

The SSE proxy was buffering the entire response body with a 30s read
timeout, causing 504s on the OpenCode /global/event stream. Add a
streaming path that detects SSE requests (by Accept header or /event
path) and returns a StreamingResponse with no read timeout.

Also fix the make try target to poll the health endpoint for Docker
readiness and wait for the container to reach running status before
opening the browser.
This commit is contained in:
2026-02-16 00:38:57 +01:00
parent fb2c1f0c60
commit 9683cf280b
3 changed files with 120 additions and 6 deletions

View File

@@ -33,14 +33,25 @@ session:
# Try the web interface - starts stack, creates a session and opens it
try: up
@echo "Waiting for services to be ready..."
@for i in $$(seq 1 30); do \
curl -sf http://localhost:8080/api/health >/dev/null 2>&1 && break; \
@echo "Waiting for services to be ready (Docker daemon can take ~30s)..."
@for i in $$(seq 1 60); do \
STATUS=$$(curl -sf http://localhost:8080/api/health 2>/dev/null | jq -r '.docker // false') && \
[ "$$STATUS" = "true" ] && break; \
printf '.'; \
sleep 1; \
done
@echo "Creating session and opening web interface..."
@echo ""
@echo "Creating session..."
@SESSION_ID=$$(curl -s -X POST http://localhost:8080/api/sessions | jq -r '.session_id') && \
echo "Session created: $$SESSION_ID" && \
echo "Session $$SESSION_ID created, waiting for container to start..." && \
for i in $$(seq 1 30); do \
S=$$(curl -sf http://localhost:8080/api/sessions/$$SESSION_ID 2>/dev/null | jq -r '.status // "unknown"') && \
[ "$$S" = "running" ] && break; \
[ "$$S" = "error" ] && echo "Container failed to start" && exit 1; \
printf '.'; \
sleep 1; \
done && \
echo "" && \
echo "Opening http://localhost:8080/session/$$SESSION_ID" && \
(xdg-open "http://localhost:8080/session/$$SESSION_ID" 2>/dev/null || \
open "http://localhost:8080/session/$$SESSION_ID" 2>/dev/null || \