Skip to content

Commit 00ea3d7

Browse files
committed
Merge remote-tracking branch 'github/main' into issue-watch/32453
2 parents 9321f14 + fa2f4ff commit 00ea3d7

23 files changed

Lines changed: 628 additions & 76 deletions

‎apps/desktop/src/window/DesktopWindow.test.ts‎

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ function layerTest(input: {
233233
readonly destroyAll?: Effect.Effect<void>;
234234
readonly onWindowCreate?: Effect.Effect<void>;
235235
readonly openedExternalUrls?: unknown[];
236-
readonly copiedTexts?: string[];
236+
readonly onCopyText?: (text: string) => Effect.Effect<void>;
237237
readonly onPopupTemplate?: (input: ElectronMenu.ElectronMenuTemplateInput) => Effect.Effect<void>;
238238
readonly previewZoomReapplies?: number[];
239239
readonly onReveal?: (window: Electron.BrowserWindow) => void;
@@ -325,10 +325,7 @@ function layerTest(input: {
325325
return true;
326326
}),
327327
openSystemSettings: () => Effect.succeed(true),
328-
copyText: (text) =>
329-
Effect.sync(() => {
330-
input.copiedTexts?.push(text);
331-
}),
328+
copyText: input.onCopyText ?? (() => Effect.void),
332329
} satisfies ElectronShell.ElectronShell["Service"]),
333330
layerElectronTheme,
334331
layerElectronWindow,
@@ -1186,6 +1183,56 @@ describe("DesktopWindow", () => {
11861183
}),
11871184
);
11881185

1186+
it.effect("offers to copy the bare address when right-clicking a mailto link", () =>
1187+
Effect.gen(function* () {
1188+
const fakeWindow = makeFakeBrowserWindow();
1189+
const createCount = yield* Ref.make(0);
1190+
const mainWindow = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());
1191+
const popup = yield* Deferred.make<ElectronMenu.ElectronMenuTemplateInput>();
1192+
const copied = yield* Deferred.make<string>();
1193+
const layer = layerTest({
1194+
window: fakeWindow.window,
1195+
createCount,
1196+
mainWindow,
1197+
onPopupTemplate: (input) => Deferred.succeed(popup, input),
1198+
onCopyText: (text) => Deferred.succeed(copied, text),
1199+
});
1200+
1201+
yield* Effect.gen(function* () {
1202+
const desktopWindow = yield* DesktopWindow.DesktopWindow;
1203+
yield* desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773"));
1204+
1205+
const contextMenu = fakeWindow.webContentsListeners.get("context-menu");
1206+
if (!contextMenu) {
1207+
return yield* Effect.die("context-menu listener was not registered");
1208+
}
1209+
contextMenu(
1210+
{ preventDefault: vi.fn() },
1211+
{
1212+
linkURL: "mailto:restaurant%40example.com?subject=Hi",
1213+
misspelledWord: "",
1214+
dictionarySuggestions: [],
1215+
mediaType: "none",
1216+
editFlags: { canCut: false, canCopy: false, canPaste: false, canSelectAll: true },
1217+
},
1218+
);
1219+
1220+
const { template } = yield* Deferred.await(popup);
1221+
const copyEmail = template.find((item) => item.label === "Copy Email Address");
1222+
assert.isDefined(
1223+
copyEmail,
1224+
`no "Copy Email Address" item in ${JSON.stringify(template.map((item) => item.label ?? item.role ?? item.type))}`,
1225+
);
1226+
copyEmail?.click?.(
1227+
{} as Electron.MenuItem,
1228+
fakeWindow.window,
1229+
{} as Electron.KeyboardEvent,
1230+
);
1231+
assert.equal(yield* Deferred.await(copied), "[email protected]");
1232+
}).pipe(Effect.provide(layer));
1233+
}),
1234+
);
1235+
11891236
it.effect(
11901237
"retries opening the real main on activate when a failed post-readiness open left only the splash",
11911238
() =>

‎apps/desktop/src/window/DesktopWindow.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ class ContextMenuImageCopyError extends Schema.TaggedError<ContextMenuImageCopyE
5353
const MACOS_WORKSPACE_TOPBAR_HEIGHT = 52;
5454
const MACOS_WINDOW_BUTTON_RADIUS = 7;
5555

56+
function parseMailtoAddress(rawUrl: string): Option.Option<string> {
57+
let url: URL;
58+
try {
59+
url = new URL(rawUrl);
60+
} catch {
61+
return Option.none();
62+
}
63+
if (url.protocol !== "mailto:" || url.pathname === "") return Option.none();
64+
try {
65+
return Option.some(decodeURIComponent(url.pathname));
66+
} catch {
67+
return Option.some(url.pathname);
68+
}
69+
}
70+
5671
function syncMacosWindowButtons(window: Electron.BrowserWindow): void {
5772
if (window.isDestroyed() || window.isFullScreen()) return;
5873
window.setWindowButtonPosition({
@@ -590,6 +605,19 @@ export const make = Effect.gen(function* () {
590605
);
591606
}
592607

608+
const mailtoAddress = parseMailtoAddress(params.linkURL);
609+
if (Option.isSome(mailtoAddress)) {
610+
menuTemplate.push(
611+
{
612+
label: "Copy Email Address",
613+
click: () => {
614+
void runPromise(electronShell.copyText(mailtoAddress.value));
615+
},
616+
},
617+
{ type: "separator" },
618+
);
619+
}
620+
593621
if (params.mediaType === "image") {
594622
menuTemplate.push({
595623
label: "Copy Image",

‎apps/mobile/src/features/files/FileTreeBrowser.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ export function FileTreeBrowser(props: {
215215
return (
216216
<LegendList
217217
renderScrollComponent={NativeScrollView}
218+
nestedScrollEnabled={false}
218219
contentInset={{ top: headerInset, bottom: bottomInset }}
219220
alwaysBounceVertical
220221
className="flex-1"

‎apps/mobile/src/features/files/thread-file-navigator-pane.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ export function ThreadFileNavigatorPane(props: {
7878
);
7979

8080
return (
81-
<View className="flex-1 ios:bg-sheet android:bg-header">
81+
// Material drags target the first scroll view, so place content before the header.
82+
<View className="flex-1 ios:bg-sheet android:bg-header android:flex-col-reverse">
83+
<ScreenContent insetHorizontal>{fileTree}</ScreenContent>
8284
<AppBar
8385
title="Files"
8486
subtitle={props.projectName}
@@ -89,7 +91,6 @@ export function ThreadFileNavigatorPane(props: {
8991
}}
9092
refresh={{ accessibilityLabel: "Refresh files", onPress: entriesQuery.refresh }}
9193
/>
92-
<ScreenContent insetHorizontal>{fileTree}</ScreenContent>
9394
</View>
9495
);
9596
}

‎apps/mobile/src/features/layout/inspector-host.android.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ export function InspectorPanes(props: {
5353
position: "absolute",
5454
inset: 0,
5555
opacity: visible ? 1 : 0,
56-
zIndex: visible ? 1 : 0,
56+
// A lower zIndex puts the visible pane first in native order, where Material finds its scroll view.
57+
zIndex: visible ? 0 : 1,
5758
}}
5859
>
5960
<PaneContent pane={pane} resetKeys={props.content?.resetKeys} />

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts‎

Lines changed: 131 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {
5656
} from "@t3tools/contracts";
5757
import { mcpAppFromToolItem } from "@t3tools/shared/toolOutput";
5858
import { assert, describe, it } from "@effect/vitest";
59+
import * as Cause from "effect/Cause";
5960
import * as Context from "effect/Context";
6061
import * as DateTime from "effect/DateTime";
6162
import * as Deferred from "effect/Deferred";
@@ -2466,7 +2467,7 @@ describe("ClaudeAdapterV2 native fork", () => {
24662467
Effect.sync(() => {
24672468
openedQueries.push(input);
24682469
return {
2469-
messages: Stream.empty,
2470+
messages: Stream.never,
24702471
offer: () => Effect.void,
24712472
setModel: () => Effect.void,
24722473
applyFlagSettings: () => Effect.void,
@@ -2808,7 +2809,7 @@ describe("ClaudeAdapterV2 native session identity", () => {
28082809
Effect.sync(() => {
28092810
openedQueries.push(input);
28102811
return {
2811-
messages: Stream.empty,
2812+
messages: Stream.never,
28122813
offer: () => Effect.void,
28132814
setModel: () => Effect.void,
28142815
applyFlagSettings: () => Effect.void,
@@ -10979,6 +10980,134 @@ describe("ClaudeAdapterV2 background wake turns", () => {
1097910980
),
1098010981
);
1098110982

10983+
const openAdapterWhoseFirstQueryEndsBeforeItsFirstFrame = Effect.fnUntraced(function* (
10984+
name: string,
10985+
) {
10986+
const fileSystem = yield* FileSystem.FileSystem;
10987+
const idAllocator = yield* IdAllocator.IdAllocatorV2;
10988+
const attachmentsDir = yield* fileSystem.makeTempDirectoryScoped({
10989+
prefix: `t3-claude-v2-${name}-`,
10990+
});
10991+
const deadStreamEnded = yield* Deferred.make<void>();
10992+
let opened = 0;
10993+
const adapter = yield* ClaudeAdapterV2.makeClaudeAdapterV2({
10994+
instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
10995+
settings: DEFAULT_CLAUDE_SETTINGS,
10996+
environment: {},
10997+
attachmentsDir,
10998+
// startTurn reads the auto-compact window from settings between opening the query and
10999+
// attaching the turn; holding that read until the CLI's stream has ended pins the race.
11000+
fileSystem: {
11001+
...fileSystem,
11002+
readFileString: (filePath, encoding) =>
11003+
opened === 1 && filePath.endsWith("settings.json")
11004+
? Deferred.await(deadStreamEnded).pipe(
11005+
Effect.andThen(fileSystem.readFileString(filePath, encoding)),
11006+
)
11007+
: fileSystem.readFileString(filePath, encoding),
11008+
},
11009+
path: yield* Path.Path,
11010+
random: yield* SecureRandom.SecureRandom,
11011+
idAllocator,
11012+
continuationRequests: { offer: () => Effect.void },
11013+
queryRunner: {
11014+
allocateSessionId: Effect.succeed(`native-${name}`),
11015+
open: () =>
11016+
Effect.gen(function* () {
11017+
opened += 1;
11018+
const sdkMessages = yield* Queue.unbounded<SDKMessage>();
11019+
return {
11020+
// The first CLI exits without writing a frame.
11021+
messages:
11022+
opened === 1
11023+
? Stream.empty.pipe(Stream.ensuring(Deferred.succeed(deadStreamEnded, undefined)))
11024+
: Stream.fromQueue(sdkMessages),
11025+
offer: () => Effect.void,
11026+
setModel: () => Effect.void,
11027+
applyFlagSettings: () => Effect.void,
11028+
setPermissionMode: () => Effect.void,
11029+
backgroundTasks: () => Effect.succeed(false),
11030+
mcpServerStatus: Effect.succeed([]),
11031+
readMcpResource: () => Effect.die("unexpected MCP resource read"),
11032+
callMcpTool: () => Effect.die("unexpected MCP tool call"),
11033+
listPermissionRules: Effect.die("unexpected permission rules read"),
11034+
stopTask: () => Effect.void,
11035+
interrupt: Effect.void,
11036+
close: Queue.shutdown(sdkMessages),
11037+
};
11038+
}),
11039+
forkSession: () => Effect.die("unused forkSession"),
11040+
subagentLaunchToolUseId: () => Effect.succeed(null),
11041+
assertComplete: Effect.void,
11042+
},
11043+
});
11044+
const threadId = ThreadId.make(`thread-${name}`);
11045+
const runtime = yield* adapter.openSession({
11046+
threadId,
11047+
providerSessionId: ProviderSessionId.make(`provider-session-${name}`),
11048+
modelSelection: CLAUDE_TEST_MODEL_SELECTION,
11049+
runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
11050+
});
11051+
const providerThread = yield* runtime.ensureThread({
11052+
threadId,
11053+
modelSelection: CLAUDE_TEST_MODEL_SELECTION,
11054+
runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
11055+
});
11056+
const now = yield* DateTime.now;
11057+
const turnInput = (attempt: string, providerTurnOrdinal: number) =>
11058+
makeClaudeTestTurnInput({
11059+
threadId,
11060+
providerThread,
11061+
now,
11062+
attemptId: RunAttemptId.make(`attempt-${name}-${attempt}`),
11063+
text: "Continue with the plan.",
11064+
attachments: [],
11065+
providerTurnOrdinal,
11066+
});
11067+
return { runtime, turnInput };
11068+
});
11069+
11070+
it.effect("fails a turn whose Claude query ends before its first frame", () =>
11071+
Effect.scoped(
11072+
Effect.gen(function* () {
11073+
const harness = yield* openAdapterWhoseFirstQueryEndsBeforeItsFirstFrame(
11074+
"claude-query-dies-before-frame",
11075+
);
11076+
const started = yield* harness.runtime
11077+
.startTurn(harness.turnInput("a", 1))
11078+
.pipe(Effect.exit);
11079+
assert.isTrue(
11080+
Exit.isFailure(started),
11081+
"a turn whose Claude query ended before its first frame started running on the dead query",
11082+
);
11083+
if (Exit.isFailure(started)) {
11084+
assert.include(
11085+
Cause.pretty(started.cause),
11086+
"Claude provider query ended before the turn could start.",
11087+
);
11088+
}
11089+
const followUp = yield* harness.runtime
11090+
.startTurn(harness.turnInput("b", 2))
11091+
.pipe(Effect.exit);
11092+
assert.isTrue(
11093+
Exit.isSuccess(followUp),
11094+
`the turn whose query ended before its first frame is still active: ${
11095+
Exit.isFailure(followUp) ? Cause.pretty(followUp.cause) : ""
11096+
}`,
11097+
);
11098+
}).pipe(
11099+
Effect.provide(
11100+
Layer.mergeAll(
11101+
IdAllocator.layer,
11102+
McpProviderSessions.layer,
11103+
NodeServices.layer,
11104+
NodeCrypto.layer,
11105+
),
11106+
),
11107+
),
11108+
),
11109+
);
11110+
1098211111
it.effect(
1098311112
"clears the replaced sibling native thread roster when openQuery switches processes",
1098411113
() =>

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11311,8 +11311,22 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
1131111311
executedModel: undefined,
1131211312
};
1131311313
const attachTurn = Effect.gen(function* () {
11314-
querySession.lastTurn = context;
11314+
// Set before claiming: a query that exits after the claim finalizes this turn; one that exits before it fails the start.
1131511315
yield* Ref.set(activeTurn, context);
11316+
const attached = yield* Ref.modify(queryContext, (current) => {
11317+
if (current?.query !== querySession.query || querySession.stopping) {
11318+
return [false, current];
11319+
}
11320+
querySession.lastTurn = context;
11321+
return [true, current];
11322+
});
11323+
if (!attached) {
11324+
yield* Ref.update(activeTurn, (current) => (current === context ? null : current));
11325+
return yield* new ProviderAdapter.ProviderAdapterProtocolError({
11326+
driver: CLAUDE_PROVIDER,
11327+
detail: "Claude provider query ended before the turn could start.",
11328+
});
11329+
}
1131611330
if (
1131711331
!isClaudeProviderContinuationTurn(turnInput) &&
1131811332
permissionModeForClaudeRuntimePolicy(turnInput.runtimePolicy) ===
@@ -11389,15 +11403,6 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
1138911403
// Transcript reads suspend replay; hold SDK frames until the buffer is applied to preserve order.
1139011404
yield* sdkMessageLock.withPermits(1)(
1139111405
Effect.gen(function* () {
11392-
if (
11393-
(yield* Ref.get(queryContext))?.query !== querySession.query ||
11394-
querySession.stopping
11395-
) {
11396-
return yield* new ProviderAdapter.ProviderAdapterProtocolError({
11397-
driver: CLAUDE_PROVIDER,
11398-
detail: "Claude provider query ended before the continuation could start.",
11399-
});
11400-
}
1140111406
yield* attachTurn;
1140211407
const drained = (yield* Ref.get(wakeBuffers)).get(nativeThreadId)?.messages ?? [];
1140311408
yield* Ref.update(requestedContinuations, (current) => {

0 commit comments

Comments
 (0)