diff --git a/Source/Chatbook/ChatModes/Common.wl b/Source/Chatbook/ChatModes/Common.wl index 4fcec311..a4d82b9e 100644 --- a/Source/Chatbook/ChatModes/Common.wl +++ b/Source/Chatbook/ChatModes/Common.wl @@ -11,8 +11,8 @@ HoldComplete[ `createWorkspaceChat, `evaluateAttachedInlineChat, `findCurrentWorkspaceChat, - `getNotebookAssistanceInput, `getContextFromSelection, + `getNotebookAssistanceInput, `getSelectionInfo, `moveChatInputToBottom, `moveChatInputToTop, diff --git a/Source/Chatbook/ChatModes/UI.wl b/Source/Chatbook/ChatModes/UI.wl index 13d906f5..bcd37ac8 100644 --- a/Source/Chatbook/ChatModes/UI.wl +++ b/Source/Chatbook/ChatModes/UI.wl @@ -1812,30 +1812,77 @@ $trashButtonLabel := $trashButtonLabel = chatbookIcon[ "WorkspaceHistoryTrashI (* ::Section::Closed:: *) (*Global Progress Bar*) -(* TODO: *) -Grid[ +(* ::**************************************************************************************************************:: *) +(* ::Subsection::Closed:: *) +(*withWorkspaceGlobalProgress*) +withWorkspaceGlobalProgress // beginDefinition; +withWorkspaceGlobalProgress // Attributes = { HoldRest }; + +withWorkspaceGlobalProgress[ nbo_NotebookObject, eval_ ] := Enclose[ + Catch @ Module[ { attached }, + + attached = ConfirmMatch[ + AttachCell[ + nbo, + Cell[ + BoxData @ ToBoxes @ $workspaceChatProgressBar, + "WorkspaceChatProgressBar", + FontSize -> 0.1, + Magnification -> AbsoluteCurrentValue[ nbo, Magnification ] + ], + { Center, Top }, + Offset[ { 0, 1 }, { 0, 0 } ], + { Center, Top }, + RemovalConditions -> { "EvaluatorQuit" } + ], + _CellObject, + "Attached" + ]; + + WithCleanup[ eval, NotebookDelete @ attached ] + ], + throwInternalFailure +]; + +withWorkspaceGlobalProgress // endDefinition; + + +$workspaceChatProgressBar = With[ { + background = None, + colorCenter = RGBColor[ 0.27451, 0.61961, 0.79608, 1.0 ], + colorEdges = RGBColor[ 0.27451, 0.61961, 0.79608, 0.0 ], + duration = 3, + leftOffset = -0.5, + rightOffset = 1.5, + thickness = Thickness[ 1 ] + }, + Graphics[ { - Graphics[ - { - RGBColor[ "#449EF7" ], - Dynamic @ Rectangle[ - ImageScaled @ { Max[ 0, Clock[ { -0.5, 1.0 }, 3 ] ], 0 }, - ImageScaled @ { Min[ 1, Clock[ { 0.0, 1.5 }, 3 ] ], 1 } + thickness, + Dynamic @ TemplateBox[ + { Clock[ { leftOffset, 1.0 }, duration ], Clock[ { 0.0, rightOffset }, duration ] }, + "WorkspaceChatProgressBar", + DisplayFunction -> Function[ + LineBox[ + { + { #1, 0 }, + { (#1 + #2) / 2, 0 }, + { #2, 0 } + }, + VertexColors -> { colorEdges, colorCenter, colorEdges } ] - }, - AspectRatio -> Full, - Background -> RGBColor[ "#D1D1D1" ], - ImageSize -> { Full, 2 }, - PlotRangePadding -> None + ] ] - } - }, - Alignment -> { Center, Center }, - Frame -> None, - ItemSize -> { Automatic, 0 }, - Spacings -> { { 0, { }, 0 }, { 0, { }, 0 } } -] + }, + AspectRatio -> Full, + Background -> background, + ImageMargins -> 0, + ImageSize -> { Full, 4 }, + PlotRange -> { { 0, 1 }, Automatic }, + PlotRangePadding -> None + ] +]; (* ::**************************************************************************************************************:: *) (* ::Section::Closed:: *) diff --git a/Source/Chatbook/ChatState.wl b/Source/Chatbook/ChatState.wl index 802a29c5..3c1bbb54 100644 --- a/Source/Chatbook/ChatState.wl +++ b/Source/Chatbook/ChatState.wl @@ -160,7 +160,15 @@ withEvaluationCell // endDefinition; (*withEvaluationNotebook*) withEvaluationNotebook // beginDefinition; withEvaluationNotebook // Attributes = { HoldRest }; -withEvaluationNotebook[ nbo_NotebookObject, eval_ ] := Block[ { $evaluationNotebook = nbo }, eval ]; + +withEvaluationNotebook[ nbo_NotebookObject, eval_ ] := + Block[ { $evaluationNotebook = nbo }, + If[ TrueQ @ CurrentChatSettings[ nbo, "WorkspaceChat" ], + withWorkspaceGlobalProgress[ nbo, eval ], + eval + ] + ]; + withEvaluationNotebook // endDefinition; (* ::**************************************************************************************************************:: *) diff --git a/Source/Chatbook/CommonSymbols.wl b/Source/Chatbook/CommonSymbols.wl index c1ae1411..2cb0fdb3 100644 --- a/Source/Chatbook/CommonSymbols.wl +++ b/Source/Chatbook/CommonSymbols.wl @@ -310,6 +310,7 @@ BeginPackage[ "Wolfram`Chatbook`Common`" ]; `withChatState; `withChatStateAndFEObjects; `withToolBox; +`withWorkspaceGlobalProgress; `wlTemplateBoxes; `writeInlineChatOutputCell; `writeReformattedCell; diff --git a/Source/Chatbook/Formatting.wl b/Source/Chatbook/Formatting.wl index 32763188..fddc0a62 100644 --- a/Source/Chatbook/Formatting.wl +++ b/Source/Chatbook/Formatting.wl @@ -1496,7 +1496,10 @@ makeToolCallBoxLabel[ as_Association, name_String ] := makeToolCallBoxLabel[ as, name, getToolIcon @ as ]; makeToolCallBoxLabel[ as_, name_String, icon_ ] /; $dynamicText := - fakeOpenerView @ makeToolCallBoxLabel0[ as, name, icon ]; + fakeOpenerView[ + makeToolCallBoxLabel0[ as, name, icon ], + as[ "Result" ] =!= "" + ]; makeToolCallBoxLabel[ as0_, name_String, icon_ ] := With[ { as = resolveToolFormatter @ as0 }, @@ -1523,11 +1526,15 @@ makeToolCallBoxLabel // endDefinition; makeToolCallBoxLabel0 // beginDefinition; -makeToolCallBoxLabel0[ KeyValuePattern[ "Result" -> "" ], string_String, icon_ ] := Flatten @ { - toolCallIconPane @ icon, - Style[ tr[ "FormattingToolUsing" ], FontColor -> RGBColor[ "#3383AC" ] ], - Style[ string, FontWeight -> "DemiBold", FontColor -> RGBColor[ "#3383AC" ] ] -}; +makeToolCallBoxLabel0[ KeyValuePattern[ "Result" -> "" ], string_String, icon_ ] := +With[ { col = RGBColor[ "#3383AC" ] }, + Flatten @ { + toolCallIconPane @ icon, + Style[ tr[ "FormattingToolUsing" ], FontColor -> col ], + Style[ string, FontWeight -> "DemiBold", FontColor -> col ], + RawBoxes @ DynamicBox @ FEPrivate`FrontEndResource[ "FEExpressions", "PercolateColorAnimator" ][ Small, col ] + } +]; makeToolCallBoxLabel0[ as_, string_String, icon_ ] := Flatten @ { toolCallIconPane @ icon, diff --git a/Source/Chatbook/FrontEnd.wl b/Source/Chatbook/FrontEnd.wl index 7800daaf..2d0123e9 100644 --- a/Source/Chatbook/FrontEnd.wl +++ b/Source/Chatbook/FrontEnd.wl @@ -1107,12 +1107,15 @@ $openerFrameOptionsActive = Sequence[ but doesn't yet contain any inner data to reduce MathLink traffic *) fakeOpenerView // beginDefinition; -fakeOpenerView[ label_ ] := Deploy @ Framed[ +fakeOpenerView[ label_, showButton_: False ] := Deploy @ Framed[ Grid[ { Flatten @ { label, - RawBoxes @ TemplateBox[ { RGBColor[ "#3383AC" ] }, "DiscardedMaterialOpenerIcon" ] + If[ TrueQ @ showButton, + RawBoxes @ TemplateBox[ { RGBColor[ "#3383AC" ] }, "DiscardedMaterialOpenerIcon" ], + Nothing + ] } }, $openerLabelGridOptions