Skip to content

fix: Show full text on hover when text overflows the cards on the list page. - #16787

Merged
wangq8 merged 2 commits into
infiniflow:mainfrom
dcc123456:fix/show-full-text
Jul 10, 2026
Merged

wangq8 merged 2 commits into
infiniflow:mainfrom
dcc123456:fix/show-full-text

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

Summary

fix: Show full text on hover when text overflows the cards on the list page.

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 9, 2026
@dcc123456
dcc123456 requested a review from wangq8 July 9, 2026 11:34
@dcc123456 dcc123456 added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Jul 9, 2026
@dcc123456
dcc123456 marked this pull request as draft July 9, 2026 11:35
@dcc123456
dcc123456 marked this pull request as ready for review July 9, 2026 11:35
@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

A new TruncatedText component is added to home-card.tsx, which conditionally wraps content in a Tooltip based on measured scroll/client width truncation. HomeCard is updated to use this component for rendering the agent name and description instead of plain elements.

Changes

TruncatedText Component and HomeCard Integration

Layer / File(s) Summary
TruncatedText component definition
web/src/components/home-card.tsx
Adds tooltip-related imports and ElementType/useRef/useState from React, then defines TruncatedText which renders a Tag directly or wraps it in a Tooltip based on a ref-driven scrollWidth > clientWidth truncation check.
HomeCard integration
web/src/components/home-card.tsx
Replaces the agent name h3 and description div with TruncatedText, passing tooltip, truncation classes, and test ids (agent-name).

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant HomeCard
  participant TruncatedText
  participant Tooltip

  HomeCard->>TruncatedText: render with tooltip=data.name/data.description
  TruncatedText->>TruncatedText: measure scrollWidth vs clientWidth
  alt text truncated
    TruncatedText->>Tooltip: wrap content, set open state
    Tooltip-->>HomeCard: show tooltip on hover
  else not truncated
    TruncatedText-->>HomeCard: render Tag only
  end
Loading

Poem

A rabbit hops past text cut short,
"No tooltip needed?" gives no retort.
But when the words spill past their box,
A tiny tooltip pops like socks! 🧦
Hop hop, hooray for clarity's sport~

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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.
Title check ✅ Passed The title clearly summarizes the main change: showing full text on hover for overflowing card text.
Description check ✅ Passed The Summary section is present and on-topic, but it is very brief and lacks background context.

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.

@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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
web/src/components/home-card.tsx (1)

60-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the onOpenChange handler to comply with coding guidelines.

The inline arrow function in onOpenChange violates the project guideline: "Avoid inline event handlers in JSX; define handlers separately and pass references such as onClick={handleClick} instead of inline arrows." As per coding guidelines, inline event handlers in JSX should be avoided.

♻️ Proposed refactor
 function TruncatedText({
   as: Tag = 'div',
   className,
   children,
   tooltip,
   testId,
 }: {
   as?: ElementType;
   className?: string;
   children?: ReactNode;
   tooltip?: ReactNode;
   testId?: string;
 }) {
   const ref = useRef<HTMLElement>(null);
   const [open, setOpen] = useState(false);
+  const handleOpenChange = (next: boolean) => {
+    const el = ref.current;
+    setOpen(next && el !== null && el.scrollWidth > el.clientWidth);
+  };

   if (tooltip == null) {
     return (
       <Tag ref={ref} className={className} data-testid={testId}>
         {children}
       </Tag>
     );
   }

   return (
     <Tooltip
       open={open}
-      onOpenChange={(next) => {
-        const el = ref.current;
-        setOpen(next && el !== null && el.scrollWidth > el.clientWidth);
-      }}
+      onOpenChange={handleOpenChange}
     >
       <TooltipTrigger asChild>
         <Tag ref={ref} className={className} data-testid={testId}>
           {children}
         </Tag>
       </TooltipTrigger>
       <TooltipContent>{tooltip}</TooltipContent>
     </Tooltip>
   );
 }
🤖 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 `@web/src/components/home-card.tsx` around lines 60 - 63, The inline
onOpenChange arrow in home-card.tsx should be extracted to a named handler to
match the JSX event-handler guideline. Move the current logic that reads
ref.current and calls setOpen into a separate function in the HomeCard component
(for example, a handleOpenChange-style method), then pass that function
reference to onOpenChange instead of defining the arrow inline.

Source: Coding guidelines

🤖 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 `@web/src/components/home-card.tsx`:
- Around line 46-72: The tooltip trigger in HomeCard is not keyboard-focusable
because the rendered Tag element is not naturally focusable, so keyboard users
cannot open the tooltip. Update the HomeCard component around TooltipTrigger/Tag
so that when tooltip is provided the trigger can receive focus (for example by
adding focusability to the Tag used as the TooltipTrigger), while keeping the
existing open state and truncation check logic in place.

---

Nitpick comments:
In `@web/src/components/home-card.tsx`:
- Around line 60-63: The inline onOpenChange arrow in home-card.tsx should be
extracted to a named handler to match the JSX event-handler guideline. Move the
current logic that reads ref.current and calls setOpen into a separate function
in the HomeCard component (for example, a handleOpenChange-style method), then
pass that function reference to onOpenChange instead of defining the arrow
inline.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 94dcb4fb-0d08-4e05-aee2-1df1427af96d

📥 Commits

Reviewing files that changed from the base of the PR and between 5c8b51c and 8409398.

📒 Files selected for processing (1)
  • web/src/components/home-card.tsx

Comment thread web/src/components/home-card.tsx Resolved
@dcc123456
dcc123456 marked this pull request as draft July 9, 2026 11:56
@dcc123456
dcc123456 marked this pull request as ready for review July 9, 2026 11:56
@wangq8
wangq8 merged commit 0095fa0 into infiniflow:main Jul 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants