Skip to content

fix: VRL chat persistence and review tab scroll#100

Merged
TerrifiedBug merged 3 commits intomainfrom
fix/ai-chat-bugs
Mar 11, 2026
Merged

fix: VRL chat persistence and review tab scroll#100
TerrifiedBug merged 3 commits intomainfrom
fix/ai-chat-bugs

Conversation

@TerrifiedBug
Copy link
Owner

Summary

  • VRL chat "New Chat" bug: Server was reusing existing conversations when conversationId was null, causing old messages to persist in LLM context after clicking New Chat. Fixed by always creating a new conversation (matching pipeline route behavior).
  • Review tab scroll + hidden button: ScrollArea in the pipeline review tab lacked h-0 height constraint, causing content to overflow the flex container. This broke scrolling and pushed the "New Conversation" button out of the visible dialog area.
  • Greyed-out suggestions: Resolves automatically — suggestions appeared outdated because stale targetCode from reused conversations didn't match current editor code.

Test plan

  • Open VRL editor AI chat, have a conversation, click "New Chat", send a message — should NOT reference previous conversation
  • Open AI Pipeline Builder → Review tab with messages — scroll should work, "New Conversation" button should be visible below the input
  • Verify suggestions from a new VRL chat are actionable (not greyed out)

Two bugs fixed:
- VRL chat route was reusing existing conversations when conversationId
  was null (New Chat), causing old context to persist. Now always creates
  a new conversation, matching the pipeline route behavior.
- Review tab ScrollArea lacked height constraint in flex layout, causing
  content to overflow and hiding the New Conversation button. Added h-0
  to establish proper scroll containment.
@github-actions github-actions bot added the fix label Mar 11, 2026
@TerrifiedBug TerrifiedBug merged commit 67818a9 into main Mar 11, 2026
3 checks passed
@TerrifiedBug TerrifiedBug deleted the fix/ai-chat-bugs branch March 11, 2026 16:52
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 11, 2026

Greptile Summary

This PR fixes three related UX bugs in the AI-assisted VRL editor and pipeline review dialog. The changes are surgical and well-scoped.

  • VRL chat "New Chat" bug (vrl-chat/route.ts): Removes the findFirst lookup that reused an existing aiConversation record when no conversationId was provided. Previously, clicking "New Chat" on the client cleared the conversationId field but the server silently resumed the old conversation — injecting stale history into the LLM context. The fix always calls prisma.aiConversation.create(), matching the existing pipeline-chat route behaviour and correctly isolating each new session.

  • Review tab scroll / hidden button (ai-pipeline-dialog.tsx): Adds h-0 to the ScrollArea inside the Review tab. This is the standard Tailwind CSS pattern for making a flex-1 child actually constrain its height and scroll, rather than growing past its flex container and pushing sibling elements (the "New Conversation" button) out of view.

  • VRL editor focus trap (vrl-editor.tsx): Adds onFocusOutside={(e) => e.preventDefault()} to the Radix UI DialogContent. This prevents the dialog's focus-trap from breaking when Monaco's autocomplete dropdown or other portalled elements momentarily claim focus outside the dialog boundary. A minor SelectTrigger sizing tweak is also included.

Confidence Score: 5/5

  • All three changes are minimal, targeted fixes with no side-effects on auth, data integrity, or broader application state.
  • The route change correctly removes a harmful lookup and replaces it with a simple create — authorization and ownership verification for the existing-conversation path are untouched. The UI changes are standard Tailwind/Radix patterns with no logic risk.
  • No files require special attention.

Important Files Changed

Filename Overview
src/app/api/ai/vrl-chat/route.ts Removes stale-conversation reuse logic: now always creates a new aiConversation when no conversationId is provided, mirroring the pipeline route and correctly isolating "New Chat" sessions.
src/components/flow/ai-pipeline-dialog.tsx Adds h-0 to the ScrollArea in the Review tab — standard Tailwind fix to make a flex-1 child actually scroll instead of overflowing its flex container, restoring "New Conversation" button visibility.
src/components/vrl-editor/vrl-editor.tsx Adds onFocusOutside prevention to the VRL dialog (stops accidental dismissal when Monaco autocomplete or other external elements steal focus) and minor SelectTrigger sizing tweak.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Route as vrl-chat/route.ts
    participant DB as Prisma / PostgreSQL

    Note over Client,DB: BEFORE fix — "New Chat" click
    Client->>Route: POST {conversationId: undefined}
    Route->>DB: aiConversation.findFirst(pipelineId + componentKey)
    DB-->>Route: existing conversation (with stale history)
    Route->>DB: aiMessage.findMany(existingId) ← old messages injected into LLM
    Route-->>Client: response reusing old context ❌

    Note over Client,DB: AFTER fix — "New Chat" click
    Client->>Route: POST {conversationId: undefined}
    Route->>DB: aiConversation.create(pipelineId, componentKey, userId)
    DB-->>Route: fresh conversation id
    Route->>DB: aiMessage.findMany(newId) ← empty history
    Route-->>Client: response with clean context ✅

    Note over Client,DB: Continuing an existing conversation (unchanged)
    Client->>Route: POST {conversationId: "abc123"}
    Route->>DB: aiConversation.findUnique("abc123") — ownership check
    DB-->>Route: verified record
    Route->>DB: aiMessage.findMany("abc123")
    Route-->>Client: streaming response with correct history ✅
Loading

Last reviewed commit: 01613b5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant