Skip to content

Commit 8adc39b

Browse files
authored
Merge pull request #1360 from WolframResearch/bugfix/Sidebar5
Bugfix/sidebar5
2 parents 6d98b4b + da0afa6 commit 8adc39b

File tree

9 files changed

+54
-25
lines changed

9 files changed

+54
-25
lines changed

FrontEnd/TextResources/ChatbookStrings.tr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@
214214
"MenuItemShowContentSuggestions" -> "AI Content Suggestion",
215215

216216
"SidebarToolbarButtonTooltipHideSidebar" -> "Hide notebook assistant",
217+
"SidebarToolbarButtonTooltipOpenAsWindowedAssistant" -> "Open as a separate window",
217218
"SidebarFocusIndicator" -> "Ignore notebook content",
218219

219220
"WorkspaceWindowTitle" -> "Notebook Assistant",

FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@
214214
"MenuItemShowContentSuggestions" -> "AI \:5185\:5BB9\:5EFA\:8BAE",
215215

216216
"SidebarToolbarButtonTooltipHideSidebar" -> "Hide notebook assistant",
217+
"SidebarToolbarButtonTooltipOpenAsWindowedAssistant" -> "Open as a separate window",
217218
"SidebarFocusIndicator" -> "Ignore notebook content",
218219

219220
"WorkspaceWindowTitle" -> "\:7B14\:8BB0\:672C\:52A9\:624B",

FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@
214214
"MenuItemShowContentSuggestions" -> "AI \:5167\:5BB9\:5EFA\:8B70",
215215

216216
"SidebarToolbarButtonTooltipHideSidebar" -> "Hide notebook assistant",
217+
"SidebarToolbarButtonTooltipOpenAsWindowedAssistant" -> "Open as a separate window",
217218
"SidebarFocusIndicator" -> "Ignore notebook content",
218219

219220
"WorkspaceWindowTitle" -> "\:7B46\:8A18\:672C\:5C0F\:5E6B\:624B",

FrontEnd/TextResources/French/ChatbookStrings.tr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@
214214
"MenuItemShowContentSuggestions" -> "Suggestion de contenu par l\[CloseCurlyQuote]IA",
215215

216216
"SidebarToolbarButtonTooltipHideSidebar" -> "Hide notebook assistant",
217+
"SidebarToolbarButtonTooltipOpenAsWindowedAssistant" -> "Open as a separate window",
217218
"SidebarFocusIndicator" -> "Ignore notebook content",
218219

219220
"WorkspaceWindowTitle" -> "Assistant de notebook",

FrontEnd/TextResources/Japanese/ChatbookStrings.tr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@
214214
"MenuItemShowContentSuggestions" -> "AI\:306B\:3088\:308B\:30B3\:30F3\:30C6\:30F3\:30C4\:306E\:63D0\:6848",
215215

216216
"SidebarToolbarButtonTooltipHideSidebar" -> "Hide notebook assistant",
217+
"SidebarToolbarButtonTooltipOpenAsWindowedAssistant" -> "Open as a separate window",
217218
"SidebarFocusIndicator" -> "Ignore notebook content",
218219

219220
"WorkspaceWindowTitle" -> "\:30ce\:30fc\:30c8\:30d6\:30c3\:30af\:30a2\:30b7\:30b9\:30bf\:30f3\:30c8",

FrontEnd/TextResources/Korean/ChatbookStrings.tr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@
214214
"MenuItemShowContentSuggestions" -> "AI\:C5D0 \:C758\:D55C \:CF58\:D150\:CE20 \:C81C\:C548",
215215

216216
"SidebarToolbarButtonTooltipHideSidebar" -> "Hide notebook assistant",
217+
"SidebarToolbarButtonTooltipOpenAsWindowedAssistant" -> "Open as a separate window",
217218
"SidebarFocusIndicator" -> "Ignore notebook content",
218219

219220
"WorkspaceWindowTitle" -> "\:B178\:D2B8\:BD81 \:C5B4\:C2DC\:C2A4\:D134\:D2B8",

FrontEnd/TextResources/Spanish/ChatbookStrings.tr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@
214214
"MenuItemShowContentSuggestions" -> "Sugerencia de contenido de IA",
215215

216216
"SidebarToolbarButtonTooltipHideSidebar" -> "Hide notebook assistant",
217+
"SidebarToolbarButtonTooltipOpenAsWindowedAssistant" -> "Open as a separate window",
217218
"SidebarFocusIndicator" -> "Ignore notebook content",
218219

219220
"WorkspaceWindowTitle" -> "Notebook Assistant",

Source/Chatbook/ChatModes/UI.wl

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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

331353
sidebarHideButton // beginDefinition;
332354

@@ -594,7 +616,7 @@ $toolbarButtonLight = Sequence[ Background -> color @ "NA_ToolbarLightButtonBa
594616
(*buttonTooltip*)
595617
buttonTooltip // beginDefinition;
596618
buttonTooltip[ 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 ] ];
598620
buttonTooltip // endDefinition;
599621

600622
(* ::**************************************************************************************************************:: *)
@@ -1985,9 +2007,9 @@ attachOverlayMenu[ nbo_NotebookObject, appContainer:None, name_String ] := Enclo
19852007
CellTags -> name,
19862008
Magnification -> Dynamic @ AbsoluteCurrentValue[ nbo, Magnification ]
19872009
],
1988-
{ Center, Top },
2010+
{ Left, Top },
19892011
0,
1990-
{ Center, Top }
2012+
{ Left, Top }
19912013
],
19922014
throwInternalFailure
19932015
];
@@ -2007,9 +2029,9 @@ attachOverlayMenu[ nbo_NotebookObject, sidebarCell_CellObject, name_String ] :=
20072029
CellTags -> name,
20082030
Magnification -> Dynamic[ 0.85*AbsoluteCurrentValue[ nbo, Magnification ] ]
20092031
],
2010-
{ Center, Bottom },
2032+
{ Left, Bottom },
20112033
0,
2012-
{ Center, Top }
2034+
{ Left, Top }
20132035
]
20142036
],
20152037
throwInternalFailure
@@ -2022,7 +2044,7 @@ attachedOverlayMenuFrame // beginDefinition;
20222044

20232045
attachedOverlayMenuFrame[ nbo_NotebookObject, appContainer_, content_ ] := Framed[
20242046
content,
2025-
Alignment -> { Center, Top },
2047+
Alignment -> { Left, Top },
20262048
Background -> color @ "NA_NotebookBackground",
20272049
FrameMargins -> { { 5, 5 }, { 5, 5 } },
20282050
FrameStyle -> color @ "NA_NotebookBackground",
@@ -2448,7 +2470,7 @@ makeDefaultHistoryView[ nbo_NotebookObject, appContainer_, Dynamic[ page_ ], Dyn
24482470

24492471
Pane[
24502472
Dynamic[ display, TrackedSymbols :> { display } ],
2451-
Alignment -> { Center, Top },
2473+
Alignment -> { Left, Top },
24522474
AppearanceElements -> { },
24532475
FrameMargins -> { { 0, 0 }, { 5, 5 } },
24542476
If[ MatchQ[ appContainer, _CellObject ],

Source/Chatbook/Settings.wl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,10 +1772,10 @@ currentChatSettings0[ cell_CellObject, key_String ] /; cellTaggedQ[ cell, "Noteb
17721772

17731773
currentChatSettings0[ cell_CellObject, key_String ] /; cellTaggedQ[ cell, "SidebarTopCell" ] :=
17741774
Lookup[
1775-
Replace[ CurrentValue[ cell, { TaggingRules, "ChatNotebookSettings" } ], Inherited -> <||> ],
1775+
Replace[ CurrentValue[ cell, { TaggingRules, "ChatNotebookSettings" } ], Except[ _Association ] -> <||> ],
17761776
key,
17771777
Lookup[
1778-
CurrentValue[ ParentCell @ ParentCell @ cell, { TaggingRules, "ChatNotebookSettings" } ],
1778+
Replace[ CurrentValue[ ParentCell @ ParentCell @ cell, { TaggingRules, "ChatNotebookSettings" } ], Except[ _Association ] -> <||> ],
17791779
key,
17801780
Lookup[
17811781
$cachedGlobalSettings,

0 commit comments

Comments
 (0)