File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -378,6 +378,11 @@ def upsert_note(
378378 existing .title if title is None else title ,
379379 content_plain ,
380380 )
381+ next_is_ai_generated = (
382+ existing .is_ai_generated
383+ if is_ai_generated is None
384+ else bool (is_ai_generated )
385+ )
381386 topic_values = existing .topic_ids if topic_ids is _UNSET else topic_ids
382387 tag_values = existing .tags if tags is _UNSET else tags
383388 with self .store ._lock :
@@ -392,6 +397,7 @@ def upsert_note(
392397 snippet = ?,
393398 topic_ids = ?,
394399 tags = ?,
400+ is_ai_generated = ?,
395401 word_count = ?,
396402 updated_at = datetime('now'),
397403 edited_at = datetime('now')
@@ -405,6 +411,7 @@ def upsert_note(
405411 _snippet (content_plain ),
406412 self .store ._json_dumps (_normalize_string_list (topic_values )),
407413 self .store ._json_dumps (_normalize_string_list (tag_values )),
414+ 1 if next_is_ai_generated else 0 ,
408415 _word_count (content_plain ),
409416 note_key ,
410417 ),
Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ def test_notebook_store_crud_search_and_topic_counts(tmp_path) -> None:
103103 notebook_id = notebook .id ,
104104 title = "Closure updated" ,
105105 content = "closure update" ,
106+ is_ai_generated = True ,
106107 source_type = "topic" ,
107108 source_ref = "closure" ,
108109 topic_ids = ["closure" ],
@@ -115,13 +116,18 @@ def test_notebook_store_crud_search_and_topic_counts(tmp_path) -> None:
115116 "source_type update ignored" in str (args [0 ])
116117 for args , _kwargs in logger .warnings
117118 )
119+ assert updated .is_ai_generated is True
118120
119121 partial = notebooks .upsert_note (note_id = note .id , title = "Closure final" )
120122 assert partial .title == "Closure final"
121123 assert partial .notebook_id == notebook .id
122124 assert partial .content == "closure update"
123125 assert partial .topic_ids == ["closure" ]
124126 assert partial .tags == ["updated" ]
127+ assert partial .is_ai_generated is True
128+
129+ manual = notebooks .upsert_note (note_id = note .id , is_ai_generated = False )
130+ assert manual .is_ai_generated is False
125131
126132 deleted = notebooks .delete_notebook (notebook .id )
127133 assert deleted == {"deleted" : 1 , "notes_unlinked" : 1 }
You can’t perform that action at this time.
0 commit comments