Skip to content

Commit 72db9c1

Browse files
Merge branch 'main' into fix/issue-15243
2 parents 9868f5e + 689bdb8 commit 72db9c1

106 files changed

Lines changed: 5219 additions & 1449 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/threads/ThreadDetailScreen.tsx‎

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ import {
197197
} from "./ThreadComposer";
198198
import { ComposerPopoverHost } from "./ComposerPopoverHost";
199199
import { ThreadFeed, type ThreadFeedHandle, type ThreadFeedHistoryControls } from "./ThreadFeed";
200+
import { WorkspaceMutationIdProvider } from "./WorkspaceMutationIdProvider";
200201
import { useThreadTurnSubagents } from "./ThreadAgentsSheet";
201202
import { ComposerQueuedEditBanner } from "./ComposerQueuedEdit";
202203
import { useThreadQueuedCount } from "./ThreadQueueControl";
@@ -1437,54 +1438,56 @@ function ThreadDetailBody(
14371438
/>
14381439
)}
14391440
>
1440-
<ThreadFeed
1441-
environmentId={props.environmentId}
1442-
threadId={props.selectedThread.id}
1443-
detailRef={props.selectedThreadDetailRef}
1444-
workspaceRoot={props.threadCwd}
1445-
feed={props.selectedThreadFeed}
1446-
pendingHandoff={props.pendingHandoff}
1447-
worktreeSetup={props.worktreeSetup}
1448-
setupWorkingStartedAt={props.setupWorkingStartedAt}
1449-
queuedMessages={props.queuedMessages}
1450-
dispatchingMessageId={props.dispatchingMessageId}
1451-
// A native subagent has no composer to edit a pending message in;
1452-
// Cancel on the edit banner would discard it.
1453-
onEditPendingMessage={
1454-
isProviderSubagent || pendingMessageEditBlocked ? null : handleEditPendingMessage
1455-
}
1456-
contentPresentation={props.contentPresentation}
1457-
threadTitle={props.selectedThread.title}
1458-
latestRun={props.activityRun}
1459-
activeWorkStartedAt={props.activeWorkStartedAt}
1460-
runlessWorkActive={props.runlessWorkActive ?? false}
1461-
listRef={listRef}
1462-
freeze={freeze}
1463-
anchorMessageId={anchorMessageId}
1464-
jumpToMessageId={jumpMessageLoaded ? jumpMessageId : null}
1465-
onJumpedToMessage={() => finishThreadMessageJump(selectedThreadKey)}
1466-
ref={feedRef}
1467-
contentInsetEndAdjustment={combinedContentInsetEndAdjustment}
1468-
keyboardOffset={composerKeyboardOffset}
1469-
sendingWithKeyboard={sendingWithKeyboard}
1470-
fitShortFeedToViewport={questionInFlow && !isKeyboardVisible}
1471-
contentTopInset={0}
1472-
contentBottomInset={
1473-
questionInFlow
1474-
? 0
1475-
: estimatedOverlayHeight +
1476-
(showFloatingStatus ? FLOATING_WORKING_CONTROL_COVERAGE : 0)
1477-
}
1478-
contentMaxWidth={contentMaxWidth}
1479-
historyControls={props.historyControls}
1480-
contentSideInsets={nativeMetrics?.safeArea}
1481-
layoutVariant={layoutVariant}
1482-
usesAutomaticContentInsets={props.usesAutomaticContentInsets}
1483-
onHeaderMaterialVisibilityChange={props.onHeaderMaterialVisibilityChange}
1484-
onEndFollowEnabledChange={handleEndFollowEnabledChange}
1485-
skills={selectedProviderSkills}
1486-
onUseArtifactTemplate={handleUseArtifactTemplate}
1487-
/>
1441+
<WorkspaceMutationIdProvider threadRef={props.selectedThreadDetailRef}>
1442+
<ThreadFeed
1443+
environmentId={props.environmentId}
1444+
threadId={props.selectedThread.id}
1445+
detailRef={props.selectedThreadDetailRef}
1446+
workspaceRoot={props.threadCwd}
1447+
feed={props.selectedThreadFeed}
1448+
pendingHandoff={props.pendingHandoff}
1449+
worktreeSetup={props.worktreeSetup}
1450+
setupWorkingStartedAt={props.setupWorkingStartedAt}
1451+
queuedMessages={props.queuedMessages}
1452+
dispatchingMessageId={props.dispatchingMessageId}
1453+
// A native subagent has no composer to edit a pending message in;
1454+
// Cancel on the edit banner would discard it.
1455+
onEditPendingMessage={
1456+
isProviderSubagent || pendingMessageEditBlocked ? null : handleEditPendingMessage
1457+
}
1458+
contentPresentation={props.contentPresentation}
1459+
threadTitle={props.selectedThread.title}
1460+
latestRun={props.activityRun}
1461+
activeWorkStartedAt={props.activeWorkStartedAt}
1462+
runlessWorkActive={props.runlessWorkActive ?? false}
1463+
listRef={listRef}
1464+
freeze={freeze}
1465+
anchorMessageId={anchorMessageId}
1466+
jumpToMessageId={jumpMessageLoaded ? jumpMessageId : null}
1467+
onJumpedToMessage={() => finishThreadMessageJump(selectedThreadKey)}
1468+
ref={feedRef}
1469+
contentInsetEndAdjustment={combinedContentInsetEndAdjustment}
1470+
keyboardOffset={composerKeyboardOffset}
1471+
sendingWithKeyboard={sendingWithKeyboard}
1472+
fitShortFeedToViewport={questionInFlow && !isKeyboardVisible}
1473+
contentTopInset={0}
1474+
contentBottomInset={
1475+
questionInFlow
1476+
? 0
1477+
: estimatedOverlayHeight +
1478+
(showFloatingStatus ? FLOATING_WORKING_CONTROL_COVERAGE : 0)
1479+
}
1480+
contentMaxWidth={contentMaxWidth}
1481+
historyControls={props.historyControls}
1482+
contentSideInsets={nativeMetrics?.safeArea}
1483+
layoutVariant={layoutVariant}
1484+
usesAutomaticContentInsets={props.usesAutomaticContentInsets}
1485+
onHeaderMaterialVisibilityChange={props.onHeaderMaterialVisibilityChange}
1486+
onEndFollowEnabledChange={handleEndFollowEnabledChange}
1487+
skills={selectedProviderSkills}
1488+
onUseArtifactTemplate={handleUseArtifactTemplate}
1489+
/>
1490+
</WorkspaceMutationIdProvider>
14881491
</RenderErrorBoundary>
14891492
</View>
14901493
) : (

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { PresentationSource } from "../../components/ui/NativePresentation";
1919
import { useMediaActions } from "../../state/mediaActions";
2020
import type { MediaActionsSource } from "../../lib/mediaActionsSource";
2121
import { useAssetUrlState } from "../../state/assets";
22+
import { WorkspaceMutationIdContext } from "./workspaceMutationIdContext";
2223
import { assetImageCacheKey } from "../../lib/assetImageSource";
2324
import {
2425
MARKDOWN_IMAGE_MAX_WIDTH,
@@ -277,7 +278,12 @@ export function ThreadMarkdownImage(props: {
277278
readonly onPressPreview: (source: FilePreviewSource) => void;
278279
}) {
279280
const withGallery = useFilePreviewGallery();
280-
const assetUrl = useAssetUrlState(props.environmentId, props.resource);
281+
const workspaceMutationId = useContext(WorkspaceMutationIdContext);
282+
const assetUrl = useAssetUrlState(
283+
props.environmentId,
284+
props.resource,
285+
props.resource._tag === "media-file" ? workspaceMutationId : undefined,
286+
);
281287
const resourceKey =
282288
props.resource._tag === "attachment"
283289
? `attachment:${props.resource.attachmentId}`
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { useAtomValue } from "@effect/atom-react";
2+
import type { ScopedThreadRef } from "@t3tools/contracts";
3+
import { Atom } from "effect/reactivity";
4+
import type { ReactNode } from "react";
5+
6+
import { environmentThreadDetails } from "../../state/threads";
7+
import { WorkspaceMutationIdContext } from "./workspaceMutationIdContext";
8+
9+
const NO_WORKSPACE_MUTATION_ID_ATOM = Atom.make<string | null | undefined>(undefined);
10+
11+
export function WorkspaceMutationIdProvider(props: {
12+
readonly threadRef: ScopedThreadRef | null;
13+
readonly children: ReactNode;
14+
}) {
15+
const workspaceMutationId = useAtomValue(
16+
props.threadRef === null
17+
? NO_WORKSPACE_MUTATION_ID_ATOM
18+
: environmentThreadDetails.workspaceMutationIdAtom(props.threadRef),
19+
);
20+
return (
21+
<WorkspaceMutationIdContext value={workspaceMutationId}>
22+
{props.children}
23+
</WorkspaceMutationIdContext>
24+
);
25+
}

‎apps/mobile/src/features/threads/thread-work-log.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,13 +937,14 @@ const ThreadWorkLogRow = function ThreadWorkLogRow(
937937
const warning = failureItem.failure.class === "usage_limit";
938938
const timestamp = new Date(row.createdAt);
939939
const resetAt = failureItem.failure.resetAt;
940+
// The reset time is the viewer's local time; naming the zone keeps it unambiguous.
940941
const resetTime = resetAt
941-
? new Date(resetAt).toLocaleString(undefined, {
942+
? `${new Date(resetAt).toLocaleString(undefined, {
942943
month: "short",
943944
day: "numeric",
944945
hour: "numeric",
945946
minute: "2-digit",
946-
})
947+
})} (${new Intl.DateTimeFormat().resolvedOptions().timeZone})`
947948
: null;
948949
const label = warning
949950
? `Usage limit reached.${resetTime ? ` Retry after ${resetTime}.` : ""}`
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createContext } from "react";
2+
3+
/** The thread's workspace mutation id, so a host image the agent rewrites gets a fresh URL. */
4+
export const WorkspaceMutationIdContext = createContext<string | null | undefined>(undefined);

‎apps/mobile/src/state/assets.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
createAssetEnvironmentAtoms,
77
createProjectFaviconUrlAtomFamily,
88
EMPTY_ASSET_URL_ATOM,
9+
makeRevisionedAssetUrlFamily,
910
} from "@t3tools/client-runtime/state/assets";
1011
import { executeAtomQuery } from "@t3tools/client-runtime/state/runtime";
1112
import type { AssetResource, EnvironmentId } from "@t3tools/contracts";
@@ -34,9 +35,16 @@ export const projectFaviconUrlAtom = createProjectFaviconUrlAtomFamily({
3435
projectClones: environmentProjectCloneListAtom,
3536
});
3637

38+
const revisionedAssetUrl = makeRevisionedAssetUrlFamily(assetEnvironment.createUrl);
39+
40+
/**
41+
* Pass `revision` for a host file whose bytes can change under the same path; each new
42+
* revision re-mints the URL so the image reloads.
43+
*/
3744
export function useAssetUrlState(
3845
environmentId: EnvironmentId | null,
3946
resource: AssetResource | null,
47+
revision?: string | null,
4048
): AssetUrlState {
4149
const fileAccessSession = useEnvironmentQuery(
4250
environmentId === null ? null : environmentSession.sessionStateAtom(environmentId),
@@ -54,7 +62,9 @@ export function useAssetUrlState(
5462
const result = useAtomValue(
5563
blocked !== null || environmentId === null || resource === null
5664
? EMPTY_ASSET_URL_ATOM
57-
: assetEnvironment.createUrl({ environmentId, input: { resource } }),
65+
: revision === undefined
66+
? assetEnvironment.createUrl({ environmentId, input: { resource } })
67+
: revisionedAssetUrl({ environmentId, input: { resource }, revision }),
5868
);
5969
const shared =
6070
blocked ??

‎apps/server/src/cloud/CloudLink.lifecycle.test.ts‎

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ describe("releaseManagedTunnelOnShutdown", () => {
140140
readonly address?: HttpServer.HttpServer["Service"]["address"];
141141
readonly respondEffect?: Effect.Effect<Response>;
142142
readonly getExisting?: CliTokenManager.CloudCliTokenManager["Service"]["getExisting"];
143+
readonly latestReachability?: ConnectReachability.ConnectReachability["Service"]["latest"];
143144
}
144145

145146
const writeLauncherState = (update: ServiceUpdateRecord) =>
@@ -165,7 +166,7 @@ describe("releaseManagedTunnelOnShutdown", () => {
165166
ConnectReachability.ConnectReachability,
166167
ConnectReachability.ConnectReachability.of({
167168
check: Effect.die("unused"),
168-
latest: Effect.succeedNone,
169+
latest: harness.latestReachability ?? Effect.succeedNone,
169170
}),
170171
),
171172
Effect.provideService(HttpServer.HttpServer, {
@@ -1050,4 +1051,57 @@ describe("releaseManagedTunnelOnShutdown", () => {
10501051
expect(values.has(CLOUD_ENDPOINT_RUNTIME_CONFIG)).toBe(false);
10511052
}).pipe(provideReleaseHarness({ store: failingStore, applyConfigCalls, requests }));
10521053
});
1054+
1055+
it.effect("does not report a not-linked check once the managed tunnel config is stored", () => {
1056+
const { store } = makeMemorySecretStore(managedLinkSecrets);
1057+
const notLinked = ConnectReachability.classifyReachability(
1058+
{
1059+
managedTunnelConfigured: false,
1060+
connector: null,
1061+
endpoint: null,
1062+
edgeReachable: null,
1063+
exitNode: null,
1064+
},
1065+
"2026-10-29T00:00:00.000Z",
1066+
);
1067+
1068+
return Effect.gen(function* () {
1069+
const state = yield* (yield* CloudLink.CloudLink).linkState();
1070+
1071+
expect(state.managedTunnelActive).toBe(true);
1072+
expect(state.reachability?.status === "unreachable" && state.reachability.cause).not.toBe(
1073+
"not_linked",
1074+
);
1075+
}).pipe(
1076+
provideReleaseHarness({
1077+
store,
1078+
applyConfigCalls: [],
1079+
requests: [],
1080+
latestReachability: Effect.succeedSome(notLinked),
1081+
}),
1082+
);
1083+
});
1084+
1085+
it.effect("reports a check that ran after the managed tunnel config was stored", () => {
1086+
const { store } = makeMemorySecretStore(managedLinkSecrets);
1087+
const reachable = {
1088+
status: "reachable" as const,
1089+
checkedAt: "2026-10-29T00:00:00.000Z",
1090+
readyConnections: 4,
1091+
protocol: "quic",
1092+
};
1093+
1094+
return Effect.gen(function* () {
1095+
const state = yield* (yield* CloudLink.CloudLink).linkState();
1096+
1097+
expect(state.reachability).toEqual(reachable);
1098+
}).pipe(
1099+
provideReleaseHarness({
1100+
store,
1101+
applyConfigCalls: [],
1102+
requests: [],
1103+
latestReachability: Effect.succeedSome(reachable),
1104+
}),
1105+
);
1106+
});
10531107
});

‎apps/server/src/cloud/CloudLink.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,13 @@ const make = Effect.gen(function* () {
12901290
],
12911291
{ concurrency: 8 },
12921292
);
1293+
// A not-linked check predates the stored tunnel config; the next check replaces it.
1294+
const currentReachability = Option.filter(
1295+
latestReachability,
1296+
(result) =>
1297+
Option.isNone(endpointRuntimeConfig) ||
1298+
!(result.status === "unreachable" && result.cause === "not_linked"),
1299+
);
12931300
return {
12941301
linked: Option.isSome(cloudUserId),
12951302
linkRevoked: Option.isSome(cloudUserId) && Option.isSome(revoked),
@@ -1302,7 +1309,7 @@ const make = Effect.gen(function* () {
13021309
: false,
13031310
holdWebhooksWhileOffline:
13041311
Option.isSome(holdWebhooks) && bytesToString(holdWebhooks.value) === "true",
1305-
...(Option.isSome(latestReachability) ? { reachability: latestReachability.value } : {}),
1312+
...(Option.isSome(currentReachability) ? { reachability: currentReachability.value } : {}),
13061313
} satisfies EnvironmentCloudLinkStateResult;
13071314
});
13081315

‎apps/server/src/cloud/ConnectReachability.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ describe("classifyReachability", () => {
6565
classifyReachability(facts({ connector: notConnected, edgeReachable: true }), checkedAt),
6666
).toMatchObject({ cause: "connector_not_ready" });
6767
});
68+
69+
it("does not point an unlinked server at a background service it may not have", () => {
70+
// Desktop and `t3 serve` run the server without a background service.
71+
const result = classifyReachability(facts({ managedTunnelConfigured: false }), checkedAt);
72+
expect(result).toMatchObject({ cause: "not_linked" });
73+
expect(result.status === "unreachable" && result.fix).not.toContain("t3 service");
74+
});
6875
});
6976

7077
describe("T3 Connect troubleshooting links", () => {

‎apps/server/src/cloud/ConnectReachability.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ export function classifyReachability(
6868
const restart = "Restart T3 Code. If it stays, run `t3 connect` again.";
6969

7070
if (!facts.managedTunnelConfigured) {
71+
// A running server reads the link `t3 connect` stores only at startup.
7172
return fail(
7273
"not_linked",
7374
"The server has not set up a T3 Connect tunnel.",
74-
"Run `t3 connect`, then restart the server (`t3 service restart`) so it applies the link.",
75+
"Run `t3 connect`, then restart T3 Code so it applies the link.",
7576
);
7677
}
7778
if (connector === null) {

0 commit comments

Comments
 (0)