@@ -118,26 +118,11 @@ writeSidebarChatSubDockedCell[ nbo_NotebookObject, sidebarCell_CellObject, conte
118118 subDockedCell = First [ Cells [ sidebarCell , CellTags -> "SidebarSubDockedCell" ], $Failed ];
119119 If [ ! FailureQ @ subDockedCell ,
120120 (* if the sub-cell already exists then rewrite it *)
121- WithCleanup [
122- FrontEndExecute [ {
123- FrontEnd ` SetOptions [ sidebarCell , Editable -> True ],
124- FrontEnd ` NotebookWrite [ subDockedCell , makeSidebarChatSubDockedCellExpression [ nbo , sidebarCell , content ] ]
125- } ]
126- ,
127- CurrentValue [ sidebarCell , Editable ] = Inherited
128- ]
121+ NotebookWrite [ subDockedCell , makeSidebarChatSubDockedCellExpression [ nbo , sidebarCell , content ] ]
129122 ,
130123 (* else, write a new sub-cell after the last docked cell *)
131124 lastDockedCell = ConfirmMatch [ Last [ Cells [ sidebarCell , CellTags -> "SidebarDockedCell" ], $Failed ], _ CellObject , "SidebarDockedCell" ];
132- WithCleanup [
133- FrontEndExecute [ {
134- FrontEnd ` SetOptions [ sidebarCell , Editable -> True ],
135- FrontEnd ` SelectionMove [ lastDockedCell , After , Cell ],
136- FrontEnd ` NotebookWrite [ nbo , RowBox [ { "\n " , makeSidebarChatSubDockedCellExpression [ nbo , sidebarCell , content ] } ] ]
137- } ]
138- ,
139- CurrentValue [ sidebarCell , Editable ] = Inherited
140- ]
125+ NotebookWrite [ System ` NotebookLocationSpecifier [ lastDockedCell , "After" ], makeSidebarChatSubDockedCellExpression [ nbo , sidebarCell , content ] ]
141126 ];
142127 (* TODO: move selection to side bar chat's input field *)
143128 ],
@@ -167,17 +152,7 @@ removeSidebarChatSubDockedCell // beginDefinition;
167152
168153removeSidebarChatSubDockedCell [ nbo_ NotebookObject , sidebarCell_ CellObject ] := Module [ { subDockedCell },
169154 subDockedCell = First [ Cells [ sidebarCell , CellTags -> "SidebarSubDockedCell" ], Missing @ "NoSidebarSubDockedCell" ];
170- If [ ! MissingQ @ subDockedCell ,
171- WithCleanup [
172- FrontEndExecute [ {
173- FrontEnd ` SetOptions [ sidebarCell , Editable -> True ],
174- FrontEnd ` SelectionMove [ subDockedCell , Before , Cell ],
175- FrontEnd ` FrontEndToken [ nbo , "DeletePrevious" ], (* remove the newline character before the sub-cell *)
176- FrontEnd ` NotebookDelete @ subDockedCell } ]
177- ,
178- CurrentValue [ sidebarCell , Editable ] = Inherited
179- ]
180- ]
155+ If [ ! MissingQ @ subDockedCell , NotebookDelete @ subDockedCell ]
181156];
182157
183158removeSidebarChatSubDockedCell // endDefinition ;
@@ -187,15 +162,7 @@ removeSidebarChatSubDockedCell // endDefinition;
187162(*removeSidebarTopCell*)
188163removeSidebarTopCell // beginDefinition ;
189164
190- removeSidebarTopCell [ nbo_ NotebookObject , sidebarTopCell_ CellObject ] := WithCleanup [
191- FrontEndExecute [ {
192- FrontEnd ` SetOptions [ sidebarCell , Editable -> True ],
193- FrontEnd ` SelectionMove [ sidebarTopCell , Before , Cell ],
194- FrontEnd ` FrontEndToken [ nbo , "DeletePrevious" ], (* remove the newline character before the top cell *)
195- FrontEnd ` NotebookDelete @ sidebarTopCell } ]
196- ,
197- CurrentValue [ sidebarCell , Editable ] = Inherited
198- ];
165+ removeSidebarTopCell [ nbo_ NotebookObject , sidebarTopCell_ CellObject ] := NotebookDelete @ sidebarTopCell ;
199166
200167removeSidebarTopCell // endDefinition ;
201168
@@ -206,17 +173,7 @@ removeSidebarScrollingContentCell // beginDefinition;
206173
207174removeSidebarScrollingContentCell [ nbo_ NotebookObject , sidebarCell_ CellObject ] := Module [ { scrollablePaneCell },
208175 scrollablePaneCell = First [ Cells [ sidebarCell , CellTags -> "SidebarScrollingContentCell" ], Missing @ "NoScrollingSidebarCell" ];
209- If [ ! MissingQ @ scrollablePaneCell ,
210- WithCleanup [
211- FrontEndExecute [ {
212- FrontEnd ` SetOptions [ sidebarCell , Editable -> True ],
213- FrontEnd ` SelectionMove [ scrollablePaneCell , Before , Cell ],
214- FrontEnd ` FrontEndToken [ nbo , "DeletePrevious" ], (* remove the newline character before the top cell *)
215- FrontEnd ` NotebookDelete @ scrollablePaneCell } ]
216- ,
217- CurrentValue [ sidebarCell , Editable ] = Inherited
218- ]
219- ]
176+ If [ ! MissingQ @ scrollablePaneCell , NotebookDelete @ scrollablePaneCell ]
220177];
221178
222179removeSidebarScrollingContentCell // endDefinition ;
@@ -234,7 +191,7 @@ Module[ { sidebarCellObj, dockedCellObj, chatInputCellObj },
234191 With [ { sc = sidebarCellObj , cc = chatInputCellObj , dc = dockedCellObj },
235192 Cell [ BoxData @
236193 PaneBox [
237- RowBox @ Riffle [ cells , " \n " ] ,
194+ RowBox @ cells ,
238195 AppearanceElements -> {},
239196 ImageSize ->
240197 Dynamic [
@@ -2700,25 +2657,9 @@ loadConversation[ nbo_NotebookObject, sidebarCell_CellObject, id_ ] := Enclose[
27002657 scrollablePaneCell = First [ Cells [ sidebarCell , CellTags -> "SidebarScrollingContentCell" ], Missing @ "NoScrollingContent" ];
27012658 If [ MissingQ @ scrollablePaneCell ,
27022659 lastDockedCell = ConfirmMatch [ Last [ Cells [ sidebarCell , CellTags -> "SidebarDockedCell" ], $Failed ], _ CellObject , "SidebarDockedCell" ];
2703- (* FIXME: this can write to the notebook content area if its empty *)
2704- WithCleanup [
2705- FrontEndExecute [ {
2706- FrontEnd ` SetOptions [ sidebarCell , Editable -> True ],
2707- FrontEnd ` SelectionMove [ lastDockedCell , After , Cell , AutoScroll -> True ],
2708- FrontEnd ` NotebookWrite [ nbo , RowBox [ { "\n " , sidebarScrollingCell [ nbo , cells ] } ] ]
2709- } ]
2710- ,
2711- CurrentValue [ sidebarCell , Editable ] = Inherited
2712- ]
2660+ NotebookWrite [ System ` NotebookLocationSpecifier [ lastDockedCell , "After" ], sidebarScrollingCell [ nbo , cells ] ]
27132661 , (* ELSE *)
2714- WithCleanup [
2715- FrontEndExecute [ {
2716- FrontEnd ` SetOptions [ sidebarCell , Editable -> True ],
2717- FrontEnd ` NotebookWrite [ scrollablePaneCell , sidebarScrollingCell [ nbo , cells ] ]
2718- } ]
2719- ,
2720- CurrentValue [ sidebarCell , Editable ] = Inherited
2721- ]
2662+ NotebookWrite [ scrollablePaneCell , sidebarScrollingCell [ nbo , cells ] ]
27222663 ];
27232664
27242665 CurrentChatSettings [ sidebarCell , "ConversationUUID" ] = uuid ;
0 commit comments