From 06d267dec8a5b4645675907cb0783e11cf6dd7e5 Mon Sep 17 00:00:00 2001 From: "shumeiko.it" Date: Tue, 27 Oct 2026 12:54:45 +0100 Subject: [PATCH] fix(web): name only what a chat turn touched in the activity card (UF-050) The card headline was a fixed "Worked across your memory, web & files". It is now built from the turn: memory, web and file tools it called and the memory steps the server reported, or a plain Working / Done. --- .../os/apps/chat-blocks/BlockRenderer.tsx | 16 ++++-- .../os/apps/chat-blocks/activity-summary.ts | 56 +++++++++++++++++++ apps/web/src/test/chat-work-canvas.test.tsx | 23 ++++++++ docs/oss/upstream-fixes.md | 10 ++++ 4 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 apps/web/src/components/os/apps/chat-blocks/activity-summary.ts diff --git a/apps/web/src/components/os/apps/chat-blocks/BlockRenderer.tsx b/apps/web/src/components/os/apps/chat-blocks/BlockRenderer.tsx index 2b8cf94..66f5e95 100644 --- a/apps/web/src/components/os/apps/chat-blocks/BlockRenderer.tsx +++ b/apps/web/src/components/os/apps/chat-blocks/BlockRenderer.tsx @@ -1,5 +1,5 @@ import type { ReactNode } from 'react'; -import type { ContentBlock, StepContentBlock } from '@/lib/types'; +import type { ContentBlock, StepContentBlock, ToolUseContentBlock } from '@/lib/types'; import TextBlock from './TextBlock'; import ToolUseBlock from './ToolUseBlock'; import ModelSwitchBlock from './ModelSwitchBlock'; @@ -11,6 +11,7 @@ import { segmentText } from './capability-request-parser'; import type { RouteProposalConfirmResponse } from '@/lib/route-proposals'; import { ActivityStream, type ActivityStep } from '../../warm'; import { frameSourceLabel } from '@/lib/frame-source'; +import { activitySummary } from './activity-summary'; interface BlockRendererProps { blocks: ContentBlock[]; @@ -66,8 +67,14 @@ function trustedCapabilityProposals(blocks: ContentBlock[]): Map s.status === 'running'); const activitySteps: ActivityStep[] = steps.map(s => { const sourceLabels = (s.provenance?.sources ?? []) @@ -89,7 +96,7 @@ function renderStepGroup(steps: StepContentBlock[], key: string, isStreaming: bo return ( b.type === 'step'); + const allTools = blocks.filter((b): b is ToolUseContentBlock => b.type === 'tool_use'); const firstStepIdx = blocks.findIndex(b => b.type === 'step'); const capabilityProposals = trustedCapabilityProposals(blocks); blocks.forEach((block, i) => { if (block.type === 'step') { - if (i === firstStepIdx) out.push(renderStepGroup(allSteps, 'activity', !!isStreaming)); + if (i === firstStepIdx) out.push(renderStepGroup(allSteps, allTools, 'activity', !!isStreaming)); return; } const key = getBlockKey(block, i); diff --git a/apps/web/src/components/os/apps/chat-blocks/activity-summary.ts b/apps/web/src/components/os/apps/chat-blocks/activity-summary.ts new file mode 100644 index 0000000..295086f --- /dev/null +++ b/apps/web/src/components/os/apps/chat-blocks/activity-summary.ts @@ -0,0 +1,56 @@ +import type { StepContentBlock, ToolUseContentBlock } from '@/lib/types'; + +type Area = 'memory' | 'web' | 'files'; + +const AREA_LABEL: Record = { + memory: 'your memory', + web: 'the web', + files: 'files', +}; + +const MEMORY_TOOLS = new Set(['auto_recall', 'search_memory', 'save_memory', 'recall_memory', 'memory']); +const WEB_TOOLS = new Set(['web_search', 'web_fetch', 'brave_search', 'tavily_search', 'perplexity_search', 'research']); +const FILE_TOOLS = new Set([ + 'read_file', 'write_file', 'edit_file', 'multi_edit', 'get_file', 'get_file_metadata', 'list_files', + 'list_workspace_files', 'search_files', 'download_file', 'upload_file', 'read_other_workspace_file', + 'list_folder', 'create_folder', 'generate_docx', 'generate_pdf', 'generate_pptx', 'generate_xlsx', +]); + +// Server steps that report memory work: "Recalling relevant memories...", +// "Recalled 2 relevant memories.", "Auto-saved 3 memories…", "Session summary saved to memory". +const MEMORY_STEP = /\b(recall\w*|saved)\b.*\bmemor(y|ies)\b/i; + +function toolArea(name: string): Area | null { + if (MEMORY_TOOLS.has(name)) return 'memory'; + if (WEB_TOOLS.has(name) || name.startsWith('browser_')) return 'web'; + if (FILE_TOOLS.has(name)) return 'files'; + return null; +} + +function joinAreas(labels: string[]): string { + if (labels.length <= 1) return labels.join(''); + return `${labels.slice(0, -1).join(', ')} & ${labels[labels.length - 1]}`; +} + +/** + * The Activity card's headline, built from what the turn actually touched: + * the memory, web and file tools it called and the memory steps the server + * reported. A turn that touched none of them gets a plain "Working" / "Done". + */ +export function activitySummary( + steps: StepContentBlock[], + tools: ToolUseContentBlock[], + running: boolean, +): string { + const areas = new Set(); + for (const step of steps) { + if (step.provenance || MEMORY_STEP.test(step.description)) areas.add('memory'); + } + for (const tool of tools) { + const area = toolArea(tool.name); + if (area) areas.add(area); + } + const ordered = (['memory', 'web', 'files'] as const).filter((a) => areas.has(a)); + if (ordered.length === 0) return running ? 'Working' : 'Done'; + return `${running ? 'Working' : 'Worked'} across ${joinAreas(ordered.map((a) => AREA_LABEL[a]))}`; +} diff --git a/apps/web/src/test/chat-work-canvas.test.tsx b/apps/web/src/test/chat-work-canvas.test.tsx index 397ff99..58cb38f 100644 --- a/apps/web/src/test/chat-work-canvas.test.tsx +++ b/apps/web/src/test/chat-work-canvas.test.tsx @@ -86,4 +86,27 @@ describe('BlockRenderer — activity grouping', () => { expect(screen.getByText('Recalled 2 relevant memories')).toBeInTheDocument(); expect(screen.getByText('Searched 3 sites')).toBeInTheDocument(); }); + + it('UF-050: names only what the turn touched', () => { + const blocks: ContentBlock[] = [ + { type: 'step', blockId: 's1', description: 'Processing /plan via AI...', status: 'done' }, + ]; + const { unmount } = render(); + expect(screen.getByText(/^Done/)).toBeInTheDocument(); + expect(screen.queryByText(/memory|web|files/)).not.toBeInTheDocument(); + unmount(); + + render( + , + ); + expect(screen.getByText(/Working across the web & files/)).toBeInTheDocument(); + expect(screen.queryByText(/your memory/)).not.toBeInTheDocument(); + }); }); diff --git a/docs/oss/upstream-fixes.md b/docs/oss/upstream-fixes.md index 24c7343..c9a9756 100644 --- a/docs/oss/upstream-fixes.md +++ b/docs/oss/upstream-fixes.md @@ -78,6 +78,7 @@ Baseline: commit `b20b138` of `git.os-dev.tech/oleg.m/waggle-os`. | UF-047 | The command palette's search text touches its focus outline | Fixed | Web UI | | UF-048 | The sidebar account row sits off-center at the bottom | Fixed | Web UI | | UF-049 | The workspace title stretches when switching tabs | Fixed | Web UI | +| UF-050 | The chat activity card always claims memory, web and files | Fixed | Web UI, chat | ## Entries @@ -495,3 +496,12 @@ Entries UF-010 to UF-019 come from the UI audit `anti-slop/audit-001-2026-10-14. - Cause: the title carries a framer-motion `layoutId` for the card-to-header hero morph, and a `layoutId` animates any change of the element's box. The title's width follows the header column, which is as wide as the subtitle row when the name is short; hiding that row on the Chat tab changes the width, and framer animates it with a horizontal scale, which distorts the text. - What we did: both titles (the header and its loading skeleton) use `layout="position"`, so only their position animates and the hero morph still moves the name into place. The hero-morph test checks the setting; in the browser no tab switch puts a transform on the title any more. - Recommendation: apply the same change in the main project, and use `layout="position"` for any text that carries a `layoutId`. + +### UF-050. The chat activity card always claims memory, web and files +- Status: Fixed +- Found: 2026-10-26 +- Where: at commit `b20b138`, `apps/web/src/components/os/apps/chat-blocks/BlockRenderer.tsx:92` +- Symptom: above every answer with steps, the activity card reads "Worked across your memory, web & files", even when the agent only recalled memory, or touched none of the three. +- Cause: the headline is a fixed string; only the step count beside it comes from the turn. +- What we did: the headline is built from the turn itself: memory when a memory tool ran or the server reported recall or saving, the web for search, fetch and browser tools, files for file tools. A turn that touched none of them reads "Working" or "Done". Tests cover a plain turn and a web-and-files turn. +- Recommendation: apply the same change in the main project.