Skip to content

feat(chat): bundle turn tool blocks behind collapse preference - #1001

Open
beruro wants to merge 4 commits into
developfrom
junyu/chat-collapse-tool-blocks
Open

feat(chat): bundle turn tool blocks behind collapse preference#1001
beruro wants to merge 4 commits into
developfrom
junyu/chat-collapse-tool-blocks

Conversation

@beruro

@beruro beruro commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Problem

Chat sessions with many tool/activity rows (thinking, explore, shell, image reads, etc.) become visually noisy. Users need a way to collapse that activity without hiding assistant messages or interactive cards such as ask_question.

Per-block collapse also left many separate header rows visible, which did not match the desired UX of grouping all tool activity in a turn into one collapsible stack.

Solution

Add a persisted session-menu toggle (Collapse tools / 折叠 Tool) backed by chatToolBlocksCollapsedAtom.

When enabled, the chat projection post-processes each turn group and merges consecutive bundlable tool/activity items into a single turnToolBundle row rendered by TurnToolBundleGroup. The bundle header shows the total item count on the left and a right-side type summary (for example 思考 · 探索 ×5 · 执行命令). Expanding the bundle renders the original nested rows unchanged.

Assistant prose, user messages, and interactive cards remain outside the bundle. Collapsed tool/thinking headers hide their detail summaries; the turn bundle keeps its item count visible and removes the nested stack height cap when expanded. Bundling logic and type classification live in pure helpers (turnToolBundle.ts) with Vitest coverage.

Integrated develop through 89bda2ea1 without rewriting the PR history. Collapse tools now lives inside the shared UI settings submenu alongside the existing display switches, and is wired through Chat Panel, WorkStation, and the detached session window. The bundle icon uses the repository's BotIcon instead of the removed lucide-react package.

Potential risks

  • Bundling runs after turn collapse projection, so flat-index-derived metadata (search highlights, copy targeting) may shift when the toggle is on; pagination counts per turn also shrink when multiple tool rows collapse into one bundle row.
  • Type summary labels are coarse-grained buckets and may not cover every rare tool canonical; unknown tools fall back to a generic Tool label.
  • The preference defaults to off, so turn-level bundling remains opt-in. It adds the boolean local preference orgii:chatToolBlocksCollapsed; no database or IPC migration is required. Roll back by disabling the toggle or reverting the feature; older versions ignore the new preference.
  • Live desktop rendering, theme/viewport coverage, and screenshots were not verified during conflict resolution; desktop control was not requested.

Verification

Post-integration checks:

  • pnpm run typecheck — passed on the final resolution. The first run found the removed lucide-react import; it was replaced with the repository icon before the successful rerun.
  • Normal commit hooks — lint-staged and hook TypeScript checks passed; no Rust files were staged.
  • pnpm exec vitest run src/engines/ChatPanel/components/SessionHeaderActionsMenu.test.ts src/engines/ChatPanel/ChatPanelHeader.test.ts src/engines/ChatPanel/ChatHistory/__tests__/turnToolBundle.test.ts — 44 tests passed across 3 files. Covers submenu placement, enabling/disabling tool collapse without closing the menu, existing header behavior, and bundle classification/grouping.
  • git diff --name-only --diff-filter=ACMR origin/develop -- '*.ts' '*.tsx' | xargs pnpm exec eslint --max-warnings 0 — passed for all 18 changed TypeScript files after replacing the stale icon import.
  • pnpm exec prettier --check src/engines/ChatPanel/components/SessionHeaderActionsMenu.tsx src/engines/ChatPanel/components/SessionHeaderActionsMenu.test.ts src/engines/ChatPanel/ChatPanelHeader.test.ts src/modules/SessionWindow/index.tsx and pnpm exec prettier --check src/engines/ChatPanel/ChatItems/TurnToolBundleGroup/index.tsx — passed.
  • git diff --check and git diff --cached --check — passed; final diff inspected for conflict markers, credentials, personal paths, debug logs, and unrelated changes.

Manual QA recommended (not run in this handoff):

  • Toggle UI settings → Collapse tools in Chat Panel, WorkStation, and detached session window menus
  • Confirm one collapsed Tool activity row per turn segment with right-side type summary
  • Expand bundle and verify nested tools render as before
  • Confirm assistant messages and ask_question cards stay outside the bundle

Live desktop QA and screenshots were not run because desktop control was not requested. The full application test suite was not run; checks were scoped to the affected menu, header, and tool-bundle behavior.

beruro added 2 commits August 26, 2026 21:31
Add a session-menu toggle that groups per-turn tool and activity rows into
one collapsible stack with a right-side type summary, keeping assistant
messages and interactive cards outside the bundle.

Pre-commit hook ran. Total eslint: 0, total circular: 0
Pre-commit hook ran. Total eslint: 0, total circular: 0
@beruro
beruro requested a review from Harry19081 August 26, 2026 13:58
@Harry19081 Harry19081 added enhancement New feature or request chat Chat, composer, markdown, canvas, browser, or terminal surfaces frontend-ui Frontend UI, design system, accessibility, layout, or theming UX Improvements to user experience, workflow smoothness labels Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chat Chat, composer, markdown, canvas, browser, or terminal surfaces enhancement New feature or request frontend-ui Frontend UI, design system, accessibility, layout, or theming UX Improvements to user experience, workflow smoothness

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants