fix(ui): keep the session model chip inside its own border - #8
Closed
richardfogaca wants to merge 1 commit into
Closed
fix(ui): keep the session model chip inside its own border#8richardfogaca wants to merge 1 commit into
richardfogaca wants to merge 1 commit into
Conversation
Long provider/model ids (OpenCode, e.g. kimi-for-coding/kimi-for-coding-highspeed) painted straight through the footer model chip's 180px box. The ellipsis never applied: antd moves a tag's children into its own content span when an icon is set, so the custom span sat inside that flex item, and the flex item's automatic minimum size kept it at full text width. Add a `truncate` prop to the shared Tag wrapper that owns the fix once: `minWidth: 0` on the root so it can shrink without clipping (clipping the root would eat antd's click ripple), the label box clipping and ellipsizing itself, and a per-key merge so a caller styling one part cannot silently drop truncation. Icon-less tags get their own label box because antd renders bare children there. The model chip now grows with the available info-bar width and ellipsizes only when it must, with the full id on hover. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the shared UI Tag wrapper to support an opt-in truncate mode so long chip labels (notably the session model provider/model id) ellipsize within the tag border instead of overflowing, and adds targeted unit tests to lock in the behavior.
Changes:
- Add
truncate?: booleanto the sharedTagwrapper and implement truncation via semanticstyles.content(icon path) or a wrapper<span>(no-icon path). - Update the SessionFooter model chip to use
truncate+titleinstead of a hand-rolled inner span and fixedmaxWidth. - Add unit tests for the
Tagtruncation contract and a regression test for the long model id case inSessionFooter.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/agor-ui/src/components/Tag/Tag.tsx | Adds truncate behavior and style-merging logic to keep ellipsis/clipping owned by the shared Tag wrapper. |
| apps/agor-ui/src/components/Tag/Tag.test.tsx | Adds tests validating truncation behavior for icon and no-icon variants and style merging. |
| apps/agor-ui/src/components/SessionPanel/SessionFooter.tsx | Switches the model chip to truncate and removes the fixed max-width + inner span workaround. |
| apps/agor-ui/src/components/SessionPanel/SessionFooter.test.tsx | Adds a regression test for truncating a long provider/model id and ensuring full value is available via title. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+24
to
+28
| const TRUNCATE_LABEL_STYLE: CSSProperties = { | ||
| minWidth: 0, | ||
| overflow: 'hidden', | ||
| textOverflow: 'ellipsis', | ||
| }; |
Owner
Author
|
Superseded — opened against preset-io/agor instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
truncateprop to the sharedTagwrapper that owns chip-label truncation correctly in one placemaxWidth: 180capprovider/modelid on hoverWhy / context
On sessions whose model id is long — OpenCode reports
provider/model, e.g.kimi-for-coding/kimi-for-coding-highspeed— the label rendered straight through the chip's border and background instead of being clipped.Root cause: the chip capped itself at
maxWidth: 180and putoverflow/text-overflowon a custom inner<span>. Neither rule could take effect.icon, antd moves the children into its own content span, so the custom span sat inside that element — andtext-overflowdoes not apply to an inline box anyway.Implementation notes
truncatekeeps the tricky part in the owning component rather than at each call site, per the styling hierarchy incontext/guidelines/frontend.md(AntD semanticstylesAPI above inline style, both above CSS, and no.ant-*overrides):styles.contentwhen there is an icon, or a span this wrapper supplies when there is not (antd renders bare children in that case, and ellipsis on a flex root is inert).minWidth: 0, notoverflow: hidden. Zeroing the min-content floor is what lets the chip shrink; clipping the root would also clip the click ripple antd renders inside the tag, so a clickable chip would lose its press feedback.stylesare merged per key, so styling one part (say the icon) cannot silently drop truncation.stylemerges the same way, with the caller winning on conflicts.inline-blockwrapper) should also pass a numericstyle.maxWidth.Call sites stay declarative — the model chip is now
<Tag icon={...} truncate title={modelName}>.Validation / test plan
pnpm vitest runinapps/agor-ui— 187 files, 1277 tests passTag.test.tsxpin the contract: label clips while the root stays unclipped, the icon-less path gets its own label box, truncation survives a caller styling another part, andtruncateoff leaves layout untouchedSessionFooter.test.tsxcovers the reportedkimi-for-coding/kimi-for-coding-highspeedchippnpm typecheck— no new errors. The 7 pre-existing errors under these paths (stalepackages/clientbuild artifacts:reasoningEffortLevels,isAgenticToolName) are identical before and after this branch, andTag.tsxreports noneRisks / rollout / rollback
Low.
truncatedefaults tofalse, so all 28 existingTagconsumers render byte-identically; only the model chip opts in. No API, data, or config changes. Rollback is reverting the commit.Known trade-off: without the 180px cap, a very long id can claim the whole info-bar row and wrap the neighbouring chips (tokens, context, IDs) onto an extra line in a narrow panel. That is the intended direction — the hard cap is what produced the reported bug — but it is worth a look if the footer feels tall on small panels.
Out of scope / follow-ups
Pill.tsxstill hand-rolls the same clipping forIssuePill/PullRequestPill(pillTextStyle,maxWidth: 220). Migrating those totruncateis the natural next step and matches the "converge repeated pill treatments" follow-up in the frontend guidelines.{cursor, height: 22, display: 'inline-flex', alignItems: 'center'}chip style is still duplicated across the footer info-bar chips andSessionMcpFooterControl; extracting a small footer-chip component would remove it.