@@ -10,6 +10,10 @@ import { type Ref, watch } from 'vue'
1010import { useRouter } from 'vue-router'
1111
1212import { useAppSettings } from '@/composables/use-app-settings.ts'
13+ import {
14+ enableInstallJobSandbox ,
15+ type InstallSandboxChoice ,
16+ } from '@/features/sandbox/enable-instance-sandbox'
1317import { get_user } from '@/helpers/cache'
1418import { toError } from '@/helpers/errors'
1519import {
@@ -28,7 +32,7 @@ import type { AppNotification, SharedInstanceInvite } from './shared-instance-in
2832type InstallModal = {
2933 show (
3034 preview : Awaited < ReturnType < typeof install_get_shared_instance_preview > > ,
31- install : ( ) => Promise < void > ,
35+ install : ( choice : InstallSandboxChoice ) => Promise < void > ,
3236 creator ?: SharedInstanceCreator ,
3337 ) : void
3438}
@@ -69,7 +73,7 @@ export function useSharedInstanceInviteHandler(
6973 | {
7074 instanceId : string
7175 preview : Awaited < ReturnType < typeof install_get_shared_instance_preview > >
72- install : ( ) => Promise < void >
76+ install : ( choice : InstallSandboxChoice ) => Promise < void >
7377 creator ?: SharedInstanceCreator
7478 onGoToInstance ?: ( ) => void | Promise < void >
7579 }
@@ -104,17 +108,17 @@ export function useSharedInstanceInviteHandler(
104108
105109 function showInstall (
106110 preview : Awaited < ReturnType < typeof install_get_shared_instance_preview > > ,
107- install : ( ) => Promise < void > ,
111+ install : ( choice : InstallSandboxChoice ) => Promise < void > ,
108112 creator ?: SharedInstanceCreator ,
109113 ) {
110114 if ( ! installModal . value ) throw new Error ( 'Shared instance install modal is not available.' )
111115 const generation = notificationGeneration
112116 installModal . value . show (
113117 preview ,
114- async ( ) => {
118+ async ( choice ) => {
115119 if ( generation !== notificationGeneration ) return
116120 try {
117- await install ( )
121+ await install ( choice )
118122 } catch ( error ) {
119123 notifySharedInstanceError ( error )
120124 throw error
@@ -127,7 +131,7 @@ export function useSharedInstanceInviteHandler(
127131 async function showInstallOrAlreadyInstalled (
128132 sharedInstanceId : string ,
129133 preview : Awaited < ReturnType < typeof install_get_shared_instance_preview > > ,
130- install : ( ) => Promise < void > ,
134+ install : ( choice : InstallSandboxChoice ) => Promise < void > ,
131135 creator ?: SharedInstanceCreator ,
132136 onGoToInstance ?: ( ) => void | Promise < void > ,
133137 ) {
@@ -195,9 +199,9 @@ export function useSharedInstanceInviteHandler(
195199 await showInstallOrAlreadyInstalled (
196200 invite . sharedInstanceId ,
197201 preview ,
198- async ( ) => {
202+ async ( { sandbox } ) => {
199203 await install_accept_pending_shared_instance_invite ( invite . sharedInstanceId )
200- await install_shared_instance (
204+ const job = await install_shared_instance (
201205 invite . sharedInstanceId ,
202206 invite . sharedInstanceName ,
203207 invite . invitedById ,
@@ -206,6 +210,7 @@ export function useSharedInstanceInviteHandler(
206210 invite . instanceIconUrl ,
207211 invite . instanceIconConfig ,
208212 )
213+ if ( sandbox ) await enableInstallJobSandbox ( job )
209214 await markNotificationRead ( notification ) . catch ( ( error ) => handleError ( toError ( error ) ) )
210215 await queryClient . invalidateQueries ( { queryKey : [ 'instances' ] } )
211216 } ,
@@ -301,9 +306,9 @@ export function useSharedInstanceInviteHandler(
301306 await showInstallOrAlreadyInstalled (
302307 invite . sharedInstanceId ,
303308 invite . preview ,
304- async ( ) => {
309+ async ( { sandbox } ) => {
305310 await install_accept_shared_instance_invite ( invite . sharedInstanceId , inviteId )
306- await install_shared_instance (
311+ const job = await install_shared_instance (
307312 invite . sharedInstanceId ,
308313 invite . preview . name ,
309314 invite . managerId ,
@@ -312,6 +317,7 @@ export function useSharedInstanceInviteHandler(
312317 invite . instanceIconUrl ,
313318 invite . instanceIconConfig ,
314319 )
320+ if ( sandbox ) await enableInstallJobSandbox ( job )
315321 await queryClient . invalidateQueries ( { queryKey : [ 'instances' ] } )
316322 } ,
317323 invite . inviter
0 commit comments