feat(cli): --offline / JCODE_OFFLINE unified startup network kill switch (#24)#197
Merged
Conversation
Adds the missing 'offline mode' switch requested in issue #24. A single flag (or env var) disables every startup network operation: - Update check (`src/update.rs::check_for_update_blocking`) - Install/update telemetry (`src/telemetry.rs::is_enabled`) - Provider model-list refresh - OpenAI (`src/provider/models.rs::should_refresh_openai_model_catalog`) - Anthropic (`src/provider/models.rs::should_refresh_anthropic_model_catalog`) - OpenRouter (`src/provider/openrouter.rs::begin_background_model_catalog_refresh`) Provider API calls during the session itself are NOT affected — this is strictly about startup-time chatter, mirroring pi-mono's PI_OFFLINE. Behavior: - `--offline` CLI flag, `JCODE_OFFLINE=1` env var. Either sets the in-process JCODE_OFFLINE flag in `parse_and_prepare_args`. Pre-set env value is honored too. - Prints a one-line banner on startup unless `--quiet`: "Offline mode: startup network operations disabled (JCODE_OFFLINE=1)." - Each downstream gate logs a `debug`/`info` line when it short-circuits so the audit trail is preserved. Two regression tests: - `update::tests::check_for_update_blocking_returns_none_in_offline_mode` - `telemetry::tests::telemetry_disabled_by_jcode_offline_env` Closes #24
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.
What
Adds the missing 'offline mode' switch requested in issue #24. A single flag (or env var) disables every startup network operation:
src/update.rs::check_for_update_blocking)src/telemetry.rs::is_enabled)should_refresh_openai_model_catalog)should_refresh_anthropic_model_catalog)begin_background_model_catalog_refresh)Provider API calls during the session itself are NOT affected — this is strictly about startup-time chatter, mirroring pi-mono's
PI_OFFLINE.Usage
When active, prints once on startup (suppressed by
--quiet):Offline mode: startup network operations disabled (JCODE_OFFLINE=1).Changes
offline: boolglobal flag.parse_and_prepare_argstranslatesargs.offline || env::var('JCODE_OFFLINE').is_ok()into a single in-processJCODE_OFFLINE=1env so deep code paths can read it without threading an extra arg.should_spawn_background_update_checkshort-circuits.check_for_update_blockingreturnsOk(None)immediately, logs "Update check skipped".is_enabledreturnsfalseafter the existingJCODE_NO_TELEMETRY/DO_NOT_TRACKchecks.should_refresh_*_model_catalogshort-circuit before throttle / cache-fresh checks.begin_background_model_catalog_refreshshort-circuits.Tests
update::tests::check_for_update_blocking_returns_none_in_offline_modetelemetry::tests::telemetry_disabled_by_jcode_offline_envNotes
Future feature work that adds new startup network calls (skill index refresh #16, package update checks #6, extension registry #3) should follow the same pattern: short-circuit at the entry point with
if std::env::var("JCODE_OFFLINE").is_ok() { return ... }.