Skip to content

Add: activeRootRunId to useRun and useJobStream#830

Merged
FL4TLiN3 merged 2 commits intomainfrom
feat/active-root-run-id
Mar 26, 2026
Merged

Add: activeRootRunId to useRun and useJobStream#830
FL4TLiN3 merged 2 commits intomainfrom
feat/active-root-run-id

Conversation

@FL4TLiN3
Copy link
Contributor

Summary

  • Adds activeRootRunId state to useRun() hook, set from startRun events where delegatedBy is absent
  • Exposes activeRootRunId from useJobStream() for consumers (Studio)
  • Available immediately when SSE events arrive, before run tree API poll returns

Motivation

Studio's conversation view has a race condition: currentRunId depends on useRunTree API poll (~300ms), but SSE startRun provides the runId at ~10ms. activeRootRunId bridges this gap for streaming display (not checkpoint queries, which would 404 since the run isn't in DB yet when SSE fires).

Detection logic

After processRunEventToActivity processes a startRun event, inspect stateRef.current.runStates for the new run. If !runState.delegatedBy, it's a root run → set activeRootRunId. Same pattern as existing isComplete detection.

  • Delegated child runs: have delegatedBy → filtered out
  • Delegation returns: emit resumeFromStop (not startRun) → never reach this code
  • Continuation: new root startRun with status: "completed" → correctly updates

Test plan

  • Initial state is null
  • Root startRun → sets activeRootRunId
  • Delegated startRun → does NOT change activeRootRunId
  • Continuation startRun → updates to new runId
  • All 26 existing tests pass

🤖 Generated with Claude Code

FL4TLiN3 and others added 2 commits March 26, 2026 23:33
Captures the root run's runId from startRun events (where delegatedBy
is absent). Available immediately when SSE events arrive, before the
run tree API poll returns. Used by Studio to provide correct runId to
StreamingOverlay without waiting for API polling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@FL4TLiN3 FL4TLiN3 merged commit 87c6d68 into main Mar 26, 2026
11 checks passed
@FL4TLiN3 FL4TLiN3 deleted the feat/active-root-run-id branch March 26, 2026 23:50
@FL4TLiN3 FL4TLiN3 mentioned this pull request Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant