Summary
Running crit (or go run .) in a git repo with a clean working tree exits with:
Started crit daemon at http://localhost:61736 (PID 19104)
Error: could not reach daemon on port 61736: Get "http://127.0.0.1:61736/api/session": dial tcp 127.0.0.1:61736: connect: connection refused
exit status 1
The actual cause is no changed files detected (after applying ignore patterns), but that message never reaches the user.
Reproduction
cd into a clean git repo (no uncommitted changes, branch == base branch or equivalent).
- Run
crit (or go run .).
- Observe the misleading "could not reach daemon" / connection refused error.
Root cause (from a quick read of cli_serve.go / daemon.go)
In runServe (cli_serve.go:369):
bindListener succeeds.
signalReadiness(pipe, addr.Port) fires at line 456 — parent startDaemon returns successfully and prints "Started crit daemon at …".
createSession runs concurrently (line 485) and immediately returns "no changed files detected".
- The
initErr path (lines 498–510) calls stop(), removeSessionFile(key), and httpServer.Shutdown(...) — daemon exits.
- The client polls
/api/session and gets "connection refused" because the listener is already gone.
removeSessionFile (daemon.go:142) also deletes ~/.crit/sessions/<key>.log, so the real error is unrecoverable after the fact.
Suggested fixes (pick one or more)
- Validate before signaling readiness: detect the no-changes condition before
signalReadiness, and report via daemonFatal so the parent surfaces the real message.
- Preserve the log on init failure: skip log cleanup (or rename to
<key>.failed.log) when shutdown is triggered by initErr, so users have a forensic trail.
- Advise the user that the software needs a plan: when there are no changed files, the friendly message should point to the alternatives — pass file arguments (`crit `), use plan mode (`crit plan ...`), or switch branches — instead of just stating the bare condition.
Environment
- crit @ commit 95b8ab7 (main)
- macOS / darwin 25.3.0
- Go: built from source via `go run .`
Summary
Running
crit(orgo run .) in a git repo with a clean working tree exits with:The actual cause is
no changed files detected (after applying ignore patterns), but that message never reaches the user.Reproduction
cdinto a clean git repo (no uncommitted changes, branch == base branch or equivalent).crit(orgo run .).Root cause (from a quick read of
cli_serve.go/daemon.go)In
runServe(cli_serve.go:369):bindListenersucceeds.signalReadiness(pipe, addr.Port)fires at line 456 — parentstartDaemonreturns successfully and prints "Started crit daemon at …".createSessionruns concurrently (line 485) and immediately returns "no changed files detected".initErrpath (lines 498–510) callsstop(),removeSessionFile(key), andhttpServer.Shutdown(...)— daemon exits./api/sessionand gets "connection refused" because the listener is already gone.removeSessionFile(daemon.go:142) also deletes~/.crit/sessions/<key>.log, so the real error is unrecoverable after the fact.Suggested fixes (pick one or more)
signalReadiness, and report viadaemonFatalso the parent surfaces the real message.<key>.failed.log) when shutdown is triggered byinitErr, so users have a forensic trail.Environment