Skip to content

Commit 72f94b5

Browse files
fix(mobile): save the selected modes before continuing a thread
A turn on an existing thread runs with the thread's saved runtime and interaction modes, so set them first when they changed, like web's resume and mobile's own send path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8139b18 commit 72f94b5

1 file changed

Lines changed: 36 additions & 2 deletions

File tree

‎apps/mobile/src/features/threads/ThreadRouteScreen.tsx‎

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,14 @@ function ThreadRouteContent(
399399
label: "continue thread",
400400
reportFailure: false,
401401
});
402+
const setThreadRuntimeMode = useAtomCommand(threadEnvironment.setRuntimeMode, {
403+
label: "set thread runtime mode",
404+
reportFailure: false,
405+
});
406+
const setThreadInteractionMode = useAtomCommand(threadEnvironment.setInteractionMode, {
407+
label: "set thread interaction mode",
408+
reportFailure: false,
409+
});
402410
const loadEarlierHistory = useAtomCommand(threadEnvironment.loadEarlierHistory, {
403411
label: "load earlier thread history",
404412
reportFailure: false,
@@ -715,6 +723,32 @@ function ThreadRouteContent(
715723
};
716724
// The server holds the queue behind a stopped or usage-limited run until that run is continued.
717725
if (composer.resumableRunId !== null) {
726+
const runtimeMode = composer.runtimeMode ?? selectedThread.runtimeMode;
727+
const interactionMode = composer.interactionMode ?? selectedThread.interactionMode;
728+
const createdAt = new Date().toISOString();
729+
// A turn on an existing thread runs with the thread's saved modes, not the turn's.
730+
if (
731+
runtimeMode !== selectedThread.runtimeMode &&
732+
failed(
733+
await setThreadRuntimeMode({
734+
environmentId: selectedThread.environmentId,
735+
input: { threadId: selectedThread.id, runtimeMode, createdAt },
736+
}),
737+
)
738+
) {
739+
return;
740+
}
741+
if (
742+
interactionMode !== selectedThread.interactionMode &&
743+
failed(
744+
await setThreadInteractionMode({
745+
environmentId: selectedThread.environmentId,
746+
input: { threadId: selectedThread.id, interactionMode, createdAt },
747+
}),
748+
)
749+
) {
750+
return;
751+
}
718752
const continued = await continueThreadRun({
719753
environmentId: selectedThread.environmentId,
720754
input: {
@@ -728,8 +762,8 @@ function ThreadRouteContent(
728762
text: "Continue where you left off.",
729763
attachments: [],
730764
},
731-
runtimeMode: composer.runtimeMode ?? selectedThread.runtimeMode,
732-
interactionMode: composer.interactionMode ?? selectedThread.interactionMode,
765+
runtimeMode,
766+
interactionMode,
733767
dispatchMode: "start",
734768
},
735769
});

0 commit comments

Comments
 (0)