Skip to content

Draft: Add conversation persistence and history drawer#1587

Draft
onmete wants to merge 1 commit intoopenshift:mainfrom
onmete:conversation-persistence-draft
Draft

Draft: Add conversation persistence and history drawer#1587
onmete wants to merge 1 commit intoopenshift:mainfrom
onmete:conversation-persistence-draft

Conversation

@onmete
Copy link
Contributor

@onmete onmete commented Mar 4, 2026

Summary

Draft PR for reference — demonstrates how conversation persistence and a history drawer can be implemented in the OLS console plugin.

  • Session persistence: Stores the active conversation_id in localStorage; on page refresh, restores the last conversation by fetching its history from the OLS service (GET /v1/conversations/{id})
  • Conversation history drawer: Integrates PatternFly's ChatbotConversationHistoryNav inside the Chatbot component, providing a searchable side panel to browse, switch between, and delete past conversations (GET /v1/conversations, DELETE /v1/conversations/{id})
  • Layout preservation: The drawer is placed inside the Chatbot component (not wrapping it) to preserve the position: fixed floating overlay behavior

Files changed

File Purpose
src/conversations.ts New module: API calls (list/fetch/delete), response types, transformChatHistory, localStorage helpers
src/hooks/useConversationRestore.ts New hook: restores last conversation from localStorage + OLS service on mount
src/components/GeneralPage.tsx Integrates ChatbotConversationHistoryNav drawer with conversation list, search, select, delete, new chat
src/components/Popover.tsx Gates first-time-user auto-open on conversation restore completion
src/components/Prompt.tsx Saves conversation_id to localStorage on stream start event
src/redux-actions.ts New actions: setConversations, removeConversation, setIsConversationsLoading
src/redux-reducers.ts New state: conversations, isConversationsLoading + reducer cases
src/types.ts New type: ConversationSummary
locales/en/plugin__lightspeed-console-plugin.json New i18n strings for conversation history UI

Architecture notes

  • ChatbotConversationHistoryNav must be a child of Chatbot, not a wrapper. Wrapping Chatbot in the drawer breaks the position: fixed overlay and causes the chat to render in normal document flow above the OKD console.
  • Conversations are grouped by date (Today / Previous 7 days / Previous 30 days / Older) using last_message_timestamp from the OLS service.
  • The useConversationRestore hook runs once on mount and signals completion via a boolean return, allowing dependent effects (like first-time-user auto-open) to wait.

Test plan

  • Send a message, refresh the page — conversation should be restored automatically
  • Open the conversation history drawer — all past conversations should be listed
  • Search conversations by topic summary
  • Select a different conversation — chat panel should switch to it
  • Delete a conversation from the drawer menu
  • Delete the active conversation — chat panel should clear
  • Click "New chat" — should clear the panel and start fresh
  • Verify the chat remains a floating overlay on the right (not pushing OKD console content down)

Made with Cursor

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 4, 2026
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 4, 2026
@openshift-ci
Copy link

openshift-ci bot commented Mar 4, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kyoto for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Persist the active conversation across page refreshes using localStorage
and the OLS service conversation endpoints. Add a conversation history
drawer (ChatbotConversationHistoryNav) that lets users browse, search,
switch between, and delete past conversations.

Key changes:
- New src/conversations.ts: API calls (list/fetch/delete), response types,
  transformChatHistory mapping, and localStorage helpers
- New useConversationRestore hook: restores last conversation on mount
- Redux: add conversations list, isConversationsLoading state, and actions
- GeneralPage: integrate conversation history drawer inside Chatbot
  (drawer must be inside Chatbot to preserve position:fixed overlay)
- Prompt: save conversation_id to localStorage on stream start event
- Popover: gate first-time-user auto-open on conversation restore
- Types: add ConversationSummary type
- i18n: add conversation UI strings

Made-with: Cursor
@onmete onmete force-pushed the conversation-persistence-draft branch from 04288ac to ca145b7 Compare March 4, 2026 15:33
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants