fix: report a clear cli error when no herdr server is running - #1963
fix: report a clear cli error when no herdr server is running#1963season179 wants to merge 3 commits into
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThe PR converts missing or stale local server socket connection failures into a deferred, structured
Confidence Score: 5/5The PR appears safe to merge with no actionable changed-code defects identified. The new marker is consistently propagated or intentionally recovered, structured errors are emitted once at the CLI boundary, and socket overrides and named sessions receive appropriate startup guidance.
|
| Filename | Overview |
|---|---|
| src/cli.rs | Centralizes dead-server classification and maps both guarded and unchecked local API requests to the deferred marker. |
| src/cli/server_not_running.rs | Defines the marker, structured error response, and session-aware startup guidance. |
| src/main.rs | Surfaces deferred server-not-running responses once at the top-level CLI boundary. |
| src/cli/plugin.rs | Recognizes the marker as a recoverable connection failure so offline registry fallback remains silent. |
| src/cli/agent.rs | Preserves structured single-line output for agent transport failures carrying the new marker. |
| src/cli/status.rs | Reuses the shared dead-server classifier while retaining graceful not-running status output. |
| tests/cli/sessions.rs | Adds end-to-end coverage for one-line JSON output and session-aware startup guidance on missing and stale sockets. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[CLI socket request] --> B{Connect result}
B -->|Success| C[Process server response]
B -->|NotFound or ConnectionRefused| D[Create server_not_running marker]
B -->|Other error| E[Propagate original I/O error]
D --> F{Caller recovers?}
F -->|Plugin fallback| G[Use offline registry silently]
F -->|Status path| H[Report not running]
F -->|No recovery| I[Print carried JSON once and exit 1]
Reviews (1): Last reviewed commit: "fix: make server-not-running guidance se..." | Re-trigger Greptile
|
@season179 thanks for working on this—the clearer error and preserved offline fallbacks look good. before we merge, could you make the startup guidance session-aware? for example, |
socket cli commands surfaced a raw io::Error debug string
(`Error: Os { code: 2, ... }`) when nothing was listening on the
api socket, which read like a bad --cwd path. map dead-socket
connect failures to a `server_not_running` json error carrying the
resolved socket path, printed once at the edge that surfaces the
error; recovering callers (plugin offline registry fallback, agent
start polling) recognize the marker and keep their existing
behavior.
refs herdrdev#1941
a9825d0 to
a98bead
Compare
Current behavior
With no herdr server running, every socket CLI command fails with a raw debug string:
It reads like the
--cwdpath is invalid, which is exactly how #1941 was reported. A stale socket file (ConnectionRefused) and every other workspace/tab/pane/agent/worktree command produce the same raw output.What this does
Dead-socket connect failures from the guarded CLI request path (
ErrorKind::NotFound | ConnectionRefused— kind-based so Windows named pipes classify the same) map to a marker error carrying aserver_not_runningErrorResponse, mirroring the existingprotocol_guardpattern. The edge that surfaces the error prints it exactly once:Exit codes are unchanged (server errors 1, syntax errors 2). Printing is deferred — the marker carries the response — so callers that intentionally recover from a dead server keep their behavior with nothing printed:
plugin list --json→ offline result, exit 0, empty stderr)herdr statusstill reportsstatus: not runningagent starttransport failures print exactly one error linesession stopmessaging unchangedThe shared classifier replaces the private copy in
cli/status.rs. No wire protocol change (CLI-emitted error, likeprotocol_mismatch) and no server auto-start behavior.Validation
just checkgreen on macOS (zig 0.15.2 via homebrew) except one pre-existing failure unrelated to this change:live_handoff_keeps_unmanaged_agent_name_bound_to_saved_sessionfails identically on clean master @ 1491b7dstatusgraceful; positive path against a live server unchanged; plugin offline fallback behavior identical to v0.7.5refs #1941