@@ -32,12 +32,26 @@ def setUp(self):
3232 "INSERT INTO cursorDiskKV ([key], value) VALUES (?, ?)" ,
3333 ("bubbleId:composer-abc:bubble-null" , None ), # NULL value — the crash case
3434 )
35- # Also insert a healthy bubble so we verify good rows still load .
35+ # Healthy bubble that should surface in the assembled tab .
3636 conn .execute (
3737 "INSERT INTO cursorDiskKV ([key], value) VALUES (?, ?)" ,
3838 (
3939 "bubbleId:composer-abc:bubble-ok" ,
40- json .dumps ({"type" : 1 , "text" : "hello" , "createdAt" : 0 }),
40+ json .dumps ({"type" : 1 , "text" : "hello world" , "createdAt" : 1739200000000 }),
41+ ),
42+ )
43+ # Composer referencing the healthy bubble — required for a tab to be built.
44+ conn .execute (
45+ "INSERT INTO cursorDiskKV ([key], value) VALUES (?, ?)" ,
46+ (
47+ "composerData:composer-abc" ,
48+ json .dumps ({
49+ "name" : "Test Chat" ,
50+ "modelConfig" : {"modelName" : "gpt-4o" },
51+ "fullConversationHeadersOnly" : [{"bubbleId" : "bubble-ok" , "type" : 1 }],
52+ "lastUpdatedAt" : 1739300000000 ,
53+ "createdAt" : 1739200000000 ,
54+ }),
4155 ),
4256 )
4357 conn .commit ()
@@ -53,7 +67,7 @@ def test_null_bubble_row_is_skipped_without_exception(self):
5367 from services .workspace_tabs import assemble_workspace_tabs
5468
5569 try :
56- payload , status = assemble_workspace_tabs (
70+ _payload , status = assemble_workspace_tabs (
5771 workspace_id = "global" ,
5872 workspace_path = self .workspace_path ,
5973 rules = [],
@@ -64,7 +78,7 @@ def test_null_bubble_row_is_skipped_without_exception(self):
6478 self .assertEqual (status , 200 )
6579
6680 def test_healthy_bubbles_still_load_when_null_row_present (self ):
67- """Healthy bubble rows in the same table are not dropped by the None-guard ."""
81+ """The healthy bubble surfaces in a tab even when a NULL row is present ."""
6882 from services .workspace_tabs import assemble_workspace_tabs
6983
7084 payload , status = assemble_workspace_tabs (
@@ -74,7 +88,21 @@ def test_healthy_bubbles_still_load_when_null_row_present(self):
7488 )
7589 self .assertEqual (status , 200 )
7690 self .assertIsInstance (payload , dict )
77- self .assertIn ("tabs" , payload )
91+ tabs = payload .get ("tabs" , [])
92+ self .assertEqual (len (tabs ), 1 , "Expected exactly one tab for composer-abc" )
93+
94+ tab = tabs [0 ]
95+ self .assertEqual (tab ["id" ], "composer-abc" )
96+ self .assertEqual (tab ["title" ], "Test Chat" )
97+ self .assertIn ("bubbles" , tab )
98+ self .assertIn ("codeBlockDiffs" , tab )
99+
100+ bubbles = tab ["bubbles" ]
101+ self .assertEqual (len (bubbles ), 1 , "Expected exactly one bubble (null row skipped)" )
102+ bubble = bubbles [0 ]
103+ self .assertEqual (bubble ["type" ], "user" )
104+ self .assertEqual (bubble ["text" ], "hello world" )
105+ self .assertIn ("timestamp" , bubble )
78106
79107
80108if __name__ == "__main__" :
0 commit comments