refactor(chat): share activity group projection - #776
Closed
beruro wants to merge 1 commit into
Closed
Conversation
Collaborator
Author
|
Superseded by #780, which preserves this change as an independent commit and has passed the consolidated CI suite. The source branch is retained for recovery. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Edit and terminal activity groups duplicated the same presentation pipeline: event/tail projection, suppression of stale running state on non-tail events, lazy registry rendering, and tool-usage aggregation. The copies had already diverged slightly in rendering shape and could drift in loading or usage-badge behavior.
Solution
Add one
activityGroupProjectionowner and route both groups through it. Domain-specific behavior remains local: edit/read counts and diff stats stay with the edit group, while terminal/MCP/wait summaries and durable Work Item cards stay with the terminal group. Focused tests pin event-tail projection, intermediate running-state normalization, direct/serialized usage aggregation, and the no-usage case.Potential risks
Both components now depend on the same lazy event renderer, so a regression there would affect both group types. The implementation is a direct extraction of their equivalent code, existing edit and terminal rendering tests pass, and the new pure projection tests cover the shared branches. No prop, state, persistence, or visual contract changed. Rollback is a single-commit revert.
Architecture and UI audit
docs/frontend-ui-audit-2026-08-11/ActivityGroups.md.StackedBlock, tool icon, diff token, usage badge, collapse, and accessibility contracts are retained.Verification
pnpm exec vitest run src/engines/ChatPanel/ChatItems/activityGroupProjection.test.ts src/engines/ChatPanel/ChatItems/EditActivityGroup/__tests__/EditActivityGroup.test.ts src/engines/ChatPanel/ChatItems/TerminalActivityGroup/TerminalActivityGroup.test.ts— 3 files, 12 tests passed.pnpm exec eslint src/engines/ChatPanel/ChatItems/activityGroupProjection.tsx src/engines/ChatPanel/ChatItems/activityGroupProjection.test.ts src/engines/ChatPanel/ChatItems/EditActivityGroup/index.tsx src/engines/ChatPanel/ChatItems/TerminalActivityGroup/index.tsx— passed.pnpm exec prettier --check ...for the four source/test files and audit report — passed.pnpm typecheck— full TypeScript check executed and passed.git diff --check— passed.verify:quickorverify:final, so focused tests/lint plus the full typecheck entry point were used.