Skip to content

refactor(chat): share activity group projection - #776

Closed
beruro wants to merge 1 commit into
developfrom
junyu/unify-render-projection
Closed

refactor(chat): share activity group projection#776
beruro wants to merge 1 commit into
developfrom
junyu/unify-render-projection

Conversation

@beruro

@beruro beruro commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

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 activityGroupProjection owner 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

  • Covered presentation ownership, event-state projection, registry dependency direction, usage metadata compatibility, component-specific domain boundaries, and tests.
  • Intentionally skipped wire schema, persistence, FSM, initialization, and backend layers because they are unchanged.
  • Frontend UI audit: 1 abstract, 3 keep-with-reason, 0 fixes, 0 sweep candidates. Report: docs/frontend-ui-audit-2026-08-11/ActivityGroups.md.
  • Existing StackedBlock, tool icon, diff token, usage badge, collapse, and accessibility contracts are retained.
  • Effects: none added or modified.
  • Performance verdict: neutral; the same per-render projection and aggregation work runs with no new subscription, cache, timer, or background task.

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.
  • The repository snapshot does not provide verify:quick or verify:final, so focused tests/lint plus the full typecheck entry point were used.
  • No screenshots: this is a render-output-preserving refactor with no visual change.

@beruro

beruro commented Aug 11, 2026

Copy link
Copy Markdown
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.

@beruro beruro closed this Aug 11, 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