Skip to content

Commit b3418a0

Browse files
Merge remote-tracking branch 'origin/main' into fix/scheduler-timezone-short-label
2 parents ed82e31 + a0efdae commit b3418a0

112 files changed

Lines changed: 3574 additions & 645 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/mobile/src/features/home/HomeRouteScreen.tsx‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616

1717
import { useProjects } from "../../state/entities";
1818
import { environmentThreadShells } from "../../state/threads";
19-
import { usePendingNewTasks } from "../../state/use-pending-new-tasks";
19+
import { useLaunchingThreads, usePendingNewTasks } from "../../state/use-pending-new-tasks";
2020
import { useWorkspaceState } from "../../state/workspace";
2121
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
2222
import {
@@ -46,9 +46,8 @@ export function HomeRouteScreen() {
4646
const projects = useProjects();
4747
// Stop rebuilding the streaming thread list while Thread covers Home.
4848
const visible = useHomeRouteVisible();
49-
const threads = useAtomValueWhileVisible(
50-
environmentThreadShells.navigationThreadShellsAtom,
51-
visible,
49+
const threads = useLaunchingThreads(
50+
useAtomValueWhileVisible(environmentThreadShells.navigationThreadShellsAtom, visible),
5251
);
5352
const { environments: workspaceEnvironments, state: catalogState } = useWorkspaceState();
5453
const { savedConnectionsById } = useSavedRemoteConnections();

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ const WIDE_MARKDOWN_BLOCK_OPTIONS = {
286286

287287
const TURN_FOLD_HEIGHT = 42;
288288
const FEED_PADDING_TOP = 12;
289+
const VIEWED_IMAGE_GAP = 8;
289290
const USER_BUBBLE_HORIZONTAL_PADDING = 3.5 * 3.5;
290291
const ASSISTANT_ROW_HORIZONTAL_PADDING = 3.5;
291292
// Virtualization remounts old rows; only newly created content should replay an entrance.
@@ -1722,6 +1723,19 @@ function renderFeedEntry(
17221723
);
17231724
}
17241725

1726+
if (entry.type === "viewed-images") {
1727+
const thumbnailWidth = Math.floor((props.contentWidth - VIEWED_IMAGE_GAP) / 2);
1728+
return (
1729+
<View className="flex-row flex-wrap pb-2" style={{ gap: VIEWED_IMAGE_GAP }}>
1730+
{entry.paths.map((path) => (
1731+
<View key={path} style={{ width: thumbnailWidth }}>
1732+
{props.renderViewedImage({ href: path, alt: null, title: null })}
1733+
</View>
1734+
))}
1735+
</View>
1736+
);
1737+
}
1738+
17251739
if (entry.type === "mcp-app") {
17261740
return (
17271741
<ThreadMcpApp

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ import { useThreadListV2ShelfPreferences } from "./use-thread-list-v2-shelf-pref
3232
import { useThreadListNow } from "./use-thread-list-now";
3333
import { usePendingThreadOrder } from "../../state/thread-order";
3434
import { threadListEnvironmentsAtom } from "../../state/presentation";
35-
import { usePendingNewTasks, type PendingNewTask } from "../../state/use-pending-new-tasks";
35+
import {
36+
useLaunchingThreads,
37+
usePendingNewTasks,
38+
type PendingNewTask,
39+
} from "../../state/use-pending-new-tasks";
3640
import { useQueuedThreadKeys } from "../../state/use-thread-outbox";
3741
import { useWorkspaceState } from "../../state/workspace";
3842
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
@@ -136,6 +140,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
136140
regenerateThreadTitle,
137141
} = useThreadListActions();
138142
const pendingTasks = usePendingNewTasks();
143+
const launchingThreads = useLaunchingThreads(threads);
139144
const activeNewTask = useActiveNewTask();
140145
const queuedThreadKeys = useQueuedThreadKeys();
141146
const selectDetail = useSelectWorkspaceDetail();
@@ -264,7 +269,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
264269
contentOnlyThreadKeys,
265270
olderSettledShelf,
266271
} = useThreadListV2({
267-
threads,
272+
threads: launchingThreads,
268273
pendingTasks,
269274
environmentId: options.selectedEnvironmentId,
270275
projectRefs: selectedProjectScope === null ? null : selectedProjectScope.projectRefs,

‎apps/mobile/src/lib/threadActivity.ts‎

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
resolveWorkEntryToolPresentation,
2828
summarizeToolGroup,
2929
toolGroupSummaryKind,
30+
workEntriesViewedImagePaths,
3031
type ToolGroupSummaryKind,
3132
type WorkLogPresentationEntry,
3233
type WorkLogToolLifecycleStatus,
@@ -224,6 +225,14 @@ type ThreadFeedEntryContent =
224225
readonly shimmer: boolean;
225226
readonly thought?: string;
226227
}
228+
| {
229+
/** Images the agent opened in the tool group above, kept visible while the group is collapsed. */
230+
readonly type: "viewed-images";
231+
readonly id: string;
232+
readonly createdAt: string;
233+
readonly runId: RunId | null;
234+
readonly paths: ReadonlyArray<string>;
235+
}
227236
| {
228237
readonly type: "run-fold";
229238
readonly deferredWorkItemIds?: ReadonlyArray<string>;
@@ -1252,7 +1261,10 @@ const supersededReasoningGroups = new WeakMap<ThreadFeedActivityGroup, ThreadFee
12521261
const trailingReasoningGroups = new WeakMap<ThreadFeedActivityGroup, ThreadFeedActivityGroup>();
12531262

12541263
function settleSupersededReasoning(
1255-
entry: Exclude<ThreadFeedEntry, { readonly type: "run-fold" | "work-toggle" | "thinking" }>,
1264+
entry: Exclude<
1265+
ThreadFeedEntry,
1266+
{ readonly type: "run-fold" | "work-toggle" | "thinking" | "viewed-images" }
1267+
>,
12561268
tail: boolean,
12571269
) {
12581270
if (entry.type !== "activity-group") return entry;
@@ -1527,7 +1539,10 @@ export function deriveThreadFeedPresentation(
15271539
const lastEntryByRun = new Map<RunId, number>();
15281540

15291541
const retainedFeed: Array<
1530-
Exclude<ThreadFeedEntry, { readonly type: "run-fold" | "work-toggle" | "thinking" }>
1542+
Exclude<
1543+
ThreadFeedEntry,
1544+
{ readonly type: "run-fold" | "work-toggle" | "thinking" | "viewed-images" }
1545+
>
15311546
> = [];
15321547
const retainedFeedIndices: number[] = [];
15331548
const { toolCallVisibility, revealedMessageId } = display;
@@ -1540,7 +1555,12 @@ export function deriveThreadFeedPresentation(
15401555
: null;
15411556
for (let index = start; index < feed.length; index += 1) {
15421557
let entry = feed[index]!;
1543-
if (entry.type === "run-fold" || entry.type === "work-toggle" || entry.type === "thinking")
1558+
if (
1559+
entry.type === "run-fold" ||
1560+
entry.type === "work-toggle" ||
1561+
entry.type === "thinking" ||
1562+
entry.type === "viewed-images"
1563+
)
15441564
continue;
15451565
const runId = feedEntryRunId(entry);
15461566
if (runId !== null) {
@@ -1819,7 +1839,10 @@ function thinkingRow(createdAt: string, runId: RunId | null, label: string | nul
18191839

18201840
function appendPresentedFeedEntry(
18211841
result: ThreadFeedEntry[],
1822-
entry: Exclude<ThreadFeedEntry, { readonly type: "run-fold" | "work-toggle" | "thinking" }>,
1842+
entry: Exclude<
1843+
ThreadFeedEntry,
1844+
{ readonly type: "run-fold" | "work-toggle" | "thinking" | "viewed-images" }
1845+
>,
18231846
expandedWorkGroupIds: ReadonlySet<string>,
18241847
activeRunId: RunId | null,
18251848
isWorking: boolean,
@@ -1890,16 +1913,27 @@ function appendActivityGroupRows(
18901913
let groupableRun: ThreadFeedActivity[] = [];
18911914
const flushGroupableRun = (isTrailingRun: boolean) => {
18921915
if (groupableRun.length === 0) return;
1916+
const groupId = `work-group:${groupAnchorIdByActivityId.get(groupableRun[0]!.id) ?? groupableRun[0]!.id}`;
18931917
appendToolGroupRows(
18941918
result,
18951919
entry,
18961920
groupableRun,
1897-
`work-group:${groupAnchorIdByActivityId.get(groupableRun[0]!.id) ?? groupableRun[0]!.id}`,
1921+
groupId,
18981922
expandedWorkGroupIds,
18991923
activeRunId,
19001924
isWorking,
19011925
activeTail && isTrailingRun,
19021926
);
1927+
const paths = workEntriesViewedImagePaths(groupableRun.map((activity) => activity.workEntry));
1928+
if (paths.length > 0) {
1929+
result.push({
1930+
type: "viewed-images",
1931+
id: `${groupId}:viewed-images`,
1932+
createdAt: groupableRun[0]!.createdAt,
1933+
runId: groupableRun[0]!.runId,
1934+
paths,
1935+
});
1936+
}
19031937
groupableRun = [];
19041938
};
19051939
for (const activity of activities) {

‎apps/mobile/src/state/composer-attachment-uploads.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ vi.mock("./use-thread-outbox", async () => {
170170
dispatchingQueuedMessageIdAtom: Atom.make<Record<string, string>>({}).pipe(Atom.keepAlive),
171171
useThreadOutboxMessages: () =>
172172
appAtomRegistry.get(threadOutboxManager.queuedMessagesByThreadKeyAtom),
173+
retryingQueuedMessageIdsAtom: Atom.make({}).pipe(Atom.keepAlive),
173174
threadOutboxShellStatusesAtom: Atom.make(new Map()),
174175
};
175176
});

‎apps/mobile/src/state/pending-new-tasks-model.test.ts‎

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
import { EnvironmentId, ProjectId } from "@t3tools/contracts";
1+
import {
2+
CommandId,
3+
EnvironmentId,
4+
MessageId,
5+
ProjectId,
6+
ProviderInstanceId,
7+
ThreadId,
8+
} from "@t3tools/contracts";
29
import { describe, expect, it } from "vite-plus/test";
310

411
import {
12+
buildPendingNewTasks,
513
type PendingDraftProjectDefaults,
614
pendingDraftBranchNeedsRefs,
715
resolvePendingDraftBranch,
816
} from "./pending-new-tasks-model";
17+
import type { QueuedThreadMessage } from "./thread-outbox-model";
918
import type { ComposerDraft, ComposerDraftWorkspaceSelection } from "./use-composer-drafts";
1019

1120
const projectCwd = "/repo";
@@ -82,3 +91,55 @@ describe("resolvePendingDraftBranch", () => {
8291
expect(resolve({ draft: chosen, branches, projectCwd })).toBe("release");
8392
});
8493
});
94+
95+
function queuedCreation(environmentId: string): QueuedThreadMessage {
96+
return {
97+
environmentId: EnvironmentId.make(environmentId),
98+
threadId: ThreadId.make(`thread-${environmentId}`),
99+
messageId: MessageId.make(`message-${environmentId}`),
100+
commandId: CommandId.make(`command-${environmentId}`),
101+
text: "Test",
102+
attachments: [],
103+
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.6-sol" },
104+
creation: {
105+
projectId: ProjectId.make("project-1"),
106+
workspaceMode: "local",
107+
branch: null,
108+
worktreePath: null,
109+
},
110+
createdAt: "2026-11-10T01:10:00.000Z",
111+
};
112+
}
113+
114+
describe("buildPendingNewTasks", () => {
115+
it("lists only creations the outbox is not sending yet", () => {
116+
const sending = EnvironmentId.make("sending");
117+
const syncing = EnvironmentId.make("syncing");
118+
const readOnly = EnvironmentId.make("read-only");
119+
const retrying = EnvironmentId.make("retrying");
120+
const { modelSelection: _model, ...modelless } = queuedCreation("sending");
121+
const tasks = buildPendingNewTasks({
122+
queuedMessages: [
123+
...["sending", "syncing", "read-only", "retrying", "offline"].map(queuedCreation),
124+
{ ...modelless, messageId: MessageId.make("message-modelless") },
125+
],
126+
drafts: {},
127+
sendGate: {
128+
connectedEnvironmentIds: new Set([sending, syncing, readOnly, retrying]),
129+
operableEnvironmentIds: new Set([sending, syncing, retrying]),
130+
shellStatuses: new Map([
131+
[sending, "live"],
132+
[syncing, "synchronizing"],
133+
[readOnly, "live"],
134+
[retrying, "live"],
135+
]),
136+
retryingMessageIds: { [MessageId.make("message-retrying")]: true },
137+
},
138+
});
139+
140+
expect(tasks).toHaveLength(5);
141+
expect(new Set(tasks.map((task) => task.environmentId))).toEqual(
142+
new Set(["syncing", "read-only", "retrying", "offline", "sending"]),
143+
);
144+
});
145+
});

‎apps/mobile/src/state/pending-new-tasks-model.ts‎

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
import type { EnvironmentId, ProjectId } from "@t3tools/contracts";
1+
import type { EnvironmentShellStatus } from "@t3tools/client-runtime/state/shell";
2+
import type { EnvironmentId, MessageId, ProjectId } from "@t3tools/contracts";
23

34
import { deriveThreadTitleFromPrompt } from "../lib/projectThreadStartTurn";
4-
import type { QueuedThreadCreation, QueuedThreadMessage } from "./thread-outbox-model";
5+
import {
6+
isQueuedThreadCreationSendable,
7+
resolveThreadOutboxDeliveryAction,
8+
type QueuedThreadCreation,
9+
type QueuedThreadMessage,
10+
} from "./thread-outbox-model";
511
import { isNewTaskDraftKey } from "./new-task-draft-key";
612
import type { ComposerDraft } from "./use-composer-drafts";
713
import { resolveNewTaskDraftWorkspace } from "../features/threads/new-task-context-presentation";
@@ -85,13 +91,41 @@ export function resolvePendingDraftBranch(input: {
8591
}).branch;
8692
}
8793

94+
export interface ThreadOutboxSendGate {
95+
readonly connectedEnvironmentIds: ReadonlySet<EnvironmentId>;
96+
readonly operableEnvironmentIds: ReadonlySet<EnvironmentId>;
97+
readonly shellStatuses: ReadonlyMap<EnvironmentId, EnvironmentShellStatus>;
98+
readonly retryingMessageIds: Readonly<Partial<Record<MessageId, true>>>;
99+
}
100+
101+
/** The outbox drain's gate for a creation: sendable, connected, shell live, operate granted, not backing off. */
102+
export function isQueuedCreationSending(
103+
message: QueuedThreadMessage,
104+
gate: ThreadOutboxSendGate,
105+
): boolean {
106+
const environmentId = message.environmentId;
107+
return (
108+
isQueuedThreadCreationSendable(message) &&
109+
gate.retryingMessageIds[message.messageId] !== true &&
110+
gate.operableEnvironmentIds.has(environmentId) &&
111+
resolveThreadOutboxDeliveryAction({
112+
isCreation: true,
113+
threadExists: false,
114+
shellStatus: gate.shellStatuses.get(environmentId) ?? "empty",
115+
environmentConnected: gate.connectedEnvironmentIds.has(environmentId),
116+
}) === "send"
117+
);
118+
}
119+
88120
export function buildPendingNewTasks(input: {
89121
readonly queuedMessages: ReadonlyArray<QueuedThreadMessage>;
90122
readonly drafts: Readonly<Record<string, ComposerDraft>>;
123+
readonly sendGate: ThreadOutboxSendGate;
91124
}): ReadonlyArray<PendingNewTask> {
92125
const tasks: PendingNewTask[] = [];
93126
for (const message of input.queuedMessages) {
94-
if (!message.creation) {
127+
// Listing a creation already being sent would flash an "Unsent" row.
128+
if (!message.creation || isQueuedCreationSending(message, input.sendGate)) {
95129
continue;
96130
}
97131
tasks.push({

‎apps/mobile/src/state/pending-thread-creation.test.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ import {
44
MessageId,
55
ProjectId,
66
ProviderInstanceId,
7+
RunId,
78
ThreadId,
89
} from "@t3tools/contracts";
10+
import { isThreadWorking } from "@t3tools/client-runtime/state/thread-inbox";
911
import { describe, expect, it } from "vite-plus/test";
1012

1113
import {
14+
pendingThreadCreationShell,
1215
resolvePendingThreadCreation,
1316
selectThreadCreationDetail,
17+
withLaunchingThreads,
1418
type PendingThreadCreation,
1519
} from "./pending-thread-creation";
1620
import type { QueuedThreadMessage } from "./thread-outbox-model";
@@ -186,3 +190,30 @@ describe("selectThreadCreationDetail", () => {
186190
).toEqual({ pendingCreation: null, detailRef: threadRef });
187191
});
188192
});
193+
194+
describe("withLaunchingThreads", () => {
195+
it("reads as working from Send until the thread's first run arrives", () => {
196+
const launch = (threads: Parameters<typeof withLaunchingThreads>[0]["threads"]) =>
197+
withLaunchingThreads({ threads, launches: [creation], hiddenThreadKeys: new Set() });
198+
// Before the shell arrives, and after the server commits the thread without its run.
199+
const created = { ...pendingThreadCreationShell(creation)!, title: "Server title" };
200+
for (const threads of [launch([]), launch([created])]) {
201+
expect(threads).toHaveLength(1);
202+
expect(isThreadWorking(threads[0]!)).toBe(true);
203+
}
204+
expect(launch([created])[0]!.title).toBe("Server title");
205+
206+
const started = {
207+
...created,
208+
latestRun: {
209+
runId: RunId.make("run-1"),
210+
status: "completed" as const,
211+
requestedAt: null,
212+
startedAt: null,
213+
completedAt: null,
214+
assistantMessageId: null,
215+
},
216+
};
217+
expect(launch([started])[0]).toBe(started);
218+
});
219+
});

0 commit comments

Comments
 (0)