Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

fix(ui): a channel message on a phone gets the width it needs (#826)

lmliheng7abf102083db
diff --git a/changelog/unreleased/2026-10-14-channel-bubble-phone.md b/changelog/unreleased/2026-10-14-channel-bubble-phone.md
new file mode 100644
index 00000000..5a75c973
--- /dev/null
+++ b/changelog/unreleased/2026-10-14-channel-bubble-phone.md
@@ -0,0 +1,24 @@
+# A channel message on a phone gets the width it needs
+
+- **Date:** 2026-10-14
+- **Type:** fix
+- **Scope:** `ui`
+
+[中文版](2026-10-14-channel-bubble-phone.zh.md)
+
+Ported from upstream PenguinHarness (#826, commit `9eae0a2d`).
+
+On a phone, a company channel's message bubbles were narrow and the time stamp squeezed the
+words: Chinese wrapped at about seven characters a line. Two things changed:
+
+- A bubble may take 88% of its column on a narrow screen (75% from the `sm` breakpoint up, as
+ before). The column is already the avatar gutter short of the screen; three quarters of what
+ was left was not enough.
+- The time no longer sits in a column of its own beside the body. It ends the bubble: beside
+ the words when a message fits on one line with it, and on a line of its own — right-aligned,
+ under the last line — when the words need the width. The body keeps room for it on its last
+ line (the last paragraph, list item or quote line ends in an inline gap of the time's width),
+ and a block that cannot end in a gap (code, a table) gets the line under it instead. The body
+ is `text-base` on a phone and `text-sm` from `sm` up, as before.
+
+No API, wire format or stored data changes.
diff --git a/changelog/unreleased/2026-10-14-channel-bubble-phone.zh.md b/changelog/unreleased/2026-10-14-channel-bubble-phone.zh.md
new file mode 100644
index 00000000..5de1a865
--- /dev/null
+++ b/changelog/unreleased/2026-10-14-channel-bubble-phone.zh.md
@@ -0,0 +1,20 @@
+# 手机上的频道消息有了足够的宽度
+
+- **Date:** 2026-10-14
+- **Type:** fix
+- **Scope:** `ui`
+
+[English](2026-10-14-channel-bubble-phone.md)
+
+移植自上游 PenguinHarness(#826,提交 `9eae0a2d`)。
+
+手机上公司频道的消息气泡偏窄,时间戳又把文字往左挤:中文每行只排得下七个字左右。改了两处:
+
+- 窄屏上气泡最多占列宽的 88%(`sm` 断点及以上仍是 75%)。这一列本来就比屏幕少了头像那一段,剩余的
+ 四分之三不够用。
+- 时间戳不再作为正文旁边的一栏。它收在气泡末尾:一行放得下就跟在文字后面;文字需要整行宽度时就单独
+ 占一行、靠右、贴在最后一行下面。正文在最后一行上给它留出位置(最后一段、最后一个列表项、引用的最后
+ 一行都以一段行内空隙收尾),而无法以空隙收尾的块(代码、表格)则把那一行让到它下面。正文在手机上
+ 是 `text-base`,`sm` 及以上仍是 `text-sm`。
+
+接口、线上格式与已存数据都没有变化。
diff --git a/packages/ui/src/components/chat/channel-bubble/channel-bubble.css b/packages/ui/src/components/chat/channel-bubble/channel-bubble.css
index 00edaa82..bbf30294 100644
--- a/packages/ui/src/components/chat/channel-bubble/channel-bubble.css
+++ b/packages/ui/src/components/chat/channel-bubble/channel-bubble.css
@@ -16,3 +16,25 @@
.channel-bubble :is(th, td) {
border-color: var(--ui-line-emphasis);
}
+
+/* A channel message's time (channel-bubble.tsx) sits in the bubble's bottom-right
+ corner, and the words keep room for it: the last line of the body ends in an inline gap of the
+ time's width — WhatsApp's spacer — so a line that ends short of the gap shares the line with
+ the time, and one that does not wraps its last word under, leaving the corner to the time. A
+ block that cannot end in an inline gap (code, a table) is given the line under it instead. */
+.channel-bubble {
+ --channel-time-gap: 2.75rem;
+}
+.channel-bubble .md-body > :is(p, h1, h2, h3, h4):last-child::after,
+.channel-bubble .md-body > :is(ul, ol):last-child > li:last-child::after,
+.channel-bubble .md-body > blockquote:last-child > :last-child::after {
+ content: "";
+ display: inline-block;
+ width: var(--channel-time-gap);
+}
+.channel-bubble .md-body > :is(pre, table):last-child {
+ margin-bottom: 1.125rem;
+}
+.channel-time-gap {
+ flex: 0 0 var(--channel-time-gap);
+}
diff --git a/packages/ui/src/components/chat/channel-bubble/channel-bubble.tsx b/packages/ui/src/components/chat/channel-bubble/channel-bubble.tsx
index d8f24c40..898d20c3 100644
--- a/packages/ui/src/components/chat/channel-bubble/channel-bubble.tsx
+++ b/packages/ui/src/components/chat/channel-bubble/channel-bubble.tsx
@@ -10,8 +10,8 @@
* its own tint, with no avatar and no name; a screen reader hears `ownLabel` instead, since a side
* and a colour are not something every reader can read.
*
- * Each bubble carries its own time at its end, inside it, bottom-aligned: on a one-line message it
- * lands beside the words, on a longer one it settles into the bottom-right corner, and it never
+ * Each bubble carries its own time in its bottom-right corner, with a spacer on the body’s last
+ * line: it lands beside the words, or under their last line, and it never
* overlaps the body. A time that only appeared on hover would be one a touch reader never sees, and
* one time per run would leave every later message in a long run unstamped. The body is Markdown in
* the compact reading box; what the caller renders into it is its own (a channel keeps its
@@ -158,21 +158,24 @@ export function ChannelBubble({
<div
id={id}
data-side={own ? "own" : "other"}
- className={`channel-bubble max-w-[75%] px-3 py-1.5 text-sm leading-relaxed ${corners(own, last)} ${own ? SURFACE.own : SURFACE.other}`}
+ className={`channel-bubble relative max-w-[88%] px-3 py-1.5 text-base leading-relaxed sm:max-w-[75%] sm:text-sm ${corners(own, last)} ${own ? SURFACE.own : SURFACE.other}`}
>
- <div className={`flex items-end ${ICON_GAP.menu}`}>
- <div className="min-w-0 flex-1">
- <div className="md-body md-compact">{children}</div>
- {footer}
- </div>
- <span
- data-tooltip={timeTooltip}
- className="shrink-0 text-xs tabular-nums text-tone-neutral-fg"
- >
- <span className="sr-only">{timeLabel}</span>
- <span aria-hidden>{time}</span>
- </span>
+ <div className="min-w-0">
+ <div className="md-body md-compact">{children}</div>
+ {footer != null && (
+ <>
+ {footer}
+ <span aria-hidden className="channel-time-gap" />
+ </>
+ )}
</div>
+ <span
+ data-tooltip={timeTooltip}
+ className="absolute bottom-1.5 right-3 text-xs tabular-nums text-tone-neutral-fg"
+ >
+ <span className="sr-only">{timeLabel}</span>
+ <span aria-hidden>{time}</span>
+ </span>
</div>
);
}
diff --git a/packages/ui/test/channel-bubble.test.ts b/packages/ui/test/channel-bubble.test.ts
index b9376efe..bb0502b9 100644
--- a/packages/ui/test/channel-bubble.test.ts
+++ b/packages/ui/test/channel-bubble.test.ts
@@ -75,11 +75,23 @@ describe("ChannelBubble", () => {
expect(html).toMatch(/^<div id="m-1" data-side="other" class="channel-bubble /);
expect(html).toContain('<div class="md-body md-compact"><p>body</p></div><span>refs</span>');
expect(html).toContain(
- '<span data-tooltip="9/30 14:05" class="shrink-0 text-xs tabular-nums ' +
+ '<span data-tooltip="9/30 14:05" class="absolute bottom-1.5 right-3 text-xs tabular-nums ' +
'text-tone-neutral-fg"><span class="sr-only">发送于 9/30 14:05</span>' +
'<span aria-hidden="true">14:05</span></span>',
);
- expect(classTokens(html)).toEqual(expect.arrayContaining(["bg-fill-neutral", "text-fg"]));
+ expect(classTokens(html)).toEqual(
+ expect.arrayContaining([
+ "bg-fill-neutral",
+ "text-fg",
+ "relative",
+ "max-w-[88%]",
+ "sm:max-w-[75%]",
+ "text-base",
+ "sm:text-sm",
+ ]),
+ );
+ expect(html).toContain('<span aria-hidden="true" class="channel-time-gap"></span>');
+ expect(bubble()).not.toContain("channel-time-gap");
});
it("squares the corner nearest the run's tail, on the last bubble only", () => {