From 9252bb565fd246ae792123786bfd837c858daa38 Mon Sep 17 00:00:00 2001 From: Badcuban <108198679+badcuban@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:12:17 -0500 Subject: [PATCH] fix(web): family tabs keep the lead whole and drop a shared topic On a crowded family row the "Lead" tab was cut to "L..." first. Every tab could shrink, and the browser shrank each one by its full title length, so the short lead tab lost its width fastest. The lead tab no longer shrinks, and the other tabs start from one 200px basis, so the longest titles give way first and cut tabs end up one width. Threads from one job usually share a topic ("Pull Station: ..."), which filled every tab before the cut. When two or more of a family's threads start with the same topic, their tabs and their rows under the parent in the sidebar now show only the rest. Both use one rule (familyTitles.logic) over the same members, so a tab and its row read the same. A one-word topic needs a separator after it, and a title keeps its full text when the rest would clash with another label or say almost nothing. Hover, screen readers and rename keep the full title. --- apps/server/src/guide/topics.ts | 2 +- .../components/ChatView.agents.browser.tsx | 84 ++++++++++++++++++ apps/web/src/components/Sidebar.logic.test.ts | 24 ++++- apps/web/src/components/Sidebar.logic.ts | 29 +++++- apps/web/src/components/Sidebar.tsx | 10 ++- apps/web/src/components/chat/FamilyTabs.tsx | 28 +++--- .../components/chat/familyTabs.logic.test.ts | 1 + .../src/components/chat/familyTabs.logic.ts | 15 +++- .../src/components/familyTitles.logic.test.ts | 62 +++++++++++++ apps/web/src/components/familyTitles.logic.ts | 88 +++++++++++++++++++ apps/web/src/components/sidebar/InboxRows.tsx | 33 ++++++- docs/design/lead-chat.md | 11 ++- 12 files changed, 364 insertions(+), 23 deletions(-) create mode 100644 apps/web/src/components/familyTitles.logic.test.ts create mode 100644 apps/web/src/components/familyTitles.logic.ts diff --git a/apps/server/src/guide/topics.ts b/apps/server/src/guide/topics.ts index 911656e47..484d0a0cd 100644 --- a/apps/server/src/guide/topics.ts +++ b/apps/server/src/guide/topics.ts @@ -94,7 +94,7 @@ Whether the thread's agent may bring in another model on its own is {place:threa id: "agent-threads", title: "Threads agents start", keywords: ["child thread", "subthread", "thread_start", "spawn", "parallel", "delegate"], - body: `An agent can start threads of its own to work in parallel, and message, read or stop them. Each started thread shows under its parent in the sidebar; its final reply comes back to the parent as a message, which wakes the parent's agent. The parent and the threads it started also show as a row of tabs under the chat header, on the parent and on each of its threads: a click opens that thread, with its own message box and draft. The row lists the threads the sidebar shows under the parent; one the user made its own, or whose parent is wrapped, has no row. + body: `An agent can start threads of its own to work in parallel, and message, read or stop them. Each started thread shows under its parent in the sidebar; its final reply comes back to the parent as a message, which wakes the parent's agent. The parent and the threads it started also show as a row of tabs under the chat header, on the parent and on each of its threads: a click opens that thread, with its own message box and draft. When two or more of the threads start their titles with the same topic ("Pull Station: ..."), their tabs and their rows under the parent in the sidebar leave it out, and hovering one shows the full title. The row lists the threads the sidebar shows under the parent; one the user made its own, or whose parent is wrapped, has no row. {place:threads.agentThreads} decides this: Off, Ask me first (a card in the chat lists the threads and you decide), or Automatic. The same setting covers agents creating or changing scheduled tasks. An agent may start at most 5 threads and send 10 messages to them per message you send. diff --git a/apps/web/src/components/ChatView.agents.browser.tsx b/apps/web/src/components/ChatView.agents.browser.tsx index c4ce72d4d..9ab45023d 100644 --- a/apps/web/src/components/ChatView.agents.browser.tsx +++ b/apps/web/src/components/ChatView.agents.browser.tsx @@ -1349,6 +1349,90 @@ describe("ChatView (full app): agent browser tabs and rooms", () => { } }); + it("keeps the lead's tab whole on a crowded row, drops a shared topic, and cuts long tabs to one width", async () => { + const titles = [ + "Panel Jam animation timing review", + "Panel Jam: council round two", + "Review: last three commits on main", + "Pull Station restructure: start the split", + "Pull Station: Android toolchain setup", + "Pull Station: UI polish pass after review", + ]; + const children = titles.map((_, index) => `thread-crowded-${index}` as ThreadId); + const base = children.reduce( + (snapshot, child) => addThreadToSnapshot(snapshot, child), + createSnapshotForTargetUser({ + targetMessageId: "msg-user-crowded-family" as MessageId, + targetText: "crowded family target", + }), + ); + const mounted = await mountChatView({ + viewport: { ...DEFAULT_VIEWPORT, width: 1_280 }, + snapshot: { + ...base, + projects: base.projects.map((project) => ({ ...project, leadThreadId: THREAD_ID })), + threads: base.threads.map((thread) => { + const index = children.indexOf(thread.id); + return index === -1 + ? thread + : { + ...thread, + title: titles[index]!, + parentThreadId: THREAD_ID, + attachedToParent: true, + createdAt: isoAt(10 + index), + }; + }), + }, + }); + const tabs = () => [ + ...document.querySelectorAll('[data-testid="family-tabs"] [role="tab"]'), + ]; + try { + await vi.waitFor(() => expect(tabs()).toHaveLength(1 + children.length), { + timeout: 10_000, + }); + const [leadTab, ...childTabs] = tabs(); + const labelOf = (tab: HTMLElement) => tab.querySelector("span.truncate")!; + // A topic two threads share is dropped from their tabs, and kept in the tooltip. + expect(childTabs.map((tab) => labelOf(tab).textContent)).toEqual([ + "Animation timing review", + "Council round two", + "Review: last three commits on main", + "Restructure: start the split", + "Android toolchain setup", + "UI polish pass after review", + ]); + expect(childTabs.map((tab) => tab.title)).toEqual(titles); + // "Lead" is never cut... + expect(labelOf(leadTab!).textContent).toBe("Lead"); + expect(labelOf(leadTab!).scrollWidth).toBeLessThanOrEqual(labelOf(leadTab!).clientWidth); + // ...and on a crowded row the cut tabs share one width, which no other tab passes. + const width = (tab: HTMLElement) => tab.getBoundingClientRect().width; + const cut = childTabs.filter((tab) => labelOf(tab).scrollWidth > labelOf(tab).clientWidth); + expect(cut.length).toBeGreaterThan(1); + const cutWidths = cut.map(width); + // Within a pixel: layout splits the row in fractions of one. + expect(Math.max(...cutWidths) - Math.min(...cutWidths)).toBeLessThan(1); + expect(childTabs.every((tab) => width(tab) < Math.max(...cutWidths) + 1)).toBe(true); + + // The sidebar's rows under the lead say the same, with the full title for screen readers. + await page.getByTestId(`thread-family-${THREAD_ID}`).click(); + const sidebarTitle = (child: ThreadId) => + document.querySelector(`[data-testid="child-title-${child}"]`); + await vi.waitFor(() => expect(sidebarTitle(children[4]!)).not.toBeNull(), { + timeout: 10_000, + }); + expect(sidebarTitle(children[4]!)!.querySelector(`[aria-hidden="true"]`)?.textContent).toBe( + "Android toolchain setup", + ); + expect(sidebarTitle(children[4]!)!.querySelector(".sr-only")?.textContent).toBe(titles[4]); + expect(sidebarTitle(children[2]!)!.textContent).toBe(titles[2]); + } finally { + await mounted.cleanup(); + } + }); + it("names the thread that started this one, in the header and on its request", async () => { const base = createSnapshotForTargetUser({ targetMessageId: "msg-user-started-by" as MessageId, diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.ts index 3b592ca18..ba28e7e9f 100644 --- a/apps/web/src/components/Sidebar.logic.test.ts +++ b/apps/web/src/components/Sidebar.logic.test.ts @@ -1937,10 +1937,15 @@ describe("child thread families", () => { deliveredAt?: string; seenAt?: string; wrappedByUser?: boolean; + title?: string; } = {}, ): Entry => ({ threadKey: id, - thread: { id: ThreadId.make(id), createdAt: options.createdAt ?? "2026-10-01T00:00:00.000Z" }, + thread: { + id: ThreadId.make(id), + createdAt: options.createdAt ?? "2026-10-01T00:00:00.000Z", + title: options.title ?? id, + }, status: options.status ?? null, isDone: options.done ?? false, settledAt: options.settledAt ?? options.createdAt ?? "2026-10-01T00:00:00.000Z", @@ -1969,6 +1974,22 @@ describe("child thread families", () => { sortDone: (heads) => [...heads], }); + it("shortens a family's titles over every child, drawn or folded, as the tabs do", () => { + const entries = [ + entry("lead"), + entry("android", { parent: "lead", title: "Pull Station: Android toolchain" }), + entry("polish", { parent: "lead", title: "Pull Station: UI polish pass" }), + entry("notes", { parent: "lead", title: "Write release notes" }), + ]; + // Folded, no child is drawn, but the labels stay what they are when open. + const [folded] = sections(entries).live; + expect(folded!.shownChildren).toEqual([]); + expect(Object.fromEntries(folded!.childShortTitles)).toEqual({ + android: "Android toolchain", + polish: "UI polish pass", + }); + }); + it("takes one seat per family and lists exactly the rows it draws", () => { // Children never stand as live rows of their own while their parent is // live; a family folds as one row, and the keyboard walks what is drawn. @@ -2310,6 +2331,7 @@ describe("families across computers", () => { thread: { id: ThreadId.make(id), createdAt: "2026-10-21T09:00:00.000Z", + title: id, environmentId, parentThreadId: options.childOf === undefined ? null : ThreadId.make(options.childOf), attachedToParent: options.childOf !== undefined, diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.ts index f21fe401c..3ccf35da5 100644 --- a/apps/web/src/components/Sidebar.logic.ts +++ b/apps/web/src/components/Sidebar.logic.ts @@ -24,6 +24,7 @@ import type { SidebarThreadSummary, Thread } from "../types"; import { isLatestTurnSettled, isWaitingOnBackgroundTasks } from "../session-logic"; import { startOfLocalDayMs } from "../timestampFormat"; import { nextCheckBack } from "./chat/checkBacks"; +import { shortFamilyTitles } from "./familyTitles.logic"; import { isHandedBackCompletion } from "@threadlines/shared/childThreads"; import { hasUnseenCompletion as hasUnseenCompletionSince, @@ -1606,7 +1607,7 @@ export interface InboxFamilyExit extends InboxFamilyStatus { /** What the family rules read about each inbox thread. */ export interface InboxFamilyEntry extends InboxFamilyExit { readonly threadKey: string; - readonly thread: Pick; + readonly thread: Pick; readonly seenAt: string | undefined; readonly wrappedByUser: boolean; } @@ -1701,6 +1702,12 @@ export interface InboxLiveRow { readonly remoteChildren: readonly InboxRemoteChild[]; /** The ones drawn: all while open, else only those that need the user. */ readonly shownRemoteChildren: readonly InboxRemoteChild[]; + /** + * What a child's row shows where its title shares a topic with its + * siblings' (`shortFamilyTitles`, as the family tabs do), by thread key. + * A child missing here shows its title. + */ + readonly childShortTitles: ReadonlyMap; /** A live child whose parent is wrapped stands on its own, naming the parent. */ readonly wrappedParent: E | null; /** @@ -1737,6 +1744,25 @@ export interface InboxDoneRow { readonly startedBy: E | null; } +const NO_SHORT_TITLES: ReadonlyMap = new Map(); + +/** A family's shortened child titles by thread key, over every member, drawn or folded. */ +function childShortTitlesOf( + children: readonly InboxFamilyEntry[], + remoteChildren: readonly InboxRemoteChild[], +): ReadonlyMap { + const members = [ + ...children.map((child) => ({ key: child.threadKey, title: child.thread.title })), + ...remoteChildren.map((child) => ({ key: child.threadKey, title: child.title })), + ]; + if (members.length < 2) return NO_SHORT_TITLES; + const short = shortFamilyTitles(members.map((member) => member.title)); + const changed = members.flatMap((member, index) => + short[index] === member.title ? [] : [[member.key, short[index]!] as const], + ); + return changed.length === 0 ? NO_SHORT_TITLES : new Map(changed); +} + const NEEDS_YOU_NOW: ReadonlySet = new Set([ "Pending Approval", "Awaiting Input", @@ -1995,6 +2021,7 @@ export function buildInboxSections(input: { shownChildren, remoteChildren, shownRemoteChildren, + childShortTitles: childShortTitlesOf(children, remoteChildren), wrappedParent, scopedOutParent, }; diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index e810dd0b0..686c3a322 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -2153,7 +2153,13 @@ export default function Sidebar() { ) : null} {section.rows.map( ( - { entry, shownChildren, shownRemoteChildren, wrappedParent }, + { + entry, + shownChildren, + shownRemoteChildren, + childShortTitles, + wrappedParent, + }, rowIndex, ) => ( @@ -2218,6 +2224,7 @@ export default function Sidebar() { ))} diff --git a/apps/web/src/components/chat/FamilyTabs.tsx b/apps/web/src/components/chat/FamilyTabs.tsx index 0e3af6a64..e067dd891 100644 --- a/apps/web/src/components/chat/FamilyTabs.tsx +++ b/apps/web/src/components/chat/FamilyTabs.tsx @@ -230,12 +230,12 @@ const FamilyTabButton = memo(function FamilyTabButton({ [openMenu], ); const touchHold = useTouchHoldMenu({ open: openMenu, onContextMenu }); - const label = - tab.kind === "parent" && tab.lead - ? `Lead: ${tab.title}` - : tab.statusWord !== null - ? `${tab.title}, ${tab.statusWord}` - : tab.title; + const isLeadTab = tab.kind === "parent" && tab.lead; + const label = isLeadTab + ? `Lead: ${tab.title}` + : tab.statusWord !== null + ? `${tab.title}, ${tab.statusWord}` + : tab.title; const tabButton = (showLeadCard: (() => void) | null) => ( ); - return tab.kind === "parent" && tab.lead && tab.threadRef !== null ? ( + return isLeadTab && tab.threadRef !== null ? ( ) : ( tabButton(null) diff --git a/apps/web/src/components/chat/familyTabs.logic.test.ts b/apps/web/src/components/chat/familyTabs.logic.test.ts index a3f42f165..f31db4729 100644 --- a/apps/web/src/components/chat/familyTabs.logic.test.ts +++ b/apps/web/src/components/chat/familyTabs.logic.test.ts @@ -116,6 +116,7 @@ describe("fitting the row", () => { threadRef: null, kind: "child", title: key, + shortTitle: key, lead: false, dotClass: null, statusWord: null, diff --git a/apps/web/src/components/chat/familyTabs.logic.ts b/apps/web/src/components/chat/familyTabs.logic.ts index 04fbfc5db..9ec78703d 100644 --- a/apps/web/src/components/chat/familyTabs.logic.ts +++ b/apps/web/src/components/chat/familyTabs.logic.ts @@ -19,6 +19,7 @@ import { isNeedsUserStatus, liveFamilyOf, } from "../Sidebar.logic"; +import { shortFamilyTitles } from "../familyTitles.logic"; /** One tab on the row. */ export interface FamilyTab { @@ -28,6 +29,11 @@ export interface FamilyTab { readonly threadRef: ScopedThreadRef | null; readonly kind: "parent" | "child"; readonly title: string; + /** + * What the tab itself shows: the title, less a topic it shares with other + * threads on the row (`shortFamilyTitles`, the sidebar's rule too). The tooltip keeps the title. + */ + readonly shortTitle: string; /** The parent is its project's lead chat: its tab is the flag and "Lead". */ readonly lead: boolean; /** A child's status dot class and word; null for the parent or a quiet child. */ @@ -100,6 +106,7 @@ export function familyTabsOf(input: { threadRef: scopeThreadRef(child.thread.environmentId, child.thread.id), kind: "child", title: child.thread.title, + shortTitle: child.thread.title, lead: false, dotClass: child.isDone ? null : (child.status?.dotClass ?? null), statusWord: child.isDone ? null : inboxStatusWord(child.status), @@ -113,6 +120,7 @@ export function familyTabsOf(input: { threadRef: null, kind: "child", title: child.title, + shortTitle: child.title, lead: false, dotClass: child.isDone ? null : (child.status?.dotClass ?? null), statusWord: child.isDone ? null : inboxStatusWord(child.status), @@ -121,6 +129,8 @@ export function familyTabsOf(input: { computerLabel: child.computerLabel, inbox: null, }); + const children = [...family.children.map(childTab), ...family.remoteChildren.map(remoteTab)]; + const shortTitles = shortFamilyTitles(children.map((tab) => tab.title)); return { familyKey: parent.threadKey, openKey: input.openKey, @@ -130,6 +140,7 @@ export function familyTabsOf(input: { threadRef: scopeThreadRef(parent.thread.environmentId, parent.thread.id), kind: "parent", title: parent.thread.title, + shortTitle: parent.thread.title, lead: parent.isLead === true, dotClass: null, statusWord: null, @@ -138,8 +149,7 @@ export function familyTabsOf(input: { computerLabel: null, inbox: { isDone: parent.isDone, canMarkDone: parent.canMarkDone === true }, }, - ...family.children.map(childTab), - ...family.remoteChildren.map(remoteTab), + ...children.map((tab, index) => ({ ...tab, shortTitle: shortTitles[index]! })), ], }; } @@ -157,6 +167,7 @@ export function sameFamilyTabs(left: FamilyTabs | null, right: FamilyTabs | null return ( tab.key === other.key && tab.title === other.title && + tab.shortTitle === other.shortTitle && tab.lead === other.lead && tab.dotClass === other.dotClass && tab.statusWord === other.statusWord && diff --git a/apps/web/src/components/familyTitles.logic.test.ts b/apps/web/src/components/familyTitles.logic.test.ts new file mode 100644 index 000000000..957a80e8c --- /dev/null +++ b/apps/web/src/components/familyTitles.logic.test.ts @@ -0,0 +1,62 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { shortFamilyTitles } from "./familyTitles.logic"; + +describe("short titles", () => { + it("drops a topic two or more siblings share, and leaves the rest whole", () => { + expect( + shortFamilyTitles([ + "Panel Jam animation timing review", + "Panel Jam: council round two", + "Review: last three commits on main", + "Pull Station restructure: start the split", + "Pull Station: Android toolchain setup", + "pull station - iOS build", + ]), + ).toEqual([ + "Animation timing review", + "Council round two", + "Review: last three commits on main", + "Restructure: start the split", + "Android toolchain setup", + "iOS build", + ]); + }); + + it("needs a separator to call shared words a topic, and a name to drop it without one", () => { + const plain = ["Fix the flaky test", "Fix the build"]; + expect(shortFamilyTitles(plain)).toEqual(plain); + expect(shortFamilyTitles([...plain, "Fix: release notes", "Fix: docs"])).toEqual([ + ...plain, + "Release notes", + "Docs", + ]); + }); + + it("keeps the full title where the rest would read the same as another tab, or say nothing", () => { + expect(shortFamilyTitles(["CLI: --verbose", "CLI: verbose", "Docs"])).toEqual([ + "--verbose", + "Verbose", + "Docs", + ]); + expect( + shortFamilyTitles(["Android: Build", "Android: Test", "iOS: Build", "iOS: Test", "Test"]), + ).toEqual(["Android: Build", "Android: Test", "iOS: Build", "iOS: Test", "Test"]); + expect(shortFamilyTitles(["Release: QA", "Release: Staging", "Release: x"])).toEqual([ + "QA", + "Staging", + "Release: x", + ]); + expect(shortFamilyTitles(["Docs: İstanbul setup", "Docs: Ankara setup"])).toEqual([ + "İstanbul setup", + "Ankara setup", + ]); + expect(shortFamilyTitles(["İstanbul: Android setup", "İstanbul: UI polish"])).toEqual([ + "Android setup", + "UI polish", + ]); + expect( + shortFamilyTitles(["Docs: Build", "Docs: Test", "Build", "Work: Docs: Build", "Work: Notes"]), + ).toEqual(["Docs: Build", "Test", "Build", "Work: Docs: Build", "Notes"]); + }); +}); diff --git a/apps/web/src/components/familyTitles.logic.ts b/apps/web/src/components/familyTitles.logic.ts new file mode 100644 index 000000000..0c5d97860 --- /dev/null +++ b/apps/web/src/components/familyTitles.logic.ts @@ -0,0 +1,88 @@ +/** + * Short titles for a family's threads (docs/design/lead-chat.md, "Family + * tabs"): the family tabs and the sidebar's rows under a parent show each + * started thread without the topic it shares with its siblings. Both call + * this over the same members, so they agree on every label. + */ + +/** The first separator in a title, which ends its topic: "Topic: rest", "Topic - rest", "Topic | rest". */ +const FIRST_SEPARATOR = /:\s|\s[-–—|/]\s/; +/** That separator, right after a topic. */ +const SEPARATOR_AFTER_TOPIC = /^(?::\s+|\s+[-–—|/]\s+)/; +/** A topic longer than this is a sentence, not a name. */ +const TOPIC_MAX_CHARS = 40; +/** A shortened title shorter than this says too little; the tab keeps its title. */ +const SHORT_TITLE_MIN_CHARS = 2; + +/** + * The siblings' titles without the topic they share, so each tab shows what + * tells it apart: "Pull Station: Android toolchain setup" and "Pull Station: + * UI polish pass" become "Android toolchain setup" and "UI polish pass". + * + * A topic is the words before the first separator of a title, and it is + * shared once two or more titles start with it. A topic of two or more words + * is a name, so a title counts when it goes straight on from it ("Pull Station + * restructure: start" becomes "Restructure: start"); a one-word topic is often + * a verb ("Fix"), so only titles with the separator after it count. A title keeps its full text when what is left would be under two + * characters or would read the same as another tab's. + */ +export function shortFamilyTitles(titles: readonly string[]): readonly string[] { + // A topic as it was written (`length`, in the title's own characters) and in lower case + // (`key`, which can be longer: "İ" lowers to two). + interface Topic { + readonly key: string; + readonly length: number; + } + // Where the text after `topic` starts in `title`, or null when the topic doesn't lead it. + const cutAfter = (title: string, topic: Topic): number | null => { + if (title.slice(0, topic.length).toLowerCase() !== topic.key) return null; + const after = title.slice(topic.length); + const separator = SEPARATOR_AFTER_TOPIC.exec(after); + if (separator !== null) return topic.length + separator[0].length; + const space = /^\s+(?=\S)/.exec(after); + return space !== null && /\s/.test(topic.key) ? topic.length + space[0].length : null; + }; + const shared = new Map(); + for (const title of titles) { + const end = title.search(FIRST_SEPARATOR); + if (end < 1 || end > TOPIC_MAX_CHARS) continue; + const written = title.slice(0, end).trimEnd(); + const topic = { key: written.toLowerCase(), length: written.length }; + if (topic.key === "" || shared.has(topic.key)) continue; + if (titles.filter((other) => cutAfter(other, topic) !== null).length >= 2) { + shared.set(topic.key, topic); + } + } + if (shared.size === 0) return titles; + const labels = titles.map((title) => { + let cut: number | null = null; + let longest = 0; + for (const topic of shared.values()) { + if (topic.length <= longest) continue; + const at = cutAfter(title, topic); + if (at !== null) [cut, longest] = [at, topic.length]; + } + if (cut === null) return title; + const rest = title.slice(cut).trimEnd(); + if (rest.length < SHORT_TITLE_MIN_CHARS) return title; + // "council round two" reads as a label once capitalised; "iOS build" is left alone. + return /^[a-z]+\b/.test(rest) ? rest.charAt(0).toUpperCase() + rest.slice(1) : rest; + }); + // Two that would read the same keep their full titles. A title put back can + // clash in turn ("Docs: Build" beside "Work: Docs: Build"), so repeat until none do. + for (let clashed = true; clashed;) { + clashed = false; + const counts = new Map(); + for (const label of labels) { + const key = label.toLowerCase(); + counts.set(key, (counts.get(key) ?? 0) + 1); + } + labels.forEach((label, index) => { + if (label !== titles[index] && counts.get(label.toLowerCase())! > 1) { + labels[index] = titles[index]!; + clashed = true; + } + }); + } + return labels; +} diff --git a/apps/web/src/components/sidebar/InboxRows.tsx b/apps/web/src/components/sidebar/InboxRows.tsx index 09be99148..b8dd65ea7 100644 --- a/apps/web/src/components/sidebar/InboxRows.tsx +++ b/apps/web/src/components/sidebar/InboxRows.tsx @@ -1367,6 +1367,8 @@ export const InboxThreadRow = memo(function InboxThreadRow(props: InboxThreadRow export interface InboxChildRowProps { thread: SidebarThreadSummary; + /** Its title without the topic its siblings share (`childShortTitles`); absent: the title. */ + shortTitle?: string | undefined; status: ThreadStatusPill | null; /** Filed under Wrapped: a grey check, the time it was wrapped, and reopen on hover. */ isDone: boolean; @@ -1411,9 +1413,31 @@ export interface InboxChildRowProps { * thread from another computer shows, or with a computer glyph when it runs * here and its parent is the one elsewhere. */ +/** + * A started thread's title under its parent: the short one on screen when + * its siblings share a topic (`childShortTitles`), the full one for screen + * readers. + */ +function FamilyChildTitle({ + title, + shortTitle, +}: { + title: string; + shortTitle: string | undefined; +}) { + if (shortTitle === undefined) return title; + return ( + <> + + {title} + + ); +} + export const InboxChildRow = memo(function InboxChildRow(props: InboxChildRowProps) { const { thread, + shortTitle, status, isDone, doneAt, @@ -1614,7 +1638,7 @@ export const InboxChildRow = memo(function InboxChildRow(props: InboxChildRowPro )} data-testid={`child-title-${thread.id}`} > - {thread.title} + )} @@ -1704,9 +1728,12 @@ export const InboxChildRow = memo(function InboxChildRow(props: InboxChildRowPro */ export const InboxRemoteChildRow = memo(function InboxRemoteChildRow({ child, + shortTitle, onSetDone, }: { child: InboxRemoteChild; + /** See InboxChildRowProps.shortTitle. */ + shortTitle?: string | undefined; /** Wraps it up or reopens it; absent: the row has no button. */ onSetDone?: RemoteChildSetDone | undefined; }) { @@ -1741,8 +1768,10 @@ export const InboxRemoteChildRow = memo(function InboxRemoteChildRow({ "min-w-0 flex-1 truncate text-xs leading-4", child.isDone ? "text-muted-foreground/80" : "text-foreground/85", )} + // No hover card here: the full title shows on hover this way. + title={child.title} > - {child.title} + {showAction ? ( diff --git a/docs/design/lead-chat.md b/docs/design/lead-chat.md index d48d3a096..76d6ca6d4 100644 --- a/docs/design/lead-chat.md +++ b/docs/design/lead-chat.md @@ -173,10 +173,17 @@ always one click away, and so is every thread it started. today's "Started by" chip. - **A tab.** The parent's tab is its title; a lead's is the crown and "Lead". A child's is its status dot (the family child rows' colours and words; a check once wrapped - and still in the family) and its title. The open one has a quiet fill. Hover is a + and still in the family) and its title. When two or more children's titles start with the same topic + (the words before a separator in one of them, such as "Pull Station:"), their tabs + drop it and show the rest; the tooltip and the "+N" menu keep the full title. A + one-word topic ("Fix:") counts only where the separator follows it, and a tab keeps + its full title when the rest would read the same as another tab's. The sidebar's rows + under the parent use the same rule over the same members, so a row and its tab + always read the same. The open one has a quiet fill. Hover is a colour shift. Right-click or a long press opens the sidebar's thread menu. There is no close button: a tab is not an open file, and wrapping up stays in the menu. -- **Too many to fit.** Tabs shrink to a floor (about 96px), then the rest move behind +- **Too many to fit.** The longest titles give way first, so crowded tabs end up one + width; the lead's crown and "Lead" never shrink. Tabs shrink to a floor (about 96px), then the rest move behind a "+N" menu at the end of the row, which lists them with their status. The open thread's tab is always on the row. "+N" carries an amber dot when a hidden thread needs the user. On a phone the row scrolls sideways instead and the open tab is