Skip to content

Commit 35217a9

Browse files
committed
fix(chat): refresh automated turn workflow names and use shared label styles
1 parent 4f7e500 commit 35217a9

2 files changed

Lines changed: 25 additions & 14 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import {
6666
} from '@/app/workspace/[workspaceId]/home/components/user-input'
6767
import type { ModelSelectorOptions } from '@/app/workspace/[workspaceId]/home/components/user-input/components/model-selector'
6868
import { UserMessageContent } from '@/app/workspace/[workspaceId]/home/components/user-message-content'
69+
import { useResourceNameRevision } from '@/app/workspace/[workspaceId]/home/hooks/use-tool-resource-titles'
6970
import {
7071
fetchWorkspaceResourceRef,
7172
readCachedWorkspaceResourceRef,
@@ -246,12 +247,13 @@ const AutomatedTurnRow = memo(function AutomatedTurnRow({
246247
bubbleClassName,
247248
}: AutomatedTurnRowProps) {
248249
const params = useParams<{ workspaceId?: string }>()
250+
useResourceNameRevision()
249251
const { label, text, note } = describeAutomatedTurn(origin, content, params?.workspaceId)
250252
const Icon = origin === 'task' ? Clock : Calendar
251253
return (
252254
<div className={rowClassName}>
253-
<div className='flex items-center gap-1.5 text-[12px] text-[var(--text-tertiary)]'>
254-
<Icon className='size-[12px]' />
255+
<div className='flex items-center gap-1.5 text-[var(--text-muted)] text-caption'>
256+
<Icon className='size-[12px] text-[var(--text-icon)]' />
255257
{label}
256258
</div>
257259
<div className={bubbleClassName} title={note}>

‎apps/sim/app/workspace/[workspaceId]/home/hooks/use-tool-resource-titles.ts‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,32 @@ import { getQueryClient } from '@/app/_shell/providers/get-query-client'
88
import type { ContentBlock } from '@/app/workspace/[workspaceId]/home/types'
99
import { useCustomBlockOverlayVersion } from '@/blocks/custom/client-overlay'
1010

11+
/** Bumps when the sidebar inventory arrives or a resource is renamed, so cached names re-resolve. */
12+
export function useResourceNameRevision(): number {
13+
const [revision, refresh] = useReducer((value: number) => value + 1, 0)
14+
useEffect(
15+
() =>
16+
getQueryClient()
17+
.getQueryCache()
18+
.subscribe((event) => {
19+
if (
20+
event.type === 'updated' &&
21+
event.action.type === 'success' &&
22+
isResourceNameQuery(event.query.queryKey)
23+
)
24+
refresh()
25+
}),
26+
[]
27+
)
28+
return revision
29+
}
30+
1131
/** Refresh existing rows when the sidebar inventory arrives or a resource is renamed. */
1232
export function useToolResourceTitles(blocks: ContentBlock[]): ContentBlock[] {
1333
const overlayVersion = useCustomBlockOverlayVersion()
1434
const params = useParams<{ workspaceId?: string }>()
1535
const workspaceId = params?.workspaceId
16-
const [revision, refresh] = useReducer((value: number) => value + 1, 0)
17-
useEffect(() => {
18-
const cache = getQueryClient().getQueryCache()
19-
return cache.subscribe((event) => {
20-
if (
21-
event.type === 'updated' &&
22-
event.action.type === 'success' &&
23-
isResourceNameQuery(event.query.queryKey)
24-
)
25-
refresh()
26-
})
27-
}, [workspaceId])
36+
const revision = useResourceNameRevision()
2837

2938
return useMemo(
3039
() =>

0 commit comments

Comments
 (0)