Auto-discover server host/port for test/env/status commands#17
Merged
Conversation
The local server could be started on a non-default port (`serve --port`, `OG_VEIL_PORT`), but `test`, `env`, and `status` always fell back to `ServerConfig.from_env()` and assumed 11434 — so `og-veil test` hit the wrong port and 404'd unless the caller re-exported OG_VEIL_PORT in the same shell and restarted everything. Persist the config the background server actually started with to `server.json` (mirroring the pidfile lifecycle), and have the client commands read it back: - config: `runtime_path()` + `ServerConfig.to_dict()`/`from_dict()`. - daemon: `save_runtime`/`load_runtime`/`clear_runtime`; `load_runtime` returns the recorded config only while a server is actually running, and the recorded config is cleared on stop and when a stale pidfile is reaped (so a server that died on a port conflict can't mislead later commands). - cli: save the runtime config on a successful background start; `test`, `env`, and `status` resolve the host/port from the running server. `status` now also prints the live Base URL. - cli: add `--host`/`--port` overrides to `test` for pointing at a specific server, and clarify the help text. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U1jJ45sjA3o5KtBR4b2TM7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the background server is started on a non-default port, client commands (
test,env,status) now automatically discover and connect to it without requiring the user to re-specify the port. This is achieved by persisting the server's configuration when it starts and loading it when client commands run.Key Changes
save_runtime()andload_runtime()functions indaemon.pyto persist the server's configuration to a JSON file when it starts and retrieve it when needed_client_config()helper: Introduced a helper function that prefers the running server's actual configuration but falls back to environment/defaults when no server is runningtestandenvcommands to use_client_config()instead of hardcoded defaultstestcommand: Added--hostand--portflags to allow explicit overrides when neededstatusoutput: Now displays the running server's actual base URLto_dict()andfrom_dict()methods toServerConfigfor JSON persistenceImplementation Details
~/.og-veil/server.jsonand only exists while the server is runningload_runtime()function checks if a server is actually running (via pidfile) before returning the saved config, ensuring stale configs don't mislead clientstestcommand's explicit--host/--portflags take precedence over the discovered configurationhttps://claude.ai/code/session_01U1jJ45sjA3o5KtBR4b2TM7