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
25 changes: 8 additions & 17 deletions src/app/api/ai/vrl-chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,15 @@ export async function POST(request: Request) {
let priorMessages: Array<{ role: "user" | "assistant"; content: string }> = [];

if (!conversationId) {
// Reuse existing conversation for this pipeline + component if one exists
const existing = await prisma.aiConversation.findFirst({
where: { pipelineId: body.pipelineId, componentKey: body.componentKey },
orderBy: { createdAt: "desc" },
select: { id: true },
// Always create a new conversation — the client loads existing ones via TRPC query
const conversation = await prisma.aiConversation.create({
data: {
pipelineId: body.pipelineId,
componentKey: body.componentKey,
createdById: session.user.id,
},
});
if (existing) {
conversationId = existing.id;
} else {
const conversation = await prisma.aiConversation.create({
data: {
pipelineId: body.pipelineId,
componentKey: body.componentKey,
createdById: session.user.id,
},
});
conversationId = conversation.id;
}
conversationId = conversation.id;
} else {
// Verify conversationId belongs to this pipeline + component
const existing = await prisma.aiConversation.findUnique({
Expand Down
2 changes: 1 addition & 1 deletion src/components/flow/ai-pipeline-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ export function AiPipelineDialog({
) : (
<>
{/* Message thread */}
<ScrollArea className="flex-1 pr-4">
<ScrollArea className="flex-1 h-0 pr-4">
<div className="space-y-4 pb-4">
{conversation.messages.length === 0 && !conversation.isStreaming && (
<p className="text-sm text-muted-foreground text-center py-8">
Expand Down
3 changes: 2 additions & 1 deletion src/components/vrl-editor/vrl-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ export function VrlEditor({ value, onChange, sourceTypes, pipelineId, componentK
<DialogContent
className="h-[85vh] flex flex-col sm:max-w-[calc(100vw-4rem)] xl:max-w-6xl"
onKeyDown={(e) => e.stopPropagation()}
onFocusOutside={(e) => e.preventDefault()}
>
<DialogHeader>
<DialogTitle>VRL Editor</DialogTitle>
Expand Down Expand Up @@ -615,7 +616,7 @@ export function VrlEditor({ value, onChange, sourceTypes, pipelineId, componentK
{pipelineId && upstreamSourceKeys && upstreamSourceKeys.length > 0 && (
<>
<Select value={String(sampleLimit)} onValueChange={(val) => setSampleLimit(Number(val))}>
<SelectTrigger className="h-8 w-[110px] text-xs">
<SelectTrigger className="h-8 w-[120px] text-sm">
<SelectValue />
</SelectTrigger>
<SelectContent>
Expand Down
Loading