Skip to content

Improve display of agent/tool cards in chat session#1360

Open
dobesv wants to merge 1 commit intokagent-dev:mainfrom
dobesv:feat/tool-display-improvements
Open

Improve display of agent/tool cards in chat session#1360
dobesv wants to merge 1 commit intokagent-dev:mainfrom
dobesv:feat/tool-display-improvements

Conversation

@dobesv
Copy link
Contributor

@dobesv dobesv commented Feb 23, 2026

  • Parse JSON payloads and render basic tree view
  • Render strings as markdown
  • Copy to clipboard button copies original text
  • Add view source button in case of render/parse issues
  • Prevent ScrollArea from overflow horizontally
  • Prevent Tool Call ID from making cards too wide for the container

@dobesv dobesv requested a review from peterj as a code owner February 23, 2026 01:20
Copilot AI review requested due to automatic review settings February 23, 2026 01:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the display of agent and tool call cards in chat sessions by introducing smart content rendering with JSON parsing, markdown support, and better UI controls.

Changes:

  • Added SmartContent component that intelligently renders content as JSON tree view, markdown, or plain text
  • Added CollapsibleSection component to provide consistent expand/collapse behavior with preview
  • Modified ScrollArea to prevent horizontal overflow with CSS override
  • Added copy-to-clipboard functionality to chat messages and improved display of tool/agent call arguments and results

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
ui/src/components/chat/SmartContent.tsx New component for intelligent content rendering with JSON parsing, markdown support, type icons, and copy/view source controls
ui/src/components/chat/CollapsibleSection.tsx New reusable component for collapsible content sections with preview and scroll support
ui/src/components/ui/scroll-area.tsx Added CSS override to force block display on direct child divs to prevent horizontal overflow
ui/src/components/chat/ChatMessage.tsx Added copy-to-clipboard button for chat messages and refactored feedback button visibility
ui/src/components/chat/AgentCallDisplay.tsx Integrated SmartContent for rendering args/results, added clickable link for function calls, replaced custom collapse logic with CollapsibleSection
ui/src/components/ToolDisplay.tsx Integrated SmartContent for rendering args/results, removed custom copy button, replaced custom collapse logic with CollapsibleSection

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dobesv dobesv force-pushed the feat/tool-display-improvements branch from 93a368a to ea7f6f6 Compare March 8, 2026 08:10
@dobesv dobesv marked this pull request as draft March 8, 2026 08:10
@dobesv
Copy link
Contributor Author

dobesv commented Mar 9, 2026

@peterj @EItanya are you guys interested in having this change?

@dobesv dobesv force-pushed the feat/tool-display-improvements branch from 4a6c40e to 13cc185 Compare March 18, 2026 06:55
@dobesv dobesv marked this pull request as ready for review March 18, 2026 07:03
@dobesv
Copy link
Contributor Author

dobesv commented Mar 18, 2026

@peterj can you take a look at this one?

tokenStats?: TokenStats;
}

const AGENT_TOOL_NAME_RE = /^(.+)__NS__(.+)$/;
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a function to check if it's an agent tool in ui/src/lib/utils.ts isAgentToolName

<div className="font-light">{call.id}</div>
<div className="font-light">
{functionCallLink ? (
<Link href={functionCallLink} className="text-blue-500 hover:underline">
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the function call link page supposed to do? I don't think the route is present in the app it always redirects to 404

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah it might be something from another change that snuck in here

</div>
</div>
</div>
<button
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it would be nice if clicking on the text area just toggles the collapse state, since right now to close it I will need to click on the small button, and that's also not consistent with the expand behaviour where if you click on the text area it opens

Copy link
Contributor Author

@dobesv dobesv Mar 19, 2026

Choose a reason for hiding this comment

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

I wanted to be able to copy paste things from the content when expanded

@dobesv dobesv force-pushed the feat/tool-display-improvements branch from b7b6409 to 7aabf02 Compare March 19, 2026 18:05
- Parse JSON payloads and render basic tree view
- Render strings as markdown
- Copy to clipboard button copies original text
- Add view source button in case of render/parse issues
- Prevent ScrollArea from overflow horizontally

Signed-off-by: Dobes Vandermeer <dobes.vandermeer@newsela.com>
@dobesv dobesv force-pushed the feat/tool-display-improvements branch from 7aabf02 to 5b92d7f Compare March 19, 2026 18:09
@dobesv
Copy link
Contributor Author

dobesv commented Mar 19, 2026

I rebased this on main, hopefully it still works OK. I did a quick test and it looked OK.

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.

3 participants