Fix CI regressions after branch sync

Co-authored-by: codex <[email protected]>
This commit is contained in:
Julius Marmingeandcodex committed 2026-05-20 13:48:49 +02:00
1 parent 6b48288f77
commit 3ee6fbba2c
9 files changed
+181 -26

No files matched your search

+18
View File
@@ -2602,6 +2602,9 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
cwd: "/tmp/repo",
},
layers: {
vcsDriver: {
isInsideWorkTree: () => Effect.succeed(true),
},
gitManager: {
invalidateLocalStatus: () => Effect.void,
invalidateRemoteStatus: () => Effect.void,
@@ -2738,6 +2741,21 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
createRef: (input) => Effect.succeed({ refName: input.refName }),
switchRef: (input) => Effect.succeed({ refName: input.refName }),
},
vcsStatusBroadcaster: {
refreshStatus: () =>
Effect.succeed({
isRepo: true,
hasPrimaryRemote: true,
isDefaultRef: true,
refName: "main",
hasWorkingTreeChanges: false,
workingTree: { files: [], insertions: 0, deletions: 0 },
hasUpstream: true,
aheadCount: 0,
behindCount: 0,
pr: null,
}),
},
reviewService: {
getDiffPreview: (input) =>
Effect.succeed({
@@ -16,9 +16,15 @@ import {
type ReactNode,
} from "react";
import { LegendList, type LegendListRef } from "@legendapp/list/react";
import { FileDiff } from "@pierre/diffs/react";
import { deriveTimelineEntries, formatElapsed } from "../../session-logic";
import { type TurnDiffSummary } from "../../types";
import { summarizeTurnDiffStats } from "../../lib/turnDiffTree";
import {
getRenderablePatch,
resolveDiffThemeName,
resolveFileDiffPath,
} from "../../lib/diffRendering";
import ChatMarkdown from "../ChatMarkdown";
import {
BotIcon,
@@ -67,6 +73,11 @@ import {
} from "./userMessageTerminalContexts";
import { SkillInlineText } from "./SkillInlineText";
import { formatWorkspaceRelativePath } from "../../filePathDisplay";
import {
buildReviewCommentRenderablePatch,
parseReviewCommentMessageSegments,
type ReviewCommentContext,
} from "../../reviewCommentContext";
// ---------------------------------------------------------------------------
// Context — shared state consumed by every row component via Context.
@@ -837,6 +848,25 @@ const UserMessageBody = memo(function UserMessageBody(props: {
terminalContexts: ParsedTerminalContextEntry[];
skills: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">>;
}) {
const reviewCommentSegments = parseReviewCommentMessageSegments(props.text);
if (reviewCommentSegments.some((segment) => segment.kind === "review-comment")) {
return (
<div className="space-y-3 text-sm leading-relaxed text-foreground">
{reviewCommentSegments.map((segment) =>
segment.kind === "text" ? (
segment.text.trim().length > 0 ? (
<div key={segment.id} className="whitespace-pre-wrap wrap-break-word">
<SkillInlineText text={segment.text.trim()} skills={props.skills} />
</div>
) : null
) : (
<UserMessageReviewCommentCard key={segment.comment.id} comment={segment.comment} />
),
)}
</div>
);
}
if (props.terminalContexts.length > 0) {
const hasEmbeddedInlineLabels = textContainsInlineTerminalContextLabels(
props.text,
@@ -930,6 +960,49 @@ const UserMessageBody = memo(function UserMessageBody(props: {
);
});
function UserMessageReviewCommentCard({ comment }: { comment: ReviewCommentContext }) {
const ctx = use(TimelineRowCtx);
const renderablePatch = getRenderablePatch(
buildReviewCommentRenderablePatch(comment),
`review-comment:${comment.id}`,
);
return (
<div className="space-y-2 rounded-lg border border-border/70 bg-background/70 p-3">
<div className="space-y-1">
<div className="text-xs font-medium text-foreground">
{formatWorkspaceRelativePath(comment.filePath, ctx.workspaceRoot)}
</div>
<div className="text-[11px] text-muted-foreground">
{comment.sectionTitle} · {comment.rangeLabel}
</div>
</div>
{comment.text.length > 0 && (
<div className="whitespace-pre-wrap wrap-break-word text-sm">
<SkillInlineText text={comment.text} skills={ctx.skills} />
</div>
)}
{renderablePatch?.kind === "files" &&
renderablePatch.files.map((fileDiff) => (
<FileDiff
key={resolveFileDiffPath(fileDiff)}
fileDiff={fileDiff}
options={{
collapsed: false,
diffStyle: "unified",
theme: resolveDiffThemeName(ctx.resolvedTheme),
}}
/>
))}
{renderablePatch?.kind === "raw" && (
<pre className="overflow-x-auto rounded-md bg-muted/40 p-2 text-xs">
{renderablePatch.text}
</pre>
)}
</div>
);
}
// ---------------------------------------------------------------------------
// Structural sharing — reuse old row references when data hasn't changed
// so LegendList (and React) can skip re-rendering unchanged items.
+22 -1
View File
@@ -239,7 +239,28 @@ describe("remote environment api", () => {
httpBaseUrl: "https://remote.example.com/",
bearerToken: "bearer-token",
}),
).resolves.toBe("wss://remote.example.com/ws?wsToken=ws-token");
).resolves.toBe("wss://remote.example.com/?wsToken=ws-token");
});
it("preserves the caller-provided websocket path when minting a token", async () => {
const fetchMock = vi.fn().mockResolvedValue(
new Response(
JSON.stringify({
token: "ws-token",
expiresAt: "2026-05-01T12:05:00.000Z",
}),
{ status: 200 },
),
);
globalThis.fetch = fetchMock as typeof fetch;
await expect(
resolveRemoteWebSocketConnectionUrl({
wsBaseUrl: "wss://remote.example.com/custom/socket?existing=1",
httpBaseUrl: "https://remote.example.com/",
bearerToken: "bearer-token",
}),
).resolves.toBe("wss://remote.example.com/custom/socket?existing=1&wsToken=ws-token");
});
});
@@ -72,6 +72,7 @@ function createTestClient() {
clear: vi.fn(async () => undefined),
restart: vi.fn(async () => undefined),
close: vi.fn(async () => undefined),
onEvent: vi.fn(() => () => undefined),
onMetadata: vi.fn(() => () => undefined),
},
projects: {
@@ -269,6 +269,17 @@ describe("retainThreadDetailSubscription", () => {
mockCreateEnvironmentConnection.mockImplementation((input) => {
const reconnect = vi.fn(async () => undefined);
mockConnectionReconnects.push(reconnect);
queueMicrotask(() => {
input.onConfigSnapshot?.({
environment: {
environmentId: input.knownEnvironment.environmentId,
label: input.knownEnvironment.label,
platform: { os: "darwin", arch: "arm64" },
serverVersion: "0.0.0-test",
capabilities: { repositoryIdentity: true },
},
});
});
return {
kind: input.kind,
environmentId: input.knownEnvironment.environmentId,
@@ -438,13 +449,13 @@ describe("retainThreadDetailSubscription", () => {
const stop = startEnvironmentConnectionService(new QueryClient());
savedEnvironmentRegistryListener?.();
await vi.waitFor(() => {
expect(mockCreateEnvironmentConnection).toHaveBeenCalledTimes(2);
expect(
listEnvironmentConnections().some(
(connection) => connection.environmentId === environmentId,
),
).toBe(true);
});
const createConnectionCallsBeforeReconnect = mockCreateEnvironmentConnection.mock.calls.length;
const release = retainThreadDetailSubscription(environmentId, threadId);
expect(mockSubscribeThread).toHaveBeenCalledTimes(1);
@@ -459,7 +470,9 @@ describe("retainThreadDetailSubscription", () => {
await vi.advanceTimersByTimeAsync(200);
await reconnectPromise;
await vi.waitFor(() => {
expect(mockCreateEnvironmentConnection).toHaveBeenCalledTimes(3);
expect(mockCreateEnvironmentConnection).toHaveBeenCalledTimes(
createConnectionCallsBeforeReconnect + 1,
);
expect(mockSubscribeThread).toHaveBeenCalledTimes(2);
});
@@ -486,6 +499,33 @@ describe("retainThreadDetailSubscription", () => {
const { resetEnvironmentServiceForTests, startEnvironmentConnectionService } =
await import("./service");
mockCreateEnvironmentConnection.mockImplementation((input) => {
const reconnect = vi.fn(async () => undefined);
mockConnectionReconnects.push(reconnect);
queueMicrotask(() => {
input.onConfigSnapshot?.({
environment: {
environmentId: input.knownEnvironment.environmentId,
label: input.knownEnvironment.label,
platform: { os: "darwin", arch: "arm64" },
serverVersion: "0.0.0-test",
capabilities: { repositoryIdentity: true },
},
});
});
return {
kind: input.kind,
environmentId: input.knownEnvironment.environmentId,
knownEnvironment: input.knownEnvironment,
client: {
...input.client,
isHeartbeatFresh: vi.fn(() => true),
},
ensureBootstrapped: vi.fn(async () => undefined),
reconnect,
dispose: vi.fn(async () => undefined),
};
});
const stop = startEnvironmentConnectionService(new QueryClient());
expect(mockConnectionReconnects).toHaveLength(1);
+4 -9
View File
@@ -242,15 +242,10 @@ describe("WsTransport (web instrumentation)", () => {
socket.close(1012, "service restart");
await waitFor(() => {
expect(onClose).toHaveBeenCalledWith(
{
code: 1012,
reason: "service restart",
},
{
intentional: false,
},
);
expect(onClose).toHaveBeenCalledWith({
code: 1012,
reason: "service restart",
});
expect(getWsConnectionStatus()).toMatchObject({
attemptCount: 2,
closeReason: "service restart",
@@ -645,8 +645,8 @@ describe("WsTransport", () => {
});
it("does not retry stream subscriptions after application-level failures", async () => {
const transport = createTransport("ws://localhost:3020");
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => undefined);
const warnSpy = vi.fn();
const transport = createTransport("ws://localhost:3020", undefined, { logWarning: warnSpy });
let attempts = 0;
const unsubscribe = transport.subscribe(
@@ -684,8 +684,8 @@ describe("WsTransport", () => {
});
it("keeps retrying stream subscriptions after transport failures", async () => {
const transport = createTransport("ws://localhost:3020");
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => undefined);
const warnSpy = vi.fn();
const transport = createTransport("ws://localhost:3020", undefined, { logWarning: warnSpy });
let attempts = 0;
const unsubscribe = transport.subscribe(
@@ -717,8 +717,8 @@ describe("WsTransport", () => {
});
it("logs a transport disconnect once even when multiple subscriptions fail together", async () => {
const transport = createTransport("ws://localhost:3020");
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => undefined);
const warnSpy = vi.fn();
const transport = createTransport("ws://localhost:3020", undefined, { logWarning: warnSpy });
const unsubscribeA = transport.subscribe(
() => Stream.fail(new Error("SocketCloseError: 1006")),
+14 -8
View File
@@ -31,6 +31,7 @@ export interface WsTransportOptions {
url: WsRpcProtocolSocketUrlProvider,
lifecycleHandlers?: WsProtocolLifecycleHandlers,
) => Layer.Layer<RpcClient.Protocol, never, never>;
readonly logWarning?: (message: string, metadata: { readonly error: string }) => void;
/**
* Invoked at the start of {@link WsTransport.reconnect} before the session is replaced.
*/
@@ -172,18 +173,14 @@ export class WsTransport {
const formattedError = formatErrorMessage(error);
if (!isTransportConnectionErrorMessage(formattedError)) {
Effect.runSync(
Effect.logWarning("WebSocket RPC subscription failed", { error: formattedError }),
);
this.logWarning("WebSocket RPC subscription failed", { error: formattedError });
return;
}
if (!this.hasReportedTransportDisconnect) {
Effect.runSync(
Effect.logWarning("WebSocket RPC subscription disconnected", {
error: formattedError,
}),
);
this.logWarning("WebSocket RPC subscription disconnected", {
error: formattedError,
});
}
this.hasReportedTransportDisconnect = true;
await sleep(retryDelayMs);
@@ -252,6 +249,15 @@ export class WsTransport {
};
}
private logWarning(message: string, metadata: { readonly error: string }) {
const logWarning = this.options?.logWarning;
if (logWarning) {
logWarning(message, metadata);
} else {
Effect.runSync(Effect.logWarning(message, metadata));
}
}
private runStreamOnSession<TValue>(
session: TransportSession,
connect: (client: WsRpcProtocolClient) => Stream.Stream<TValue, Error, never>,
+1
View File
@@ -44,6 +44,7 @@ describe("TerminalOpenInput", () => {
expect(
decodes(TerminalOpenInput, {
threadId: "thread-1",
terminalId: DEFAULT_TERMINAL_ID,
cwd: "/tmp/project",
cols: 423,
rows: 40,