@@ -9,18 +9,8 @@ import {
99 isAtomCommandInterrupted ,
1010 squashAtomCommandFailure ,
1111} from "@t3tools/client-runtime/state/runtime" ;
12- import {
13- deriveResumableRunId ,
14- deriveThreadStructureRuntime ,
15- } from "@t3tools/client-runtime/state/thread-execution" ;
1612import { resolveUserMessagePresentation } from "@t3tools/client-runtime/user-message" ;
17- import {
18- type ChatAttachment ,
19- type EnvironmentId ,
20- MessageId ,
21- type RunId ,
22- type ThreadId ,
23- } from "@t3tools/contracts" ;
13+ import type { ChatAttachment , EnvironmentId , RunId , ThreadId } from "@t3tools/contracts" ;
2414import { Atom } from "effect/reactivity" ;
2515import { Image } from "expo-image" ;
2616import * as Haptics from "expo-haptics" ;
@@ -41,7 +31,6 @@ import { SymbolView } from "../../components/ui/AppSymbol";
4131import { Menu } from "../../components/ui/Menu" ;
4232import { ScreenContent } from "../../components/ui/ScreenContent" ;
4333import { scopedThreadKey } from "../../lib/scopedEntities" ;
44- import { uuidv4 } from "../../lib/uuid" ;
4534import { useAssetUrl } from "../../state/assets" ;
4635import { useQuietThreadShell } from "../../state/entities" ;
4736import { useEnvironmentQuery } from "../../state/query" ;
@@ -55,7 +44,6 @@ import {
5544 buildCancelQueuedRunCommand ,
5645 resolveThreadQueueRowControls ,
5746} from "./threadQueueControlPresentation" ;
58- import { resumeThread } from "./resume-thread" ;
5947
6048const REMOVE_ACTION_WIDTH = 76 ;
6149const THUMBNAIL_LIMIT = 3 ;
@@ -149,23 +137,10 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
149137 const promote = useAtomCommand ( threadEnvironment . promoteQueuedRun , "promote queued message" ) ;
150138 const cancel = useAtomCommand ( threadEnvironment . cancelQueuedRun , "remove queued message" ) ;
151139 const resume = useAtomCommand ( threadEnvironment . resumeThreadQueue , "resume queue" ) ;
152- const continueRun = useAtomCommand ( threadEnvironment . startTurn , {
153- label : "continue thread" ,
154- reportFailure : false ,
155- } ) ;
156- const setRuntimeMode = useAtomCommand ( threadEnvironment . setRuntimeMode , {
157- label : "set thread runtime mode" ,
158- reportFailure : false ,
159- } ) ;
160- const setInteractionMode = useAtomCommand ( threadEnvironment . setInteractionMode , {
161- label : "set thread interaction mode" ,
162- reportFailure : false ,
163- } ) ;
164140 const resumeHeldQueue = useAtomCommand ( threadEnvironment . resumeThreadQueue , {
165141 label : "resume queue" ,
166142 reportFailure : false ,
167143 } ) ;
168- const quietThread = useAtomValue ( environmentThreadDetails . quietThreadAtom ( target ) ) ;
169144 const [ resuming , setResuming ] = useState ( false ) ;
170145 const [ busyRunId , setBusyRunId ] = useState < RunId | null > ( null ) ;
171146 const busyRef = useRef ( false ) ;
@@ -251,41 +226,13 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
251226 if ( busyRef . current ) return ;
252227 busyRef . current = true ;
253228 setResuming ( true ) ;
254- const resumableRunId = quietThread
255- ? deriveResumableRunId (
256- quietThread . projection ,
257- deriveThreadStructureRuntime ( quietThread . projection ) ,
258- )
259- : null ;
260- // Only a usage-limited run holds queue.resume; a stopped run's queue resumes as is.
261- const limitedRunId =
262- quietThread ?. projection . runs . find ( ( run ) => run . id === resumableRunId ) ?. status ===
263- "failed"
264- ? resumableRunId
265- : null ;
266- const result = quietThread
267- ? await resumeThread ( {
268- thread : {
269- environmentId : target . environmentId ,
270- id : target . threadId ,
271- runtimeMode : quietThread . projection . thread . runtimeMode ,
272- interactionMode : quietThread . projection . thread . interactionMode ,
273- } ,
274- resumableRunId : limitedRunId ,
275- queueHeld : true ,
276- runtimeMode : quietThread . projection . thread . runtimeMode ,
277- interactionMode : quietThread . projection . thread . interactionMode ,
278- modelSelection : null ,
279- messageId : MessageId . make ( uuidv4 ( ) ) ,
280- createdAt : new Date ( ) . toISOString ( ) ,
281- setRuntimeMode,
282- setInteractionMode,
283- startTurn : continueRun ,
284- resumeQueue : resumeHeldQueue ,
285- } )
286- : await resumeHeldQueue ( { ...target , input : { threadId : target . threadId } } ) ;
229+ const result = await resumeHeldQueue ( {
230+ ...target ,
231+ input : { threadId : target . threadId } ,
232+ } ) ;
287233 busyRef . current = false ;
288234 setResuming ( false ) ;
235+ // A usage limit holds the queue until the composer's Resume thread continues the run.
289236 if ( result . _tag === "Failure" && ! isAtomCommandInterrupted ( result ) ) {
290237 const error = squashAtomCommandFailure ( result ) ;
291238 Dialog . alert (
0 commit comments