From 2b1021ce411db0f0aade4c513ab2bb4b0cdcaf94 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Sun, 1 Nov 2026 07:06:39 -0600 Subject: [PATCH 001/184] perf(codex): trace app server request latency (#28666) --- .../src/protocol.test.ts | 90 +++++++++++++++++++ .../effect-codex-app-server/src/protocol.ts | 33 ++++--- 2 files changed, 113 insertions(+), 10 deletions(-) diff --git a/packages/effect-codex-app-server/src/protocol.test.ts b/packages/effect-codex-app-server/src/protocol.test.ts index 351f0d2b87731..b4c3ac7b7558b 100644 --- a/packages/effect-codex-app-server/src/protocol.test.ts +++ b/packages/effect-codex-app-server/src/protocol.test.ts @@ -7,6 +7,7 @@ import * as Schema from "effect/Schema"; import * as Sink from "effect/Sink"; import * as Stdio from "effect/Stdio"; import * as Stream from "effect/Stream"; +import * as Tracer from "effect/Tracer"; import * as TestClock from "effect/testing/TestClock"; import * as NodeServices from "@effect/platform-node/NodeServices"; @@ -186,6 +187,95 @@ it.layer(NodeServices.layer)("effect-codex-app-server protocol", (it) => { }), ); + it.effect( + "correlates concurrent request spans through responses, failures and interruption", + () => { + const spans: Array = []; + const tracer = Tracer.make({ + span: (options) => { + const span = new Tracer.NativeSpan(options); + spans.push(span); + return span; + }, + }); + return Effect.gen(function* () { + const { stdio, input, output } = yield* makeInMemoryStdio(); + const transport = yield* CodexProtocol.makeCodexAppServerPatchedProtocol({ stdio }); + const methods = ["model/list", "account/read", "skills/list"]; + const requests = []; + for (const method of methods) { + requests.push( + yield* transport.request(method, { secret: "private-payload" }).pipe(Effect.forkScoped), + ); + yield* Queue.take(output); + } + yield* Queue.offer( + input, + encodeJsonl({ id: 2, error: { code: -32602, message: "Invalid params" } }), + ); + yield* Fiber.await(requests[1]!); + yield* Queue.offer(input, encodeJsonl({ id: 1, result: { secret: "private-result" } })); + yield* Fiber.join(requests[0]!); + yield* Fiber.interrupt(requests[2]!); + // A late response for an interrupted request must not affect the next request. + yield* Queue.offer(input, encodeJsonl({ id: 3, result: {} })); + const next = yield* transport.request("config/read").pipe(Effect.forkScoped); + yield* Queue.take(output); + yield* Queue.offer(input, encodeJsonl({ id: 4, result: {} })); + yield* Fiber.join(next); + for (const [index, method] of [...methods, "config/read"].entries()) { + const request = spans.find( + (span) => + span.name === "CodexAppServerProtocol.request" && + span.attributes.get("rpc.request_id") === index + 1, + ); + assert.isDefined(request); + assert.equal(request!.attributes.get("rpc.method"), method); + assert.equal(request!.attributes.get("rpc.system"), "jsonrpc"); + assert.equal(request!.status._tag, "Ended"); + if (request!.status._tag === "Ended") { + assert.equal( + request!.status.exit._tag, + index === 1 || index === 2 ? "Failure" : "Success", + ); + } + for (const phase of ["enqueue", "awaitResponse"]) { + const child: Tracer.NativeSpan | undefined = spans.find( + (span) => + span.name === `CodexAppServerProtocol.request.${phase}` && + span.parent?._tag === "Some" && + span.parent.value.spanId === request!.spanId, + ); + assert.isDefined(child); + assert.equal(child!.traceId, request!.traceId); + assert.equal(child!.attributes.get("rpc.method"), method); + assert.equal(child!.attributes.get("rpc.request_id"), index + 1); + assert.equal(child!.status._tag, "Ended"); + } + } + const failedSend = yield* transport + .request("thread/start", { value: 1n }) + .pipe(Effect.exit); + assert.equal(failedSend._tag, "Failure"); + const sendSpans = spans.filter((span) => span.attributes.get("rpc.request_id") === 5); + assert.deepEqual( + sendSpans.map((span) => span.name), + ["CodexAppServerProtocol.request", "CodexAppServerProtocol.request.enqueue"], + ); + for (const span of sendSpans) { + assert.equal(span.attributes.get("rpc.method"), "thread/start"); + assert.equal(span.status._tag, "Ended"); + if (span.status._tag === "Ended") assert.equal(span.status.exit._tag, "Failure"); + } + for (const span of spans) { + const attrs = JSON.stringify([...span.attributes]); + assert.notInclude(attrs, "private-payload"); + assert.notInclude(attrs, "private-result"); + } + }).pipe(Effect.withTracer(tracer)); + }, + ); + it.effect.each([1, 7, 1024])( "preserves JSONL framing and UTF-8 across %i-byte input chunks", (chunkSize) => diff --git a/packages/effect-codex-app-server/src/protocol.ts b/packages/effect-codex-app-server/src/protocol.ts index c628079d0b491..fdf0863af0a16 100644 --- a/packages/effect-codex-app-server/src/protocol.ts +++ b/packages/effect-codex-app-server/src/protocol.ts @@ -502,17 +502,30 @@ export const makeCodexAppServerPatchedProtocol = Effect.fn("makeCodexAppServerPa nextRequestId, (current) => [current, current + 1] as const, ); + const attributes = { + "rpc.system": "jsonrpc", + "rpc.method": method, + "rpc.request_id": requestId, + }; + yield* Effect.annotateCurrentSpan(attributes); const deferred = yield* Deferred.make(); - yield* Ref.update(pending, (current) => - new Map(current).set(String(requestId), { deferred, method }), - ); - yield* offerOutgoing({ - id: requestId, - method, - ...(payload !== undefined ? { params: payload } : {}), - }).pipe(Effect.tapError(() => removePending(String(requestId)))); - return yield* Deferred.await(deferred).pipe( - Effect.onInterrupt(() => removePending(String(requestId))), + return yield* Effect.acquireUseRelease( + Ref.update(pending, (current) => + new Map(current).set(String(requestId), { deferred, method }), + ), + () => + Effect.gen(function* () { + yield* offerOutgoing({ + id: requestId, + method, + ...(payload !== undefined ? { params: payload } : {}), + }).pipe(Effect.withSpan("CodexAppServerProtocol.request.enqueue", { attributes })); + // Includes queue/stdin delivery, Codex work and response routing, not just T3 CPU. + return yield* Deferred.await(deferred).pipe( + Effect.withSpan("CodexAppServerProtocol.request.awaitResponse", { attributes }), + ); + }), + () => removePending(String(requestId)), ); }); From 82b10d546c1041d8eff40425f076d61f608d518f Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Sun, 1 Nov 2026 07:21:42 -0600 Subject: [PATCH 002/184] fix(web): align pull request file viewed checkboxes (#28665) --- apps/web/src/components/pullRequest/PullRequestCodeTab.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/components/pullRequest/PullRequestCodeTab.tsx b/apps/web/src/components/pullRequest/PullRequestCodeTab.tsx index 86e2e27b98365..8246fad432b43 100644 --- a/apps/web/src/components/pullRequest/PullRequestCodeTab.tsx +++ b/apps/web/src/components/pullRequest/PullRequestCodeTab.tsx @@ -204,7 +204,7 @@ function FileViewedToggle({ {stat}