From 1f874d6da3e5db4d0c61294fc6920eaee23ee6c8 Mon Sep 17 00:00:00 2001 From: Samuel K Date: Fri, 22 May 2026 19:34:59 -0500 Subject: [PATCH] fix(provider): persist options without running init The set-options CLI command ran provider init after saving options. If init failed (e.g. SSH unreachable), the config was never written so options appeared to vanish on re-open. Add --skip-init flag to set-options and use it from the desktop IPC handler so options persist independently of init success. Also refresh the providers store after saving so the UI reflects the new values immediately. --- cmd/provider/set_options.go | 7 +++++-- desktop/src/main/ipc.ts | 2 +- .../src/lib/components/provider/ProviderSheet.svelte | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cmd/provider/set_options.go b/cmd/provider/set_options.go index 82ad580b3..e11b24f38 100644 --- a/cmd/provider/set_options.go +++ b/cmd/provider/set_options.go @@ -17,7 +17,8 @@ import ( type SetOptionsCmd struct { *flags.GlobalFlags - Dry bool + Dry bool + SkipInit bool Reconfigure bool SingleMachine bool @@ -55,6 +56,8 @@ func NewSetOptionsCmd(f *flags.GlobalFlags) *cobra.Command { StringArrayVarP(&cmd.Options, "option", "o", []string{}, "Provider option in the form KEY=VALUE") setOptionsCmd.Flags(). BoolVar(&cmd.Dry, "dry", false, "Dry will not persist the options to file and instead return the new filled options") + setOptionsCmd.Flags(). + BoolVar(&cmd.SkipInit, "skip-init", false, "If true will skip running the provider init command") return setOptionsCmd } @@ -86,7 +89,7 @@ func (cmd *SetOptionsCmd) Run(ctx context.Context, args []string) error { UserOptions: cmd.Options, Reconfigure: cmd.Reconfigure, SkipRequired: cmd.Dry, - SkipInit: cmd.Dry, + SkipInit: cmd.Dry || cmd.SkipInit, SkipSubOptions: false, SingleMachine: &cmd.SingleMachine, }) diff --git a/desktop/src/main/ipc.ts b/desktop/src/main/ipc.ts index 885e2157d..fddced78d 100644 --- a/desktop/src/main/ipc.ts +++ b/desktop/src/main/ipc.ts @@ -126,7 +126,7 @@ export function registerIpcHandlers(deps: IpcDependencies): { tunnelProcesses: M ipcMain.handle( "provider_set_options", async (_event, args: { name: string; options: string[] }) => { - const cliArgs = ["provider", "set-options", args.name] + const cliArgs = ["provider", "set-options", args.name, "--skip-init"] for (const opt of args.options) { cliArgs.push("-o", opt) } diff --git a/desktop/src/renderer/src/lib/components/provider/ProviderSheet.svelte b/desktop/src/renderer/src/lib/components/provider/ProviderSheet.svelte index b6e334f67..966b5b0ae 100644 --- a/desktop/src/renderer/src/lib/components/provider/ProviderSheet.svelte +++ b/desktop/src/renderer/src/lib/components/provider/ProviderSheet.svelte @@ -91,11 +91,9 @@ async function loadOptions() { const raw = await providerOptions(provider.name) options = raw as unknown as Record - const currentOpts = provider.options ?? {} for (const [key, opt] of Object.entries(options)) { - const currentVal = currentOpts[key] - if (currentVal?.value != null) { - optionValues[key] = String(currentVal.value) + if (opt.value != null) { + optionValues[key] = String(opt.value) } else if (opt.default != null) { optionValues[key] = String(opt.default) } else { @@ -202,6 +200,8 @@ async function handleSaveOptions() { if (val !== "") values[key] = val } await providerSetOptions(provider.name, values) + const updated = await providerList() + providers.set(updated) initialValues = { ...optionValues } if (setup) { await providerUse(provider.name)