1+ import { getAuthenticatedClient } from "@features/auth/hooks/authClient" ;
12import { useGitQueries } from "@features/git-interaction/hooks/useGitQueries" ;
23import { computeGitInteractionState } from "@features/git-interaction/state/gitInteractionLogic" ;
34import {
@@ -19,6 +20,7 @@ import { getSuggestedBranchName } from "@features/git-interaction/utils/getSugge
1920import { invalidateGitBranchQueries } from "@features/git-interaction/utils/gitCacheKeys" ;
2021import { partitionByStaged } from "@features/git-interaction/utils/partitionByStaged" ;
2122import { updateGitCacheFromSnapshot } from "@features/git-interaction/utils/updateGitCache" ;
23+ import { useSessionStore } from "@features/sessions/stores/sessionStore" ;
2224import { trpc , trpcClient } from "@renderer/trpc" ;
2325import type { ChangedFile } from "@shared/types" ;
2426import { ANALYTICS_EVENTS } from "@shared/types/analytics" ;
@@ -115,6 +117,21 @@ function trackGitAction(
115117 } ) ;
116118}
117119
120+ function attachPrUrlToTask ( taskId : string , prUrl : string ) {
121+ const taskRunId = useSessionStore . getState ( ) . taskIdIndex [ taskId ] ;
122+ if ( ! taskRunId ) return ;
123+
124+ getAuthenticatedClient ( )
125+ . then ( ( client ) =>
126+ client ?. updateTaskRun ( taskId , taskRunId , {
127+ output : { pr_url : prUrl } ,
128+ } ) ,
129+ )
130+ . catch ( ( err ) =>
131+ log . warn ( "Failed to attach PR URL to task" , { taskId, prUrl, err } ) ,
132+ ) ;
133+ }
134+
118135export function useGitInteraction (
119136 taskId : string ,
120137 repoPath ?: string ,
@@ -255,6 +272,7 @@ export function useGitInteraction(
255272
256273 if ( result . prUrl ) {
257274 await trpcClient . os . openExternal . mutate ( { url : result . prUrl } ) ;
275+ attachPrUrlToTask ( taskId , result . prUrl ) ;
258276 }
259277
260278 modal . closeCreatePr ( ) ;
0 commit comments