Skip to content

MGMT-21595: Chatbot conversation history#3131

Merged
openshift-merge-bot[bot] merged 2 commits intoopenshift-assisted:masterfrom
rawagner:conv_history
Aug 25, 2025
Merged

MGMT-21595: Chatbot conversation history#3131
openshift-merge-bot[bot] merged 2 commits intoopenshift-assisted:masterfrom
rawagner:conv_history

Conversation

@rawagner
Copy link
Member

@rawagner rawagner commented Aug 25, 2025

Screenshot From 2025-08-25 09-01-27

Summary by CodeRabbit

  • New Features

    • Chat history drawer to browse and open past conversations; can start a new chat from the drawer.
    • Ability to load a past conversation into the chat view.
  • Improvements

    • Loading spinner and disabled send button while conversations load.
    • Clear empty and error states for conversation history.
    • Updated header with menu to toggle history and a dedicated close control.
  • Refactor

    • Removed the previous confirmation modal for starting a new chat.

@openshift-ci openshift-ci bot requested review from ammont82 and jgyselov August 25, 2025 06:56
@coderabbitai
Copy link

coderabbitai bot commented Aug 25, 2025

Walkthrough

Adds a ChatBotHistory drawer component that fetches and displays conversation history, integrates it into ChatBotWindow (replacing the confirm modal flow), removes ConfirmNewChatModal, and extends useMessages with isLoading and loadConversation to fetch specific conversations.

Changes

Cohort / File(s) Summary
New history drawer component
libs/chatbot/lib/components/ChatBot/ChatBotHistory.tsx
New React component rendering a PatternFly drawer: fetches /v1/conversations via onApiCall, validates/parses/sorts results, maps to internal items, manages isLoading/error/empty states, and wires actions (new chat, select conversation, open/close).
Chat window integration & UI restructuring
libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx
Integrates ChatBotHistory, adds isLoading and loadConversation props, replaces previous header/new-chat UI with header menu and close button, manages drawer state, adjusts focus/scroll effects, shows spinner EmptyState when loading, and disables send while loading.
Removed confirmation modal
libs/chatbot/lib/components/ChatBot/ConfirmNewChatModal.tsx
Deleted ConfirmNewChatModal and its export/usages.
Hook enhancements for conversation loading
libs/chatbot/lib/hooks/use-message.ts
Exposes isLoading and loadConversation(convId), fetches /v1/conversations/{id}, maps chat_history to UI message props (including timestamps and roles), manages loading and errors, and clears/sets messages accordingly.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant W as ChatBotWindow
  participant H as ChatBotHistory
  participant M as useMessages
  participant API as Backend API

  U->>W: Open history menu
  W->>H: setIsOpen(true)
  H->>API: GET /v1/conversations
  API-->>H: 200 JSON / Error
  alt success
    H->>H: parse, sort, map items
    H-->>U: display history list
  else error
    H-->>U: show inline alert
  end

  U->>H: Select conversation (convId)
  H->>W: onSelectActiveItem(convId)
  W->>W: setTriggerScroll(0)
  W->>M: loadConversation(convId)
  M->>API: GET /v1/conversations/{convId}
  API-->>M: 200 JSON / Error
  alt success
    M->>M: map chat_history -> messages
    M-->>W: messages updated, isLoading=false
    W-->>U: render messages
  else error
    M-->>W: setError(msg), isLoading=false
    W-->>U: show error
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

lgtm

Suggested reviewers

  • ammont82
  • jgyselov
  • ElayAharoni

Poem

I hop and fetch the chats you store,
A drawer of tales from times before.
I nibble errors, spin a light,
Load old threads with whiskered delight.
Carrot-click—history at the door. 🥕

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5a8c66e and b4dcdde.

📒 Files selected for processing (3)
  • libs/chatbot/lib/components/ChatBot/ChatBotHistory.tsx (1 hunks)
  • libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx (5 hunks)
  • libs/chatbot/lib/hooks/use-message.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx
  • libs/chatbot/lib/components/ChatBot/ChatBotHistory.tsx
  • libs/chatbot/lib/hooks/use-message.ts
⏰ 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: tests
  • GitHub Check: unit-tests
  • GitHub Check: circular-deps
  • GitHub Check: lint
  • GitHub Check: format
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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 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 Aug 25, 2025
@rawagner rawagner changed the title Chatbot conversation history MGMT-21595: Chatbot conversation history Aug 25, 2025
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 25, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 25, 2025

@rawagner: This pull request references MGMT-21595 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:

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
Copy link

openshift-ci-robot commented Aug 25, 2025

@rawagner: This pull request references MGMT-21595 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:

Summary by CodeRabbit

  • New Features
  • Added a chat history drawer to browse and open past conversations.
  • Supports starting a new chat directly from the history panel.
  • Improvements
  • Loading state with spinner when retrieving conversation history or loading a conversation.
  • Clear empty and error states for conversation history.
  • Send button is disabled during loading to prevent duplicate actions.
  • Updated header with a menu to toggle the history drawer and a dedicated close button.
  • Refactor
  • Removed the previous “Confirm new chat” modal; new chat is managed via the history drawer.

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
Copy link

openshift-ci-robot commented Aug 25, 2025

@rawagner: This pull request references MGMT-21595 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:

Screenshot From 2025-08-25 09-01-27

Summary by CodeRabbit

  • New Features
  • Added a chat history drawer to browse and open past conversations.
  • Supports starting a new chat directly from the history panel.
  • Improvements
  • Loading state with spinner when retrieving conversation history or loading a conversation.
  • Clear empty and error states for conversation history.
  • Send button is disabled during loading to prevent duplicate actions.
  • Updated header with a menu to toggle the history drawer and a dedicated close button.
  • Refactor
  • Removed the previous “Confirm new chat” modal; new chat is managed via the history drawer.

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: 4

🧹 Nitpick comments (6)
libs/chatbot/lib/hooks/use-message.ts (2)

2-2: Decouple the hook from UI component types; use MsgProps[] directly.

The hook imports ChatBotWindowProps just to derive the messages state type. This creates an upward dependency from hooks → components and risks circular deps. Use MsgProps[] instead.

Apply this diff:

-import { ChatBotWindowProps } from '../components/ChatBot/ChatBotWindow';
+// Keep hooks independent of UI component types.
-  const [messages, setMessages] = React.useState<ChatBotWindowProps['messages']>([]);
+  const [messages, setMessages] = React.useState<MsgProps[]>([]);

Also applies to: 31-31


48-57: Guard against unexpected message types in history.

Backends may return roles beyond 'user'/'assistant' (e.g., 'system', 'tool'). Filter or map unknown types to avoid misrendering as user messages.

Apply this diff:

-        const msgs = conv.chat_history.flatMap(({ messages, completed_at }) => {
-          const timestamp = new Date(completed_at).toLocaleString();
-          return messages.map<MsgProps>(({ content, type }) => ({
+        const msgs = conv.chat_history.flatMap(({ messages, completed_at }) => {
+          const timestamp = Number.isNaN(Date.parse(completed_at))
+            ? new Date().toLocaleString()
+            : new Date(completed_at).toLocaleString();
+          return messages
+            .filter(({ type }) => type === 'assistant' || type === 'user')
+            .map<MsgProps>(({ content, type }) => ({
               pfProps: {
                 content,
                 role: type === 'assistant' ? botRole : userRole,
                 timestamp,
               },
             }));
         });

Follow-up: Should 'system' messages be shown separately (e.g., as an info banner)? If yes, I can wire a small transformer to emit them as a distinct UI block.

libs/chatbot/lib/components/ChatBot/ChatBotHistory.tsx (2)

17-19: Tighten the prop type for loadConversation to Promise for consistency.

The hook’s loadConversation returns Promise. Narrowing here improves type safety and readability.

-  loadConversation: (id: string) => Promise<unknown>;
+  loadConversation: (id: string) => Promise<void>;

91-95: Consider i18n/externalization for empty-state text.

'No conversation history' is user-facing. If the project is localized, route through your i18n layer.

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

121-123: Use functional state update when toggling the drawer.

Avoid stale closures by using the functional form.

-                onMenuToggle={() => setIsDrawerOpen(!isDrawerOpen)}
+                onMenuToggle={() => setIsDrawerOpen((prev) => !prev)}

137-145: Minor UX note: spinner replaces the entire content area.

Current behavior removes previous messages while loading a conversation. If retaining context while showing a loading overlay is preferable, render a semi-transparent overlay instead of swapping the whole content.

I can provide an overlay pattern using a conditional

to preserve scroll position and reduce jank.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e439417 and 5a8c66e.

📒 Files selected for processing (4)
  • libs/chatbot/lib/components/ChatBot/ChatBotHistory.tsx (1 hunks)
  • libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx (5 hunks)
  • libs/chatbot/lib/components/ChatBot/ConfirmNewChatModal.tsx (0 hunks)
  • libs/chatbot/lib/hooks/use-message.ts (3 hunks)
💤 Files with no reviewable changes (1)
  • libs/chatbot/lib/components/ChatBot/ConfirmNewChatModal.tsx
🧰 Additional context used
🧬 Code graph analysis (2)
libs/chatbot/lib/hooks/use-message.ts (2)
libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx (1)
  • ChatBotWindowProps (31-46)
libs/chatbot/lib/components/ChatBot/helpers.ts (4)
  • MsgProps (6-9)
  • botRole (12-12)
  • userRole (13-13)
  • getErrorMessage (15-23)
libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx (1)
libs/chatbot/lib/components/ChatBot/helpers.ts (2)
  • botRole (12-12)
  • MESSAGE_BAR_ID (11-11)
⏰ 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: tests
  • GitHub Check: translation-files
  • GitHub Check: format
  • GitHub Check: circular-deps
  • GitHub Check: lint
  • GitHub Check: unit-tests
🔇 Additional comments (1)
libs/chatbot/lib/hooks/use-message.ts (1)

39-39: Confirm desired UX when load fails after selecting a conversation.

You set conversationId before the fetch. If the fetch fails, the UI highlights the selected conversation but shows an error and empty content. If the desired behavior is to keep the previous conversation selected on failure, move setConversationId to run after a successful fetch (see previous diff), or revert conversationId in the catch.

I can adjust based on your preference.

Copy link
Contributor

@celdrake celdrake left a comment

Choose a reason for hiding this comment

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

Just some small suggestions from CodeRabbit and for better clarity.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 25, 2025
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 25, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 25, 2025

@rawagner: This pull request references MGMT-21595 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:

Screenshot From 2025-08-25 09-01-27

Summary by CodeRabbit

  • New Features

  • Chat history drawer to browse and open past conversations; can start a new chat from the drawer.

  • Ability to load a past conversation into the chat view.

  • Improvements

  • Loading spinner and disabled send button while conversations load.

  • Clear empty and error states for conversation history.

  • Updated header with menu to toggle history and a dedicated close control.

  • Refactor

  • Removed the previous confirmation modal for starting a new chat.

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 openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 25, 2025
@openshift-ci
Copy link

openshift-ci bot commented Aug 25, 2025

[APPROVALNOTIFIER] This PR is APPROVED

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

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

@openshift-merge-bot openshift-merge-bot bot merged commit 6c66ff9 into openshift-assisted:master Aug 25, 2025
11 checks passed
@rawagner
Copy link
Member Author

/cherry-pick releases/v0.1-chatbot

@openshift-cherrypick-robot
Copy link
Contributor

@rawagner: new pull request created: #3134

Details

In response to this:

/cherry-pick releases/v0.1-chatbot

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.

4 participants