Skip to content

feat(core): deliver background job notices from the job service - #60705

Open
kitlangton wants to merge 1 commit into
job-seam-1-notice-snapshotfrom
job-seam-2-job-notifier
Open

kitlangton wants to merge 1 commit into
job-seam-1-notice-snapshotfrom
job-seam-2-job-notifier

Conversation

@kitlangton

@kitlangton kitlangton commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Background job completion notices now deliver from the global job service instead of plugin-scoped fibers.
Previously each tool forked its own notifyWhenDone fiber inside a location-scoped plugin, so reloading or closing a location mid-run could orphan notice delivery. Centralizing delivery in Job keeps background runs alive until the notice reaches the session inbox.

💡 Why

🆕 Now you can

  • Pass sessionID, output (live partial output reader), stop, and { output, value } to Job.start, with Session registering a single global notifier via Job.registerNotifier.
  • Inspect live or settled jobs through Job.read and Job.list, and cancel silently with Job.cancel(id, { notify: false }).
- plugin scope forks notifyWhenDone -> jobs.wait -> sessions.synthetic -> completeBackground
+ Session registers notifier once on Job.Service
+ Job.settle / markBackground / cancel deliver notice in global scope -> completeBackground

📊 Numbers

Case Before After
Location reloads while job runs ❌ Plugin watcher scope closes ✅ Global Job scope delivers notice
Structured return value from Job.start ❌ Extra Deferred per caller ✅ Typed RunOutput<Value> on Info

Tests: 53 pass across job.test.ts and session-execution.test.ts.

👀 Read: packages/core/src/job.ts around deliverNotice and autoNotify: auto-delivery activates only when callers opt in with sessionID on Job.start, keeping existing callers (ShellTool, ImageGenerateTool) duplicate-free until their follow-up PRs drop notifyWhenDone. The rest is routine.

🔍 Split 2 of 6 from #60495 · stacked on #60704

Checks run
  • bun run --cwd packages/core typecheck
  • bun --cwd packages/core test test/job.test.ts test/session-execution.test.ts: 53 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