Skip to content

feat: add feedback tracking for assistant messages#1597

Merged
mfortman11 merged 6 commits into
mainfrom
response-feedback
May 13, 2026
Merged

feat: add feedback tracking for assistant messages#1597
mfortman11 merged 6 commits into
mainfrom
response-feedback

Conversation

@mfortman11

@mfortman11 mfortman11 commented May 13, 2026

Copy link
Copy Markdown
Contributor

Adds a new like/dislike option for tracking purposes on assistant messages.

Screenshot 2026-05-13 at 2 45 57 PM

Adds a INITIAL_ASSISTANT_MESSAGE option now used when creating new chats and the new MessageActions shouldn't be shown there.

it also won't show during onboarding

Summary by CodeRabbit

  • New Features

    • Users can now provide feedback on assistant messages using like/dislike buttons.
  • Improvements

    • Feedback controls display intelligently (hidden for initial greeting, streaming messages, and onboarding).
    • Standardized initial assistant greeting and timestamp handling for more consistent message behavior.

Review Change Stack

@mfortman11
mfortman11 requested a review from lucaseduoli May 13, 2026 19:51
@github-actions github-actions Bot added the frontend 🟨 Issues related to the UI/UX label May 13, 2026
@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a like/dislike feedback UI and analytics for assistant messages, introduces INITIAL_ASSISTANT_MESSAGE with a Date timestamp, adopts that constant across chat pages and context, suppresses feedback during onboarding, and changes TypeScript JSX to "preserve".

Changes

Message Feedback Tracking and Initial Assistant Constant

Layer / File(s) Summary
Initial assistant message constant
frontend/app/chat/_types/types.ts
Exports INITIAL_ASSISTANT_MESSAGE with role: "assistant", default content, and timestamp: new Date().
MessageActions feedback component
frontend/app/chat/_components/message-actions.tsx
New MessageActions component with local feedbackSelected state, handleFeedback that prevents duplicate tracking, and two icon buttons for like/dislike.
AssistantMessage analytics wiring
frontend/app/chat/_components/assistant-message.tsx
Imports trackButton and MessageActions; adds optional timestamp?: Date and showFeedback?: boolean; implements trackFeedback that passes timestamp?.getTime() to trackButton; conditionally renders MessageActions when not initial greeting and not streaming.
Suppress feedback during onboarding
frontend/app/onboarding/_components/onboarding-content.tsx
Passes showFeedback={false} to AssistantMessage in the onboarding assistant/nudge render.
Chat pages and context constant adoption
frontend/app/chat/page.tsx, frontend/contexts/chat-context.tsx
Import and use INITIAL_ASSISTANT_MESSAGE for initial messages state, reset handlers, placeholder initialization, and initial-greeting detection (compare content against the constant).
JSX compilation configuration
frontend/tsconfig.json
Set compilerOptions.jsx from "react-jsx" to "preserve".

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding feedback tracking (like/dislike functionality) for assistant messages.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch response-feedback

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added community enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels May 13, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/app/chat/_components/assistant-message.tsx`:
- Around line 170-172: The feedback actions are currently rendered while the
assistant message is still streaming; update the render guard for MessageActions
(currently using isInitialGreeting and showFeedback) to also require the message
to be fully delivered (e.g., check a streaming/completion flag such as
!isStreaming, message.isStreaming === false, or message.isFinished) so
MessageActions only appears when streaming has finished; modify the conditional
around <MessageActions trackFeedback={trackFeedback} /> accordingly.

In `@frontend/app/chat/_components/message-actions.tsx`:
- Around line 22-49: The two icon-only Button controls rendering ThumbsUp and
ThumbsDown lack accessible names and toggle semantics; update the Buttons (the
ones using feedbackSelected and onClick={() => handleFeedback(...)}) to include
an accessible label (e.g., aria-label="Like" and aria-label="Dislike" or a
visually-hidden text child) and expose the selected state with
aria-pressed={feedbackSelected === "like"} / aria-pressed={feedbackSelected ===
"dislike"} so assistive tech sees the toggle state; keep existing onClick
handlers (handleFeedback) and maintain visual styling while adding these
attributes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c61c38c6-f445-4d10-a910-ff136b6700b1

📥 Commits

Reviewing files that changed from the base of the PR and between 915b714 and 102a4b1.

📒 Files selected for processing (7)
  • frontend/app/chat/_components/assistant-message.tsx
  • frontend/app/chat/_components/message-actions.tsx
  • frontend/app/chat/_types/types.ts
  • frontend/app/chat/page.tsx
  • frontend/app/onboarding/_components/onboarding-content.tsx
  • frontend/contexts/chat-context.tsx
  • frontend/tsconfig.json

Comment thread frontend/app/chat/_components/assistant-message.tsx Outdated
Comment thread frontend/app/chat/_components/message-actions.tsx
@github-actions github-actions Bot added the lgtm label May 13, 2026
@github-actions github-actions Bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels May 13, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/app/chat/page.tsx`:
- Line 56: INITIAL_ASSISTANT_MESSAGE is created at module load and reusing it
causes stale timestamps; when resetting the conversation in the page component
(initial state where INITIAL_ASSISTANT_MESSAGE is used, inside the
handleNewConversation effect, and inside the placeholderConversation effect),
unpack only the message content from INITIAL_ASSISTANT_MESSAGE and build a new
message object with the same content but a fresh timestamp using new
Date().toISOString(); update the places that reference INITIAL_ASSISTANT_MESSAGE
to create a new object (e.g., { ...INITIAL_ASSISTANT_MESSAGE, timestamp: new
Date().toISOString() } or extract content and set timestamp) so each reset gets
a current timestamp.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 06232c40-8787-45d3-b847-c9e58858e63b

📥 Commits

Reviewing files that changed from the base of the PR and between 102a4b1 and 924bde9.

📒 Files selected for processing (4)
  • frontend/app/chat/_components/assistant-message.tsx
  • frontend/app/chat/_components/message-actions.tsx
  • frontend/app/chat/page.tsx
  • frontend/contexts/chat-context.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/app/chat/_components/assistant-message.tsx
  • frontend/app/chat/_components/message-actions.tsx

content: "How can I assist?",
timestamp: new Date(),
},
INITIAL_ASSISTANT_MESSAGE,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the INITIAL_ASSISTANT_MESSAGE definition to see if timestamp is static or dynamic
rg -A 5 -B 2 'INITIAL_ASSISTANT_MESSAGE\s*=' frontend/app/chat/_types/types.ts

Repository: langflow-ai/openrag

Length of output: 45


🏁 Script executed:

#!/bin/bash
# Search for INITIAL_ASSISTANT_MESSAGE definition across the frontend
rg 'INITIAL_ASSISTANT_MESSAGE\s*=' frontend/ --type ts --type tsx -A 8

Repository: langflow-ai/openrag

Length of output: 91


🏁 Script executed:

#!/bin/bash
# Also search for where it's imported from in page.tsx
rg 'import.*INITIAL_ASSISTANT_MESSAGE' frontend/app/chat/page.tsx -B 2 -A 2

Repository: langflow-ai/openrag

Length of output: 189


🏁 Script executed:

#!/bin/bash
# Check the structure of the page.tsx file at the mentioned lines
sed -n '50,70p' frontend/app/chat/page.tsx
sed -n '320,335p' frontend/app/chat/page.tsx
sed -n '560,575p' frontend/app/chat/page.tsx

Repository: langflow-ai/openrag

Length of output: 2087


🏁 Script executed:

#!/bin/bash
# Read the types.ts file to find INITIAL_ASSISTANT_MESSAGE definition
cat frontend/app/chat/_types/types.ts

Repository: langflow-ai/openrag

Length of output: 1728


🏁 Script executed:

#!/bin/bash
# Also check the chat-context.tsx implementation mentioned in the review
rg -B 5 -A 5 'new Date().toISOString()' frontend/app/chat/

Repository: langflow-ai/openrag

Length of output: 45


🏁 Script executed:

#!/bin/bash
# Find chat-context.tsx
fd 'chat-context' frontend/ --type f

Repository: langflow-ai/openrag

Length of output: 98


🏁 Script executed:

#!/bin/bash
# Check line 347 area and message initialization in chat-context
rg 'const createMessage|content.*timestamp|new Date' frontend/app/chat/chat-context.tsx -B 3 -A 3

Repository: langflow-ai/openrag

Length of output: 138


🏁 Script executed:

#!/bin/bash
# Check the correct chat-context.tsx location
rg 'INITIAL_ASSISTANT_MESSAGE|new Date' frontend/contexts/chat-context.tsx -B 3 -A 3

Repository: langflow-ai/openrag

Length of output: 809


🏁 Script executed:

#!/bin/bash
# Also search for any message creation patterns around line 347 or nearby
sed -n '340,360p' frontend/contexts/chat-context.tsx

Repository: langflow-ai/openrag

Length of output: 719


Create fresh timestamps when resetting to INITIAL_ASSISTANT_MESSAGE instead of reusing the stale module-level timestamp.

The INITIAL_ASSISTANT_MESSAGE constant is defined with timestamp: new Date() at module load time, meaning all three reset locations (initial state at line 56, handleNewConversation effect at line 328, and placeholderConversation effect at line 566) share the same static timestamp rather than reflecting the actual start time of each conversation.

The pattern in frontend/contexts/chat-context.tsx demonstrates the correct approach: extract only the content from INITIAL_ASSISTANT_MESSAGE and create a fresh timestamp with new Date().toISOString(). Apply the same pattern here:

Proposed fix
-const [messages, setMessages] = useState<Message[]>([
-  INITIAL_ASSISTANT_MESSAGE,
-]);
+const [messages, setMessages] = useState<Message[]>([
+  { ...INITIAL_ASSISTANT_MESSAGE, timestamp: new Date() },
+]);

And similarly for lines 328 and 566:

-setMessages([INITIAL_ASSISTANT_MESSAGE]);
+setMessages([{ ...INITIAL_ASSISTANT_MESSAGE, timestamp: new Date() }]);

Also applies to: 328-328, 566-566

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/app/chat/page.tsx` at line 56, INITIAL_ASSISTANT_MESSAGE is created
at module load and reusing it causes stale timestamps; when resetting the
conversation in the page component (initial state where
INITIAL_ASSISTANT_MESSAGE is used, inside the handleNewConversation effect, and
inside the placeholderConversation effect), unpack only the message content from
INITIAL_ASSISTANT_MESSAGE and build a new message object with the same content
but a fresh timestamp using new Date().toISOString(); update the places that
reference INITIAL_ASSISTANT_MESSAGE to create a new object (e.g., {
...INITIAL_ASSISTANT_MESSAGE, timestamp: new Date().toISOString() } or extract
content and set timestamp) so each reset gets a current timestamp.

@mfortman11
mfortman11 merged commit 489f138 into main May 13, 2026
15 checks passed
@github-actions
github-actions Bot deleted the response-feedback branch May 13, 2026 21:58
ricofurtado pushed a commit that referenced this pull request May 23, 2026
* add feedback tracking for assistant messages

* style: apply biome auto-fixes [skip ci]

* don't show during onboarding

* coderabbit suggestions

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community enhancement 🔵 New feature or request frontend 🟨 Issues related to the UI/UX lgtm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants