fix(mobile): steer active turns by default (#6543)

This commit is contained in:
Chris Deeming authored and GitHub committed 2026-08-14 13:35:10 +02:00
1 parent 038560e580
commit 184d8ef33b
7 files changed
+27 -27

No files matched your search

@@ -105,7 +105,6 @@ export interface ThreadComposerProps {
readonly selectedThread: OrchestrationThreadShell;
readonly serverConfig: T3ServerConfig | null;
readonly queueCount: number;
readonly activeThreadBusy: boolean;
readonly environmentId: EnvironmentId;
readonly projectCwd: string | null;
readonly editorRef?: RefObject<ComposerEditorHandle | null>;
@@ -327,9 +326,7 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
props.selectedThread.session?.status === "starting";
const sendLabel =
props.connectionState !== "connected" || props.activeThreadBusy || props.queueCount > 0
? "Queue"
: "Send";
props.connectionState !== "connected" || props.queueCount > 0 ? "Queue" : "Send";
const currentModelSelection = props.selectedThread.modelSelection;
const currentRuntimeMode = props.selectedThread.runtimeMode;
const connectionStatus = composerConnectionStatus({
@@ -101,7 +101,6 @@ export interface ThreadDetailScreenProps {
readonly threadSyncStatus?: EnvironmentThreadStatus;
/** Non-null when older turns exist beyond the loaded window. */
readonly loadEarlier?: { readonly loading: boolean; readonly onLoadEarlier: () => void } | null;
readonly activeThreadBusy: boolean;
readonly environmentId: EnvironmentId;
readonly projectWorkspaceRoot: string | null;
readonly threadCwd: string | null;
@@ -727,7 +726,6 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
selectedThread={props.selectedThread}
serverConfig={props.serverConfig}
queueCount={props.selectedThreadQueueCount}
activeThreadBusy={props.activeThreadBusy}
environmentId={props.environmentId}
projectCwd={props.projectWorkspaceRoot}
bottomInset={composerBottomInset}
@@ -785,7 +785,6 @@ function ThreadRouteContent(
connectionStateLabel={routeConnectionState}
threadSyncStatus={selectedThreadDetailState.status}
loadEarlier={loadEarlierTurns}
activeThreadBusy={composer.activeThreadBusy}
environmentId={selectedThread.environmentId}
projectWorkspaceRoot={selectedThreadProject?.workspaceRoot ?? null}
threadCwd={selectedThreadCwd}
+1 -1
View File
@@ -169,7 +169,7 @@ export function resolveThreadOutboxDeliveryAction(input: {
if (!input.threadExists) {
return input.shellStatus === "live" ? "remove" : "wait";
}
return input.environmentConnected && !input.threadBusy ? "send" : "wait";
return input.environmentConnected ? "send" : "wait";
}
/**
@@ -487,6 +487,27 @@ describe("thread outbox", () => {
).toBe("send");
});
it("sends existing-thread messages whenever connected so queued messages can steer", () => {
expect(
resolveThreadOutboxDeliveryAction({
isCreation: false,
threadExists: true,
shellStatus: "live",
environmentConnected: true,
threadBusy: true,
}),
).toBe("send");
expect(
resolveThreadOutboxDeliveryAction({
isCreation: false,
threadExists: true,
shellStatus: "live",
environmentConnected: false,
threadBusy: true,
}),
).toBe("wait");
});
it("sends queued creations once connected and live, removing already-created ones", () => {
expect(
resolveThreadOutboxDeliveryAction({
@@ -129,10 +129,6 @@ export function useThreadComposerState() {
);
}, [selectedThreadDetail, selectedThreadSessionActivity, selectedThreadShell]);
const activeThreadBusy =
!!selectedThread &&
(selectedThread.session?.status === "running" || selectedThread.session?.status === "starting");
const onSendMessage = useCallback(async () => {
if (!selectedThreadShell) {
return null;
@@ -308,7 +304,6 @@ export function useThreadComposerState() {
modelSelection,
runtimeMode,
interactionMode,
activeThreadBusy,
onChangeDraftMessage,
onPickDraftImages,
onPasteIntoDraft,
@@ -37,7 +37,7 @@ import {
type QueuedThreadMessage,
type ThreadOutboxCommandStage,
} from "./thread-outbox-model";
import { environmentThreadShells, threadEnvironment } from "./threads";
import { threadEnvironment } from "./threads";
import { useAtomCommand } from "./use-atom-command";
import {
editingQueuedMessageIdsAtom,
@@ -362,22 +362,12 @@ export function useThreadOutboxDrain(): void {
return true;
}
// The guards evaluated before the confirmation await are stale by now:
// the thread may have gone busy, or the user may have opened this
// message in the editor. Re-read both and defer to the next drain pass
// (returning true skips the failure/backoff path) rather than sending
// a payload the user is editing or racing an active turn.
// the user may have opened this message in the editor. Re-read that
// guard and defer to the next drain pass (returning true skips the
// failure/backoff path) rather than sending a payload being edited.
if (appAtomRegistry.get(editingQueuedMessageIdsAtom)[nextQueuedMessage.messageId]) {
return true;
}
const freshThread = findThread(
appAtomRegistry.get(environmentThreadShells.threadShellsAtom),
nextQueuedMessage,
);
const freshThreadBusy =
freshThread?.session?.status === "running" || freshThread?.session?.status === "starting";
if (deliveryAction === "send" && creation === undefined && freshThreadBusy) {
return true;
}
return deliveryAction === "remove"
? removeQueuedMessage("[thread-outbox] failed to remove message for a missing thread")
: creation !== undefined