🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(sidebar): show path group titles tail-first with a hover marquee (#20955)
Arvin Xu3e0a28638a67
diff --git a/src/components/TailMarquee/index.tsx b/src/components/TailMarquee/index.tsxnew file mode 100644index 00000000000..81229b905ef--- /dev/null+++ b/src/components/TailMarquee/index.tsx@@ -0,0 +1,157 @@+import { createStaticStyles, cx, keyframes } from 'antd-style';+import {+ type CSSProperties,+ type PointerEvent,+ type ReactNode,+ useLayoutEffect,+ useRef,+ useState,+} from 'react';++import { getMarqueeDuration, HOLD_RATIO, shouldRevealOnPointerDown } from './utils';++const HOLD = HOLD_RATIO * 100;++// Hold at the tail, scroll to the head, hold, scroll back.+const scrollToHead = keyframes`+ 0%,+ ${HOLD}% {+ transform: translateX(0);+ }++ ${50 - HOLD / 2}%,+ ${50 + HOLD / 2}% {+ transform: translateX(var(--tail-marquee-offset));+ }++ ${100 - HOLD}%,+ 100% {+ transform: translateX(0);+ }+`;++const styles = createStaticStyles(({ css }) => ({+ container: css`+ /* Paths read left to right in every locale; the alignment, fade and+ translate below all assume LTR, so pin it even inside an RTL page. */+ direction: ltr;+ unicode-bidi: isolate;+ overflow: hidden;+ display: flex;+ flex: 1;+ justify-content: flex-end;++ min-width: 0;+ `,+ overflowing: css`+ mask-image: linear-gradient(to right, transparent, #000 16px);++ /* Keyboard focus on the enclosing control (e.g. an accordion trigger)+ loops; a tap on a touch screen plays one loop. */+ *:focus-visible > &,+ *:focus-visible > * > &,+ &[data-revealing] {+ mask-image: none;+ }++ *:focus-visible > & > span,+ *:focus-visible > * > & > span {+ animation: ${scrollToHead} var(--tail-marquee-duration) ease-in-out infinite;+ }++ &[data-revealing] > span {+ animation: ${scrollToHead} var(--tail-marquee-duration) ease-in-out 1;+ }++ /* Only real hover loops: touch browsers keep a sticky :hover after a tap,+ which would otherwise turn the one-loop tap reveal into an endless one. */+ @media (hover: hover) {+ &:hover {+ mask-image: none;+ }++ &:hover > span {+ animation: ${scrollToHead} var(--tail-marquee-duration) ease-in-out infinite;+ }+ }++ @media (prefers-reduced-motion: reduce) {+ & > span {+ animation: none !important;+ }+ }+ `,+ content: css`+ flex: none;+ white-space: nowrap;+ `,+}));++interface TailMarqueeProps {+ children: ReactNode;+ className?: string;+ style?: CSSProperties;+}++/**+ * Single-line text that keeps its tail visible when it overflows (paths read+ * from the end), and scrolls back to the head on hover, on keyboard focus of+ * the enclosing control, or once per tap on touch screens. The full text is+ * also exposed as a native tooltip.+ */+const TailMarquee = ({ children, className, style }: TailMarqueeProps) => {+ const containerRef = useRef<HTMLDivElement>(null);+ const contentRef = useRef<HTMLSpanElement>(null);+ const [overflow, setOverflow] = useState(0);+ const [fullText, setFullText] = useState<string>();+ const [revealing, setRevealing] = useState(false);++ useLayoutEffect(() => {+ const container = containerRef.current;+ const content = contentRef.current;+ if (!container || !content) return;++ const measure = () => {+ setOverflow(Math.max(0, content.offsetWidth - container.clientWidth));+ setFullText(content.textContent ?? undefined);+ };+ measure();++ const observer = new ResizeObserver(measure);+ observer.observe(container);+ observer.observe(content);+ return () => observer.disconnect();+ }, []);++ const handlePointerDown = (event: PointerEvent) => {+ const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;+ if (shouldRevealOnPointerDown({ overflow, pointerType: event.pointerType, reducedMotion }))+ setRevealing(true);+ };++ const duration = getMarqueeDuration(overflow);++ return (+ <div+ className={cx(styles.container, overflow > 0 && styles.overflowing, className)}+ data-revealing={revealing || undefined}+ ref={containerRef}+ title={overflow > 0 ? fullText : undefined}+ style={+ {+ ...style,+ '--tail-marquee-duration': `${duration}s`,+ '--tail-marquee-offset': `${overflow}px`,+ } as CSSProperties+ }+ onAnimationEnd={() => setRevealing(false)}+ onPointerDown={handlePointerDown}+ >+ <span className={styles.content} ref={contentRef}>+ {children}+ </span>+ </div>+ );+};++export default TailMarquee;diff --git a/src/components/TailMarquee/utils.test.ts b/src/components/TailMarquee/utils.test.tsnew file mode 100644index 00000000000..e49c053e28f--- /dev/null+++ b/src/components/TailMarquee/utils.test.ts@@ -0,0 +1,35 @@+import { describe, expect, it } from 'vitest';++import { getMarqueeDuration, shouldRevealOnPointerDown } from './utils';++describe('getMarqueeDuration', () => {+ it('scrolls both ways at 40px/s within the 40% of the loop left after the holds', () => {+ // 186px each way = 9.3s of scrolling, which is 40% of the loop.+ expect(getMarqueeDuration(186)).toBeCloseTo(23.25);+ });++ it('never drops below 3s for short overflows', () => {+ expect(getMarqueeDuration(4)).toBe(3);+ });+});++describe('shouldRevealOnPointerDown', () => {+ const base = { overflow: 186, pointerType: 'touch', reducedMotion: false };++ it('reveals on a touch tap when text overflows', () => {+ expect(shouldRevealOnPointerDown(base)).toBe(true);+ });++ it('leaves mouse and pen to the hover rule', () => {+ expect(shouldRevealOnPointerDown({ ...base, pointerType: 'mouse' })).toBe(false);+ expect(shouldRevealOnPointerDown({ ...base, pointerType: 'pen' })).toBe(false);+ });++ it('does nothing when the text fits', () => {+ expect(shouldRevealOnPointerDown({ ...base, overflow: 0 })).toBe(false);+ });++ it('does nothing under reduced motion', () => {+ expect(shouldRevealOnPointerDown({ ...base, reducedMotion: true })).toBe(false);+ });+});diff --git a/src/components/TailMarquee/utils.ts b/src/components/TailMarquee/utils.tsnew file mode 100644index 00000000000..b067bddaa00--- /dev/null+++ b/src/components/TailMarquee/utils.ts@@ -0,0 +1,25 @@+// Scroll speed of the marquee, in px per second.+const SCROLL_SPEED = 40;+// Share of one loop spent on each of the three holds (tail, head, tail), so+// both ends stay readable.+export const HOLD_RATIO = 0.2;+const MIN_DURATION = 3;++/** Seconds for one tail → head → tail loop over `overflow` hidden pixels. */+export const getMarqueeDuration = (overflow: number): number =>+ Math.max(MIN_DURATION, (overflow * 2) / SCROLL_SPEED / (1 - HOLD_RATIO * 3));++/**+ * Touch screens have no hover, so a tap plays one loop instead. Skipped when+ * nothing is hidden, and under reduced motion, where no animation would end+ * the reveal.+ */+export const shouldRevealOnPointerDown = ({+ overflow,+ pointerType,+ reducedMotion,+}: {+ overflow: number;+ pointerType: string;+ reducedMotion: boolean;+}): boolean => pointerType === 'touch' && overflow > 0 && !reducedMotion;diff --git a/src/features/AgentSidebar/Topic/TopicListContent/ByProjectMode/GroupItem.tsx b/src/features/AgentSidebar/Topic/TopicListContent/ByProjectMode/GroupItem.tsxindex 8e3ff0ca9d4..511bbb50838 100644--- a/src/features/AgentSidebar/Topic/TopicListContent/ByProjectMode/GroupItem.tsx+++ b/src/features/AgentSidebar/Topic/TopicListContent/ByProjectMode/GroupItem.tsx@@ -31,6 +31,7 @@ import { useActiveWorkspaceSlug } from '@/business/client/hooks/useActiveWorkspaimport Avatar from '@/components/Avatar';import { TOPIC_STATUS_VISUALS } from '@/components/ExecutionStatus';import RingLoadingIcon from '@/components/RingLoading';+import TailMarquee from '@/components/TailMarquee';import UnreadDot from '@/components/UnreadDot';import { useCommitWorkingDirectory } from '@/features/ChatInput/ControlBar/useCommitWorkingDirectory';import { AgentDirectoryActions } from '@/features/Projects/WorkingDirectories/AgentDirectoryActions';@@ -112,13 +113,23 @@ const styles = createStaticStyles(({ css }) => ({max-width 150ms ${cssVar.motionEaseOut},opacity 150ms ${cssVar.motionEaseOut};- /* Holds the grouping menu, the "more" menu and the start "+" (3 × 24px) */+ /* Holds the grouping menu, the "more" menu and the start "+" (3 × 24px).+ Stays open while one of its menus is, so the popup keeps its anchor. */&:focus-within,+ &:has([data-popup-open]),.accordion-header:hover & {pointer-events: auto;max-width: 72px;opacity: 1;}++ /* Touch-only screens have no hover to reveal the actions with, so they+ keep their width there, as before the actions collapsed at rest. */+ @media (hover: none) {+ pointer-events: auto;+ max-width: 72px;+ opacity: 1;+ }`,}));@@ -371,12 +382,14 @@ const GroupItem = memo<GroupItemComponentProps>(({ group, expanded }) => {const hasCollapsedIndicators = hasCollapsedStatus || hasCollapsedUnread;const ProjectFolderIcon = expanded ? FolderOpenIcon : FolderClosedIcon;// Sub-grouping is its own row action: it needs no directory, so it stays- // available even when the directory actions below can't render.+ // available even when the directory actions below can't render. The buttons+ // collapse to zero width until the row is hovered, so a resting title gets+ // the full row instead of a gap reserved for invisible actions.const action = (<Flexbox horizontal align={'center'} gap={4}>{hasCollapsedStatus && <CollapsedStatusBadges counts={statusCounts} />}{hasCollapsedUnread && <CollapsedUnreadDot count={unreadCount} />}- <span className={hasCollapsedIndicators ? styles.addTopicAction : undefined}>+ <span className={styles.addTopicAction}><DropdownMenu items={subGroupMenuItems}><ActionIconicon={ListFilter}@@ -439,40 +452,44 @@ const GroupItem = memo<GroupItemComponentProps>(({ group, expanded }) => {/>)}</Center>- <Text- ellipsis- fontSize={14}- style={{ color: project ? cssVar.colorText : cssVar.colorTextSecondary, flex: 1 }}- >- {project && !scope ? (- <a- style={{ color: 'inherit', textDecoration: 'none' }}- href={buildWorkspaceAwarePath(- `/project/${project.projectSlug ?? project.projectId}`,- activeWorkspaceSlug,- )}- onClick={(event) => {- // Keep the accordion closed either way; leave modified clicks- // (new tab / window) to the browser's native link handling.- event.stopPropagation();- if (- event.button !== 0 ||- event.metaKey ||- event.ctrlKey ||- event.shiftKey ||- event.altKey- )- return;- event.preventDefault();- navigate(`/project/${project.projectSlug ?? project.projectId}`);- }}- >- {project.projectName}- </a>- ) : (- title- )}- </Text>+ {project ? (+ <Text ellipsis fontSize={14} style={{ color: cssVar.colorText, flex: 1 }}>+ {scope ? (+ title+ ) : (+ <a+ style={{ color: 'inherit', textDecoration: 'none' }}+ href={buildWorkspaceAwarePath(+ `/project/${project.projectSlug ?? project.projectId}`,+ activeWorkspaceSlug,+ )}+ onClick={(event) => {+ // Keep the accordion closed either way; leave modified clicks+ // (new tab / window) to the browser's native link handling.+ event.stopPropagation();+ if (+ event.button !== 0 ||+ event.metaKey ||+ event.ctrlKey ||+ event.shiftKey ||+ event.altKey+ )+ return;+ event.preventDefault();+ navigate(`/project/${project.projectSlug ?? project.projectId}`);+ }}+ >+ {project.projectName}+ </a>+ )}+ </Text>+ ) : (+ // A bare path reads from its end: keep the tail in view and+ // scroll to the head on hover.+ <TailMarquee style={{ color: cssVar.colorTextSecondary, fontSize: 14 }}>+ {title}+ </TailMarquee>+ )}</Flexbox></AccordionTrigger><div