Skip to content

Commit

Permalink
Pull request #85: Feature: Use dedicated kernel for notebook assistan…
Browse files Browse the repository at this point in the history
…ce if one is defined

Merge in PAC/chatbook from feature/dedicated-notebook-assistance-kernel to main

* commit '0fb2e6410fade33d97935a2afaa00b10abe3a241':
  Feature: Use dedicated kernel for notebook assistance if one is defined
  • Loading branch information
rhennigan committed Nov 19, 2024
2 parents 7fe6058 + 0fb2e64 commit 8ae59f2
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Source/Chatbook/ChatModes/ShowNotebookAssistance.wl
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ showNotebookAssistanceWindow[ source_NotebookObject, input_, evaluate_, new_ ] :
ConfirmMatch[ LogChatTiming @ attachToLeft[ source, current ], _NotebookObject, "Attached" ]
];

setNotebookAssistanceEvaluator @ nbo;

LogChatTiming @ setWindowInputAndEvaluate[ nbo, input, evaluate ]
],
throwInternalFailure
Expand All @@ -494,6 +496,8 @@ showNotebookAssistanceWindow[ None, input_, evaluate_, new_ ] := Enclose[
current
];

setNotebookAssistanceEvaluator @ nbo;

setWindowInputAndEvaluate[ nbo, input, evaluate ]
],
throwInternalFailure
Expand All @@ -502,6 +506,18 @@ showNotebookAssistanceWindow[ None, input_, evaluate_, new_ ] := Enclose[

showNotebookAssistanceWindow // endDefinition;

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

setNotebookAssistanceEvaluator[ nbo_NotebookObject ] :=
If[ AssociationQ @ Association @ CurrentValue[ nbo, { EvaluatorNames, "NotebookAssistance" } ],
SetOptions[ nbo, Evaluator -> "NotebookAssistance" ]
];

setNotebookAssistanceEvaluator // endDefinition;

(* ::**************************************************************************************************************:: *)
(* ::Subsubsection::Closed:: *)
(*setWindowInputAndEvaluate*)
Expand Down Expand Up @@ -549,15 +565,15 @@ attachToLeft[ source_NotebookObject, current_NotebookObject ] := Enclose[
WindowMargins -> { { left - width, Automatic }, { bottom, top } },
WindowSize -> { width, Automatic }
];

If[ (* Starting in Mac 14.2, we can make sure the assistant notebook is on right "space". *)
And[
BoxForm`sufficientVersionQ[14.2],
Internal`CachedSystemInformation["FrontEnd", "OperatingSystem"] === "MacOSX"
],
FE`Evaluate @ Evaluate @ FEPrivate`MoveToActiveDesktop @ current
];

SetSelectedNotebook @ current;
moveToChatInputField[ current, True ];

Expand Down

0 comments on commit 8ae59f2

Please sign in to comment.