@@ -10,7 +10,6 @@ import {
1010} from "@/core/cells/cells" ;
1111import { CellId } from "@/core/cells/ids" ;
1212import { updateEditorCodeFromPython } from "@/core/codemirror/language/utils" ;
13- import type { JotaiStore } from "@/core/state/jotai" ;
1413import type { CellColumnId } from "@/utils/id-tree" ;
1514import {
1615 type AiTool ,
@@ -87,28 +86,23 @@ export type EditType = EditOperation["type"];
8786export class EditNotebookTool
8887 implements AiTool < EditNotebookInput , ToolOutputBase >
8988{
90- private store : JotaiStore ;
9189 readonly name = "edit_notebook_tool" ;
9290 readonly description = description ;
9391 readonly schema = editNotebookSchema ;
9492 readonly outputSchema = toolOutputBaseSchema ;
9593 readonly mode : CopilotMode [ ] = [ "agent" ] ;
9694
97- constructor ( store : JotaiStore ) {
98- this . store = store ;
99- }
100-
10195 handler = async (
10296 { edit } : EditNotebookInput ,
10397 toolContext : ToolNotebookContext ,
10498 ) : Promise < ToolOutputBase > => {
105- const { addStagedCell, createNewCell } = toolContext ;
99+ const { addStagedCell, createNewCell, store } = toolContext ;
106100
107101 switch ( edit . type ) {
108102 case "update_cell" : {
109103 const { cellId, code } = edit ;
110104
111- const notebook = this . store . get ( notebookAtom ) ;
105+ const notebook = store . get ( notebookAtom ) ;
112106 this . validateCellIdExists ( cellId , notebook ) ;
113107 const editorView = this . getCellEditorView ( cellId , notebook ) ;
114108
@@ -133,7 +127,7 @@ export class EditNotebookTool
133127 const newCellId = CellId . create ( ) ;
134128
135129 if ( typeof position === "object" ) {
136- const notebook = this . store . get ( notebookAtom ) ;
130+ const notebook = store . get ( notebookAtom ) ;
137131 if ( "cellId" in position ) {
138132 this . validateCellIdExists ( position . cellId , notebook ) ;
139133 notebookPosition = position . cellId ;
@@ -164,7 +158,7 @@ export class EditNotebookTool
164158 case "delete_cell" : {
165159 const { cellId } = edit ;
166160
167- const notebook = this . store . get ( notebookAtom ) ;
161+ const notebook = store . get ( notebookAtom ) ;
168162 this . validateCellIdExists ( cellId , notebook ) ;
169163
170164 const editorView = this . getCellEditorView ( cellId , notebook ) ;
0 commit comments