mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-07 22:18:33 +00:00
feat: enhance environment variable persistence handling (#5783)
* feat: enhance environment variable persistence handling * feat: experiment playwright with multiple workers --------- Co-authored-by: Bijin Bruno <bijin@usebruno.com>
This commit is contained in:
@@ -1467,8 +1467,16 @@ export const mergeAndPersistEnvironment =
|
||||
}
|
||||
});
|
||||
|
||||
// Save only non-ephemeral vars, or ephemerals explicitly persisted this run
|
||||
// Save all non-ephemeral vars and all variables that were previously persisted
|
||||
const persistedNames = new Set(Object.keys(persistentEnvVariables));
|
||||
|
||||
// Add all existing non-ephemeral variables to persistedNames so they are preserved
|
||||
existingVars.forEach((v) => {
|
||||
if (!v.ephemeral) {
|
||||
persistedNames.add(v.name);
|
||||
}
|
||||
});
|
||||
|
||||
const environmentToSave = cloneDeep(environment);
|
||||
environmentToSave.variables = buildPersistedEnvVariables(merged, { mode: 'merge', persistedNames });
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ export const collectionsSlice = createSlice({
|
||||
}
|
||||
},
|
||||
scriptEnvironmentUpdateEvent: (state, action) => {
|
||||
const { collectionUid, envVariables, runtimeVariables } = action.payload;
|
||||
const { collectionUid, envVariables, runtimeVariables, persistentEnvVariables } = action.payload;
|
||||
const collection = findCollectionByUid(state.collections, collectionUid);
|
||||
|
||||
if (collection) {
|
||||
@@ -326,9 +326,10 @@ export const collectionsSlice = createSlice({
|
||||
if (activeEnvironment) {
|
||||
forOwn(envVariables, (value, key) => {
|
||||
const variable = find(activeEnvironment.variables, (v) => v.name === key);
|
||||
const isPersistent = persistentEnvVariables && persistentEnvVariables[key] !== undefined;
|
||||
|
||||
if (variable) {
|
||||
// For updates coming from scripts, treat them as ephemeral overlays.
|
||||
// For updates coming from scripts, treat them as ephemeral overlays unless they are persistent.
|
||||
if (variable.value !== value) {
|
||||
/*
|
||||
Overlay (persist: false): keep new value in Redux for UI and mark ephemeral
|
||||
@@ -337,7 +338,7 @@ export const collectionsSlice = createSlice({
|
||||
*/
|
||||
const previousValue = variable.value;
|
||||
variable.value = value;
|
||||
variable.ephemeral = true;
|
||||
variable.ephemeral = !isPersistent;
|
||||
if (variable.persistedValue === undefined) {
|
||||
variable.persistedValue = previousValue;
|
||||
}
|
||||
@@ -353,7 +354,7 @@ export const collectionsSlice = createSlice({
|
||||
enabled: true,
|
||||
type: 'text',
|
||||
uid: uuid(),
|
||||
ephemeral: true,
|
||||
ephemeral: !isPersistent
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,6 +398,7 @@ const registerNetworkIpc = (mainWindow) => {
|
||||
mainWindow.webContents.send('main:script-environment-update', {
|
||||
envVariables: scriptResult.envVariables,
|
||||
runtimeVariables: scriptResult.runtimeVariables,
|
||||
persistentEnvVariables: scriptResult.persistentEnvVariables,
|
||||
requestUid,
|
||||
collectionUid
|
||||
});
|
||||
@@ -486,6 +487,7 @@ const registerNetworkIpc = (mainWindow) => {
|
||||
mainWindow.webContents.send('main:script-environment-update', {
|
||||
envVariables: result.envVariables,
|
||||
runtimeVariables: result.runtimeVariables,
|
||||
persistentEnvVariables: result.persistentEnvVariables,
|
||||
requestUid,
|
||||
collectionUid
|
||||
});
|
||||
@@ -532,6 +534,7 @@ const registerNetworkIpc = (mainWindow) => {
|
||||
mainWindow.webContents.send('main:script-environment-update', {
|
||||
envVariables: scriptResult.envVariables,
|
||||
runtimeVariables: scriptResult.runtimeVariables,
|
||||
persistentEnvVariables: scriptResult.persistentEnvVariables,
|
||||
requestUid,
|
||||
collectionUid
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user