From 609b5f8a326909abeb81c8e6f5d68b63c4e49e07 Mon Sep 17 00:00:00 2001 From: Rick Hennigan Date: Wed, 27 Nov 2024 17:41:11 -0500 Subject: [PATCH] Bugfix: Show correct code block buttons while streaming --- PacletInfo.wl | 2 +- Source/Chatbook/Formatting.wl | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/PacletInfo.wl b/PacletInfo.wl index 31096f9b..fbddbe06 100644 --- a/PacletInfo.wl +++ b/PacletInfo.wl @@ -1,7 +1,7 @@ PacletObject[ <| "Name" -> "Wolfram/Chatbook", "PublisherID" -> "Wolfram", - "Version" -> "1.5.2.12", + "Version" -> "1.5.2.13", "WolframVersion" -> "14.1+", "Description" -> "Wolfram Notebooks + LLMs", "License" -> "MIT", diff --git a/Source/Chatbook/Formatting.wl b/Source/Chatbook/Formatting.wl index e064ea2e..be0f9b2b 100644 --- a/Source/Chatbook/Formatting.wl +++ b/Source/Chatbook/Formatting.wl @@ -685,17 +685,24 @@ evaluateLanguageLabel[ name_String, False ] := ]; evaluateLanguageLabel[ name_String, True ] := - With[ { icon = If[ name === "Wolfram", chatbookIcon[ "WorkspaceCodeBlockInsertAndEvaluate", False ], $languageIcons @ name ] }, + Catch @ Module[ { wl, icon, labeled }, + + wl = wolframLanguageQ @ name; + icon = If[ wl, chatbookIcon[ "WorkspaceCodeBlockInsertAndEvaluate", False ], $languageIcons @ name ]; + If[ ! MatchQ[ icon, _Graphics | _Dynamic | _Image ], Throw @ $insertEvaluateButtonLabel ]; + + labeled = labeledIcon[ + If[ wl, { "WorkspaceCodeBlockInsertAndEvaluate", False }, name ], + "FormattingInsertContentAndEvaluateLabel" + ]; + fancyTooltip[ MouseAppearance[ - buttonMouseover[ - buttonFrameDefault[ labeledIcon[ If[ name === "Wolfram", { "WorkspaceCodeBlockInsertAndEvaluate", False }, name ], "FormattingInsertContentAndEvaluateLabel" ], True ], - buttonFrameActive[ labeledIcon[ If[ name === "Wolfram", { "WorkspaceCodeBlockInsertAndEvaluate", False }, name ], "FormattingInsertContentAndEvaluateLabel" ], True ] - ], + buttonMouseover[ buttonFrameDefault[ labeled, True ], buttonFrameActive[ labeled, True ] ], "LinkHand" ], targetNotebookLabel @ EvaluationNotebook[ ] - ] /; MatchQ[ icon, _Graphics | _Dynamic | _Image ] + ] ]; evaluateLanguageLabel[ ___ ] := $insertEvaluateButtonLabel;