Add ucode codex-app to configure + launch the Codex desktop app#211
Add ucode codex-app to configure + launch the Codex desktop app#211AarushiShah-db wants to merge 2 commits into
Conversation
The desktop app has no --profile/-c flags, so it only reads the root ~/.codex/config.toml. ucode codex-app backs that file up and edits it in place (distinct provider name so it coexists with the CLI's isolated profile), then opens the app — prompting to restart if it's already running. ucode codex-app --restore and ucode revert both undo it. Co-authored-by: Isaac
A GUI app launched via `open`/`start` doesn't inherit the shell's cwd, so Codex opened its own default folder instead of where `ucode codex-app` ran. Pass the cwd through so it opens the right repo. Co-authored-by: Isaac
| if system == "Darwin": | ||
| result = subprocess.run( | ||
| ["osascript", "-e", 'tell application "System Events" to exists process "Codex"'], | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=10, | ||
| ) | ||
| return result.stdout.strip() == "true" | ||
| if system == "Windows": | ||
| result = subprocess.run( | ||
| ["tasklist", "/FI", "IMAGENAME eq Codex.exe"], | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=10, | ||
| ) | ||
| return "Codex.exe" in result.stdout |
There was a problem hiding this comment.
nit - it would be cleaner to define an interface called SystemCodex with functions such as start, quit, is_running, etc. Then you have 2 objects that implement this interface - WindowsCodexandDarwinCodex` and those have OS-specific logic to operate on the Codex app. Now all OS-specific logic is in those classes/interfaces and adding another OS (Linux) requires only changing one place.
| resolved_model = None | ||
| else: | ||
| state, resolved_model = resolve_launch_model("codex", state, None) | ||
| state = codex.write_app_config(state, resolved_model, provider=provider) |
There was a problem hiding this comment.
Can we use different variables/subfunctions to manage 'state', instead of reassigning 'state' multiple times? This would make the code easier to follow
| ["model_providers", CODEX_APP_MODEL_PROVIDER_NAME], | ||
| ["model_providers", CODEX_APP_MODEL_PROVIDER_NAME, "http_headers"], |
There was a problem hiding this comment.
i don't understand what a list of strings means for a key. could you add a comment?
| capture_output=True, | ||
| timeout=10, | ||
| ) | ||
| elif system == "Windows": |
There was a problem hiding this comment.
ideally: add a case for Linux. if that's too much work, add an else case
| argv.append(workdir) | ||
| result = subprocess.run(argv, capture_output=True, timeout=15) | ||
| return result.returncode == 0 | ||
| if system == "Windows": |
| argv.append(workdir) | ||
| result = subprocess.run(argv, capture_output=True, timeout=15) | ||
| return result.returncode == 0 | ||
| except (OSError, subprocess.SubprocessError): |
There was a problem hiding this comment.
add case for ubuntu or add an else throwing b/c it's not handled
| so we back that file up and edit it in place. `ucode codex-app --restore` | ||
| (or `ucode revert`) undoes it. | ||
| """ | ||
| from ucode.agents import codex |
There was a problem hiding this comment.
nit move this import up
lilly-luo
left a comment
There was a problem hiding this comment.
is it possible to run the restore_codex step any time the customer exits codex? would be nice to restore their .toml in case they're going to then use codex separately
Adds
ucode codex-appto point the Codex desktop app at Databricks and open it.Why it edits
config.toml(notucode.config.toml)The CLI (
ucode codex) writes an isolated~/.codex/ucode.config.tomland launches withcodex --profile ucode, so it never touches your real config. The desktop app has no--profile— the only file it reads on startup is the root~/.codex/config.toml.So to steer the app we have to edit that shared file in place. To make that safe, ucode backs it
up first and uses a distinct provider name (
ucode-databricks-app) so it coexists with the CLI'sprovider on the same file.
What it does
~/.codex/config.toml, then merges in a Databricks provider block (base URL +ucode auth-tokenrefresh command).Undo (both restore from the backup)
ucode codex-app --restoreucode revert(wired in too)macOS + Windows; Linux gives a clear error pointing to
ucode codex. Tests added for the configwrite, revert, and launch/restart paths.