Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-bob-processing-turn-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- bob 2.x's busy indicator ("⠇ Processing… (Enter to steer, Tab to queue)") is now recognised as an in-progress turn. Previously a kicked bob turn was classified as ended ~30s after delivery while bob was still working, so the kick outcome settled early and the turn-end kick log archive under 🕘 past kicks was a mid-run snapshot rather than the full run.
36 changes: 36 additions & 0 deletions src/crux/agent/agent_working_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,39 @@ func TestWaitForInputPrompt_WorkingGate(t *testing.T) {
"want ready (gate must use the visible pane, not scrollback)")
}
}

// Bob-Shell 2.x keeps the "❯" input box painted while a response streams and
// signals busy only with "⠇ Processing… (Enter to steer, Tab to queue)". The
// busy pane must read as working (delivery gate) and NOT as a finished turn
// (turn-end classification / kick log archive); the idle pane must do the
// opposite. Captures are from the live hive in #15864.
func TestPaneShowsAgentWorking_BobProcessing(t *testing.T) {
busyBob := `• All referenced issues are still open. Now let me look at the current state of the code.
Execute Command (completed)
Command: ls /tmp/hive/ 2>/dev/null || echo "no hive dir"
bin
⠇ Processing… (Enter to steer, Tab to queue)
───────────────────────────────────────────────────────────────────────
❯ Build Anything, @ for context, / for commands, $ for skills
───────────────────────────────────────────────────────────────────────
Agent Mode (auto-approve) · 22.6k / 270.0k (8%) · 0.380 🅞`
if !paneShowsAgentWorking(busyBob) {
t.Error("a bob pane showing Processing… (Enter to steer) must read as working (#15864)")
}
if paneShowsTurnEnded(busyBob) {
t.Error("a bob pane showing Processing… (Enter to steer) must not read as turn ended (#15864)")
}

idleBob := ` ### Key Recommendations This Cycle
1. PR #179 — Reviewer should clarify or dismiss the stale CHANGES_REQUESTED.
───────────────────────────────────────────────────────────────────────
❯ Build Anything, @ for context, / for commands, $ for skills
───────────────────────────────────────────────────────────────────────
Agent Mode (auto-approve) · 31.9k / 270.0k (12%) · 0.984 🅞`
if paneShowsAgentWorking(idleBob) {
t.Error("an idle bob pane must not read as working")
}
if !paneShowsTurnEnded(idleBob) {
t.Error("an idle bob pane must read as turn ended")
}
}
247 changes: 247 additions & 0 deletions src/crux/agent/manager_pane_blocking_prompts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
package agent

import "strings"

// blockingPrompt is a startup-blocking modal that must be answered with a
// SPECIFIC numbered option rather than a bare Enter or a generic
// navigate-away-from-"No" heuristic.
//
// The generic heuristic in dismissInferencePrompts steers away from options
// containing "no"/"exit" and otherwise confirms whatever is selected. That is
// wrong for menus whose DEFAULT selection is affirmative but harmful — most
// notably codex's update prompt, where the pre-selected option shells out to
// `npm install -g`. Answering those needs the exact key, so each entry names
// the one prompt it answers and nothing else is ever blind-fired at.
//
// This mirrors blockingPromptKey() in bin/contributor-relay.js, which solved
// the same problem contributor-side. The hub had no equivalent.
type blockingPrompt struct {
// backend this prompt belongs to. Prompts are matched only against the
// backend that actually renders them, so a codex pattern can never fire at
// a claude pane that happens to contain similar words.
backend string
// match reports whether this prompt is the one on screen. All conditions
// must hold, so a prompt is only answered when positively identified.
match func(pane string) bool
key string // the option to type before Enter
label string // for the audit log
}

const (
// claudeAutoModeNoticeMarker / claudeAutoModeNoticeFooter identify Claude
// Code's auto-mode classifier notice, verbatim from a live FMA pane
// (#9945): "We're changing auto mode to no longer charge for classifier
// requests in Claude Code. … Enter to continue · Esc to cancel". Both
// must be present so a kick that merely mentions auto mode cannot match.
claudeAutoModeNoticeMarker = "classifier requests in Claude Code"
claudeAutoModeNoticeFooter = "Enter to continue"
claudeAutoModeNoticeLabel = "claude auto-mode classifier notice"
// claudeAutoModeNoticeFooterLines is how many trailing non-blank lines
// the footer may sit in for the notice to count as live (the footer
// itself plus a possible status/spinner line under it).
claudeAutoModeNoticeFooterLines = 2
)

var blockingPrompts = []blockingPrompt{
{
backend: "claude",
// Claude Code: "Quick safety check: Is this a project you created or
// one you trust?" defaults to "No, exit". If it is not answered before
// the kick path runs, Claude exits and the prompt text lands in bash.
match: func(p string) bool {
return strings.Contains(p, "Is this a project you created or one you trust") &&
strings.Contains(p, "Yes, I trust this folder")
},
key: "Down",
label: "claude workspace trust",
},
{
backend: "claude",
// Claude Code's auto-mode classifier notice (#9945). It appears
// MID-RUN, at the first checked tool call, not at startup, so the
// 60s dismissInferencePrompts window never sees it; only this
// lifetime watcher can. Enter continues the held action and the
// notice never returns in that session; Esc cancels the turn. New
// inference sessions launch with CLAUDE_CODE_AUTO_MODE_SERVER=0 so
// the notice is not shown at all — this entry rescues panes that
// were already running when that landed, and any session whose
// settings re-enable the server check.
//
// The footer must be on the LAST non-blank lines: once Enter is
// pressed the CLI resumes and draws output below the notice, and the
// lingering text must not read as a live modal (it would hold the
// readiness gate and re-fire Enter every trustReanswerAfter).
match: func(p string) bool {
return strings.Contains(p, claudeAutoModeNoticeMarker) &&
strings.Contains(paneTail(p, claudeAutoModeNoticeFooterLines), claudeAutoModeNoticeFooter)
},
key: "",
label: claudeAutoModeNoticeLabel,
},
{
backend: "copilot",
// Copilot: "Confirm folder trust" → 1. Yes (THIS SESSION ONLY).
//
// Deliberately NOT "2. Yes, and remember": remembering makes the CLI
// rewrite the SHARED ~/.copilot/config.json from its own in-memory
// snapshot, which stomps every other agent's state in that file — traced
// live on hivecommons/hive (2026-08-22): each agent's "remember" wiped
// the others' trustedFolders entries, and one stale rewrite resurrected
// a dead token over the operator's fresh login, which is why re-logins
// never stuck. Session-only trust writes NOTHING; the watcher now runs
// for the agent's whole lifetime, so every (re)launch gets re-answered
// and persistence is unnecessary.
match: func(p string) bool {
return strings.Contains(p, "Confirm folder trust") || strings.Contains(p, "Do you trust the files")
},
key: "1",
label: "copilot folder trust",
},
{
backend: "agy",
// agy (Antigravity CLI): "Do you trust the contents of this project?"
// An arrow-key menu whose affirmative option is ALREADY selected, so a
// bare Enter is correct and there is no numbered option to type. It
// blocks startup exactly like the codex/copilot trust dialogs.
match: func(p string) bool {
return strings.Contains(p, "Do you trust the contents of this project")
},
key: "",
label: "agy project trust",
},
{
backend: "omp",
match: func(p string) bool {
lower := strings.ToLower(p)
return strings.Contains(lower, "welcome to omp") && strings.Contains(lower, "press enter to skip")
},
key: "Enter",
label: "omp onboarding",
},
{
backend: "codex",
// codex: older CLIs rendered "Do you trust the contents of this
// directory?"; 0.156.1 renders "Folder access" with an
// explicit "Trust this folder?" question and "Trust and continue"
// option. Both choose option 1 to continue.
match: func(p string) bool {
return strings.Contains(p, "Do you trust the contents of this directory") ||
(strings.Contains(p, "Trust this folder? Codex can read, edit, and run files here, subject to your permission settings") &&
strings.Contains(p, "Trust and continue"))
},
key: "1",
label: "codex directory trust",
},
{
backend: "codex",
// codex: "✨ Update available[!] x -> y" → 3. Skip until next version.
//
// Deliberately NOT "1. Update now", which is the PRE-SELECTED option:
// it runs `npm install -g @openai/codex` as the unprivileged agent UID,
// which fails with EACCES and takes the CLI down with it — on every
// launch, indefinitely, until a human intervenes. Even where it could
// succeed it is slow, needs network, can fail half-way, and drifts the
// CLI version out from under the image.
//
// "Skip until next version" is chosen over a plain "Skip" because it
// persists: a plain Skip re-prompts on the very next launch.
match: func(p string) bool {
return strings.Contains(p, "Update available") && strings.Contains(p, "Skip until next version")
},
key: "3",
label: codexUpdatePromptLabel,
},
{
backend: "codex",
// codex command approval prompt. The hub path now launches with
// --dangerously-bypass-approvals-and-sandbox, but this keeps already
// wedged panes visible and lets the watcher make the same unattended
// choice the launch posture declares.
match: func(p string) bool {
return strings.Contains(p, "Would you like to run the following command?") &&
strings.Contains(p, "Yes, proceed")
},
key: "1",
label: "codex command approval",
},
}

// blockingPromptTailLines bounds how much of the pane a prompt may be matched
// in. captureTmuxPaneForAgent returns SCROLLBACK, not just the visible screen,
// so matching the whole capture answers prompts that have long since scrolled
// away: after a codex CLI died, its update menu stayed in history and the
// watcher typed "3" into the bash shell that replaced it, once every poll,
// forever. A live modal is always at the bottom of the pane, so only the tail
// is eligible.
const blockingPromptTailLines = 25

// paneTail returns the last n non-blank lines of a captured pane.
func paneTail(pane string, n int) string {
lines := strings.Split(pane, "\n")
kept := make([]string, 0, n)
for i := len(lines) - 1; i >= 0 && len(kept) < n; i-- {
if strings.TrimSpace(lines[i]) == "" {
continue
}
kept = append(kept, lines[i])
}
for i, j := 0, len(kept)-1; i < j; i, j = i+1, j-1 {
kept[i], kept[j] = kept[j], kept[i]
}
return strings.Join(kept, "\n")
}

// blockingPromptKey returns the keystroke that dismisses whatever known
// startup-blocking modal this backend currently has on screen, and whether one
// was recognised. Only the tail of the pane is considered — see
// blockingPromptTailLines.
func blockingPromptKey(backend, pane string) (key, label string, ok bool) {
tail := paneTail(pane, blockingPromptTailLines)
for _, p := range blockingPrompts {
if p.backend == backend && p.match(tail) {
return p.key, p.label, true
}
}
return "", "", false
}

// PaneShowsBlockingPrompt reports whether the pane is currently sitting on a
// known startup-blocking modal (folder trust, codex update, …) for the given
// backend. The login-detector uses it to stand down: a trust-wedged pane is
// NOT a login problem, and pausing the agent for it kills the very watcher
// that would answer the prompt — the deadlock that kept hivecommons/hive's
// copilot agents "sitting at login prompt" through every re-login (2026-08-22).
func PaneShowsBlockingPrompt(backend, pane string) bool {
_, _, ok := blockingPromptKey(backend, pane)
return ok
}

// paneHasBlockingPrompt reports whether ANY known blocking prompt is on the
// pane, regardless of backend. Used by the readiness gate, which does not know
// the backend; the patterns are specific enough that a false positive only
// delays readiness rather than mis-firing a keystroke.
func paneHasBlockingPrompt(pane string) bool {
tail := paneTail(pane, blockingPromptTailLines)
for _, p := range blockingPrompts {
if p.match(tail) {
return true
}
}
return false
}

// backendHasBlockingPrompts reports whether any known startup-blocking prompt
// belongs to this backend, and so whether the watcher is worth running for it.
//
// Derived from the table rather than hardcoded: the watcher used to be gated on
// `backend == "copilot"`, which is why codex agents were never rescued from
// their update menu even after the menu itself was understood. Adding a prompt
// for a new backend now enables the watcher for it automatically.
func backendHasBlockingPrompts(backend string) bool {
for _, p := range blockingPrompts {
if p.backend == backend {
return true
}
}
return false
}
Loading
Loading