@devries-cameron20 / t3code Mirror · read-only / commits / ea3767b248
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 22, 10:45 UTC

fix(web): scheduled task editor shows the destination thread (#26658)

Co-authored-by: PR Batch Tester <agent@local.test> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

shivam committed Oct 31, 2026 at 07:12 UTC ea3767b248f981a707fe97441494d086c6250992
2 files changed +60 -3
apps/web/src/components/settings/ScheduledTasksSettings.browser.test.tsx
+20 -2
@@ -6,6 +6,7 @@ import {
6 ProjectId,
7 ProviderInstanceId,
8 ScheduledTaskId,
9 + ThreadId,
10 type ScheduledTask,
11 } from "@t3tools/contracts";
12 import { describe, expect, it, vi } from "vite-plus/test";
@@ -24,7 +25,7 @@ const task: ScheduledTask = {
25 enabled: true,
26 schedule: { type: "interval", everyMs: 60_000 },
27 projectId,
27 - threadId: null,
28 + threadId: ThreadId.make("older-thread"),
29 workspaceStrategy: { type: "root" },
30 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
31 runtimeMode: "full-access",
@@ -40,6 +41,12 @@ const task: ScheduledTask = {
41 runCount: 0,
42 };
43
44 +// Stands in for the thread family read the editor makes when the shell lacks the bound thread.
45 +const threadFamilyRead = {
46 + snapshotSequence: 1,
47 + threads: [{ id: task.threadId, title: "Fix login bug" }],
48 +};
49 +
50 const state = vi.hoisted(() => ({ connected: true, tasksLoaded: true, secondary: false }));
51 const secondaryId = EnvironmentId.make("secondary");
52 const permissions = new Map<string, Atom.Writable<boolean>>();
@@ -102,11 +109,21 @@ vi.mock(import("../../state/server"), async (original) => {
109 },
110 };
111 });
112 +vi.mock(import("../../state/threads"), async (original) => {
113 + const actual = await original();
114 + return {
115 + ...actual,
116 + threadFamilies: { ...actual.threadFamilies, familyAtom: (() => threadFamilyRead) as never },
117 + };
118 +});
119 // Mirrors the real query: a null request (disconnected environment) has no data.
120 vi.mock(import("../../state/query"), async (original) => ({
121 ...(await original()),
122 useEnvironmentQuery: ((request: unknown) => ({
109 - data: request === null ? null : { tasks: state.tasksLoaded ? [task] : [] },
123 + data:
124 + request === null || request === threadFamilyRead
125 + ? request
126 + : { tasks: state.tasksLoaded ? [task] : [] },
127 error: null,
128 isPending: false,
129 refresh: vi.fn(),
@@ -166,6 +183,7 @@ describe("ScheduledTasksSettings", () => {
183 it("keeps a linked task's unsaved edits across a disconnect and reconnect", async () => {
184 setup();
185 await using screen = await render(<ScheduledTasksSettings taskId={task.id} />);
186 + await expect.element(page.getByRole("dialog").getByText("Fix login bug")).toBeVisible();
187 const name = page.getByRole("dialog").getByRole("textbox", { name: "Name" });
188 await expect.element(name).toHaveValue("Review issues");
189 await userEvent.fill(name, "Review stale issues");
apps/web/src/components/settings/ScheduledTasksSettings.tsx
+40 -1
@@ -59,10 +59,12 @@ import {
59 useEnvironmentHttpBaseUrl,
60 type EnvironmentPresentation,
61 } from "../../state/environments";
62 -import { useProjects } from "../../state/entities";
62 +import { useProjects, useThreadShell } from "../../state/entities";
63 +import { scopeThreadRef } from "@t3tools/client-runtime/environment";
64 import { environmentAtomList, environmentIdsKey } from "../../state/environmentAtomList";
65 import { formatEnvironmentQueryError, useEnvironmentQuery } from "../../state/query";
66 import { EMPTY_SERVER_PROVIDERS, serverEnvironment } from "../../state/server";
67 +import { threadFamilies } from "../../state/threads";
68 import { useAtomCommand } from "../../state/use-atom-command";
69 import { WorktreeBaseBranchPicker } from "../WorktreeBaseBranchPicker";
70 import { EnvironmentMachineIcon } from "../EnvironmentMachineIcon";
@@ -1120,6 +1122,38 @@ function ScheduledTaskEditorDialog({
1122 );
1123 }
1124
1125 +function ScheduledTaskDestination({
1126 + environmentId,
1127 + threadId,
1128 +}: {
1129 + readonly environmentId: EnvironmentId;
1130 + readonly threadId: ThreadId | null;
1131 +}) {
1132 + const ref = threadId === null ? null : scopeThreadRef(environmentId, threadId);
1133 + const shell = useThreadShell(ref);
1134 + // The shell can omit older settled threads; their family read still carries the title.
1135 + const family = useEnvironmentQuery(
1136 + ref !== null && shell === null ? threadFamilies.familyAtom(environmentId, ref.threadId) : null,
1137 + );
1138 + const thread = shell ?? family.data?.threads.find((row) => row.id === threadId);
1139 + return (
1140 + <Field label="Destination">
1141 + {ref === null ? (
1142 + <p className="text-sm text-muted-foreground">
1143 + Each run starts a new thread with the workspace and model below.
1144 + </p>
1145 + ) : (
1146 + <div className="space-y-1 text-sm">
1147 + <p className="wrap-anywhere">{thread?.title.trim() || `Thread ${ref.threadId}`}</p>
1148 + <p className="text-muted-foreground">
1149 + Each run continues this conversation, in its workspace and with its current model.
1150 + </p>
1151 + </div>
1152 + )}
1153 + </Field>
1154 + );
1155 +}
1156 +
1157 function ScheduledTaskEditorForm({
1158 initialEnvironmentId,
1159 task,
@@ -1396,6 +1430,11 @@ function ScheduledTaskEditorForm({
1430 />
1431 </Field>
1432
1433 + <ScheduledTaskDestination
1434 + environmentId={environmentId}
1435 + threadId={draft.threadId ? (draft.threadId as ThreadId) : null}
1436 + />
1437 +
1438 <div className="grid gap-3 sm:grid-cols-2">
1439 <Field label="Project" htmlFor="scheduled-task-project">
1440 <Select