@@ -3,12 +3,15 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
33import { assert , it } from "@effect/vitest" ;
44import {
55 AuthSessionId ,
6+ AuthSourceControlWriteScope ,
67 EnvironmentId ,
8+ GitManagerError ,
79 ProjectId ,
810 ThreadId ,
911 ProviderDriverKind ,
1012 ProviderInstanceId ,
1113 WS_METHODS ,
14+ WsRpcGroup ,
1215 WsServerRefreshProvidersRpc ,
1316 WsSubscribeServerConfigRpc ,
1417 type OrchestrationV2StoredEvent ,
@@ -58,6 +61,7 @@ import * as ModelManifest from "./provider/ModelManifest.ts";
5861import * as Orchestrator from "./orchestration-v2/Orchestrator.ts" ;
5962import * as OtlpEndpointCheck from "./observability/OtlpEndpointCheck.ts" ;
6063import * as PairingGrantStore from "./auth/PairingGrantStore.ts" ;
64+ import * as RpcAuthorization from "./auth/RpcAuthorization.ts" ;
6165import * as PeerLinkRequests from "./peer/PeerLinkRequests.ts" ;
6266import * as PeerLinks from "./peer/PeerLinks.ts" ;
6367import * as PortScanner from "./preview/PortScanner.ts" ;
@@ -1035,6 +1039,73 @@ it.effect("on-demand clients get provider config without workspace snapshots", (
10351039 ) ,
10361040) ;
10371041
1042+ it . effect ( "a git action that fails partway still refreshes the repository status" , ( ) =>
1043+ Effect . gen ( function * ( ) {
1044+ const failure = new GitManagerError ( { operation : "test" , cwd : "/repo" , detail : "push failed" } ) ;
1045+ const refreshed = yield * Deferred . make < string > ( ) ;
1046+ const exits = yield * Queue . unbounded < string > ( ) ;
1047+ const services = Layer . mergeAll (
1048+ layerUnusedConfigRpcServices ,
1049+ Layer . mock ( GitWorkflowService . GitWorkflowService ) ( {
1050+ runStackedAction : ( ) => Effect . fail ( failure ) ,
1051+ } ) ,
1052+ Layer . mock ( VcsStatusBroadcaster . VcsStatusBroadcaster ) ( {
1053+ refreshStatus : ( cwd ) =>
1054+ Deferred . succeed ( refreshed , cwd ) . pipe ( Effect . andThen ( Effect . fail ( failure ) ) ) ,
1055+ } ) ,
1056+ Layer . mock ( ExternalLauncher . ExternalLauncher ) ( { } ) ,
1057+ Layer . mock ( ProviderRegistry . ProviderRegistry ) ( { } ) ,
1058+ Layer . mock ( UsageLimitSources . UsageLimitSources ) ( { } ) ,
1059+ Layer . mock ( RemoteOpenTargets . RemoteOpenTargets ) ( { } ) ,
1060+ Layer . mock ( DirectEndpoints . DirectEndpoints ) ( { } ) ,
1061+ Layer . mock ( ManagedProjectFolders . ManagedProjectFolders ) ( { namedProjectsRoot : "/unused" } ) ,
1062+ Layer . mock ( ScratchThreadPromotion . ScratchThreadPromotion ) ( { } ) ,
1063+ Layer . mock ( ServerEnvironment . ServerEnvironment ) ( { } ) ,
1064+ Layer . mock ( EnvironmentAuth . EnvironmentAuth ) ( { } ) ,
1065+ ) ;
1066+ const server = yield * RpcServer . makeNoSerialization ( WsRpcGroup , {
1067+ ...WS_RPC_SERVER_OPTIONS ,
1068+ onFromServer : ( response ) =>
1069+ response . _tag === "Exit" ? Queue . offer ( exits , response . exit . _tag ) : Effect . void ,
1070+ } ) . pipe (
1071+ Effect . provide (
1072+ layerWsRpc (
1073+ {
1074+ sessionId : AuthSessionId . make ( "git-test" ) ,
1075+ subject : "git-test" ,
1076+ method : "browser-session-cookie" ,
1077+ scopes : [ AuthSourceControlWriteScope ] ,
1078+ } ,
1079+ { } ,
1080+ yield * ServerBrowser . ServerBrowser ,
1081+ ( ) => Effect . void ,
1082+ ) . pipe (
1083+ Layer . provide ( services ) ,
1084+ Layer . merge ( RpcAuthorization . layer ( [ AuthSourceControlWriteScope ] ) ) ,
1085+ ) ,
1086+ ) ,
1087+ ) ;
1088+ yield * server . write ( 0 , {
1089+ _tag : "Request" ,
1090+ id : RpcMessage . RequestId ( "git" ) ,
1091+ tag : WS_METHODS . gitRunStackedAction ,
1092+ payload : { actionId : "action" , cwd : "/repo" , action : "commit_push" } ,
1093+ headers : Headers . empty ,
1094+ } ) ;
1095+ assert . equal ( yield * Queue . take ( exits ) , "Failure" ) ;
1096+ assert . equal ( yield * Deferred . await ( refreshed ) , "/repo" ) ;
1097+ } ) . pipe (
1098+ Effect . provide (
1099+ Layer . mergeAll (
1100+ Layer . fresh ( layerConfigSources ) ,
1101+ Layer . mock ( PreviewAutomationBroker . PreviewAutomationBroker ) ( { } ) ,
1102+ Layer . mock ( ServerBrowser . ServerBrowser ) ( { } ) ,
1103+ ) ,
1104+ ) ,
1105+ Effect . scoped ,
1106+ ) ,
1107+ ) ;
1108+
10381109// Compaction keeps the oldest and newest event per message, so a cursor older
10391110// than the deleted rows still replays each message where the client would
10401111// first have seen it (reducers append on first sight) and reaches the same
0 commit comments