fix(plugin-engine): refresh shell env values#486
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@codex review |
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Tauri plugin-engine host env resolver so that shell-derived environment variables are re-read on each lookup (instead of being cached for the app’s lifetime). This targets macOS GUI launches (e.g., Spotlight) where the process environment may not include API keys, while still preserving “process env wins” precedence.
Changes:
- Removed the lifetime cache for interactive-shell-derived env vars.
- Introduced
resolve_env_value_with_readersto make the resolver logic more testable/composable. - Added a test verifying repeated shell reads when the process env does not contain the variable.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if let Some(value) = read_process(name) { | ||
| return Some(value); | ||
| } | ||
|
|
||
| if let Ok(cache) = terminal_env_cache().lock() { | ||
| if let Some(cached) = cache.get(name) { | ||
| return cached.clone(); | ||
| } | ||
| } | ||
| read_shells(name) |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Test plan
Made with Cursor
Note
Cursor Bugbot is generating a summary for commit b53dc4f. Configure here.
Summary by cubic
Re-read shell-derived env vars on each lookup (no caching) while keeping process env precedence. This lets Spotlight-launched OpenUsage pick up updated shell config without restart and fixes #305.
resolve_env_value_with_readersfor clearer logic and testability, plus a test to verify repeated shell reads.Written for commit b53dc4f. Summary will update on new commits. Review in cubic