🩹 [Patch]: Enable Context Sharing Across PowerShell Processes and Runspaces#88
Conversation
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
|
Would it make sense to let the completer to use Get-ContextInfo? |
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Both suggestions implemented in commit 310c6a8:
Benefits: DRY principle, simpler code (7 vs 14 lines), consistent behavior across module. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…context retrieval; update Sodium module version to 2.2.0 across relevant scripts.
… for context management
|
Module Context - 7.0.5-copilotfix87001 published to the PowerShell Gallery. |
|
GitHub release for Context v7.0.5-copilotfix87001 has been created. |
|
Module Context - 7.0.5-copilotfix87002 published to the PowerShell Gallery. |
|
GitHub release for Context v7.0.5-copilotfix87002 has been created. |
There was a problem hiding this comment.
Pull Request Overview
This patch refactors context handling in the PowerShell module to enable true cross-process context sharing by replacing the in-memory dictionary with disk‐based operations. Key changes include:
- Removing the in-memory context store and updating context operations to read/write directly from disk.
- Updating module dependencies and documentation to reflect the new behavior.
- Removing the Import-Context function and updating argument completers to enumerate contexts from disk.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/variables/private/Contexts.ps1 | Removed in-memory concurrent dictionary storage. |
| src/functions/public/Set-Context.ps1 | Refactored context creation/update to scan disk files and update docs. |
| src/functions/public/Remove-Context.ps1 | Revised context removal to operate over files on disk. |
| src/functions/public/Get-ContextInfo.ps1 | Changed retrieval to read only metadata from disk. |
| src/functions/public/Get-Context.ps1 | Adjusted context decryption to work with contexts stored on disk. |
| src/functions/private/Set-ContextVault.ps1 | Updated vault initialization and removed auto-import of contexts. |
| src/functions/private/Import-Context.ps1 | Removed deprecated function for in-memory context import. |
| src/completers.ps1 | Updated argument completer to enumerate contexts via Get-ContextInfo. |
|
Module Context - 7.0.5 published to the PowerShell Gallery. |
|
GitHub release for Context v7.0.5 has been created. |
This release refactors context management to be entirely disk-based, enabling robust context sharing and synchronization across scripts, modules, jobs, and processes.
Key Changes
Get-ContextInfoperform quick metadata lookups by reading only the necessary file information, improving performance.Impact for Integrators
Get-Context,Set-Context, etc.) will now always reflect the true state on disk.This update ensures reliable, up-to-date context management for all usage patterns, including concurrent and multi-process environments.
Core Changes
Get-Context: Now reads and decrypts context files directly from the vault directory each time calledGet-ContextInfo: Reads only file metadata from disk without decryption for fast queriesSet-Context: No longer updates$script:Contextsmemory cache, writes only to diskRemove-Context: Scans disk files directly instead of iterating memory cacheSet-ContextVault: No longer auto-imports contexts into memory on initialization