The best way to control Claude Code, Codex and more from any computer or phone
fix(server): a publish whose first push fails still shows the new remote (#29688)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>
Alex Southwell committed
Nov 6, 2026 at 04:22 UTC
37f9134bea549a18c6bf798678aabcb87d9cffd4
2 files changed
+98
-2
apps/server/src/ws.test.ts
+92
@@ -4,12 +4,15 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
4
import { assert, it } from "@effect/vitest";
5
import {
6
AuthSessionId,
7
+ AuthSourceControlWriteScope,
8
EnvironmentId,
9
ProjectId,
10
ThreadId,
11
ProviderDriverKind,
12
ProviderInstanceId,
13
+ SourceControlRepositoryError,
14
WS_METHODS,
15
+ WsRpcGroup,
16
WsServerRefreshProvidersRpc,
17
WsSubscribeServerConfigRpc,
18
type OrchestrationV2StoredEvent,
@@ -63,6 +66,7 @@ import * as ModelManifest from "./provider/ModelManifest.ts";
66
import * as Orchestrator from "./orchestration-v2/Orchestrator.ts";
67
import * as OtlpEndpointCheck from "./observability/OtlpEndpointCheck.ts";
68
import * as PairingGrantStore from "./auth/PairingGrantStore.ts";
69
+import * as RpcAuthorization from "./auth/RpcAuthorization.ts";
70
import * as PeerLinkRequests from "./peer/PeerLinkRequests.ts";
71
import * as PeerLinks from "./peer/PeerLinks.ts";
72
import * as PortScanner from "./preview/PortScanner.ts";
@@ -1240,6 +1244,94 @@ it.effect("on-demand clients get provider config without workspace snapshots", (
1244
),
1245
);
1246
1247
+it.effect("a publish whose push fails still refreshes the new remote", () =>
1248
+ Effect.gen(function* () {
1249
+ const refreshes = yield* Queue.unbounded<string>();
1250
+ const exits = yield* Queue.unbounded<string>();
1251
+ const services = Layer.mergeAll(
1252
+ layerUnusedConfigRpcServices,
1253
+ Layer.mock(SourceControlRepositoryService.SourceControlRepositoryService)({
1254
+ publishRepository: (input) =>
1255
+ Effect.fail(
1256
+ new SourceControlRepositoryError({
1257
+ provider: input.provider,
1258
+ operation: "publishRepository",
1259
+ detail: 'Created owner/repo and added it as remote "origin", but the push failed.',
1260
+ }),
1261
+ ),
1262
+ }),
1263
+ Layer.mock(RepositoryIdentityResolver.RepositoryIdentityResolver)({
1264
+ resolve: (cwd, options) =>
1265
+ Queue.offer(refreshes, `identity ${cwd} refresh=${options?.refresh === true}`).pipe(
1266
+ Effect.as(null),
1267
+ ),
1268
+ }),
1269
+ Layer.mock(VcsStatusBroadcaster.VcsStatusBroadcaster)({
1270
+ refreshStatus: (cwd) =>
1271
+ Queue.offer(refreshes, `status ${cwd}`).pipe(Effect.andThen(Effect.die("unused"))),
1272
+ }),
1273
+ Layer.mock(ExternalLauncher.ExternalLauncher)({}),
1274
+ Layer.mock(ProviderRegistry.ProviderRegistry)({}),
1275
+ Layer.mock(UsageLimitSources.UsageLimitSources)({}),
1276
+ Layer.mock(RemoteOpenTargets.RemoteOpenTargets)({}),
1277
+ Layer.mock(DirectEndpoints.DirectEndpoints)({}),
1278
+ Layer.mock(ManagedProjectFolders.ManagedProjectFolders)({ namedProjectsRoot: "/unused" }),
1279
+ Layer.mock(ScratchThreadPromotion.ScratchThreadPromotion)({}),
1280
+ Layer.mock(ServerEnvironment.ServerEnvironment)({}),
1281
+ Layer.mock(EnvironmentAuth.EnvironmentAuth)({}),
1282
+ );
1283
+ const server = yield* RpcServer.makeNoSerialization(WsRpcGroup, {
1284
+ ...WS_RPC_SERVER_OPTIONS,
1285
+ onFromServer: (response) =>
1286
+ response._tag === "Exit" ? Queue.offer(exits, response.exit._tag) : Effect.void,
1287
+ }).pipe(
1288
+ Effect.provide(
1289
+ layerWsRpc(
1290
+ {
1291
+ sessionId: AuthSessionId.make("publish-test"),
1292
+ subject: "publish-test",
1293
+ method: "browser-session-cookie",
1294
+ scopes: [AuthSourceControlWriteScope],
1295
+ },
1296
+ {},
1297
+ yield* ServerBrowser.ServerBrowser,
1298
+ () => Effect.void,
1299
+ { secretReferences: true },
1300
+ ).pipe(
1301
+ Layer.provide(services),
1302
+ Layer.merge(RpcAuthorization.layer([AuthSourceControlWriteScope])),
1303
+ ),
1304
+ ),
1305
+ );
1306
+ yield* server.write(0, {
1307
+ _tag: "Request",
1308
+ id: RpcMessage.RequestId("publish"),
1309
+ tag: WS_METHODS.sourceControlPublishRepository,
1310
+ payload: {
1311
+ cwd: "/repo",
1312
+ provider: "github",
1313
+ repository: "owner/repo",
1314
+ visibility: "private",
1315
+ },
1316
+ headers: Headers.empty,
1317
+ });
1318
+ assert.equal(yield* Queue.take(exits), "Failure");
1319
+ assert.deepEqual(
1320
+ [yield* Queue.take(refreshes), yield* Queue.take(refreshes)],
1321
+ ["identity /repo refresh=true", "status /repo"],
1322
+ );
1323
+ }).pipe(
1324
+ Effect.provide(
1325
+ Layer.mergeAll(
1326
+ Layer.fresh(layerConfigSources),
1327
+ Layer.mock(PreviewAutomationBroker.PreviewAutomationBroker)({}),
1328
+ Layer.mock(ServerBrowser.ServerBrowser)({}),
1329
+ ),
1330
+ ),
1331
+ Effect.scoped,
1332
+ ),
1333
+);
1334
+
1335
// Pruned history cannot be replayed: a cursor below the boundary must resync from a snapshot.
1336
it.effect.each(["thread", "shell"] as const)(
1337
"%s resume from a cursor below the pruned boundary loads a snapshot",
apps/server/src/ws.ts
+6
-2
@@ -2921,8 +2921,12 @@ export const layerWsRpc = (
2921
[WS_METHODS.subscribeProjectClones]: () => projectCloneTracker.stream,
2922
[WS_METHODS.sourceControlPublishRepository]: (input) =>
2923
sourceControlRepositories.publishRepository(input).pipe(
2924
- Effect.tap(() => repositoryIdentityResolver.resolve(input.cwd, { refresh: true })),
2925
- Effect.tap(() => refreshGitStatus(input.cwd)),
2924
+ // A failed push still leaves the new remote added.
2925
+ Effect.ensuring(
2926
+ repositoryIdentityResolver
2927
+ .resolve(input.cwd, { refresh: true })
2928
+ .pipe(Effect.andThen(refreshGitStatus(input.cwd))),
2929
+ ),
2930
),
2931
[WS_METHODS.projectsSearchEntries]: (input) =>
2932
workspaceEntries.search(input).pipe(