From 281a70e7812fda42a8b07d878c64a0e286c2a8ec Mon Sep 17 00:00:00 2001 From: pdolega Date: Tue, 15 Sep 2026 15:27:34 +0200 Subject: [PATCH] feat(desktop): qualify pinned sidebar rows with their project name The PINNED section lifts a workspace out of its project group, which is the point, but it also strips the only thing that said which project the row belongs to. Every project's main workspace is named "local", so two pinned mains render as two identical rows distinguished only by a 14px generated avatar. pinnedContext already carried projectName alongside projectIconUrl and only the icon was ever rendered. Render the name too, dimmed, as a path-style prefix: "Flamaster/local". The prefix goes inside the marquee's scrolling span rather than beside it, so overflow measurement, the hover-scroll reveal and the title attribute all operate on the full label instead of just the tail. Closes #7574 --- .../WorkspaceNameMarquee.test.tsx | 70 +++++++++++++++++++ .../WorkspaceNameMarquee.tsx | 14 +++- .../DashboardSidebarExpandedWorkspaceRow.tsx | 8 +++ 3 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 apps/desktop/src/renderer/components/WorkspaceNameMarquee/WorkspaceNameMarquee.test.tsx diff --git a/apps/desktop/src/renderer/components/WorkspaceNameMarquee/WorkspaceNameMarquee.test.tsx b/apps/desktop/src/renderer/components/WorkspaceNameMarquee/WorkspaceNameMarquee.test.tsx new file mode 100644 index 00000000000..47b1b34419a --- /dev/null +++ b/apps/desktop/src/renderer/components/WorkspaceNameMarquee/WorkspaceNameMarquee.test.tsx @@ -0,0 +1,70 @@ +import { afterAll, afterEach, describe, expect, test } from "bun:test"; +import { GlobalRegistrator } from "@happy-dom/global-registrator"; + +// happy-dom over the preloaded plain-object document — the marquee measures +// scrollWidth/clientWidth through refs and a ResizeObserver, so it needs a +// real DOM. Bun runs test files sequentially in one process and happy-dom's +// globals are process-wide, so we MUST unregister in afterAll to restore the +// shared mock document for the other renderer suites. +const alreadyRegistered = GlobalRegistrator.isRegistered; +if (!alreadyRegistered) GlobalRegistrator.register(); +( + globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean } +).IS_REACT_ACT_ENVIRONMENT = true; + +const { cleanup, render } = await import("@testing-library/react"); +const { WorkspaceNameMarquee } = await import("./WorkspaceNameMarquee"); + +afterEach(cleanup); +afterAll(async () => { + if (!alreadyRegistered) await GlobalRegistrator.unregister(); +}); + +describe("WorkspaceNameMarquee", () => { + test("renders the bare name when no prefix is given", () => { + const { container } = render(); + + const marquee = container.firstElementChild as HTMLElement; + expect(marquee.textContent).toBe("local"); + expect(marquee.title).toBe("local"); + }); + + test("prepends the prefix and a separator to the name", () => { + const { container } = render( + , + ); + + expect((container.firstElementChild as HTMLElement).textContent).toBe( + "Flamaster/local", + ); + }); + + test("titles the whole prefixed label so a clipped row still reads in full", () => { + const { container } = render( + , + ); + + expect((container.firstElementChild as HTMLElement).title).toBe( + "Bifrost/basic_optimization", + ); + }); + + test("dims the prefix so the workspace name stays the prominent half", () => { + const { container } = render( + , + ); + + const prefix = container.querySelector(".text-muted-foreground"); + expect(prefix?.textContent).toBe("Flamaster/"); + }); + + test("ignores an empty prefix", () => { + const { container } = render( + , + ); + + const marquee = container.firstElementChild as HTMLElement; + expect(marquee.textContent).toBe("local"); + expect(marquee.title).toBe("local"); + }); +}); diff --git a/apps/desktop/src/renderer/components/WorkspaceNameMarquee/WorkspaceNameMarquee.tsx b/apps/desktop/src/renderer/components/WorkspaceNameMarquee/WorkspaceNameMarquee.tsx index 41bc2c8a2aa..fcfab9b6cf3 100644 --- a/apps/desktop/src/renderer/components/WorkspaceNameMarquee/WorkspaceNameMarquee.tsx +++ b/apps/desktop/src/renderer/components/WorkspaceNameMarquee/WorkspaceNameMarquee.tsx @@ -14,6 +14,9 @@ const EDGE_FADE_PX = 14; interface WorkspaceNameMarqueeProps { name: string; + /** Qualifier shown dimmed ahead of the name as `prefix/name`, for rows + * that sit outside the grouping that would otherwise identify them. */ + prefix?: string; className?: string; /** Reveals the name the same way hover does, driven by the row's own * focus state — the row (not this span) is the tabbable element, so a @@ -38,6 +41,7 @@ interface WorkspaceNameMarqueeProps { */ export function WorkspaceNameMarquee({ name, + prefix, className, forceActive = false, }: WorkspaceNameMarqueeProps) { @@ -45,6 +49,7 @@ export function WorkspaceNameMarquee({ const textRef = useRef(null); const [overflow, setOverflow] = useState(0); const [hovered, setHovered] = useState(false); + const label = prefix ? `${prefix}/${name}` : name; const measureOverflow = useCallback(() => { const container = containerRef.current; @@ -55,7 +60,7 @@ export function WorkspaceNameMarquee({ }, []); useLayoutEffect(() => { - if (!name) return; + if (!label) return; measureOverflow(); const container = containerRef.current; if (!container || typeof ResizeObserver === "undefined") return; @@ -65,7 +70,7 @@ export function WorkspaceNameMarquee({ const observer = new ResizeObserver(measureOverflow); observer.observe(container); return () => observer.disconnect(); - }, [name, measureOverflow]); + }, [label, measureOverflow]); const active = (hovered || forceActive) && overflow > 0; const canScroll = overflow > 0; @@ -78,7 +83,7 @@ export function WorkspaceNameMarquee({ // biome-ignore lint/a11y/noStaticElementInteractions: decorative hover reveal, not a control — the full name is already in the DOM for assistive tech regardless of the CSS transform. + {prefix && ( + {`${prefix}/`} + )} {name} diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarWorkspaceItem/components/DashboardSidebarExpandedWorkspaceRow/DashboardSidebarExpandedWorkspaceRow.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarWorkspaceItem/components/DashboardSidebarExpandedWorkspaceRow/DashboardSidebarExpandedWorkspaceRow.tsx index 821092197ef..96a8781d907 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarWorkspaceItem/components/DashboardSidebarExpandedWorkspaceRow/DashboardSidebarExpandedWorkspaceRow.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarWorkspaceItem/components/DashboardSidebarExpandedWorkspaceRow/DashboardSidebarExpandedWorkspaceRow.tsx @@ -348,6 +348,14 @@ export const DashboardSidebarExpandedWorkspaceRow = forwardRef< <>