Skip to content

Conversation

@its-mitesh-kumar
Copy link
Member

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

Description

  • Adds Escape key functionality to cycle through chatbot display modes
  • Pressing Escape transitions: Fullscreen → Docked → Overlay → Close (FAB only)
  • Settings dropdown closes on first Escape; display mode cycles on subsequent presses
  • Works correctly across all display modes without breaking existing functionality

UI after changes

Screen.Recording.2026-01-27.at.10.42.18.PM.mov

Fixes

✔️ 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 <itsmiteshkumar98@gmail.com>
Signed-off-by: its-mitesh-kumar <itsmiteshkumar98@gmail.com>
@its-mitesh-kumar
Copy link
Member Author

/cc @HusneShabbir @aprilma419

@rhdh-gh-app
Copy link

rhdh-gh-app bot commented Jan 27, 2026

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-lightspeed workspaces/lightspeed/plugins/lightspeed patch v1.2.2

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.

I've observed a deviation where using the keyboard's Escape key to exit the chat actions menu impacts the Lightspeed display mode. This issue occurs most of the time and is reproducible. Please find the attached recording for reference.

Screen.Recording.2026-01-27.at.11.53.54.PM.mov

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.

@aprilma419 what’s your take on the above observation?

@aprilma419
Copy link

@HusneShabbir looks good, didn't see any issues so far IMO

Copy link
Member

@karthikjeeyar karthikjeeyar left a comment

Choose a reason for hiding this comment

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

Good job! I have a suggestion on finding the open modals, PTAL

Comment on lines +228 to +234
// Check if any modal dialog is currently visible (Delete, Rename, etc.)
const hasOpenModal = document.querySelector('.MuiDialog-root');

// If settings dropdown or modal is open, let those handle Escape first
if (isSettingsDropdownOpen || hasOpenModal) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

This is a brittle implementation and could break if MUI class names are changed or if we start using BUI instead of MUI.

const hasOpenModal = document.querySelector('.MuiDialog-root');

Comment on lines +84 to +88
isSettingsDropdownOpen: boolean;
/**
* Setter for settings dropdown open state
*/
setIsSettingsDropdownOpen: (isOpen: boolean) => void;
Copy link
Member

Choose a reason for hiding this comment

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

This is related to my previous comment.

Can you use similar approach to track if the rename/delete/attachment modals are open so that you can use that information to see if any modals are open, rather than relying on className .MuiDialog-root ?

pseudo code:

  const [openModals, setOpenModals] = useState<Set<string>>(new Set());

 const openModal = useCallback((modalId: string) => {
    setOpenModals(prev => new Set(prev).add(modalId));
  }, []);

  const closeModal = useCallback((modalId: string) => {
    setOpenModals(prev => {
      const next = new Set(prev);
      next.delete(modalId);
      return next;
    });
    

Then context can expose method and properties like openModal, closeModal, hasOpenModals etc, so that you can use this to decide whether to perform any action or not.

Copy link
Member

Choose a reason for hiding this comment

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

The above code can become complex, see my latest comment below, we dont need to maintain modalIds instead we can have a simple boolean to track if there any nestedModals Open and based on that we can avoid closing the main chatbot.

@sonarqubecloud
Copy link

@karthikjeeyar
Copy link
Member

karthikjeeyar commented Jan 29, 2026

Is this a new feature pressing escape to cycle through display mode? I can see this works only once, if you again go to the fullscreen for the second round and pressing escape does nothing, is this expected?

More over I can still reproduce the issue outlined in this https://issues.redhat.com/browse/RHDHBUGS-2490 ticket. If I open a rename modal (from overlay mode) and press Escape it is closing the chatbot.

Modal_closing

@karthikjeeyar
Copy link
Member

I had taken a closer look at the code changes.

When Escape is pressed on nested modals (DeleteModal, Rename, Attachment Modals etc), the event bubbles to the parent ChatbotModal, causing closeChatbot() to run and close the entire chatbot instead of just the nested modal.

I would expect closeChatbot should early return the escape events when any of the modals are open. IMO we should not mix feature and bug fix in a PR as this could become problematic especially when you want to backport a fix to earlier backstage version, I would keep create two PRs one for bug fix and one for the display cycle feature (if we want this).

@debsmita1
Copy link
Member

I agree with @karthikjeeyar. Let’s avoid over-complicating the Esc key behavior. Since display mode selection is now persisted, cycling through display modes on Esc would unnecessarily complicate that logic. Instead, pressing Esc should first close any open modal or the Lightspeed settings dropdown; pressing it again should close the chatbot

cc @aprilma419

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