Skip to content

Commit afe50db

Browse files
authored
Merge branch 'main' into t3android/issue-18978
2 parents ce378c6 + aef0e9c commit afe50db

81 files changed

Lines changed: 2270 additions & 318 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/desktop/scripts/electron-launcher.mjs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const APP_BUNDLE_ID = isDevelopment
2020
? `com.t3tools.t3code.dev.${devBundleIdSuffix || "local"}`
2121
: "com.t3tools.t3code";
2222
const APP_PROTOCOL_SCHEMES = isDevelopment ? ["t3code-dev"] : ["t3code"];
23-
const LAUNCHER_VERSION = 19;
23+
const LAUNCHER_VERSION = 20;
2424
const developmentMacIconPngPath = NodePath.join(
2525
repoRoot,
2626
"assets",
@@ -280,6 +280,8 @@ function patchMainBundleInfoPlist(appBundlePath, iconPath, executableName) {
280280
for (const [key, value] of Object.entries(resolveMacBundleInfoPlistStrings(executableName))) {
281281
setPlistString(infoPlistPath, key, value);
282282
}
283+
// macOS 26 offers Messages/Mail codes in every text field unless opted out.
284+
setPlistJson(infoPlistPath, "NSAutoFillRequiresTextContentTypeForOneTimeCodeOnMac", true);
283285
setPlistJson(infoPlistPath, "CFBundleURLTypes", [
284286
{
285287
CFBundleURLName: APP_BUNDLE_ID,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { WorktreeSetupCardProps } from "./worktree-setup-card";
66
import type { ComposerTextPaste } from "../../native/T3ComposerEditor.types";
77
import { type EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
88
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
9+
import type { HandoffEndpoints } from "@t3tools/client-runtime/handoff";
910
import type {
1011
CodexFeedbackSubmission,
1112
EnvironmentThreadStatus,
@@ -162,6 +163,7 @@ export interface ThreadDetailScreenProps {
162163
readonly feedbackSubmissions: ReadonlyArray<CodexFeedbackSubmission>;
163164
readonly onDismissFeedback: (id: MessageId) => void;
164165
readonly selectedThreadFeed: ReadonlyArray<ThreadFeedEntry>;
166+
readonly pendingHandoff?: HandoffEndpoints | null;
165167
readonly activityRun: ThreadFeedLatestRun | null;
166168
readonly activeWorkStartedAt: string | null;
167169
/** The live work is a provider-native subagent's runless root turn. */
@@ -1159,6 +1161,7 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
11591161
threadId={props.selectedThread.id}
11601162
workspaceRoot={props.threadCwd}
11611163
feed={props.selectedThreadFeed}
1164+
pendingHandoff={props.pendingHandoff}
11621165
worktreeSetup={props.worktreeSetup}
11631166
setupWorkingStartedAt={props.setupWorkingStartedAt}
11641167
queuedMessages={props.queuedMessages}

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ThreadMarkdownVideo, ThreadMediaVisibleContext } from "./ThreadMarkdown
33
import { useMarkdownImageSource } from "../../native/useMarkdownImageSource";
44
import { enrichedContextLinkPresentation } from "../../lib/enrichedLinkPresentation";
55
import { ThreadContextDivider } from "./thread-context-divider";
6-
import { ThreadHandoffRow } from "./thread-handoff-row";
6+
import { ThreadHandoffDivider, ThreadHandoffRow } from "./thread-handoff-row";
77
import { SecretRequestCard } from "./SecretRequestCard";
88
import { AppActivityIndicator } from "../../components/AppActivityIndicator";
99
import {
@@ -15,6 +15,7 @@ import * as Haptics from "expo-haptics";
1515
import { KeyboardAwareLegendList } from "@legendapp/list/keyboard";
1616
import { useViewabilityAmount, type LegendListRef } from "@legendapp/list/react-native";
1717
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
18+
import type { HandoffEndpoints } from "@t3tools/client-runtime/handoff";
1819
import { resolveUserMessagePresentation } from "@t3tools/client-runtime/user-message";
1920
import { canForkProjectedAssistantItem } from "@t3tools/client-runtime/state/thread-workflows";
2021
import {
@@ -292,6 +293,7 @@ export interface ThreadFeedProps {
292293
readonly threadTitle: string;
293294
readonly workspaceRoot?: string | null;
294295
readonly feed: ReadonlyArray<ThreadFeedEntry>;
296+
readonly pendingHandoff?: HandoffEndpoints | null;
295297
readonly contentPresentation: ThreadContentPresentation;
296298
readonly agentLabel: string;
297299
readonly latestRun: ThreadFeedLatestRun | null;
@@ -2756,6 +2758,16 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
27562758
) : null}
27572759
</>
27582760
}
2761+
ListFooterComponent={
2762+
props.pendingHandoff ? (
2763+
<ThreadHandoffDivider
2764+
environmentId={props.environmentId}
2765+
endpoints={props.pendingHandoff}
2766+
iconColor={iconSubtleColor}
2767+
label="Context handoff pending"
2768+
/>
2769+
) : null
2770+
}
27592771
contentContainerStyle={{
27602772
paddingTop: 12,
27612773
paddingLeft: contentHorizontalPadding + contentLeftInset,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,7 @@ function ThreadRouteContent(
995995
feedbackSubmissions={composer.feedbackSubmissions}
996996
onDismissFeedback={composer.dismissFeedback}
997997
selectedThreadFeed={composer.selectedThreadFeed}
998+
pendingHandoff={composer.pendingHandoff}
998999
activityRun={composer.selectedThreadActivityRun}
9991000
activeWorkStartedAt={
10001001
creationState?.kind === "preparing" ||

‎apps/mobile/src/features/threads/thread-handoff-row.tsx‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useAtomValue } from "@effect/atom-react";
22
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
3-
import { resolveHandoffEndpoints } from "@t3tools/client-runtime/handoff";
3+
import { resolveHandoffEndpoints, type HandoffEndpoints } from "@t3tools/client-runtime/handoff";
44
import { resolveProviderInstanceDisplayName } from "@t3tools/client-runtime/state/provider-instance-display";
55
import type {
66
EnvironmentId,
@@ -45,15 +45,34 @@ export function ThreadHandoffRow(props: {
4545
[props.environmentId, props.projectedItem],
4646
);
4747
const endpoints = useAtomValue(endpointsAtom);
48-
const config = useAtomValue(serverEnvironment.configValueAtom(props.environmentId));
4948
if (item.type !== "handoff" || endpoints === null) return null;
5049
const color = item.status === "failed" ? "#e11d48" : props.iconColor;
5150
return (
52-
<ThreadContextDivider
53-
label="Context handoff"
54-
icon="arrow.left.arrow.right"
51+
<ThreadHandoffDivider
52+
environmentId={props.environmentId}
53+
endpoints={endpoints}
5554
iconColor={color}
55+
label="Context handoff"
5656
failed={item.status === "failed"}
57+
/>
58+
);
59+
}
60+
61+
export function ThreadHandoffDivider(props: {
62+
environmentId: EnvironmentId;
63+
endpoints: HandoffEndpoints;
64+
iconColor: ColorValue;
65+
label: string;
66+
failed?: boolean;
67+
}) {
68+
const config = useAtomValue(serverEnvironment.configValueAtom(props.environmentId));
69+
const { endpoints } = props;
70+
return (
71+
<ThreadContextDivider
72+
label={props.label}
73+
icon="arrow.left.arrow.right"
74+
iconColor={props.iconColor}
75+
failed={props.failed}
5776
>
5877
<View className="flex-row flex-wrap items-center justify-center gap-1.5">
5978
{endpoints.from.map((endpoint, index) => (
@@ -67,7 +86,7 @@ export function ThreadHandoffRow(props: {
6786
</Fragment>
6887
))}
6988
{endpoints.from.length > 0 ? (
70-
<SymbolView name="arrow.right" size={12} tintColor={color} />
89+
<SymbolView name="arrow.right" size={12} tintColor={props.iconColor} />
7190
) : null}
7291
<HandoffEndpoint {...endpoints.to} providers={config?.providers ?? []} />
7392
</View>

‎apps/mobile/src/state/use-thread-composer-state.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { readEnvironmentScope } from "./session";
33
import type { ComposerTextPaste } from "../native/T3ComposerEditor.types";
44
import { useAtomValue } from "@effect/atom-react";
55
import { threadRuntimeIsActive } from "@t3tools/client-runtime/state/shell";
6+
import { resolvePendingHandoff } from "@t3tools/client-runtime/handoff";
67
import {
78
deriveProviderSubagentStatus,
89
deriveRunlessWorkStartedAt,
@@ -334,6 +335,15 @@ export function useThreadComposerState() {
334335
const selectedThreadQueueCount = selectedThreadQueuedMessages.length;
335336
const selectedThread = selectedThreadShell;
336337
const modelSelection = selectedDraft?.modelSelection ?? selectedThread?.modelSelection ?? null;
338+
const pendingHandoff = useMemo(
339+
() =>
340+
resolvePendingHandoff(
341+
selectedThreadProjection?.projection,
342+
modelSelection,
343+
selectedEnvironmentRuntime?.serverConfig?.providers ?? [],
344+
),
345+
[modelSelection, selectedThreadProjection, selectedEnvironmentRuntime?.serverConfig?.providers],
346+
);
337347
const runtimeMode = selectedDraft?.runtimeMode ?? selectedThread?.runtimeMode ?? null;
338348
const selectedProvider = selectedEnvironmentRuntime?.serverConfig?.providers.find(
339349
(provider) => provider.instanceId === modelSelection?.instanceId,
@@ -1091,6 +1101,7 @@ export function useThreadComposerState() {
10911101
cancelQueuedRunEdit,
10921102
onRemoveQueuedEditAttachment,
10931103
modelSelection,
1104+
pendingHandoff,
10941105
canSwitchThreadProvider,
10951106
runtimeMode,
10961107
interactionMode,

‎apps/server/src/device/DeviceHost.ts‎

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,39 @@ export class DeviceHostTimeoutError extends Schema.TaggedError<DeviceHostTimeout
3939
}
4040
}
4141

42+
export class AgentDeviceStartError extends Schema.TaggedError<AgentDeviceStartError>()(
43+
"AgentDeviceStartError",
44+
{
45+
hostId: Schema.String,
46+
stateDir: Schema.String,
47+
exitCode: Schema.NullOr(Schema.Int),
48+
reason: Schema.Literals([
49+
"daemon_lock_not_directory",
50+
"daemon_registration_unproven",
51+
"daemon_retirement_unconfirmed",
52+
"command_failed",
53+
]),
54+
cause: Schema.Defect(),
55+
},
56+
) {
57+
override get message(): string {
58+
const exit = this.exitCode === null ? "" : ` (exit code ${this.exitCode})`;
59+
const detail =
60+
this.reason === "daemon_lock_not_directory"
61+
? "Daemon registration ownership could not be verified: daemon.lock is not a directory."
62+
: this.reason === "daemon_registration_unproven"
63+
? "Daemon registration ownership could not be verified."
64+
: this.reason === "daemon_retirement_unconfirmed"
65+
? "Daemon replacement could not be confirmed."
66+
: "The AgentDevice startup command failed.";
67+
const recovery =
68+
this.reason === "command_failed"
69+
? `Inspect daemon diagnostics in ${this.stateDir}.`
70+
: `Inspect daemon.lock and daemon diagnostics in ${this.stateDir}. Stop older clients and daemons with their original CLI before manually repairing retained state.`;
71+
return `Agent tools failed to start${exit}. ${detail} ${recovery}`;
72+
}
73+
}
74+
4275
export interface DeviceHubEndpoint {
4376
/** Loopback origin of expo-device-hub, e.g. `http://127.0.0.1:3400`. */
4477
readonly origin: string;
@@ -96,7 +129,7 @@ export class DeviceHost extends Context.Service<
96129
onPhase: (phase: "installing" | "starting", detail?: string) => Effect.Effect<void>,
97130
) => Effect.Effect<
98131
DeviceHostAgentReady,
99-
DeviceHostError | DeviceHostTimeoutError | NodeRuntimeUnavailableError
132+
DeviceHostError | DeviceHostTimeoutError | AgentDeviceStartError | NodeRuntimeUnavailableError
100133
>;
101134
/** Current endpoints when already running, without starting anything. */
102135
readonly current: Effect.Effect<DeviceHostReady | null>;

‎apps/server/src/device/DeviceService.test.ts‎

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ const fixture = Effect.fn("fixture")(function* (
6666
onBoot: Effect.Effect<void> = Effect.void,
6767
bootError?: string,
6868
failListAfterShutdown = false,
69-
runtimeFailure?: NodeRuntimeUnavailableError | DeviceHost.DeviceHostError,
69+
runtimeFailure?:
70+
| NodeRuntimeUnavailableError
71+
| DeviceHost.DeviceHostError
72+
| DeviceHost.AgentDeviceStartError,
7073
inspectError = false,
7174
installTool?: Parameters<typeof DeviceService.makeWithHosts>[3],
7275
) {
@@ -107,7 +110,8 @@ const fixture = Effect.fn("fixture")(function* (
107110
platformAvailability: (platform) => Effect.succeed({ platform, available: true }),
108111
ensureReady: (onPhase) =>
109112
Effect.gen(function* () {
110-
if (runtimeFailure) return yield* runtimeFailure;
113+
if (runtimeFailure && runtimeFailure._tag !== "AgentDeviceStartError")
114+
return yield* runtimeFailure;
111115
starts.push("start");
112116
yield* onPhase("installing", "Updating device hub from 0.9.0 to 0.10.1…");
113117
return ready;
@@ -217,6 +221,36 @@ const fixture = Effect.fn("fixture")(function* (
217221
});
218222

219223
describe("device setup consent", () => {
224+
it.effect("exposes daemon startup diagnostics through agent readiness and host status", () =>
225+
Effect.gen(function* () {
226+
const startupError = new DeviceHost.AgentDeviceStartError({
227+
hostId: LOCAL_DEVICE_HOST_ID,
228+
stateDir: "/test/device/agent-device",
229+
exitCode: 1,
230+
reason: "daemon_lock_not_directory",
231+
cause: { stdout: "private startup diagnostics", code: 1 },
232+
});
233+
const { service, settings } = yield* fixture(Effect.void, undefined, false, startupError);
234+
yield* Ref.update(settings, (current) => ({
235+
...current,
236+
enableDeviceSupport: true,
237+
enableAgentDeviceAccess: true,
238+
}));
239+
const error = yield* service.agentReadinessIfSupported().pipe(Effect.flip);
240+
expect(error).toMatchObject({
241+
_tag: "DeviceHostUnavailableError",
242+
reason: startupError.message,
243+
cause: startupError,
244+
});
245+
expect(error.message).toContain("daemon.lock is not a directory");
246+
expect(error.message).not.toContain("private startup diagnostics");
247+
expect((yield* service.state).hostStatuses[LOCAL_DEVICE_HOST_ID]).toEqual({
248+
status: "failed",
249+
detail: startupError.message,
250+
});
251+
}).pipe(Effect.scoped),
252+
);
253+
220254
it.effect(
221255
"preserves missing-runtime guidance and causes through manual and agent readiness",
222256
() =>

‎apps/server/src/device/DeviceService.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,11 @@ export const makeWithHosts = Effect.fn("DeviceService.makeWithHosts")(function*
337337
? nodeRuntimeUnavailableMessage("Local device support")
338338
: error._tag === "DeviceHostTimeoutError"
339339
? `Agent tools did not start within ${error.timeoutMs} ms.`
340-
: error.step === "probe"
341-
? "Could not connect to this host over SSH."
342-
: `Device support failed during ${error.step}.`,
340+
: error._tag === "AgentDeviceStartError"
341+
? error.message
342+
: error.step === "probe"
343+
? "Could not connect to this host over SSH."
344+
: `Device support failed during ${error.step}.`,
343345
cause: error,
344346
}),
345347
),

0 commit comments

Comments
 (0)