Skip to content

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

fix(web): a scrolling session title no longer also shows a tooltip (#706)

Yaowei Zheng6248b812f886
diff --git a/changelog/unreleased/2026-09-12-session-title-tooltip.md b/changelog/unreleased/2026-09-12-session-title-tooltip.md
new file mode 100644
index 00000000..826b7575
--- /dev/null
+++ b/changelog/unreleased/2026-09-12-session-title-tooltip.md
@@ -0,0 +1,22 @@
+# A scrolling session title no longer also raises a tooltip
+
+- **Date:** 2026-09-12
+- **Type:** fix
+- **Scope:** `web`
+- **PR:** [#706](https://github.com/Prism-Shadow/penguin-harness/pull/706)
+- **Issue:** [#570](https://github.com/Prism-Shadow/penguin-harness/issues/570)
+
+[中文版](2026-09-12-session-title-tooltip.zh.md)
+
+Hovering a sidebar session whose title was too long for the row disclosed that title twice at
+once: the text scrolled its clipped tail into view, and a native tooltip carrying the same text
+opened over it. The scroll is now the only disclosure on those rows.
+
+## Details
+
+- `Truncated` attaches its `title` only where the tail cannot be scrolled into view — callers
+ that do not ask for the scroll reveal keep the tooltip exactly as before.
+- Under the system "reduce motion" preference the reveal's keyframes are disabled and nothing
+ scrolls, so the tooltip stays there as the pointer-hover fallback.
+- This covers the sidebar's session rows and its draft rows, the two places that use the scroll
+ reveal.
diff --git a/changelog/unreleased/2026-09-12-session-title-tooltip.zh.md b/changelog/unreleased/2026-09-12-session-title-tooltip.zh.md
new file mode 100644
index 00000000..5cb82f1a
--- /dev/null
+++ b/changelog/unreleased/2026-09-12-session-title-tooltip.zh.md
@@ -0,0 +1,19 @@
+# 会话标题滚动展示时不再同时弹出提示气泡
+
+- **Date:** 2026-09-12
+- **Type:** fix
+- **Scope:** `web`
+- **PR:** [#706](https://github.com/Prism-Shadow/penguin-harness/pull/706)
+- **Issue:** [#570](https://github.com/Prism-Shadow/penguin-harness/issues/570)
+
+[English](2026-09-12-session-title-tooltip.md)
+
+侧边栏中标题长于行宽的会话,鼠标悬停时会被展示两遍:文字把被截断的尾部滚动进视野,同时一个内容相同的
+原生提示气泡浮在它上面。现在这类行只保留滚动这一种展示方式。
+
+## 细节
+
+- `Truncated` 仅在尾部无法靠滚动展示时才附加 `title`;未启用滚动展示的调用方,提示气泡与此前完全一致。
+- 系统开启「减弱动态效果」时,滚动展示所依赖的关键帧被禁用、文字不再滚动,提示气泡在这种情况下保留,作为
+ 鼠标悬停时的兜底。
+- 涉及的范围是使用滚动展示的两处:侧边栏的会话行与草稿行。
diff --git a/packages/web/src/components/layout/sidebar.tsx b/packages/web/src/components/layout/sidebar.tsx
index 00590107..88b85fd1 100644
--- a/packages/web/src/components/layout/sidebar.tsx
+++ b/packages/web/src/components/layout/sidebar.tsx
@@ -2654,9 +2654,11 @@ function SessionRow({
)}
{/* Truncated titles reveal their full text on row hover / keyboard focus by
scrolling the tail into view (#309; scrollReveal, no-op when the title fits).
- The conditional `title` stays as the pointer-hover fallback under
- prefers-reduced-motion — not as a touch path: mobile browsers do not surface
- `title` on long-press. Touch reaches the full text by opening the Session. */}
+ No `title` tooltip comes with it: it would sit over the very text scrolling
+ past underneath. Under prefers-reduced-motion the keyframes are disabled and
+ nothing scrolls, so the conditional `title` returns there as the pointer-hover
+ fallback — not as a touch path: mobile browsers do not surface `title` on
+ long-press. Touch reaches the full text by opening the Session. */}
<Truncated
scrollReveal
text={s.title ?? S.chat.defaultSessionTitle}
diff --git a/packages/web/src/components/ui/truncated.tsx b/packages/web/src/components/ui/truncated.tsx
index 07885e9a..e002c356 100644
--- a/packages/web/src/components/ui/truncated.tsx
+++ b/packages/web/src/components/ui/truncated.tsx
@@ -1,6 +1,6 @@
/**
* Single-line truncated text: attaches `title` (hover to see the full text)
- * **only when actually truncated**.
+ * **only when actually truncated**, and only where nothing else reveals the tail.
*
* The site-wide rule is "don't duplicate `title` when the element already shows
* the text", but text whose tail is cut off by `truncate` isn't fully shown —
@@ -14,16 +14,23 @@
* at a constant reading speed, holds at the end, and snaps back the instant the
* hover/focus ends. The animation itself is pure CSS (styles.css
* `title-scroll-reveal` keyframes) driven by the two custom properties set here:
- * this component only measures and publishes numbers. There are no timers and no
- * media-query subscriptions to leak — reduced motion is handled by the global
- * `animation: none !important` block in styles.css, which disables the keyframes
- * outright and leaves the plain ellipsis plus the `title` tooltip. The full text
- * also always stays in the DOM, so screen readers announce it regardless of the
- * visual clipping.
+ * this component only measures and publishes numbers. There are no timers, and
+ * the reduced-motion query is one app-wide subscription shared by every row
+ * (use-reduced-motion.ts), not one per row.
+ *
+ * Which of the two discloses the tail is `titleDisclosure` (title-reveal.ts), and
+ * they are alternatives: the tooltip covers the text the scroll cannot reach —
+ * callers without `scrollReveal`, and scroll-reveal rows under reduced motion,
+ * where the global `animation: none !important` block in styles.css disables the
+ * keyframes outright and leaves the plain ellipsis. Where the reveal does run, no
+ * `title` is attached: having both put a tooltip over the very text sliding past
+ * underneath it (#570). The full text always stays in the DOM either way, so the
+ * accessible name carries it whole no matter how much of it is visually clipped.
*/
import { useLayoutEffect, useRef, useState } from "react";
import type { CSSProperties } from "react";
-import { revealDistancePx, revealDurationMs } from "../../lib/title-reveal";
+import { revealDistancePx, revealDurationMs, titleDisclosure } from "../../lib/title-reveal";
+import { usePrefersReducedMotion } from "./use-reduced-motion";
export function Truncated({
text,
@@ -38,6 +45,7 @@ export function Truncated({
const ref = useRef<HTMLSpanElement>(null);
/** Measured overflow in px (0 = fits): > 0 drives both the `title` tooltip and the scroll distance. */
const [overflowPx, setOverflowPx] = useState(0);
+ const reducedMotion = usePrefersReducedMotion();
// className is also a dependency: when the caller switches to font-medium in the
// selected state, the font weight changes and content width (scrollWidth) changes
@@ -60,16 +68,20 @@ export function Truncated({
return () => ro.disconnect();
}, [text, className]);
- const overflowing = overflowPx > 0;
- // The scroll class and variables are attached only while there is something to
- // scroll: without them the styles.css rules match nothing, leaving exactly the
- // pre-#309 rendering (native ellipsis + conditional title) for titles that fit.
- const scrolling = scrollReveal && overflowing;
+ // One decision drives all three: the scroll class and its variables are attached
+ // only where the reveal will actually run, so anywhere else the styles.css rules
+ // match nothing and the row renders exactly as it did pre-#309 (native ellipsis
+ // plus the conditional title).
+ const disclosure = titleDisclosure({
+ overflowing: overflowPx > 0,
+ scrollReveal,
+ reducedMotion,
+ });
return (
<span
ref={ref}
- className={`truncate ${className}${scrolling ? " title-scroll" : ""}`}
- {...(scrolling
+ className={`truncate ${className}${disclosure === "scroll" ? " title-scroll" : ""}`}
+ {...(disclosure === "scroll"
? {
style: {
"--title-scroll-shift": `-${overflowPx}px`,
@@ -77,7 +89,7 @@ export function Truncated({
} as CSSProperties,
}
: {})}
- {...(overflowing ? { title: text } : {})}
+ {...(disclosure === "tooltip" ? { title: text } : {})}
>
{/* The scroll needs a child the keyframes can turn into an inline-block and
transform; at rest it renders inline, i.e. exactly like the bare text node
diff --git a/packages/web/src/components/ui/use-reduced-motion.ts b/packages/web/src/components/ui/use-reduced-motion.ts
index f6de6bc6..514c2292 100644
--- a/packages/web/src/components/ui/use-reduced-motion.ts
+++ b/packages/web/src/components/ui/use-reduced-motion.ts
@@ -2,21 +2,45 @@
* Whether the reader asked their system to reduce motion, as live state.
*
* `styles.css` already disables the app's CSS animations under that preference, so this hook is
- * for the motion CSS cannot reach: a spring driven frame by frame in JS. Its callers replace the
- * animation with the resting state it would have ended on — the sheet snaps to its target, the
- * dock launcher's ball jumps home and its fan opens and folds without one.
+ * for what CSS cannot reach on its own: motion driven frame by frame in JS, and the one
+ * disclosure that has to know whether the keyframes are running at all (truncated.tsx, #570).
+ * Its callers replace the animation with the resting state it would have ended on — the sheet
+ * snaps to its target, the dock launcher's ball jumps home and its fan opens and folds without
+ * one.
+ *
+ * One query and one listener for the whole app rather than one per component: `Truncated` reads
+ * this from every truncating row, and per-row media-query subscriptions are exactly what the
+ * scroll reveal was built to avoid (#309). Reading through `useSyncExternalStore` also closes
+ * the window a useState/useEffect pair leaves open, in which a change landing between the first
+ * render and the effect is never seen. The window guard keeps the module importable outside a
+ * browser, since the query is opened at import time.
*/
-import { useEffect, useState } from "react";
+import { useSyncExternalStore } from "react";
const QUERY = "(prefers-reduced-motion: reduce)";
+const query =
+ typeof window !== "undefined" && typeof window.matchMedia === "function"
+ ? window.matchMedia(QUERY)
+ : null;
+
+const listeners = new Set<() => void>();
+
+query?.addEventListener("change", () => {
+ for (const notify of listeners) notify();
+});
+
+function subscribe(onStoreChange: () => void): () => void {
+ listeners.add(onStoreChange);
+ return () => {
+ listeners.delete(onStoreChange);
+ };
+}
+
+function prefersReducedMotion(): boolean {
+ return query?.matches ?? false;
+}
+
export function usePrefersReducedMotion(): boolean {
- const [reduced, setReduced] = useState(() => window.matchMedia(QUERY).matches);
- useEffect(() => {
- const mq = window.matchMedia(QUERY);
- const onChange = (event: MediaQueryListEvent) => setReduced(event.matches);
- mq.addEventListener("change", onChange);
- return () => mq.removeEventListener("change", onChange);
- }, []);
- return reduced;
+ return useSyncExternalStore(subscribe, prefersReducedMotion, prefersReducedMotion);
}
diff --git a/packages/web/src/lib/title-reveal.ts b/packages/web/src/lib/title-reveal.ts
index 5dfb2578..dc0b7e18 100644
--- a/packages/web/src/lib/title-reveal.ts
+++ b/packages/web/src/lib/title-reveal.ts
@@ -1,7 +1,8 @@
/**
- * Pure math of the truncated-title scroll reveal (#309): whether a clipped title
- * actually overflows, how far it must travel to bring its tail into view, and how
- * long that travel should take. Kept out of truncated.tsx so the logic is
+ * Pure rules of the truncated-title scroll reveal (#309): whether a clipped title
+ * actually overflows, how far it must travel to bring its tail into view, how long
+ * that travel should take, and which of the reveal and the `title` tooltip is the
+ * one disclosing the tail (#570). Kept out of truncated.tsx so the logic is
* unit-testable (vitest runs node-only, no DOM) — the component feeds in the live
* scrollWidth/clientWidth and writes the results into CSS custom properties.
*/
@@ -41,3 +42,23 @@ export function revealDurationMs(distancePx: number): number {
const proportional = (distancePx / REVEAL_SPEED_PX_PER_S) * 1000;
return Math.round(Math.min(REVEAL_MAX_MS, Math.max(REVEAL_MIN_MS, proportional)));
}
+
+/** How a clipped title hands its tail over: the scroll, the native tooltip, or neither. */
+export type TitleDisclosure = "none" | "scroll" | "tooltip";
+
+/**
+ * The scroll and the `title` tooltip are alternatives, never a pair — a tooltip raised over a
+ * row that is already scrolling repeats the text sliding past underneath it (#570). The scroll
+ * takes the disclosure wherever it can actually run: a caller that asked for it, on text that
+ * really overflows, while the keyframes are enabled. The tooltip covers everything left over —
+ * callers without the reveal, and reveal rows under `prefers-reduced-motion`, where styles.css
+ * disables the keyframes outright and nothing would move.
+ */
+export function titleDisclosure(opts: {
+ overflowing: boolean;
+ scrollReveal: boolean;
+ reducedMotion: boolean;
+}): TitleDisclosure {
+ if (!opts.overflowing) return "none";
+ return opts.scrollReveal && !opts.reducedMotion ? "scroll" : "tooltip";
+}
diff --git a/packages/web/src/styles.css b/packages/web/src/styles.css
index e2536a3a..27b35763 100644
--- a/packages/web/src/styles.css
+++ b/packages/web/src/styles.css
@@ -384,10 +384,11 @@
in keyframes gets a no-op (ellipsis kept, `title` tooltip still there) instead of a
clipped-but-motionless title.
- Being an animation rather than a transition is what makes the reduced-motion path free: the
+ Being an animation rather than a transition is what keeps the reduced-motion path cheap: the
global `animation: none !important` block below disables the reveal outright, leaving the
- ellipsis and the `title` tooltip — no JS media query to subscribe to per row, nothing to go
- stale between render and effect.
+ ellipsis and the `title` tooltip that truncated.tsx hands back there (#570). Choosing between
+ the two is the only thing JS reads the preference for, and it reads it from one app-wide media
+ query (use-reduced-motion.ts) — still nothing subscribed per row.
:focus-visible (not :focus-within) scopes the keyboard trigger to actual keyboard focus;
inside :is() its selector is forgiving, so engines without :has() keep the hover trigger. */
diff --git a/packages/web/test/title-reveal.test.ts b/packages/web/test/title-reveal.test.ts
index f599f25a..93b63140 100644
--- a/packages/web/test/title-reveal.test.ts
+++ b/packages/web/test/title-reveal.test.ts
@@ -5,9 +5,11 @@
* must be exactly 0. Duration: proportional to the distance (constant reading
* speed), clamped between a floor (a sub-350ms hop reads as a glitch) and a
* ceiling (a huge title speeds up instead of holding the hover hostage), and 0
- * when there is nothing to scroll.
+ * when there is nothing to scroll. Disclosure: which of the scroll and the `title`
+ * tooltip reaches the tail (#570) — a rule rather than a number, but pure in the
+ * same way, so it is tested the same way.
*
- * The second half pins the CSS contract. The arithmetic was never the fragile
+ * The rest pins the CSS contract. The arithmetic was never the fragile
* part: the reveal only works while three files agree on four names, and nothing
* else in the suite notices if one side is renamed. vitest runs node-only here
* (`environment: "node"`, no jsdom), so these assert against the source text
@@ -24,6 +26,7 @@ import {
REVEAL_SPEED_PX_PER_S,
revealDistancePx,
revealDurationMs,
+ titleDisclosure,
} from "../src/lib/title-reveal";
describe("revealDistancePx", () => {
@@ -105,9 +108,10 @@ describe("the truncated-title reveal's CSS contract", () => {
});
it("moves the text with an animation, which is what reduced motion disables", () => {
- // The reduced-motion guarantee is the global `animation: none !important` block —
- // it does not gate on any JS state, but it only reaches animations. Rewriting this
- // as a transition would keep the visuals and silently lose reduced-motion support.
+ // The reduced-motion guarantee is the global `animation: none !important` block, and
+ // it only reaches animations: rewriting this as a transition would keep the visuals and
+ // silently lose reduced-motion support. JS reads the same preference, but only to decide
+ // which disclosure is live (titleDisclosure below) — never to start or stop the motion.
expect(trigger).toMatch(/animation: title-scroll-reveal var\(--title-scroll-ms/);
expect(trigger).not.toContain("transition:");
expect(css).toMatch(
@@ -132,3 +136,43 @@ describe("the truncated-title reveal's CSS contract", () => {
expect(trigger).toMatch(/animation:[^;}]*\blinear\b[^;}]*\b0\.3s\b[^;}]*\bforwards\b/);
});
});
+
+describe("titleDisclosure", () => {
+ it("discloses nothing for a title that fits", () => {
+ for (const scrollReveal of [false, true]) {
+ for (const reducedMotion of [false, true]) {
+ expect(titleDisclosure({ overflowing: false, scrollReveal, reducedMotion })).toBe("none");
+ }
+ }
+ });
+
+ it("gives a scrolling row the scroll alone", () => {
+ // The pair is what #570 reported: a tooltip raised over a row that is already scrolling
+ // repeats the text sliding past under the pointer.
+ expect(titleDisclosure({ overflowing: true, scrollReveal: true, reducedMotion: false })).toBe(
+ "scroll",
+ );
+ });
+
+ it("falls back to the tooltip once reduced motion stops the scroll", () => {
+ // styles.css disables the keyframes outright there, so the scroll is not an option and
+ // the tooltip is the only thing left that reaches the tail with a pointer.
+ expect(titleDisclosure({ overflowing: true, scrollReveal: true, reducedMotion: true })).toBe(
+ "tooltip",
+ );
+ });
+
+ it("leaves a caller that never asked for the scroll with its tooltip", () => {
+ for (const reducedMotion of [false, true]) {
+ expect(titleDisclosure({ overflowing: true, scrollReveal: false, reducedMotion })).toBe(
+ "tooltip",
+ );
+ }
+ });
+
+ it("is the one rule the component asks", () => {
+ // The cases above only bind the rendering while truncated.tsx routes through this rule
+ // instead of re-deriving it inline, where the two could drift apart.
+ expect(truncated).toContain("titleDisclosure({");
+ });
+});