From 3c7455fdbe18a9cc4ec396b529a0ba703597d77e Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sun, 28 Jun 2026 00:01:22 -0400 Subject: [PATCH] test(rag): wait for files setter before triggering RAG sync The set_value('files', ...) call is async (push_event -> pending_gui_tasks -> render loop). The RAG setters (rag_enabled, rag_source, rag_emb_provider) are also async and each triggers a RAG sync via submit_io. The syncs and the files setter are NOT ordered: the sync may fire before the files setter is processed, in which case the sync sees self.files == [] and skips the rebuild (RAG sync only triggers the rebuild if both is_empty() AND self.files are truthy). Fix: poll get_value('files') until the expected value is reflected, guaranteeing the files setter is processed before the RAG setters trigger their syncs. Belt-and-suspenders alongside the project-switch fix from the previous commit. The test was passing in 4d2a6666 because of timing; the project switch added latency, so the race is now exposed. --- tests/test_rag_phase4_final_verify.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_rag_phase4_final_verify.py b/tests/test_rag_phase4_final_verify.py index 7121658f..aff79334 100644 --- a/tests/test_rag_phase4_final_verify.py +++ b/tests/test_rag_phase4_final_verify.py @@ -69,8 +69,18 @@ def test_phase4_final_verify(live_gui, live_gui_workspace): try: # 2. Configure project through Hook API + # set_value is async (push_event -> pending_gui_tasks -> render loop). + # Wait for the files setter to be processed before triggering the RAG + # sync, otherwise the sync sees self.files == [] and skips the rebuild + # (RAG sync only triggers the rebuild if both is_empty() AND self.files + # are truthy). The test was passing in 4d2a6666 because of timing; + # the project switch added latency, so the race is now exposed. client.set_value('rag_collection_name', _collection_name) client.set_value('files', ['final_test_1.txt', 'final_test_2.py']) + for _ in range(50): + if client.get_value('files') == ['final_test_1.txt', 'final_test_2.py']: + break + time.sleep(0.1) client.set_value('rag_enabled', True) client.set_value('rag_source', 'chroma') client.set_value('rag_emb_provider', 'local')