diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/components/index.ts b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/components/index.ts index 34541b1a149..8e944da54cc 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/components/index.ts +++ b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/components/index.ts @@ -1 +1,2 @@ +export { JumpToLatest } from './jump-to-latest' export { MothershipChatSkeleton } from './mothership-chat-skeleton' diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/components/jump-to-latest/index.ts b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/components/jump-to-latest/index.ts new file mode 100644 index 00000000000..19f626b2812 --- /dev/null +++ b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/components/jump-to-latest/index.ts @@ -0,0 +1 @@ +export { JumpToLatest } from './jump-to-latest' diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/components/jump-to-latest/jump-to-latest.test.tsx b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/components/jump-to-latest/jump-to-latest.test.tsx new file mode 100644 index 00000000000..561f95889de --- /dev/null +++ b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/components/jump-to-latest/jump-to-latest.test.tsx @@ -0,0 +1,123 @@ +/** @vitest-environment jsdom */ + +import { act } from 'react' +import { noop } from '@sim/utils/helpers' +import { createRoot, type Root } from 'react-dom/client' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { JumpToLatest } from '@/app/workspace/[workspaceId]/home/components/mothership-chat/components/jump-to-latest/jump-to-latest' + +const FRAME_MS = 16 + +let atLatest = false +let root: Root +let container: HTMLDivElement +let scroller: HTMLDivElement +/** Stable across renders, like the chat's refs and its `useCallback` reader. */ +const scrollElementRef: { current: HTMLElement | null } = { current: null } +const contentRef: { current: HTMLElement | null } = { current: null } +const isAtLatest = () => atLatest + +function render(chatId: string | undefined) { + act(() => + root.render( + + ) + ) +} + +/** The transcript scrolls (a landing step, a user scroll) and the next frame reads it. */ +function scrollTo(nowAtLatest: boolean) { + atLatest = nowAtLatest + act(() => { + scroller.dispatchEvent(new Event('scroll')) + vi.advanceTimersByTime(FRAME_MS * 2) + }) +} + +const isShown = () => container.querySelector('button') !== null + +describe('JumpToLatest', () => { + beforeEach(() => { + vi.useFakeTimers({ toFake: ['requestAnimationFrame', 'cancelAnimationFrame'] }) + vi.stubGlobal( + 'ResizeObserver', + class { + observe() {} + disconnect() {} + } + ) + atLatest = false + scroller = document.createElement('div') + scrollElementRef.current = scroller + container = document.createElement('div') + document.body.append(scroller, container) + root = createRoot(container) + }) + + afterEach(() => { + act(() => root.unmount()) + scroller.remove() + container.remove() + vi.useRealTimers() + }) + + it('stays hidden while a chat lands, and shows once the user leaves the latest message', () => { + render('chat-a') + scrollTo(false) + expect(isShown()).toBe(false) + + scrollTo(true) + scrollTo(false) + + expect(isShown()).toBe(true) + }) + + it('shows once the user scrolls a chat whose landing stopped short of the latest message', () => { + render('chat-a') + scrollTo(false) + expect(isShown()).toBe(false) + + // At the very top an upward wheel moves nothing, so no scroll event follows it. + act(() => { + scroller.dispatchEvent(new WheelEvent('wheel', { deltaY: -120 })) + vi.advanceTimersByTime(FRAME_MS * 2) + }) + + expect(isShown()).toBe(true) + }) + + it('hides on a chat switch until the new chat has landed', () => { + render('chat-a') + scrollTo(true) + scrollTo(false) + expect(isShown()).toBe(true) + + render('chat-b') + scrollTo(false) + expect(isShown()).toBe(false) + + scrollTo(true) + scrollTo(false) + expect(isShown()).toBe(true) + }) + + it('keeps showing when a pending chat adopts its id', () => { + render(undefined) + scrollTo(true) + scrollTo(false) + expect(isShown()).toBe(true) + + render('chat-persisted') + expect(isShown()).toBe(true) + + scrollTo(false) + expect(isShown()).toBe(true) + }) +}) diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/components/jump-to-latest/jump-to-latest.tsx b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/components/jump-to-latest/jump-to-latest.tsx new file mode 100644 index 00000000000..c6a520bcf6a --- /dev/null +++ b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/components/jump-to-latest/jump-to-latest.tsx @@ -0,0 +1,134 @@ +'use client' + +import { type MouseEvent, type RefObject, useEffect, useRef, useState } from 'react' +import { Chip, Tooltip } from '@sim/emcn' +import { ArrowDown } from '@sim/emcn/icons' + +const LABEL = 'Jump to latest' +/** Inputs that mean the user is scrolling the transcript themselves, which ends any landing. */ +const USER_SCROLL_EVENTS = ['wheel', 'touchstart', 'keydown', 'pointerdown'] as const + +interface JumpToLatestProps { + /** The chat shown. A different chat lands at its latest message before the button can show. */ + chatId: string | undefined + scrollElementRef: RefObject + /** The transcript's sizer, whose growth moves the bottom away without a scroll. */ + contentRef: RefObject + /** False while the transcript has no rows or its first landing at the bottom is held back. */ + enabled: boolean + /** Whether the latest content is in view, read once per frame. */ + isAtLatest: () => boolean + /** + * Scrolls to the latest message and resumes following. `fromKeyboard` asks the caller to + * move focus on, since the focused button unmounts. + */ + onJump: (fromKeyboard: boolean) => void +} + +/** + * Floating control that returns a scrolled-away transcript to its latest message. Renders on a + * zero-height anchor between the transcript and the composer, outside the transcript's edge + * mask, so the fade never dims it and it never covers the composer. + * + * Owns its own visibility state so a scroll re-renders only this control. Each chat switch + * remounts it, so the switch's landing at the latest message never shows it on the way down. + */ +export function JumpToLatest({ chatId, ...controlProps }: JumpToLatestProps) { + const [landingChatId, setLandingChatId] = useState(chatId) + const [landing, setLanding] = useState(0) + if (landingChatId !== chatId) { + setLandingChatId(chatId) + // A pending chat adopting its id is the same conversation, which does not land again. + if (landingChatId !== undefined) setLanding(landing + 1) + } + return +} + +function JumpToLatestControl({ + scrollElementRef, + contentRef, + enabled, + isAtLatest, + onJump, +}: Omit) { + /** + * Whether this chat has finished landing: its latest message has been in view, or the user has + * scrolled it themselves, so a landing that stops short still offers the jump. + */ + const landedRef = useRef(false) + const [away, setAway] = useState(false) + + useEffect(() => { + const scrollElement = scrollElementRef.current + if (!enabled || !scrollElement) return + + let frame = 0 + /** + * One read per frame, after the frame's scroll writes and gesture listeners: a wheel or key + * that stops following reaches its own listener in an order this one does not control. + */ + const schedule = () => { + if (frame) return + frame = requestAnimationFrame(() => { + frame = 0 + const atLatest = isAtLatest() + if (atLatest) landedRef.current = true + setAway(landedRef.current && !atLatest) + }) + } + + const endLanding = () => { + landedRef.current = true + schedule() + } + + schedule() + scrollElement.addEventListener('scroll', schedule, { passive: true }) + for (const type of USER_SCROLL_EVENTS) { + scrollElement.addEventListener(type, endLanding, { passive: true }) + } + const observer = new ResizeObserver(schedule) + observer.observe(scrollElement) + if (contentRef.current) observer.observe(contentRef.current) + + return () => { + cancelAnimationFrame(frame) + scrollElement.removeEventListener('scroll', schedule) + for (const type of USER_SCROLL_EVENTS) scrollElement.removeEventListener(type, endLanding) + observer.disconnect() + setAway(false) + } + }, [enabled, scrollElementRef, contentRef, isAtLatest]) + + if (!enabled || !away) return null + + /** + * Hides in the jump's own render: rows revealed by a long jump can hold the main thread for + * frames, and the per-frame check would only catch up after them. + */ + const handleClick = (event: MouseEvent) => { + const fromKeyboard = event.currentTarget.matches(':focus-visible') + setAway(false) + onJump(fromKeyboard) + } + + return ( +
+
+ + + } + onClick={handleClick} + /> + + {LABEL} + +
+
+ ) +} diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx index 5605710e459..7e099e8e3e2 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx +++ b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx @@ -55,6 +55,10 @@ import { } from '@/app/workspace/[workspaceId]/home/components/message-content/components/special-tags' import type { SearchIntegrationConnectionProps } from '@/app/workspace/[workspaceId]/home/components/message-content/components/special-tags/search-integration-connection' import { watchLabel } from '@/app/workspace/[workspaceId]/home/components/message-content/components/watch-activity/watch-activity' +import { + JumpToLatest, + MothershipChatSkeleton, +} from '@/app/workspace/[workspaceId]/home/components/mothership-chat/components' import { prepareCopyableMarkdown, toCopyableMarkdown, @@ -87,7 +91,6 @@ import type { import { useOptionalWorkspacePermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider' import { useAutoScroll } from '@/hooks/use-auto-scroll' import type { ChatContext } from '@/stores/panel' -import { MothershipChatSkeleton } from './components/mothership-chat-skeleton' import { shouldShowAssistantMessageActions } from './message-actions-visibility' interface MothershipChatProps { @@ -817,10 +820,12 @@ export function MothershipChat({ scrollElementRef, virtualizer, }) - const { ref: autoScrollRef, release: releaseAutoScroll } = useAutoScroll( - isStreamActive || lastRowAnimating, - find.isOpen - ) + const { + ref: autoScrollRef, + release: releaseAutoScroll, + follow: followAutoScroll, + isAtLatest, + } = useAutoScroll(isStreamActive || lastRowAnimating, find.isOpen) const setScrollElement = useCallback( (el: HTMLDivElement | null) => { scrollElementRef.current = el @@ -918,6 +923,15 @@ export function MothershipChat({ [messageIndexById, releaseAutoScroll, virtualizer] ) + /** A keyboard jump moves focus to the default composer, or the chat when a surface brings its own. */ + const jumpToLatest = (fromKeyboard: boolean) => { + virtualizer.scrollToIndex(lastIndex, { align: 'end' }) + followAutoScroll() + if (!fromKeyboard) return + if (userInputRef.current) userInputRef.current.focus() + else containerRef.current?.focus() + } + /** Quotes attach to the default composer; a surface that brings its own composer opts out. */ const { pendingQuote, clearPendingQuote, replyChipRef } = useQuoteSelection({ enabled: !composer && !isLoading, @@ -1161,6 +1175,15 @@ export function MothershipChat({ )} + + void + /** Focuses the input with the caret after any draft already typed. */ + focus: () => void } function isChatQuote(context: ChatContext): context is ChatQuoteContext { @@ -432,6 +434,7 @@ const UserInputImpl = forwardRef(function UserI editorRef.current.focusAtEnd() }, attachQuote: (quote: ChatQuoteContext) => editorRef.current.attachQuote(quote), + focus: () => editorRef.current.focusAtEnd(), }), [] ) diff --git a/apps/sim/hooks/use-auto-scroll.test.tsx b/apps/sim/hooks/use-auto-scroll.test.tsx new file mode 100644 index 00000000000..9f75e55ebc3 --- /dev/null +++ b/apps/sim/hooks/use-auto-scroll.test.tsx @@ -0,0 +1,191 @@ +/** @vitest-environment jsdom */ + +import { act } from 'react' +import { createRoot, type Root } from 'react-dom/client' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { useAutoScroll } from '@/hooks/use-auto-scroll' + +const VIEWPORT_HEIGHT = 600 +const FRAME_MS = 16 + +/** The transcript's geometry; `scrollTop` clamps to it the way a browser does. */ +const metrics = { contentHeight: 0, scrollTop: 0 } +const sizerObservers = new Set() + +class ResizeObserverStub { + constructor(private readonly onResize: () => void) {} + observe() { + sizerObservers.add(this) + } + disconnect() { + sizerObservers.delete(this) + } + notify() { + this.onResize() + } +} + +let latest: ReturnType +let scroller: HTMLDivElement +let root: Root + +function withTranscriptGeometry(el: HTMLDivElement): HTMLDivElement { + if (el.dataset.geometry) return el + el.dataset.geometry = 'set' + Object.defineProperty(el, 'clientHeight', { get: () => VIEWPORT_HEIGHT }) + Object.defineProperty(el, 'scrollHeight', { get: () => metrics.contentHeight }) + Object.defineProperty(el, 'scrollTop', { + get: () => metrics.scrollTop, + set: (value: number) => { + metrics.scrollTop = Math.max(0, Math.min(value, metrics.contentHeight - VIEWPORT_HEIGHT)) + }, + }) + scroller = el + return el +} + +function Transcript({ streaming, findOpen }: { streaming: boolean; findOpen: boolean }) { + latest = useAutoScroll(streaming, findOpen) + const { ref } = latest + return ( +
ref(el && withTranscriptGeometry(el))}> +
+
+ ) +} + +function render(state: { streaming: boolean; findOpen?: boolean }) { + act(() => root.render()) +} + +function distanceFromBottom() { + return metrics.contentHeight - metrics.scrollTop - VIEWPORT_HEIGHT +} + +/** Streamed content lands below the fold and the sizer reports it. */ +function grow(px: number) { + metrics.contentHeight += px + for (const observer of sizerObservers) observer.notify() +} + +function frames(count: number) { + act(() => vi.advanceTimersByTime(count * FRAME_MS)) +} + +function wheelUp(px: number) { + scroller.dispatchEvent(new WheelEvent('wheel', { deltaY: -px })) + metrics.scrollTop -= px + scroller.dispatchEvent(new Event('scroll')) +} + +describe('useAutoScroll', () => { + beforeEach(() => { + vi.useFakeTimers({ + toFake: [ + 'requestAnimationFrame', + 'cancelAnimationFrame', + 'setTimeout', + 'clearTimeout', + 'performance', + ], + }) + vi.stubGlobal('ResizeObserver', ResizeObserverStub) + metrics.contentHeight = 3000 + metrics.scrollTop = metrics.contentHeight - VIEWPORT_HEIGHT + sizerObservers.clear() + root = createRoot(document.createElement('div')) + }) + + afterEach(() => { + act(() => root.unmount()) + vi.useRealTimers() + }) + + it('counts the latest content as in view while following glides after streamed growth', () => { + render({ streaming: true }) + grow(400) + + expect(distanceFromBottom()).toBeGreaterThan(30) + expect(latest.isAtLatest()).toBe(true) + + frames(60) + expect(distanceFromBottom()).toBeLessThanOrEqual(1) + expect(latest.isAtLatest()).toBe(true) + }) + + it('reports the user away when a stream ends after they scrolled up', () => { + render({ streaming: true }) + wheelUp(200) + + render({ streaming: false }) + + expect(latest.isAtLatest()).toBe(false) + }) + + it('reports the user away when they scroll up during the settle after a stream ends', () => { + render({ streaming: true }) + grow(400) + render({ streaming: false }) + expect(latest.isAtLatest()).toBe(true) + + wheelUp(200) + + expect(latest.isAtLatest()).toBe(false) + }) + + it('counts the latest content as in view while a glide outlasts the settle window', () => { + render({ streaming: true }) + // A gap too long to close inside the window, as when frames were starved in a + // background tab while the reply finished. + grow(1_000_000) + render({ streaming: false }) + + // Just past the window's 900ms end (800ms settle + 100ms guard in use-auto-scroll.ts). + frames(57) + expect(distanceFromBottom()).toBeGreaterThan(30) + expect(latest.isAtLatest()).toBe(true) + + frames(60) + expect(distanceFromBottom()).toBeLessThanOrEqual(1) + }) + + it('leaves nothing gliding or pending after the transcript unmounts mid-stream', () => { + render({ streaming: true }) + grow(1_000_000) + + act(() => root.render(
)) + const topAtUnmount = metrics.scrollTop + frames(120) + + expect(metrics.scrollTop).toBe(topAtUnmount) + expect(vi.getTimerCount()).toBe(0) + }) + + it('follows streamed growth again after follow(), before any scroll reaches the bottom', () => { + render({ streaming: true }) + wheelUp(800) + grow(300) + frames(5) + expect(distanceFromBottom()).toBe(1100) + + act(() => latest.follow()) + frames(80) + expect(distanceFromBottom()).toBeLessThanOrEqual(1) + grow(300) + frames(80) + + expect(distanceFromBottom()).toBeLessThanOrEqual(1) + }) + + it('leaves the position to find-in-chat when follow() runs while find is open', () => { + render({ streaming: true }) + grow(400) + render({ streaming: true, findOpen: true }) + const findPosition = metrics.scrollTop + + act(() => latest.follow()) + frames(80) + + expect(metrics.scrollTop).toBe(findPosition) + }) +}) diff --git a/apps/sim/hooks/use-auto-scroll.ts b/apps/sim/hooks/use-auto-scroll.ts index 47084c0e58a..010ee0f9111 100644 --- a/apps/sim/hooks/use-auto-scroll.ts +++ b/apps/sim/hooks/use-auto-scroll.ts @@ -1,7 +1,13 @@ import { useCallback, useEffect, useRef } from 'react' -import { createSmoothBottomChase } from '@/lib/core/utils/smooth-bottom-chase' +import { + createSmoothBottomChase, + type SmoothBottomChaseHandle, +} from '@/lib/core/utils/smooth-bottom-chase' -/** Tolerance for keeping stickiness during programmatic auto-scroll. */ +/** + * Tolerance for keeping stickiness during programmatic auto-scroll, and how close to the + * bottom still counts as showing the latest content. + */ const STICK_THRESHOLD = 30 /** User must scroll back to within this distance to re-engage auto-scroll. */ const REATTACH_THRESHOLD = 5 @@ -31,6 +37,13 @@ const SCROLL_UP_KEYS = new Set(['ArrowUp', 'PageUp', 'Home']) * append only after the abort round-trips. */ const POST_STOP_SETTLE_WINDOW = 800 +/** How often a settle window that is still gliding at its end checks again for the park. */ +const SETTLE_PARK_RECHECK = 100 + +function distanceFromBottom(el: HTMLElement): number { + return el.scrollHeight - el.scrollTop - el.clientHeight +} + /** * Manages sticky auto-scroll for a streaming chat container. * @@ -41,7 +54,9 @@ const POST_STOP_SETTLE_WINDOW = 800 * current scroll position, so a user who scrolled up beforehand stays put. * * Yields scroll ownership while paused, including between streams. - * Returns `ref`, the callback ref for the scroll container, and `release`. + * Returns `ref`, the callback ref for the scroll container, with `release` and `follow` + * to hand following off and back, and `isAtLatest` to read whether the latest content + * is in view. */ export function useAutoScroll(isStreaming: boolean, paused = false) { const containerRef = useRef(null) @@ -62,6 +77,8 @@ export function useAutoScroll(isStreaming: boolean, paused = false) { * so a keypress near a stream's end can't carry into the next session. */ const lastUserGestureAtRef = useRef(Number.NEGATIVE_INFINITY) + /** The streaming session's chase, kept until its settle window ends and it parks; null between. */ + const chaseRef = useRef(null) const callbackRef = useCallback((el: HTMLDivElement | null) => { containerRef.current = el @@ -74,7 +91,6 @@ export function useAutoScroll(isStreaming: boolean, paused = false) { * on unmount. */ const settleCleanupRef = useRef<(() => void) | null>(null) - useEffect(() => () => settleCleanupRef.current?.(), []) useEffect(() => { if (paused) { @@ -109,9 +125,9 @@ export function useAutoScroll(isStreaming: boolean, paused = false) { }, () => stickyRef.current ) + chaseRef.current = chase - const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight - const isNearBottom = distanceFromBottom <= STICK_THRESHOLD + const isNearBottom = distanceFromBottom(el) <= STICK_THRESHOLD stickyRef.current = isNearBottom userDetachedRef.current = !isNearBottom prevScrollTopRef.current = el.scrollTop @@ -164,15 +180,15 @@ export function useAutoScroll(isStreaming: boolean, paused = false) { * re-stick on its own scroll event. */ const onScroll = () => { - const { scrollTop, scrollHeight, clientHeight } = el - const distanceFromBottom = scrollHeight - scrollTop - clientHeight + const { scrollTop, scrollHeight } = el + const distance = distanceFromBottom(el) const threshold = userDetachedRef.current ? REATTACH_THRESHOLD : STICK_THRESHOLD const userDriven = pointerDownRef.current || performance.now() - lastUserGestureAtRef.current < USER_GESTURE_WINDOW const movedDown = scrollTop > prevScrollTopRef.current - if (distanceFromBottom <= threshold && (!userDetachedRef.current || movedDown)) { + if (distance <= threshold && (!userDetachedRef.current || movedDown)) { stickyRef.current = true userDetachedRef.current = false } else if ( @@ -247,18 +263,33 @@ export function useAutoScroll(isStreaming: boolean, paused = false) { el.removeEventListener('wheel', cancelOnGesture) el.removeEventListener('touchmove', cancelOnGesture) } - const guardTimeout = setTimeout(() => { + const endSettle = () => { removeGestureGuard() + if (chaseRef.current === chase) chaseRef.current = null + } + // A glide can outlast the window when frames were starved, such as a tab coming + // back to a reply that finished in the background; the guard stays until it parks. + const endSettleOnceParked = () => { + if (chase.isActive()) { + guardTimeout = setTimeout(endSettleOnceParked, SETTLE_PARK_RECHECK) + return + } + endSettle() settleCleanupRef.current = null - }, POST_STOP_SETTLE_WINDOW + 100) + } + let guardTimeout = setTimeout(endSettleOnceParked, POST_STOP_SETTLE_WINDOW + 100) settleCleanupRef.current = () => { chase.cancel() clearTimeout(guardTimeout) - removeGestureGuard() + endSettle() } } }, [isStreaming, paused]) + // Declared after the streaming effect: unmount runs cleanups in declaration order, so this + // also cancels the settle that effect's teardown schedules on its way out. + useEffect(() => () => settleCleanupRef.current?.(), []) + /** * Stops following for a scroll the user asked for that no gesture announces, such as * jumping to a quoted message. Following resumes once they scroll back to the bottom. @@ -268,5 +299,30 @@ export function useAutoScroll(isStreaming: boolean, paused = false) { userDetachedRef.current = true }, []) - return { ref: callbackRef, release } + /** + * Resumes following after the user asked for the latest content, such as from a jump + * button whose own scroll may land before the last streamed growth does. Paused + * ownership still wins: a stream starting after the pause re-seeds from the position. + */ + const follow = useCallback(() => { + stickyRef.current = true + userDetachedRef.current = false + chaseRef.current?.kick() + }, []) + + /** + * Whether the latest content is in view: the container sits within + * {@link STICK_THRESHOLD} of its bottom, or following is gliding it there behind + * streamed growth. Read it after the frame's scroll writes, not inside a scroll + * listener, since the gestures that stop following reach their own listeners in an + * order the caller does not control. + */ + const isAtLatest = useCallback(() => { + const el = containerRef.current + if (!el) return true + if (stickyRef.current && chaseRef.current?.isActive()) return true + return distanceFromBottom(el) <= STICK_THRESHOLD + }, []) + + return { ref: callbackRef, release, follow, isAtLatest } } diff --git a/packages/emcn/src/components/chip/chip.tsx b/packages/emcn/src/components/chip/chip.tsx index 56bab6ef7df..61d568826aa 100644 --- a/packages/emcn/src/components/chip/chip.tsx +++ b/packages/emcn/src/components/chip/chip.tsx @@ -17,6 +17,7 @@ import { import { OverflowText, overflowTextClipClass } from '../overflow-text/overflow-text' import { chipActiveSurfaceClass, + chipBorderShadowRing, chipContentIconClass, chipContentLabelClass, chipFilledFillTokens, @@ -72,9 +73,8 @@ const chipVariants = cva( primary: `${chipPrimaryFillTokens} hover-hover:bg-[var(--text-body)] hover-hover:text-[var(--text-inverse)] dark:hover-hover:bg-[var(--text-secondary)] dark:hover-hover:text-[var(--bg)]`, destructive: 'bg-[var(--text-error)] text-white hover-hover:text-white hover-hover:brightness-106', - 'border-shadow': - 'bg-[var(--surface-2)] shadow-[0_0_0_1px_rgba(28,40,64,0.08),0_1px_3px_0_rgba(28,40,64,0.1)] hover-hover:bg-[var(--surface-3)] dark:shadow-[0_0_0_1px_var(--border-1),0_1px_3px_0_rgba(0,0,0,0.3)] dark:hover-hover:bg-[var(--surface-4)]', - border: `shadow-[0_0_0_1px_rgba(28,40,64,0.08),0_1px_3px_0_rgba(28,40,64,0.1)] ${chipHoverSurfaceClass} dark:shadow-[0_0_0_1px_var(--border-1),0_1px_3px_0_rgba(0,0,0,0.3)]`, + 'border-shadow': `bg-[var(--surface-2)] ${chipBorderShadowRing} hover-hover:bg-[var(--surface-3)] focus-visible:bg-[var(--surface-3)] dark:focus-visible:bg-[var(--surface-4)] dark:hover-hover:bg-[var(--surface-4)]`, + border: `${chipBorderShadowRing} ${chipHoverSurfaceClass}`, outline: 'border border-[var(--border)] bg-transparent hover-hover:border-[color-mix(in_srgb,var(--border)_80%,var(--text-secondary))]', }, diff --git a/scripts/check-source-conventions.baseline.json b/scripts/check-source-conventions.baseline.json index 6d6ae738211..8dc6ce83d2b 100644 --- a/scripts/check-source-conventions.baseline.json +++ b/scripts/check-source-conventions.baseline.json @@ -57,7 +57,7 @@ "apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/agent-group/inline-markdown.test.tsx": 1, "apps/sim/app/workspace/[workspaceId]/home/components/message-content/message-content.test.ts": 2, "apps/sim/app/workspace/[workspaceId]/home/components/message-content/message-content.tsx": 3, - "apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx": 2, + "apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx": 1, "apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/browser-session/browser-loading-bar.tsx": 1, "apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/mothership-view.tsx": 1, "apps/sim/app/workspace/[workspaceId]/home/home.tsx": 3, diff --git a/scripts/check-unused-exports.baseline.json b/scripts/check-unused-exports.baseline.json index da4a0ae88bc..6b0d940964e 100644 --- a/scripts/check-unused-exports.baseline.json +++ b/scripts/check-unused-exports.baseline.json @@ -419,7 +419,6 @@ "apps/sim/app/workspace/[workspaceId]/home/components/message-content/message-content.tsx#deriveThinkingLabel", "apps/sim/app/workspace/[workspaceId]/home/components/message-content/message-content.tsx#shouldSmoothTextSegment", "apps/sim/app/workspace/[workspaceId]/home/components/message-content/utils.ts#TOOL_ICONS", - "apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/components/index.ts#MothershipChatSkeleton", "apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/index.ts#MothershipChatSkeleton", "apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/add-resource-dropdown/add-resource-dropdown.tsx#FOLDERED_RESOURCE_TYPES", "apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/add-resource-dropdown/add-resource-dropdown.tsx#ResourceFolderTreeItems",