Files
codex/codex-rs/tui/src/terminal_visualization_instructions.rs
T
vie-oai 61a913d9c8 [codex] Gate terminal visualization instructions in TUI (#26013)
## Summary
- add `Feature::TerminalVisualizationInstructions` as
`UnderDevelopment`, disabled by default
- keep terminal visualization instructions inside the TUI package
- append them to existing developer instructions for TUI start, resume,
and fork flows only when enabled
- intentionally do not apply them to `codex exec`

## Rollout
Control behavior is unchanged. TUI dogfooders can enable
`terminal_visualization_instructions`; no default user receives the new
terminal-specific instructions.

The shared visualization-selection rule is supplied separately through
the `codex_proxy_model_3` Statsig layer for every target Codex model
slug in the gated cohort. This TUI feature determines how to render an
appropriate visualization on the terminal surface; the model-layer
treatment determines when to use one.

## Validation
- `cargo test -p codex-tui
terminal_visualization_instructions_are_gated_for_all_tui_thread_flows
--lib`
- `cargo test -p codex-features --lib`
- `cargo fmt --all -- --check`
- `git diff --check`
- GPT-5.4 and GPT-5.5 real prompt-pipeline smoke tests: both visualized
the positive mapping case, abstained on the negative route case, and
passed exact prompt-stack verification on CLI and App
- refreshed onto current `main` with a clean merge and reran the focused
validation

The full 53-probe all-model treatment comparison and requested
production coding evals remain rollout gates before broadening beyond
the initial employee cohort.

This PR remains open for normal human review.
2026-06-05 17:23:45 -07:00

30 lines
1.2 KiB
Rust

use crate::legacy_core::config::Config;
use codex_features::Feature;
pub(crate) const TERMINAL_VISUALIZATION_INSTRUCTIONS: &str = "\
- This surface is a terminal. When the formatting rules require a visual, include one in the final answer using compact ASCII diagrams, trees, timelines, or tables.
- Use tables for exact mappings or comparisons rather than collapsing known mappings into prose.
- Use trees for hierarchy or one-to-many relationships, and diagrams or timelines for sequence, change, or state transferred between records across event order.
- Use only ASCII characters in visuals.";
pub(crate) fn with_terminal_visualization_instructions(
config: &Config,
control_instructions: Option<String>,
) -> Option<String> {
if !config
.features
.enabled(Feature::TerminalVisualizationInstructions)
{
return control_instructions;
}
let existing_instructions =
control_instructions.or_else(|| config.developer_instructions.clone());
Some(match existing_instructions.as_deref() {
Some(existing) if !existing.trim().is_empty() => {
format!("{existing}\n\n{TERMINAL_VISUALIZATION_INSTRUCTIONS}")
}
_ => TERMINAL_VISUALIZATION_INSTRUCTIONS.to_string(),
})
}