@@ -32,7 +32,6 @@ import {
3232 ChevronDownIcon ,
3333 CloudDownloadIcon ,
3434 CloudUploadIcon ,
35- ExternalLinkIcon ,
3635 GitBranchPlusIcon ,
3736 GitCommitIcon ,
3837 InfoIcon ,
@@ -97,9 +96,9 @@ import { vcsEnvironment } from "~/state/vcs";
9796import { randomUUID } from "~/lib/utils" ;
9897import { resolvePathLinkTarget } from "~/terminal-links" ;
9998import { type DraftId , useComposerDraftStore } from "~/composerDraftStore" ;
100- import { readLocalApi } from "~/localApi" ;
10199import { getSourceControlPresentation } from "~/sourceControlPresentation" ;
102- import { openPullRequestLink , useOpenPrLink } from "~/lib/openPullRequestLink" ;
100+ import { useOpenLink } from "~/browser/useOpenLink" ;
101+ import { useOpenPrLink } from "~/lib/openPullRequestLink" ;
103102
104103interface GitActionsControlProps {
105104 gitCwd : string | null ;
@@ -384,10 +383,13 @@ interface PublishRepositoryDialogProps {
384383 readonly open : boolean ;
385384 readonly onOpenChange : ( open : boolean ) => void ;
386385 readonly environmentId : ScopedThreadRef [ "environmentId" ] | null ;
386+ /** Thread the dialog was opened from, so the new repository can open beside it. */
387+ readonly threadRef : ScopedThreadRef | null ;
387388 readonly gitCwd : string ;
388389}
389390
390391function PublishRepositoryDialog ( props : PublishRepositoryDialogProps ) {
392+ const openLink = useOpenLink ( props . threadRef ) ;
391393 const navigate = useNavigate ( ) ;
392394 const sourceControlDiscovery = useEnvironmentQuery (
393395 props . environmentId === null
@@ -911,12 +913,9 @@ function PublishRepositoryDialog(props: PublishRepositoryDialogProps) {
911913 size = "sm"
912914 className = "w-full"
913915 onClick = { ( ) => {
914- const api = readLocalApi ( ) ;
915- if ( ! api ) return ;
916- void api . shell . openExternal ( publishResult . repository . url ) ;
916+ void openLink ( publishResult . repository . url ) . catch ( ( ) => undefined ) ;
917917 } }
918918 >
919- < ExternalLinkIcon className = "size-3.5" aria-hidden />
920919 Open on { publishProviderLabel }
921920 </ Button >
922921 </ >
@@ -1004,6 +1003,7 @@ export default function GitActionsControl({
10041003 [ activeThreadRef ] ,
10051004 ) ;
10061005 const openPrLink = useOpenPrLink ( activeThreadRef ?? undefined ) ;
1006+ const openLink = useOpenLink ( activeThreadRef ) ;
10071007 const activeDraftThread = useComposerDraftStore ( ( store ) =>
10081008 draftId
10091009 ? store . getDraftSession ( draftId )
@@ -1238,15 +1238,6 @@ export default function GitActionsControl({
12381238 onOpenPullRequest ( openPr . number ) ;
12391239 return ;
12401240 }
1241- const api = readLocalApi ( ) ;
1242- if ( ! api ) {
1243- toastManager . add ( {
1244- type : "error" ,
1245- title : "Link opening is unavailable." ,
1246- data : threadToastData ,
1247- } ) ;
1248- return ;
1249- }
12501241 const prUrl = openPr ?. url ?? null ;
12511242 if ( ! prUrl ) {
12521243 toastManager . add ( {
@@ -1256,7 +1247,7 @@ export default function GitActionsControl({
12561247 } ) ;
12571248 return ;
12581249 }
1259- void openPullRequestLink ( api . shell , prUrl ) . catch ( ( err : unknown ) => {
1250+ void openLink ( prUrl ) . catch ( ( err : unknown ) => {
12601251 console . error ( err ) ;
12611252 toastManager . add (
12621253 stackedThreadToast ( {
@@ -1267,7 +1258,7 @@ export default function GitActionsControl({
12671258 } ) ,
12681259 ) ;
12691260 } ) ;
1270- } , [ gitStatusForActions , onOpenPullRequest , threadToastData ] ) ;
1261+ } , [ gitStatusForActions , onOpenPullRequest , openLink , threadToastData ] ) ;
12711262
12721263 runGitActionWithToast = useEffectEvent (
12731264 async ( {
@@ -2010,6 +2001,7 @@ export default function GitActionsControl({
20102001 open = { isPublishDialogOpen }
20112002 onOpenChange = { setIsPublishDialogOpen }
20122003 environmentId = { activeEnvironmentId }
2004+ threadRef = { activeThreadRef }
20132005 gitCwd = { gitCwd }
20142006 />
20152007
0 commit comments