Skip to content

feat(core): auto-background slow shell commands via the job service - #60707

Open
kitlangton wants to merge 1 commit into
job-seam-3-tool-wrapperfrom
job-seam-4-shell-yield
Open

kitlangton wants to merge 1 commit into
job-seam-3-tool-wrapperfrom
job-seam-4-shell-yield

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Shell commands now yield to the background after 10 seconds with partial output, deleting ShellTool.notifyWhenDone.
Instead of blocking foreground turns for up to two minutes or losing completion notices on location reload, shell now blocks with yield_after (10 s default), returns captured output so far on yield, and lets Job deliver the final <shell> notice. Net production code shrinks by 24 lines.

💡 Why

  • Builds, dev servers, and slow CLI commands routinely stalled foreground turns unless the model remembered background: true.
  • ShellTool maintained its own Deferred + notifyWhenDone fiber duplicating Job notice delivery.

🆕 Now you can

  • Pass yield_after on shell (default 10 s, 0 for immediate background) and receive partial Shell.snapshot output when a command moves to the background.
  • Reload or close a project location while a background shell runs without losing its completion notice.
- ShellTool forks notifyWhenDone + Deferred<Output>; blocks indefinitely until exit or Ctrl+B
+ jobs.start({ sessionID, output: shell.snapshot, stop: shell.remove })
+ jobs.block({ yield_after: input.yield_after ?? 10_000 }) -> returns partial snapshot on yield

📊 Numbers

Metric Before After
packages/core/src/tool/plugin/shell.ts Duplicate notifyWhenDone + Deferred −24 net lines (+37 −61)
Slow foreground shell after reload ❌ Notice lost when plugin scope closes ✅ Delivered by Job with full output

New reload + auto-yield test in tool-auto-background.test.ts fails without this change; 8 pass across tool-auto-background.test.ts and tool-shell.test.ts -t background.

👀 Read: packages/core/src/tool/plugin/shell.ts around result.reason === "signal" || input.timeout === undefined: auto-yield clears the default 2-minute foreground timeout while keeping an explicit caller timeout armed. The rest is routine.

🔍 Split 4 of 6 from #60495 · shrinks production code by 24 lines

Checks run
  • bun run --cwd packages/core typecheck
  • bun --cwd packages/core test test/tool-auto-background.test.ts: 5 pass
  • bun --cwd packages/core test test/tool-shell.test.ts -t background: 4 pass

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant