@@ -25,7 +25,6 @@ import {
2525 type ModelSelection ,
2626 type PreviewAnnotationPayload ,
2727 type ThreadId ,
28- type RunId ,
2928 ProviderInteractionMode ,
3029 RuntimeMode ,
3130} from "@t3tools/contracts" ;
@@ -44,7 +43,7 @@ import {
4443} from "@t3tools/client-runtime/environment" ;
4544import { createModelSelection } from "@t3tools/shared/model" ;
4645import { truncate } from "@t3tools/shared/String" ;
47- import { type SetStateAction , useLayoutEffect , useRef , useState } from "react" ;
46+ import { type SetStateAction , useLayoutEffect , useRef } from "react" ;
4847import { flushSync } from "react-dom" ;
4948import { useNavigate } from "@tanstack/react-router" ;
5049import {
@@ -162,12 +161,9 @@ interface ComposerSendInput {
162161 readonly isServerThread : boolean ;
163162 readonly isLocalDraftThread : boolean ;
164163 readonly isGitRepo : boolean ;
165- readonly hasHeldQueuedRuns : boolean ;
166- readonly resumableRunId : RunId | null ;
167164 readonly phase : SessionPhase ;
168165 readonly runtimeMode : RuntimeMode ;
169166 readonly defaultRuntimeMode : RuntimeMode ;
170- readonly interactionMode : ProviderInteractionMode ;
171167 readonly sendEnvMode : DraftThreadEnvMode ;
172168 readonly startFromOrigin : boolean ;
173169 readonly localCheckoutBranchMismatch : {
@@ -230,7 +226,6 @@ interface ComposerSendInput {
230226 ) => void ;
231227 readonly setThreadError : ReturnType < typeof makeThreadErrorSetter > ;
232228 readonly setKeepFullHistory : ( threadKey : string , keep : boolean ) => void ;
233- readonly scrollToEnd : TimelineFollow [ "scrollToEnd" ] ;
234229 readonly anchorNewTurn : TimelineFollow [ "anchorNewTurn" ] ;
235230 readonly acknowledgeActiveThreadWoke : ( ) => void ;
236231 readonly handleInteractionModeChange : ( mode : ProviderInteractionMode ) => void ;
@@ -267,12 +262,9 @@ export function useComposerSend(input: ComposerSendInput) {
267262 isServerThread,
268263 isLocalDraftThread,
269264 isGitRepo,
270- hasHeldQueuedRuns,
271- resumableRunId,
272265 phase,
273266 runtimeMode,
274267 defaultRuntimeMode,
275- interactionMode,
276268 sendEnvMode,
277269 startFromOrigin,
278270 localCheckoutBranchMismatch,
@@ -328,7 +320,6 @@ export function useComposerSend(input: ComposerSendInput) {
328320 setMultipleModelSelections,
329321 setThreadError,
330322 setKeepFullHistory,
331- scrollToEnd,
332323 anchorNewTurn,
333324 acknowledgeActiveThreadWoke,
334325 handleInteractionModeChange,
@@ -342,9 +333,6 @@ export function useComposerSend(input: ComposerSendInput) {
342333 const startThreadTurn = useOrchestrationCommand ( threadEnvironment . startTurn , {
343334 reportFailure : false ,
344335 } ) ;
345- const resumeThreadQueue = useOrchestrationCommand ( threadEnvironment . resumeThreadQueue , {
346- reportFailure : false ,
347- } ) ;
348336 const uploadThreadFeedback = useOrchestrationCommand ( threadEnvironment . uploadFeedback , {
349337 reportFailure : false ,
350338 } ) ;
@@ -365,10 +353,6 @@ export function useComposerSend(input: ComposerSendInput) {
365353 const readMultipleModelSelections = ( ) => appAtomRegistry . get ( fanoutSelectionsAtom ) ;
366354 const { sendInFlight : sendInFlightRef , uncertainSubmissions : uncertainMultipleSubmissionsRef } =
367355 draftSendState ( routeThreadKey ) ;
368- const [ resumingThreadKeys , setResumingThreadKeys ] = useState < ReadonlySet < string > > (
369- ( ) => new Set ( ) ,
370- ) ;
371- const isResuming = resumingThreadKeys . has ( routeThreadKey ) ;
372356 const composerSendGenerationRef = useRef ( 0 ) ;
373357 const environmentUnavailableSendToastSlotRef = useRef ( 0 ) ;
374358 // A send awaits uploads before it declines, so it reads the approvals pending by then.
@@ -379,83 +363,6 @@ export function useComposerSend(input: ComposerSendInput) {
379363 respondingRequestIdsRef . current = respondingRequestIds ;
380364 } , [ pendingApprovals , respondingRequestIds ] ) ;
381365
382- const onResume = async ( ) => {
383- if (
384- ! activeThread ||
385- ( resumableRunId === null && ! hasHeldQueuedRuns ) ||
386- isSendBusy ||
387- isResuming ||
388- isConnecting ||
389- isRevertingCheckpoint ||
390- threadDetailLoading ||
391- activeEnvironmentUnavailable ||
392- sendInFlightRef . current
393- ) {
394- return ;
395- }
396- const threadId = activeThread . id ;
397- sendInFlightRef . current = true ;
398- setResumingThreadKeys ( ( current ) => new Set ( current ) . add ( routeThreadKey ) ) ;
399- setThreadError ( threadId , null ) ;
400- // Commands settle into a result, so this always runs.
401- const resume = async ( ) => {
402- if ( resumableRunId === null ) {
403- return resumeThreadQueue ( { environmentId, input : { threadId } } ) ;
404- }
405- const createdAt = new Date ( ) . toISOString ( ) ;
406- const settingsResult = await persistThreadSettingsForNextTurn ( {
407- threadId,
408- createdAt,
409- ...( localCheckoutBranchMismatch
410- ? { branch : localCheckoutBranchMismatch . currentBranch }
411- : { } ) ,
412- runtimeMode,
413- interactionMode,
414- } ) ;
415- if ( settingsResult . _tag === "Failure" ) return settingsResult ;
416- const modelSelection = composerRef . current ?. getSendContext ( ) . selectedModelSelection ;
417- const turnResult = await startThreadTurn ( {
418- environmentId,
419- input : {
420- threadId,
421- manualContinuationOfRunId : resumableRunId ,
422- ...( modelSelection ? { modelSelection } : { } ) ,
423- message : {
424- messageId : newMessageId ( ) ,
425- role : "user" ,
426- text : "Continue where you left off." ,
427- attachments : [ ] ,
428- } ,
429- runtimeMode,
430- interactionMode,
431- dispatchMode : "start" ,
432- } ,
433- } ) ;
434- if ( turnResult . _tag === "Failure" || ! hasHeldQueuedRuns ) return turnResult ;
435- clearUsageLimitsFor ( routeThreadKey ) ;
436- return resumeThreadQueue ( { environmentId, input : { threadId } } ) ;
437- } ;
438- const result = await resume ( ) ;
439- if ( result . _tag === "Failure" ) {
440- if ( ! isAtomCommandInterrupted ( result ) ) {
441- const error = squashAtomCommandFailure ( result ) ;
442- setThreadError (
443- threadId ,
444- error instanceof Error ? error . message : "Could not resume thread." ,
445- ) ;
446- }
447- } else {
448- clearUsageLimitsFor ( routeThreadKey ) ;
449- if ( currentRouteThreadKeyRef . current === routeThreadKey ) scrollToEnd ( ) ;
450- }
451- sendInFlightRef . current = false ;
452- setResumingThreadKeys ( ( current ) => {
453- const next = new Set ( current ) ;
454- next . delete ( routeThreadKey ) ;
455- return next ;
456- } ) ;
457- } ;
458-
459366 const onSend = async (
460367 e ?: { preventDefault : ( ) => void } ,
461368 dispatchMode : ComposerDispatchMode = "auto" ,
@@ -1912,5 +1819,5 @@ export function useComposerSend(input: ComposerSendInput) {
19121819 finish ( ) ;
19131820 } ;
19141821
1915- return { onSend, onResume , onImplementPlanInNewThread, isResuming } ;
1822+ return { onSend, onImplementPlanInNewThread } ;
19161823}
0 commit comments