Commit Graph
14517 Commits
Author SHA1 Message Date
tejsudha-openai f20d485ea2 Send the installation ID header on authenticated Responses requests (#65183)
## What changed

Add `x-codex-installation-id` to Responses API HTTP requests and WebSocket
handshakes when an authorization header is attached and the destination is
a trusted OpenAI endpoint. Use the persisted installation ID already sent in
`client_metadata` and mark the header value as sensitive.

## Testing

Cover header delivery over WebSocket and HTTP, retention across a trusted
redirect, and omission for unauthenticated requests and third-party endpoints.

GitOrigin-RevId: 3fa83816cc91584944d6023680ba0dd05fbca138
2026-12-02 06:54:40 +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
alexsong-oai badc482b81 Add monthly spend reads for custom model providers (#65168)
## What changed

Add an optional `usage_url` to model provider configuration and carry it
through remote thread configuration. Expose `read_provider_usage` to
fetch the current user's monthly USD spend, optional cap and percentage
used, and reset time.

Use the provider's own credentials for the request. Reject redirects,
disable interactive gateway login, and enforce same-origin validation
for gateway OAuth configurations that require it.

## Testing

Cover capped and uncapped spend, percentage rounding, and malformed
responses. Verify usage URL validation and remote configuration
round-tripping.

GitOrigin-RevId: ed805a756aab6e55c24751f0285bfe73b9091f07
2026-12-02 04:59:30 +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
ningyi-oai abb3701f4c Refresh workspace Git status before sending WebSocket turn frames (#65158)
## Why

A background Git scan can finish during WebSocket connection setup.
The generation frame previously used the earlier metadata snapshot,
so it could omit Git status that was already available when it was sent.

## What changed

Pick up same-turn Git results before building the generation frame,
without waiting for the scan. Handshake headers and prewarm frames use
the initial snapshot. Keep the earlier workspace snapshot if the refresh
would exceed the metadata size limit where the earlier one fit, or
displace a Git remote URL that would otherwise fit.

## Testing

Add regression coverage for Git status arriving during the handshake,
which request kinds can refresh, and remote URL retention at the
metadata size boundary.

GitOrigin-RevId: 942eeb8d5ee16756803ce3a5021d186a47fb9f0c
2026-12-02 03:47:42 +00:00
arnavpatidar-OAI ed3678a2a9 Reuse discovered OAuth for managed gateway inference (#65157)
## Why

Gateway enrollment required an explicit `[gateway.auth]` block even when
Codex could discover the OAuth settings while loading managed policy.
Frozen policy snapshots also dropped the discovered settings before
Codex configured the inference provider.

## What changed

Make `[gateway.auth]` optional. When it is omitted, use the OAuth
settings retained in the policy snapshot to configure the inference
provider, provided the snapshot matches the configured gateway enrollment.

## Testing

Add a regression test that compares the provider built from a frozen
snapshot with the provider built from explicit OAuth settings. The test
also verifies that changing the gateway root leaves the new provider
without the previous gateway's OAuth settings and fails the managed
policy check.

GitOrigin-RevId: a8734b3c98f50c9c9ef1917eb8c1d12548cbc271
2026-12-02 03:47:01 +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
Charlie Marsh 028590df7d Preserve deferred tool declarations in prediction forks (#65146)
## Why

A prediction fork that disables MCP inherits the parent's tool declarations,
but recomputing the deferred tool list can append a conflicting declaration
to the request.

## What changed

Skip the deferred tool list update when the fork preserves the parent's tool
declarations. The fork still reports MCP tool unavailability separately.

## Testing

Extend `prediction_fork_keeps_inherited_tools` to cover both inline and
deferred MCP tools and assert that the fork carries exactly the parent's
`<tools>` messages.

GitOrigin-RevId: 04b4a542e0d587a20706935e8b028b7f1fdb9209
2026-12-02 02:40:50 +00:00
Alvin 3fef28219c Surface TLS failures during workload identity sign-in (#65145)
## Why

The generic token exchange unavailable error gives users no indication that
they should check their trusted CA certificates when a TLS failure occurs.

## What changed

Report TLS failures during token exchange with guidance to check the trusted
CA certificates on the host or container. Keep these failures transient and
continue reporting other request failures as exchange unavailable.

## Testing

Add a regression test that checks the certificate guidance for an invalid
custom CA file and verifies that both TLS failures and timeouts remain
transient, with timeouts still reported as exchange unavailable.

GitOrigin-RevId: b4eb9eb9eb86d4703b9b96b3e339d2764bc5644f
2026-12-02 02:39:37 +00:00
Alvin b6743d7ea8 Report workload identity authentication in codex doctor (#65142)
## Why

`codex doctor` could report missing credentials when workload identity
was selected and no local credentials were stored.

## What changed

Use the auth manager's workload identity selection to report authentication
as successful and show how to check it with `codex login status`.

## Testing

Add a regression test that checks the terminal and redacted JSON reports
for workload identity with no stored credentials.

GitOrigin-RevId: cf385cf2cb71cc8aed95427ef83524bab4582702
2026-12-02 02:14:46 +00:00
Adam Perry @ OpenAI e1e967cd46 Add session-scoped aliases for registered environment IDs (#65140)
## What changed

Pair each registered executor ID with a model-facing alias assigned on
first use by the session's model ID store. Turn environment snapshots
can resolve these pairs in selection order, including for executors
that are still starting or have failed. Environment context snapshots
and rendering continue to use registered IDs.

## Testing

Cover alias assignment in selection order, stability across readiness
updates, and reuse of the same ID pair after reopening the SQLite store.

GitOrigin-RevId: e5fa6e5549ebb12fcf651e5bf7413402fb4db1b3
2026-12-02 01:59:55 +00:00
Adam Perry @ OpenAI 55ea9a4620 Standardize response request IDs across Codex clients (#65135)
## Why

Different response paths recognize different request ID headers, so
diagnostics can lose the ID needed to correlate a failed request. For
example, an Azure response may carry only `x-ms-request-id`.

## What changed

Use `CodexHeaderMap` to share response header parsing across API clients,
OAuth errors, and response debug context. When a caller needs one
request ID, fall back to the next supported header if the preferred
value is missing, empty, or unreadable.

Preserve recognized request ID headers on Responses WebSocket
handshakes. Use a shared summary for remote control errors and tracing,
omitting sensitive, empty, unreadable, and unrelated values.

## Testing

Cover fallback from an empty or unreadable primary ID, Azure-only debug
context, filtering in diagnostic summaries, and preservation of request
IDs in WebSocket handshakes and remote control pairing errors.

GitOrigin-RevId: f728a4a867f4705b784916b331f413e560f8626b
2026-12-02 01:44:46 +00:00
Benjamin Carlsson cf24cd5a93 Centralize CLI config flag expansion (#65134)
## What changed

Expand root feature toggles and auto-review flags in the config
argument module before dispatch. Keep auto-review expansion for
`resume` in its command-specific path.

## Testing

Extend the `mcp add` argument test to check that a root `--disable`
follows the collected `-c` overrides and that the command-scoped
override still takes precedence. The test also checks that `-c` after
`--` is forwarded to the MCP server command.

GitOrigin-RevId: 6a7b2a8dddb9043dbfde6b8a20cd98cef5b39ab0
2026-12-02 01:42:03 +00:00
Benjamin Carlsson b444ea738c List account skills and Cloud-compatible plugin installations (#65130)
## What changed

- List uploaded skills for the signed-in ChatGPT account through MCP
  `resources/list`. Return the URI, name, and optional description for
  each valid account skill, deduplicated by URI across pages.
- List enabled, available plugin installations across account scopes and
  group them by marketplace. Exclude plugins with a disabled reason or
  an explicit local executor requirement.

Both lookups use metadata only. Skill contents and plugin bundles stay
on the server.

## Testing

Mock service tests cover pagination, skill URI filtering and
deduplication, and plugin eligibility. The plugin test also checks that
requests omit download URLs and skip display assets.

GitOrigin-RevId: 6b3330232db3f28a6e81510b8fd573159eaf66a9
2026-12-02 01:22:29 +00:00
Dylan Hurd b1387dd6cc Preserve active input context order during compaction (#65128)
## Why

Restoring active context after compaction selects retained messages can
move it across user turns. For example, instructions for a context-only
heartbeat can end up before an earlier, already answered user question.

## What changed

Retain active context in source order when building compacted history
and resetting the context window. Use the full items from live history
so active tool outputs and messages survive prompt shortening.

## Testing

Add regression coverage for a heartbeat that compacts mid-turn, and
verify ordering around repeated user message IDs and pending agent
messages in local and remote compaction.

GitOrigin-RevId: b670f3c4e87331a61986b4c163f892e43bd0261d
2026-12-02 01:08:37 +00:00
Ian MacLeod 0cc4569555 Avoid stale GitHub release asset redirects (#65127)
## Why

GitHub release asset URLs can return cached redirects whose signatures
have expired, causing dependency downloads to fail during CI setup and
packaging.

## What changed

Add a fresh `cache_bust` query parameter to rusty-v8 artifact downloads in
CI and packaging, the Windows voice setup's `pkgconf` MSI download, and
DotSlash archive downloads that use plain GitHub release asset URLs.

GitOrigin-RevId: 560bfdb5788032f6450920b986cd30363eda996e
2026-12-02 01:08:01 +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
aakash-oai 6adca62116 Measure model catalog lookups and HTTP GET attempts (#65123)
## Why

A model catalog lookup can use a cached snapshot or bundled fallback without sending a request. A lookup that reaches the endpoint can send multiple requests through retries. Measuring both lets readers of the metrics distinguish cache behavior from endpoint traffic.

## What changed

- Record one `codex.remote_models.lookup.outcome` observation per completed catalog lookup with its purpose, result, and the source of the snapshot actually selected. Record observations without taking the exporter lock on the lookup path.
- Count dispatched requests in `codex.remote_models.http_get_attempt`, including retries. Tag them by purpose and whether they match the configured endpoint when that context is available. Keep endpoint URLs out of metric labels.
- Mark background refreshes as maintenance and apply metrics enablement changes to cached global handles when the process reloads telemetry settings.

## Testing

Add coverage for cache and fallback attribution, retry counts, auth failures before dispatch, and metrics collection across exporter disablement and replacement.

GitOrigin-RevId: b970207a69432030b4511c7e84acb6696b6f824b
2026-12-02 00:44:37 +00:00
Won Park cd9a09e7f6 Record why MCP runtimes refresh (#65120)
## Why

Several invalidations can be handled by a single MCP runtime refresh. Recording the reasons together shows which changes prompted that refresh.

## What changed

When `mcp_refresh_reason_telemetry` is enabled, successful MCP runtime refreshes report a `codex_mcp_runtime_refresh_event` with distinct reason labels, a timestamp, and thread and session attribution. The flag is off by default.

Multiple installed-plugin metadata changes collapse to one `installed_plugin_metadata` label. The event omits configuration contents and plugin change IDs. Analytics buffers refresh events that arrive before their thread context is available.

## Testing

Add an integration test that queues multiple invalidations and verifies that one event with deduplicated reasons and the correct thread and session IDs is sent after thread start is recorded.

GitOrigin-RevId: 639326d0cb993b8b3a0fcbf0618049cb2ff065fd
2026-12-02 00:41:52 +00:00
Robbie Ostrow 607f7efdfb Require a local runtime for MCP HTTP headers helpers (#65119)
## Why

MCP servers can use the host's HTTP client without a local runtime. That
fallback also let locally configured `http_headers_helper` commands run
on the host when only remote executors were attached.

## What changed

Reject locally configured HTTP headers helpers unless the host has a
local runtime. A host that retains its startup runtime can still run
helpers when it exposes only remote executors. HTTP servers without a
headers helper can still use the host's HTTP client.

## Testing

Cover helper rejection with no executors and with both laptop and cloud
executors attached. Verify that the helper command leaves no marker
file, local stdio startup still fails, and plain HTTP still works. Cover
helper client resolution when a local runtime is available, including
when only remote executors are exposed.

GitOrigin-RevId: 0aff6cc1f9f6122aace54ed4c19ef93e26817c64
2026-12-02 00:28:46 +00:00
Will Emmanuel 7131f15461 Include the host subagent roster in initial environment context (#65118)
## Why

When a turn has no execution environments or other environment context
to report, Codex can skip the environment update before reading the host
roster. The model then misses any active subagents in that roster.

## What changed

Keep the initial environment update until Codex has had a chance to
attach the host roster. Emit `<environment_context>` when the roster is
its only content, and drop the update if it is still empty.

## Testing

Add integration coverage for roster-only context and empty context in
both the default and per-environment formats.

GitOrigin-RevId: 6ceffd9aa13fefa31387c4d598a81a4281554c1c
2026-12-02 00:28:07 +00:00
Shuo c4fcff5e97 Preserve primary authentication for OAuth gateways (#65117)
## Why

When runtime authentication is enabled, a gateway endpoint outside the
supported OpenAI runtime endpoints can fail runtime URL validation before
Codex can use the configured gateway credentials.

## What changed

For valid HTTPS gateway destinations on port 443 with a usable gateway
OAuth configuration, preserve the primary API key or ChatGPT token
alongside the gateway token and skip runtime authentication. Evaluate
inference and model catalog URLs independently so supported OpenAI
endpoints still use runtime authentication and invalid endpoints still fail
validation.

## Testing

Add regression coverage for model discovery and Responses requests in
both runtime authentication modes. The tests check that gateway requests
carry both credentials, omit the runtime assertion, and skip runtime
registration. They also cover mixed inference and catalog destinations
and rejection of invalid URLs.

GitOrigin-RevId: d36d12412495c50c6643d615be8a7d72046c4d1c
2026-12-02 00:26:16 +00:00
hesham-oai 5d32c09b5b Add a multiplexed stdio transport to the exec server (#65115)
## Why

Plain stdio serves one JSON-RPC connection and shuts down when it closes,
so clients cannot run concurrent sessions or reconnect to resume a
detached session over the same stdin/stdout pair.

## What changed

Add `--listen stdio-mux` to serve multiple independent newline-delimited
JSON-RPC connections over one HTTP/2 connection on stdin and stdout.
Each `CONNECT` stream to `rpc.local` carries one JSON-RPC connection.
A client can half-close the request to detach, wait for response EOF,
then open a fresh stream and initialize with `resumeSessionId` before
the session expires.

## Testing

Add tests for concurrent sessions, immediate resume after response EOF,
session expiry, and recovery after a stream reset while another stream
stays usable. Cover shutdown with a full input queue and verify that a
failed stdio write unblocks response senders.

GitOrigin-RevId: cdb9638f8b69671a50f44e3eca4dd9059f5bdcd1
2026-12-02 00:14:30 +00:00
Krish Chainani 33811295ff Treat Noise relay handshake failures as retryable disconnects (#65114)
## Why

A malformed reply during the Noise relay handshake could surface as a
protocol error and stop connection preparation from retrying.

## What changed

Report handshake failures as disconnects and preserve the reason when the
connection fails before it is ready. Keep authenticated registry rejections
as a distinct error that stops retries.

## Testing

Update the transport test to assert the disconnect reason for both an
unexpected WebSocket text frame and a relay stream reset.

GitOrigin-RevId: 2ad2dbcce5518dcfd35141dd234c87c0d86aa1ae
2026-12-02 00:11:21 +00:00
Owen Lin 88eff82bd7 Wait for reader cancellation in the RPC delay test (#65113)
## Why

The reader task can take more than ten scheduler yields to drop the
reader after a write error, causing the test to fail even when
cancellation works.

## What changed

Have the test reader signal its drop with Tokio's `Notify` and give
`write_error_cancels_reader` up to five seconds to receive that signal
after asserting the broken-pipe error.

GitOrigin-RevId: fdb1fc8d9aaccaa72f85b51e11184df483420f80
2026-12-02 00:00:35 +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
Owen Lin a1deffb5b2 Pass the last inherited turn ID when creating a fork (#65111)
## Why

A thread store that resolves the last inherited turn during fork preparation
can reuse that ID when creating the child instead of resolving it again.

## What changed

Forward the optional `last_inherited_turn_id` from `PreparedFork` to
`CreateThreadParams` alongside the inherited history position. Omit the
field from serialized creation parameters when no ID is available.

## Testing

Add a regression test that checks the in-memory thread store receives the
turn ID supplied by the prepared fork when it creates the child.

GitOrigin-RevId: 709c8cc4a744b2f893af6233e825026a27732873
2026-12-01 23:56:56 +00:00
aakash-oai 1640c74f1f Count remote model catalog ETag hint outcomes (#65110)
## What changed

Record one increment of `codex.remote_models.etag_hint` per comparison
when metrics are enabled. Set `result` to `match` or `mismatch` when the
current endpoint identity has a cached ETag, and to `no_baseline` when
there is no comparable cached ETag. Count the outcome even if the
subsequent refresh fails or authentication prevents a fetch.

## Testing

Add an in-memory metrics test that checks the exact counts and verifies
that a matching hint skips the fetch and an equal ETag from another
endpoint identity counts as `no_baseline`.

GitOrigin-RevId: 9570f415d43cf19bac8f4d82960466c86e883f73
2026-12-01 23:40:13 +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
iceweasel-oai 80d0a67185 Share runtime registration across app-server startup clients (#65106)
## Why

Statsig starts before the model catalog. When runtime agent instances are
enabled, separate auth managers can cause Statsig and model discovery to
register the same app-server runtime twice.

## What changed

Pass a shared runtime auth slot to Statsig and model discovery in both
standalone and in-process app-server startup so they use the same runtime
registration.

## Testing

Extend the CLI startup integration test to require exactly one runtime
registration and verify that both Statsig evaluations and model discovery
send `AgentAssertion` authorization headers.

GitOrigin-RevId: 132521b685c5c7c617e7067c648de65b9a4287b2
2026-12-01 23:12:29 +00:00
Tom 47e1cf4fe4 Link startup prewarm to the first turn's OpenTelemetry trace (#65105)
## Why

Startup prewarm runs in the session startup trace, while the first turn
can run in a separate trace. The first-turn trace needs a way to show
which prewarm task it resolved, including when the wait times out.

## What changed

Record `startup_prewarm.resolve` at info level under the first-turn span.
Capture the startup prewarm span context when scheduling the task and
attach it as an OpenTelemetry span link during resolution. If the prewarm
span is filtered out, omit the link.

## Testing

Check exported spans for first-turn parentage, link behavior with the
prewarm span enabled or filtered out, and no second resolution on a
later turn. Add a regression test for retaining the link on timeout.

GitOrigin-RevId: ef4a19be64ecf145b17527081960e50adca3b92e
2026-12-01 23:11:46 +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
Ben Romano 1aeab9e3d5 Overlap remote MCP config reads with capability discovery (#65101)
## Why

MCP runtime refreshes waited for capability discovery and host MCP
configuration to finish before requesting HTTP MCP servers from the selected
remote environment. That serialized two reads that can be in flight together.

## What changed

Start the remote environment config read alongside host MCP configuration,
including executor capability discovery. Start the read's 10-second timeout
after host configuration is ready so a serial executor can queue the read
behind discovery without consuming its timeout. Merge the results with host
server precedence and requirements still enforced.

## Testing

Add V1 and V2 integration cases that hold both executor replies until both
requests arrive, then verify host precedence and requirements. Add a
paused-clock test that covers a queued read and confirms a stalled read
times out 10 seconds after discovery completes.

GitOrigin-RevId: d974f0f575559bfe6b756de11aa460399fdabf25
2026-12-01 22:57:35 +00:00
Eric Traut 6cc6cee6c5 Make local codex exec interruptible when output blocks (#65099)
## Why

On Unix, a caller that stops draining an output pipe can stall
`codex exec` in a write, preventing it from interrupting the turn
and cleaning up running commands.

## What changed

Move human-readable output, JSON events, and `--output-last-message`
writes to a dedicated thread for local Unix runs. Handle `SIGTERM`
alongside `SIGINT`, and bound the time spent waiting for output after
an interrupt. Allow local turn cancellation before the server marks
the turn active, and exit with status 1 if output is cut short.

## Testing

Add regression tests that send `SIGTERM` with JSON stdout or human
stderr blocked and check that the running command and its child exit.
Also cover interruption while writing the last message to a blocked pipe.

GitOrigin-RevId: fd9a3621d340cefc9af589c605596d2b178aaa9f
2026-12-01 22:49:30 +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 30fdd9bd68 Fix Codex keyboard input when launching from a piped installer (#65093)
## Why

When the installer runs through a pipe, Codex inherits the pipe as
standard input and cannot read keystrokes from the terminal.

## What changed

Keep standard input when it is already a terminal. Otherwise, launch
Codex with input from `/dev/tty`. On macOS, open the controlling
terminal device directly because polling `/dev/tty` for keyboard events
is unsupported.

GitOrigin-RevId: 382436320b801f499dd8ae3de288f42c4cb503f2
2026-12-01 21:55:16 +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