refactor(desktop): share tool activity block updates#8470
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the desktop chat tool-activity rendering logic to reduce duplication and prevent status-handling drift between the main chat surface and task chat surface. It centralizes the “tool call content block update” behavior and reuses the same bridge-status mapping in both locations so terminal failures aren’t accidentally shown as successful completions.
Changes:
- Extracted shared tool-call content-block update logic into
ChatContentBlock.applyToolActivity. - Routed both
ChatProviderandTaskChatStatetool-activity updates through the shared helper. - Updated task chat to use
ChatProvider.mapBridgeToolStatussofailed/cancelled/interruptedaren’t flattened into.completed.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| desktop/macos/Desktop/Sources/Providers/ChatProvider.swift | Adds the shared ChatContentBlock.applyToolActivity helper and routes ChatProvider.addToolActivity through it. |
| desktop/macos/Desktop/Sources/ProactiveAssistants/Assistants/TaskAgent/TaskChatState.swift | Uses the shared bridge-status mapping and shared tool-activity block update helper to match main chat behavior. |
| desktop/macos/changelog/unreleased/dry-tool-activity.json | Adds a desktop changelog fragment documenting the refactor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Nice cleanup. Routing both chat surfaces through A couple of observations for when you mark this ready for review:
No formal approval since this is still a draft. Will review the final version. |
|
Added focused unit coverage for |
|
Nice cleanup — extracting the duplicated Worth flagging that this is more than a mechanical refactor — it corrects two latent behaviors along the way:
One gap before this is marked ready for review: the new shared helper ( Adding |
|
Thanks @eulicesl — Removing Still a draft, so no formal approval from me. Looks good to mark ready once a maintainer confirms. |
|
Nice cleanup. Extracting the duplicated tool-activity logic into One thing worth surfacing beyond the pure DRY win: This looks mergeable to me once you're ready to flip it out of draft. Is anything still pending, or was the draft marker just process/caution? |
|
No implementation work is still pending from my side. The draft marker is process/caution: this was created as a later cleanup PR, and the requested focused |
Summary
ChatContentBlock.applyToolActivity.ChatProvider) and task chat (TaskChatState) through the shared helper.ChatProvider.mapBridgeToolStatus, so failed/cancelled/interrupted statuses do not get flattened to completed.Why draft
This is follow-up cleanup from PR #7555. It is not urgent for the stall telemetry rollout, but it removes duplicated logic that had already started to drift.
Verification
xcrun swift test -c debug --package-path desktop/macos/Desktop --filter 'StallDetectorTests|ToolCallStatusTests'-> 23 tests, 0 failuresxcrun swift build -c debug --package-path desktop/macos/Desktop-> build completepython3 .github/scripts/check-desktop-changelog.py --base upstream/main --head HEAD-> Desktop changelog fragment foundgit diff --check-> clean