Skip to content

Add expand/collapse toggle for input/output messages in span overview#1070

Open
chamals3n4 wants to merge 5 commits into
wso2:mainfrom
chamals3n4:fix/678-span-collapse
Open

Add expand/collapse toggle for input/output messages in span overview#1070
chamals3n4 wants to merge 5 commits into
wso2:mainfrom
chamals3n4:fix/678-span-collapse

Conversation

@chamals3n4

@chamals3n4 chamals3n4 commented Jun 15, 2026

Copy link
Copy Markdown

Purpose

resolves #678

Goals

Add expand/collapse toggle for input and output messages in the span overview section to reduce UI clutter when spans contain large payloads.

Approach

add a useState(false) hook to the MessageList component to track the expanded/collapsed state. wrapped the messages list in MUI Collapse component, and replaced the static section header with a clickable Box that toggles the state on click. and add ChevronDown/ChevronUp icons from oxygen ui icons to visually indicate the current state. by default bothi input and output messages sections are collapsed .

Screencast.from.2026-06-15.14-02-29.webm

User stories

Summary of user stories addressed by this change>

Release note

Brief description of the new feature or bug fix as it will appear in the release notes

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter �N/A� plus brief explanation of why there�s no doc impact

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

Type �Sent� when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type �N/A� and explain why.

Marketing

Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

Summary by CodeRabbit

  • New Features
    • Made the span details “messages” section collapsible, with clickable headers and expand/collapse toggle icons to improve readability and page organization.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 787f0dd8-8520-42e4-bf8a-43331c8316d5

📥 Commits

Reviewing files that changed from the base of the PR and between 589d871 and 9374c92.

📒 Files selected for processing (1)
  • console/workspaces/pages/traces/src/subComponents/spanDetails/Overview.tsx

📝 Walkthrough

Walkthrough

MessageList in Overview.tsx gains an isExpanded state initialized from a new optional defaultExpanded prop. The always-visible title/list layout is replaced with a clickable header containing chevron icons and an IconButton that toggles isExpanded, wrapping all message cards in a Collapse component. Imports, the type contract, and useMemo dependencies are updated accordingly.

Changes

Collapsible MessageList in span details Overview

Layer / File(s) Summary
Contract and state initialization
console/workspaces/pages/traces/src/subComponents/spanDetails/Overview.tsx
MessageListProps extends with an optional defaultExpanded prop; imports add Collapse, IconButton, chevron icons, and useState; isExpanded state is initialized from defaultExpanded.
Collapsible header and message card rendering
console/workspaces/pages/traces/src/subComponents/spanDetails/Overview.tsx
The always-visible title/list layout is replaced with a clickable header that toggles isExpanded and displays chevron icons; message cards (role chip, JSONView, MarkdownView, tool-call) render inside a Collapse component controlled by isExpanded; defaultExpanded is wired into the Input Messages instance; useMemo dependency arrays for inputMessages and outputMessages are reformatted.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hop, hop, the messages fold away,
A chevron click hides the long display.
No more clutter when payloads are wide,
Just tap the header to peek inside!
Collapsible neatness — the rabbit's delight. ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers Purpose, Goals, and Approach sections with concrete implementation details and a screencast. However, most template sections (User stories, Release note, Documentation, Training, Certification, Marketing, Automation tests, Security checks, Samples, Related PRs, Migrations, Test environment, Learning) are left incomplete with placeholder text. Complete the missing sections including User stories, Release note, Documentation, Security checks, Automation tests, and Test environment details to fully satisfy the template requirements.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding expand/collapse toggles for input/output messages in span overview, which matches the primary objective of the PR.
Linked Issues check ✅ Passed The PR implementation addresses issue #678 by adding expand/collapse toggles for input and output messages using useState, Collapse component, and chevron icons, with input messages defaulting to expanded and output to collapsed.
Out of Scope Changes check ✅ Passed All changes in Overview.tsx are scoped to the expand/collapse feature for the MessageList component, including state management, UI updates, and icon integration. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
console/workspaces/pages/traces/src/subComponents/spanDetails/Overview.tsx (2)

138-156: ⚡ Quick win

Use a semantic control for the section toggle header.

The toggle is bound to a clickable Box, which is not announced as an interactive control. Prefer rendering the header as a semantic button (or move toggle handling onto a dedicated button with aria-expanded/aria-controls) so assistive tech gets correct state and intent.

Suggested patch
-      <Box
+      <Box
+        component="button"
+        type="button"
         sx={{
           display: "flex",
           alignItems: "center",
           justifyContent: "space-between",
           mb: isExpanded ? 2 : 0,
-          cursor: "pointer",
-          userSelect: "none",
+          width: "100%",
+          border: 0,
+          p: 0,
+          m: 0,
+          backgroundColor: "transparent",
+          textAlign: "left",
+          cursor: "pointer",
+          userSelect: "none",
         }}
+        aria-expanded={isExpanded}
+        aria-controls={`${testId ?? title}-content`}
         onClick={() => setIsExpanded((prev) => !prev)}
       >
         <Typography variant="h6">{title}</Typography>
         <IconButton
           size="small"
           aria-label={isExpanded ? "Collapse" : "Expand"}
         >
           {isExpanded ? <ChevronUp /> : <ChevronDown />}
         </IconButton>
       </Box>
-      <Collapse in={isExpanded}>
+      <Collapse in={isExpanded} id={`${testId ?? title}-content`}>
🤖 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 `@console/workspaces/pages/traces/src/subComponents/spanDetails/Overview.tsx`
around lines 138 - 156, The section header toggle is currently implemented with
a non-semantic Box element that has onClick and click-related styling, which
assistive technologies cannot properly announce as an interactive control.
Replace the Box click handler approach by making the IconButton component the
primary toggle control: move the onClick handler from the Box to the IconButton,
add aria-expanded attribute set to the isExpanded state value, and optionally
add aria-controls pointing to the collapsible content if it has an id. This
ensures screen readers announce it as a toggle button with the correct
expanded/collapsed state. Remove the pointer cursor and click-related styling
from the Box since the IconButton will be the semantic control.

157-229: ⚡ Quick win

Consider unmounting collapsed message content to reduce hidden render cost.

Given this section can contain large payloads, keeping collapsed children mounted can still carry rendering/DOM overhead. unmountOnExit is a low-cost improvement here.

Suggested patch
-      <Collapse in={isExpanded}>
+      <Collapse in={isExpanded} unmountOnExit>
🤖 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 `@console/workspaces/pages/traces/src/subComponents/spanDetails/Overview.tsx`
around lines 157 - 229, The Collapse component wrapping the Stack with the
messages.map() call keeps its children mounted even when collapsed, which causes
unnecessary rendering overhead for potentially large payloads. Add the
unmountOnExit prop to the Collapse component to ensure the collapsed content is
removed from the DOM rather than just hidden, reducing rendering cost.
🤖 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.

Nitpick comments:
In `@console/workspaces/pages/traces/src/subComponents/spanDetails/Overview.tsx`:
- Around line 138-156: The section header toggle is currently implemented with a
non-semantic Box element that has onClick and click-related styling, which
assistive technologies cannot properly announce as an interactive control.
Replace the Box click handler approach by making the IconButton component the
primary toggle control: move the onClick handler from the Box to the IconButton,
add aria-expanded attribute set to the isExpanded state value, and optionally
add aria-controls pointing to the collapsible content if it has an id. This
ensures screen readers announce it as a toggle button with the correct
expanded/collapsed state. Remove the pointer cursor and click-related styling
from the Box since the IconButton will be the semantic control.
- Around line 157-229: The Collapse component wrapping the Stack with the
messages.map() call keeps its children mounted even when collapsed, which causes
unnecessary rendering overhead for potentially large payloads. Add the
unmountOnExit prop to the Collapse component to ensure the collapsed content is
removed from the DOM rather than just hidden, reducing rendering cost.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2d1a78d1-ee24-4d1c-81b1-0f226a4040d1

📥 Commits

Reviewing files that changed from the base of the PR and between 3d0897e and 589d871.

📒 Files selected for processing (1)
  • console/workspaces/pages/traces/src/subComponents/spanDetails/Overview.tsx

@chamals3n4

Copy link
Copy Markdown
Author

UPDATE : make input messages expand by default, feel better UX than having both collapsed

@chamals3n4

Copy link
Copy Markdown
Author

hi @RAVEENSR , can you check this PR please?

@rasika2012

Copy link
Copy Markdown
Contributor

Hi @chamals3n4 , can you use the Oxygen UI Accordion component for this implimentation? Here is the doc link: https://wso2.github.io/oxygen-ui/?path=/docs/surfaces-accordion--docs

@chamals3n4 chamals3n4 force-pushed the fix/678-span-collapse branch from 9374c92 to 64ce77a Compare June 18, 2026 10:25
@chamals3n4

Copy link
Copy Markdown
Author

hi @rasika2012 , i updated it to use the oxygen ui accordion

Screencast.from.2026-06-18.15-51-34.webm

Comment thread console/workspaces/pages/traces/src/subComponents/spanDetails/Overview.tsx Outdated
Comment thread console/workspaces/pages/traces/src/subComponents/spanDetails/Overview.tsx Outdated
chamals3n4 and others added 2 commits June 22, 2026 12:12
Co-authored-by: Rasika Maduranga <rasikat77@gmail.com>
…Overview.tsx

Co-authored-by: Rasika Maduranga <rasikat77@gmail.com>
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.

Add toggle (expand/collapse) for input/output messages in span overview for all spans

2 participants