fix saving hooks + env vars (#7176)

This commit is contained in:
Prospector
2026-08-17 17:46:32 -07:00
committed by GitHub
parent 1b341a8e07
commit d5556271f9
4 changed files with 51 additions and 43 deletions
@@ -11,7 +11,7 @@ import { computed, ref, watch } from 'vue'
import { edit } from '@/helpers/instance'
import { get } from '@/helpers/settings.ts'
import type { AppSettings, Hooks } from '../../../../helpers/types'
import type { AppSettings } from '../../../../helpers/types'
import { injectInstanceSettings } from './instance-settings-context'
const { handleError } = injectNotificationManager()
@@ -26,23 +26,31 @@ const overrideHooks = ref(
!!instance.value.hooks.wrapper ||
!!instance.value.hooks.post_exit,
)
const hooks = ref(instance.value.hooks ?? globalSettings.hooks)
const editInstanceObject = computed(() => {
const editInstancePatch: {
hooks?: Hooks
} = {}
// When hooks are not overridden per-instance, we want to clear them
editInstancePatch.hooks = overrideHooks.value ? hooks.value : {}
return editInstancePatch
const hooksRaw = instance.value.hooks ?? globalSettings.hooks
const hooks = ref({
pre_launch: hooksRaw.pre_launch ?? '',
wrapper: hooksRaw.wrapper ?? '',
post_exit: hooksRaw.post_exit ?? '',
})
const editInstanceObject = computed(() => ({
hooks: overrideHooks.value
? {
pre_launch: hooks.value.pre_launch ?? '',
wrapper: hooks.value.wrapper ?? '',
post_exit: hooks.value.post_exit ?? '',
}
: {
pre_launch: '',
wrapper: '',
post_exit: '',
},
}))
watch(
[overrideHooks, hooks],
async () => {
await edit(instance.value.id, editInstanceObject.value)
await edit(instance.value.id, editInstanceObject.value).catch(handleError)
},
{ deep: true },
)