mirror of
https://github.com/openai/codex.git
synced 2026-11-21 22:50:37 +00:00
Support the Orca integrated terminal (#63013)
## What changed Recognize Orca from `TERM_PROGRAM=Orca` and report it in `codex doctor`. Render Markdown links as clickable labels in Orca and keep destinations visible under terminal multiplexers. Enable Kitty graphics for pet images only when Orca advertises `ORCA_IMAGE_PROTOCOL=kitty` and the session passes the direct-terminal checks. ## Testing Cover Orca detection, Markdown link rendering and multiplexer fallback, and pet image capability checks. GitOrigin-RevId: 978a9cd99a8090bfe9198611e9ae7e0dd2709c3b
This commit is contained in:
@@ -1909,6 +1909,7 @@ fn terminal_name(info: &TerminalInfo) -> &'static str {
|
||||
TerminalName::AppleTerminal => "Apple Terminal",
|
||||
TerminalName::Ghostty => "Ghostty",
|
||||
TerminalName::Rex => "Rex",
|
||||
TerminalName::Orca => "Orca",
|
||||
TerminalName::Iterm2 => "iTerm2",
|
||||
TerminalName::WarpTerminal => "Warp",
|
||||
TerminalName::VsCode => "VS Code",
|
||||
|
||||
@@ -42,6 +42,8 @@ pub enum TerminalName {
|
||||
Ghostty,
|
||||
/// Rex terminal emulator.
|
||||
Rex,
|
||||
/// Orca integrated terminal.
|
||||
Orca,
|
||||
/// iTerm2 terminal emulator.
|
||||
Iterm2,
|
||||
/// Warp terminal emulator.
|
||||
@@ -180,6 +182,7 @@ impl TerminalInfo {
|
||||
}
|
||||
TerminalName::Ghostty => format_terminal_version("Ghostty", &self.version),
|
||||
TerminalName::Rex => format_terminal_version("rex", &self.version),
|
||||
TerminalName::Orca => format_terminal_version("Orca", &self.version),
|
||||
TerminalName::Iterm2 => format_terminal_version("iTerm.app", &self.version),
|
||||
TerminalName::WarpTerminal => {
|
||||
format_terminal_version("WarpTerminal", &self.version)
|
||||
@@ -421,6 +424,7 @@ fn terminal_name_from_term_program(value: &str) -> Option<TerminalName> {
|
||||
"appleterminal" => Some(TerminalName::AppleTerminal),
|
||||
"ghostty" => Some(TerminalName::Ghostty),
|
||||
"rex" => Some(TerminalName::Rex),
|
||||
"orca" => Some(TerminalName::Orca),
|
||||
"iterm" | "iterm2" | "itermapp" => Some(TerminalName::Iterm2),
|
||||
"warp" | "warpterminal" => Some(TerminalName::WarpTerminal),
|
||||
"vscode" => Some(TerminalName::VsCode),
|
||||
|
||||
@@ -226,6 +226,12 @@ fn detects_rex() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detects_orca() {
|
||||
let env = FakeEnvironment::new().with_var("TERM_PROGRAM", "Orca");
|
||||
assert_eq!(detect_terminal_info_from_env(&env).name, TerminalName::Orca);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detects_vscode() {
|
||||
let env = FakeEnvironment::new()
|
||||
|
||||
@@ -272,6 +272,7 @@ impl LocalSettings {
|
||||
| TerminalName::WarpTerminal
|
||||
| TerminalName::WezTerm
|
||||
| TerminalName::Rex
|
||||
| TerminalName::Orca
|
||||
| TerminalName::Alacritty
|
||||
| TerminalName::Konsole
|
||||
| TerminalName::GnomeTerminal
|
||||
|
||||
@@ -74,6 +74,7 @@ impl WebLinkDisplay {
|
||||
| TerminalName::Iterm2
|
||||
| TerminalName::WezTerm
|
||||
| TerminalName::Rex
|
||||
| TerminalName::Orca
|
||||
| TerminalName::Kitty
|
||||
| TerminalName::VsCode
|
||||
| TerminalName::Alacritty
|
||||
|
||||
@@ -92,6 +92,7 @@ fn supporting_terminals_render_only_the_styled_label_and_keep_its_target() {
|
||||
TerminalName::Iterm2,
|
||||
TerminalName::WezTerm,
|
||||
TerminalName::Rex,
|
||||
TerminalName::Orca,
|
||||
TerminalName::Kitty,
|
||||
TerminalName::VsCode,
|
||||
TerminalName::Alacritty,
|
||||
@@ -146,7 +147,7 @@ fn supporting_terminals_render_only_the_styled_label_and_keep_its_target() {
|
||||
|
||||
#[test]
|
||||
fn unknown_terminals_and_multiplexers_keep_visible_destinations() {
|
||||
let mut tmux = terminal(TerminalName::Ghostty);
|
||||
let mut tmux = terminal(TerminalName::Orca);
|
||||
tmux.multiplexer = Some(Multiplexer::Tmux { version: None });
|
||||
let mut zellij = terminal(TerminalName::Ghostty);
|
||||
zellij.multiplexer = Some(Multiplexer::Zellij { version: None });
|
||||
@@ -278,7 +279,9 @@ fn streaming_and_full_render_agree_with_label_only_links() {
|
||||
#[test]
|
||||
fn label_only_and_fallback_presentations_snapshot() {
|
||||
let markdown = "plain [plain](https://example.com) `code` [`code`](https://example.com)\n\n| Resource |\n| --- |\n| [docs](https://example.com/docs) |";
|
||||
let presentations = [WebLinkDisplay::LabelOnly, WebLinkDisplay::WithDestination]
|
||||
.map(|display| Text::from(visible_lines(render(markdown, /*width*/ 40, display))));
|
||||
let presentations = [TerminalName::Orca, TerminalName::Unknown].map(|name| {
|
||||
let display = WebLinkDisplay::for_terminal(&terminal(name), /*term*/ None);
|
||||
Text::from(visible_lines(render(markdown, /*width*/ 40, display)))
|
||||
});
|
||||
assert_debug_snapshot!(presentations);
|
||||
}
|
||||
|
||||
@@ -128,6 +128,23 @@ pub(crate) fn detect_pet_image_support() -> PetImageSupport {
|
||||
return PetImageSupport::Unsupported(PetImageUnsupportedReason::Zellij);
|
||||
}
|
||||
|
||||
image_support_for_terminal_environment(&terminal_info())
|
||||
}
|
||||
|
||||
fn image_support_for_terminal_environment(info: &TerminalInfo) -> PetImageSupport {
|
||||
if info.name == TerminalName::Orca {
|
||||
return if supports_orca_kitty_graphics(
|
||||
info,
|
||||
env::var("ORCA_IMAGE_PROTOCOL").ok().as_deref(),
|
||||
env::var("TERM").ok().as_deref(),
|
||||
/*sty_present*/ env::var_os("STY").is_some(),
|
||||
) {
|
||||
PetImageSupport::Supported(ImageProtocol::Kitty)
|
||||
} else {
|
||||
PetImageSupport::Unsupported(PetImageUnsupportedReason::Terminal)
|
||||
};
|
||||
}
|
||||
|
||||
if env::var_os("KITTY_WINDOW_ID").is_some() {
|
||||
return PetImageSupport::Supported(ImageProtocol::Kitty);
|
||||
}
|
||||
@@ -136,7 +153,21 @@ pub(crate) fn detect_pet_image_support() -> PetImageSupport {
|
||||
return PetImageSupport::Supported(ImageProtocol::Kitty);
|
||||
}
|
||||
|
||||
pet_image_support_for_terminal(&terminal_info())
|
||||
pet_image_support_for_terminal(info)
|
||||
}
|
||||
|
||||
fn supports_orca_kitty_graphics(
|
||||
info: &TerminalInfo,
|
||||
protocol: Option<&str>,
|
||||
term: Option<&str>,
|
||||
sty_present: bool,
|
||||
) -> bool {
|
||||
info.multiplexer.is_none()
|
||||
&& protocol == Some("kitty")
|
||||
&& !sty_present
|
||||
&& !term.is_some_and(|term| {
|
||||
term == "dumb" || term.starts_with("screen") || term.starts_with("tmux")
|
||||
})
|
||||
}
|
||||
|
||||
fn pet_image_support_for_terminal(info: &TerminalInfo) -> PetImageSupport {
|
||||
@@ -605,6 +636,36 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn orca_graphics_require_a_direct_terminal_and_advertised_protocol() {
|
||||
let mut info = terminal_info_for_test(
|
||||
TerminalName::Orca,
|
||||
/*multiplexer*/ None,
|
||||
Some("Orca"),
|
||||
/*term*/ None,
|
||||
);
|
||||
for (protocol, term, sty_present, expected) in [
|
||||
(Some("kitty"), Some("xterm-256color"), false, true),
|
||||
(None, Some("xterm-256color"), false, false),
|
||||
(Some("kitty"), Some("screen-256color"), false, false),
|
||||
(Some("kitty"), Some("tmux-256color"), false, false),
|
||||
(Some("kitty"), Some("dumb"), false, false),
|
||||
(Some("kitty"), Some("xterm-256color"), true, false),
|
||||
] {
|
||||
assert_eq!(
|
||||
supports_orca_kitty_graphics(&info, protocol, term, sty_present),
|
||||
expected
|
||||
);
|
||||
}
|
||||
info.multiplexer = Some(Multiplexer::Tmux { version: None });
|
||||
assert!(!supports_orca_kitty_graphics(
|
||||
&info,
|
||||
Some("kitty"),
|
||||
Some("xterm-256color"),
|
||||
/*sty_present*/ false
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pet_image_support_detects_sixel_terminals() {
|
||||
for info in [
|
||||
@@ -651,11 +712,26 @@ mod tests {
|
||||
let _kitty = EnvVarGuard::new("KITTY_WINDOW_ID", /*value*/ None);
|
||||
let _wezterm = EnvVarGuard::new("WEZTERM_VERSION", Some("20240203"));
|
||||
let _wezterm_executable = EnvVarGuard::new("WEZTERM_EXECUTABLE", /*value*/ None);
|
||||
let _orca_protocol = EnvVarGuard::new("ORCA_IMAGE_PROTOCOL", /*value*/ None);
|
||||
|
||||
assert_eq!(
|
||||
detect_pet_image_support(),
|
||||
image_support_for_terminal_environment(&terminal_info_for_test(
|
||||
TerminalName::Unknown,
|
||||
/*multiplexer*/ None,
|
||||
/*term_program*/ None,
|
||||
/*term*/ None,
|
||||
)),
|
||||
PetImageSupport::Supported(ImageProtocol::Kitty)
|
||||
);
|
||||
assert_eq!(
|
||||
image_support_for_terminal_environment(&terminal_info_for_test(
|
||||
TerminalName::Orca,
|
||||
/*multiplexer*/ None,
|
||||
Some("Orca"),
|
||||
/*term*/ None,
|
||||
)),
|
||||
PetImageSupport::Unsupported(PetImageUnsupportedReason::Terminal)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -65,6 +65,7 @@ fn auto_resize_reflow_max_rows(
|
||||
TerminalName::AppleTerminal
|
||||
| TerminalName::Ghostty
|
||||
| TerminalName::Rex
|
||||
| TerminalName::Orca
|
||||
| TerminalName::Iterm2
|
||||
| TerminalName::WarpTerminal
|
||||
| TerminalName::Kitty
|
||||
|
||||
@@ -783,6 +783,7 @@ pub(super) async fn run_main_inner(
|
||||
TerminalName::AppleTerminal => "apple_terminal",
|
||||
TerminalName::Ghostty => "ghostty",
|
||||
TerminalName::Rex => "rex",
|
||||
TerminalName::Orca => "orca",
|
||||
TerminalName::Iterm2 => "iterm2",
|
||||
TerminalName::WarpTerminal => "warp",
|
||||
TerminalName::VsCode => "vscode",
|
||||
|
||||
Reference in New Issue
Block a user