Active collection environment is not cleared when its file is deleted
Description
When the active collection environment's file is deleted from disk (e.g. removed outside Bruno, or via git checkout of a branch without it), the environment disappears from the list, but collection.activeEnvironmentUid in the Redux store keeps pointing at the uid of the deleted environment.
Steps to reproduce
- Open a collection with an environment, e.g.
environments/dev.yml, and select it as the active environment. - Delete
environments/dev.ymlfrom disk outside Bruno. - The environment is removed from the environment list, but
activeEnvironmentUidstill holds the old uid. - Recreate a file at the same path: it silently becomes the active environment again, because environment uids are derived from the file path.
Expected
Removing the active environment's file should reset the selection to "No Environment", the same way deleting the active global environment already does (_deleteGlobalEnvironment).
Notes
This is also called out by an existing TODO in collectionUnlinkEnvFileEvent (packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js).
Thanks for the clear report @tuanxminhxgi. I was able to reproduce it: after the selected environment’s file is removed, it disappears from the list, but requests keep using its values.
Your fix in PR #9766 resolves this in my testing. Follow that PR for updates.