Skip to content

Trigger restartRpc when envVars changed#160

Open
jthuangarm wants to merge 5 commits intoOpen-CMSIS-Pack:mainfrom
jthuangarm:update-envvar
Open

Trigger restartRpc when envVars changed#160
jthuangarm wants to merge 5 commits intoOpen-CMSIS-Pack:mainfrom
jthuangarm:update-envvar

Conversation

@jthuangarm
Copy link
Copy Markdown
Contributor

@jthuangarm jthuangarm commented Apr 7, 2026

Fixes

Changes

Introduce a new event to notify when environment variables change, and integrates this event into the solution management workflow, e.g. restartRpc. By doing this, restartRpc will be triggered immediately after entering environment variables in Settings and pressing the OK button.

  • Added a new onDidChangeEnvVars event to the EnvironmentManager interface.
  • Registered the event emitter for disposal in the extension's subscriptions to ensure proper cleanup.
  • Avoid frequent/duplicate RPC restarts even when the resulting env vars are identical (e.g., extensions changing like (un-)installing extensions that are unrelated to Keil Studio).
  • Updated SolutionManagerImpl to accept an EnvironmentManager instance and listen for the new onDidChangeEnvVars event, triggering debouncedHandleEnvironmentChange when environment variables are updated.

Testing and Verification:

  • Added tests to verify that the onDidChangeEnvVars event fires on environment initialization and configuration changes.
  • Added a test to ensure that when environment variables change after a solution is activated, the system requests an RPC restart as expected.

2026-04-07_11-23-01

Checklist

  • 🤖 This change is covered by unit tests (if applicable).
  • 🤹 Manual testing has been performed (if necessary).
  • 🛡️ Security impacts have been considered (if relevant).
  • 📖 Documentation updates are complete (if required).
  • 🧠 Third-party dependencies and TPIP updated (if required).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an EnvironmentManager event to detect environment variable updates and wires it into SolutionManagerImpl so environment changes can trigger an RPC restart flow (via debounced environment-change handling), with unit tests covering the new behavior.

Changes:

  • Introduces EnvironmentManager.onDidChangeEnvVars and fires it when the environment variable collection is updated.
  • Injects EnvironmentManager into SolutionManagerImpl and listens for env-var changes to trigger the existing debounced environment-change handling (restart RPC path).
  • Adds unit tests verifying the env-var change event and that a post-activation env-var change requests an RPC restart.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/solutions/solution-manager.ts Injects EnvironmentManager and subscribes to env-var change events to trigger debounced environment change handling.
src/solutions/solution-manager.test.ts Adds coverage to ensure env-var changes after activation request restartRpc.
src/desktop/extension.ts Passes the existing envManager instance into SolutionManagerImpl.
src/desktop/env-manager.ts Adds onDidChangeEnvVars event and fires it after updating the environment variable collection.
src/desktop/env-manager.test.ts Adds tests asserting onDidChangeEnvVars fires on init and config updates.

@jthuangarm jthuangarm marked this pull request as ready for review April 7, 2026 14:29
@jthuangarm jthuangarm requested a review from edriouk April 7, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants