@@ -26,7 +26,6 @@ import {
2626 v2PullRequestThread ,
2727} from "../../../orchestration-v2/testkit/pullRequestFixtures.ts" ;
2828import * as ProjectService from "../../../project/ProjectService.ts" ;
29- import * as PullRequestService from "../../../pullRequest/PullRequestService.ts" ;
3029import * as PullRequestReviewGuideService from "../../../pullRequest/PullRequestReviewGuideService.ts" ;
3130import * as McpInvocationContext from "../../McpInvocationContext.ts" ;
3231import * as McpToolAccess from "../../McpToolAccess.ts" ;
@@ -147,7 +146,6 @@ const gitlabProject = makeProject({
147146interface HarnessOptions {
148147 readonly thread ?: PullRequestTestThread | null ;
149148 readonly project ?: OrchestrationProjectShell | null ;
150- readonly detail ?: PullRequestService . PullRequestService [ "Service" ] [ "detail" ] ;
151149 readonly reject ?: ( command : OrchestrationCommand ) => string | null ;
152150 readonly projects ?: ReadonlyArray < OrchestrationProjectShell > ;
153151 readonly generate ?: (
@@ -164,7 +162,6 @@ const makeHarness = Effect.fn("makePullRequestsToolkitHarness")(function* (
164162 options : HarnessOptions = { } ,
165163) {
166164 const commands = yield * Ref . make < ReadonlyArray < OrchestrationCommand > > ( [ ] ) ;
167- const detailRequests = yield * Ref . make < ReadonlyArray < PullRequestService . PullRequestRef > > ( [ ] ) ;
168165 const guideRequests = yield * Ref . make < ReadonlyArray < PullRequestRef > > ( [ ] ) ;
169166 const thread = options . thread === undefined ? makeThread ( [ ] ) : options . thread ;
170167 const project = options . project === undefined ? makeProject ( ) : options . project ;
@@ -185,12 +182,6 @@ const makeHarness = Effect.fn("makePullRequestsToolkitHarness")(function* (
185182 getShell : ( ) => Effect . succeed ( Option . fromNullishOr ( project ) ) ,
186183 listShells : ( ) => Effect . succeed ( options . projects ?? ( project ? [ project ] : [ ] ) ) ,
187184 } ) ,
188- Layer . mock ( PullRequestService . PullRequestService ) ( {
189- detail : ( input ) =>
190- Ref . update ( detailRequests , ( recorded ) => [ ...recorded , input ] ) . pipe (
191- Effect . andThen ( options . detail ?.( input ) ?? Effect . die ( "Unexpected pull request read" ) ) ,
192- ) ,
193- } ) ,
194185 Layer . mock ( PullRequestReviewGuideService . PullRequestReviewGuideService ) ( {
195186 get : ( ) => Effect . succeed ( NO_GUIDE ) ,
196187 generate : ( input ) =>
@@ -238,7 +229,7 @@ const makeHarness = Effect.fn("makePullRequestsToolkitHarness")(function* (
238229 Effect . provideService ( McpInvocationContext . McpInvocationContext , invocation ( capabilities ) ) ,
239230 Effect . provide ( layerDependencies ) ,
240231 ) ;
241- return { commands, detailRequests , guideRequests, call } ;
232+ return { commands, guideRequests, call } ;
242233} ) ;
243234
244235describe ( "pull request toolkit handlers" , ( ) => {
@@ -442,106 +433,23 @@ describe("pull request toolkit handlers", () => {
442433 } ) ,
443434 ) ;
444435
445- it . effect ( "resolves repository-only GitLab links and watches to the actual MR URL " , ( ) =>
436+ it . effect ( "keeps a GitLab repository selector raw and carries an existing link to a watch " , ( ) =>
446437 Effect . gen ( function * ( ) {
447- const url = "http://code.example:8924/gitlab/gitlab/team/subgroup/project/-/merge_requests/1" ;
448438 const target = { repository : "gitlab/team/subgroup/project" , number : 1 } ;
449- const harness = yield * makeHarness ( {
450- project : gitlabProject ,
451- detail : ( ) =>
452- Effect . succeed ( {
453- ...target ,
454- provider : SourceControlProviderKind . make ( "gitlab" ) ,
455- capabilities : {
456- diff : true ,
457- comment : true ,
458- actions : [ ] ,
459- mergeMethods : [ ] ,
460- search : false ,
461- review : { inlineComment : false , reply : false , resolve : false , verdicts : [ ] } ,
462- reviewers : { request : false , listCandidates : false } ,
463- } ,
464- viewerPermissions : {
465- actions : [ ] ,
466- comment : true ,
467- resolve : false ,
468- verdicts : [ ] ,
469- requestReviewers : false ,
470- } ,
471- projectId : PROJECT_ID ,
472- projectTitle : "GitLab" ,
473- workspaceRoot : "/workspace/project" ,
474- title : "Project 2 MR" ,
475- body : "" ,
476- url,
477- author : null ,
478- state : "open" ,
479- isDraft : false ,
480- mergeability : "mergeable" ,
481- additions : 0 ,
482- deletions : 0 ,
483- changedFiles : 0 ,
484- headBranch : "feature" ,
485- baseBranch : "main" ,
486- createdAt : "2026-10-19T00:00:00.000Z" ,
487- updatedAt : "2026-10-19T00:00:00.000Z" ,
488- mergedAt : null ,
489- closedAt : null ,
490- reviewers : [ ] ,
491- labels : [ ] ,
492- checks : [ ] ,
493- mergeCapabilities : { merge : true , squash : false , rebase : false } ,
494- } ) ,
495- } ) ;
496- const linked = yield * harness . call ( "link_pull_request" , target ) ;
497- const watched = yield * harness . call ( "watch_pull_request" , target ) ;
498- expect ( [ linked . url , watched . url ] ) . toEqual ( [ url , url ] ) ;
499- expect ( yield * Ref . get ( harness . detailRequests ) ) . toEqual ( [
500- { projectId : PROJECT_ID , host : "code.example" , ...target } ,
501- { projectId : PROJECT_ID , host : "code.example" , ...target } ,
502- ] ) ;
503- expect ( yield * Ref . get ( harness . commands ) ) . toMatchObject ( [
504- { type : "thread.pull-request.link" , ...target , url, repositoryWebUrl : url } ,
505- {
506- type : "thread.pull-request.watch" ,
507- ...target ,
508- link : { url, repositoryWebUrl : url , source : "agent" } ,
509- } ,
510- ] ) ;
511- } ) ,
512- ) ;
439+ const harness = yield * makeHarness ( { project : gitlabProject } ) ;
440+ yield * harness . call ( "link_pull_request" , target ) ;
441+ const [ link ] = yield * Ref . get ( harness . commands ) ;
442+ expect ( link ) . toMatchObject ( { type : "thread.pull-request.link" , ...target } ) ;
443+ expect ( link ) . not . toHaveProperty ( "repositoryWebUrl" ) ;
513444
514- it . effect ( "requires GitLab URL resolution only when creating a link or watch" , ( ) =>
515- Effect . gen ( function * ( ) {
516- const harness = yield * makeHarness ( {
517- project : gitlabProject ,
518- detail : ( ) =>
519- Effect . fail ( new PullRequestOperationError ( { operation : "detail" , detail : "host down" } ) ) ,
520- } ) ;
521- const target = { repository : "gitlab/team/subgroup/project" , number : 1 } ;
522- const linked = yield * harness . call ( "link_pull_request" , target ) . pipe ( Effect . result ) ;
523- const watched = yield * harness . call ( "watch_pull_request" , target ) . pipe ( Effect . result ) ;
524- expect ( yield * Ref . get ( harness . commands ) ) . toEqual ( [ ] ) ;
525- expect ( linked ) . toMatchObject ( {
526- _tag : "Failure" ,
527- failure : { _tag : "PullRequestLinkFailedError" } ,
528- } ) ;
529- expect ( watched ) . toMatchObject ( {
530- _tag : "Failure" ,
531- failure : { _tag : "PullRequestWatchFailedError" } ,
532- } ) ;
533-
534- const url = "http://code.example:8924/gitlab/gitlab/team/subgroup/project/-/merge_requests/1" ;
445+ const url = "http://code.example:8924/gitlab/team/subgroup/project/-/merge_requests/1" ;
535446 const existing = yield * makeHarness ( {
536447 project : gitlabProject ,
537448 thread : makeThread ( [
538449 makeLink ( 1 , { ...target , host : "code.example" , url, repositoryWebUrl : url } ) ,
539450 ] ) ,
540- detail : ( ) =>
541- Effect . fail ( new PullRequestOperationError ( { operation : "detail" , detail : "host down" } ) ) ,
542451 } ) ;
543- const result = yield * existing . call ( "watch_pull_request" , target ) . pipe ( Effect . result ) ;
544- expect ( yield * Ref . get ( existing . detailRequests ) ) . toEqual ( [ ] ) ;
452+ const result = yield * existing . call ( "watch_pull_request" , target ) ;
545453 expect ( yield * Ref . get ( existing . commands ) ) . toMatchObject ( [
546454 {
547455 type : "thread.pull-request.watch" ,
@@ -552,11 +460,11 @@ describe("pull request toolkit handlers", () => {
552460 link : { url, repositoryWebUrl : url , source : "agent" } ,
553461 } ,
554462 ] ) ;
555- expect ( result ) . toMatchObject ( { _tag : "Success" , success : { url } } ) ;
463+ expect ( result . url ) . toBe ( url ) ;
556464 } ) ,
557465 ) ;
558466
559- it . effect ( "builds other hosts' URLs without reading the project's GitLab " , ( ) =>
467+ it . effect ( "builds the URL in the project host 's own shape " , ( ) =>
560468 Effect . gen ( function * ( ) {
561469 const harness = yield * makeHarness ( {
562470 project : makeProject ( {
@@ -570,6 +478,12 @@ describe("pull request toolkit handlers", () => {
570478 displayName : "group/sub/project" ,
571479 } ) ,
572480 } ) ;
481+ const result = yield * harness . call ( "link_pull_request" , {
482+ repository : "group/sub/project" ,
483+ number : 42 ,
484+ } ) ;
485+ expect ( result . url ) . toBe ( "https://gitlab.com/group/sub/project/-/merge_requests/42" ) ;
486+ expect ( result . host ) . toBe ( "gitlab.com" ) ;
573487 const other = yield * harness . call ( "link_pull_request" , {
574488 host : "gitlab.example.test" ,
575489 repository : "team/repo" ,
0 commit comments