@@ -134,7 +134,7 @@ function useThreadActionExecutor(
134134
135135 inFlightThreadKeys . current . add ( key ) ;
136136 selectionHaptic ( ) ;
137- return await ( async ( ) => {
137+ const succeeded = await ( async ( ) => {
138138 if (
139139 ( action === "settle" || action === "unsettle" ) &&
140140 ! environmentSupportsSettlement ( thread . environmentId )
@@ -185,9 +185,9 @@ function useThreadActionExecutor(
185185 }
186186 onCompleted ?.( action , thread ) ;
187187 return true ;
188- } ) ( ) . finally ( ( ) => {
189- inFlightThreadKeys . current . delete ( key ) ;
190- } ) ;
188+ } ) ( ) ;
189+ inFlightThreadKeys . current . delete ( key ) ;
190+ return succeeded ;
191191 } ;
192192
193193 return executeAction ;
@@ -258,7 +258,7 @@ export function useThreadListActions(): {
258258 return false ;
259259 }
260260 snoozeInFlightThreadKeys . current . add ( key ) ;
261- return await ( async ( ) => {
261+ const succeeded = await ( async ( ) => {
262262 if ( ! environmentSupportsSnooze ( thread . environmentId ) ) {
263263 Dialog . alert (
264264 "Could not snooze thread" ,
@@ -302,9 +302,9 @@ export function useThreadListActions(): {
302302 return false ;
303303 }
304304 return true ;
305- } ) ( ) . finally ( ( ) => {
306- snoozeInFlightThreadKeys . current . delete ( key ) ;
307- } ) ;
305+ } ) ( ) ;
306+ snoozeInFlightThreadKeys . current . delete ( key ) ;
307+ return succeeded ;
308308 } ;
309309 const unsnoozeThread = async ( thread : EnvironmentThreadShell ) => {
310310 if ( ! checkThreadOperationPermission ( thread , "Could not wake thread" ) ) return false ;
@@ -313,7 +313,7 @@ export function useThreadListActions(): {
313313 return false ;
314314 }
315315 snoozeInFlightThreadKeys . current . add ( key ) ;
316- return await ( async ( ) => {
316+ const succeeded = await ( async ( ) => {
317317 if ( ! environmentSupportsSnooze ( thread . environmentId ) ) {
318318 Dialog . alert (
319319 "Could not wake thread" ,
@@ -343,9 +343,9 @@ export function useThreadListActions(): {
343343 return false ;
344344 }
345345 return true ;
346- } ) ( ) . finally ( ( ) => {
347- snoozeInFlightThreadKeys . current . delete ( key ) ;
348- } ) ;
346+ } ) ( ) ;
347+ snoozeInFlightThreadKeys . current . delete ( key ) ;
348+ return succeeded ;
349349 } ;
350350 const unsettleThread = async ( thread : EnvironmentThreadShell ) =>
351351 ( await executeAction ( "unsettle" , thread ) ) === true ;
@@ -454,7 +454,7 @@ export function useThreadListActions(): {
454454
455455 titleRegenerationInFlightThreadKeys . current . add ( key ) ;
456456 selectionHaptic ( ) ;
457- return await ( async ( ) => {
457+ const succeeded = await ( async ( ) => {
458458 const result = await updateThreadMetadata ( {
459459 environmentId : thread . environmentId ,
460460 input : { threadId : thread . id , regenerateTitle : true } ,
@@ -470,9 +470,9 @@ export function useThreadListActions(): {
470470 return false ;
471471 }
472472 return true ;
473- } ) ( ) . finally ( ( ) => {
474- titleRegenerationInFlightThreadKeys . current . delete ( key ) ;
475- } ) ;
473+ } ) ( ) ;
474+ titleRegenerationInFlightThreadKeys . current . delete ( key ) ;
475+ return succeeded ;
476476 } ;
477477 const renameThread = ( thread : EnvironmentThreadShell ) => {
478478 const commit = ( title : string ) => {
@@ -531,11 +531,9 @@ export function useThreadListActions(): {
531531 if ( section === "settled" ) {
532532 if ( ! environmentSupportsSettlement ( thread . environmentId ) ) return false ;
533533 appAtomRegistry . set ( threadDropBusyAtom , true ) ;
534- return await ( async ( ) => {
535- return await settleThread ( thread ) ;
536- } ) ( ) . finally ( ( ) => {
537- appAtomRegistry . set ( threadDropBusyAtom , false ) ;
538- } ) ;
534+ const settled = await settleThread ( thread ) ;
535+ appAtomRegistry . set ( threadDropBusyAtom , false ) ;
536+ return settled ;
539537 }
540538 const configs = appAtomRegistry . get ( environmentServerConfigsAtom ) ;
541539 const supportsReorder = ( environmentId : EnvironmentThreadShell [ "environmentId" ] ) => {
@@ -608,9 +606,8 @@ export function useThreadListActions(): {
608606 assignments,
609607 } ) ,
610608 ) ;
611- let succeeded = false ;
612609 const reorder = section === "pinned" ? reorderPinnedMutation : reorderActiveMutation ;
613- return await ( async ( ) => {
610+ const moved = await ( async ( ) => {
614611 if ( crossSection ) {
615612 if ( section === "pinned" ) {
616613 const orderKey = assignments . find (
@@ -657,13 +654,12 @@ export function useThreadListActions(): {
657654 return false ;
658655 }
659656 }
660- succeeded = true ;
661657 pending ?. complete ( ) ;
662658 return true ;
663- } ) ( ) . finally ( ( ) => {
664- if ( ! succeeded ) pending ?. cancel ( ) ;
665- appAtomRegistry . set ( threadDropBusyAtom , false ) ;
666- } ) ;
659+ } ) ( ) ;
660+ if ( ! moved ) pending ?. cancel ( ) ;
661+ appAtomRegistry . set ( threadDropBusyAtom , false ) ;
662+ return moved ;
667663 } ;
668664
669665 const confirmDeleteThread = useConfirmDeleteThread ( executeAction ) ;
0 commit comments