Skip to content

refactor: extract TruncatedLabel component and replace inline truncation logic - #4763

Merged
akshaydeo merged 3 commits into
mainfrom
refactor/extract-truncated-label-replace-inline-truncation
Jun 29, 2026
Merged

refactor: extract TruncatedLabel component and replace inline truncation logic#4763
akshaydeo merged 3 commits into
mainfrom
refactor/extract-truncated-label-replace-inline-truncation

Conversation

@impoiler

Copy link
Copy Markdown
Contributor

Cherry-picked from dev: 5d420a5

…dle special characters in URLs (#4714)

## Summary

Array-type query parameters in the logs page (models, providers, etc.) were not using the safe URI-encoding parser, meaning values containing characters like `://` (e.g. model names such as `gpt://host/model`) could be misinterpreted as path or query delimiters by TanStack Router. This introduces `parseAsSafeArrayOf` and applies it consistently across all array filters.

## Changes

- Added `parseAsSafeArrayOf` to `queryParamsParser.ts` by composing `parseAsArrayOf` with the existing `parseAsSafeString` parser, ensuring full URI-encoding for comma-separated filter values.
- Replaced all usages of `parseAsArrayOf(parseAsString)` in the logs page with `parseAsSafeArrayOf` so that array filters (models, providers, aliases, status, etc.) benefit from the same encoding guarantees as string filters.
- Added unit tests for both `parseAsSafeString` and `parseAsSafeArrayOf` to verify round-trip correctness with model names containing `://`.

## Type of change

- [x] Bug fix

## Affected areas

- [x] UI (React)

## How to test

```sh
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

To manually verify, navigate to the logs page and apply a filter using a model name containing `://` (e.g. `gpt://host/model`). Confirm the URL encodes correctly and the filter persists on page reload without routing errors.

## Screenshots/Recordings

N/A

## Breaking changes

- [x] No

## Related issues

#4603

## Security considerations

No security implications. This change only affects URL query parameter encoding in the UI.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
@mintlify

mintlify Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
Bifrost 🟡 Building Jun 29, 2026, 7:00 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 81053acf-b9eb-4336-acbf-3dd16cd49cf4

📥 Commits

Reviewing files that changed from the base of the PR and between 19fb4d5 and 11d6f95.

📒 Files selected for processing (3)
  • ui/app/workspace/providers/page.tsx
  • ui/components/filters/logsFilterSidebar.tsx
  • ui/components/filters/mcpFilterSidebar.tsx
📝 Walkthrough

Walkthrough

Three sidebar label renderers now use the shared TruncatedLabel component. The providers page removes its local truncation helper and unused hook imports. The logs and MCP filter sidebars replace truncated span labels in checkbox rows.

Changes

TruncatedLabel adoption across sidebars

Layer / File(s) Summary
Replace provider label truncation
ui/app/workspace/providers/page.tsx
Imports TruncatedLabel, renders the provider label through it, and removes the local TruncatedName helper plus unused React hook imports.
Use TruncatedLabel in filter rows
ui/components/filters/logsFilterSidebar.tsx, ui/components/filters/mcpFilterSidebar.tsx
Imports TruncatedLabel and replaces truncated span-based checkbox labels with the shared component in both filter sidebars.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

🐇 A label once clipped with a span so small,
Now hops through TruncatedLabel, neat for all.
Three sidebars share one tidy glow,
Less local code, more carrots in a row.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete and does not follow the required template sections beyond a cherry-pick note. Add the template sections: Summary, Changes, Type of change, Affected areas, How to test, Screenshots, Breaking changes, Related issues, Security considerations, and Checklist.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 accurately summarizes the main refactor: extracting TruncatedLabel and replacing inline truncation logic.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/extract-truncated-label-replace-inline-truncation

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

@greptile-apps

greptile-apps Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
ui/app/workspace/providers/page.tsx Provider-name truncation now uses the shared TruncatedLabel component.
ui/components/filters/logsFilterSidebar.tsx Filter checkbox labels now use the shared TruncatedLabel component.
ui/components/filters/mcpFilterSidebar.tsx MCP filter checkbox labels now use the shared TruncatedLabel component.

Reviews (3): Last reviewed commit: "refactor: extract `TruncatedLabel` compo..." | Re-trigger Greptile

Comment thread ui/app/workspace/providers/page.tsx
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 29, 2026
@impoiler
impoiler changed the base branch from main to graphite-base/4763 June 29, 2026 07:05
@impoiler
impoiler force-pushed the refactor/extract-truncated-label-replace-inline-truncation branch from 12f52ac to 19fb4d5 Compare June 29, 2026 07:05
@impoiler
impoiler changed the base branch from graphite-base/4763 to fix/use-parse-as-safe-array-logs-query-params June 29, 2026 07:05
impoiler added 2 commits June 29, 2026 12:38
## Summary

Adds a reusable `TruncatedLabel` component that displays truncated text with an automatic tooltip when the content overflows its container.

## Changes

- Introduces `TruncatedLabel`, a `<span>`-based component that detects when its text content is truncated via CSS overflow and conditionally renders a `Tooltip` to show the full content
- Truncation detection is performed by comparing `scrollWidth` to `clientWidth`, and re-evaluated on window resize or when `children` changes
- The tooltip content defaults to the `children` value if it is a string, but accepts an explicit `tooltip` prop for custom content
- The tooltip is only rendered when the text is actually truncated, avoiding unnecessary DOM overhead when content fits

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
cd ui
pnpm i || npm i
pnpm build || npm run build
```

Render a `TruncatedLabel` inside a constrained-width container with a long string. Verify that hovering over the truncated text shows a tooltip with the full content, and that no tooltip appears when the text is not truncated.

## Screenshots/Recordings

N/A

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

N/A

## Security considerations

No security implications. The component renders user-provided React nodes, which is consistent with existing UI patterns.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
…ation logic (#4716)

## Summary

Extracts the truncated label logic (truncate text with a tooltip on overflow) into a shared `TruncatedLabel` component and replaces all inline implementations with it.

## Changes

- Added a reusable `TruncatedLabel` component in `ui/components/ui/truncatedLabel` that handles text truncation and conditionally renders a tooltip when the content overflows
- Removed the local `TruncatedName` component from the providers page, which duplicated this logic using `useRef`, `useState`, and a resize event listener
- Replaced inline `<span className="truncate ...">` elements in the logs and MCP filter sidebars with `TruncatedLabel`

## Type of change

- [ ] Bug fix
- [ ] Feature
- [x] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

Verify that truncated labels in the providers list and filter sidebars still show a tooltip on hover when the text overflows, and no tooltip when it does not.

## Screenshots/Recordings

Verify the providers sidebar and log/MCP filter sidebars visually behave the same as before — truncated text shows a tooltip, non-truncated text does not.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

#4604

## Security considerations

None.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
@impoiler
impoiler changed the base branch from fix/use-parse-as-safe-array-logs-query-params to graphite-base/4763 June 29, 2026 07:08
@impoiler
impoiler force-pushed the refactor/extract-truncated-label-replace-inline-truncation branch from 19fb4d5 to 11d6f95 Compare June 29, 2026 07:08
@impoiler
impoiler changed the base branch from graphite-base/4763 to feat/truncated-label-tooltip-overflow June 29, 2026 07:08
@impoiler impoiler self-assigned this Jun 29, 2026

akshaydeo commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • Jun 29, 9:56 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 29, 9:59 AM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo changed the base branch from feat/truncated-label-tooltip-overflow to graphite-base/4763 June 29, 2026 09:58
@akshaydeo
akshaydeo changed the base branch from graphite-base/4763 to main June 29, 2026 09:58
@akshaydeo
akshaydeo dismissed coderabbitai[bot]’s stale review June 29, 2026 09:58

The base branch was changed.

@akshaydeo
akshaydeo merged commit 6c726fb into main Jun 29, 2026
11 of 13 checks passed
@akshaydeo
akshaydeo deleted the refactor/extract-truncated-label-replace-inline-truncation branch June 29, 2026 09:59
R-droid101 pushed a commit to R-droid101/bifrost that referenced this pull request Jul 1, 2026
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
…ion logic (maximhq#4763)

Cherry-picked from dev: 91fddc2bbf75910ab8e91758d65f0d13aa540c8e
occcat pushed a commit to occcat/bifrost that referenced this pull request Sep 2, 2026
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.

2 participants