From 21800c17e6115ee7d3ae6bd42d6bc05f89a43714 Mon Sep 17 00:00:00 2001 From: Rick Hennigan Date: Wed, 27 Nov 2024 10:30:32 -0500 Subject: [PATCH 1/4] Revert "Pull request #104: French Translation Updates of ChatbookStrings.tr" This reverts commit 3b9a3d3a6e1af8212de0bd06555edb33c8253434, reversing changes made to 46ca461385415c10e93fe84e08f520fcf368c2e8. # Conflicts: # Source/Chatbook/Formatting.wl --- .../CodeBlocks/WorkspaceCodeBlockCopy.wl | 50 ++++ .../WorkspaceCodeBlockInsertAndEvaluate.wl | 32 ++ .../WorkspaceToolbarIconHistorySmall.wl | 16 + FrontEnd/TextResources/ChatbookResources.tr | 83 +++++- FrontEnd/TextResources/ChatbookStrings.tr | 3 + .../ChineseSimplified/ChatbookStrings.tr | 3 + .../ChineseTraditional/ChatbookStrings.tr | 3 + .../TextResources/French/ChatbookStrings.tr | 36 +-- .../TextResources/Japanese/ChatbookStrings.tr | 3 + .../TextResources/Korean/ChatbookStrings.tr | 3 + .../TextResources/Spanish/ChatbookStrings.tr | 43 +-- Source/Chatbook/ChatModes/ChatModes.wl | 1 + Source/Chatbook/ChatModes/Common.wl | 1 + Source/Chatbook/ChatModes/NotebookFocus.wl | 274 ++++++++++++++++++ .../ChatModes/ShowNotebookAssistance.wl | 78 ++++- Source/Chatbook/ChatModes/UI.wl | 219 +------------- Source/Chatbook/CommonSymbols.wl | 1 + Source/Chatbook/Formatting.wl | 90 +++++- Source/Chatbook/Main.wl | 2 + 19 files changed, 663 insertions(+), 278 deletions(-) create mode 100644 Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockCopy.wl create mode 100644 Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockInsertAndEvaluate.wl create mode 100644 Developer/Resources/FrontEndResources/WorkspaceChat/ToolbarIcon/WorkspaceToolbarIconHistorySmall.wl create mode 100644 Source/Chatbook/ChatModes/NotebookFocus.wl diff --git a/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockCopy.wl b/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockCopy.wl new file mode 100644 index 00000000..d6f9e35d --- /dev/null +++ b/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockCopy.wl @@ -0,0 +1,50 @@ +(* Created with the Wolfram Language : www.wolfram.com *) +RawBoxes @ ToBoxes @ +Graphics[{Thickness[0.125], + Style[{FilledCurve[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, + {{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, {0, 1, 0}, + {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, + {{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, {1, 3, 3}, + {0, 1, 0}, {1, 3, 3}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, + {0, 1, 0}, {1, 3, 3}, {0, 1, 0}, {1, 3, 3}, {0, 1, 0}, {1, 3, 3}, + {0, 1, 0}, {1, 3, 3}, {0, 1, 0}, {1, 3, 3}, {0, 1, 0}, {1, 3, 3}}}, + {{{6.822000026702881, 6.291999816894531}, {1.1779999732971191, + 6.291999816894531}, {1.1779999732971191, 7.008999824523926}, + {6.822000026702881, 7.008999824523926}, {6.822000026702881, + 6.291999816894531}}, {{6.822000026702881, 4.8580002784729}, + {1.1779999732971191, 4.8580002784729}, {1.1779999732971191, + 5.575000286102295}, {6.822000026702881, 5.575000286102295}, + {6.822000026702881, 4.8580002784729}}, + {{6.822000026702881, 3.4250001907348633}, {1.1779999732971191, + 3.4250001907348633}, {1.1779999732971191, 4.142000198364258}, + {6.822000026702881, 4.142000198364258}, {6.822000026702881, + 3.4250001907348633}}, {{6.822000026702881, 1.9910001754760742}, + {1.1779999732971191, 1.9910001754760742}, {1.1779999732971191, + 2.7080001831054688}, {6.822000026702881, 2.7080001831054688}, + {6.822000026702881, 1.9910001754760742}}, + {{2.800999879837036, 9.597000122070312}, {5.199999809265137, + 9.597000122070312}, {5.599999904632568, 8.79699993133545}, + {2.4010000228881836, 8.79699993133545}, {2.800999879837036, + 9.597000122070312}}, {{7.5, 9.}, {6.357000350952148, 9.}, + {6.3429999351501465, 9.052000045776367}, {6.340000152587891, + 9.105000495910645}, {6.315000534057617, 9.155000686645508}, + {5.914000511169434, 9.955999374389648}, {5.779999732971191, + 10.22700023651123}, {5.501999855041504, 10.398000717163086}, + {5.198999881744385, 10.397000312805176}, {4.801000118255615, + 10.397000312805176}, {4.801000118255615, 11.197000503540039}, + {3.2009999752044678, 11.197000503540039}, {3.2009999752044678, + 10.397000312805176}, {2.800999879837036, 10.397000312805176}, + {2.497999906539917, 10.398000717163086}, {2.2209999561309814, + 10.22700023651123}, {2.0850000381469727, 9.954999923706055}, + {1.6850000619888306, 9.155000686645508}, {1.6610000133514404, + 9.105999946594238}, {1.6660000085830688, 9.052000045776367}, + {1.6519999504089355, 9.}, {0.5, 9.}, {0.2239999920129776, 9.}, + {0., 8.775999069213867}, {0., 8.5}, {0., 0.5}, + {0., 0.2239999920129776}, {0.2239999920129776, 0.}, {0.5, 0.}, + {7.5, 0.}, {7.776000022888184, 0.}, {8., 0.2239999920129776}, + {8., 0.5}, {8., 8.5}, {8., 8.775999069213867}, + {7.776000022888184, 9.}, {7.5, 9.}}}]}, + FaceForm[RGBColor[0.2901960784313726, 0.5843137254901961, 0.8, 1.]]]}, + ImageSize -> {11., 16.}, PlotRange -> {{-0.5, 8.5}, + {-0.5, 11.697400093078613}}, AspectRatio -> Automatic, + BaselinePosition -> Center -> Center] diff --git a/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockInsertAndEvaluate.wl b/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockInsertAndEvaluate.wl new file mode 100644 index 00000000..6a6f4e22 --- /dev/null +++ b/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockInsertAndEvaluate.wl @@ -0,0 +1,32 @@ +(* Created with the Wolfram Language : www.wolfram.com *) +RawBoxes @ ToBoxes @ +Graphics[{Thickness[0.07016411257027613], + Style[{JoinedCurve[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, + {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, + {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, + {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}}, + {{{7.126100063323975, 14.347000122070312}, {5.716100096702576, + 11.91700005531311}, {3.158100128173828, 13.049000024795532}, + {3.4361002445220947, 10.248000144958496}, {0.7041001319885254, + 9.64900016784668}, {2.5631003379821777, 7.548000335693359}, + {0.7041001319885254, 5.446000099182129}, {3.4351003170013428, + 4.8470001220703125}, {3.156100034713745, 2.045999526977539}, + {5.716100096702576, 3.177000045776367}, {7.126100063323975, + 0.7469997406005859}, {8.536100029945374, 3.175999641418457}, + {11.094099998474121, 2.0450000762939453}, {10.816099882125854, + 4.845000267028809}, {13.548099994659424, 5.445000648498535}, + {11.689099788665771, 7.546000003814697}, {13.548099994659424, + 9.648000240325928}, {10.817099809646606, 10.247000217437744}, + {11.096100091934204, 13.04800009727478}, {8.536100029945374, + 11.91700005531311}, {7.126100063323975, 14.347000122070312}}}, + CurveClosed -> {1}]}, CapForm["Butt"], JoinForm[{"Miter", 1.}], + Thickness[0.05262308442770709], RGBColor[0.2901960784313726, + 0.5843137254901961, 0.8, 1.]], + Style[{FilledCurve[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}}}, + {{{5.526100158691406, 10.766900062561035}, {5.526100158691406, + 4.3668999671936035}, {10.32610034942627, 7.582900285720825}, + {5.526100158691406, 10.766900062561035}}}]}, + FaceForm[RGBColor[0.2901960784313726, 0.5843137254901961, 0.8, 1.]]]}, + ImageSize -> {16., 17.}, PlotRange -> {{-0.5, 14.752300262451172}, + {-0.5, 15.594200134277344}}, AspectRatio -> Automatic, + BaselinePosition -> Center -> Center] diff --git a/Developer/Resources/FrontEndResources/WorkspaceChat/ToolbarIcon/WorkspaceToolbarIconHistorySmall.wl b/Developer/Resources/FrontEndResources/WorkspaceChat/ToolbarIcon/WorkspaceToolbarIconHistorySmall.wl new file mode 100644 index 00000000..50a9093f --- /dev/null +++ b/Developer/Resources/FrontEndResources/WorkspaceChat/ToolbarIcon/WorkspaceToolbarIconHistorySmall.wl @@ -0,0 +1,16 @@ +(* Created with the Wolfram Language : www.wolfram.com *) +RawBoxes @ ToBoxes @ +Graphics[{Thickness[0.14285714285714285], + Style[{FilledCurve[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, + {{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, {0, 1, 0}, + {0, 1, 0}, {0, 1, 0}}}, {{{0., 4.800000190734863}, + {7., 4.800000190734863}, {7., 6.00100040435791}, + {0., 6.00100040435791}, {0., 4.800000190734863}}, + {{0., 2.3929998874664307}, {7., 2.3929998874664307}, + {7., 3.5939998626708984}, {0., 3.5939998626708984}, + {0., 2.3929998874664307}}, {{0., 0.}, {7., 0.}, + {7., 1.2000000476837158}, {0., 1.2000000476837158}, {0., 0.}}}]}, + FaceForm[RGBColor[0.2, 0.5137254901960784, 0.6745098039215687, 1.]]]}, + ImageSize -> {8., 7.}, PlotRange -> {{-0.5, 7.5}, {-0.5, 6.5}}, + AspectRatio -> Automatic, + BaselinePosition -> Center -> Center] diff --git a/FrontEnd/TextResources/ChatbookResources.tr b/FrontEnd/TextResources/ChatbookResources.tr index 2f719cc3..d5217f5a 100644 --- a/FrontEnd/TextResources/ChatbookResources.tr +++ b/FrontEnd/TextResources/ChatbookResources.tr @@ -6282,7 +6282,88 @@ TD2Mb3lNEkxzlMqBaSGoOMw9MD7MvTC+5EEUPjx8oOahhB8ACaE9/g== Background->GrayLevel[1, 0], BaseStyle->GrayLevel[1, 0], ImageSize->{168., 78.}, - PlotRange->{{-0.5, 167.5}, {-0.5, 77.5}}] + PlotRange->{{-0.5, 167.5}, {-0.5, 77.5}}], + +"WorkspaceToolbarIconHistorySmall" -> GraphicsBox[ + {Thickness[0.14285714285714285`], FaceForm[{RGBColor[ + 0.2, 0.5137254901960784, 0.6745098039215687], Opacity[1.]}], + FilledCurveBox[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, { + 0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, + 0}}}, {{{0., 4.800000190734863}, {7., 4.800000190734863}, {7., + 6.00100040435791}, {0., 6.00100040435791}, {0., 4.800000190734863}}, {{0., + 2.3929998874664307`}, {7., 2.3929998874664307`}, {7., + 3.5939998626708984`}, {0., 3.5939998626708984`}, {0., + 2.3929998874664307`}}, {{0., 0.}, {7., 0.}, {7., 1.2000000476837158`}, { + 0., 1.2000000476837158`}, {0., 0.}}}]}, + AspectRatio->Automatic, + BaselinePosition->(Center -> Center), + ImageSize->{8., 7.}, + PlotRange->{{-0.5, 7.5}, {-0.5, 6.5}}], + +"WorkspaceCodeBlockCopy" -> GraphicsBox[ + {Thickness[0.125], FaceForm[{RGBColor[ + 0.2901960784313726, 0.5843137254901961, 0.8], Opacity[1.]}], + FilledCurveBox[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, { + 0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, + 0}}, {{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, {0, 1, + 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, {1, 3, 3}, {0, 1, 0}, {1, 3, 3}, { + 0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {1, 3, 3}, {0, 1, + 0}, {1, 3, 3}, {0, 1, 0}, {1, 3, 3}, {0, 1, 0}, {1, 3, 3}, {0, 1, 0}, {1, + 3, 3}, {0, 1, 0}, {1, 3, 3}}}, {{{6.822000026702881, + 6.291999816894531}, {1.1779999732971191`, 6.291999816894531}, { + 1.1779999732971191`, 7.008999824523926}, {6.822000026702881, + 7.008999824523926}, {6.822000026702881, 6.291999816894531}}, {{ + 6.822000026702881, 4.8580002784729}, {1.1779999732971191`, + 4.8580002784729}, {1.1779999732971191`, 5.575000286102295}, { + 6.822000026702881, 5.575000286102295}, {6.822000026702881, + 4.8580002784729}}, {{6.822000026702881, 3.4250001907348633`}, { + 1.1779999732971191`, 3.4250001907348633`}, {1.1779999732971191`, + 4.142000198364258}, {6.822000026702881, 4.142000198364258}, { + 6.822000026702881, 3.4250001907348633`}}, {{6.822000026702881, + 1.9910001754760742`}, {1.1779999732971191`, 1.9910001754760742`}, { + 1.1779999732971191`, 2.7080001831054688`}, {6.822000026702881, + 2.7080001831054688`}, {6.822000026702881, 1.9910001754760742`}}, {{ + 2.800999879837036, 9.597000122070312}, {5.199999809265137, + 9.597000122070312}, {5.599999904632568, 8.79699993133545}, { + 2.4010000228881836`, 8.79699993133545}, {2.800999879837036, + 9.597000122070312}}, CompressedData[" +1:eJxTTMoPSmViYGBQBWIQDQFyDhBaCUQ3TMyVROYnWMeD+QfmS4H5DJoxYP6C +Q6YQ9f1OYL5DjD+Yf+D9cnEwXfFSGSy+Qw7MT7AsUQHzeZjEwPLHToP5C46d +FgHTzhB+gqWJMDa+w90UNRD9YOlsTmx8mPoFRRlsKPqf/2ZGsW/2EUZk9zSI +rGMAy399oQzx19df9sj+KZkM5i9wNQPzF7xfDubDwqNheh6YDwsvkJOQ+Qoc +a86gyYPBAf9eRWQ+EKDzYeaAAcwcJPOwqmNAxCfEnvlS8mjmKqC5SwHN3TA+ +zD1gPsy9SObB/INIPwC/b2f2 + "]}]}, + AspectRatio->Automatic, + BaselinePosition->(Center -> Center), + ImageSize->{11., 16.}, + PlotRange->{{-0.5, 8.5}, {-0.5, 11.697400093078613`}}], + +"WorkspaceCodeBlockInsertAndEvaluate" -> GraphicsBox[ + {Thickness[0.07016411257027613], + {RGBColor[0.2901960784313726, 0.5843137254901961, 0.8], Thickness[ + 0.05262308442770709], Opacity[1.], CapForm["Butt"], + JoinForm[{"Miter", 1.}], + JoinedCurveBox[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, { + 0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, + 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, + 1, 0}, {0, 1, 0}}}, CompressedData[" +1:eJxTTMoPSmVmYGBgBGJRIGZiAIMEhUYZBxBj1UYdEB3heVcMRHM0XlUHi59y +5gTRHWKSWiBaQamWG0Q/+FmnApb/2/7MHkgd8PRRBvEPWDWygMXVDeWQ5R22 +nBAF6xOtButnCEkWBtEJG+3B5jOYxjEg289QnwUWh7sv5/lzkDlbqoUUQfyG +ogyw/ANdAzWwvGYMWP+N6wtVwe5wTwSbP2GBhDaIdlh3HGz/hosJYH8tkNKX +Q5bfcMwb7P4XUYvA+i+UQfzHYWIINr9isgTY/zD7YeGDEn4ArS1I9w== + "], + CurveClosed->{1}]}, + {FaceForm[{RGBColor[0.2901960784313726, 0.5843137254901961, 0.8], Opacity[ + 1.]}], FilledCurveBox[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}}}, {{{ + 5.526100158691406, 10.766900062561035`}, {5.526100158691406, + 4.3668999671936035`}, {10.32610034942627, 7.582900285720825}, { + 5.526100158691406, 10.766900062561035`}}}]}}, + AspectRatio->Automatic, + BaselinePosition->(Center -> Center), + ImageSize->{16., 17.}, + PlotRange->{{-0.5, 14.752300262451172`}, {-0.5, 15.594200134277344`}}] } @| @| diff --git a/FrontEnd/TextResources/ChatbookStrings.tr b/FrontEnd/TextResources/ChatbookStrings.tr index 522b489d..44ae93e7 100644 --- a/FrontEnd/TextResources/ChatbookStrings.tr +++ b/FrontEnd/TextResources/ChatbookStrings.tr @@ -62,6 +62,8 @@ "FormattingCopyToClipboardLabel" -> "Copy", "FormattingInsertContentLabel" -> "Insert", "FormattingInsertContentAndEvaluateTooltip" -> "Insert content as new input cell below and evaluate", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" -> "Insert this into a new notebook and evaluate.", "FormattingCopyToClipboardTooltip" -> "Copy to clipboard", "FormattingInsertContentTooltip" -> "Insert content as new input cell below", "FormattingToolUsing" -> "Using ", @@ -208,6 +210,7 @@ "WorkspaceWindowTitle" -> "Notebook Assistant", "WorkspaceToolbarButtonLabelHistory" -> "History", "WorkspaceToolbarButtonLabelSources" -> "Sources", +"WorkspaceToolbarSourcesSubTitleMoved" -> "Previous chat moved to `1` History.", "WorkspaceToolbarSourcesSubTitle" -> "Choose sources to be made available to the notebook assistant.", "WorkspaceToolbarButtonLabelNew" -> "New Chat", "WorkspaceToolbarButtonTooltipHistory" -> "Manage conversations", diff --git a/FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr b/FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr index bbfa4a92..3f2f5416 100644 --- a/FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr +++ b/FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr @@ -62,6 +62,8 @@ "FormattingCopyToClipboardLabel" -> "\:590D\:5236", "FormattingInsertContentLabel" -> "\:63D2\:5165", "FormattingInsertContentAndEvaluateTooltip" -> "\:5728\:4E0B\:9762\:63D2\:5165\:5185\:5BB9\:4F5C\:4E3A\:65B0\:7684\:8F93\:5165\:5355\:5143\:5E76\:8BA1\:7B97", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" -> "Insert this into a new notebook and evaluate.", "FormattingCopyToClipboardTooltip" -> "\:590D\:5236\:5230\:526A\:8D34\:677F", "FormattingInsertContentTooltip" -> "\:5728\:4E0B\:9762\:63D2\:5165\:5185\:5BB9\:4F5C\:4E3A\:65B0\:7684\:8F93\:5165\:5355\:5143", "FormattingToolUsing" -> "\:4F7F\:7528 ", @@ -208,6 +210,7 @@ "WorkspaceWindowTitle" -> "\:7B14\:8BB0\:672C\:52A9\:624B", "WorkspaceToolbarButtonLabelHistory" -> "\:5386\:53F2\:8BB0\:5F55", "WorkspaceToolbarButtonLabelSources" -> "\:8D44\:6E90", +"WorkspaceToolbarSourcesSubTitleMoved" -> "Previous chat moved to `1` History.", "WorkspaceToolbarSourcesSubTitle" -> "\:9009\:62E9\:7B14\:8BB0\:672C\:52A9\:624B\:53EF\:7528\:7684\:8D44\:6E90\:3002", "WorkspaceToolbarButtonLabelNew" -> "\:65B0\:7684\:804A\:5929", "WorkspaceToolbarButtonTooltipHistory" -> "\:7BA1\:7406\:5BF9\:8BDD", diff --git a/FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr b/FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr index b4af265a..3f9bd562 100644 --- a/FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr +++ b/FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr @@ -62,6 +62,8 @@ "FormattingCopyToClipboardLabel" -> "\:8907\:88FD", "FormattingInsertContentLabel" -> "\:63D2\:5165", "FormattingInsertContentAndEvaluateTooltip" -> "\:63D2\:5165\:5982\:540C\:5728\:4E0B\:65B9\:65B0\:589E\:8F38\:5165\:5132\:5B58\:683C\:7684\:5167\:5BB9\:4E26\:9032\:884C\:8A08\:7B97", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" -> "Insert this into a new notebook and evaluate.", "FormattingCopyToClipboardTooltip" -> "\:8907\:88FD\:81F3\:526A\:8CBC\:7C3F", "FormattingInsertContentTooltip" -> "\:63D2\:5165\:5982\:540C\:5728\:4E0B\:65B9\:65B0\:589E\:8F38\:5165\:5132\:5B58\:683C\:7684\:5167\:5BB9", "FormattingToolUsing" -> "\:6B63\:5728\:4F7F\:7528 ", @@ -208,6 +210,7 @@ "WorkspaceWindowTitle" -> "\:7B46\:8A18\:672C\:5C0F\:5E6B\:624B", "WorkspaceToolbarButtonLabelHistory" -> "\:6B77\:53F2\:8A18\:9304", "WorkspaceToolbarButtonLabelSources" -> "\:8CC7\:6E90", +"WorkspaceToolbarSourcesSubTitleMoved" -> "Previous chat moved to `1` History.", "WorkspaceToolbarSourcesSubTitle" -> "\:9078\:64C7\:53EF\:4F9B\:7B46\:8A18\:672C\:5C0F\:5E6B\:624B\:4F7F\:7528\:7684\:4F86\:6E90\:3002", "WorkspaceToolbarButtonLabelNew" -> "\:65B0\:589E\:7DB2\:8DEF\:804A\:5929\:7CFB\:7D71", "WorkspaceToolbarButtonTooltipHistory" -> "\:7BA1\:7406\:6703\:8A71", diff --git a/FrontEnd/TextResources/French/ChatbookStrings.tr b/FrontEnd/TextResources/French/ChatbookStrings.tr index 6332ee35..3fe5e98d 100644 --- a/FrontEnd/TextResources/French/ChatbookStrings.tr +++ b/FrontEnd/TextResources/French/ChatbookStrings.tr @@ -173,12 +173,12 @@ "UIAdvancedRoles" -> "Choisir automatiquement", "UITryEnableChatDialogMainText" -> "L\[CloseCurlyQuote]activation de la fonctionnalit\[EAcute] du notebook de chat d\[EAcute]truira les styles priv\[EAcute]s d\[EAcute]finis dans ce notebook et les remplacera par la feuille de style du chatbook partag\[EAcute]e.", "UITryEnableChatDialogConfirm" -> "\[CapitalEHat]tes-vous s\[UHat]r de vouloir continuer\[NonBreakingSpace]?", -"UIMessageManageSubscription" -> "G\[EAcute]rer l\[CloseCurlyQuote]abonnement \[RightGuillemet]", -"UIMessageContactUs" -> "Contactez\[Hyphen]nous \[RightGuillemet]", -"UIMessageUsed80" -> "Vous avez utilis\[EAcute] 80\[NonBreakingSpace]% de votre allocation Assistant de notebook Wolfram + Kit LLM pour ce mois.", -"UIMessageUsedAll" -> "Vous avez utilis\[EAcute] la totalit\[EAcute] de votre allocation Assistant de notebook Wolfram + Kit LLM pour ce mois.", -"UIMessageHighUsageRate" -> "Nous avons d\[EAcute]tect\[EAcute] un nombre tr\[EGrave]s \[EAcute]lev\[EAcute] de demandes provenant de votre compte. Afin de ne pas perturber le service pour les autres utilisateurs, nous avons d\[UHat] temporairement bloquer vos demandes.", -"UIMessageUnblockRequest" -> "Demandez le d\[EAcute]blocage \[RightGuillemet]", +"UIMessageManageSubscription" -> "Manage Subscription \[RightGuillemet]", +"UIMessageContactUs" -> "Contact us \[RightGuillemet]", +"UIMessageUsed80" -> "You have used 80% of your Wolfram Notebook Assistant + LLM Kit allowance for this month.", +"UIMessageUsedAll" -> "You have used your entire Wolfram Notebook Assistant + LLM Kit allowance for this month.", +"UIMessageHighUsageRate" -> "We've detected a very high rate of requests from your account. To prevent disruptions to the service for other users, we've temporarily had to block your requests.", +"UIMessageUnblockRequest" -> "Ask to be unblocked \[RightGuillemet]", "StylesheetChatWidgetButtonTooltip" -> "Envoyer au LLM", "StylesheetAssistantMenuInitializerButtonTooltip" -> "D\[EAcute]sactiver l\[CloseCurlyQuote]assistance automatique", @@ -210,7 +210,7 @@ "WorkspaceWindowTitle" -> "Assistant de notebook", "WorkspaceToolbarButtonLabelHistory" -> "Historique", "WorkspaceToolbarButtonLabelSources" -> "Sources", -"WorkspaceToolbarSourcesSubTitleMoved" -> "Le chat pr\[EAcute]c\[EAcute]dent a \[EAcute]t\[EAcute] d\[EAcute]plac\[EAcute] dans l\[CloseCurlyQuote]historique `1`.", +"WorkspaceToolbarSourcesSubTitleMoved" -> "Previous chat moved to `1` History.", "WorkspaceToolbarSourcesSubTitle" -> "Choisir les sources \[AGrave] mettre à la disposition de l\[CloseCurlyQuote]assistant de notebook.", "WorkspaceToolbarButtonLabelNew" -> "Nouveau Chat", "WorkspaceToolbarButtonTooltipHistory" -> "G\[EAcute]rer les conversations", @@ -220,23 +220,23 @@ "WorkspaceSourcesOpenNotebooks" -> "Ouvrir les notebooks", "WorkspaceOutputRaftCopyAsTooltip" -> "Copier la r\[EAcute]ponse dans le presse\[Hyphen]papiers\[Ellipsis]", -"WorkspaceOutputRaftCopyAs" -> "Copier la r\[EAcute]ponse en tant que\[Ellipsis]", -"WorkspaceOutputRaftCopyAsNotebookCells" -> "Cellules de notebook", -"WorkspaceOutputRaftCopyAsPlainText" -> "Texte brut", +"WorkspaceOutputRaftCopyAs" -> "Copy response as\[Ellipsis]", +"WorkspaceOutputRaftCopyAsNotebookCells" -> "Notebook Cells", +"WorkspaceOutputRaftCopyAsPlainText" -> "Plain Text", "WorkspaceOutputRaftCopyAsImage" -> "Image", "WorkspaceOutputRaftRegenerateTooltip" -> "Reg\[EAcute]n\[EAcute]rer la r\[EAcute]ponse", -"WorkspaceOutputRaftShareAsTooltip" -> "Partager la r\[EAcute]ponse\[Ellipsis]", -"WorkspaceOutputRaftShareAs" -> "Partager ceci en tant que\[Ellipsis]", -"WorkspaceOutputRaftShareAsCloudDeployment" -> "D\[EAcute]ploiement dans le cloud", +"WorkspaceOutputRaftShareAsTooltip" -> "Share response\[Ellipsis]", +"WorkspaceOutputRaftShareAs" -> "Share this as\[Ellipsis]", +"WorkspaceOutputRaftShareAsCloudDeployment" -> "Cloud Deployment", "WorkspaceOutputRaftShareAsPDF" -> "PDF", "WorkspaceOutputRaftShareAsImage" -> "Image", "WorkspaceOutputRaftFeedbackTooltip" -> "Envoyer un commentaire \[AGrave] Wolfram", -"WorkspaceFocusIndicatorEnableTooltip" -> "Activer l\[CloseCurlyQuote]utilisation du contexte provenant d\[CloseCurlyQuote]autres notebooks", -"WorkspaceFocusIndicatorDisableTooltip" -> "D\[EAcute]sactiver l\[CloseCurlyQuote]utilisation du contexte provenant d\[CloseCurlyQuote]autres notebooks", -"WorkspaceFocusIndicatorFocus" -> "Focus :", -"WorkspaceFocusIndicatorMenuTooltip" -> "Choisissez un notebook sur lequel vous vous concentrerez pour obtenir un contexte suppl\[EAcute]mentaire.", -"WorkspaceFocusIndicatorMenuAutomatic" -> "Choisir automatiquement", +"WorkspaceFocusIndicatorEnableTooltip" -> "Enable using context from other notebooks", +"WorkspaceFocusIndicatorDisableTooltip" -> "Disable using context from other notebooks", +"WorkspaceFocusIndicatorFocus" -> "Focus:", +"WorkspaceFocusIndicatorMenuTooltip" -> "Choose a notebook to focus on for additional context", +"WorkspaceFocusIndicatorMenuAutomatic" -> "Choose Automatically", "InlineChatButtonTooltipClose" -> "Fermer", "InlineChatButtonTooltipViewNotebookAssist" -> "Voir dans le chat de l\[CloseCurlyQuote]assistant du notebook", diff --git a/FrontEnd/TextResources/Japanese/ChatbookStrings.tr b/FrontEnd/TextResources/Japanese/ChatbookStrings.tr index f6ece36b..fd812672 100644 --- a/FrontEnd/TextResources/Japanese/ChatbookStrings.tr +++ b/FrontEnd/TextResources/Japanese/ChatbookStrings.tr @@ -62,6 +62,8 @@ "FormattingCopyToClipboardLabel" -> "\:30b3\:30d4\:30fc", "FormattingInsertContentLabel" -> "\:633f\:5165", "FormattingInsertContentAndEvaluateTooltip" -> "\:30b3\:30f3\:30c6\:30f3\:30c4\:3092\:65b0\:898f\:306e\:5165\:529b\:30bb\:30eb\:3068\:3057\:3066\:4e0b\:306b\:633f\:5165\:3057\:8a55\:4fa1\:3059\:308b", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" -> "Insert this into a new notebook and evaluate.", "FormattingCopyToClipboardTooltip" -> "\:30af\:30ea\:30c3\:30d7\:30dc\:30fc\:30c9\:306b\:30b3\:30d4\:30fc", "FormattingInsertContentTooltip" -> "\:30b3\:30f3\:30c6\:30f3\:30c4\:3092\:65b0\:898f\:306e\:5165\:529b\:30bb\:30eb\:3068\:3057\:3066\:4e0b\:306b\:633f\:5165\:3059\:308b", "FormattingToolUsing" -> "\:4f7f\:7528\:4e2d\:ff1a", @@ -208,6 +210,7 @@ "WorkspaceWindowTitle" -> "\:30ce\:30fc\:30c8\:30d6\:30c3\:30af\:30a2\:30b7\:30b9\:30bf\:30f3\:30c8", "WorkspaceToolbarButtonLabelHistory" -> "\:5c65\:6b74", "WorkspaceToolbarButtonLabelSources" -> "\:30BD\:30FC\:30B9", +"WorkspaceToolbarSourcesSubTitleMoved" -> "Previous chat moved to `1` History.", "WorkspaceToolbarSourcesSubTitle" -> "\:30ce\:30fc\:30c8\:30d6\:30c3\:30af\:30a2\:30b7\:30b9\:30bf\:30f3\:30c8\:304c\:5229\:7528\:3067\:304d\:308b\:30bd\:30fc\:30b9\:3092\:9078\:629e\:3059\:308b\:ff0e", "WorkspaceToolbarButtonLabelNew" -> "\:65b0\:898f\:30c1\:30e3\:30c3\:30c8", "WorkspaceToolbarButtonTooltipHistory" -> "\:4F1A\:8A71\:3092\:7BA1\:7406\:3059\:308B", diff --git a/FrontEnd/TextResources/Korean/ChatbookStrings.tr b/FrontEnd/TextResources/Korean/ChatbookStrings.tr index 31f7f244..03515009 100644 --- a/FrontEnd/TextResources/Korean/ChatbookStrings.tr +++ b/FrontEnd/TextResources/Korean/ChatbookStrings.tr @@ -63,6 +63,8 @@ "FormattingInsertContentLabel" -> "\:633F\:5165", "FormattingInsertContentAndEvaluateTooltip" -> "\:C544\:B798\:C5D0 \:CF58\:D150\:CE20\:B97C \:C0C8 \:C785\:B825 \ \:C140\:B85C \:C0BD\:C785\:D558\:ACE0 \:D3C9\:AC00", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" -> "Insert this into a new notebook and evaluate.", "FormattingCopyToClipboardTooltip" -> "\:D074\:B9BD\:BCF4\:B4DC\:C5D0 \:BCF5\:C0AC", "FormattingInsertContentTooltip" -> "\:CF58\:D150\:CE20\:B97C \:C0C8 \:C785\:B825 \:C140\:B85C \:C544\:B798\:C5D0 \:C0BD\:C785", "FormattingToolUsing" -> "\:C0AC\:C6A9\:C911 ", @@ -209,6 +211,7 @@ "WorkspaceWindowTitle" -> "\:B178\:D2B8\:BD81 \:C5B4\:C2DC\:C2A4\:D134\:D2B8", "WorkspaceToolbarButtonLabelHistory" -> "\:D788\:C2A4\:D1A0\:B9AC", "WorkspaceToolbarButtonLabelSources" -> "\:CD9C\:CC98", +"WorkspaceToolbarSourcesSubTitleMoved" -> "Previous chat moved to `1` History.", "WorkspaceToolbarSourcesSubTitle" -> "Choose sources to be made available to the notebook assistant.", "WorkspaceToolbarButtonLabelNew" -> "New Chat", "WorkspaceToolbarButtonTooltipHistory" -> "\:B300\:D654 \:AD00\:B9AC", diff --git a/FrontEnd/TextResources/Spanish/ChatbookStrings.tr b/FrontEnd/TextResources/Spanish/ChatbookStrings.tr index 5bcd6cbd..98b00471 100644 --- a/FrontEnd/TextResources/Spanish/ChatbookStrings.tr +++ b/FrontEnd/TextResources/Spanish/ChatbookStrings.tr @@ -62,6 +62,8 @@ "FormattingCopyToClipboardLabel" -> "Copiar", "FormattingInsertContentLabel" -> "Insertar", "FormattingInsertContentAndEvaluateTooltip" -> "Insertar contenido como una nueva celda de entrada debajo y evaluar", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" -> "Insert this into a new notebook and evaluate.", "FormattingCopyToClipboardTooltip" -> "Copiar al portapapeles", "FormattingInsertContentTooltip" -> "Insertar contenido como una nueva celda de entrada debajo", "FormattingToolUsing" -> "Utilizando ", @@ -171,12 +173,12 @@ "UIAdvancedRoles" -> "Roles", "UITryEnableChatDialogMainText" -> "Habilitar la funcionalidad de Cuadernos de chat destruir\[AAcute] los estilos privados definidos en este cuaderno, y los reemplazar\[AAcute] con la hoja de estilo compartida Chatbook.", "UITryEnableChatDialogConfirm" -> "\[DownQuestion]Est\[AAcute] seguro que desea continuar?", -"UIMessageManageSubscription" -> "Manage Subscription \[RightGuillemet]", -"UIMessageContactUs" -> "Contact us \[RightGuillemet]", -"UIMessageUsed80" -> "You have used 80% of your Wolfram Notebook Assistant + LLM Kit allowance for this month.", -"UIMessageUsedAll" -> "You have used your entire Wolfram Notebook Assistant + LLM Kit allowance for this month.", -"UIMessageHighUsageRate" -> "We've detected a very high rate of requests from your account. To prevent disruptions to the service for other users, we've temporarily had to block your requests.", -"UIMessageUnblockRequest" -> "Ask to be unblocked \[RightGuillemet]", +"UIMessageManageSubscription" -> "Administrar suscripci\[OAcute]n \[RightGuillemet]", +"UIMessageContactUs" -> "Cont\[AAcute]ctenos \[RightGuillemet]", +"UIMessageUsed80" -> "Ha utilizado 80% de su asignaci\[OAcute]m del Asistente de cuadernos Wolfram + Kit LLM para este mes.", +"UIMessageUsedAll" -> "Ha utilizado toda su asignaci\[OAcute]m del Asistente de cuadernos Wolfram + Kit LLM para este mes.", +"UIMessageHighUsageRate" -> "Hemos detectado una tasa muy alta de solicitudes desde su cuenta. Para prevenir interrupciones en el servicio de otros usuarios, hemos tenido que bloquear sus solicitudes temporalmente.", +"UIMessageUnblockRequest" -> "Solicitar el desbloqueo \[RightGuillemet]", "StylesheetChatWidgetButtonTooltip" -> "Enviar a LLM", "StylesheetAssistantMenuInitializerButtonTooltip" -> "Deshabilitar asistencia autom\[AAcute]tica", @@ -208,7 +210,8 @@ "WorkspaceWindowTitle" -> "Asistente de cuadernos", "WorkspaceToolbarButtonLabelHistory" -> "Historial", "WorkspaceToolbarButtonLabelSources" -> "Fuentes", -"WorkspaceToolbarSourcesSubTitle" -> "Seleccione las fuentes que estar\[AAcute]n disponibles para el asistente de cuadernos.", +"WorkspaceToolbarSourcesSubTitleMoved" -> "Previous chat moved to `1` History.", +"WorkspaceToolbarSourcesSubTitle" -> "Seleccionar las fuentes que estar\[AAcute]n disponibles para el asistente de cuadernos.", "WorkspaceToolbarButtonLabelNew" -> "Nuevo chat", "WorkspaceToolbarButtonTooltipHistory" -> "Administrar conversaciones", "WorkspaceToolbarButtonTooltipSources" -> "Fuentes para material adicional que se a\[NTilde]adir\[AAcute] al contexto del chat", @@ -217,23 +220,23 @@ "WorkspaceSourcesOpenNotebooks" -> "Abrir cuadernos", "WorkspaceOutputRaftCopyAsTooltip" -> "Copiar respuesta al portapapeles\[Ellipsis]", -"WorkspaceOutputRaftCopyAs" -> "Copy response as\[Ellipsis]", -"WorkspaceOutputRaftCopyAsNotebookCells" -> "Notebook Cells", -"WorkspaceOutputRaftCopyAsPlainText" -> "Plain Text", -"WorkspaceOutputRaftCopyAsImage" -> "Image", +"WorkspaceOutputRaftCopyAs" -> "Copiar respuesta como\[Ellipsis]", +"WorkspaceOutputRaftCopyAsNotebookCells" -> "Celdas del cuaderno", +"WorkspaceOutputRaftCopyAsPlainText" -> "Texto simple", +"WorkspaceOutputRaftCopyAsImage" -> "Imagen", "WorkspaceOutputRaftRegenerateTooltip" -> "Regenerar respuesta", -"WorkspaceOutputRaftShareAsTooltip" -> "Share response\[Ellipsis]", -"WorkspaceOutputRaftShareAs" -> "Share this as\[Ellipsis]", -"WorkspaceOutputRaftShareAsCloudDeployment" -> "Cloud Deployment", +"WorkspaceOutputRaftShareAsTooltip" -> "Compartir respuesta\[Ellipsis]", +"WorkspaceOutputRaftShareAs" -> "Compartir esto como\[Ellipsis]", +"WorkspaceOutputRaftShareAsCloudDeployment" -> "Implementaci\[OAcute]n en la nube", "WorkspaceOutputRaftShareAsPDF" -> "PDF", -"WorkspaceOutputRaftShareAsImage" -> "Image", +"WorkspaceOutputRaftShareAsImage" -> "Imagen", "WorkspaceOutputRaftFeedbackTooltip" -> "Enviar comentarios a Wolfram", -"WorkspaceFocusIndicatorEnableTooltip" -> "Enable using context from other notebooks", -"WorkspaceFocusIndicatorDisableTooltip" -> "Disable using context from other notebooks", -"WorkspaceFocusIndicatorFocus" -> "Focus:", -"WorkspaceFocusIndicatorMenuTooltip" -> "Choose a notebook to focus on for additional context", -"WorkspaceFocusIndicatorMenuAutomatic" -> "Choose Automatically", +"WorkspaceFocusIndicatorEnableTooltip" -> "Habilitar el uso de contexto de otros cuadernos", +"WorkspaceFocusIndicatorDisableTooltip" -> "Deshabilitar el uso de contexto de otros cuadernos", +"WorkspaceFocusIndicatorFocus" -> "Enfoque:", +"WorkspaceFocusIndicatorMenuTooltip" -> "Seleccione un cuaderno en el cual enfocarse para obtener contexto adicional", +"WorkspaceFocusIndicatorMenuAutomatic" -> "Seleccionar autom\[OAcute]ticamente", "InlineChatButtonTooltipClose" -> "Cerrar", "InlineChatButtonTooltipViewNotebookAssist" -> "Ver en chat de asistencia de cuadernos", diff --git a/Source/Chatbook/ChatModes/ChatModes.wl b/Source/Chatbook/ChatModes/ChatModes.wl index b96d9ffb..7af72f1d 100644 --- a/Source/Chatbook/ChatModes/ChatModes.wl +++ b/Source/Chatbook/ChatModes/ChatModes.wl @@ -39,6 +39,7 @@ $subcontexts = { "Wolfram`Chatbook`ChatModes`Context`", "Wolfram`Chatbook`ChatModes`Evaluate`", "Wolfram`Chatbook`ChatModes`NotebookAssistanceInstructions`", + "Wolfram`Chatbook`ChatModes`NotebookFocus`", "Wolfram`Chatbook`ChatModes`ShowNotebookAssistance`", "Wolfram`Chatbook`ChatModes`UI`" }; diff --git a/Source/Chatbook/ChatModes/Common.wl b/Source/Chatbook/ChatModes/Common.wl index a4d82b9e..df4b56cc 100644 --- a/Source/Chatbook/ChatModes/Common.wl +++ b/Source/Chatbook/ChatModes/Common.wl @@ -11,6 +11,7 @@ HoldComplete[ `createWorkspaceChat, `evaluateAttachedInlineChat, `findCurrentWorkspaceChat, + `focusedNotebookDisplay, `getContextFromSelection, `getNotebookAssistanceInput, `getSelectionInfo, diff --git a/Source/Chatbook/ChatModes/NotebookFocus.wl b/Source/Chatbook/ChatModes/NotebookFocus.wl new file mode 100644 index 00000000..b76a4b40 --- /dev/null +++ b/Source/Chatbook/ChatModes/NotebookFocus.wl @@ -0,0 +1,274 @@ +(* ::Section::Closed:: *) +(*Package Header*) +BeginPackage[ "Wolfram`Chatbook`ChatModes`NotebookFocus`" ]; +Begin[ "`Private`" ]; + +Needs[ "Wolfram`Chatbook`" ]; +Needs[ "Wolfram`Chatbook`Common`" ]; +Needs[ "Wolfram`Chatbook`ChatModes`Common`" ]; + +(* ::**************************************************************************************************************:: *) +(* ::Section::Closed:: *) +(*Configuration*) + +(* ::**************************************************************************************************************:: *) +(* ::Section::Closed:: *) +(*GetFocusedNotebook*) +GetFocusedNotebook // beginDefinition; +GetFocusedNotebook[ ] := catchMine @ GetFocusedNotebook @ EvaluationNotebook[ ]; +GetFocusedNotebook[ obj: $$feObj ] := catchMine @ getFocusedNotebook @ obj; +GetFocusedNotebook[ app: _String | All ] := catchMine @ GetFocusedNotebook @ findCurrentWorkspaceChat @ app; +GetFocusedNotebook[ _Missing ] := None; +GetFocusedNotebook // endExportedDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Subsection::Closed:: *) +(*getFocusedNotebook*) +getFocusedNotebook // beginDefinition; + +getFocusedNotebook[ obj: $$feObj ] /; ! TrueQ @ CurrentChatSettings[ obj, "WorkspaceChat" ] := + If[ MatchQ[ obj, _NotebookObject ], obj, parentNotebook @ obj ]; + +getFocusedNotebook[ obj: $$feObj ] := Enclose[ + Module[ { locked }, + locked = ConfirmMatch[ getLockedNotebook @ obj, _NotebookObject | None, "Locked" ]; + If[ notebookObjectQ @ locked, locked, getUserNotebook[ ] ] + ], + throwInternalFailure +]; + +getFocusedNotebook // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Section::Closed:: *) +(*Notebook Focus Indicator*) + +(* ::**************************************************************************************************************:: *) +(* ::Subsection::Closed:: *) +(*focusedNotebookDisplay*) +focusedNotebookDisplay // beginDefinition; + +focusedNotebookDisplay[ chatNB_ ] := Enclose[ + Catch @ Module[ { locked, notebooks, info, current, focused, label }, + + locked = getLockedNotebook @ chatNB; + + notebooks = ConfirmMatch[ + Cases[ SourceNotebookObjectInformation[ ], KeyValuePattern[ "Included" -> True ] ], + { ___Association }, + "Notebooks" + ]; + + If[ notebooks === { }, Throw @ Spacer[ 0 ] ]; + + info = ConfirmMatch[ addFocusInfo[ locked, notebooks ], { __Association }, "Info" ]; + current = ConfirmBy[ First @ info, AssociationQ, "Current" ]; + focused = FirstCase[ info, KeyValuePattern[ "Focused" -> True ], current ]; + + (* focusedNotebookDisplay is dynamically updated so this TaggingRules value should be kept current *) + CurrentValue[ chatNB, { TaggingRules, "FocusWindowTitle" } ] = Lookup[ focused, "WindowTitle", None ]; + + label = Grid[ + { { + Toggler[ + Dynamic @ CurrentChatSettings[ chatNB, "AllowSelectionContext" ], + { + True -> $disableNotebookFocusLabel, + False -> $enableNotebookFocusLabel + }, + BaselinePosition -> Baseline + ], + tr[ "WorkspaceFocusIndicatorFocus" ], + focusedNotebookDisplay0[ chatNB, focused, locked, info ] + } }, + Alignment -> { Left, Baseline }, + BaseStyle -> { "Text", FontColor -> GrayLevel[ 0.5 ], FontSize -> 13 }, + BaselinePosition -> { 1, 2 } (* align to the text *) + ]; + + Pane[ label, ImageMargins -> { { 0, 0 }, { 0, 0 } } ] + ], + throwInternalFailure +]; + +focusedNotebookDisplay // endDefinition; + + + +focusedNotebookDisplay0 // beginDefinition; + +focusedNotebookDisplay0[ chatNB_, focused_, locked_, info_ ] := Grid[ + { { + currentNotebookButton @ focused, + selectNotebookFocusMenu[ chatNB, locked, info ] + } }, + Alignment -> { Left, Baseline }, + BaselinePosition -> { 1, 1 }, (* align to the button *) + Dividers -> Center, + FrameStyle -> GrayLevel[ 0.75 ] +]; + +focusedNotebookDisplay0 // endDefinition; + + +$enableNotebookFocusLabel := $enableNotebookFocusLabel = Tooltip[ + chatbookIcon[ "WorkspaceFocusIndicatorUncheck", False ], + tr[ "WorkspaceFocusIndicatorEnableTooltip" ] +]; + +$disableNotebookFocusLabel := $disableNotebookFocusLabel = Tooltip[ + chatbookIcon[ "WorkspaceFocusIndicatorCheck", False ], + tr[ "WorkspaceFocusIndicatorDisableTooltip" ] +]; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*addFocusInfo*) +addFocusInfo // beginDefinition; + +addFocusInfo[ locked_, notebooks_List ] := + MapIndexed[ addFocusInfo[ locked, #1, #2 ] &, notebooks ]; + +addFocusInfo[ locked_, as_Association, { idx_ } ] := <| + "Current" -> idx === 1, + "Focused" -> as[ "NotebookObject" ] === locked, + as +|>; + +addFocusInfo // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*currentNotebookButton*) +currentNotebookButton // beginDefinition; + +currentNotebookButton[ as: KeyValuePattern @ { "NotebookObject" -> nbo_NotebookObject, "WindowTitle" -> title_ } ] := + Button[ + currentNotebookButtonLabel @ Replace[ + formatNotebookTitle @ title, + s_String :> FE`Evaluate @ FEPrivate`TruncateStringToWidth[ s, "Text", 200, Right ] + ], + SetSelectedNotebook @ nbo, + Appearance -> "Suppressed", + BaseStyle -> { "Text", FontColor -> GrayLevel[ 0.5 ], FontSize -> 13 }, + BaselinePosition -> Baseline + ]; + +currentNotebookButton // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*currentNotebookButtonLabel*) +currentNotebookButtonLabel // beginDefinition; + +currentNotebookButtonLabel[ title_ ] := Mouseover[ + Row[ + { + chatbookIcon[ "WorkspaceFocusIndicatorNotebook", False ], + Spacer[ 3 ], + title + }, + BaselinePosition -> Baseline + ], + Row[ + { + chatbookIcon[ "WorkspaceFocusIndicatorNotebookActive", False ], + Spacer[ 3 ], + Style[ title, FontColor -> RGBColor[ 0.2, 0.51373, 0.67451, 1.0 ] ] + }, + BaselinePosition -> Baseline + ], + BaselinePosition -> Baseline +]; + +currentNotebookButtonLabel // endDefinition; + +$smallNotebookIcon := $smallNotebookIcon = chatbookIcon[ "WorkspaceFocusIndicatorNotebook", False ]; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*selectNotebookFocusMenu*) +selectNotebookFocusMenu // beginDefinition; + +selectNotebookFocusMenu[ chatNB_, locked_, items: { current_Association, ___Association } ] := + selectNotebookFocusMenu[ chatNB, locked, current, SortBy[ items, Lookup[ "WindowTitle" ] ] ]; + +selectNotebookFocusMenu[ chatNB_, locked_, first_, rest_ ] := Tooltip[ + ActionMenu[ + chatbookIcon[ "WorkspaceFocusIndicatorCaret", False ], + Flatten @ { + currentNotebookAction[ chatNB, locked, first ], + Delimiter, + otherNotebookActions[ chatNB, locked, rest ] + }, + Appearance -> "Suppressed", + BaseStyle -> { "Text", FontColor -> GrayLevel[ 0.5 ], FontSize -> 13, Magnification -> Inherited / 0.85 }, + BaselinePosition -> Baseline + ], + tr[ "WorkspaceFocusIndicatorMenuTooltip" ] +]; + +selectNotebookFocusMenu // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*currentNotebookAction*) +currentNotebookAction // beginDefinition; + +currentNotebookAction[ chatNB_, locked_, as_Association ] := + currentNotebookAction[ chatNB, locked, as[ "WindowTitle" ], as[ "NotebookObject" ] ]; + +currentNotebookAction[ chatNB_, locked_, title_, nbo_ ] := + Row @ { + Style[ "\[Checkmark] ", ShowContents -> locked === None ], + tr[ "WorkspaceFocusIndicatorMenuAutomatic" ], + " (", + formatNotebookTitle @ title, + ")" + } :> ( + CurrentChatSettings[ chatNB, "AllowSelectionContext" ] = True; + CurrentChatSettings[ chatNB, "FocusedNotebook" ] = Inherited + ); + +currentNotebookAction // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*otherNotebookActions*) +otherNotebookActions // beginDefinition; +otherNotebookActions[ chatNB_, locked_, items_List ] := otherNotebookAction[ chatNB, locked, # ] & /@ items; +otherNotebookActions // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsubsection::Closed:: *) +(*otherNotebookAction*) +otherNotebookAction // beginDefinition; + +otherNotebookAction[ chatNB_, locked_, as_Association ] := + otherNotebookAction[ chatNB, locked, as[ "WindowTitle" ], as[ "NotebookObject" ] ]; + +otherNotebookAction[ chatNB_, locked_, title_, nbo_ ] := + Row @ { Style[ "\[Checkmark] ", ShowContents -> locked === nbo ], formatNotebookTitle @ title } :> ( + CurrentChatSettings[ chatNB, "AllowSelectionContext" ] = True; + CurrentChatSettings[ chatNB, "FocusedNotebook" ] = nbo + ); + +otherNotebookAction // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*getLockedNotebook*) +getLockedNotebook // beginDefinition; +getLockedNotebook[ nbo_ ] := getLockedNotebook[ nbo, CurrentChatSettings[ nbo, "FocusedNotebook" ] ]; +getLockedNotebook[ nbo_, focused_ ] := If[ TrueQ @ notebookObjectQ @ focused, focused, None ]; +getLockedNotebook // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Section::Closed:: *) +(*Package Footer*) +addToMXInitialization[ + Null +]; + +End[ ]; +EndPackage[ ]; diff --git a/Source/Chatbook/ChatModes/ShowNotebookAssistance.wl b/Source/Chatbook/ChatModes/ShowNotebookAssistance.wl index 92cceef2..c1ba64ad 100644 --- a/Source/Chatbook/ChatModes/ShowNotebookAssistance.wl +++ b/Source/Chatbook/ChatModes/ShowNotebookAssistance.wl @@ -461,14 +461,16 @@ showNotebookAssistanceWindow[ source_, input_, evaluate_, new_, settings_Associa ]; showNotebookAssistanceWindow[ source_NotebookObject, input_, evaluate_, new_ ] := Enclose[ - Module[ { current, nbo }, + Module[ { current, nbo, movedLastChatToSourcesIndicatorQ }, current = ConfirmMatch[ - LogChatTiming @ findCurrentWorkspaceChat[ ], + LogChatTiming @ findCurrentWorkspaceChat[ "NotebookAssistance" ], _NotebookObject | Missing[ "NotFound" ], "Existing" ]; + movedLastChatToSourcesIndicatorQ = MatchQ[ current, _NotebookObject ] && Cells[ current ] =!= {}; + If[ TrueQ @ new, Quiet @ NotebookClose @ current; current = Missing[ "NotFound" ] @@ -479,6 +481,22 @@ showNotebookAssistanceWindow[ source_NotebookObject, input_, evaluate_, new_ ] : ConfirmMatch[ LogChatTiming @ attachToLeft[ source, current ], _NotebookObject, "Attached" ] ]; + If[ movedLastChatToSourcesIndicatorQ, + writeWorkspaceChatSubDockedCell[ + nbo, + Button[ + MouseAppearance[ + Style[ + Row[ { trExprTemplate["WorkspaceToolbarSourcesSubTitleMoved"][ <| "1" -> chatbookIcon[ "WorkspaceToolbarIconHistorySmall", False ] |> ] } ], + "WorkspaceChatToolbarTitle", FontSlant -> Italic, FontWeight -> Plain + ], + "LinkHand"], (* using LinkHand to indicate the sub-docked cell is clickable *) + Wolfram`Chatbook`ChatModes`UI`Private`toggleOverlayMenu[ nbo, "History" ], + Appearance -> "Suppressed" + ] + ] + ]; + setNotebookAssistanceEvaluator @ nbo; LogChatTiming @ setWindowInputAndEvaluate[ nbo, input, evaluate ] @@ -489,7 +507,12 @@ showNotebookAssistanceWindow[ source_NotebookObject, input_, evaluate_, new_ ] : showNotebookAssistanceWindow[ None, input_, evaluate_, new_ ] := Enclose[ Module[ { current, nbo }, - current = ConfirmMatch[ findCurrentWorkspaceChat[ ], _NotebookObject | Missing[ "NotFound" ], "Existing" ]; + + current = ConfirmMatch[ + findCurrentWorkspaceChat[ "NotebookAssistance" ], + _NotebookObject | Missing[ "NotFound" ], + "Existing" + ]; If[ TrueQ @ new, Quiet @ NotebookClose @ current; @@ -603,12 +626,57 @@ windowMargins // endDefinition; (*findCurrentWorkspaceChat*) findCurrentWorkspaceChat // beginDefinition; -findCurrentWorkspaceChat[ ] := FirstCase[ - selectByCurrentValue[ Notebooks[ ], { TaggingRules, "ChatNotebookSettings", "WorkspaceChat" }, "Absolute" -> True ], + +findCurrentWorkspaceChat[ ] := + findCurrentWorkspaceChat[ All, Notebooks[ ] ]; + + +findCurrentWorkspaceChat[ appName_String ] := + findCurrentWorkspaceChat[ appName, Notebooks[ ] ]; + + +findCurrentWorkspaceChat[ All | _String, { } ] := + Missing[ "NotFound" ]; + + +findCurrentWorkspaceChat[ All, notebooks: { __NotebookObject } ] := FirstCase[ + selectByCurrentValue[ notebooks, { TaggingRules, "ChatNotebookSettings", "WorkspaceChat" }, "Absolute" -> True ], _NotebookObject, Missing[ "NotFound" ] ]; + +findCurrentWorkspaceChat[ appName_String, notebooks: { __NotebookObject } ] := Enclose[ + Catch @ Module[ { wsNotebooks, appNotebooks }, + + wsNotebooks = ConfirmMatch[ + selectByCurrentValue[ + notebooks, + { TaggingRules, "ChatNotebookSettings", "WorkspaceChat" }, + "Absolute" -> True + ], + { ___NotebookObject }, + "WorkspaceNotebooks" + ]; + + If[ wsNotebooks === { }, Throw @ Missing[ "NotFound" ] ]; + + appNotebooks = ConfirmMatch[ + selectByCurrentValue[ + wsNotebooks, + { TaggingRules, "ChatNotebookSettings", "AppName" }, + SameAs @ appName, + "Absolute" -> True + ], + { ___NotebookObject }, + "AppNotebooks" + ]; + + FirstCase[ appNotebooks, _NotebookObject, Missing[ "NotFound" ] ] + ] +]; + + findCurrentWorkspaceChat // endDefinition; (* ::**************************************************************************************************************:: *) diff --git a/Source/Chatbook/ChatModes/UI.wl b/Source/Chatbook/ChatModes/UI.wl index 903a09ff..b3c59b69 100644 --- a/Source/Chatbook/ChatModes/UI.wl +++ b/Source/Chatbook/ChatModes/UI.wl @@ -483,223 +483,6 @@ moveChatInputToBottom[ nbo_NotebookObject ] := moveChatInputToBottom // endDefinition; -(* ::**************************************************************************************************************:: *) -(* ::Subsection::Closed:: *) -(*focusedNotebookDisplay*) -focusedNotebookDisplay // beginDefinition; - -focusedNotebookDisplay[ chatNB_ ] := Enclose[ - Catch @ Module[ { locked, notebooks, info, current, focused, label }, - - locked = getLockedNotebook @ chatNB; - - notebooks = ConfirmMatch[ - Cases[ SourceNotebookObjectInformation[ ], KeyValuePattern[ "Included" -> True ] ], - { ___Association }, - "Notebooks" - ]; - - If[ notebooks === { }, Throw @ Spacer[ 0 ] ]; - - info = ConfirmMatch[ addFocusInfo[ locked, notebooks ], { __Association }, "Info" ]; - current = ConfirmBy[ First @ info, AssociationQ, "Current" ]; - focused = FirstCase[ info, KeyValuePattern[ "Focused" -> True ], current ]; - - label = Grid[ - { { - Toggler[ - Dynamic @ CurrentChatSettings[ chatNB, "AllowSelectionContext" ], - { - True -> $disableNotebookFocusLabel, - False -> $enableNotebookFocusLabel - }, - BaselinePosition -> Baseline - ], - tr[ "WorkspaceFocusIndicatorFocus" ], - focusedNotebookDisplay0[ chatNB, focused, locked, info ] - } }, - Alignment -> { Left, Baseline }, - BaseStyle -> { "Text", FontColor -> GrayLevel[ 0.5 ], FontSize -> 13 }, - BaselinePosition -> { 1, 2 } (* align to the text *) - ]; - - Pane[ label, ImageMargins -> { { 0, 0 }, { 0, 0 } } ] - ], - throwInternalFailure -]; - -focusedNotebookDisplay // endDefinition; - - - -focusedNotebookDisplay0 // beginDefinition; - -focusedNotebookDisplay0[ chatNB_, focused_, locked_, info_ ] := Grid[ - { { - currentNotebookButton @ focused, - selectNotebookFocusMenu[ chatNB, locked, info ] - } }, - Alignment -> { Left, Baseline }, - BaselinePosition -> { 1, 1 }, (* align to the button *) - Dividers -> Center, - FrameStyle -> GrayLevel[ 0.75 ] -]; - -focusedNotebookDisplay0 // endDefinition; - - -$enableNotebookFocusLabel := $enableNotebookFocusLabel = Tooltip[ - chatbookIcon[ "WorkspaceFocusIndicatorUncheck", False ], - tr[ "WorkspaceFocusIndicatorEnableTooltip" ] -]; - -$disableNotebookFocusLabel := $disableNotebookFocusLabel = Tooltip[ - chatbookIcon[ "WorkspaceFocusIndicatorCheck", False ], - tr[ "WorkspaceFocusIndicatorDisableTooltip" ] -]; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsection::Closed:: *) -(*addFocusInfo*) -addFocusInfo // beginDefinition; - -addFocusInfo[ locked_, notebooks_List ] := - MapIndexed[ addFocusInfo[ locked, #1, #2 ] &, notebooks ]; - -addFocusInfo[ locked_, as_Association, { idx_ } ] := <| - "Current" -> idx === 1, - "Focused" -> as[ "NotebookObject" ] === locked, - as -|>; - -addFocusInfo // endDefinition; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsection::Closed:: *) -(*currentNotebookButton*) -currentNotebookButton // beginDefinition; - -currentNotebookButton[ as: KeyValuePattern @ { "NotebookObject" -> nbo_NotebookObject, "WindowTitle" -> title_ } ] := - Button[ - currentNotebookButtonLabel @ Replace[ - formatNotebookTitle @ title, - s_String :> FE`Evaluate @ FEPrivate`TruncateStringToWidth[ s, "Text", 200, Right ] - ], - SetSelectedNotebook @ nbo, - Appearance -> "Suppressed", - BaseStyle -> { "Text", FontColor -> GrayLevel[ 0.5 ], FontSize -> 13 }, - BaselinePosition -> Baseline - ]; - -currentNotebookButton // endDefinition; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsection::Closed:: *) -(*currentNotebookButtonLabel*) -currentNotebookButtonLabel // beginDefinition; - -currentNotebookButtonLabel[ title_ ] := Mouseover[ - Row[ - { - chatbookIcon[ "WorkspaceFocusIndicatorNotebook", False ], - Spacer[ 3 ], - title - }, - BaselinePosition -> Baseline - ], - Row[ - { - chatbookIcon[ "WorkspaceFocusIndicatorNotebookActive", False ], - Spacer[ 3 ], - Style[ title, FontColor -> RGBColor[ 0.2, 0.51373, 0.67451, 1.0 ] ] - }, - BaselinePosition -> Baseline - ], - BaselinePosition -> Baseline -]; - -currentNotebookButtonLabel // endDefinition; - -$smallNotebookIcon := $smallNotebookIcon = chatbookIcon[ "WorkspaceFocusIndicatorNotebook", False ]; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsection::Closed:: *) -(*selectNotebookFocusMenu*) -selectNotebookFocusMenu // beginDefinition; - -selectNotebookFocusMenu[ chatNB_, locked_, items: { current_Association, ___Association } ] := - selectNotebookFocusMenu[ chatNB, locked, current, SortBy[ items, Lookup[ "WindowTitle" ] ] ]; - -selectNotebookFocusMenu[ chatNB_, locked_, first_, rest_ ] := Tooltip[ - ActionMenu[ - chatbookIcon[ "WorkspaceFocusIndicatorCaret", False ], - Flatten @ { - currentNotebookAction[ chatNB, locked, first ], - Delimiter, - otherNotebookActions[ chatNB, locked, rest ] - }, - Appearance -> "Suppressed", - BaseStyle -> { "Text", FontColor -> GrayLevel[ 0.5 ], FontSize -> 13, Magnification -> Inherited / 0.85 }, - BaselinePosition -> Baseline - ], - tr[ "WorkspaceFocusIndicatorMenuTooltip" ] -]; - -selectNotebookFocusMenu // endDefinition; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsection::Closed:: *) -(*currentNotebookAction*) -currentNotebookAction // beginDefinition; - -currentNotebookAction[ chatNB_, locked_, as_Association ] := - currentNotebookAction[ chatNB, locked, as[ "WindowTitle" ], as[ "NotebookObject" ] ]; - -currentNotebookAction[ chatNB_, locked_, title_, nbo_ ] := - Row @ { - Style[ "\[Checkmark] ", ShowContents -> locked === None ], - tr[ "WorkspaceFocusIndicatorMenuAutomatic" ], - " (", - formatNotebookTitle @ title, - ")" - } :> ( - CurrentChatSettings[ chatNB, "AllowSelectionContext" ] = True; - CurrentChatSettings[ chatNB, "FocusedNotebook" ] = Inherited - ); - -currentNotebookAction // endDefinition; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsection::Closed:: *) -(*otherNotebookActions*) -otherNotebookActions // beginDefinition; -otherNotebookActions[ chatNB_, locked_, items_List ] := otherNotebookAction[ chatNB, locked, # ] & /@ items; -otherNotebookActions // endDefinition; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsubsection::Closed:: *) -(*otherNotebookAction*) -otherNotebookAction // beginDefinition; - -otherNotebookAction[ chatNB_, locked_, as_Association ] := - otherNotebookAction[ chatNB, locked, as[ "WindowTitle" ], as[ "NotebookObject" ] ]; - -otherNotebookAction[ chatNB_, locked_, title_, nbo_ ] := - Row @ { Style[ "\[Checkmark] ", ShowContents -> locked === nbo ], formatNotebookTitle @ title } :> ( - CurrentChatSettings[ chatNB, "AllowSelectionContext" ] = True; - CurrentChatSettings[ chatNB, "FocusedNotebook" ] = nbo - ); - -otherNotebookAction // endDefinition; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsection::Closed:: *) -(*getLockedNotebook*) -getLockedNotebook // beginDefinition; -getLockedNotebook[ nbo_ ] := getLockedNotebook[ nbo, CurrentChatSettings[ nbo, "FocusedNotebook" ] ]; -getLockedNotebook[ nbo_, focused_ ] := If[ TrueQ @ notebookObjectQ @ focused, focused, None ]; -getLockedNotebook // endDefinition; - (* ::**************************************************************************************************************:: *) (* ::Section::Closed:: *) (*Inline Chat*) @@ -1868,8 +1651,8 @@ notebookSources // endDefinition; (* ::Subsubsection::Closed:: *) (*formatNotebookTitle*) formatNotebookTitle // beginDefinition; +formatNotebookTitle[ None|"" ] := Style[ "Unnamed Notebook", FontColor -> GrayLevel[ 0.6 ], FontSlant -> Italic ]; formatNotebookTitle[ title_String ] := title; -formatNotebookTitle[ None ] := Style[ "Unnamed Notebook", FontColor -> GrayLevel[ 0.6 ], FontSlant -> Italic ]; formatNotebookTitle // endDefinition; (* ::**************************************************************************************************************:: *) diff --git a/Source/Chatbook/CommonSymbols.wl b/Source/Chatbook/CommonSymbols.wl index 53bd7a40..12b33157 100644 --- a/Source/Chatbook/CommonSymbols.wl +++ b/Source/Chatbook/CommonSymbols.wl @@ -164,6 +164,7 @@ BeginPackage[ "Wolfram`Chatbook`Common`" ]; `fixLineEndings; `floatingButtonGrid; `forceRefreshCloudPreferences; +`formatNotebookTitle; `functionTemplateBoxes; `getAvailableServiceNames; `getBoxObjectFromBoxID; diff --git a/Source/Chatbook/Formatting.wl b/Source/Chatbook/Formatting.wl index 5e833924..6cc149f5 100644 --- a/Source/Chatbook/Formatting.wl +++ b/Source/Chatbook/Formatting.wl @@ -618,17 +618,17 @@ floatingButtonGrid[ cell_Cell, lang_ ] := cellObj = topParentCell @ EvaluationCell[ ]; Grid[ { - checkTemplateBoxes @ { - button[ evaluateLanguageLabel @ lang, insertCodeBelow[ EvaluationCell[ ], True ] ], - button[ - If[ TrueQ @ CurrentChatSettings[ cellObj, "WorkspaceChat" ], - $insertInputButtonLabelWorkspaceChat, - $insertInputButtonLabel - ], - insertCodeBelow[ EvaluationCell[ ], False ] - ], - button[ $copyToClipboardButtonLabel, copyCodeBlock @ EvaluationCell[ ] ] - } + checkTemplateBoxes @ If[ TrueQ @ CurrentChatSettings[ cellObj, "WorkspaceChat" ], + { + button[ $copyToClipboardButtonLabelWorkspaceChat, copyCodeBlock @ EvaluationCell[ ] ], + button[ evaluateLanguageLabel[ lang, True ], insertCodeBelow[ EvaluationCell[ ], True ] ] + }, + { + button[ evaluateLanguageLabel[ lang, False ], insertCodeBelow[ EvaluationCell[ ], True ] ], + button[ $insertInputButtonLabel, insertCodeBelow[ EvaluationCell[ ], False ] ], + button[ $copyToClipboardButtonLabel, copyCodeBlock @ EvaluationCell[ ] ] + } + ] }, Alignment -> Top, Spacings -> 0.2, @@ -643,7 +643,7 @@ floatingButtonGrid[ string_, lang_ ] := RawBoxes @ TemplateBox[ ToBoxes @ Grid[ { checkTemplateBoxes @ { - button[ evaluateLanguageLabel @ lang, insertCodeBelow[ string, True ] ], + button[ evaluateLanguageLabel[ lang, False ], insertCodeBelow[ string, True ] ], button[ $insertInputButtonLabel, insertCodeBelow[ string, False ] ], button[ $copyToClipboardButtonLabel, copyCodeBlock @ string ] } @@ -670,7 +670,7 @@ checkTemplateBoxes // endDefinition; (* ::**************************************************************************************************************:: *) (* ::Subsubsection::Closed:: *) (*evaluateLanguageLabel*) -evaluateLanguageLabel[ name_String ] := +evaluateLanguageLabel[ name_String, False ] := With[ { icon = $languageIcons @ name }, fancyTooltip[ MouseAppearance[ @@ -684,8 +684,49 @@ evaluateLanguageLabel[ name_String ] := ] /; MatchQ[ icon, _Graphics | _Image ] ]; +evaluateLanguageLabel[ name_String, True ] := + With[ { icon = If[ name === "Wolfram", chatbookIcon[ "WorkspaceCodeBlockInsertAndEvaluate", False ], $languageIcons @ name ] }, + fancyTooltip[ + MouseAppearance[ + buttonMouseover[ + buttonFrameDefault[ labeledIcon[ If[ name === "Wolfram", { "WorkspaceCodeBlockInsertAndEvaluate", False }, name ], "FormattingInsertContentAndEvaluateLabel" ], True ], + buttonFrameActive[ labeledIcon[ If[ name === "Wolfram", { "WorkspaceCodeBlockInsertAndEvaluate", False }, name ], "FormattingInsertContentAndEvaluateLabel" ], True ] + ], + "LinkHand" + ], + targetNotebookLabel @ EvaluationNotebook[ ] + ] /; MatchQ[ icon, _Graphics | _Dynamic | _Image ] + ]; + evaluateLanguageLabel[ ___ ] := $insertEvaluateButtonLabel; +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*targetNotebookLabel*) +targetNotebookLabel // beginDefinition; + +targetNotebookLabel[ nbo_NotebookObject ] := + targetNotebookLabel[ nbo, GetFocusedNotebook @ nbo ]; + +targetNotebookLabel[ nbo_, None ] := + tr[ "FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" ]; + +targetNotebookLabel[ nbo_, focused_NotebookObject ] := + targetNotebookLabel[ nbo, focused, AbsoluteCurrentValue[ focused, WindowTitle ] ]; + +targetNotebookLabel[ nbo_, focused_NotebookObject, title_ ] := + Row @ Flatten @ { + trExprTemplate[ "FormattingInsertContentAndEvaluateWorkspaceChatTooltip" ][ <| + "1" -> { + chatbookIcon[ "WorkspaceFocusIndicatorNotebook", False ], + "\[ThinSpace]", + Style[ formatNotebookTitle @ title, FontWeight -> Bold ] + } + |> ] + }; + +targetNotebookLabel // endDefinition; + (* ::**************************************************************************************************************:: *) (* ::Section::Closed:: *) (*Buttons*) @@ -709,6 +750,20 @@ $copyToClipboardButtonLabel := $copyToClipboardButtonLabel = fancyTooltip[ tr[ "FormattingCopyToClipboardTooltip" ] ]; +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*$copyToClipboardButtonLabelWorkspaceChat*) +$copyToClipboardButtonLabelWorkspaceChat := $copyToClipboardButtonLabelWorkspaceChat = fancyTooltip[ + MouseAppearance[ + buttonMouseover[ + buttonFrameDefault @ labeledIcon[ { "WorkspaceCodeBlockCopy", False }, "FormattingCopyToClipboardLabel" ], + buttonFrameActive @ labeledIcon[ { "WorkspaceCodeBlockCopy", False }, "FormattingCopyToClipboardLabel" ] + ], + "LinkHand" + ], + tr[ "FormattingCopyToClipboardTooltip" ] +]; + (* ::**************************************************************************************************************:: *) (* ::Subsubsection::Closed:: *) (*$insertInputButtonLabel*) @@ -837,7 +892,7 @@ copyCodeBlock // endDefinition; (* ::Subsubsection::Closed:: *) (*getNotebookForCodeInsertion*) getNotebookForCodeInsertion // beginDefinition; -getNotebookForCodeInsertion[ chatNB_NotebookObject ] := getNotebookForCodeInsertion[ chatNB, getUserNotebook[ ] ]; +getNotebookForCodeInsertion[ chatNB_NotebookObject ] := getNotebookForCodeInsertion[ chatNB, GetFocusedNotebook @ chatNB ]; getNotebookForCodeInsertion[ _, userNB_NotebookObject ] := userNB; getNotebookForCodeInsertion[ _, None ] := CreateNotebook[ ]; getNotebookForCodeInsertion // endDefinition; @@ -1047,10 +1102,12 @@ buttonPane[ expr_ ] := (* ::**************************************************************************************************************:: *) (* ::Subsubsection::Closed:: *) (*labeledIcon*) -labeledIcon[ iconTemplateName_String, textResource_String ] := +labeledIcon[ iconTemplateName_String, textResource_String ] := labeledIcon[ { iconTemplateName, True }, textResource ] + +labeledIcon[ { iconTemplateName_String, useTemplateBoxQ_ }, textResource_String ] := Grid[ { { - buttonPane @ RawBoxes @ TemplateBox[ { }, iconTemplateName ], + buttonPane @ If[ useTemplateBoxQ, RawBoxes @ TemplateBox[ { }, iconTemplateName ], chatbookIcon[ iconTemplateName, False ] ], Style[ tr @ textResource, FontSize -> 12, FontColor -> RGBColor[ "#333333" ], FontFamily -> "Source Sans Pro" ] } }, BaselinePosition -> { 1, 2 }, Alignment -> { Left, Baseline }, Spacings -> { 0, 0 } ]; @@ -2931,6 +2988,7 @@ userMessageBox // endDefinition; (*Package Footer*) addToMXInitialization[ $copyToClipboardButtonLabel; + $copyToClipboardButtonLabelWorkspaceChat; $insertInputButtonLabel; $insertInputButtonLabelWorkspaceChat; $insertEvaluateButtonLabel; diff --git a/Source/Chatbook/Main.wl b/Source/Chatbook/Main.wl index 395f5e04..a822c767 100644 --- a/Source/Chatbook/Main.wl +++ b/Source/Chatbook/Main.wl @@ -64,6 +64,7 @@ BeginPackage[ "Wolfram`Chatbook`" ]; `GetChatHistory; `GetExpressionURI; `GetExpressionURIs; +`GetFocusedNotebook; `InlineTemplateBoxes; `InvalidateServiceCache; `ListSavedChats; @@ -229,6 +230,7 @@ $ChatbookProtectedNames = "Wolfram`Chatbook`" <> # & /@ { "GetChatHistory", "GetExpressionURI", "GetExpressionURIs", + "GetFocusedNotebook", "InlineTemplateBoxes", "ListSavedChats", "LoadChat", From 734c4f412934779d076c07ef521551077c6d019d Mon Sep 17 00:00:00 2001 From: Rick Hennigan Date: Wed, 27 Nov 2024 10:32:42 -0500 Subject: [PATCH 2/4] Reapply localization changes --- .../TextResources/French/ChatbookStrings.tr | 47 ++++++++----------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/FrontEnd/TextResources/French/ChatbookStrings.tr b/FrontEnd/TextResources/French/ChatbookStrings.tr index 3fe5e98d..4bc6fc7e 100644 --- a/FrontEnd/TextResources/French/ChatbookStrings.tr +++ b/FrontEnd/TextResources/French/ChatbookStrings.tr @@ -173,12 +173,12 @@ "UIAdvancedRoles" -> "Choisir automatiquement", "UITryEnableChatDialogMainText" -> "L\[CloseCurlyQuote]activation de la fonctionnalit\[EAcute] du notebook de chat d\[EAcute]truira les styles priv\[EAcute]s d\[EAcute]finis dans ce notebook et les remplacera par la feuille de style du chatbook partag\[EAcute]e.", "UITryEnableChatDialogConfirm" -> "\[CapitalEHat]tes-vous s\[UHat]r de vouloir continuer\[NonBreakingSpace]?", -"UIMessageManageSubscription" -> "Manage Subscription \[RightGuillemet]", -"UIMessageContactUs" -> "Contact us \[RightGuillemet]", -"UIMessageUsed80" -> "You have used 80% of your Wolfram Notebook Assistant + LLM Kit allowance for this month.", -"UIMessageUsedAll" -> "You have used your entire Wolfram Notebook Assistant + LLM Kit allowance for this month.", -"UIMessageHighUsageRate" -> "We've detected a very high rate of requests from your account. To prevent disruptions to the service for other users, we've temporarily had to block your requests.", -"UIMessageUnblockRequest" -> "Ask to be unblocked \[RightGuillemet]", +"UIMessageManageSubscription" -> "G\[EAcute]rer l\[CloseCurlyQuote]abonnement \[RightGuillemet]", +"UIMessageContactUs" -> "Contactez\[Hyphen]nous \[RightGuillemet]", +"UIMessageUsed80" -> "Vous avez utilis\[EAcute] 80\[NonBreakingSpace]% de votre allocation Assistant de notebook Wolfram + Kit LLM pour ce mois.", +"UIMessageUsedAll" -> "Vous avez utilis\[EAcute] la totalit\[EAcute] de votre allocation Assistant de notebook Wolfram + Kit LLM pour ce mois.", +"UIMessageHighUsageRate" -> "Nous avons d\[EAcute]tect\[EAcute] un nombre tr\[EGrave]s \[EAcute]lev\[EAcute] de demandes provenant de votre compte. Afin de ne pas perturber le service pour les autres utilisateurs, nous avons d\[UHat] temporairement bloquer vos demandes.", +"UIMessageUnblockRequest" -> "Demandez le d\[EAcute]blocage \[RightGuillemet]", "StylesheetChatWidgetButtonTooltip" -> "Envoyer au LLM", "StylesheetAssistantMenuInitializerButtonTooltip" -> "D\[EAcute]sactiver l\[CloseCurlyQuote]assistance automatique", @@ -210,7 +210,7 @@ "WorkspaceWindowTitle" -> "Assistant de notebook", "WorkspaceToolbarButtonLabelHistory" -> "Historique", "WorkspaceToolbarButtonLabelSources" -> "Sources", -"WorkspaceToolbarSourcesSubTitleMoved" -> "Previous chat moved to `1` History.", +"WorkspaceToolbarSourcesSubTitleMoved" -> "Le chat pr\[EAcute]c\[EAcute]dent a \[EAcute]t\[EAcute] d\[EAcute]plac\[EAcute] dans l\[CloseCurlyQuote]historique `1`.", "WorkspaceToolbarSourcesSubTitle" -> "Choisir les sources \[AGrave] mettre à la disposition de l\[CloseCurlyQuote]assistant de notebook.", "WorkspaceToolbarButtonLabelNew" -> "Nouveau Chat", "WorkspaceToolbarButtonTooltipHistory" -> "G\[EAcute]rer les conversations", @@ -220,38 +220,29 @@ "WorkspaceSourcesOpenNotebooks" -> "Ouvrir les notebooks", "WorkspaceOutputRaftCopyAsTooltip" -> "Copier la r\[EAcute]ponse dans le presse\[Hyphen]papiers\[Ellipsis]", -"WorkspaceOutputRaftCopyAs" -> "Copy response as\[Ellipsis]", -"WorkspaceOutputRaftCopyAsNotebookCells" -> "Notebook Cells", -"WorkspaceOutputRaftCopyAsPlainText" -> "Plain Text", +"WorkspaceOutputRaftCopyAs" -> "Copier la r\[EAcute]ponse en tant que\[Ellipsis]", +"WorkspaceOutputRaftCopyAsNotebookCells" -> "Cellules de notebook", +"WorkspaceOutputRaftCopyAsPlainText" -> "Texte brut", "WorkspaceOutputRaftCopyAsImage" -> "Image", "WorkspaceOutputRaftRegenerateTooltip" -> "Reg\[EAcute]n\[EAcute]rer la r\[EAcute]ponse", -"WorkspaceOutputRaftShareAsTooltip" -> "Share response\[Ellipsis]", -"WorkspaceOutputRaftShareAs" -> "Share this as\[Ellipsis]", -"WorkspaceOutputRaftShareAsCloudDeployment" -> "Cloud Deployment", +"WorkspaceOutputRaftShareAsTooltip" -> "Partager la r\[EAcute]ponse\[Ellipsis]", +"WorkspaceOutputRaftShareAs" -> "Partager ceci en tant que\[Ellipsis]", +"WorkspaceOutputRaftShareAsCloudDeployment" -> "D\[EAcute]ploiement dans le cloud", "WorkspaceOutputRaftShareAsPDF" -> "PDF", "WorkspaceOutputRaftShareAsImage" -> "Image", "WorkspaceOutputRaftFeedbackTooltip" -> "Envoyer un commentaire \[AGrave] Wolfram", -"WorkspaceFocusIndicatorEnableTooltip" -> "Enable using context from other notebooks", -"WorkspaceFocusIndicatorDisableTooltip" -> "Disable using context from other notebooks", -"WorkspaceFocusIndicatorFocus" -> "Focus:", -"WorkspaceFocusIndicatorMenuTooltip" -> "Choose a notebook to focus on for additional context", -"WorkspaceFocusIndicatorMenuAutomatic" -> "Choose Automatically", +"WorkspaceFocusIndicatorEnableTooltip" -> "Activer l\[CloseCurlyQuote]utilisation du contexte provenant d\[CloseCurlyQuote]autres notebooks", +"WorkspaceFocusIndicatorDisableTooltip" -> "D\[EAcute]sactiver l\[CloseCurlyQuote]utilisation du contexte provenant d\[CloseCurlyQuote]autres notebooks", +"WorkspaceFocusIndicatorFocus" -> "Focus :", +"WorkspaceFocusIndicatorMenuTooltip" -> "Choisissez un notebook sur lequel vous vous concentrerez pour obtenir un contexte suppl\[EAcute]mentaire.", +"WorkspaceFocusIndicatorMenuAutomatic" -> "Choisir automatiquement", "InlineChatButtonTooltipClose" -> "Fermer", "InlineChatButtonTooltipViewNotebookAssist" -> "Voir dans le chat de l\[CloseCurlyQuote]assistant du notebook", "NotebookAssistanceInputGettingStarted" -> "Aide\[Hyphen]moi \[AGrave] d\[EAcute]marrer", -"NotebookAssistanceInputErrorMessage" -> "Qu\[CloseCurlyQuote]est\[Hyphen]ce qui n\[CloseCurlyQuote]a pas fonctionn\[EAcute]\[NonBreakingSpace]?", - -"ProgressTextCheckingDocumentation" -> "Checking documentation", -"ProgressTextChoosingDocumentation" -> "Choosing relevant documentation", -"ProgressTextCreatingMessages" -> "Creating messages", -"ProgressTextSendingChat" -> "Sending chat", -"ProgressTextGeneratingSuggestions" -> "Generating suggestions", -"ProgressTextWaitingForResponse" -> "Waiting for response", -"ProgressTextDownloadingSnippet" -> "Downloading `1` documentation snippet", -"ProgressTextDownloadingSnippets" -> "Downloading `1` documentation snippets" +"NotebookAssistanceInputErrorMessage" -> "Qu\[CloseCurlyQuote]est\[Hyphen]ce qui n\[CloseCurlyQuote]a pas fonctionn\[EAcute]\[NonBreakingSpace]?" } @| @| From 0655b09aff53ab3f92c94e87b0132eaf1a907446 Mon Sep 17 00:00:00 2001 From: Rick Hennigan Date: Wed, 27 Nov 2024 10:33:17 -0500 Subject: [PATCH 3/4] Paclet version --- PacletInfo.wl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PacletInfo.wl b/PacletInfo.wl index 25571e9a..57c8245e 100644 --- a/PacletInfo.wl +++ b/PacletInfo.wl @@ -1,7 +1,7 @@ PacletObject[ <| "Name" -> "Wolfram/Chatbook", "PublisherID" -> "Wolfram", - "Version" -> "1.5.2.8", + "Version" -> "1.5.2.9", "WolframVersion" -> "14.1+", "Description" -> "Wolfram Notebooks + LLMs", "License" -> "MIT", From db37e8fa9be08283526c051cbb95d342c91ab050 Mon Sep 17 00:00:00 2001 From: Rick Hennigan Date: Wed, 27 Nov 2024 10:34:46 -0500 Subject: [PATCH 4/4] Add missing text resources --- FrontEnd/TextResources/French/ChatbookStrings.tr | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/FrontEnd/TextResources/French/ChatbookStrings.tr b/FrontEnd/TextResources/French/ChatbookStrings.tr index 4bc6fc7e..6332ee35 100644 --- a/FrontEnd/TextResources/French/ChatbookStrings.tr +++ b/FrontEnd/TextResources/French/ChatbookStrings.tr @@ -242,7 +242,16 @@ "InlineChatButtonTooltipViewNotebookAssist" -> "Voir dans le chat de l\[CloseCurlyQuote]assistant du notebook", "NotebookAssistanceInputGettingStarted" -> "Aide\[Hyphen]moi \[AGrave] d\[EAcute]marrer", -"NotebookAssistanceInputErrorMessage" -> "Qu\[CloseCurlyQuote]est\[Hyphen]ce qui n\[CloseCurlyQuote]a pas fonctionn\[EAcute]\[NonBreakingSpace]?" +"NotebookAssistanceInputErrorMessage" -> "Qu\[CloseCurlyQuote]est\[Hyphen]ce qui n\[CloseCurlyQuote]a pas fonctionn\[EAcute]\[NonBreakingSpace]?", + +"ProgressTextCheckingDocumentation" -> "Checking documentation", +"ProgressTextChoosingDocumentation" -> "Choosing relevant documentation", +"ProgressTextCreatingMessages" -> "Creating messages", +"ProgressTextSendingChat" -> "Sending chat", +"ProgressTextGeneratingSuggestions" -> "Generating suggestions", +"ProgressTextWaitingForResponse" -> "Waiting for response", +"ProgressTextDownloadingSnippet" -> "Downloading `1` documentation snippet", +"ProgressTextDownloadingSnippets" -> "Downloading `1` documentation snippets" } @| @|