@@ -18,6 +18,7 @@ describe("useThreadSelectors", () => {
1818 activeWorkspaceId : "workspace-1" ,
1919 activeThreadIdByWorkspace : { "workspace-1" : "thread-1" } ,
2020 itemsByThread : { "thread-1" : [ messageItem ] } ,
21+ threadsByWorkspace : { } ,
2122 } ) ,
2223 ) ;
2324
@@ -31,6 +32,7 @@ describe("useThreadSelectors", () => {
3132 activeWorkspaceId : null ,
3233 activeThreadIdByWorkspace : { "workspace-1" : "thread-1" } ,
3334 itemsByThread : { "thread-1" : [ messageItem ] } ,
35+ threadsByWorkspace : { } ,
3436 } ) ,
3537 ) ;
3638
@@ -44,10 +46,75 @@ describe("useThreadSelectors", () => {
4446 activeWorkspaceId : "workspace-1" ,
4547 activeThreadIdByWorkspace : { "workspace-1" : "thread-2" } ,
4648 itemsByThread : { } ,
49+ threadsByWorkspace : { } ,
4750 } ) ,
4851 ) ;
4952
5053 expect ( result . current . activeThreadId ) . toBe ( "thread-2" ) ;
5154 expect ( result . current . activeItems ) . toEqual ( [ ] ) ;
5255 } ) ;
56+
57+ it ( "enriches collab tool items from active workspace thread metadata" , ( ) => {
58+ const collabItem : ConversationItem = {
59+ id : "collab-1" ,
60+ kind : "tool" ,
61+ toolType : "collabToolCall" ,
62+ title : "Collab: spawn_agent" ,
63+ detail : "From thread-parent → thread-child" ,
64+ status : "completed" ,
65+ output : "Investigate the issue\n\nthread-child: completed" ,
66+ collabSender : { threadId : "thread-parent" } ,
67+ collabReceiver : { threadId : "thread-child" } ,
68+ collabReceivers : [ { threadId : "thread-child" } ] ,
69+ collabStatuses : [ { threadId : "thread-child" , status : "completed" } ] ,
70+ } ;
71+
72+ const { result } = renderHook ( ( ) =>
73+ useThreadSelectors ( {
74+ activeWorkspaceId : "workspace-1" ,
75+ activeThreadIdByWorkspace : { "workspace-1" : "thread-parent" } ,
76+ itemsByThread : { "thread-parent" : [ collabItem ] } ,
77+ threadsByWorkspace : {
78+ "workspace-1" : [
79+ {
80+ id : "thread-child" ,
81+ name : "Review helper" ,
82+ updatedAt : 1 ,
83+ isSubagent : true ,
84+ subagentNickname : "Atlas" ,
85+ subagentRole : "reviewer" ,
86+ } ,
87+ ] ,
88+ } ,
89+ } ) ,
90+ ) ;
91+
92+ expect ( result . current . activeItems ) . toEqual ( [
93+ {
94+ ...collabItem ,
95+ detail : "From thread-parent → Atlas [reviewer]" ,
96+ output : "Investigate the issue\n\nAtlas [reviewer]: completed" ,
97+ collabReceiver : {
98+ threadId : "thread-child" ,
99+ nickname : "Atlas" ,
100+ role : "reviewer" ,
101+ } ,
102+ collabReceivers : [
103+ {
104+ threadId : "thread-child" ,
105+ nickname : "Atlas" ,
106+ role : "reviewer" ,
107+ } ,
108+ ] ,
109+ collabStatuses : [
110+ {
111+ threadId : "thread-child" ,
112+ nickname : "Atlas" ,
113+ role : "reviewer" ,
114+ status : "completed" ,
115+ } ,
116+ ] ,
117+ } ,
118+ ] ) ;
119+ } ) ;
53120} ) ;
0 commit comments