Skip to content
This repository was archived by the owner on Nov 3, 2026. It is now read-only.

[pull] kontext-dev from main - #17

Merged
michiosw merged 1 commit into
kontext-devfrom
main
Feb 27, 2026
Merged

michiosw merged 1 commit into
kontext-devfrom
main

Conversation

@michiosw

@michiosw michiosw commented Feb 27, 2026 •

Copy link
Copy Markdown

Automated upstream sync from main into kontext-dev.


Open with Devin

* fix: use AbsolutePathBuf for permission profile file roots (openai#12970)

## Why
`PermissionProfile` should describe filesystem roots as absolute paths
at the type level. Using `PathBuf` in `FileSystemPermissions` made the
shared type too permissive and blurred together three different
deserialization cases:

- skill metadata in `agents/openai.yaml`, where relative paths should
resolve against the skill directory
- app-server API payloads, where callers should have to send absolute
paths
- local tool-call payloads for commands like `shell_command` and
`exec_command`, where `additional_permissions.file_system` may
legitimately be relative to the command `workdir`

This change tightens the shared model without regressing the existing
local command flow.

## What Changed
- changed `protocol::models::FileSystemPermissions` and the app-server
`AdditionalFileSystemPermissions` mirror to use `AbsolutePathBuf`
- wrapped skill metadata deserialization in `AbsolutePathBufGuard`, so
relative permission roots in `agents/openai.yaml` resolve against the
containing skill directory
- kept app-server/API deserialization strict, so relative
`additionalPermissions.fileSystem.*` paths are rejected at the boundary
- restored cwd/workdir-relative deserialization for local tool-call
payloads by parsing `shell`, `shell_command`, and `exec_command`
arguments under an `AbsolutePathBufGuard` rooted at the resolved command
working directory
- simplified runtime additional-permission normalization so it only
canonicalizes and deduplicates absolute roots instead of trying to
recover relative ones later
- updated the app-server schema fixtures, `app-server/README.md`, and
the affected transport/TUI tests to match the final behavior

* fix(tui): promote windows terminal diff ansi16 to truecolor (openai#13016)

## Summary

- Promote ANSI-16 to truecolor for diff rendering when running inside
Windows Terminal
- Respect explicit `FORCE_COLOR` override, skipping promotion when set
- Extract a pure `diff_color_level_for_terminal` function for
testability
- Strip background tints from ANSI-16 diff output, rendering add/delete
lines with foreground color only
- Introduce `RichDiffColorLevel` to type-safely restrict background
fills to truecolor and ansi256

## Problem

Windows Terminal fully supports 24-bit (truecolor) rendering but often
does not provide the usual TERM metadata (`TERM`, `TERM_PROGRAM`,
`COLORTERM`) in `cmd.exe`/PowerShell sessions. In those environments,
`supports-color` can report only ANSI-16 support. The diff renderer
therefore falls back to a 16-color palette, producing washed-out,
hard-to-read diffs.

The screenshots below demonstrate that both PowerShell and cmd.exe don't
set any `*TERM*` environment variables.

| PowerShell | cmd.exe |
|---|---|
| <img width="2032" height="1162" alt="SCR-20260226-nfvy"
src="https://github.com/user-attachments/assets/59e968cc-4add-4c7b-a415-07163297e86a"
/> | <img width="2032" height="1162" alt="SCR-20260226-nfyc"
src="https://github.com/user-attachments/assets/d06b3e39-bf91-4ce3-9705-82bf9563a01b"
/> |


## Mental model

`StdoutColorLevel` (from `supports-color`) is the _detected_ capability.
`DiffColorLevel` is the _intended_ capability for diff rendering. A new
intermediary — `diff_color_level_for_terminal` — maps one to the other
and is the single place where terminal-specific overrides live.

Windows Terminal is detected two independent ways: the `TerminalName`
parsed by `terminal_info()` and the raw presence of `WT_SESSION`. When
`WT_SESSION` is present and `FORCE_COLOR` is not set, we promote
unconditionally to truecolor. When `WT_SESSION` is absent but
`TerminalName::WindowsTerminal` is detected, we promote only the ANSI-16
level (not `Unknown`).

A single override helper — `has_force_color_override()` — checks whether
`FORCE_COLOR` is set. When it is, both the `WT_SESSION` fast-path and
the `TerminalName`-based promotion are suppressed, preserving explicit
user intent.

| PowerShell | cmd.exe | WSL | Bash for Windows |
|---|---|---|---|
|
![SCR-20260226-msrh](https://github.com/user-attachments/assets/0f6297a6-4241-4dbf-b7ff-cf02da8941b0)
|
![SCR-20260226-nbao](https://github.com/user-attachments/assets/bb5ff8a9-903c-4677-a2de-1f6e1f34b18e)
|
![SCR-20260226-nbej](https://github.com/user-attachments/assets/26ecec2c-a7e9-410a-8702-f73995b490a6)
|
![SCR-20260226-nbkz](https://github.com/user-attachments/assets/80c4bf9a-3b41-40e1-bc87-f5c565f96075)
|

## Non-goals

- This does not change color detection for anything outside the diff
renderer (e.g. the chat widget, markdown rendering).
- This does not add a user-facing config knob; `FORCE_COLOR` already
serves that role.

## Tradeoffs

- The `has_wt_session` signal is intentionally kept separate from
`TerminalName::WindowsTerminal`. `terminal_info()` is derived with
`TERM_PROGRAM` precedence, so it can differ from raw `WT_SESSION`.
- Real-world validation in this issue: in both `cmd.exe` and PowerShell,
`TERM`/`TERM_PROGRAM`/`COLORTERM` were absent, so TERM-based capability
hints were unavailable in those sessions.
- Checking `FORCE_COLOR` for presence rather than parsing its value is a
simplification. In practice `supports-color` has already parsed it, so
our check is a coarse "did the user set _anything_?" gate. The effective
color level still comes from `supports-color`.
- When `WT_SESSION` is present without `FORCE_COLOR`, we promote to
truecolor regardless of `stdout_level` (including `Unknown`). This is
aggressive but correct: `WT_SESSION` is a strong signal that we're in
Windows Terminal.
- ANSI-16 add/delete backgrounds (bright green/red) overpower
syntax-highlighted token colors, making diffs harder to read.
Foreground-only cues (colored text, gutter signs) preserve readability
on low-color terminals.

## Architecture

```
stdout_color_level()  ──┐
terminal_info().name  ──┤
WT_SESSION presence   ──┼──▶ diff_color_level_for_terminal() ──▶ DiffColorLevel
FORCE_COLOR presence  ──┘                                            │
                                                                     ▼
                                                          RichDiffColorLevel::from_diff_color_level()
                                                                     │
                                                          ┌──────────┴──────────┐
                                                          │ Some(TrueColor|256) │ → bg tints
                                                          │ None (Ansi16)       │ → fg only
                                                          └─────────────────────┘
```

`diff_color_level()` is the environment-reading entry point; it gathers
the four runtime signals and delegates to the pure, testable
`diff_color_level_for_terminal()`.

## Observability

No new logs or metrics. Incorrect color selection is immediately visible
as broken diff rendering; the test suite covers the decision matrix
exhaustively.

## Tests

Six new unit tests exercise every branch of
`diff_color_level_for_terminal`:

| Test | Inputs | Expected |
|------|--------|----------|
| `windows_terminal_promotes_ansi16_to_truecolor_for_diffs` | Ansi16 +
WindowsTerminal name | TrueColor |
| `wt_session_promotes_ansi16_to_truecolor_for_diffs` | Ansi16 +
WT_SESSION only | TrueColor |
| `non_windows_terminal_keeps_ansi16_diff_palette` | Ansi16 + WezTerm |
Ansi16 |
| `wt_session_promotes_unknown_color_level_to_truecolor` | Unknown +
WT_SESSION | TrueColor |
| `explicit_force_override_keeps_ansi16_on_windows_terminal` | Ansi16 +
WindowsTerminal + FORCE_COLOR | Ansi16 |
| `explicit_force_override_keeps_ansi256_on_windows_terminal` | Ansi256
+ WT_SESSION + FORCE_COLOR | Ansi256 |
| `ansi16_add_style_uses_foreground_only` | Dark + Ansi16 | fg=Green,
bg=None |
| (and any other new snapshot/assertion tests from commits d757fee and
d7c78b3) | | |

## Test plan

- [x] Verify all new unit tests pass (`cargo test -p codex-tui --lib`)
- [x] On Windows Terminal: confirm diffs render with truecolor
backgrounds
- [x] On Windows Terminal with `FORCE_COLOR` set: confirm promotion is
disabled and output follows the forced `supports-color` level
- [x] On macOS/Linux terminals: confirm no behavior change

Fixes openai#12904 
Fixes openai#12890
Fixes openai#12912
Fixes openai#12840

* Align TUI voice transcription audio with 4o ASR (openai#13030)

## Summary
- switch TUI push-to-talk transcription requests to
`gpt-4o-mini-transcribe`
- prefer 24 kHz mono `i16` microphone configs and normalize voice input
to 24 kHz mono before upload/send
- add unit coverage for the new downmix/resample path

## Testing
- `just fmt`
- `cargo test -p codex-tui`

---------

Co-authored-by: Michael Bolin <[email protected]>
Co-authored-by: Felipe Coury <[email protected]>
Co-authored-by: Jeremy Rose <[email protected]>
@michiosw michiosw added the upstream-sync Automated upstream sync PR label Feb 27, 2026
@michiosw
michiosw merged commit 2f36a07 into kontext-dev Feb 27, 2026
20 of 62 checks passed

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 8 additional findings in Devin Review.

Open in Devin Review

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 is_mutating parses AbsolutePathBuf-containing types without AbsolutePathBufGuard, causing false positives

After migrating FileSystemPermissions from Vec<PathBuf> to Vec<AbsolutePathBuf>, the is_mutating methods in ShellHandler, ShellCommandHandler, and UnifiedExecHandler all deserialize argument types containing AbsolutePathBuf fields without setting the thread-local AbsolutePathBufGuard. When the model provides relative paths in additional_permissions, deserialization fails and the entire command is conservatively classified as mutating.

Detailed Explanation

The AbsolutePathBuf deserializer (codex-rs/utils/absolute-path/src/lib.rs:172-189) requires a thread-local base path (set via AbsolutePathBufGuard) to resolve relative paths. If no guard is set and the path is not absolute, deserialization errors with "AbsolutePathBuf deserialized without a base path".

In the handle() methods, this is done correctly via resolve_workdir_base_path + parse_arguments_with_base_path. But in is_mutating, the arguments are parsed with plain serde_json::from_str (no guard):

// shell.rs line 158
serde_json::from_str::<ShellToolCallParams>(arguments)
    .map(|params| !is_known_safe_command(&params.command))
    .unwrap_or(true)

Since ShellToolCallParams contains additional_permissions: Option<PermissionProfile>, and PermissionProfile → FileSystemPermissions now holds Vec<AbsolutePathBuf>, the parse fails for any tool call with relative paths in additional_permissions.

Because all three is_mutating implementations fall back to true on parse errors, the effect is that safe commands (e.g., read-only ls) get misclassified as mutating, potentially triggering unnecessary approval prompts.

Impact: Commands with relative additional_permissions paths are always treated as mutating regardless of whether the command is actually safe, resulting in unnecessary approval prompts.

(Refers to lines 157-161)

Prompt for agents
In codex-rs/core/src/tools/handlers/shell.rs, the is_mutating methods for ShellHandler (line 157-161), ShellCommandHandler (line 239-252), and in codex-rs/core/src/tools/handlers/unified_exec.rs UnifiedExecHandler::is_mutating (line 100-112) all parse argument types that now contain AbsolutePathBuf fields without first setting the AbsolutePathBufGuard thread-local.

To fix this, either:
1. Set the guard before parsing in each is_mutating method (like handle() does), e.g. by calling resolve_workdir_base_path first and then parse_arguments_with_base_path.
2. Or, for is_mutating only, use a more targeted deserialization that extracts just the command field as a raw Value without trying to deserialize the full struct (avoiding the AbsolutePathBuf deserialization entirely).
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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

Labels

upstream-sync Automated upstream sync PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant