Skip to content

Commit

Permalink
Merge pull request #1037 from WolframResearch/998-frontendresourcecha…
Browse files Browse the repository at this point in the history
…tbookstrings-name-can-fail-potentially-requiring-a-pacletdatarebuild

Bugfix: Attempt a `PacletDataRebuild[]` if `FrontEndResource["ChatbookStrings", name]` fails
  • Loading branch information
rhennigan authored Jan 21, 2025
2 parents c2118d5 + 7b2b366 commit a7ddfe5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
26 changes: 25 additions & 1 deletion Source/Chatbook/Common.wl
Original file line number Diff line number Diff line change
Expand Up @@ -1340,9 +1340,33 @@ tr // endDefinition;
(*trRaw*)
trRaw // beginDefinition;
trRaw[ name_? StringQ ] /; $CloudEvaluation := cloudTextResource @ name;
trRaw[ name_? StringQ ] := FrontEndResource[ "ChatbookStrings", name ];
trRaw[ name_? StringQ ] := chatbookString @ name;
trRaw // endDefinition;

(* ::**************************************************************************************************************:: *)
(* ::Subsubsection::Closed:: *)
(*chatbookString*)
chatbookString // beginDefinition;

chatbookString[ name_String ] := Enclose[
Catch @ Module[ { string },
string = ConfirmMatch[ usingFrontEnd @ FrontEndResource[ "ChatbookStrings", name ], _String|$Failed, "String" ];
If[ StringQ @ string, Throw @ string ];
pacletDataRebuild[ ];
ConfirmBy[ usingFrontEnd @ FrontEndResource[ "ChatbookStrings", name ], StringQ, "Retry" ]
],
throwInternalFailure
];

chatbookString // endDefinition;

(* ::**************************************************************************************************************:: *)
(* ::Subsubsubsection::Closed:: *)
(*pacletDataRebuild*)
pacletDataRebuild // beginDefinition;
pacletDataRebuild[ ] := pacletDataRebuild[ ] = PacletDataRebuild[ ];
pacletDataRebuild // endDefinition;

(* ::**************************************************************************************************************:: *)
(* ::Subsection::Closed:: *)
(*trStringTemplate*)
Expand Down
19 changes: 11 additions & 8 deletions Source/Chatbook/PromptGenerators/RelatedDocumentation.wl
Original file line number Diff line number Diff line change
Expand Up @@ -919,14 +919,17 @@ fetchDocumentationSnippets[ uris: { __String } ] := Enclose[
Module[ { count, text, $results, tasks },
count = Length @ uris;

text = ConfirmBy[
If[ count === 1,
trStringTemplate[ "ProgressTextDownloadingSnippet" ][ count ],
trStringTemplate[ "ProgressTextDownloadingSnippets" ][ count ]
],
StringQ,
"Text"
];
text = If[ $EvaluationEnvironment === "Session",
ConfirmBy[
If[ count === 1,
trStringTemplate[ "ProgressTextDownloadingSnippet" ][ count ],
trStringTemplate[ "ProgressTextDownloadingSnippets" ][ count ]
],
StringQ,
"Text"
],
""
];

withApproximateProgress[
$results = AssociationMap[ <| "URI" -> #1 |> &, uris ];
Expand Down

0 comments on commit a7ddfe5

Please sign in to comment.