Skip to content

Commit a7fee47

Browse files
Yuruzuuclaude
andcommitted
Merge remote-tracking branch 'upstream/main' into feat/selection-open-in-side-chat
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 parents 3dac8e3 + 9c19aa9 commit a7fee47

123 files changed

Lines changed: 4651 additions & 1788 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/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"effect": "catalog:",
2525
"electron": "44.10.1",
2626
"electron-store": "^8.2.0",
27-
"electron-updater": "^6.8.9",
27+
"electron-updater": "6.8.9",
2828
"electron-webauthn": "catalog:",
2929
"ffi-rs": "1.3.2",
3030
"playwright-core": "1.64.1",
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// @effect-diagnostics nodeBuiltinImport:off -- Fake Electron net request and response emitters.
2+
import * as NodeEvents from "node:events";
3+
import { ElectronHttpExecutor } from "electron-updater/out/electronHttpExecutor.js";
4+
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
5+
6+
function startRequest() {
7+
const request = Object.assign(new NodeEvents.EventEmitter(), { abort: vi.fn() });
8+
const response = new NodeEvents.EventEmitter();
9+
const reject = vi.fn();
10+
new ElectronHttpExecutor().addErrorAndTimeoutHandlers(request, reject);
11+
// Electron's net.ClientRequest emits these as soon as the request body is sent, before any response.
12+
request.emit("finish");
13+
request.emit("close");
14+
return { request, response, reject };
15+
}
16+
17+
describe("ElectronHttpExecutor idle timeout", () => {
18+
beforeEach(() => {
19+
vi.useFakeTimers();
20+
});
21+
afterEach(() => {
22+
vi.useRealTimers();
23+
});
24+
25+
it("aborts a request that receives no response for 60 seconds", () => {
26+
const { request, reject } = startRequest();
27+
28+
vi.advanceTimersByTime(59_999);
29+
expect(reject).not.toHaveBeenCalled();
30+
vi.advanceTimersByTime(1);
31+
32+
expect(request.abort).toHaveBeenCalledOnce();
33+
expect(reject).toHaveBeenCalledWith(new Error("Request timed out"));
34+
});
35+
36+
it("keeps a slow download alive while data keeps arriving", () => {
37+
const { request, response, reject } = startRequest();
38+
request.emit("response", response);
39+
40+
for (let elapsed = 0; elapsed < 180_000; elapsed += 30_000) {
41+
vi.advanceTimersByTime(30_000);
42+
response.emit("data", Buffer.alloc(1));
43+
}
44+
45+
expect(request.abort).not.toHaveBeenCalled();
46+
expect(reject).not.toHaveBeenCalled();
47+
});
48+
49+
it("stops the timer once the response ends", () => {
50+
const { request, response, reject } = startRequest();
51+
request.emit("response", response);
52+
53+
response.emit("end");
54+
vi.advanceTimersByTime(600_000);
55+
56+
expect(request.abort).not.toHaveBeenCalled();
57+
expect(reject).not.toHaveBeenCalled();
58+
});
59+
});

‎apps/desktop/src/updates/DesktopUpdates.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,33 @@ describe("DesktopUpdates", () => {
426426
).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
427427
});
428428

429+
it.effect("shows why a download failed, not only the channel", () => {
430+
const harness = makeHarness({
431+
downloadUpdate: Effect.fail(
432+
new ElectronUpdater.ElectronUpdaterDownloadUpdateError({
433+
channel: "nightly",
434+
cause: new Error("net::ERR_CONTENT_LENGTH_MISMATCH"),
435+
}),
436+
),
437+
});
438+
439+
return Effect.scoped(
440+
Effect.gen(function* () {
441+
const updates = yield* DesktopUpdates.DesktopUpdates;
442+
yield* updates.configure;
443+
harness.emit("update-available", { version: "1.2.4" });
444+
yield* flushCallbacks;
445+
446+
const result = yield* updates.download;
447+
assert.isFalse(result.completed);
448+
449+
const state = yield* updates.getState;
450+
assert.equal(state.errorContext, "download");
451+
assert.include(state.message ?? "", "ERR_CONTENT_LENGTH_MISMATCH");
452+
}),
453+
).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
454+
});
455+
429456
it.effect("restores download state and permits retry after interruption", () =>
430457
Effect.gen(function* () {
431458
const actionStarted = yield* Deferred.make<void>();

‎apps/desktop/src/updates/DesktopUpdates.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,12 +614,13 @@ export const make = Effect.gen(function* () {
614614
Effect.catchTags({
615615
ElectronUpdaterDownloadUpdateError: Effect.fn("desktop.updates.handleDownloadFailure")(
616616
function* (error) {
617+
const cause = describeUpdateErrorCause(error.cause);
617618
yield* updateState((current) =>
618-
reduceDesktopUpdateStateOnDownloadFailure(current, error.message),
619+
reduceDesktopUpdateStateOnDownloadFailure(current, `${error.message} ${cause}`),
619620
);
620621
yield* logUpdaterError(error.message, {
621622
errorTag: error._tag,
622-
cause: describeUpdateErrorCause(error.cause),
623+
cause,
623624
channel: error.channel,
624625
});
625626
return { accepted: true, completed: false };

‎apps/desktop/src/updates/updatesTestHarness.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface UpdatesHarnessOptions {
2727
readonly beforeSetUpdateChannel?: Effect.Effect<void>;
2828
readonly setUpdateChannelError?: DesktopAppSettings.DesktopSettingsWriteError;
2929
readonly setDisableDifferentialDownload?: Effect.Effect<void>;
30-
readonly downloadUpdate?: Effect.Effect<void>;
30+
readonly downloadUpdate?: Effect.Effect<void, ElectronUpdater.ElectronUpdaterDownloadUpdateError>;
3131
readonly quitAndInstall?: Effect.Effect<void, ElectronUpdater.ElectronUpdaterQuitAndInstallError>;
3232
readonly stopBackend?: Effect.Effect<void>;
3333
readonly startBackend?: Effect.Effect<void>;

‎apps/mobile/src/features/usage/UsageLimitsPooled.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function PoolWindowCard({
171171
readonly color: string;
172172
readonly now: number;
173173
readonly environmentIds: readonly string[] | null;
174-
readonly label?: string;
174+
readonly label?: string | null;
175175
readonly description?: string;
176176
readonly wide: boolean;
177177
}) {
@@ -195,7 +195,9 @@ function PoolWindowCard({
195195
<>
196196
<View className={wide ? "gap-1" : "flex-row items-start justify-between gap-3"}>
197197
<View className="gap-1">
198-
<Text className="text-sm font-t3-medium text-foreground">{label ?? pool.label}</Text>
198+
{label !== null ? (
199+
<Text className="text-sm font-t3-medium text-foreground">{label ?? pool.label}</Text>
200+
) : null}
199201
<View className="flex-row items-baseline gap-1.5">
200202
<Text className="text-3xl font-t3-bold tabular-nums text-foreground">
201203
{pool.remainingPercent}%
@@ -444,7 +446,7 @@ export function UsageLimitsSection({
444446
</View>
445447
{windows.map((window) => {
446448
const details =
447-
pool.driver === "cursor" ? cursorUsageWindowDetails(window.id) : undefined;
449+
pool.driver === "cursor" ? cursorUsageWindowDetails(window.id, pool) : undefined;
448450
return (
449451
<PoolWindowCard
450452
key={`${window.kind}:${window.id}`}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ const CONTEXT_CHIP_PRESENTATIONS = {
4545
},
4646
// A machine: the record carries only its identity, so every machine wears one glyph.
4747
environment: { accent: "#3f9a4f", icon: "server" },
48+
// An earlier response the message replies to. Mobile shows it as a plain labelled chip.
49+
response: { accent: "#7f8793", icon: null },
4850
} as const satisfies Record<string, ContextChipPresentation>;
4951

5052
const CHIP_CONTRAST = 5;

‎apps/server/scripts/record-cursor-agent-sdk-replay-fixture.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const RECORDINGS = {
5555
message_steering: {
5656
prompts: [MESSAGE_STEERING_INITIAL_PROMPT, MESSAGE_STEERING_STEER_PROMPT],
5757
output: "../src/orchestration-v2/testkit/fixtures/message_steering/cursor_transcript.ndjson",
58-
interruptAfterRunStartPromptIndex: 0,
58+
steerAfterRunStartPromptIndex: 0,
5959
},
6060
provider_thread_resume: {
6161
prompts: [PROVIDER_THREAD_RESUME_FIRST_PROMPT, PROVIDER_THREAD_RESUME_SECOND_PROMPT],
@@ -183,8 +183,8 @@ const recordScenario = Effect.fn("recordScenario")(function* (
183183
...("interruptAfterToolStart" in recording
184184
? { interruptAfterToolStart: recording.interruptAfterToolStart }
185185
: {}),
186-
...("interruptAfterRunStartPromptIndex" in recording
187-
? { interruptAfterRunStartPromptIndex: recording.interruptAfterRunStartPromptIndex }
186+
...("steerAfterRunStartPromptIndex" in recording
187+
? { steerAfterRunStartPromptIndex: recording.steerAfterRunStartPromptIndex }
188188
: {}),
189189
...("restartBeforePromptIndex" in recording
190190
? { restartBeforePromptIndex: recording.restartBeforePromptIndex }

‎apps/server/src/cli/thread.test.ts‎

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import * as NetService from "@t3tools/shared/Net";
77
import * as ConfigProvider from "effect/ConfigProvider";
88
import * as DateTime from "effect/DateTime";
99
import * as Effect from "effect/Effect";
10+
import * as Fiber from "effect/Fiber";
1011
import * as FileSystem from "effect/FileSystem";
1112
import * as Layer from "effect/Layer";
1213
import * as Path from "effect/Path";
1314
import { ChildProcess, ChildProcessSpawner } from "effect/process";
15+
import * as TestClock from "effect/testing/TestClock";
1416
import * as TestConsole from "effect/testing/TestConsole";
1517
import { Command } from "effect/cli";
1618
import { vi } from "vite-plus/test";
@@ -210,6 +212,133 @@ it.effect("--wait follows the sent run to its continuation's terminal status", (
210212
}),
211213
);
212214

215+
/** The reads that ask whether a run after `runId` holds a message someone sent. */
216+
const laterRunReads = (
217+
laterRun: RunId,
218+
items: ReadonlyArray<{ readonly runId: RunId; readonly type: string }>,
219+
) => [
220+
{
221+
recentRuns: [
222+
{ runId, ordinal: 1 },
223+
{ runId: laterRun, ordinal: 2 },
224+
],
225+
},
226+
{ thread: {}, items, nextPosition: null, hasMore: false },
227+
];
228+
229+
it.effect("--wait lasts until background work the agent waits on wakes it and that run ends", () =>
230+
Effect.gen(function* () {
231+
const wakeRun = RunId.make("run-2");
232+
const { tools, calls } = scriptedTools({
233+
t3_thread_wait: [
234+
{ threadId, runId, status: "completed", timedOut: false },
235+
{
236+
threadId,
237+
runId,
238+
status: "completed",
239+
timedOut: false,
240+
resultRun: { runId: wakeRun, status: "completed" },
241+
},
242+
],
243+
// The wake run starts from a notification, which the messages view leaves out.
244+
t3_thread_read: laterRunReads(wakeRun, []),
245+
});
246+
247+
const outcome = yield* waitForRun(tools, threadId, runId, true);
248+
249+
assert.deepStrictEqual(
250+
calls.filter((entry) => entry.tool === "t3_thread_wait").map((entry) => entry.args),
251+
[
252+
{ threadId, runId, timeoutMs: 15_000 },
253+
{ threadId, runId, timeoutMs: 15_000, untilDelegatedWorkSettled: true },
254+
],
255+
);
256+
assert.deepStrictEqual(outcome, { type: "ended", runId: wakeRun, status: "completed" });
257+
}),
258+
);
259+
260+
it.effect(
261+
"--wait waits out the moment between background work ending and its wake run starting",
262+
() =>
263+
Effect.gen(function* () {
264+
const wakeRun = RunId.make("run-2");
265+
const ownOnly = { recentRuns: [{ runId, ordinal: 1, status: "completed" }] };
266+
const withWake = (status: string) => [
267+
{
268+
recentRuns: [
269+
{ runId, ordinal: 1, status: "completed" },
270+
{ runId: wakeRun, ordinal: 2, status },
271+
],
272+
},
273+
{ thread: {}, items: [], nextPosition: null, hasMore: false },
274+
];
275+
const { tools } = scriptedTools({
276+
t3_thread_wait: [
277+
{ threadId, runId, status: "completed", timedOut: false },
278+
{ threadId, runId, status: "completed", timedOut: true },
279+
// The work ended, and the run it wakes is not recorded yet.
280+
{
281+
threadId,
282+
runId,
283+
status: "completed",
284+
timedOut: false,
285+
resultRun: { runId, status: "completed" },
286+
},
287+
{
288+
threadId,
289+
runId,
290+
status: "completed",
291+
timedOut: false,
292+
resultRun: { runId: wakeRun, status: "completed" },
293+
},
294+
],
295+
t3_thread_read: [
296+
ownOnly,
297+
{ thread: { pendingRequestCount: 0 } },
298+
ownOnly,
299+
...withWake("running"),
300+
...withWake("completed"),
301+
],
302+
});
303+
304+
const fiber = yield* Effect.forkChild(waitForRun(tools, threadId, runId, true));
305+
yield* TestClock.adjust("500 millis");
306+
307+
assert.deepStrictEqual(yield* Fiber.join(fiber), {
308+
type: "ended",
309+
runId: wakeRun,
310+
status: "completed",
311+
});
312+
}),
313+
);
314+
315+
it.effect(
316+
"--wait keeps its own run's result when another client's later run settles the thread",
317+
() =>
318+
Effect.gen(function* () {
319+
const sentRun = RunId.make("run-2");
320+
const { tools } = scriptedTools({
321+
t3_thread_wait: [
322+
{ threadId, runId, status: "completed", timedOut: false },
323+
{
324+
threadId,
325+
runId,
326+
status: "completed",
327+
timedOut: false,
328+
resultRun: { runId: sentRun, status: "failed" },
329+
},
330+
],
331+
t3_thread_read: laterRunReads(sentRun, [{ runId: sentRun, type: "user_message" }]),
332+
});
333+
334+
assert.deepStrictEqual(yield* waitForRun(tools, threadId, runId, true), {
335+
type: "ended",
336+
runId,
337+
status: "completed",
338+
});
339+
}),
340+
);
341+
213342
it.effect("--wait stops when the thread waits for an answer instead of polling forever", () =>
214343
Effect.gen(function* () {
215344
const { tools } = scriptedTools({

0 commit comments

Comments
 (0)