Skip to content

fix(muse): align background roster task IDs with subagent turn items #23844

Closed

Description

@coderabbitai

Summary

Align the Muse provider-thread background roster task ID with the native ID used by the corresponding subagent turn item.

Requested by @koushikxd as a follow-up to PR #23828.

Problem

In packages/provider-muse/src/server/adapter.ts, syncBackground lists a running child on the provider-thread roster under itemId. The corresponding turn item's nativeItemRef uses childSessionId ?? subagentId ?? itemId.

When these IDs differ:

  • The web banner cannot filter out a follow-up turn's own children by matching their turn-item IDs.
  • derivePendingBackgroundWork cannot deduplicate the roster entry against the corresponding turn item.

This can display the same running child in both the timeline and the background-work banner.

Required changes

  • Inspect Muse roster creation, stop handling, and roster cleanup paths that match on taskId.
  • Use the same native ID selection for the roster entry and its corresponding turn item, likely childSessionId ?? subagentId ?? itemId.
  • Update dependent stop and cleanup matching as needed so that child completion, failure, or cancellation removes the correct roster entry.
  • Add regression coverage for differing itemId, childSessionId, and subagentId values, including fallback behavior.

Affected areas

  • packages/provider-muse/src/server/adapter.ts: syncBackground, turn-item native references, and related stop/cleanup handling.
  • packages/shared/src/orchestrationV2PendingBackgroundWork.ts: identity-based deduplication behavior.
  • apps/web/src/components/ChatView.logic.ts: active-turn roster filtering.
  • Relevant Muse adapter and background-work derivation tests.

Acceptance criteria

  • A Muse child uses the same identity in the provider-thread roster and its corresponding turn item's native reference.
  • A child started by an active follow-up turn remains in the timeline and does not also appear in the background-work banner.
  • An earlier turn's pending child remains visible in the banner while the follow-up turn runs.
  • Shared background-work derivation does not return duplicate entries for the same child.
  • Stop and roster cleanup continue to target the correct child when native IDs differ from itemId.
  • Tests cover native-ID precedence and the itemId fallback.

Out of scope

The Claude background-command case is excluded. Its tool item completes when the command is backgrounded, so the banner entry is not a duplicate of a running tool item.

References

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions