Skip to content

feat(ui): show the full text of an ellipsized label on hover - #61

Merged
xiaoyumuxi merged 1 commit into
mainfrom
feat/ellipsis-hover-full-text-fork
Nov 25, 2026
Merged

xiaoyumuxi merged 1 commit into
mainfrom
feat/ellipsis-hover-full-text-fork

Conversation

@xiaoyumuxi

@xiaoyumuxi xiaoyumuxi commented Nov 25, 2026 •

Copy link
Copy Markdown

Upstream: vivaui#454 (the same change on upstream main f6d52d5f). This branch is that commit cherry-picked onto the fork's main (36cbd3ab), with two differences:

  • The fork has no gfx/pose.go. The one line upstream changes there, recording len(canvas.hoverHints) where a pose opens, is in Presence.apply in gfx/presence.go.
  • The installer templates and componentRequires are regenerated on this base with go run ./tools/componentgen.

Lithe's ellipsis hover change was built and tested against a copy of this branch that differs from it only in cmd/viva's generated installer templates, which Lithe does not import.

On this branch, macOS (Apple Silicon):

  • test -z "$(gofmt -l $(git ls-files '*.go'))"
  • go vet ./... (apart from the ignored local build/ directory): clean apart from the existing didModifyRange: deprecation warning.
  • go vet -tags vivahead ./internal/platform/darwin ./headless/...; GOOS=windows, GOOS=linux (amd64) go vet ./internal/... ./app/; GOOS=js GOARCH=wasm go vet ./internal/platform/web/ ./app/.
  • go test ./... -count=1: 131 packages pass. cmd/viva fails: its 14 packaging tests report "the program was built for macOS 13.0 or later but [mac] min_system says 12.0", from the macOS 27 SDK's deployment target. The same 14 fail on 36cbd3ab without this change. TestGeneratedRecipesAreCurrent and TestInstalledRecipesMatchReferenceSource pass.
  • The new tests listed below pass.

The benchmarks and binary size below were measured on the upstream branch.


What this changes

A label that Ellipsis cuts short now shows its full text in the shared tooltip when the pointer rests on it.

  • base:
    • Layout marks a text node it actually truncated (textTruncated). Painting registers a hover hint for it, and only for it: a value that merely ends in … does not get one.
    • Box.OverflowTooltip(text) lets a caller that shortened a value itself (a middle-elided path, say) hand over the original. With it the hint is registered whenever the box paints text, since the caller already decided the value is shortened.
    • Page.HoveredText() returns the hint under the pointer; Page.PointerDown() reports a press.
  • gfx:
    • gfx.HoverHint holds the owner, bounds, full text, the control it belongs to, layer and clip scope. Canvas collects hints with the rest of the frame.
    • HoverHintAt returns the topmost hint at a point. It skips a hint covered by a hit painted later on another control, by a higher layer, or outside a focus trap. A hit of the control the hint belongs to, and container and label hits, do not hide it.
    • Reset, Trim, Rewind, embedding and replay carry or clear the hints the same way they treat hits.
  • ui: after TooltipDelay, Page shows the hint through components.BeginTooltip, the tooltip Tooltip already uses. A press hides it until the pointer leaves the text, so it does not cover a selection or a drag.
  • components: Select, Combobox, Single Select, dropdown menu and hierarchy menu items, Multi Select chips and area chart axis labels go through one helper (labelEllipsis, in label.go), so each gets the hint. Those components now require label; the installer templates and componentRequires are regenerated with go run ./tools/componentgen. Table cells, which shorten their values themselves, register the hint with the full value where the drawn text differs from it.
    • Visible change in Select: its trigger and items drew their text with Label, which clips at the bounds with no ellipsis. They now end a value that does not fit with …, as the other components already did, and show it in full on hover. Code or tests that read a narrow Select's drawn text get the shortened value: in Lithe, "All configurations (3)" in a 112pt-wide trigger now reads "All configuration…".

The hint adds no hit target, focus stop or accessibility node. Clicks, selection, keyboard behaviour and the accessibility tree are unchanged.

Why

Lithe (1lck/Lithe-IDEA) shows commit subjects, paths, toolchain locations and plugin canvas text in places too narrow for them. Ellipsis cut them with no way to read the rest. Each control adding its own Tooltip would need a hit target per label and its own idea of when text is cut, which only layout knows. A non-interactive hint keyed to the truncation layout already measured gives every ellipsized label the same behaviour.

How it was verified

  • test -z "$(gofmt -l $(git ls-files '*.go'))"

  • go vet ./... on macOS: clean apart from the existing didModifyRange: deprecation warning in core_render.m.

  • go vet -tags vivahead ./internal/platform/darwin ./headless/...; GOOS=windows, GOOS=linux (amd64) go vet ./internal/... ./app/; GOOS=js GOARCH=wasm go vet ./internal/platform/web/ ./app/.

  • go test ./... -count=1 on macOS (Apple Silicon): 137 packages pass. The 4 that fail fail the same way on f6d52d5f without this change:

    • cmd/viva: the packaging tests report "the program was built for macOS 13.0 or later but [mac] min_system says 12.0", from the macOS 27 SDK's deployment target. TestGeneratedRecipesAreCurrent and TestInstalledRecipesMatchReferenceSource pass.
    • internal/componentdemo, internal/gallery, ui/inputnumber: input-number's warm paint allocates once.
  • New tests:

    • ui: TestEllipsisTooltip, TestEllipsisTooltipWithoutAHit, TestEllipsisTooltipClippingAndExistingHint, TestMaxLinesTooltipAndLiteralEllipsis, TestOverflowTooltipKeepsCheckboxCaptionClickable
    • gfx: TestHoverHintFollowsReplayAndRewind, TestHoverHintIsMountedAndClippedWithEmbeddedText
    • ui/multiselect: TestEllipsizedChipKeepsItsFullLabelAndRemoveButton

    They use the new API and do not build on f6d52d5f.

  • Benchmarks before and after, macOS Apple Silicon, 5 runs each, -benchtime 200ms, median ns/op. The machine was not idle; the differences are within run-to-run noise. allocs/op are unchanged.

    Benchmark before after B/op allocs/op
    FrozenTable 5550 5614 194 → 194 1 → 1
    WrappedMonoParagraphs 15373 15011 7 → 6 0 → 0
    WrappedParagraphs 4666 4654 2 → 2 0 → 0
    HitBoundsInALargePaint 2648 2646 0 → 0 0 → 0
    CanvasMonoLabels/digits 3574 3651 0 → 0 0 → 0
    CanvasMonoLabels/code 1090 1092 0 → 0 0 → 0
    ComboboxOpen 1617 1642 0 → 0 0 → 0
    PageFleet 9358 9444 8 → 8 0 → 0
  • Binary size: cmd/showcase, darwin/arm64, -trimpath -ldflags='-s -w': 7661794 → 7694850 bytes (+33 KB, +0.43%).

  • Not checked in a real window on any platform. No platform backend changed; the tooltip is drawn by the existing BeginTooltip path.

Reaching the frame

Headless (-tags vivahead): a Label with Ellipsis in a box narrower than its text, pointer moved onto the text, clock advanced past TooltipDelay. TestEllipsisTooltip does exactly this and checks the tooltip's text; the same test with the box wide enough checks that no tooltip appears.

Cost

  • One HoverHint appended per truncated label per paint, into a slice the canvas reuses, so a warm frame allocates nothing more (see the allocs/op column).
  • A pointer move walks the frame's hints from the top, and for a hint under the pointer, the frame's hits, to find one painted over it. A frame without truncated text has no hints, so the walk is empty.

A label that Ellipsis cuts short hides the rest of its text with no way to
read it. Layout now marks a text node it actually truncated, and painting
registers a non-interactive hover hint for it (gfx.HoverHint: owner, bounds,
full text, the control it belongs to, layer and clip scope). After the
tooltip delay a Page shows the hint through the shared tooltip, the same
one Tooltip uses.

The hint adds no hit target, focus stop or accessibility node, so clicks,
selection and keyboard behaviour are unchanged. It only appears when the
layout really cut the text: a value that merely ends in an ellipsis does not
trigger it. A clip, a hit painted later, a higher layer or a focus trap
hides it; pressing the pointer hides it until the pointer leaves.

Box.OverflowTooltip(text) lets a caller that shortened a value itself (a
middle-elided path, say) hand over the original. Select, combobox, dropdown
menu and hierarchy menu items, multi-select chips, table cells and area
chart axis labels use the same path. Canvas Reset, Trim, Rewind, embedding
and replay carry or clear the hints with the rest of the frame.

The components that share the ellipsis helper now require label, so the
installer templates and componentRequires are regenerated with componentgen.
@xiaoyumuxi
xiaoyumuxi merged commit 98e5d08 into main Nov 25, 2026
15 of 16 checks passed
xiaoyumuxi added a commit to 1lck/Lithe-IDEA that referenced this pull request Nov 25, 2026
* feat(workbench): 省略文字悬停时显示全文

日志消息与字段、工具链路径、Git 日志、插件画布、状态栏文件名和信任对话框的省略文字,
鼠标停留后用共享提示显示完整内容。宿主提前缩短的文字通过 Viva 的 OverflowTooltip
传入原文,点击、行选择、筛选和复选框行为不变。

依赖 Viva 全文提示能力(Lithe-IDEA/Lithe-viva#61,上游 vivaui/viva#454),
desktop/go.mod 的固定版本要在 fork PR 合入后再升级。

* test(workbench): 运行配置作用域标签按省略后的显示检查

打了全文提示补丁的 Viva 让 Select 的触发器在放不下时显示“…”,不再硬裁剪。
112 宽的作用域选择器里,“All configurations (3)”会显示成“All configuration…”。
新增 showsFitted:完整显示即通过;被省略时把指针停在标签上,检查提示里是完整的值。

* docs(agents): 记录下拉框改为省略显示,更新全文提示的矩阵说明

* perf(logwindow): 只给被截断且有高亮的消息加容器

日志消息原来每行都包一层 Row 来承载全文提示。现在只有消息被截断、又被搜索高亮
分成多段时才包这一层;其余消息直接在标签上登记提示,保持原来的节点结构。字段的
完整键值改为第一次被截断时拼接并随字段缓存。

补充高亮分段消息的悬停回归测试,修正截图说明里字段提示的描述,功能矩阵列出新测试。
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.

1 participant