Skip to content

Commit 5b94db6

Browse files
committed
Options ordering
1 parent c026ce7 commit 5b94db6

2 files changed

Lines changed: 53 additions & 41 deletions

File tree

  • apps/sim/app
    • api/webhooks/trigger/[path]
    • workspace/[workspaceId]/home/components/message-content/components/chat-content

apps/sim/app/api/webhooks/trigger/[path]/route.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,14 @@ async function handleWebhookPost(
155155
if (shouldSkipWebhookEvent(foundWebhook, body, requestId)) {
156156
continue
157157
}
158-
159-
try {
160-
const response = await queueWebhookExecution(foundWebhook, foundWorkflow, body, request, {
161-
requestId,
162-
path,
163-
actorUserId: preprocessResult.actorUserId,
164-
executionId: preprocessResult.executionId,
165-
correlation: preprocessResult.correlation,
166-
})
167-
responses.push(response)
168-
} catch (error) {
169-
throw error
170-
}
158+
const response = await queueWebhookExecution(foundWebhook, foundWorkflow, body, request, {
159+
requestId,
160+
path,
161+
actorUserId: preprocessResult.actorUserId,
162+
executionId: preprocessResult.executionId,
163+
correlation: preprocessResult.correlation,
164+
})
165+
responses.push(response)
171166
}
172167

173168
if (responses.length === 0) {

apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/chat-content/chat-content.tsx

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -241,40 +241,57 @@ export function ChatContent({
241241
const hasSpecialContent = parsed.hasPendingTag || parsed.segments.some((s) => s.type !== 'text')
242242

243243
if (hasSpecialContent) {
244+
type RenderGroup =
245+
| { kind: 'inline'; markdown: string }
246+
| { kind: 'block'; segment: ContentSegment; index: number }
247+
248+
const groups: RenderGroup[] = []
249+
let pendingMarkdown = ''
250+
251+
const flushMarkdown = () => {
252+
if (pendingMarkdown.trim()) {
253+
groups.push({ kind: 'inline', markdown: pendingMarkdown })
254+
}
255+
pendingMarkdown = ''
256+
}
257+
258+
for (let i = 0; i < parsed.segments.length; i++) {
259+
const s = parsed.segments[i]
260+
if (s.type === 'workspace_resource') {
261+
const label = s.data.title || s.data.id
262+
pendingMarkdown += `[${label}](#wsres-${s.data.type}-${s.data.id})`
263+
} else if (s.type === 'text' || s.type === 'thinking') {
264+
pendingMarkdown += s.content
265+
} else {
266+
flushMarkdown()
267+
groups.push({ kind: 'block', segment: s, index: i })
268+
}
269+
}
270+
flushMarkdown()
271+
244272
return (
245273
<div className='space-y-3'>
246-
{parsed.segments.map((segment, i) => {
247-
if (
248-
segment.type === 'text' ||
249-
segment.type === 'thinking' ||
250-
segment.type === 'workspace_resource'
251-
) {
252-
return null
274+
{groups.map((group, i) => {
275+
if (group.kind === 'inline') {
276+
return (
277+
<div
278+
key={`inline-${i}`}
279+
className={cn(PROSE_CLASSES, '[&>:first-child]:mt-0 [&>:last-child]:mb-0')}
280+
>
281+
<Streamdown mode='static' components={MARKDOWN_COMPONENTS}>
282+
{group.markdown}
283+
</Streamdown>
284+
</div>
285+
)
253286
}
254287
return (
255-
<SpecialTags key={`special-${i}`} segment={segment} onOptionSelect={onOptionSelect} />
288+
<SpecialTags
289+
key={`special-${group.index}`}
290+
segment={group.segment}
291+
onOptionSelect={onOptionSelect}
292+
/>
256293
)
257294
})}
258-
{(() => {
259-
const reassembled = parsed.segments
260-
.map((s) => {
261-
if (s.type === 'workspace_resource') {
262-
const label = s.data.title || s.data.id
263-
return `[${label}](#wsres-${s.data.type}-${s.data.id})`
264-
}
265-
if (s.type === 'text' || s.type === 'thinking') return s.content
266-
return ''
267-
})
268-
.join('')
269-
if (!reassembled.trim()) return null
270-
return (
271-
<div className={cn(PROSE_CLASSES, '[&>:first-child]:mt-0 [&>:last-child]:mb-0')}>
272-
<Streamdown mode='static' components={MARKDOWN_COMPONENTS}>
273-
{reassembled}
274-
</Streamdown>
275-
</div>
276-
)
277-
})()}
278295
{parsed.hasPendingTag && isStreaming && <PendingTagIndicator />}
279296
</div>
280297
)

0 commit comments

Comments
 (0)