From c6fb3067ce74f7864c8e071ed9ea3b3b1f69d00a Mon Sep 17 00:00:00 2001 From: aaronvg Date: Wed, 27 Nov 2024 10:59:32 -0800 Subject: [PATCH] fix promptfiddle (#1201) > [!IMPORTANT] > Enable playground proxy by default and handle NextJS environment in `envVarsAtom` in `EventListener.tsx`. > > - **Behavior**: > - Change `enablePlaygroundProxy` default to `true` in `vscodeSettingsAtom` in `EventListener.tsx`. > - In `envVarsAtom`, handle NextJS environment by always enabling proxy and logging `vscodeSettings`. > - **Misc**: > - Add logging for `vscodeSettings` in `envVarsAtom` in `EventListener.tsx`. > > This description was created by [Ellipsis](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral) for b475518f3aa425cee6fcdadcbc9d13256a4ef270. It will automatically update as commits are pushed. --- .../src/baml_wasm_web/EventListener.tsx | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/typescript/playground-common/src/baml_wasm_web/EventListener.tsx b/typescript/playground-common/src/baml_wasm_web/EventListener.tsx index 1282f9453..ee17d2fa8 100644 --- a/typescript/playground-common/src/baml_wasm_web/EventListener.tsx +++ b/typescript/playground-common/src/baml_wasm_web/EventListener.tsx @@ -42,7 +42,7 @@ const vscodeSettingsAtom = unwrap( } catch (e) { console.error(`Error occurred while getting vscode settings:\n${e}`) return { - enablePlaygroundProxy: false, + enablePlaygroundProxy: true, } } }), @@ -135,15 +135,21 @@ type Selection = { } export const envVarsAtom = atom((get) => { - const vscodeSettings = get(vscodeSettingsAtom) - if (vscodeSettings?.enablePlaygroundProxy !== undefined && !vscodeSettings?.enablePlaygroundProxy) { - // filter it out + if ((window as any).next?.version) { + // NextJS environment doesnt have vscode settings, and proxy is always enabled + return Object.fromEntries(defaultEnvKeyValues.map(([k, v]) => [k, v])) + } else { + const vscodeSettings = get(vscodeSettingsAtom) + console.log('vscodeSettings', vscodeSettings) + if (vscodeSettings?.enablePlaygroundProxy !== undefined && !vscodeSettings?.enablePlaygroundProxy) { + // filter it out + const envKeyValues = get(envKeyValuesAtom) + return Object.fromEntries(envKeyValues.map(([k, v]) => [k, v]).filter(([k]) => k !== 'BOUNDARY_PROXY_URL')) + } + const envKeyValues = get(envKeyValuesAtom) - return Object.fromEntries(envKeyValues.map(([k, v]) => [k, v]).filter(([k]) => k !== 'BOUNDARY_PROXY_URL')) + return Object.fromEntries(envKeyValues.map(([k, v]) => [k, v])) } - - const envKeyValues = get(envKeyValuesAtom) - return Object.fromEntries(envKeyValues.map(([k, v]) => [k, v])) }) const selectedProjectAtom = atom(