improvement(chat): unify expandable inline tool activity by waleedlatif1 · Pull Request #7750 · simstudioai/sim · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { useMemo } from 'react'
import { Chip, ChipLink } from '@sim/emcn'
import { useQueryStates } from 'nuqs'
import { ShimmerText } from '@/components/ui/shimmer-text'
import { ActivityStatus } from '@/components/ui/activity-status'
import type {
WorkspaceKnowledgeSearchResult,
WorkspaceSearchFilters,
Expand Down Expand Up @@ -190,9 +190,9 @@ export function KnowledgeSearchResults({
}
if (isPending || (isFetching && !results)) {
return (
<p role='status' className='px-2 py-2 text-[var(--text-muted)] text-caption'>
<ShimmerText className='[--shimmer-rest:var(--text-muted)]'>Searching…</ShimmerText>
</p>
<div className='px-2 py-2'>
<ActivityStatus label='Searching…' isActive />
</div>
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
'use client'

import { type ReactNode, useId } from 'react'
import { ChevronDown, cn, Expandable, ExpandableContent } from '@sim/emcn'
import { ActivityViewport } from '@/app/workspace/[workspaceId]/home/components/message-content/components/agent-group/activity-viewport'

interface ActivityDisclosureProps {
header: ReactNode
children: ReactNode
expanded: boolean
onToggle: () => void
isStreaming: boolean
unbounded?: boolean
}

/** Shared disclosure chrome; callers own expansion and blocking-interaction decisions. */
export function ActivityDisclosure({
header,
children,
expanded,
onToggle,
isStreaming,
unbounded = false,
}: ActivityDisclosureProps) {
const contentId = useId()
const headerId = useId()

return (
<div className='flex min-w-0 flex-col gap-1.5'>
<button
type='button'
aria-expanded={expanded}
aria-controls={contentId}
aria-labelledby={headerId}
onClick={onToggle}
className='group/agent flex w-full min-w-0 cursor-pointer items-center gap-2 text-left'
>
<span id={headerId} className='flex min-w-0'>
{header}
</span>
<ChevronDown
aria-hidden
className={cn(
'size-[14px] shrink-0 text-[var(--text-icon)] transition-[transform,opacity] duration-150',
!expanded &&
'-rotate-90 opacity-0 group-hover/agent:opacity-100 group-focus-visible/agent:opacity-100'
)}
/>
</button>
<Expandable expanded={expanded}>
<ExpandableContent id={contentId}>
<ActivityViewport isStreaming={isStreaming} unbounded={unbounded}>
{children}
</ActivityViewport>
</ExpandableContent>
</Expandable>
</div>
)
}
Loading
Loading