Skip to content

Conversation

@its-mitesh-kumar
Copy link
Member

@its-mitesh-kumar its-mitesh-kumar commented Jan 6, 2026

Description

Adds conversation sorting and per-user settings persistence using Backstage's StorageApi. Users can now sort conversations by date (newest/oldest) or name (A-Z/Z-A) via a dropdown next to the search input. Pinned chats, the pinned chats toggle state, and sort order now persist across sessions, scoped per-user. Upgraded @patternfly/chatbot to 6.5.0-prerelease.28 for searchActionEnd prop support.

Fixes

UI after Changes

Screen.Recording.2026-01-05.at.10.04.13.PM.mov

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

Signed-off-by: its-mitesh-kumar <[email protected]>
Signed-off-by: its-mitesh-kumar <[email protected]>
Signed-off-by: its-mitesh-kumar <[email protected]>
@rhdh-gh-app
Copy link

rhdh-gh-app bot commented Jan 6, 2026

Important

This PR includes changes that affect public-facing API. Please ensure you are adding/updating documentation for new features or behavior.

Changed Packages

Package Name Package Path Changeset Bump Current Version
app workspaces/lightspeed/packages/app none v0.0.0
@red-hat-developer-hub/backstage-plugin-lightspeed workspaces/lightspeed/plugins/lightspeed minor v1.1.1

@its-mitesh-kumar its-mitesh-kumar changed the title Feat/lightspeed chat sorting clean feat(lightspeed): add conversation sorting with persistence, persisting pinned chats and pinned chats toggle per-user Jan 6, 2026
Signed-off-by: its-mitesh-kumar <[email protected]>
Signed-off-by: its-mitesh-kumar <[email protected]>
Copy link
Contributor

@HusneShabbir HusneShabbir left a comment

Choose a reason for hiding this comment

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

works as expected,
/lgtm
Screenshot 2026-01-06 at 6 38 11 PM

HusneShabbir and others added 2 commits January 7, 2026 14:30
@openshift-ci
Copy link

openshift-ci bot commented Jan 7, 2026

New changes are detected. LGTM label has been removed.

@openshift-ci openshift-ci bot removed the lgtm label Jan 7, 2026
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 8, 2026

Copy link
Member

@debsmita1 debsmita1 left a comment

Choose a reason for hiding this comment

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

Tested the changes locally

Screen.Recording.2026-01-09.at.12.42.57.PM.mov

const sortData = sortSnapshot.value ?? {};

setIsPinningChatsEnabled(
(enabledData[user] as boolean | undefined) ?? true,
Copy link
Member

Choose a reason for hiding this comment

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

for Guest users, avoid persisting the preferences

}, []);

const onSortSelect = useCallback(
(_event?: React.MouseEvent<Element>, value?: string | number) => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
(_event?: React.MouseEvent<Element>, value?: string | number) => {
(_event?: MouseEvent<Element>, value?: string | number) => {

);

const sortToggle = useCallback(
(toggleRef: React.Ref<MenuToggleElement>) => (
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
(toggleRef: React.Ref<MenuToggleElement>) => (
(toggleRef: Ref<MenuToggleElement>) => (

* Hook to manage pinned chats settings with persistence using Backstage StorageApi.
* Settings are scoped per-user to support multi-user environments.
*
* @param user - The user entity ref (e.g., "user:default/guest")
Copy link
Member

Choose a reason for hiding this comment

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

for Guest users, avoid persisting the preferences

handlePinningChatsToggle,
pinChat,
unpinChat,
handleSortChange,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to combine sorting and pinning logic into one hook? It would be better if sorting and pinning logic are separated into there own hooks. Easier to read and maintain. Plus sorting action won't affect pinning data to cause rerenders and vice versa.

"@backstage/theme": "^0.7.0",
"@material-ui/core": "^4.9.13",
"@material-ui/lab": "^4.0.0-alpha.61",
"@monaco-editor/react": "^4.7.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this PR adding monaco editor as a dependency here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@monaco-editor/react and @monaco-editor are required peer dependencies of @patternfly/[email protected]. We upgraded to this prerelease version to use the new searchActionEnd prop on ChatbotConversationHistoryNav for the sort dropdown feature.

Copy link
Member

@debsmita1 debsmita1 Jan 9, 2026

Choose a reason for hiding this comment

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

The chatbot pre-release verison adds monaco-editor as a peer-dependency, without this in our dependency shows module not found errs

@debsmita1
Copy link
Member

debsmita1 commented Jan 9, 2026

@its-mitesh-kumar
I have tested this on RHDH with the following configuration:

red-hat-developer-hub.backstage-plugin-lightspeed:
      translationResources:
        - importName: lightspeedTranslations
          module: Alpha
          ref: lightspeedTranslationRef
      appIcons:
        - name: LightspeedIcon
          module: LightspeedPlugin
          importName: LightspeedIcon
      dynamicRoutes:
        - path: /lightspeed
          importName: LightspeedPage
          module: LightspeedPlugin
          menuItem:
            icon: LightspeedIcon
            text: Lightspeed
userSettings:
  persistence: browser

My chat preferences persist, but when switching to the database

userSettings:
  persistence: database

My preferences are not saved

Comment on lines +130 to +132
const chatsData = { ...chatsSnapshot.value };
chatsData[user] = updated;
bucket.set(PINNED_CHATS_KEY, chatsData);
Copy link
Member

Choose a reason for hiding this comment

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

Remove the user information in the user settings bucket value.

Usersettings backend will work based on the user token attached in the request header, you do not need to save or send the user information explicitly. The backend automatically attaches the logged in userEntityRef and uses that for all the GET, PUT, DELETE methods.

userSettingsKeyValue

Comment on lines +156 to +157
chatsData[user] = updated;
bucket.set(PINNED_CHATS_KEY, chatsData);
Copy link
Member

Choose a reason for hiding this comment

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

same here, refer my above comment.

Copy link
Member

Choose a reason for hiding this comment

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

Yi is currently adding it and ja locales in rhdh-plugins repo in this PR #2009. Since these are new strings can you also use cursor to add strings for those locales?

So that we will at-least have the AI generated strings rather than completely missing out.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants