Skip to content

Commit 7108d6e

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
refactor(emcn): own shared shimmer text treatment
1 parent 316fea0 commit 7108d6e

12 files changed

Lines changed: 69 additions & 55 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/agent-group/tool-call-item.test.tsx‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @vitest-environment jsdom
33
*/
4-
import { act, type ReactNode, type SVGProps } from 'react'
4+
import { act, type SVGProps } from 'react'
55
import { createRoot, type Root } from 'react-dom/client'
66
import { renderToStaticMarkup } from 'react-dom/server'
77
import { beforeEach, describe, expect, it, vi } from 'vitest'
@@ -11,10 +11,6 @@ import type { ToolCallData } from '@/app/workspace/[workspaceId]/home/types'
1111
import { notifyBlockOverlayChanged } from '@/blocks/custom/client-overlay'
1212
import { getBlock, getBlockByToolName } from '@/blocks/registry'
1313

14-
vi.mock('@/components/ui', () => ({
15-
ShimmerText: ({ children }: { children: ReactNode }) => <span>{children}</span>,
16-
}))
17-
1814
describe('ToolCallItem', () => {
1915
beforeEach(() => {
2016
vi.clearAllMocks()

‎apps/sim/components/agent-stream/agent-stream-chrome.test.tsx‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
77

88
vi.mock('@sim/emcn', () => ({
99
cn: (...args: unknown[]) => args.filter(Boolean).join(' '),
10-
}))
11-
12-
vi.mock('@/lib/mothership/tools/tool-display', () => ({
13-
humanizeToolName: (name: string) => name,
14-
}))
15-
16-
vi.mock('@/components/ui', () => ({
1710
ShimmerText: ({
1811
as: Comp = 'span',
1912
children,
@@ -34,6 +27,10 @@ vi.mock('@/components/ui', () => ({
3427
},
3528
}))
3629

30+
vi.mock('@/lib/mothership/tools/tool-display', () => ({
31+
humanizeToolName: (name: string) => name,
32+
}))
33+
3734
import {
3835
AgentStreamThinkingChrome,
3936
AgentStreamToolCallsChrome,

‎apps/sim/components/agent-stream/agent-stream-chrome.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
'use client'
22

33
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
4-
import { cn } from '@sim/emcn'
4+
import { cn, ShimmerText } from '@sim/emcn'
55
import { Check, ChevronDown, Circle, Square, X } from '@sim/emcn/icons'
66
import type {
77
AgentStreamToolCall,
88
AgentStreamToolStatus,
99
} from '@/components/agent-stream/tool-call-lifecycle'
10-
import { ShimmerText } from '@/components/ui'
1110
import { humanizeToolName } from '@/lib/mothership/tools/tool-display'
1211

1312
/** Distance from bottom (px) within which we keep following new thinking text. */

‎apps/sim/components/ui/activity-status.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { ReactNode } from 'react'
2-
import { cn, OverflowText } from '@sim/emcn'
3-
import { ShimmerText } from '@/components/ui/shimmer-text'
2+
import { cn, OverflowText, ShimmerText } from '@sim/emcn'
43

54
/** The icon column every activity row shares, sized for the default 14px icon. */
65
export const ACTIVITY_ICON_SLOT_CLASS = 'flex size-[14px] shrink-0 items-center justify-center'

‎apps/sim/components/ui/index.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ export {
1313
SelectTrigger,
1414
SelectValue,
1515
} from './select'
16-
export { ShimmerText } from './shimmer-text'
1716
export { ThinkingLoader, type ThinkingLoaderVariant } from './thinking-loader'

‎apps/sim/components/ui/shimmer-text.tsx‎

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎apps/sim/components/ui/thinking-loader.module.css‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,9 @@
7979
white-space: nowrap;
8080
}
8181

82-
/* The sweeping-band treatment itself (gradient, timing, dark mode, reduced
83-
motion) is owned by the shared shimmer-text module; this class only adds the
84-
loader-scaled font sizing. Canonical normal weight per emcn rules: body text
85-
is 400, never medium. */
82+
/* ShimmerText owns the gradient, timing, dark mode, and reduced motion. This
83+
class only adds loader-scaled font sizing and canonical normal weight. */
8684
.label {
87-
composes: shimmer from "./shimmer-text.module.css";
8885
font-size: var(--tl-label-size, 14px);
8986
font-weight: 400;
9087
}

‎apps/sim/components/ui/thinking-loader.tsx‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { type CSSProperties, type ReactNode, useEffect, useId, useState } from 'react'
4-
import { cn } from '@sim/emcn'
4+
import { cn, ShimmerText } from '@sim/emcn'
55
import styles from '@/components/ui/thinking-loader.module.css'
66

77
const VARIANTS = [
@@ -532,11 +532,19 @@ export function ThinkingLoader({
532532
<span className={styles.labelStack}>
533533
{exitingLabel ? (
534534
<span key={exitingLabel} className={cn(styles.labelLayer, styles.labelOut)}>
535-
<span className={shimmer ? styles.label : styles.labelStatic}>{exitingLabel}</span>
535+
{shimmer ? (
536+
<ShimmerText className={styles.label}>{exitingLabel}</ShimmerText>
537+
) : (
538+
<span className={styles.labelStatic}>{exitingLabel}</span>
539+
)}
536540
</span>
537541
) : null}
538542
<span key={shownLabel} className={cn(styles.labelLayer, styles.labelIn)}>
539-
<span className={shimmer ? styles.label : styles.labelStatic}>{shownLabel}</span>
543+
{shimmer ? (
544+
<ShimmerText className={styles.label}>{shownLabel}</ShimmerText>
545+
) : (
546+
<span className={styles.labelStatic}>{shownLabel}</span>
547+
)}
540548
</span>
541549
</span>
542550
</output>

‎packages/emcn/src/components/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ export { POPOVER_ANIMATION_CLASSES } from './popover/popover-animation'
215215
export { ProgressItem } from './progress-item/progress-item'
216216
export { SecretInput } from './secret-input/secret-input'
217217
export { SecretReveal } from './secret-reveal/secret-reveal'
218+
export { ShimmerText, type ShimmerTextProps } from './shimmer-text/shimmer-text'
218219
export { WORDMARK_PATHS, WORDMARK_VIEW_BOX } from './sim-wordmark/paths'
219220
export { SimWordmark, type SimWordmarkProps } from './sim-wordmark/sim-wordmark'
220221
export { Skeleton } from './skeleton/skeleton'

apps/sim/components/ui/shimmer-text.module.css renamed to packages/emcn/src/components/shimmer-text/shimmer-text.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Claude-style text shimmer: the text paints from a gradient with a light band
33
* that sweeps across the glyphs via background-clip. This is the single source
4-
* of truth for the treatment — the ThinkingLoader label composes it. Under
4+
* of truth for the treatment, including the ThinkingLoader label. Under
55
* reduced motion the sweep is replaced by a gentle opacity pulse in solid ink:
66
* the shimmer conveys essential in-progress state, so it needs a vestibular-safe
77
* fallback rather than none. Consumers whose resting text is not body ink set

0 commit comments

Comments
 (0)