Lightweight coding agent that runs in your terminal
Rust
feat: add Android/Termux support by gating arboard dependency (#2895)
pchuri44dce748b63f
diff --git a/codex-rs/tui/Cargo.toml b/codex-rs/tui/Cargo.tomlindex 21fe3b3d70..9a115d28b0 100644--- a/codex-rs/tui/Cargo.toml+++ b/codex-rs/tui/Cargo.toml@@ -22,7 +22,6 @@ workspace = true[dependencies]anyhow = "1"-arboard = "3"async-stream = "0.3.6"base64 = "0.22.1"chrono = { version = "0.4", features = ["serde"] }@@ -93,6 +92,11 @@ pathdiff = "0.2"[target.'cfg(unix)'.dependencies]libc = "0.2"+# Clipboard support via `arboard` is not available on Android/Termux.+# Only include it for non-Android targets so the crate builds on Android.+[target.'cfg(not(target_os = "android"))'.dependencies]+arboard = "3"+[dev-dependencies]chrono = { version = "0.4", features = ["serde"] }diff --git a/codex-rs/tui/src/clipboard_paste.rs b/codex-rs/tui/src/clipboard_paste.rsindex 5a6a8b2f2e..b15b44bddf 100644--- a/codex-rs/tui/src/clipboard_paste.rs+++ b/codex-rs/tui/src/clipboard_paste.rs@@ -47,6 +47,7 @@ pub struct PastedImageInfo {}/// Capture image from system clipboard, encode to PNG, and return bytes + info.+#[cfg(not(target_os = "android"))]pub fn paste_image_as_png() -> Result<(Vec<u8>, PastedImageInfo), PasteImageError> {tracing::debug!("attempting clipboard image read");let mut cb = arboard::Clipboard::new()@@ -70,10 +71,7 @@ pub fn paste_image_as_png() -> Result<(Vec<u8>, PastedImageInfo), PasteImageErro.map_err(|e| PasteImageError::EncodeFailed(e.to_string()))?;}- tracing::debug!(- "clipboard image encoded to PNG ({len} bytes)",- len = png.len()- );+ tracing::debug!("clipboard image encoded to PNG ({}) bytes", png.len());Ok((png,PastedImageInfo {@@ -84,7 +82,16 @@ pub fn paste_image_as_png() -> Result<(Vec<u8>, PastedImageInfo), PasteImageErro))}+/// Android/Termux does not support arboard; return a clear error.+#[cfg(target_os = "android")]+pub fn paste_image_as_png() -> Result<(Vec<u8>, PastedImageInfo), PasteImageError> {+ Err(PasteImageError::ClipboardUnavailable(+ "clipboard image paste is unsupported on Android".into(),+ ))+}+/// Convenience: write to a temp file and return its path + info.+#[cfg(not(target_os = "android"))]pub fn paste_image_to_temp_png() -> Result<(PathBuf, PastedImageInfo), PasteImageError> {let (png, info) = paste_image_as_png()?;// Create a unique temporary file with a .png suffix to avoid collisions.@@ -101,6 +108,14 @@ pub fn paste_image_to_temp_png() -> Result<(PathBuf, PastedImageInfo), PasteImagOk((path, info))}+#[cfg(target_os = "android")]+pub fn paste_image_to_temp_png() -> Result<(PathBuf, PastedImageInfo), PasteImageError> {+ // Keep error consistent with paste_image_as_png.+ Err(PasteImageError::ClipboardUnavailable(+ "clipboard image paste is unsupported on Android".into(),+ ))+}+/// Normalize pasted text that may represent a filesystem path.////// Supports: