Skip to content
This repository was archived by the owner on Aug 17, 2026. It is now read-only.

Commit 0d4a394

Browse files
authored
fix(grunt/tui): TicketHoverCard text-rendering — clean preview lines, no character bleed (#17)
Refs hivemind anomalyco#233. Closes Nik feedback after PR #16: 'there is some gibberish being added in to text' with a screenshot showing the title rendered as '##nNikrdirective...' (jumbled) and the scope as 'clicktto,open inrhivemind-ui closed the session before' (with extra letters and the footer-line text bleeding into the scope). ## Root cause Three compounding issues in the card body: 1. **Multi-line scope text with wrapMode='word'** — opentui's text renderable joins adjacent <text> siblings when wrap-word is enabled, producing character bleed across line boundaries. The actual title was correct in the api response; the renderer was conflating it with the scope's first line plus the footer ('click to open in hivemind-ui') text. 2. **Markdown chars in scope** — full scope text contains markdown ('## Nik directive 2026-05-26T23:01Z (recovered from ses_...)') which the plain-text renderable was passing through verbatim, then word-wrap ate the spaces around '#' and '##'. 3. **<>Fragment</> wrapping the inner content** — Fragments don't establish a layout box; the renderable was free to flow children in weird ways. The position-absolute outer box wasn't enough to constrain line breaks per-text. ## Fix - Wrap inner content in <box flexDirection='column'> so each <text> is one explicit line. - Drop wrapMode='word' from the body; let opentui's natural per-text layout handle line bounds. - Pre-flatten the scope: strip code fences, headings, emphasis markers, and collapse whitespace to single spaces. This makes the preview a proper one-paragraph blurb instead of attempting to render markdown inside a 60-col tooltip. - Compute title / meta / scope-preview as plain strings before render. - Drop the <b> wrapper around title (use attributes={1} on <text> instead, matching the pattern in routes/session/sidebar.tsx). ## Verified bun typecheck clean. Local install reports 1.15.10-grunt.7+local.f9cad9dea.dirty.
1 parent f9cad9d commit 0d4a394

1 file changed

Lines changed: 38 additions & 31 deletions

File tree

‎packages/opencode/src/cli/cmd/tui/component/ticket-hover-card.tsx‎

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// Rendered ONCE at the app-root level. Reads the global hoveredTicket signal from the
44
// Hivemind context; when set, shows the ticket detail at a position anchored near the
5-
// trigger's cursor coords (just below + slightly right, with right-edge overflow guard).
5+
// trigger's cursor coords (just below + slightly right, with overflow guards).
66
//
77
// Sticky-hover semantics: the card also has its own onMouseOver/Out — entering the card
88
// cancels the trigger's close-timer (so the cursor can traverse the gap between trigger
@@ -16,6 +16,22 @@ import { useTheme } from "../context/theme"
1616

1717
const CARD_WIDTH = 60
1818
const CARD_MAX_HEIGHT = 16
19+
const SCOPE_PREVIEW_CHARS = 180
20+
21+
/** Flatten a multi-line markdown-flavored scope into a single-paragraph preview for the
22+
* tooltip. The hover card is a small preview, not a full doc render — newlines, markdown
23+
* headings, code fences, and stacked whitespace would otherwise wreck the layout (caught
24+
* 2026-05-27: a multi-line scope with `## heading` + blank-line gaps was rendering as
25+
* mangled bleed when the text renderable's wrap-word mode joined adjacent lines). */
26+
function flattenScope(raw: string | null | undefined): string {
27+
if (!raw) return ""
28+
return raw
29+
.replace(/```[\s\S]*?```/g, " ") // strip fenced code blocks
30+
.replace(/^#+\s*/gm, "") // strip markdown headings
31+
.replace(/[*_`>]/g, "") // strip emphasis / quote markers
32+
.replace(/\s+/g, " ") // collapse all whitespace to single spaces
33+
.trim()
34+
}
1935

2036
export function TicketHoverCard() {
2137
const hive = useHivemind()
@@ -25,7 +41,7 @@ export function TicketHoverCard() {
2541
return (
2642
<Show when={hive.hoveredTicket()}>
2743
{(anchor) => {
28-
// Position: just below the trigger cursor, offset right by 2 cols. If that would
44+
// Position: just below the trigger cursor, offset right by 1 col. If that would
2945
// push off the right edge, flip the card so its right edge aligns with the cursor.
3046
const left = () => {
3147
const desired = anchor().anchorX + 1
@@ -35,7 +51,6 @@ export function TicketHoverCard() {
3551
}
3652
const top = () => {
3753
const desired = anchor().anchorY + 1
38-
// If near the bottom, flip above the cursor.
3954
if (desired + CARD_MAX_HEIGHT > dims().height) {
4055
return Math.max(0, anchor().anchorY - CARD_MAX_HEIGHT)
4156
}
@@ -47,6 +62,7 @@ export function TicketHoverCard() {
4762
position="absolute"
4863
left={left()}
4964
top={top()}
65+
flexDirection="column"
5066
backgroundColor={theme.backgroundPanel}
5167
border={true}
5268
borderColor={theme.border}
@@ -55,7 +71,7 @@ export function TicketHoverCard() {
5571
paddingTop={0}
5672
paddingBottom={0}
5773
zIndex={3000}
58-
maxWidth={CARD_WIDTH}
74+
width={CARD_WIDTH}
5975
onMouseOver={() => hive.setCardHovered(true)}
6076
onMouseOut={() => hive.setCardHovered(false)}
6177
>
@@ -68,36 +84,27 @@ export function TicketHoverCard() {
6884
if (d === null) {
6985
return <text fg={theme.textMuted}>#{id}: not found</text>
7086
}
87+
const titleLine = `#${d.id} ${d.title}`
88+
const metaParts: string[] = [d.status, d.priority]
89+
if (d.zone) metaParts.push(`zone=${d.zone}`)
90+
if (d.owner) metaParts.push(`owner=${d.owner}`)
91+
const metaLine = metaParts.join(" · ")
92+
const scopeFlat = flattenScope(d.scope)
93+
const scopePreview =
94+
scopeFlat.length > SCOPE_PREVIEW_CHARS
95+
? scopeFlat.slice(0, SCOPE_PREVIEW_CHARS) + "…"
96+
: scopeFlat
7197
return (
72-
<>
73-
<text fg={theme.text} wrapMode="word">
74-
<b>
75-
#{d.id} {d.title}
76-
</b>
98+
<box flexDirection="column">
99+
<text fg={theme.text} attributes={1}>
100+
{titleLine}
77101
</text>
78-
<text fg={theme.textMuted}>
79-
<span>{d.status}</span>
80-
{" · "}
81-
<span>{d.priority}</span>
82-
<Show when={d.zone}>
83-
{" · "}
84-
<span>zone={d.zone}</span>
85-
</Show>
86-
<Show when={d.owner}>
87-
{" · "}
88-
<span>owner={d.owner}</span>
89-
</Show>
90-
</text>
91-
<Show when={d.scope}>
92-
<text fg={theme.textMuted} wrapMode="word">
93-
{(d.scope ?? "").slice(0, 220)}
94-
{(d.scope ?? "").length > 220 ? "..." : ""}
95-
</text>
102+
<text fg={theme.textMuted}>{metaLine}</text>
103+
<Show when={scopePreview}>
104+
<text fg={theme.textMuted}>{scopePreview}</text>
96105
</Show>
97-
<text fg={theme.textMuted}>
98-
<span>click to open in hivemind-ui</span>
99-
</text>
100-
</>
106+
<text fg={theme.textMuted}>click to open in hivemind-ui</text>
107+
</box>
101108
)
102109
})()}
103110
</box>

0 commit comments

Comments
 (0)