Global settings claude codex - #319
Merged
Merged
Conversation
Collaborator
Author
|
btw @lilly-luo we can only support claude/codex for global settings right now because the other agents don't have auth self-refresh capabilities ( the token would expire within 1 hr) so the user needs to continue using ucode for the other ones |
lilly-luo
reviewed
Aug 13, 2026
lilly-luo
reviewed
Aug 13, 2026
lilly-luo
reviewed
Aug 13, 2026
When an admin marks an agent machine-wide in `ucode setup`, also write the agent's own native config file (~/.claude/settings.json, ~/.codex/config.toml) so a bare `claude`/`codex` hits the gateway, not just `ucode <agent>`. Only claude and codex qualify — their auth self-refreshes — so the machine-wide prompt is now only asked for those two. Revert surgically prunes just ucode's keys from the native file, and hydrate_state no longer drops the tracking. Co-authored-by: Isaac
Addresses Isaac Review findings on this PR: - mark_tool_managed dropped the persisted native descriptor whenever a re-launch wrote no native file (use_as_global_settings unset, a relayed Claude launch, or a legacy-layout Codex launch). ucode's keys stayed in the user's shared file but revert could no longer find them. Preserve the prior descriptor when native is None (revert wipes state wholesale, so no stale descriptor lingers). - claude revert_native_config path-pruned whole hook-event arrays (hooks.Stop, hooks.PreToolUse/SessionStart/SubagentStart), deleting the user's own hooks. Route hook-event keys through the marker-matched removers (remove_smart_routing_hooks / _remove_tracing_stop_hook), symmetric with the write path; only plain keys go to prune_key_paths. Co-authored-by: Isaac
AarushiShah-db
force-pushed
the
global-settings-claude-codex
branch
from
August 13, 2026 21:57
c617547 to
cb8f9ce
Compare
Under use_as_global_settings, write the agent's OS-level managed settings file so a bare `claude`/`codex` picks up the gateway, not just `ucode <agent>`: - claude: /etc/claude-code/managed-settings.json (mac: /Library/…) — JSON - codex: /etc/codex/managed_config.toml — TOML New managed_files.py mirrors isaac (devtools/ai/llm_lib/core/config.py): a drift check reads the world-readable file with no sudo and no-ops when unchanged (so no password prompt on the common launch), else temp-file -> `sudo cp` with chattr/chflags immutable handling and actionable errors. Revert surgically prunes only ucode's keys via the same sudo path. Renames the transient flag write_native_config -> write_managed_config. Co-authored-by: Isaac
AarushiShah-db
force-pushed
the
global-settings-claude-codex
branch
from
August 13, 2026 22:01
cb8f9ce to
712c8d7
Compare
…dirs Manual testing on an enterprise-managed box surfaced three issues: - read_json_safe/read_toml_safe did an unguarded path.exists(), which raises PermissionError (not a clean "absent") when the file sits under a root-locked dir like a 750 /etc/codex — crashing the whole launch. Guard it -> treat as empty/absent. - managed_files._clear_immutable had the same unguarded path.exists() inside the sudo write, so the write aborted with a misleading "cannot write without root" before the chmod that opens the dir. Guard it; root's `cp` overwrites anyway. - The "enterprise managed settings may override your admin's config" warning fired even when ucode itself authored that managed file under use_as_global_settings. Suppress it (both sites) when ucode owns the file. Co-authored-by: Isaac
Name the exact file each answer writes (Claude Code's managed-settings.json / Codex's managed_config.toml) and spell out the payoff: "yes" means a bare `claude`/`codex` reaches the gateway on its own (no ucode needed), "no" keeps a ucode-only settings file. Co-authored-by: Isaac
Co-authored-by: Isaac
The provider-launch e2e tests only prove routing reaches the Model Provider Service; a real "Credit balance is too low" from the provider account is an environmental condition, not a ucode bug, so skip it like the existing no-permission case rather than failing CI. Generalize _skip_if_no_permission -> _skip_if_provider_unusable to cover both. Co-authored-by: Isaac
lilly-luo
reviewed
Aug 13, 2026
lilly-luo
reviewed
Aug 13, 2026
lilly-luo
reviewed
Aug 13, 2026
lilly-luo
reviewed
Aug 13, 2026
lilly-luo
reviewed
Aug 13, 2026
lilly-luo
reviewed
Aug 14, 2026
lilly-luo
reviewed
Aug 14, 2026
lilly-luo
reviewed
Aug 14, 2026
lilly-luo
reviewed
Aug 14, 2026
lilly-luo
reviewed
Aug 14, 2026
lilly-luo
reviewed
Aug 14, 2026
lilly-luo
reviewed
Aug 14, 2026
lilly-luo
reviewed
Aug 14, 2026
lilly-luo
approved these changes
Aug 14, 2026
AarushiShah-db
enabled auto-merge (squash)
August 14, 2026 17:02
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.
When an admin marks an agent machine-wide in ucode setup (use_as_global_settings), ucode now also writes the agent's
native config file so a bare claude/codex hits the gateway — not just ucode . It keeps writing the existing
ucode-private file too, so ucode is unchanged.
Only claude and codex qualify: their gateway auth self-refreshes, so the native file keeps working indefinitely. Other
agents bake a short-lived token with no bare-launch refresher (copilot has no native config file at all), so the
machine-wide prompt in ucode setup is now only asked for claude and codex.
ucode revert surgically prunes only ucode's keys from the native file — never deletes it, never touches the user's own
settings. Also fixes a latent hydrate_state bug that dropped the native tracking.
31 new tests; full suite green except one pre-existing environmental e2e failure. ruff + ty clean.
globalsettings.mov