@@ -31,6 +31,8 @@ import {
3131} from 'react-dropzone' ;
3232import { useLocation , useMatch , useNavigate } from 'react-router-dom' ;
3333
34+ import { configApiRef , useApi } from '@backstage/core-plugin-api' ;
35+
3436import { Button , makeStyles } from '@material-ui/core' ;
3537import {
3638 Chatbot ,
@@ -87,6 +89,7 @@ import {
8789 useLastOpenedConversation ,
8890 useLightspeedDeletePermission ,
8991 useLightspeedNotebooksPermission ,
92+ useNotebookConversationIds ,
9093 useNotebookSession ,
9194 useNotebookSessions ,
9295 usePinnedChatsSettings ,
@@ -614,9 +617,16 @@ export const LightspeedChat = ({
614617 const classes = useStyles ( ) ;
615618 const { t } = useTranslation ( ) ;
616619 const navigate = useNavigate ( ) ;
620+ const configApi = useApi ( configApiRef ) ;
621+ const notebooksEnabled =
622+ configApi . getOptionalBoolean ( 'lightspeed.notebooks.enabled' ) ?? false ;
617623 const notebooksRouteMatch = useMatch ( '/lightspeed/notebooks' ) ;
618624 const notebookViewRouteMatch = useMatch ( '/lightspeed/notebooks/:notebookId' ) ;
619625 const routeNotebookId = notebookViewRouteMatch ?. params ?. notebookId ;
626+ const isOnNotebookRoute = Boolean (
627+ notebooksRouteMatch || notebookViewRouteMatch ,
628+ ) ;
629+ const shouldShowTabs = notebooksEnabled || isOnNotebookRoute ;
620630 const {
621631 displayMode,
622632 setDisplayMode,
@@ -656,6 +666,9 @@ export const LightspeedChat = ({
656666 useLightspeedNotebooksPermission ( ) ;
657667 const notebooksPermissionResolved =
658668 ! notebooksPermissionLoading && hasNotebooksAccess ;
669+
670+ const { data : notebookConversationIdsArray = [ ] } =
671+ useNotebookConversationIds ( ) ;
659672 const { data : notebooks = [ ] , refetch : refetchNotebooks } =
660673 useNotebookSessions ( notebooksPermissionResolved ) ;
661674 const hasNotebooks = notebooks . length > 0 ;
@@ -715,9 +728,9 @@ export const LightspeedChat = ({
715728 const wasStoppedByUserRef = useRef ( false ) ;
716729 const { isReady, lastOpenedId, setLastOpenedId, clearLastOpenedId } =
717730 useLastOpenedConversation ( user ) ;
718- // Chat vs Notebooks tabs are fullscreen-only; overlay and docked always show Chat.
719731 const showChatPanel = ! isFullscreenMode || activeTab === 0 ;
720- const showNotebooksPanel = isFullscreenMode && activeTab !== 0 ;
732+ const showNotebooksPanel =
733+ ( notebooksEnabled || isOnNotebookRoute ) && activeTab !== 0 ;
721734 const [ isChatHistoryDrawerOpen , setIsChatHistoryDrawerOpen ] =
722735 useState < boolean > ( ! isMobile && isFullscreenMode ) ;
723736
@@ -1193,13 +1206,8 @@ export const LightspeedChat = ({
11931206 ) ;
11941207
11951208 const notebookConversationIds = useMemo (
1196- ( ) =>
1197- new Set (
1198- notebooks
1199- . map ( n => n . metadata ?. conversation_id )
1200- . filter ( ( id ) : id is string => ! ! id ) ,
1201- ) ,
1202- [ notebooks ] ,
1209+ ( ) => new Set ( notebookConversationIdsArray ) ,
1210+ [ notebookConversationIdsArray ] ,
12031211 ) ;
12041212
12051213 const chatOnlyConversations = useMemo (
@@ -1928,8 +1936,10 @@ export const LightspeedChat = ({
19281936 onMcpSettingsClick = { ( ) => setIsMcpSettingsOpen ( true ) }
19291937 />
19301938 </ ChatbotHeader >
1931- { isFullscreenMode && < div className = { classes . headerDivider } /> }
1932- { isFullscreenMode && (
1939+ { isFullscreenMode && shouldShowTabs && (
1940+ < div className = { classes . headerDivider } />
1941+ ) }
1942+ { isFullscreenMode && shouldShowTabs && (
19331943 < >
19341944 < Tabs
19351945 activeKey = { activeTab }
@@ -2051,7 +2061,6 @@ export const LightspeedChat = ({
20512061 avatar = { avatar }
20522062 profileLoading = { profileLoading }
20532063 topicRestrictionEnabled = { topicRestrictionEnabled }
2054- selectedModel = { selectedModel }
20552064 onClose = { handleCloseNotebook }
20562065 />
20572066 ) }
0 commit comments