Commit Graph
3870 Commits
Author SHA1 Message Date
ioanbudea-OAI 01192c6e19 Enforce session ownership in V1 multi-agent tools (#65287)
## Why

V1 tools could use a thread ID to reach agents in another session. A
thread ID can also resolve to a different runtime after a thread is
unloaded and reloaded.

## What changed

- Check session ownership before sending input, interrupting, waiting on,
  closing, or resuming a V1 agent. Keep live operations bound to the
  runtime that passed the check.
- Check ownership in saved rollouts before resuming agents and their
  descendants. Follow the recorded parent chain for legacy rollouts that
  lack a session ID. Release the agent slot when closing a known ephemeral
  agent that has already been unloaded.
- Preserve failed `wait` calls in thread history and show the failure in
  the TUI without listing rejected targets as completed agents.

## Testing

Add regression coverage for cross-session input, close, and resume
requests, slot reuse after closing an unloaded ephemeral agent, legacy
session recovery, and failed wait history and display.

GitOrigin-RevId: 4712a53315d24d5658d746ed277738e00a4e2dac
2026-12-02 16:21:14 +00:00
Felipe Coury 3a3b34c74a Refresh TUI colors on terminal theme changes and focus regain (#65238)
## Why

A terminal theme change could leave the composer using stale colors until
Codex returned from an external editor.

## What changed

On supported Unix terminals, enable live color reporting after startup
prompts have cleared and only when the terminal reports that the mode is
off. Refresh the default foreground and background on theme notifications
and when the terminal regains focus. Read color replies through the same
event stream as keyboard input and redraw when the colors change.

Release the subscription before handing the terminal to an external editor
and check whether it can be re-enabled when Codex resumes.

## Testing

PTY tests cover idle composer redraws, focus refresh without a theme
notification, existing subscriptions, and recovery after missing replies.
They also cover Escape, typing, and interrupt keys during color queries.

GitOrigin-RevId: 0f0d4b057fdc7c2d6813dc08ff284f47824db6b0
2026-12-02 11:39:41 +00:00
jif a5484adce0 Resolve approval reviewers from destination thread settings (#65237)
## Why

The TUI can resolve a fallback `approvals_reviewer` before the
destination app server applies the thread's provider and permissions.
Sending that fallback as an override can select the wrong reviewer.

## What changed

For fresh replacement sessions and startup with a selected profile,
send the reviewer when explicitly configured and otherwise let the
destination app server resolve it from the final thread settings.

## Testing

Cover reviewer selection for remote replacement sessions, profile
startup, and projectless sessions. Verify that embedded forks inheriting
saved permissions retain the saved reviewer.

GitOrigin-RevId: fc9b8f18b021d11e276888c6c6f78fc5db7c8846
2026-12-02 11:38:59 +00:00
jif 258cae0778 Default eligible OpenAI sessions to automatic approval review (#65236)
## What changed

When `approvals_reviewer` is unset, default to `auto_review` for sessions using the OpenAI model provider with `guardian_approval` enabled, effective workspace-write permissions, and an effective approval policy of `on-request` or `granular`. Otherwise default to `user`. Explicit reviewer settings still take precedence over the default, subject to configuration requirements.

When the TUI starts a replacement session on a remote app server, use the server's configured reviewer if the client has no explicit reviewer setting. Update the configuration and app-server schemas to document the new default.

## Testing

Cover reviewer eligibility and managed requirements in configuration tests, manual overrides and empty workspace roots in app-server thread-start tests, and remote reviewer precedence in the TUI replacement-session test.

GitOrigin-RevId: fd05687accddb8a3ab99df0486b93f3f595fef65
2026-12-02 11:38:20 +00:00
jif a7e4b42b4a Decouple local provider setup from codex-core (#65234)
## What changed

Have the TUI and `codex exec` pass the selected provider, optional model,
and HTTP client factory to shared OSS setup. Validate the provider's
`base_url` there and connect to Ollama or LM Studio using that URL and
factory. Return a configuration error when Ollama's URL is missing.

Remove the runtime dependency on `codex-core` from the OSS utilities
and both provider crates. Enable the existing Rustls key exchange
preference and vendored OpenSSL for musl builds directly in the provider
crates.

## Testing

Add coverage for the error returned by each provider when `base_url` is
missing. Extend the Ollama client reuse test to check readiness for an
explicitly selected, already installed model.

GitOrigin-RevId: 747ed51c6fcfa2a0ffc61ba5aa8ea4d033450241
2026-12-02 11:36:47 +00:00
Felipe Coury fc8cd2442b Refresh TUI terminal colors after returning from an external editor (#65221)
## Why

The TUI caches the terminal's default colors at startup. If the terminal
switches from dark to light while an external editor is open, the composer
can still use the old background tint when Codex regains control.

## What changed

- On supported local Kitty, Ghostty, and Rex sessions, query the default
  foreground and background through the TUI input stream after returning
  from the editor. Redraw when the reported colors change.
- Drain pending terminal reports before opening the editor, suspending, or
  exiting. If the drain times out before an editor handoff or suspension,
  keep the TUI active, preserve input, and show an error.

## Testing

Add pseudo-terminal tests for the updated composer tint, stale Enter
handling on editor handoff, and draft preservation and report draining
after editor and suspend timeouts.

GitOrigin-RevId: 7f438a7df26d602bf975695c27a9f431432d16cf
2026-12-02 10:36:43 +00:00
Charlie Weems 1805912776 Add a configurable maximum width for TUI conversations (#65216)
## Why

On wide terminals, the transcript and prompt box can span more columns than
users want for comfortable reading and editing.

## What changed

Set `tui.max_conversation_width` in `config.toml` to cap the transcript and
prompt box in fullscreen and inline modes, including the startup composer.

```toml
[tui]
max_conversation_width = 80
```

The setting accepts values from 20 to 65,535 terminal columns. When unset,
the conversation uses the available width. Raw inline scrollback keeps native
terminal wrapping, and wrapped links in formatted history and command previews
retain their full destinations.

## Testing

Add regression coverage for config validation, startup and live layouts,
inline history reflow after a config reload, and links that wrap across rows.

GitOrigin-RevId: 91e1856776986fee3b540247c3fbfe5f083b297f
2026-12-02 10:19:11 +00:00
Eric Traut aa433cb350 Show staged changes in /diff (#65211)
## Why

`/diff` skipped staged patches, so users could miss changes that would go into their next commit.

## What changed

Compare the index with `HEAD` and the working tree with the index. Show the staged patch under **Staged** and, when both are present, put the remaining patches under **Unstaged and untracked**. Keep Git operations local and show a warning alongside the working-tree patches if the staged comparison fails.

## Testing

Cover staged files before the first commit and a staged edit that is reversed in the working tree. The tests also cover the staged comparison warning, missing blobs without a fetch, and the refreshed sidebar rendering both sections.

GitOrigin-RevId: 2cb032d7766caf313363eb4c330abb3f6a95f017
2026-12-02 09:55:35 +00:00
alexsong-oai 986dc881be Expose gateway spend in app-server account rate limits (#65193)
## Why

Clients need to show the spend and cap for the account behind a thread's
model provider. The existing ChatGPT usage read cannot provide those
figures for a gateway account.

## What changed

- Route `account/rateLimits/read` through the provider's configured
  `usage_url` using the provider's credentials. An optional `threadId`
  selects a loaded thread's provider for the account-wide read. Omitting it
  selects the default provider.
- Return `usageUnavailable` for a thread whose provider has neither a
  usage endpoint nor first-party authentication. Surface gateway errors
  without falling back to ChatGPT usage.
- Report monthly gateway spend in `individualLimit` as exact USD decimal
  strings, with `limit: "unlimited"` for uncapped accounts. Use
  `spendControlReached` for the gateway's cap status. Spend snapshots
  identify their unit as `usd` or `credit`, with omitted units defaulting
  to `credit` for compatibility.

## Testing

Add integration coverage for thread-specific provider selection, gateway
usage taking precedence over ChatGPT without fallback, and reuse of an
existing gateway OAuth session without interactive login.

GitOrigin-RevId: e6ec9d83eecc3084fcc98e72e2c031bd3e53a2cd
2026-12-02 07:59:18 +00:00
Benjamin Carlsson a3bca8a1b5 Validate thread identity across TUI backends (#65190)
## Why

Different backends can return the same thread ID. A Cloud environment
selection must apply to the draft on the backend that opened the picker.
When the TUI reads or resumes a specific thread, an unexpected server
response can otherwise attach history or apply settings to the wrong thread.

## What changed

- Match Cloud environment selections against both the backend and the draft
  thread ID.
- Reject mismatched thread IDs in read and resume flows before hydrating
  history or applying resume permission settings. Preserve subscription
  bookkeeping so a rejected resume can still be cleaned up.

## Testing

Add regression coverage for a thread start that reuses an ID from another
backend and a mismatched resume that preserves the active conversation,
composer draft, and approval override without sending a settings update.

GitOrigin-RevId: 603efe7aa37e510dacf91b58487a94469c7f183d
2026-12-02 07:29:37 +00:00
Benjamin Carlsson 7f7a1aa16d Add Cloud voice signaling and protect realtime diagnostics (#65186)
## Why

HTTP and WebSocket diagnostics can record sensitive realtime data, including authorization headers, SDP offers, call IDs, and audio or transcript payloads.

## What changed

Add an account-bound app-server WebSocket for Codex Cloud voice signaling. The socket initializes without subscribing to the thread, so transcript and approval events stay on the native thread attachment. Estimate server time from the WebSocket upgrade's `Date` header so admission deadlines tolerate local clock skew.

Disable HTTP request and response logging for realtime call creation. Suppress raw WebSocket upgrade and realtime frame traces, filter sensitive Tungstenite diagnostics across TUI log sinks, and keep call details and event payloads out of debug output.

## Testing

Add coverage for denied Cloud voice endpoints and missing or invalid server dates. Exercise call creation and WebSocket exchanges with trace logging enabled to check that sensitive values stay out of the captured logs.

GitOrigin-RevId: d51a3cff7f5908685e2babbf675561cb8e57ba0e
2026-12-02 06:57:24 +00:00
Felipe Coury 0d17a47212 Support Unicode characters in TUI keybindings (#65176)
## Why

The TUI keymap required ASCII characters, so users on layouts such as Russian
could press `Ctrl+В` but could not save the corresponding `ctrl-в` shortcut.

## What changed

Accept Unicode character keys in `tui.keymap` and shortcut capture, including
modified keys and chord strokes. Apply the same case handling to configured
bindings and terminal events so `Ф` and `shift-ф` match the same keypress.

Keep Kitty's base-layout Ctrl+C and Ctrl+D fallbacks when no active binding
claims the reported key. Reserve physical Ctrl+C for list cancellation and
reject non-ASCII character bindings on actions that can grant consent,
including both strokes of a chord and expanded leader prefixes.

## Testing

Add regression tests for Unicode capture, chord matching and conflicts,
Ctrl+C and Ctrl+D fallback behavior, and consent safeguards.

GitOrigin-RevId: 8624218efcba2784f19f502770523fe00c6f1af1
2026-12-02 06:30:47 +00:00
yansenzhou-oai 21e643d32e Remove the codex cloud and codex apply commands (#65173)
## Why

Once the commands are removed, invocations such as `codex cloud exec work` could be interpreted as interactive prompts. Rejecting retired command names in the root prompt position prevents old invocations from starting a session by mistake.

## What changed

- Remove `codex cloud` and `codex apply`, which provided CLI workflows for running and browsing cloud tasks and applying their diffs locally. Delete the cloud task crates, related backend client code, and the TUI composer widget used by the cloud task interface.
- Reject `cloud`, `cloud-tasks`, `apply`, and `a` as retired root commands. To use one of those names as a prompt, pass it after `--`, as in `codex -- apply`.

## Testing

Add parser coverage for retired names used alone, with trailing arguments, and after root options, as well as for explicit prompts after `--`.

GitOrigin-RevId: 8469e936eacde3428862c6bf1b7e33084b8ead68
2026-12-02 06:11:22 +00:00
Dylan Hurd 350d8a47c4 Stream provisional text from thread/sample (#65167)
## Why

Clients had to wait for the entire sample before they could display any
assistant text.

## What changed

Set `stream: true` to receive `thread/sample/textDelta` notifications
while a sample is in progress. Each notification goes to the requesting
connection and carries the original JSON-RPC `requestId` and a text
`delta`. The stream excludes commentary and reasoning.

The final RPC response still provides the complete sample and token
usage. Discard provisional text if the request fails or the final
`text` is null. Omitting `stream` or setting it to `false` returns
only the final response.

## Testing

Integration tests cover deltas arriving before completion, text supplied
only when an output item completes, and custom tool calls producing a
null sample even after provisional text has been streamed.

GitOrigin-RevId: b2ad960420ce7789722e03f9f283781030cf61fb
2026-12-02 04:56:45 +00:00
Benjamin Carlsson fad661242b Filter hosted TUI thread discovery by originator (#65164)
## Why

Hosted thread listings can mix Cloud tasks with CLI sessions and GitHub
code reviews, which can surface unrelated results in task searches.

## What changed

Request only threads from `codex_cloud` and `codex_work_cca` when
discovering threads through the hosted app server. Apply the filter to
pinned and paginated Agents overview listings, task mention search, the
resume picker, and latest-session lookup.

## Testing

Cover originator filtering across Cloud search and resume picker pages,
the hosted task mention request, and overview recovery after a missed
unarchive notification.

GitOrigin-RevId: 0f39cd9a9a35510372fdebdba403e0b0fb227130
2026-12-02 04:42:32 +00:00
Felipe Coury 7fbe0a8018 Fix TUI Ctrl+C and Ctrl+D on non-ASCII keyboard layouts (#65162)
## Why

With a Russian keyboard layout, the keys for Ctrl+C and Ctrl+D can
send Cyrillic characters, causing Codex to miss shortcuts for
interrupting a turn, canceling a prompt, or exiting.

## What changed

Use base-layout metadata from terminals that support the Kitty keyboard
protocol to recognize Ctrl+C and Ctrl+D when the active layout produces
a non-ASCII character. Respect bindings and chords in the focused
keymap and preserve the original event during raw key capture. Give
Ctrl+C cancellation priority in lists and approval prompts, including
startup hook trust review.

## Testing

Add regression coverage for interrupting a turn and exiting with
Russian-layout key events, canceling command approval, and continuing
without trusting startup hooks when Ctrl+C is pressed on the trust option.

GitOrigin-RevId: bf5efba2de295f3665c883a95fd511089eee2aba
2026-12-02 03:58:37 +00:00
Felipe Coury 258e04a50a Handle delayed terminal color replies without swallowing TUI input (#65159)
## Why

A terminal's startup color reply can arrive in pieces across the handoff
from the startup probe to the live input reader. If the reader treats
the leading Escape as a key, the rest of the reply can leak into the
composer or trigger a shortcut. A standalone Escape still needs to
dismiss reverse history search and leave subsequent typing intact.

## What changed

Pass the outstanding foreground and background color queries to
Crossterm along with replayed input and the remainder of a two-second
reply window measured from the query. Track each completed reply,
including valid replies consumed inside bracketed paste. Update the
Crossterm pin and let the input drain at screen transitions wait for
an ambiguous Escape to resolve within that window.

## Testing

Add parser and PTY regression tests for replies completed during
probing, split across the handoff, or started in the live reader.
Cover bracketed paste, idle Escape followed by typing, and the
distinction between a reply's BEL terminator and the editor shortcut.
Run the timing-sensitive PTY cases serially in a dedicated Linux
Bazel target.

GitOrigin-RevId: b7d7db6f7d57866aad18e5bc99c32773ad25f95c
2026-12-02 03:48:16 +00:00
Felipe Coury 9f33c83cb6 Reuse the transcript overlay's interaction check for its browsing footer (#65156)
## What changed

Use `has_active_interaction()` to decide whether to show the browsing
footer, removing the duplicate checks for pending selection mode and
active viewport interactions.

GitOrigin-RevId: 9264a427feaef94bc298a18b79d440de721aadb4
2026-12-02 03:46:24 +00:00
Benjamin Carlsson ed3ccd4c21 Scope TUI reconnect recovery to the affected backend (#65154)
## Why

When the active backend reconnects, the TUI can discard pending work on
other connected backends. Completions queued before the reconnect can
also arrive after the replacement connection is active.

## What changed

- Preserve pending requests and thread state for other connected backends.
  Track asynchronous completions by connection so retired connections
  cannot update the TUI.
- Apply request resolution from background backends to pending prompts
  and the agents overview. Require users to end a voice call before
  switching sessions across backends.
- Close the verification prompt when verification finishes and suppress
  queued proofs when the user cancels the prompt.

## Testing

Add regression coverage for preserving another backend's pending work
during reconnect, dropping stale completions, resolving background
requests, and cancelling verification after a proof has been queued.

GitOrigin-RevId: fc932b0d13fd1cf04404bd5ccfce71ff776e259f
2026-12-02 03:33:04 +00:00
Ian MacLeod 4487f68480 Show task-opening progress inline in the Codex TUI (#65126)
## Why

The task list already labels a visible task `Opening…`, but the spinner
appears in the footer, away from the task it describes.

## What changed

Place the spinner next to `Opening…` in the task's status column or
compact detail row, preserving the selection highlight. Keep the
`Opening task…` footer as a fallback when the inline status has no room
or the task is outside the visible list.

## Testing

Cover inline rendering, reverse-video selection styling, and the footer
fallback for short layouts and history results that disappear when
opening clears the search.

GitOrigin-RevId: 6a66b368fefb4c43aa0b27ffe9b24bb07d1839d3
2026-12-02 01:06:48 +00:00
Benjamin Carlsson 98e240bbf7 Show modifier layers and action labels in the TUI shortcut guide (#65112)
## Why

The keyboard view only highlighted unmodified shortcuts, so users had to
switch to the list to find modified bindings or see what a highlighted
key did.

## What changed

- Let users cycle through modifier combinations from the active bindings
  with a free key shown in the guide header. Leave existing bindings
  available.
- Label keys with their actions and show the full binding for two-key
  chords beside the first key.
- Try a compact keyboard when the roomy layout does not fit, then fall
  back to the shortcut list while keeping modifier navigation available.

## Testing

Add snapshots and assertions for Ctrl and Shift layers, remapped chords,
layout fallback, and keyboard help above the prompt in an 80×24 terminal.

GitOrigin-RevId: 0b37579c145fa5176ab83de392d9eb4905d06b81
2026-12-01 23:59:56 +00:00
Dylan Hurd b6065c6128 Stabilize the TUI worktree test during fork startup (#65109)
## Why

The fork can acknowledge its working directory before startup finishes.
MCP startup can also make the composer busy between the test seeing
`Ready` and pressing Enter, causing `/cd` to be rejected.

## What changed

Wait for the fork's own `Ready` status and a complete terminal update
showing the pasted `/cd` command before submitting it. Retry only when
a new busy rejection appears and the fork is ready again. Require a
complete terminal update showing the directory change before continuing.

GitOrigin-RevId: eceb98b3376977dcc60963e3733bf45559b88ae0
2026-12-01 23:38:53 +00:00
Benjamin Carlsson 7b680b178a Keep TUI background work tied to its originating app server (#65108)
## Why

App servers can reuse the same request IDs. Tracking dynamic tool calls by
request ID alone lets one server's cleanup affect another server's call.
Background title and recap events also need to reach their originating server
when the TUI is displaying a different session.

## What changed

- Track dynamic tool calls by backend and request ID, and match completions
  to the specific call. Send replies through the original reply handle in the
  background and give pending writes time to finish on shutdown.
- Route background task registrations and title and recap events by backend.
  Check ownership before registering temporary threads or forwarding their
  notifications, and use the original connection for temporary-thread cleanup.

## Testing

Regression coverage checks that closing a side thread preserves another
backend's tool call with the same request ID, that a disconnected backend
cannot register a task thread, and that a title helper cannot replace a
temporary thread owned by another backend.

GitOrigin-RevId: 0878efba94f317c814ee131403f0c6e793dfc2c0
2026-12-01 23:22:59 +00:00
Felipe Coury fbb04fca5f Share composer copy handling across keyboard and mouse input (#65107)
## What changed

- Route keyboard and mouse copies of composer selections through the same
  plain-text copy helper.
- Check composer visibility separately when completing clipboard work
  and canceling primary selection. Use the overlay input check when
  deciding whether to end a composer drag.
- Convert external transcript links to view actions through the shared
  `ReaderLink` conversion.

GitOrigin-RevId: 7285acfe6d8911da806adbba7da8b79393389b08
2026-12-01 23:13:10 +00:00
Eric Traut 75c48af16f Support --search with the shared background server (#65103)
## Why

Launching Codex with `--search` forced the TUI into embedded mode, even when the shared background server was available.

## What changed

Treat `--search` as a per-thread request for live web search. Check daemon eligibility before applying the flag, and restore the launch setting when reconnecting to an unloaded conversation or reopening an unloaded saved side chat.

## Testing

Cover daemon startup with `--search` and verify that a conversation retains its history and search behavior across a daemon restart. Check that worktree launches honor the flag per invocation and that reattaching to an already loaded side chat leaves its search settings intact.

GitOrigin-RevId: 9d15ec3d103383d80442e07845442341f6da6727
2026-12-01 23:03:41 +00:00
Eric Traut 997204b7f9 Make /diff worktree-wide from subdirectories (#65094)
## Why

Running `/diff` from a subdirectory can omit untracked files elsewhere in
the worktree. With `diff.relative` enabled, it can also omit unstaged
changes to tracked files outside that subdirectory.

## What changed

Run Git from the discovered worktree root while retaining the session
directory for permission resolution. Pin the Git directory and worktree so
relative Git environment settings keep resolving to the same repository.

Decode Git's quoted untracked paths before generating patches. If a path
cannot be represented as UTF-8, warn that the diff is incomplete and
continue with the remaining files.

## Testing

Cover matching output from the root and a subdirectory with
`diff.relative` enabled and with an explicit Git directory and worktree.
Cover quoted UTF-8 filenames and warnings for invalid UTF-8 paths.

GitOrigin-RevId: 7dd604f543976f4ba88ae0facf9e9b573baa9c0f
2026-12-01 21:56:27 +00:00
Eric Traut a183b449e6 Use model-specific speeds for /model --speed (#65092)
## Why

Speed completion always suggested `flex`, even for models that did
not advertise it, and omitted other available tiers such as `priority`.

## What changed

Offer `standard` and the enabled service tiers advertised for the model
named in `/model`. When the command omits the model, use the current
model. Use the same choices in unavailable-speed errors.

Allow explicit use of unadvertised `flex` in `/model` and quick dials
when using the OpenAI provider with an API key. Keep completion limited
to `standard` and advertised tiers.

## Testing

Add coverage for model-specific completion and validation, including
clearing stale suggestions when the model catalog is cleared. Cover
saving and recalling a quick dial with unadvertised Flex using an
OpenAI API key and rejecting that speed on another provider.

GitOrigin-RevId: b5139d03561842eaf00511f018f6e626cf695bc5
2026-12-01 21:39:35 +00:00
Eric Traut a0676149ff Show custom provider rate limits in /status (#65091)
## Why

Custom providers can report quota during a turn, but `/status` only cached
quota from ChatGPT account usage. Users could see a quota warning while
`/status` showed no corresponding limits.

## What changed

Use provider turn snapshots and rolling updates from custom providers using
a saved API key to populate `/status`. Merge partial updates by limit ID,
preserving omitted windows with their original timestamps and carrying
forward an unexpired reset time when the window duration matches. ChatGPT
account usage remains authoritative for its status display.

## Testing

Extend TUI tests to cover weekly and five-hour limits after partial
updates, immediate status rendering for custom providers using a saved API
key, and preservation of ChatGPT account limits after a streamed update.

GitOrigin-RevId: acaed9880c020885cea97307d66d78f79c5b4c65
2026-12-01 21:38:53 +00:00
Eric Traut 6801507507 Preserve --add-dir when starting local TUI threads (#65087)
## Why

Selecting a permission profile for a new local thread could drop directories
explicitly supplied with `--add-dir`. Starting a thread in a different
directory could also lose those additions.

## What changed

Carry explicit additions into local thread starts. When a permission profile
is selected, send the working directory and the explicit additions as
runtime workspace roots. Require the app server to confirm each added
directory before accepting the thread. Decode local workspace roots as
native paths so tabs and newlines in directory names survive.

## Testing

Extend tests for startup, managed worktree creation, and permission-profile
selection. Cover an added directory with a tab in its name on Unix and the
error for an unconfirmed directory.

GitOrigin-RevId: 97beb528aa396b97d6d0ad664fde8abe3b9e2bbf
2026-12-01 21:18:55 +00:00
Eric Traut 1e832a92c2 Fix granular approval defaults at projectless TUI startup (#65086)
## Why

An `approval_policy` in the client's config could suppress the granular
default when starting a projectless session with server-owned defaults.

## What changed

Make the granular default available at startup so the launch code can
apply it when the invocation leaves the policy unset and the server
allows it.

## Testing

Extend the server-defaults startup test to set the client's policy to
`never` and verify that `thread/start` still requests granular approval.

GitOrigin-RevId: 770aa978e2372e1e30fe778b670ea25f9c3c1cd0
2026-12-01 21:01:05 +00:00
Eric Traut be972c162c Preserve the thread's selected workspace when the TUI starts a turn (#65084)
## Why

Another client can change a thread's workspace after startup. When the
TUI sends its local working directory with the next prompt, it can reset
the thread's selected environments before the TUI receives the update.

## What changed

Omit `cwd` and `runtimeWorkspaceRoots` from TUI `turn/start` requests
for both regular prompts and misalignment continuations so the turn
uses the thread's current workspace.

## Testing

Add a regression test that changes the thread's workspace before the
TUI receives the update and checks that the first prompt sent to the
model includes the newly selected working directory.

GitOrigin-RevId: b5cc23bce787f91058ede6aa7ee825e0e7a9518c
2026-12-01 20:47:55 +00:00
Felipe Coury 10cab5fad3 Keep the TUI responsive during WSL image paste (#65083)
## Why

A slow or stalled Windows clipboard helper can block the TUI while it
reads a pasted image.

## What changed

Read and stage clipboard images on a background worker in WSL. Give each
paste a five-second deadline and stop and reap the PowerShell helper if
the read is cancelled or times out.

Keep the draft editable while the paste is pending. Insert the image at
the original cursor or selection, preserve later edits outside that
range, and cancel the paste if an edit overlaps the range or the draft
is no longer current. Block submission while the paste is pending and
show a reminder to review the draft before sending.

## Testing

Add regression tests for insertion after continued typing, submission
blocking, stale completions, temporary file cleanup, and timeouts.
Cover helper cleanup after cancellation or timeout and rejection of
oversized clipboard output.

GitOrigin-RevId: d7b1d520b242244f9749f02e9d62a57d17821340
2026-12-01 20:45:18 +00:00
Felipe Coury eb79af452e Load TUI image previews in the background and downscale large JPEGs (#65079)
## Why

Composer thumbnails and transcript tool previews read and decoded files
during rendering. A JPEG whose decoded pixels exceeded the 32 MiB
allocation budget could lose its preview even when the encoded file fit
within the file size limit.

## What changed

- Load visible composer thumbnails and transcript previews on background
  workers and request a redraw when the result is ready. Reuse prepared
  tool previews when the viewport changes size.
- Share the sidebar's scaled JPEG fallback with composer and transcript
  previews. Preserve the oriented source aspect ratio and enforce the
  encoded file size limit separately from the decode budget.
- Check that the owning thread has a local workspace before reading an
  inspected image. Generated artifacts can still load from the daemon host.

## Testing

Cover large JPEG previews in the composer and transcript, thumbnail
refresh after an attachment is replaced, text fallback for oversized
PNGs, and an inspected path shared by local and remote workspaces.

GitOrigin-RevId: f2c8948a9abaa2527932423224b6ebeda3e122ae
2026-12-01 20:29:37 +00:00
Benjamin Carlsson 854e723882 Add --cloud to launch interactive Codex sessions on Cloud (#65063)
## What changed

- Select the Codex Cloud backend at startup with `codex --cloud`,
  `codex agents --cloud`, or `codex resume --cloud`.
- Use `--env <ENV_ID>` to select a saved Cloud environment for new
  threads. Resume by picker, most recent session, ID, or name using the
  thread's saved environment and model.
- Reject local execution overrides and managed execution requirements
  that Cloud cannot enforce. Recheck managed requirements for the
  ChatGPT workspace selected when connecting.

## Testing

Cover initial prompt delivery, resume by ID and name, and rejection of
unsupported settings, including managed execution requirements from a
workspace selected after startup configuration was loaded.

GitOrigin-RevId: 6144decb9679f903607a586466cff37e402ab4a4
2026-12-01 19:17:41 +00:00
Felipe Coury 4bc6a0ea93 Render web URLs in TUI file citations as hyperlinks (#65052)
## Why

The TUI treated URLs in file citations as local paths. This could prepend
the working directory and escape parts of the URL needed to reach the
cited resource.

## What changed

Render HTTP and HTTPS `codex-file-citation` paths as web links, preserving
percent escapes, query strings, and fragments in the displayed URL and
hyperlink destination.

## Testing

Regression tests compare file citations with equivalent Markdown links
with and without a working directory. A snapshot covers the rendered
text and hyperlink metadata for a spreadsheet URL.

GitOrigin-RevId: 2f3213192fced0e92ae87062d086a9015113b862
2026-12-01 18:23:08 +00:00
Eric Traut b6a53810db Add failure stages and OS error kinds to daemon startup metrics (#65049)
## Why

The TUI's daemon auto-start metric reports a failure reason, but broad
reasons such as `other` leave it unclear which startup step failed.

## What changed

Add `failure_stage` and `os_error_kind` to failed `codex.daemon.start`
attempts. For example, a missing executable reports `spawn` at
`process_spawn` with `not_found`. The metric uses a fixed set of error
categories and keeps raw OS codes and diagnostic text local.

Report Windows detached-launch restrictions as
`windows_detach_restricted`, matching the reason recorded when the TUI
falls back to an embedded app server.

## Testing

Cover missing executables, Windows launch restrictions, and preservation
of the underlying I/O error. An in-memory metrics test checks that a failed
attempt increments the counter once and maps an unknown OS code to `other`.

GitOrigin-RevId: c5976517e1178fb8d65257362a893ad6254a2ddd
2026-12-01 18:08:05 +00:00
Eric Traut b6087365cd Repair app-server daemon packages with update --from-cli (#65046)
## Why

A daemon with a dangling package selection or a missing executable can
fail to start, and leftover logs can make an absent installation look
like an existing one.

## What changed

- Let `codex app-server daemon update --from-cli` install or repair and
  pin the daemon from a complete CLI package. Point missing-executable
  errors to that command. Repair checks that the daemon and updater are
  stopped and that the package selection has stayed unchanged.
- Let `codex app-server daemon start` bootstrap a missing installation
  even when old daemon logs remain. Use legacy logs to infer a stopped
  standalone installation only when its package selection still exists
  and dedicated daemon logs are absent.
- Allow repair to replace a dangling Windows junction whose target is
  directly under the daemon's releases directory.

## Testing

Extend coverage for startup with leftover logs, package repair after
losing the selection or executable, repair blocked by a starting
daemon or updater, and replacement of a dangling Windows junction.

GitOrigin-RevId: 679266cc22b7ff7a34bbd41c2bf0659d3068eb75
2026-12-01 17:56:54 +00:00
Eric Traut 51f546979e Keep Sixel pets visible during composer sparkle redraws (#65040)
## Why

When composer stars fade, the terminal can clear to the end of the row and erase part of the Sixel pet image.

## What changed

Leave a strip of default background at the right edge of the composer where the Sixel pet is drawn, so star redraws can update the composer without clearing through the image.

## Testing

Add a terminal regression test that uses text markers to stand in for Sixel pixels. It checks that the markers survive while the stars are visible and after they disappear, and that disabling the pet restores the composer background in that area.

GitOrigin-RevId: 0f55d1e5594fa503edeb13d2d262e3c73bb0366b
2026-12-01 17:37:47 +00:00
Eric Traut e14750e0b9 Preserve the exit summary when Ctrl+C is pressed again on Windows (#65038)
## Why

Once the TUI restores the terminal, another Ctrl+C becomes a Windows
console event and can terminate Codex before it prints the exit summary,
including the resume hint when available. The npm launcher can also
force-terminate the child by forwarding a Ctrl+C that Windows already
delivered to it.

## What changed

Register a Windows Ctrl+C listener before restoring the terminal and keep
it alive until the CLI or standalone TUI finishes printing the exit
summary. Skip forwarding `SIGINT` from the npm launcher on Windows.

## Testing

Add a Windows regression test that simulates `SIGINT` in the npm launcher
and checks that the child can finish and report its own exit code.

GitOrigin-RevId: cd73a4a2ecc22812bc301787e67c349f7720a93b
2026-12-01 17:07:18 +00:00
Benjamin Carlsson 949cdb56ef Rank TUI slash commands by recent usage (#65034)
## Why

The slash menu uses a fixed order within each match tier, so frequently used commands can stay buried among equally good matches.

## What changed

Rank commands within each match tier by frequency over the last 50 dispatches, keeping the existing order for ties. Count `/quit` toward `/exit` and `/btw` toward `/side`. Store slash command usage locally in `slash_command_usage.json`, separate from `$` picker history, when history persistence is enabled.

If `/exit`, `/quit`, or `/logout` ranks first, require its full name or explicit menu navigation before Enter can run it.

## Testing

Cover ranking after queued and disconnected dispatches, exact-match priority, persistence after widget handoff, and explicit selection of shutdown commands.

GitOrigin-RevId: 152f2b642dcac1ece9c3347eb4541d03fc3a425c
2026-12-01 16:52:56 +00:00
Benjamin Carlsson 5c865592f4 Remember the TUI's Cloud environment choice per project (#65033)
## Why

Selecting a saved Cloud environment for a draft did not set a default
for future conversations in the same project.

## What changed

- Save the environment selected for a Cloud draft in the local user
  configuration under `tui.default_cloud_environments`, keyed by project
  and local user identity. Selecting Default clears the preference.
- Reuse the preference at startup, when creating a new Cloud conversation,
  and when switching to Cloud. Use the normal Cloud environment selection
  when the saved environment is absent from the catalog or the catalog
  cannot be loaded.
- Use the v2 environment catalog, filter for eligible saved environments,
  and deduplicate entries across personal and workspace results.

## Testing

Cover preference persistence and clearing, project scoping, reuse after a
config reload, fallback when the catalog is unavailable, and catalog
pagination, filtering, and deduplication.

GitOrigin-RevId: bc4f66842c5c83dc75c5b10840fd596feedd44df
2026-12-01 16:51:26 +00:00
Felipe Coury dcafb4c96f Honor the session directory when resuming after /cd (#65030)
## Why

Changing directories with `/cd` could force in-app resume to use the current
directory even when the saved preference was to use the session's directory.

## What changed

Use the `/cd` directory for the remembered Current choice. Explicit CLI and
remote directory overrides still select Current. If reloading configuration
fails, reuse the existing configuration only when it already belongs to the
resume directory.

## Testing

Update the in-app resume and agents overview cold-resume tests to cover using
the session directory after `/cd`.

GitOrigin-RevId: d87bc2ba96f7ca10d6fd0d5ec0414712d44238e6
2026-12-01 16:41:22 +00:00
Felipe Coury eb1c5108a3 Reject oversized remote sidebar file previews before reading (#65022)
## Why

A remote preview can exceed the WebSocket client's 128 MiB message limit
once the file is base64-encoded and wrapped in a JSON-RPC response.

## What changed

Check the file size with `fs/getMetadata` before calling `fs/readFile` for
remote previews. Allow for base64 expansion and reserve room for the
JSON-RPC envelope. If the reported size exceeds that budget, show a
preview error with the file's size.

Continue with the read if the server lacks `fs/getMetadata` or omits
`sizeBytes`. Apply the sidebar's existing path error handling to metadata
failures as well as read failures.

## Testing

Extend the remote preview test to cover an image at the size limit,
oversized image and text files, and both metadata compatibility fallbacks.

GitOrigin-RevId: a284b3b76d9c56fe7e80445d880ccc17d575681c
2026-12-01 16:07:34 +00:00
Dylan Hurd 697f9e5a5e Wait for complete PTY input in the TUI startup test (#65021)
## Why

A completed write to the PTY master can reach the slave in fragments.
The startup test could run its zero-time poll or input discard before
the full sequence arrived.

## What changed

Use `FIONREAD` to wait until the full paste boundary and the subsequent
action input are each queued on the PTY slave. The wait leaves the bytes
unread and reports how many arrived if it times out.

GitOrigin-RevId: 077715814c4e11e6dfd42e63238222b0204aff4d
2026-12-01 15:55:25 +00:00
Dylan Hurd 55c37f6b80 Wait for an attached thread in TUI job-control tests (#65012)
## Why

The `/status` palette can appear during startup, before the TUI attaches
to a thread. Waiting for the palette alone can let the test suspend the
TUI too early.

## What changed

Use the bundled model catalog to avoid model fetch delays during test
startup. Configure the status line to show `thread-id` and `run-state`,
then wait for ` · Ready` before opening the `/status` palette and
suspending the TUI.

GitOrigin-RevId: adfe1163082dca64c76791f38cee29791ea774b5
2026-12-01 15:28:04 +00:00
Felipe Coury 8a8708c657 Preview large JPEGs in the TUI sidebar (#65007)
## Why

A JPEG can exceed the sidebar's 32 MiB decode budget even when its
thumbnail would fit comfortably.

## What changed

When a full JPEG decode hits the allocation limit, try building a
preview from JPEG block averages within the same budget. The fallback
supports sequential and progressive JPEGs, applies EXIF orientation,
and preserves the oriented source dimensions in the sidebar label.

## Testing

Add tests for a 6544 × 1721 sequential JPEG that produces a 768 × 202
preview and for a progressive fixture that exercises scan refinement,
restart markers, EXIF rotation, and allocation limits.

GitOrigin-RevId: 232b37d8c239fbaa602930d9032c9a784bd030e2
2026-12-01 15:14:52 +00:00
Dylan Hurd 187affbce3 Wait for the Command Center grouping header in the startup test (#65004)
## Why

Startup can send a `thread/list` request while the loading screen is still
visible. Reading the terminal buffer at that point can make the saved
grouping test fail before the Command Center header has rendered.

## What changed

Capture completed terminal frames through a test-only channel. Have
`agents_overview_startup_restores_saved_grouping` wait for the grouping
header and verify that it shows `Group: Status`, the saved preference.

GitOrigin-RevId: e4479039e0663483016637be0fe5bfff62f27044
2026-12-01 14:58:43 +00:00
Benjamin Carlsson 1ba4c7b4fb Recover Cloud sessions with paginated TUI history (#64932)
## Why

A Cloud session can have more history than the TUI scans on reconnect.
Requiring the full transcript prevents recovery even when the recent
history is enough to verify where the session left off.

## What changed

Allow recovery from a bounded history window in owned transcript mode
when it confirms the required turns and updates. Preserve completed
local history outside that window and keep older history pageable
without rendering prompts or replies twice.

Bound turn metadata lookups, including across turns without items.
Sample partial history again before restoring queued question answers
so a response from another client has another chance to appear.

## Testing

Extend reconnect tests to cover partial and overlapping history,
missing live updates, duplicate-free pagination, bounded metadata
lookups, and queued question answers.

GitOrigin-RevId: 2f12d64dc83a6e7e42ee3923baaea40ca7f663ab
2026-12-01 05:32:15 +00:00
Benjamin Carlsson 0ee8daa550 Discover local and cloud tasks together in the agents overview (#64930)
## Why

The agents overview could miss cloud tasks when opened from a local
session, even when the cloud backend was already connected.

## What changed

- Refresh tasks from connected backends when opening the overview, and
  have **Show more** fetch additional pages from each backend that has
  more results.
- Preserve pagination progress across refreshes when it still applies,
  and keep refresh errors visible until the affected backend recovers.

## Testing

Add coverage for discovering and paging through cloud tasks from a local
session, reopening the overview with pagination progress intact, and
refreshing after lifecycle events from a background backend. Add a
snapshot of the mixed local and cloud overview.

GitOrigin-RevId: 11d3108dbbd8c7033cd8fe43cfd045fb3eacccd4
2026-12-01 05:20:42 +00:00
Joe Savona 333bcaa7ff Preserve line breaks in plugin detail descriptions (#64891)
## Why

The plugin detail popup passes the entire description as a single line,
so it loses the author's line breaks.

## What changed

Render each nonblank description line separately and keep dim styling and
terminal-width wrapping. Skip blank and whitespace-only lines so extra
spacing in the description cannot inflate the popup header.

## Testing

Add snapshots at 40 and 100 columns and regression tests for LF and CRLF
line endings, whitespace-only lines, literal Markdown, Unicode, and
description fallbacks. Cover navigation to the install action with a long
description in a short viewport and verify that the plugin picker stays
closed when plugins are disabled.

GitOrigin-RevId: e2f988d6e9b743a4fe318bed8e56563f495da605
2026-12-01 02:54:25 +00:00