Skip to content

Add ucode codex-app to configure + launch the Codex desktop app#211

Open
AarushiShah-db wants to merge 2 commits into
mainfrom
aarushi/codex-app
Open

Add ucode codex-app to configure + launch the Codex desktop app#211
AarushiShah-db wants to merge 2 commits into
mainfrom
aarushi/codex-app

Conversation

@AarushiShah-db

Copy link
Copy Markdown
Collaborator

Adds ucode codex-app to point the Codex desktop app at Databricks and open it.

Why it edits config.toml (not ucode.config.toml)

The CLI (ucode codex) writes an isolated ~/.codex/ucode.config.toml and launches with
codex --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's
provider on the same file.

What it does

  • Backs up ~/.codex/config.toml, then merges in a Databricks provider block (base URL +
    ucode auth-token refresh command).
  • Opens Codex in the directory you ran the command from; prompts to restart it if it's already running.

Undo (both restore from the backup)

  • ucode codex-app --restore
  • ucode revert (wired in too)

macOS + Windows; Linux gives a clear error pointing to ucode codex. Tests added for the config
write, revert, and launch/restart paths.

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
@AarushiShah-db
AarushiShah-db requested a review from rohita5l July 14, 2026 22:11
@rohita5l
rohita5l requested a review from lilly-luo July 15, 2026 07:19
Comment thread src/ucode/agents/codex.py
Comment on lines +489 to +504
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

https://refactoring.guru/design-patterns/factory-method

Comment thread src/ucode/cli.py
resolved_model = None
else:
state, resolved_model = resolve_launch_model("codex", state, None)
state = codex.write_app_config(state, resolved_model, provider=provider)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use different variables/subfunctions to manage 'state', instead of reassigning 'state' multiple times? This would make the code easier to follow

Comment thread src/ucode/agents/codex.py
Comment on lines +59 to +60
["model_providers", CODEX_APP_MODEL_PROVIDER_NAME],
["model_providers", CODEX_APP_MODEL_PROVIDER_NAME, "http_headers"],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't understand what a list of strings means for a key. could you add a comment?

Comment thread src/ucode/agents/codex.py
capture_output=True,
timeout=10,
)
elif system == "Windows":

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally: add a case for Linux. if that's too much work, add an else case

Comment thread src/ucode/agents/codex.py
argv.append(workdir)
result = subprocess.run(argv, capture_output=True, timeout=15)
return result.returncode == 0
if system == "Windows":

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if -> elif

Comment thread src/ucode/agents/codex.py
argv.append(workdir)
result = subprocess.run(argv, capture_output=True, timeout=15)
return result.returncode == 0
except (OSError, subprocess.SubprocessError):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add case for ubuntu or add an else throwing b/c it's not handled

Comment thread src/ucode/cli.py
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit move this import up

@lilly-luo lilly-luo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants