@@ -15,19 +15,19 @@ import type { SendMessageError } from "@/common/types/errors";
1515import { Err , Ok , type Result } from "@/common/types/result" ;
1616import assert from "@/common/utils/assert" ;
1717
18- type SendMessageCall = {
18+ interface SendMessageCall {
1919 workspaceId : string ;
2020 message : string ;
2121 options : SendMessageOptions | undefined ;
22- } ;
22+ }
2323
24- type CreateCall = {
24+ interface CreateCall {
2525 projectPath : string ;
2626 branchName : string ;
2727 trunkBranch : string | undefined ;
2828 title : string | undefined ;
2929 runtimeConfig : RuntimeConfig | undefined ;
30- } ;
30+ }
3131
3232class FakeAIService extends EventEmitter {
3333 private readonly streaming = new Set < string > ( ) ;
@@ -49,11 +49,9 @@ class FakeAIService extends EventEmitter {
4949 this . metadataById . set ( metadata . id , metadata ) ;
5050 }
5151
52- async getWorkspaceMetadata (
53- workspaceId : string
54- ) : Promise < Result < FrontendWorkspaceMetadata , string > > {
52+ getWorkspaceMetadata ( workspaceId : string ) : Promise < Result < FrontendWorkspaceMetadata , string > > {
5553 const metadata = this . metadataById . get ( workspaceId ) ;
56- return metadata ? Ok ( metadata ) : Err ( `Workspace ${ workspaceId } not found` ) ;
54+ return Promise . resolve ( metadata ? Ok ( metadata ) : Err ( `Workspace ${ workspaceId } not found` ) ) ;
5755 }
5856}
5957
@@ -96,7 +94,7 @@ class FakeConfig {
9694 return this . taskStateById . get ( workspaceId ) ;
9795 }
9896
99- async setWorkspaceTaskState ( workspaceId : string , taskState : TaskState ) : Promise < void > {
97+ setWorkspaceTaskState ( workspaceId : string , taskState : TaskState ) : Promise < void > {
10098 this . taskStateById . set ( workspaceId , taskState ) ;
10199
102100 const existing = this . metadataById . get ( workspaceId ) ;
@@ -108,6 +106,7 @@ class FakeConfig {
108106 taskState,
109107 } ) ;
110108 }
109+ return Promise . resolve ( ) ;
111110 }
112111
113112 countRunningAgentTasks ( ) : number {
@@ -156,8 +155,8 @@ class FakeConfig {
156155 return result ;
157156 }
158157
159- async getAllWorkspaceMetadata ( ) : Promise < FrontendWorkspaceMetadata [ ] > {
160- return [ ...this . metadataById . values ( ) ] ;
158+ getAllWorkspaceMetadata ( ) : Promise < FrontendWorkspaceMetadata [ ] > {
159+ return Promise . resolve ( [ ...this . metadataById . values ( ) ] ) ;
161160 }
162161}
163162
@@ -168,13 +167,13 @@ class FakePartialService {
168167 this . partialByWorkspaceId . set ( workspaceId , partial ) ;
169168 }
170169
171- async readPartial ( workspaceId : string ) : Promise < MuxMessage | null > {
172- return this . partialByWorkspaceId . get ( workspaceId ) ?? null ;
170+ readPartial ( workspaceId : string ) : Promise < MuxMessage | null > {
171+ return Promise . resolve ( this . partialByWorkspaceId . get ( workspaceId ) ?? null ) ;
173172 }
174173
175- async writePartial ( workspaceId : string , msg : MuxMessage ) : Promise < Result < void , string > > {
174+ writePartial ( workspaceId : string , msg : MuxMessage ) : Promise < Result < void , string > > {
176175 this . partialByWorkspaceId . set ( workspaceId , msg ) ;
177- return Ok ( undefined ) ;
176+ return Promise . resolve ( Ok ( undefined ) ) ;
178177 }
179178}
180179
@@ -185,29 +184,31 @@ class FakeHistoryService {
185184 this . historyByWorkspaceId . set ( workspaceId , history ) ;
186185 }
187186
188- async getHistory ( workspaceId : string ) : Promise < Result < MuxMessage [ ] , string > > {
189- return Ok ( this . historyByWorkspaceId . get ( workspaceId ) ?? [ ] ) ;
187+ getHistory ( workspaceId : string ) : Promise < Result < MuxMessage [ ] , string > > {
188+ return Promise . resolve ( Ok ( this . historyByWorkspaceId . get ( workspaceId ) ?? [ ] ) ) ;
190189 }
191190
192- async updateHistory ( workspaceId : string , msg : MuxMessage ) : Promise < Result < void , string > > {
191+ updateHistory ( workspaceId : string , msg : MuxMessage ) : Promise < Result < void , string > > {
193192 const existing = this . historyByWorkspaceId . get ( workspaceId ) ?? [ ] ;
194193 const idx = existing . findIndex ( ( m ) => m . id === msg . id ) ;
195194 if ( idx === - 1 ) {
196- return Err ( `Message ${ msg . id } not found` ) ;
195+ return Promise . resolve ( Err ( `Message ${ msg . id } not found` ) ) ;
197196 }
198197 const updated = [ ...existing ] ;
199198 updated [ idx ] = msg ;
200199 this . historyByWorkspaceId . set ( workspaceId , updated ) ;
201- return Ok ( undefined ) ;
200+ return Promise . resolve ( Ok ( undefined ) ) ;
202201 }
203202}
204203
205204class FakeWorkspaceService {
206205 private nextWorkspaceId = 1 ;
207206 readonly createCalls : CreateCall [ ] = [ ] ;
208207 readonly sendMessageCalls : SendMessageCall [ ] = [ ] ;
209- readonly resumeStreamCalls : Array < { workspaceId : string ; options : SendMessageOptions | undefined } > =
210- [ ] ;
208+ readonly resumeStreamCalls : Array < {
209+ workspaceId : string ;
210+ options : SendMessageOptions | undefined ;
211+ } > = [ ] ;
211212 readonly removedWorkspaceIds : string [ ] = [ ] ;
212213 readonly appendedMessages : Array < { workspaceId : string ; message : MuxMessage } > = [ ] ;
213214
@@ -218,7 +219,7 @@ class FakeWorkspaceService {
218219 private readonly aiService : FakeAIService
219220 ) { }
220221
221- async create (
222+ create (
222223 projectPath : string ,
223224 branchName : string ,
224225 trunkBranch : string | undefined ,
@@ -240,38 +241,38 @@ class FakeWorkspaceService {
240241 this . config . addWorkspace ( metadata , metadata . namedWorkspacePath ) ;
241242 this . aiService . setWorkspaceMetadata ( metadata ) ;
242243
243- return Ok ( { metadata } ) ;
244+ return Promise . resolve ( Ok ( { metadata } ) ) ;
244245 }
245246
246- async sendMessage (
247+ sendMessage (
247248 workspaceId : string ,
248249 message : string ,
249250 options : SendMessageOptions | undefined = undefined
250251 ) : Promise < Result < void , SendMessageError > > {
251252 this . sendMessageCalls . push ( { workspaceId, message, options } ) ;
252- return this . sendMessageResult ;
253+ return Promise . resolve ( this . sendMessageResult ) ;
253254 }
254255
255- async resumeStream (
256+ resumeStream (
256257 workspaceId : string ,
257258 options : SendMessageOptions | undefined = undefined
258259 ) : Promise < Result < void , SendMessageError > > {
259260 this . resumeStreamCalls . push ( { workspaceId, options } ) ;
260- return Ok ( undefined ) ;
261+ return Promise . resolve ( Ok ( undefined ) ) ;
261262 }
262263
263- async remove ( workspaceId : string ) : Promise < Result < void , string > > {
264+ remove ( workspaceId : string ) : Promise < Result < void , string > > {
264265 this . removedWorkspaceIds . push ( workspaceId ) ;
265266 this . config . removeWorkspace ( workspaceId ) ;
266- return Ok ( undefined ) ;
267+ return Promise . resolve ( Ok ( undefined ) ) ;
267268 }
268269
269- async appendToHistoryAndEmit (
270+ appendToHistoryAndEmit (
270271 workspaceId : string ,
271272 muxMessage : MuxMessage
272273 ) : Promise < Result < void , string > > {
273274 this . appendedMessages . push ( { workspaceId, message : muxMessage } ) ;
274- return Ok ( undefined ) ;
275+ return Promise . resolve ( Ok ( undefined ) ) ;
275276 }
276277}
277278
@@ -346,7 +347,7 @@ describe("TaskService", () => {
346347 globalThis . setTimeout = realSetTimeout ;
347348 } ) ;
348349
349- it ( "throws if parent workspace not found" , async ( ) => {
350+ it ( "throws if parent workspace not found" , ( ) => {
350351 const config = new FakeConfig ( ) ;
351352 const aiService = new FakeAIService ( ) ;
352353 const workspaceService = new FakeWorkspaceService ( config , aiService ) ;
@@ -361,7 +362,7 @@ describe("TaskService", () => {
361362 aiService as unknown as AIService
362363 ) ;
363364
364- await expect (
365+ return expect (
365366 taskService . createTask ( {
366367 parentWorkspaceId : "missing" ,
367368 agentType : "research" ,
@@ -371,7 +372,7 @@ describe("TaskService", () => {
371372 ) . rejects . toThrow ( "Parent workspace missing not found" ) ;
372373 } ) ;
373374
374- it ( "enforces maxTaskNestingDepth" , async ( ) => {
375+ it ( "enforces maxTaskNestingDepth" , ( ) => {
375376 const config = new FakeConfig ( ) ;
376377 config . setTaskSettings ( { maxTaskNestingDepth : 1 } ) ;
377378
@@ -395,7 +396,7 @@ describe("TaskService", () => {
395396 aiService as unknown as AIService
396397 ) ;
397398
398- await expect (
399+ return expect (
399400 taskService . createTask ( {
400401 parentWorkspaceId : "child" ,
401402 agentType : "research" ,
@@ -565,7 +566,7 @@ describe("TaskService", () => {
565566 const taskPart = parentPartialAfter . parts . find (
566567 ( p ) => p . type === "dynamic-tool" && p . toolName === "task" && p . toolCallId === "call_1"
567568 ) ;
568- assert ( taskPart && taskPart . type === "dynamic-tool" , "expected dynamic tool part" ) ;
569+ assert ( taskPart ? .type === "dynamic-tool" , "expected dynamic tool part" ) ;
569570 expect ( taskPart . state ) . toBe ( "output-available" ) ;
570571
571572 // Synthetic tool-call-end for the task tool should be emitted for UI update.
0 commit comments