Synced from monorepo

Synced from monorepo

Changes:
- Shell: accept target response id on rewind execute
- Shell: stamp response id on chat user message chunks
- Worktree: optional rebuild and stale git registration cleanup in auto-GC
- Worktree: kind-aware auto-GC TTLs and config knobs
- Worktree: macOS process CWD scan and Unix PID liveness for GC guards
- Worktree: automatic throttled GC on startup (Linux age-based; non-Linux dead-only)
- Pager: add `[ui].combine_queued_prompts` to batch queued follow-ups
- Shell: stop overwriting user skills
- Tools: read markdown in `skills/` directories untruncated
- `/usage` shows per-session token and dollar usage in the TUI
- Security: prompt on environment-dumping `ps` variants
- Security: always-safe `kubectl` no longer runs arbitrary kubeconfig credential plugins without permission
- Tools: make scheduler deletion durable
- Shell: add relocation storage primitives
- Shell: give side model calls their own conversation ids
- Fix five workflow-runtime bugs (budget, pause, cancel, reconnect)
- Security: peel `env -S` / `--split-string` operands in the Bash permission gate (managed deny/ask)
- Pager: expose doctor in the TUI
- Security: block unauthorized RCE via abused safe commands
- Pager idle watcher cue: "1 subagent still running" instead of "watching · 1 subagent"
- Security: block `rg --pre` arbitrary code execution in auto-mode
- Voice: diagnose silent-mic failures (macOS permission) and add doctor/terminal-setup Voice section
- App builder deployer: `allow_forking` and `show_built_with_grok`
- Pager: stop stacking duplicate "Worked for" markers on parked turns
- Shell: support `max` as a distinct reasoning effort tier
- Tools: serialize background `/loop` fires on the whole work unit
- Shell: add working-directory relocation state primitives
- Proto: `ClientToolResult` and `ChatConfig` client-side tools
- Shell: model providers
- Chat: select App Builder product on the Build path
- Shell: attach author identity to feedback when the deployment opts in
- Doctor: fix for SSH wrap setup
- Workflow authoring skills: create-workflow and import-claude-workflow docs
- Add read-only grok doctor
- Sandbox: apply Landlock without a controlling TTY
- Pager: recover image paste over grok wrap on headless remotes
- Pager: make actions screen-mode aware
- Shell: resume sessions when the working directory moves
- Pager: centralize terminal diagnostics
- Workspace: gate inline shell file access
- Pager: centralize terminal probes
- Pager: edit minimal prompts in an external editor
- Pager: standardize backgrounding on Ctrl+B
- Shell: recap rides the parent turn's prompt cache
- Tools: add scheduler lifecycle version clock

Source-Revision: 0f4d7c91b8b2b408333f6de1e8a76cb8eaa71899
This commit is contained in:
grokkybara[bot] 2026-07-21 18:10:23 +00:00
commit 3af4d5d398
556 changed files with 56609 additions and 21892 deletions

View file

@ -4,7 +4,6 @@
//! Pure env-map helpers (`detect_*_from_env`) enable full matrix testing.
use std::collections::HashMap;
use std::process::Command;
use std::sync::OnceLock;
use std::sync::atomic::{AtomicBool, Ordering};
@ -16,6 +15,7 @@ pub mod image;
pub mod keyboard;
pub mod overlay;
pub(crate) mod probe;
pub mod tmux_probe;
pub mod xtversion;
pub use embedded_editor::{EmbeddedEditor, embedded_editor_from_env};
@ -23,7 +23,10 @@ pub use hyperlinks::{
HyperlinkCapabilities, Osc8Support, SchemeFilter, SetDefaultCursor, SetPointerCursor,
hyperlink_capabilities,
};
pub use keyboard::{KeyboardCapabilities, ModifierDelivery, ModifierFate, keyboard_capabilities};
pub use keyboard::{
KeyboardCapabilities, ModifierDelivery, ModifierFate, keyboard_capabilities,
keyboard_capabilities_for_host,
};
#[cfg(test)]
mod test;
@ -64,29 +67,6 @@ pub fn take_kitty_flags_pushed() -> bool {
KITTY_FLAGS_PUSHED.swap(false, Ordering::AcqRel)
}
/// Run `tmux show-option -gqv <option>` and return the trimmed value,
/// or `None` if the subprocess fails or returns empty / whitespace.
/// Stderr is suppressed so startup probes don't leak shell noise.
pub fn tmux_show_option(option: &str) -> Option<String> {
let mut cmd = Command::new("tmux");
cmd.args(["show-option", "-gqv", option])
.stdin(std::process::Stdio::null())
.stderr(std::process::Stdio::null());
xai_tty_utils::detach_std_command(&mut cmd);
let output = cmd.output().ok()?;
parse_tmux_show_option_output(output.status.success(), &output.stdout)
}
/// Pure post-processing for `tmux show-option`: collapses subprocess
/// failure, empty stdout, and whitespace-only stdout to `None`.
pub fn parse_tmux_show_option_output(status_success: bool, stdout: &[u8]) -> Option<String> {
if !status_success {
return None;
}
let val = String::from_utf8_lossy(stdout).trim().to_string();
if val.is_empty() { None } else { Some(val) }
}
/// Known terminal emulator categories.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, strum::Display)]
pub enum TerminalName {
@ -639,6 +619,23 @@ pub fn terminal_context() -> &'static TerminalContext {
TERMINAL_CONTEXT.get_or_init(detect_terminal_context)
}
/// Detect terminal environment facts without any live tmux subprocesses.
///
/// Standalone diagnostics use this so an unhealthy tmux server cannot block
/// before the diagnostic runner has a chance to report unavailable evidence.
pub fn standalone_terminal_context() -> TerminalContext {
standalone_terminal_context_from_env(&collect_process_env(), HostOs::current())
}
fn standalone_terminal_context_from_env(
env: &HashMap<String, String>,
host: HostOs,
) -> TerminalContext {
let mut ctx = build_terminal_context_from_env(env);
ctx.brand = refine_unknown_brand_for_host(ctx.brand, host);
ctx
}
/// Build a [`TerminalContext`] from the current process environment.
fn detect_terminal_context() -> TerminalContext {
let env = collect_process_env();
@ -1020,70 +1017,24 @@ pub enum AltScreenMode {
/// Detect whether the current tmux session is in control mode.
///
/// tmux control mode is detected by checking the `client_flags` on the
/// current client. In control mode, the flags contain "control-mode".
///
/// Returns `false` when not inside tmux or when the query fails.
pub fn detect_tmux_control_mode(ctx: &TerminalContext) -> bool {
if ctx.multiplexer != MultiplexerKind::Tmux {
return false;
}
detect_tmux_control_mode_subprocess()
}
/// Subprocess-based control-mode detection.
///
/// Queries `tmux display-message -p "#{client_flags}"` and checks whether
/// the output contains `"control-mode"`.
fn detect_tmux_control_mode_subprocess() -> bool {
let mut cmd = std::process::Command::new("tmux");
cmd.args(["display-message", "-p", "#{client_flags}"])
.stdin(std::process::Stdio::null())
.stderr(std::process::Stdio::null());
xai_tty_utils::detach_std_command(&mut cmd);
cmd.output()
.ok()
.and_then(|out| {
if out.status.success() {
let flags = String::from_utf8_lossy(&out.stdout);
Some(flags.contains("control-mode"))
} else {
None
}
})
tmux_probe::query_control_mode()
.into_option()
.unwrap_or(false)
}
/// Detect the tmux server version by running `tmux -V`.
///
/// Returns the trimmed version string (e.g. `"tmux 3.4"`) on success,
/// or `None` when not inside tmux or when the subprocess fails.
/// Only call this when `ctx.is_tmux_backed()` is true.
pub fn detect_tmux_version() -> Option<String> {
let mut cmd = std::process::Command::new("tmux");
cmd.arg("-V")
.stdin(std::process::Stdio::null())
.stderr(std::process::Stdio::null());
xai_tty_utils::detach_std_command(&mut cmd);
cmd.output().ok().and_then(|out| {
if out.status.success() {
let version = String::from_utf8_lossy(&out.stdout).trim().to_owned();
if version.is_empty() {
None
} else {
Some(version)
}
} else {
None
}
})
tmux_probe::query_version().into_option()
}
/// Trimmed value of tmux's global `extended-keys` option, or `None` if
/// the subprocess fails or the option is unset / empty. Only call this
/// when `ctx.is_tmux_backed()` is true.
/// Trimmed value of tmux's global `extended-keys` option.
pub fn detect_tmux_extended_keys() -> Option<String> {
tmux_show_option("extended-keys")
tmux_probe::query_option("extended-keys").into_option()
}
/// Parse major.minor from a plain semver-ish string like `"3.6.0"` or `"1.2"`.