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

@ -1,6 +1,7 @@
// Per-test-case module for the `pty_e2e` integration test crate.
#[allow(unused_imports)]
use crate::common::*;
use xai_grok_pager_pty_harness::{InferenceEndpoint, InferenceRequestMatcher};
/// Reasoning text streamed by the mock. Must never appear in the answer text
/// so screen assertions can tell the two apart.
@ -18,21 +19,17 @@ async fn minimal_commits_thinking_body_to_scrollback() {
])
.await
.expect("start content");
// The scripted turn streams reasoning deltas before the visible answer.
// Two copies so an auxiliary request can't starve the prompt turn
// (consumed FIFO; unconsumed scripts are dropped with the server).
let reasoning = format!("{REASONING_SENTINEL} pondering syllables quietly");
let answer = format!("{MOCK_RESPONSE_SENTINEL} the answer body.");
for _ in 0..2 {
content.enqueue_response(
"/v1/responses",
ScriptedResponse::sse(sse::responses_api_reasoning_and_text_events(
&reasoning,
&answer,
"test-model",
)),
);
}
let _thinking_turn = content.expect_response(
"minimal transcript reasoning turn",
InferenceRequestMatcher::foreground(InferenceEndpoint::Responses),
ScriptedResponse::sse(sse::responses_api_reasoning_and_text_events(
&reasoning,
&answer,
"test-model",
)),
);
// Fallback mode for any further auxiliary traffic.
content.set_response(answer.clone());

View file

@ -38,7 +38,7 @@ async fn minimal_continue_reprints_transcript() {
project.path(),
);
resumed
.wait_for_full_text(&turn_sentinel(1), WELCOME_TIMEOUT)
.wait_for_full_text(&turn_sentinel(1), RESUME_TIMEOUT)
.unwrap_or_else(|e| {
panic!(
"history must be reprinted after --continue: {e}\nfull:\n{}",

View file

@ -10,16 +10,14 @@ use crate::common::*;
#[ignore]
async fn minimal_ctrl_o_send_now_queued_apple_terminal() {
let content = ContentController::start().await.expect("start content");
content.set_turns([
let mut turn_one = content.expect_agent_turn_blocked(
"running turn before minimal Ctrl+O send-now",
slow_turn_text("STEPONE"),
"STEPTWO send-now via Ctrl+O acknowledged.".to_owned(),
]);
// Hold turn 1 open deterministically: its content streams, but its
// completion is gated until we release it below. Chunk-delay pacing alone
// left a wall-clock race — under parallel-suite load turn 1 could finish
// before Ctrl+O landed, so the follow-up was promoted FIFO as a plain
// prompt and the send-now chrome never appeared.
content.hold_agent_completions();
);
let _turn_two = content.expect_agent_turn(
"minimal Ctrl+O sent-now prompt",
"STEPTWO send-now via Ctrl+O acknowledged.",
);
let binary = pager_binary().expect("resolve pager binary");
let mut env = content.env_for_pager();
@ -40,6 +38,9 @@ async fn minimal_ctrl_o_send_now_queued_apple_terminal() {
harness
.wait_for_text("STEPONE", Duration::from_secs(30))
.expect("turn 1 streaming");
tokio::time::timeout(Duration::from_secs(10), turn_one.wait_blocked())
.await
.expect("turn 1 reached completion barrier");
harness
.inject_keys(b"minimal send-now payload\r")
@ -62,7 +63,7 @@ async fn minimal_ctrl_o_send_now_queued_apple_terminal() {
.expect("send-now chrome (not a silent transcript open)");
// Let the mock's gate go so the promoted turn streams its reply.
content.release_agent_completions();
turn_one.release();
harness
.wait_for_text("STEPTWO", Duration::from_secs(40))
.expect("send-now turn reply");

View file

@ -18,11 +18,14 @@ async fn minimal_double_esc_committed_queued_prompt_single_render() {
// Gate turn 1's completion so the queue provably lands mid-turn; turn 2
// (the promoted prompt's) streams nothing before the cancel thanks to
// the pacing set just before the release.
content.hold_agent_completions();
content.set_turns([
"STEPONE first reply.".to_owned(),
"STEPTWO never streams before the cancel.".to_owned(),
]);
let mut turn_one = content.expect_agent_turn_blocked(
"running turn before minimal queue promotion",
"STEPONE first reply.",
);
let _turn_two = content.expect_agent_turn(
"promoted minimal prompt cancelled before first token",
"STEPTWO never streams before the cancel.",
);
let mut harness = spawn_minimal(&content);
wait_minimal_ready(&mut harness);
@ -33,6 +36,9 @@ async fn minimal_double_esc_committed_queued_prompt_single_render() {
harness
.wait_for_text("STEPONE", Duration::from_secs(30))
.expect("turn 1 streamed (completion still gated)");
tokio::time::timeout(Duration::from_secs(10), turn_one.wait_blocked())
.await
.expect("turn 1 reached completion barrier");
harness
.inject_keys(format!("{QUEUED_PROMPT}\r").as_bytes())
@ -45,7 +51,7 @@ async fn minimal_double_esc_committed_queued_prompt_single_render() {
// its turn starts — but its first token is 30s away, the exact window
// where a naive rewind would double-show the committed block.
content.set_chunk_delay(Some(Duration::from_secs(30)));
content.release_agent_completions();
turn_one.release();
harness
.wait_for_full_text(
&format!("\u{276F} {QUEUED_PROMPT}"),

View file

@ -0,0 +1,86 @@
// Per-test-case module for the `pty_e2e` integration test crate.
#[allow(unused_imports)]
use crate::common::*;
/// Minimal `Ctrl+G` hands the draft to a local non-interactive editor script,
/// restores the native-scrollback live region, and leaves the edited text in
/// the composer until the user explicitly submits it.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
#[ignore]
async fn minimal_external_editor_round_trip() {
let content = ContentController::start().await.expect("start content");
content.set_response(format!("{MOCK_RESPONSE_SENTINEL} edited prompt received."));
let dir = tempfile::tempdir().expect("temp editor dir");
let editor = if cfg!(windows) {
let script = dir.path().join("local-editor.cmd");
std::fs::write(
&script,
"@echo off\r\n>\"%~1\" echo|set /p=edited draft from external editor\r\n",
)
.expect("write Windows editor script");
format!("cmd /C '{}'", script.display())
} else {
let script = dir.path().join("local-editor.sh");
std::fs::write(
&script,
"#!/bin/sh\nprintf 'edited draft from external editor' > \"$1\"\n",
)
.expect("write Unix editor script");
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
std::fs::set_permissions(&script, std::fs::Permissions::from_mode(0o700))
.expect("make editor executable");
}
format!("'{}'", script.display())
};
let mut env = content.env_for_pager();
env.push(("VISUAL".to_owned(), editor));
let env_refs: Vec<(&str, &str)> = env.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();
let binary = pager_binary().expect("resolve pager binary");
let mut harness = PtyHarness::new(&binary, DEFAULT_ROWS, DEFAULT_COLS, MINIMAL_ARGS, &env_refs)
.expect("spawn minimal pager");
harness.set_respond_to_queries(true);
wait_minimal_ready(&mut harness);
inject_keys_paced(&mut harness, b"original draft");
harness.inject_keys(b"\x07").expect("Ctrl+G");
harness
.wait_for_text("edited draft from external editor", Duration::from_secs(10))
.expect("edited draft restored to composer");
assert!(
!harness.full_text().contains(MOCK_RESPONSE_SENTINEL),
"editor exit must not submit the draft"
);
harness.inject_keys(b"\r").expect("submit edited draft");
harness
.wait_for_full_text(MOCK_RESPONSE_SENTINEL, Duration::from_secs(30))
.expect("edited draft submitted");
let user_messages = all_user_message_blobs(&content);
assert!(
user_messages
.iter()
.any(|message| message.contains("edited draft from external editor")),
"exact edited draft must reach the wire: {user_messages:#?}"
);
assert!(
user_messages
.iter()
.all(|message| !message.contains("original draft")),
"original draft must not reach the wire: {user_messages:#?}"
);
harness
.wait_for_text(MINIMAL_IDLE_SENTINEL, Duration::from_secs(10))
.expect("minimal live region restored idle");
assert!(
!harness.contains_text("panicked"),
"pager panicked\nscreen:\n{}",
harness.screen_contents()
);
quit_minimal(&mut harness);
}

View file

@ -87,21 +87,7 @@ async fn minimal_flush_left_no_hpad() {
"description": "flush-left permission check",
})
.to_string();
content.enqueue_response(
"/v1/responses",
ScriptedResponse::sse(responses_api_tool_call_events(
"call_flush",
"run_terminal_command",
&args,
)),
);
content.enqueue_response(
"/v1/chat/completions",
ScriptedResponse::sse(chat_completions_tool_call_events(
"run_terminal_command",
&args,
)),
);
let _permission_turn = expect_tool_turn(&content, "call_flush", "run_terminal_command", args);
harness
.inject_keys(b"run the flush check\r")
.expect("submit tool prompt");

View file

@ -17,7 +17,7 @@ async fn minimal_lookup_commits_one_line_summary() {
let fixture = content.home().join("haystack.txt");
std::fs::write(&fixture, format!("{BODY_SENTINEL} body line\n")).expect("write fixture");
enqueue_tool_turn(
let _read_turn = expect_tool_turn(
&content,
"call_read",
"read_file",

View file

@ -16,10 +16,14 @@ async fn minimal_queue_indicator_shows_while_running() {
let content = ContentController::start().await.expect("start content");
// Pace turn 1 so it's still streaming when we queue behind it.
content.set_chunk_delay(Some(Duration::from_millis(150)));
content.set_turns([
let _turn_one = content.expect_agent_turn(
"running turn before minimal queue promotion",
slow_turn_text("STEPONE"),
"STEPTWO queued prompt handled.".to_owned(),
]);
);
let _turn_two = content.expect_agent_turn(
"promoted minimal queued prompt",
"STEPTWO queued prompt handled.",
);
let mut harness = spawn_minimal(&content);
wait_minimal_ready(&mut harness);

View file

@ -15,6 +15,7 @@ mod minimal_continue_reprints_transcript;
mod minimal_ctrl_c_arms_and_quits;
mod minimal_double_esc_committed_queued_prompt_single_render;
mod minimal_esc_mid_turn_is_swallowed;
mod minimal_external_editor_round_trip;
mod minimal_flush_left_no_hpad;
mod minimal_help_opens_command_palette;
mod minimal_lookup_commits_one_line_summary;