agent-orchestrator/backend/internal/httpd
Harshit Singh Bhandari ea54f31b24
fix(daemon): fall back to ephemeral port on conflict + harden teardown (#386)
Fixes the packaged desktop app getting permanently stuck on "AO daemon
is not ready" (#385) via two daemon-lifecycle fixes.

1. Port conflict no longer exits the daemon. When the configured port
   (default 127.0.0.1:3001) is held by a non-AO process, NewWithDeps now
   falls back to an OS-assigned ephemeral port instead of returning a bind
   error. A genuine peer AO daemon is already ruled out upstream (the
   running.json + /healthz check in daemon.Run), so a conflict here means a
   foreign holder. The bound port is logged ("daemon listening") and written
   to running.json, both of which the supervisor reads, so the fallback
   propagates to the renderer with no UI changes.

2. Detached daemon is torn down on more exit paths. before-quit already
   group-kills the daemon, but app.exit() and some shutdown routes skip it,
   orphaning the daemon so it keeps holding the port for the next launch. A
   synchronous process 'exit' handler now also signals the daemon's process
   group. A hard SIGKILL/crash still can't run JS, but fix #1 covers the
   orphan that leaves behind.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 22:05:14 +05:30
..
apierr refactor(backend): LLD maintainability fixes in controllers/service layers (#95) (#96) 2026-06-03 18:09:02 +05:30
apispec fix(preview): add clear, reuse defaults, force refresh, local files (#379) (#380) 2026-06-22 16:04:29 +05:30
controllers fix(preview): add clear, reuse defaults, force refresh, local files (#379) (#380) 2026-06-22 16:04:29 +05:30
envelope fix(sessions): stop AO hook files from making every worktree permanently dirty (#169) 2026-06-11 11:06:45 +05:30
api.go Feat/backend telemetry v0 (#307) 2026-06-18 22:00:25 +05:30
control_test.go fix(cli): harden daemon control surface and stop CLI from writing the store 2026-06-01 01:55:14 +05:30
cors.go feat(frontend): scaffold for frontend with complimentary backend changes (#168) 2026-06-10 11:40:17 +05:30
cors_test.go feat(frontend): scaffold for frontend with complimentary backend changes (#168) 2026-06-10 11:40:17 +05:30
events.go feat(cdc): add SSE event stream replay (#106) 2026-06-06 19:32:21 +05:30
events_test.go feat(cdc): add SSE event stream replay (#106) 2026-06-06 19:32:21 +05:30
log.go Feat/posthog error tracking redaction (#329) 2026-06-21 18:50:47 +05:30
log_test.go Feat/posthog error tracking redaction (#329) 2026-06-21 18:50:47 +05:30
logger.go refactor: simplify session lifecycle and zellij runtime (#62) 2026-06-01 08:42:49 +05:30
logger_test.go refactor(backend): LLD maintainability fixes in controllers/service layers (#95) (#96) 2026-06-03 18:09:02 +05:30
recover.go Feat/posthog error tracking redaction (#329) 2026-06-21 18:50:47 +05:30
router.go Feat/posthog error tracking redaction (#329) 2026-06-21 18:50:47 +05:30
server.go fix(daemon): fall back to ephemeral port on conflict + harden teardown (#386) 2026-06-22 22:05:14 +05:30
server_test.go fix(daemon): fall back to ephemeral port on conflict + harden teardown (#386) 2026-06-22 22:05:14 +05:30
telemetry_test.go Feat/posthog error tracking redaction (#329) 2026-06-21 18:50:47 +05:30
terminal_mux.go refactor: simplify session lifecycle and zellij runtime (#62) 2026-06-01 08:42:49 +05:30
terminal_mux_test.go feat(windows): ConPTY terminal, zellij discovery, agent launcher trampoline, codex shim resolution (#310) 2026-06-18 21:51:05 +05:30
testhelpers_test.go refactor(backend): LLD maintainability fixes in controllers/service layers (#95) (#96) 2026-06-03 18:09:02 +05:30