@@ -75,7 +75,7 @@ makeSidebarChatDockedCell[ ] := With[ { nbo = EvaluationNotebook[ ], sidebarCell
7575 Item [ Spacer [ 0 ], ItemSize -> Fit ],
7676 LogChatTiming @ sidebarSourcesButton [ Dynamic @ nbo , Dynamic @ sidebarCell ],
7777 LogChatTiming @ sidebarHistoryButton [ Dynamic @ nbo , Dynamic @ sidebarCell ],
78- LogChatTiming @ sidebarOpenAsChatbookButton [ Dynamic @ nbo , Dynamic @ sidebarCell ],
78+ LogChatTiming @ sidebarOpenAsAssistantWindowButton [ Dynamic @ nbo , Dynamic @ sidebarCell ],
7979 sidebarHideButton [ Dynamic @ nbo ]
8080 } },
8181 Alignment -> { Automatic , Center },
@@ -305,28 +305,50 @@ sidebarNewChatButton // endDefinition;
305305
306306(* ::**************************************************************************************************************:: *)
307307(* ::Subsubsection::Closed:: *)
308- (*sidebarOpenAsChatbookButton*)
309- sidebarOpenAsChatbookButton // beginDefinition ;
310-
311- sidebarOpenAsChatbookButton [ Dynamic [ nbo_ ], Dynamic [ sidebarCell_ ] ] := Button [
312- Block [ { $AppType = "SidebarChat" }, toolbarButtonLabel [ "OpenAsChatbook" , None ] ],
313- NotebookPut @ cellsToChatNB [
314- ReplaceRepeated [
315- NotebookRead @ Cells [ First [ Cells [ sidebarCell , CellTags -> "SidebarScrollingContentCell" ], {} ], CellTags -> "SidebarTopCell" ], (* fail gracefully *)
316- (* so far there's only one TemplateBox that needs to be unconverted *)
317- TemplateBox [ a_ , b : Alternatives [ "NotebookAssistant`Sidebar`ChatCodeBlockTemplate" ], c___ ] :>
318- RuleCondition [ TemplateBox [ a , StringReplace [ b , StartOfString ~~ "NotebookAssistant`Sidebar`" -> "" , c ] ], True ]
319- ],
320- CurrentValue [ sidebarCell , { TaggingRules , "ChatNotebookSettings" } ] ],
308+ (*sidebarOpenAsAssistantWindowButton*)
309+ sidebarOpenAsAssistantWindowButton // beginDefinition ;
310+
311+ sidebarOpenAsAssistantWindowButton [ Dynamic [ nbo_ ], Dynamic [ sidebarCell_ ] ] := Button [
312+ Block [ { $AppType = "SidebarChat" }, toolbarButtonLabel [ "OpenAsChatbook" , None , "OpenAsWindowedAssistant" , False ] ],
313+ With [
314+ {
315+ newNB = ShowNotebookAssistance [ nbo , "Window" ,
316+ "ChatNotebookSettings" -> KeyDrop [ CurrentValue [ sidebarCell , { TaggingRules , "ChatNotebookSettings" } ], "SidebarChat" ] ]
317+ },
318+ If [ MatchQ [ newNB , _ NotebookObject ],
319+ SelectionMove [ newNB , Before , Notebook ];
320+ NotebookWrite [
321+ newNB ,
322+ ReplaceRepeated [
323+ NotebookRead @ Cells [ First [ Cells [ sidebarCell , CellTags -> "SidebarScrollingContentCell" ], {} ], CellTags -> "SidebarTopCell" ], (* fail gracefully *)
324+ (* so far there's only one TemplateBox that needs to be unconverted *)
325+ {
326+ Cell [ a_ , b___ String , c_ String /; StringStartsQ [ c , "NotebookAssistant`Sidebar`" ], d___ ] :>
327+ RuleCondition [ Cell [ a , b , StringReplace [ c , StartOfString ~~ "NotebookAssistant`Sidebar`" -> "" ], d ], True ],
328+ TemplateBox [ a_ , b_ String /; StringStartsQ [ b , "NotebookAssistant`Sidebar`" ], c___ ] :>
329+ RuleCondition [ TemplateBox [ a , StringReplace [ b , StartOfString ~~ "NotebookAssistant`Sidebar`" -> "" ], c ], True ]
330+ }
331+ ] ];
332+ attachWorkspaceChatInput @ newNB ;
333+
334+ (* remove sidebar and its content *)
335+ NotebookDelete @ Cells [ nbo , CellStyle -> "AttachedOverlayMenu" , AttachedCell -> True ];
336+ removeSidebarScrollingContentCell [ nbo , sidebarCell ];
337+ removeSidebarChatSubDockedCell [ nbo , sidebarCell ];
338+ CurrentChatSettings [ sidebarCell , "ConversationUUID" ] = CreateUUID [ ];
339+ CurrentValue [ sidebarCell , { TaggingRules , "ConversationTitle" } ] = "" ;
340+ FrontEndTokenExecute [ nbo , "HideSidebar" ];
341+ ]
342+ ],
321343 Appearance -> "Suppressed" ,
322344 Method -> "Queued"
323345];
324346
325- sidebarOpenAsChatbookButton // endDefinition ;
347+ sidebarOpenAsAssistantWindowButton // endDefinition ;
326348
327349(* ::**************************************************************************************************************:: *)
328350(* ::Subsubsection::Closed:: *)
329- (*sidebarOpenAsChatbookButton *)
351+ (*sidebarOpenAsAssistantWindowButton *)
330352
331353sidebarHideButton // beginDefinition ;
332354
@@ -594,7 +616,7 @@ $toolbarButtonLight = Sequence[ Background -> color @ "NA_ToolbarLightButtonBa
594616(*buttonTooltip*)
595617buttonTooltip // beginDefinition ;
596618buttonTooltip [ label_ , None ] := label ;
597- buttonTooltip [ label_ , name_ String ] := Tooltip [ label , tr [ "WorkspaceToolbarButtonTooltip" <> name ] ];
619+ buttonTooltip [ label_ , name_ String ] := Tooltip [ label , tr [ If [ $AppType === "SidebarChat" , "Sidebar" , "Workspace" ] <> "ToolbarButtonTooltip" <> name ] ];
598620buttonTooltip // endDefinition ;
599621
600622(* ::**************************************************************************************************************:: *)
0 commit comments