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.
This commit is contained in:
@@ -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<string, Capabil
|
||||
* F11: steps that are split by a non-step block (e.g. the auto-recall tool_use
|
||||
* between the "Recalling…" and "Recalled N…" steps) must still yield exactly
|
||||
* ONE card per turn — see the single-group anchoring in BlockRenderer below.
|
||||
* The headline names only what the turn really touched (UF-050).
|
||||
*/
|
||||
function renderStepGroup(steps: StepContentBlock[], key: string, isStreaming: boolean): ReactNode {
|
||||
function renderStepGroup(
|
||||
steps: StepContentBlock[],
|
||||
tools: ToolUseContentBlock[],
|
||||
key: string,
|
||||
isStreaming: boolean,
|
||||
): ReactNode {
|
||||
const anyRunning = steps.some(s => 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 (
|
||||
<ActivityStream
|
||||
key={key}
|
||||
summary={anyRunning ? 'Working across your memory, web & files' : 'Worked across your memory, web & files'}
|
||||
summary={activitySummary(steps, tools, anyRunning)}
|
||||
steps={activitySteps}
|
||||
defaultOpen={isStreaming || anyRunning}
|
||||
className="my-1.5"
|
||||
@@ -107,12 +114,13 @@ const BlockRenderer = ({
|
||||
// blocks (tool rows, artifacts, text, model_switch, error) keep their order,
|
||||
// so a tool_use between two steps no longer splits the run into two cards.
|
||||
const allSteps = blocks.filter((b): b is StepContentBlock => 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);
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import type { StepContentBlock, ToolUseContentBlock } from '@/lib/types';
|
||||
|
||||
type Area = 'memory' | 'web' | 'files';
|
||||
|
||||
const AREA_LABEL: Record<Area, string> = {
|
||||
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<Area>();
|
||||
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]))}`;
|
||||
}
|
||||
@@ -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(<BlockRenderer blocks={blocks} />);
|
||||
expect(screen.getByText(/^Done/)).toBeInTheDocument();
|
||||
expect(screen.queryByText(/memory|web|files/)).not.toBeInTheDocument();
|
||||
unmount();
|
||||
|
||||
render(
|
||||
<BlockRenderer
|
||||
blocks={[
|
||||
{ type: 'step', blockId: 's2', description: 'Looking things up', status: 'running' },
|
||||
{ type: 'tool_use', id: 't1', name: 'web_search', status: 'done', input: {} },
|
||||
{ type: 'tool_use', id: 't2', name: 'read_file', status: 'running', input: {} },
|
||||
]}
|
||||
isStreaming
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText(/Working across the web & files/)).toBeInTheDocument();
|
||||
expect(screen.queryByText(/your memory/)).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user