MGMT-21595: Chatbot conversation history#3131
MGMT-21595: Chatbot conversation history#3131openshift-merge-bot[bot] merged 2 commits intoopenshift-assisted:masterfrom
Conversation
WalkthroughAdds 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 Changes
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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 detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
⏰ 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)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@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. DetailsIn 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. |
|
@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. DetailsIn 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. |
|
@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. DetailsIn 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. |
There was a problem hiding this comment.
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.
📒 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.
celdrake
left a comment
There was a problem hiding this comment.
Just some small suggestions from CodeRabbit and for better clarity.
|
@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. DetailsIn 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. |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
6c66ff9
into
openshift-assisted:master
|
/cherry-pick releases/v0.1-chatbot |
|
@rawagner: new pull request created: #3134 DetailsIn 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 kubernetes-sigs/prow repository. |

Summary by CodeRabbit
New Features
Improvements
Refactor