Skip to content
Merged
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
19 changes: 10 additions & 9 deletions apps/sim/lib/copilot/vfs/workspace-vfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1161,22 +1161,23 @@ export class WorkspaceVFS {
messages: sql<unknown[]>`COALESCE((
SELECT jsonb_agg(
jsonb_build_object(
'role', m->>'role',
'content', m->'content',
'role', m.value->>'role',
'content', m.value->'content',
'contentBlocks', COALESCE((
SELECT jsonb_agg(jsonb_build_object('type', 'text', 'content', b->'content'))
SELECT jsonb_agg(jsonb_build_object('type', 'text', 'content', b.value->'content') ORDER BY b.ord)
FROM jsonb_array_elements(
CASE WHEN jsonb_typeof(m->'contentBlocks') = 'array'
THEN m->'contentBlocks'
CASE WHEN jsonb_typeof(m.value->'contentBlocks') = 'array'
THEN m.value->'contentBlocks'
ELSE '[]'::jsonb
END
) AS b
WHERE b->>'type' = 'text'
) WITH ORDINALITY AS b(value, ord)
WHERE b.value->>'type' = 'text'
), '[]'::jsonb)
)
ORDER BY m.ord
)
FROM jsonb_array_elements(${copilotChats.messages}) AS m
WHERE m->>'role' IN ('user', 'assistant')
FROM jsonb_array_elements(${copilotChats.messages}) WITH ORDINALITY AS m(value, ord)
WHERE m.value->>'role' IN ('user', 'assistant')
), '[]'::jsonb)`,
createdAt: copilotChats.createdAt,
updatedAt: copilotChats.updatedAt,
Expand Down
Loading