Skip to content

MGMT-21122: Add feedback form to the Chatbot responses#3051

Merged
ammont82 merged 1 commit intoopenshift-assisted:masterfrom
celdrake:MGMT-21122-feedback-form
Jul 21, 2025
Merged

MGMT-21122: Add feedback form to the Chatbot responses#3051
ammont82 merged 1 commit intoopenshift-assisted:masterfrom
celdrake:MGMT-21122-feedback-form

Conversation

@celdrake
Copy link
Contributor

@celdrake celdrake commented Jul 18, 2025

Adds a new Feedback form to the Chatbot's responses.

chatbot-feedback-final.mp4

Summary by CodeRabbit

  • New Features

    • Added the ability for users to provide positive or negative feedback on chatbot responses, including optional comments for negative feedback.
    • Users can now copy chatbot message text to the clipboard directly from the chat interface.
  • Improvements

    • Enhanced accessibility and feedback form usability for a better user experience.
    • Improved chat message rendering with clearer distinction between user and bot messages.
    • Added smooth scrolling to the latest messages when feedback forms are opened.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Jul 18, 2025

@celdrake: This pull request references MGMT-21122 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.20.0" version, but no target version was set.

Details

In response to this:

Adds a new Feedback form to the Chatbot's responses.

chatbot-feedback-final.mp4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 18, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 18, 2025

"""

Walkthrough

A new BotMessage React component is introduced to render bot messages with integrated user feedback, including sentiment and optional textual input. The ChatBotWindow component is updated to use this new component for bot messages, introduces explicit role constants, and adds logic to submit feedback to a backend endpoint, associating user questions with bot responses.

Changes

File(s) Change Summary
libs/chatbot/lib/components/ChatBot/BotMessage.tsx Added BotMessage component for rendering bot messages with feedback actions and form. Introduced FeedbackRequest and BotMessageProps types.
libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx Replaced hardcoded role strings with constants, added feedback submission logic, integrated BotMessage, and improved message rendering logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BotMessage
    participant ChatBotWindow
    participant Backend

    User->>BotMessage: Clicks feedback (positive/negative)
    BotMessage->>ChatBotWindow: Calls onFeedbackSubmit(req)
    ChatBotWindow->>Backend: POST /v1/feedback (with conversationId, question, answer, feedback, sentiment)
    Backend-->>ChatBotWindow: Returns response
    ChatBotWindow-->>BotMessage: Resolves feedback submission
Loading

Suggested labels

lgtm, size/XS

Suggested reviewers

  • ammont82

Poem

🐇
A bot now listens, keen and spry,
To feedback from both low and high.
With clicks and forms, your thoughts take flight,
The chat grows smarter, day and night.
So tell the bot what’s good or not—
It learns from every thought you jot!

"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

libs/chatbot/lib/components/ChatBot/BotMessage.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "@openshift-assisted/eslint-config" to extend from. Please check that the name of the config is correct.

The config "@openshift-assisted/eslint-config" was referenced from the config file in "/libs/chatbot/.eslintrc.cjs".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "@openshift-assisted/eslint-config" to extend from. Please check that the name of the config is correct.

The config "@openshift-assisted/eslint-config" was referenced from the config file in "/libs/chatbot/.eslintrc.cjs".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 65004e3 and bad36f4.

📒 Files selected for processing (2)
  • libs/chatbot/lib/components/ChatBot/BotMessage.tsx (1 hunks)
  • libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: celdrake
PR: openshift-assisted/assisted-installer-ui#3051
File: libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx:196-222
Timestamp: 2025-07-18T12:35:50.865Z
Learning: In the assisted-installer-ui chatbot feedback implementation, the onFeedbackSubmit callback requires access to the messages array to retrieve both the bot response content and the associated user question for the API call, making it necessary to include messages in the useCallback dependency array rather than passing message content as props to avoid duplicating potentially long message data.
libs/chatbot/lib/components/ChatBot/BotMessage.tsx (1)
Learnt from: celdrake
PR: openshift-assisted/assisted-installer-ui#3051
File: libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx:196-222
Timestamp: 2025-07-18T12:35:50.865Z
Learning: In the assisted-installer-ui chatbot feedback implementation, the onFeedbackSubmit callback requires access to the messages array to retrieve both the bot response content and the associated user question for the API call, making it necessary to include messages in the useCallback dependency array rather than passing message content as props to avoid duplicating potentially long message data.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: translation-files
  • GitHub Check: circular-deps
  • GitHub Check: tests
  • GitHub Check: lint
  • GitHub Check: format
  • GitHub Check: unit-tests
🔇 Additional comments (5)
libs/chatbot/lib/components/ChatBot/BotMessage.tsx (5)

1-13: LGTM: Well-structured imports and type definitions.

The imports are appropriate and the FeedbackRequest type is well-defined with clear field names and types that align with the component's functionality.


15-51: LGTM: Well-structured helper functions.

The helper functions create appropriate configuration objects for actions and feedback form. The use of modern clipboard API is appropriate.


53-66: LGTM: Well-typed component props and clean state management.

The component props are clearly defined with appropriate TypeScript types, and the state management is simple and effective.


68-79: LGTM: Improved scrolling implementation.

The double requestAnimationFrame approach effectively ensures the feedback form is fully rendered and painted before scrolling, addressing the previous concern about arbitrary timeouts.


126-129: LGTM: Clean component rendering.

The component rendering is straightforward and properly integrates with the PatternFly Message component.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@openshift-ci openshift-ci bot requested review from ElayAharoni and jgyselov July 18, 2025 11:10
@openshift-ci openshift-ci bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 18, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jul 18, 2025

@celdrake: This pull request references MGMT-21122 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.20.0" version, but no target version was set.

Details

In response to this:

Adds a new Feedback form to the Chatbot's responses.

chatbot-feedback-final.mp4

Summary by CodeRabbit

  • New Features

  • Added the ability for users to provide positive or negative feedback on chatbot responses, including optional comments for negative feedback.

  • Users can now copy chatbot message text to the clipboard directly from the chat interface.

  • Improvements

  • Enhanced accessibility and feedback form usability for a better user experience.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (3)
libs/chatbot/lib/components/ChatBot/BotMessage.tsx (2)

34-34: Remove unnecessary void operator.

The onClick handler doesn't expect a return value, so the void operator is unnecessary.

-      void navigator.clipboard.writeText(text);
+      navigator.clipboard.writeText(text);

15-52: Consider extracting hardcoded strings for internationalization.

The hardcoded strings in getActions and userFeedbackForm should be extracted to support internationalization if this is a requirement for your application.

libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx (1)

200-212: Verify backend endpoint and add tests.

Ensure that:

  1. The /v1/feedback endpoint is implemented on the backend
  2. Unit tests are added for the feedback functionality

Would you like me to help generate unit tests for the feedback functionality?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9248bdb and fdb4883.

📒 Files selected for processing (2)
  • libs/chatbot/lib/components/ChatBot/BotMessage.tsx (1 hunks)
  • libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx (8 hunks)
🔇 Additional comments (5)
libs/chatbot/lib/components/ChatBot/BotMessage.tsx (1)

3-3: Avoid importing from internal distribution paths

Deep imports from /dist/cjs/ are fragile and can break when the library is updated. Based on the current PatternFly ChatBot documentation and published package metadata, UserFeedbackProps is not exposed from the main @patternfly-6/chatbot entry point.

• Verify whether UserFeedbackProps appears in the package’s TypeScript declaration files (e.g. inspect node_modules/@patternfly-6/chatbot/dist/esm/index.d.ts).
• If it isn’t publicly exported:
– File an issue or PR against PatternFly ChatBot to expose this type in the main entry.
– Or define a local equivalent interface for UserFeedbackProps until an official export is available.

libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx (4)

27-29: Good use of constants for role values.

Extracting role strings as constants improves maintainability and reduces the chance of typos.


53-71: Well-implemented helper function.

The function correctly handles edge cases and uses defensive programming with the String() conversion.


89-92: Clean implementation of scroll callback.

Good use of useCallback for performance optimization.


270-287: Clean implementation of conditional message rendering.

The logic properly distinguishes between bot and user messages, and the key generation strategy is appropriate.

@celdrake celdrake force-pushed the MGMT-21122-feedback-form branch from fdb4883 to 65004e3 Compare July 18, 2025 12:45
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jul 18, 2025

@celdrake: This pull request references MGMT-21122 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.20.0" version, but no target version was set.

Details

In response to this:

Adds a new Feedback form to the Chatbot's responses.

chatbot-feedback-final.mp4

Summary by CodeRabbit

  • New Features

  • Added the ability for users to provide positive or negative feedback on chatbot responses, including optional comments for negative feedback.

  • Users can now copy chatbot message text to the clipboard directly from the chat interface.

  • Improvements

  • Enhanced accessibility and feedback form usability for a better user experience.

  • Improved chat message rendering with clearer distinction between user and bot messages.

  • Added smooth scrolling to the latest messages when feedback forms are opened.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@celdrake celdrake force-pushed the MGMT-21122-feedback-form branch from 65004e3 to bad36f4 Compare July 18, 2025 13:09
@eranco74
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 20, 2025
@ammont82
Copy link
Member

/cherry-pick releases/v2.43

@openshift-cherrypick-robot
Copy link
Contributor

@ammont82: once the present PR merges, I will cherry-pick it on top of releases/v2.43 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick releases/v2.43

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci
Copy link

openshift-ci bot commented Jul 21, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ammont82, celdrake

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ammont82 ammont82 merged commit 11f44cb into openshift-assisted:master Jul 21, 2025
11 checks passed
@openshift-cherrypick-robot
Copy link
Contributor

@ammont82: new pull request created: #3052

Details

In response to this:

/cherry-pick releases/v2.43

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants