Skip to content

Camand/tools display#605

Open
camilleAND wants to merge 1 commit into
mainfrom
camand/tools_display
Open

Camand/tools display#605
camilleAND wants to merge 1 commit into
mainfrom
camand/tools_display

Conversation

@camilleAND

@camilleAND camilleAND commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Purpose

Make tool calls in the chat clearer and less noisy: compact expandable cards with readable status, instead of a generic "Search..." / "Summarizing..." loader while tools run.

Proposal

  • Add ToolCard with collapsed header (tool name + status) and expandable input/output/error details
  • Add ToolInvocationTimeline to stack multiple tool calls with a visual connector
  • Centralize tool labels, status, and readable previews in toolCardUtils
  • Show the animated assistant Loader while a tool is running
  • Keep special cases for conversation_resume and document_parsing errors
  • Add unit tests for ToolCard, ToolInvocationTimeline, and toolCardUtils
Capture d’écran 2026-07-09 à 16 44 25

Show expandable tool cards with loader
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Tool invocation rendering now uses formatted, expandable cards arranged in timelines. Visibility and document-parsing handling are centralized, previews and statuses are generated by utilities, and the loader supports configurable sizing.

Changes

Tool invocation display

Layer / File(s) Summary
Tool card formatting
src/frontend/apps/conversations/src/features/chat/components/toolCardUtils.ts, src/frontend/apps/conversations/src/features/chat/components/__tests__/toolCardUtils.test.ts
Adds tool labels, lifecycle statuses, error handling, readable previews, document summaries, expanded output formatting, and utility coverage.
Expandable tool card UI
src/frontend/apps/conversations/src/features/chat/components/ToolCard.tsx, src/frontend/apps/conversations/src/features/chat/components/__tests__/ToolCard.test.tsx, src/frontend/apps/conversations/src/components/Loader.tsx, CHANGELOG.md
Adds expandable tool cards with status indicators, localized previews, loading states, tests, a configurable loader size, and a changelog entry.
Timeline and message integration
src/frontend/apps/conversations/src/features/chat/components/ToolInvocationItem.tsx, src/frontend/apps/conversations/src/features/chat/components/ToolInvocationTimeline.tsx, src/frontend/apps/conversations/src/features/chat/components/MessageItem.tsx, src/frontend/apps/conversations/src/features/chat/components/__tests__/ToolInvocationTimeline.test.tsx
Filters visible tool invocations, summarizes document-parsing arguments, and renders assistant tool calls through a vertical timeline with tests.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels: frontend

Sequence Diagram(s)

sequenceDiagram
  participant MessageItem
  participant ToolInvocationTimeline
  participant ToolInvocationItem
  participant ToolCard
  MessageItem->>MessageItem: Filter visible tool invocations
  MessageItem->>ToolInvocationTimeline: Render visible invocations
  ToolInvocationTimeline->>ToolInvocationItem: Render each timeline item
  ToolInvocationItem->>ToolCard: Pass summarized tool invocation
  ToolCard->>ToolCard: Compute status and readable previews
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is related to tool-call display changes, but the typo and phrasing make it unclear and not very descriptive. Rename it to something like "Improve tool-call display in chat" or "Add tool cards and timeline for chat tools".
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch camand/tools_display

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/frontend/apps/conversations/src/features/chat/components/__tests__/toolCardUtils.test.ts`:
- Around line 50-54: Update the translation mock in
src/frontend/apps/conversations/src/features/chat/components/__tests__/toolCardUtils.test.ts:50-54
to interpolate both count and query placeholders, producing “Query: climate
news”; update the t stub in
src/frontend/apps/conversations/src/features/chat/components/__tests__/ToolCard.test.tsx:6-8
to interpolate options.query, producing “Query: latest news”.

In
`@src/frontend/apps/conversations/src/features/chat/components/toolCardUtils.ts`:
- Around line 201-213: Update formatGenericOutputPreview and its callers,
including getToolExpandedOutputPreview, to accept and pass the existing
translation function t. Replace the hardcoded results/items preview labels with
localized translations, and update getToolErrorFromResult to use t for its
failure message while preserving the current preview and error behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c2906e83-ddb1-4f53-841f-c50ff61a504d

📥 Commits

Reviewing files that changed from the base of the PR and between e1ea8fb and 824e2c8.

📒 Files selected for processing (10)
  • CHANGELOG.md
  • src/frontend/apps/conversations/src/components/Loader.tsx
  • src/frontend/apps/conversations/src/features/chat/components/MessageItem.tsx
  • src/frontend/apps/conversations/src/features/chat/components/ToolCard.tsx
  • src/frontend/apps/conversations/src/features/chat/components/ToolInvocationItem.tsx
  • src/frontend/apps/conversations/src/features/chat/components/ToolInvocationTimeline.tsx
  • src/frontend/apps/conversations/src/features/chat/components/__tests__/ToolCard.test.tsx
  • src/frontend/apps/conversations/src/features/chat/components/__tests__/ToolInvocationTimeline.test.tsx
  • src/frontend/apps/conversations/src/features/chat/components/__tests__/toolCardUtils.test.ts
  • src/frontend/apps/conversations/src/features/chat/components/toolCardUtils.ts

Comment on lines +50 to +54
(key, options) =>
key.replace('{{count}}', String(options?.count ?? '')),
);

expect(content.inputPreview).toBe('Query: climate news');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant test files and implementation around the referenced lines.
for f in \
  src/frontend/apps/conversations/src/features/chat/components/__tests__/toolCardUtils.test.ts \
  src/frontend/apps/conversations/src/features/chat/components/__tests__/ToolCard.test.tsx \
  src/frontend/apps/conversations/src/features/chat/components/toolCardUtils.ts
do
  echo "===== $f ====="
  wc -l "$f"
  echo
done

echo "===== toolCardUtils.test.ts (lines 1-140) ====="
sed -n '1,140p' src/frontend/apps/conversations/src/features/chat/components/__tests__/toolCardUtils.test.ts

echo "===== ToolCard.test.tsx (lines 1-180) ====="
sed -n '1,180p' src/frontend/apps/conversations/src/features/chat/components/__tests__/ToolCard.test.tsx

echo "===== toolCardUtils.ts (lines 1-220) ====="
sed -n '1,220p' src/frontend/apps/conversations/src/features/chat/components/toolCardUtils.ts

Repository: suitenumerique/conversations

Length of output: 11982


🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '1,140p' src/frontend/apps/conversations/src/features/chat/components/__tests__/toolCardUtils.test.ts
sed -n '1,180p' src/frontend/apps/conversations/src/features/chat/components/__tests__/ToolCard.test.tsx
sed -n '1,220p' src/frontend/apps/conversations/src/features/chat/components/toolCardUtils.ts

Repository: suitenumerique/conversations

Length of output: 11277


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the rest of toolCardUtils.ts where getToolReadableContent is defined.
sed -n '220,360p' src/frontend/apps/conversations/src/features/chat/components/toolCardUtils.ts

# Also inspect ToolCard for how the input preview is rendered.
sed -n '1,260p' src/frontend/apps/conversations/src/features/chat/components/ToolCard.tsx

Repository: suitenumerique/conversations

Length of output: 8830


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '220,360p' src/frontend/apps/conversations/src/features/chat/components/toolCardUtils.ts
sed -n '1,260p' src/frontend/apps/conversations/src/features/chat/components/ToolCard.tsx

Repository: suitenumerique/conversations

Length of output: 8830


🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '220,360p' src/frontend/apps/conversations/src/features/chat/components/toolCardUtils.ts
sed -n '1,260p' src/frontend/apps/conversations/src/features/chat/components/ToolCard.tsx

Repository: suitenumerique/conversations

Length of output: 8830


Interpolate {{query}} in the translation mocks Both tests expect rendered query text, but the mocked t functions leave {{query}} untouched. Update the stubs so Query: {{query}} becomes Query: climate news / Query: latest news in these suites.

  • src/frontend/apps/conversations/src/features/chat/components/__tests__/toolCardUtils.test.ts: extend the mock to handle query as well as count.
  • src/frontend/apps/conversations/src/features/chat/components/__tests__/ToolCard.test.tsx: change t: (key: string) => key to interpolate options.query.
📍 Affects 2 files
  • src/frontend/apps/conversations/src/features/chat/components/__tests__/toolCardUtils.test.ts#L50-L54 (this comment)
  • src/frontend/apps/conversations/src/features/chat/components/__tests__/ToolCard.test.tsx#L6-L8
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/frontend/apps/conversations/src/features/chat/components/__tests__/toolCardUtils.test.ts`
around lines 50 - 54, Update the translation mock in
src/frontend/apps/conversations/src/features/chat/components/__tests__/toolCardUtils.test.ts:50-54
to interpolate both count and query placeholders, producing “Query: climate
news”; update the t stub in
src/frontend/apps/conversations/src/features/chat/components/__tests__/ToolCard.test.tsx:6-8
to interpolate options.query, producing “Query: latest news”.

Comment on lines +201 to +213
if (Array.isArray(output.results)) {
return truncateText(
`${output.results.length} results`,
maxLength,
);
}

const keys = Object.keys(output);
if (keys.length === 0) {
return undefined;
}

return truncateText(`${keys.length} items`, maxLength);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Hardcoded English in generic previews bypasses i18n.

formatGenericOutputPreview renders "${n} results" and "${n} items" as literals (and getToolErrorFromResult at Line 82 returns literal 'Tool execution failed'), while the rest of the module localizes via t. Non-English users will see these untranslated. Thread t into this helper and wrap the strings, mirroring formatWebSearchOutputPreview.

🌐 Suggested direction
-const formatGenericOutputPreview = (
-  output: unknown,
-  maxLength: number,
-): string | undefined => {
+const formatGenericOutputPreview = (
+  output: unknown,
+  t: (key: string, options?: Record<string, unknown>) => string,
+  maxLength: number,
+): string | undefined => {
@@
-  if (Array.isArray(output.results)) {
-    return truncateText(
-      `${output.results.length} results`,
-      maxLength,
-    );
-  }
+  if (Array.isArray(output.results)) {
+    return truncateText(
+      t('{{count}} results', { count: output.results.length }),
+      maxLength,
+    );
+  }
@@
-  return truncateText(`${keys.length} items`, maxLength);
+  return truncateText(t('{{count}} items', { count: keys.length }), maxLength);

Callers at Lines 283/290 (and the getToolExpandedOutputPreview path) will need to pass t.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/frontend/apps/conversations/src/features/chat/components/toolCardUtils.ts`
around lines 201 - 213, Update formatGenericOutputPreview and its callers,
including getToolExpandedOutputPreview, to accept and pass the existing
translation function t. Replace the hardcoded results/items preview labels with
localized translations, and update getToolErrorFromResult to use t for its
failure message while preserving the current preview and error behavior.

@camilleAND camilleAND mentioned this pull request Jul 23, 2026
6 tasks
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