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

Commit a924001

Browse files
committed
fix(grunt/tui): hivemind sidebar — text wrapping for peer summaries + inbox (no more right-edge truncation) (#18)
Refs hivemind anomalyco#229. Nik caught visible truncation in screenshot — peer rows showing 'nik-t...' instead of 'nik-tab-2', summary lines clipped at card edge, inbox subject/body chopped to 'ack:' / 'CLAIM' fragments. ## Root cause Sidebar interior width is ~38 cols (Sidebar is 42 wide, paddingLeft=2 + paddingRight=2). Opentui's <text> renderable clips horizontally by default — no auto-wrap on inline rows. Previous implementation crammed peer-id + summary on a single inline row which overflowed and got clipped at the right edge. ## Fix Each peer / inbox row is now TWO explicit lines: - **Peers**: line 1 = '· <peer-id> <relative-time>'. Line 2 = summary (wrapMode='word', truncated to 90 chars). - **Inbox**: line 1 = '<sender>'. Line 2 = subject-or-body (wrapMode='word', truncated to 110 chars). - **You section**: summary line gets wrapMode='word'; peer-id truncated to (SIDEBAR_INNER_COLS - 6) on overflow. Plus a small truncate(s, max) helper that adds an ellipsis (…) so the eye sees that content was cut, not just disappeared. Constants: SIDEBAR_INNER_COLS=38. Reflects the sidebar.tsx width=42 minus paddingLeft=2 + paddingRight=2. ## Verified bun typecheck clean. Local install reports 1.15.10-grunt.7+local.0d4a394a8.dirty.
1 parent c58c9a8 commit a924001

1 file changed

Lines changed: 46 additions & 18 deletions

File tree

‎packages/opencode/src/cli/cmd/tui/routes/session/hivemind-sections.tsx‎

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22
// Sidebar between the session title block and the gruntcode footer, so we add hivemind
33
// awareness to the operator's already-visible side panel rather than introducing a
44
// second sidebar (saves screen real estate, no layout-width math required).
5+
//
6+
// Sidebar interior width is ~38 cols (Sidebar is 42 wide, with paddingLeft=2 + paddingRight=2).
7+
// Text needs to either word-wrap explicitly OR get truncated to fit, because <text> in opentui
8+
// clips horizontally by default (no auto-wrap on inline rows). We split each peer / inbox row
9+
// into TWO explicit lines: compact identifier on line 1, wrapped/truncated detail on line 2.
510

611
import { For, Show, createMemo } from "solid-js"
712
import { useHivemind } from "../../context/hivemind"
813
import { useTheme } from "../../context/theme"
914

15+
const SIDEBAR_INNER_COLS = 38
16+
1017
function relativeTime(iso: string): string {
1118
const t = new Date(iso).getTime()
1219
if (!Number.isFinite(t)) return iso
@@ -18,6 +25,11 @@ function relativeTime(iso: string): string {
1825
return `${Math.floor(diff / 86_400_000)}d`
1926
}
2027

28+
function truncate(s: string, max: number): string {
29+
if (s.length <= max) return s
30+
return s.slice(0, max - 1) + "…"
31+
}
32+
2133
export function HivemindSections() {
2234
const hive = useHivemind()
2335
const { theme } = useTheme()
@@ -44,60 +56,76 @@ export function HivemindSections() {
4456
<Show
4557
when={hive.state.self}
4658
fallback={
47-
<text fg={theme.textMuted}>
48-
<span>not announced yet — set --peer-id to register</span>
59+
<text fg={theme.textMuted} wrapMode="word">
60+
not announced yet — set --peer-id to register
4961
</text>
5062
}
5163
>
5264
{(self) => (
53-
<box>
65+
<box flexDirection="column">
5466
<text fg={theme.text}>
5567
<b>you · </b>
56-
<span>{self().id}</span>
68+
<span>{truncate(self().id, SIDEBAR_INNER_COLS - 6)}</span>
5769
</text>
5870
<Show when={self().summary}>
59-
<text fg={theme.textMuted}>{self().summary}</text>
71+
<text fg={theme.textMuted} wrapMode="word">
72+
{self().summary}
73+
</text>
6074
</Show>
6175
<text fg={theme.textMuted}>
62-
<span>{wakeable() ? `✓ wakeable :${self().http_port}` : "✗ not wakeable"}</span>
76+
{wakeable() ? `✓ wakeable :${self().http_port}` : "✗ not wakeable"}
6377
{" · "}
64-
<span>{relativeTime(self().last_seen_at)} ago</span>
78+
{relativeTime(self().last_seen_at)} ago
6579
</text>
6680
</box>
6781
)}
6882
</Show>
6983

70-
{/* Section 2 — live peers */}
84+
{/* Section 2 — live peers. Each peer = 2 lines: id+time on line 1, summary on line 2.
85+
Summary uses wrapMode="word" so long summaries wrap inside the card width instead of
86+
clipping (caught 2026-05-27: "nik-t" truncation visible at right edge). */}
7187
<Show when={hive.state.peers.length > 0}>
72-
<box>
88+
<box flexDirection="column">
7389
<text fg={theme.text}>
7490
<b>peers ({hive.state.peers.length})</b>
7591
</text>
7692
<For each={hive.state.peers.slice(0, 6)}>
7793
{(peer) => (
78-
<text fg={theme.textMuted}>
79-
<span style={{ fg: theme.success }}>·</span> <b>{peer.id}</b>
94+
<box flexDirection="column" paddingTop={0}>
95+
<text fg={theme.textMuted}>
96+
<span style={{ fg: theme.success }}>·</span> <b>{truncate(peer.id, 26)}</b>
97+
<span> {relativeTime(peer.last_seen_at)}</span>
98+
</text>
8099
<Show when={peer.summary}>
81-
<span> — {(peer.summary ?? "").slice(0, 40)}</span>
100+
<text fg={theme.textMuted} wrapMode="word">
101+
{" "}
102+
{truncate(peer.summary ?? "", 90)}
103+
</text>
82104
</Show>
83-
</text>
105+
</box>
84106
)}
85107
</For>
86108
</box>
87109
</Show>
88110

89-
{/* Section 3 — inbox */}
111+
{/* Section 3 — inbox. Each DM = 2 lines: sender on line 1, wrapped subject/body on line 2. */}
90112
<Show when={hive.state.inbox.length > 0}>
91-
<box>
113+
<box flexDirection="column">
92114
<text fg={theme.text}>
93115
<b>inbox · </b>
94116
<span style={{ fg: theme.warning }}>{hive.state.inbox.length} unread</span>
95117
</text>
96118
<For each={hive.state.inbox.slice(0, 4)}>
97119
{(msg) => (
98-
<text fg={theme.textMuted}>
99-
<b>{msg.from_peer}</b>: {(msg.subject ?? msg.body).slice(0, 50)}
100-
</text>
120+
<box flexDirection="column">
121+
<text fg={theme.textMuted}>
122+
<b>{truncate(msg.from_peer, 28)}</b>
123+
</text>
124+
<text fg={theme.textMuted} wrapMode="word">
125+
{" "}
126+
{truncate(msg.subject ?? msg.body, 110)}
127+
</text>
128+
</box>
101129
)}
102130
</For>
103131
</box>

0 commit comments

Comments
 (0)