@devries-cameron20 / t3code Mirror · read-only / commits / caef8c3847
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 09:45 UTC

fix(composer): show local command actions while running (#32912)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Marker-bit <Marker-bit@users.noreply.github.com>

Marker-bit committed Nov 16, 2026 at 20:43 UTC caef8c3847be4580aa035279e5a7f86e89e458a5
6 files changed +97 -25
apps/mobile/src/features/threads/ThreadComposer.tsx
+28 -15
@@ -30,7 +30,6 @@ import {
30 hasProviderUsageLimits,
31 isUsageLimitsCommand,
32 } from "@t3tools/shared/usageLimits";
33 -import { parseSideChatCommand } from "@t3tools/shared/composerTrigger";
33 import { StackActions, useFocusEffect, useNavigation } from "@react-navigation/native";
34 import type { ReactNode } from "react";
35 import { useEffect, useEffectEvent, useRef, useState, type RefObject } from "react";
@@ -101,7 +100,10 @@ import { useComposerTextRole, type ScaledTextRole } from "../settings/appearance
100 import type { RemoteClientConnectionState } from "../../lib/connection";
101 import { MOBILE_TYPOGRAPHY } from "../../lib/typography";
102 import { Menu } from "../../components/ui/Menu";
104 -import type { ActiveTurnComposerAction } from "@t3tools/client-runtime/state/composer-dispatch";
103 +import {
104 + composerRunsDraftLocally,
105 + type ActiveTurnComposerAction,
106 +} from "@t3tools/client-runtime/state/composer-dispatch";
107 import type { FollowUpBehavior } from "../../lib/followUpBehavior";
108 import {
109 resolveComposerSendPresentation,
@@ -502,7 +504,11 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
504 const [previewVideo, setPreviewVideo] = useState<VideoPreviewSource | null>(null);
505 const composerOwnerKey = scopedThreadKey(props.environmentId, props.selectedThread.id);
506 const composerDraftKey = props.draftKey ?? composerOwnerKey;
505 - const { text: draftMessage, attachments: draftAttachments } = useComposerDraft(composerDraftKey);
507 + const {
508 + text: draftMessage,
509 + attachments: draftAttachments,
510 + context: draftContext,
511 + } = useComposerDraft(composerDraftKey);
512 const queuedEdit = props.queuedEdit ?? null;
513 const hasContent =
514 draftMessage.trim().length > 0 ||
@@ -534,18 +540,6 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
540 serverConfig: props.serverConfig,
541 states: uploadStates,
542 });
537 - const sendPresentation = resolveComposerSendPresentation({
538 - editingQueuedMessage: queuedEdit !== null,
539 - // A side-chat command starts a side chat; it never queues or steers the running turn.
540 - running:
541 - props.activeThreadBusy &&
542 - (props.redirectsApproval || parseSideChatCommand(draftMessage) === null),
543 - canSteer: props.canSteerActiveTurn,
544 - followUpBehavior: props.followUpBehavior,
545 - deliveryDeferred:
546 - props.connectionState !== "connected" || props.queueCount > 0 || attachmentsUploading,
547 - });
548 - const sendLabel = sendPresentation.label;
543 const currentModelSelection = props.selectedThread.modelSelection;
544 const modelUnavailable =
545 props.connectionState === "connected" &&
@@ -582,6 +576,25 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
576 props.serverConfig?.providers ?? [],
577 props.serverConfig?.usageLimitSources ?? [],
578 );
579 + const draftRunsLocally = composerRunsDraftLocally({
580 + text: draftMessage,
581 + holdsOnlyText: draftAttachments.length === 0,
582 + // A redirect's text answers its approval, so `/side` there is that text.
583 + sideChat: !props.redirectsApproval,
584 + usageLimits: usageLimitsOffered,
585 + codexFeedback: selectedProviderStatus?.driver === "codex",
586 + freshSession: props.onFreshSession !== undefined && draftContext === undefined,
587 + });
588 + const sendPresentation = resolveComposerSendPresentation({
589 + editingQueuedMessage: queuedEdit !== null,
590 + running: props.activeThreadBusy && !draftRunsLocally,
591 + canSteer: props.canSteerActiveTurn,
592 + followUpBehavior: props.followUpBehavior,
593 + deliveryDeferred:
594 + !draftRunsLocally &&
595 + (props.connectionState !== "connected" || props.queueCount > 0 || attachmentsUploading),
596 + });
597 + const sendLabel = sendPresentation.label;
598 const openUsageLimits = () => {
599 const report = collectProviderUsageLimits(
600 currentModelSelection.instanceId,
apps/mobile/src/lib/composerContext.test.ts
+1 -1
@@ -154,7 +154,7 @@ describe("mobile composer context", () => {
154 expect(restore("deleted", initial)).toBeUndefined();
155 expect(restore(source)?.records).toEqual(initial.records);
156 expect(restore("deleted")?.records ?? []).toEqual([]);
157 - expect(createComposerContextHistory()(source)?.records).toEqual([]);
157 + expect(createComposerContextHistory()(source)).toBeUndefined();
158 });
159 it("chips a model reference only once it is complete and names a known model", () => {
160 const known = new Set(["model:codex/gpt-6.1"]);
apps/mobile/src/lib/composerContext.ts
+2 -2
@@ -233,8 +233,8 @@ export function referencedComposerContext(text: string, context?: OrchestrationM
233 }
234 }
235 const records = context.records.filter((record) => ids.has(record.contextId));
236 - if (records.length === context.records.length) return context;
237 - return records.length ? { version: 1 as const, records } : undefined;
236 + if (records.length === 0) return undefined;
237 + return records.length === context.records.length ? context : { version: 1 as const, records };
238 }
239
240 /** Uploads change attachment ids; keep context bindings attached to the same ordered file. */
apps/web/src/components/chat/ChatComposer.tsx
+18 -6
@@ -53,7 +53,7 @@ import * as Schema from "effect/Schema";
53 import { formatComposerModelMention } from "@t3tools/client-runtime/composer-model-mentions";
54 import { isPasteAsTextShortcut } from "@t3tools/client-runtime/text-paste";
55 import { scopedThreadKey, scopeThreadRef } from "@t3tools/client-runtime/environment";
56 -import { parseSideChatCommand, serializeComposerFileLink } from "@t3tools/shared/composerTrigger";
56 +import { serializeComposerFileLink } from "@t3tools/shared/composerTrigger";
57 import { type FolderDropTarget, folderDropTarget, resolveDroppedFolderPath } from "./folderDrop";
58 import { splitTransferredFiles } from "./workspaceFileDrop";
59 import { createModelSelection, normalizeModelSlug } from "@t3tools/shared/model";
@@ -253,6 +253,7 @@ import { type ComposerPromptHistoryPosition } from "./composerPromptHistory";
253 import { usePendingUserInputDraft } from "./usePendingThreadRequests";
254 import type { PendingApproval, PendingUserInput, TimelineEntry } from "../../session-logic";
255 import {
256 + composerRunsDraftLocally,
257 resolveComposerDispatchMode,
258 type ComposerDispatchMode,
259 } from "@t3tools/client-runtime/state/composer-dispatch";
@@ -2489,6 +2490,21 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
2490 // An open question owns the space above the composer. Only a machine problem,
2491 // which is why an answer could not go through, stays beside it.
2492 const replyTo = composerDraft?.replyTo ?? null;
2493 + const draftRunsLocally = composerRunsDraftLocally({
2494 + text: prompt,
2495 + holdsOnlyText:
2496 + composerImages.length + composerFiles.length === 0 &&
2497 + composerSendState.sendableTerminalContexts.length === 0 &&
2498 + composerPreviewAnnotations.length === 0 &&
2499 + composerReviewComments.length === 0 &&
2500 + composerThreadContexts.length === 0 &&
2501 + composerEnvironmentContexts.length === 0 &&
2502 + replyTo === null,
2503 + sideChat: props.sideChatAvailable === true || (props.sideChatDisabledReason ?? null) !== null,
2504 + usageLimits: props.onUsageLimitsCommand !== undefined,
2505 + codexFeedback: selectedProvider === "codex" && multipleModelSelections === null,
2506 + freshSession: props.onFreshSession !== undefined,
2507 + });
2508 const replyBannerItems: readonly ComposerBannerStackItem[] = replyTo
2509 ? [
2510 {
@@ -3737,11 +3753,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
3753 compact={isComposerPrimaryActionsCompact}
3754 canOperateThread={canOperateThread}
3755 pendingAction={pendingPrimaryAction}
3740 - // A side-chat command starts a side chat; it never queues or steers the turn.
3741 - isRunning={
3742 - (phase === "running" || phase === "connecting") &&
3743 - !(props.sideChatAvailable === true && parseSideChatCommand(prompt) !== null)
3744 - }
3756 + isRunning={(phase === "running" || phase === "connecting") && !draftRunsLocally}
3757 canInterrupt={canInterrupt}
3758 runId={activeThread?.runtime?.activeRunId ?? null}
3759 followUpBehavior={followUpBehavior}
packages/client-runtime/src/state/composerDispatch.test.ts
+25 -1
@@ -1,6 +1,6 @@
1 import { expect, it } from "vite-plus/test";
2
3 -import { compactionBlocksSteering } from "./composerDispatch.ts";
3 +import { compactionBlocksSteering, composerRunsDraftLocally } from "./composerDispatch.ts";
4
5 it("blocks steering for explicit compaction, and for automatic compaction unless the provider takes steers then", () => {
6 const during = (
@@ -47,3 +47,27 @@ it("blocks steering for explicit compaction, and for automatic compaction unless
47 }),
48 ).toBe(false);
49 });
50 +
51 +it("treats only the commands the composer runs itself as local", () => {
52 + const none = {
53 + holdsOnlyText: true,
54 + sideChat: false,
55 + usageLimits: false,
56 + codexFeedback: false,
57 + freshSession: false,
58 + };
59 + const all = {
60 + ...none,
61 + sideChat: true,
62 + usageLimits: true,
63 + codexFeedback: true,
64 + freshSession: true,
65 + };
66 + for (const text of ["/btw why?", "/usage-limits", "/feedback slow", "/clear"]) {
67 + expect(composerRunsDraftLocally({ ...all, text })).toBe(true);
68 + expect(composerRunsDraftLocally({ ...none, text })).toBe(false);
69 + }
70 + expect(composerRunsDraftLocally({ ...all, text: "fix the bug" })).toBe(false);
71 + expect(composerRunsDraftLocally({ ...all, holdsOnlyText: false, text: "/clear" })).toBe(false);
72 + expect(composerRunsDraftLocally({ ...all, holdsOnlyText: false, text: "/side why?" })).toBe(true);
73 +});
packages/client-runtime/src/state/composerDispatch.ts
+23
@@ -1,3 +1,8 @@
1 +import { isClearComposerCommand, parseSideChatCommand } from "@t3tools/shared/composerTrigger";
2 +import { isUsageLimitsCommand } from "@t3tools/shared/usageLimits";
3 +
4 +import { parseCodexFeedbackCommand } from "./threadFeedback.ts";
5 +
6 export type ComposerDispatchMode = "auto" | "queue" | "steer" | "restart";
7 export type ActiveTurnComposerAction = Exclude<ComposerDispatchMode, "auto">;
8
@@ -49,3 +54,21 @@ export function alternateComposerDispatchAction(
54 ...(activeTurnDefault === undefined ? {} : { activeTurnDefault }),
55 }) as ActiveTurnComposerAction;
56 }
57 +
58 +/** The composer runs these drafts itself, so they never queue for or steer a running turn. */
59 +export function composerRunsDraftLocally(input: {
60 + readonly text: string;
61 + readonly holdsOnlyText: boolean;
62 + readonly sideChat: boolean;
63 + readonly usageLimits: boolean;
64 + readonly codexFeedback: boolean;
65 + readonly freshSession: boolean;
66 +}): boolean {
67 + if (input.sideChat && parseSideChatCommand(input.text) !== null) return true;
68 + if (!input.holdsOnlyText) return false;
69 + return (
70 + (input.usageLimits && isUsageLimitsCommand(input.text)) ||
71 + (input.codexFeedback && parseCodexFeedbackCommand(input.text) !== null) ||
72 + (input.freshSession && isClearComposerCommand(input.text))
73 + );
74 +}