refactor(pwsh): hoist Test-InMux into 05-lib as the single pane-detection source#76
Merged
Conversation
…tion source os/30-windows.ps1 (psmux auto-attach guard) and os/33-psmux-pill.ps1 (pill auto-arm/status) each hand-maintained their own "are we inside a psmux pane?" marker list, and had already drifted — 30-windows checked PSMUX / PSMUX_PANE (which psmux does not export) while the pill used the verified TMUX + PSMUX_SESSION pair. Move the check into the pure helper layer (core/05-lib.ps1) as Test-InMux, export it from the Dotfiles module, and have both call sites use it, so the marker set lives in exactly one place and can't drift again. Adds Test-InMux unit tests (env save/restore) and documents the export. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR consolidates “inside a psmux pane” detection into a single shared helper (Test-InMux) in the core helper layer, exports it from the Dotfiles module, and updates the two previously-drifting call sites to use that shared implementation.
Changes:
- Added
Test-InMuxtopowershell/core/05-lib.ps1and exported it viapowershell/Dotfiles/Dotfiles.psd1. - Replaced duplicated / drifting pane-marker logic in
powershell/os/30-windows.ps1andpowershell/os/33-psmux-pill.ps1with the sharedTest-InMux. - Added Pester coverage for
Test-InMuxand documented the new export in the module export tests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Module.Tests.ps1 | Adds Test-InMux to the expected exported-functions list. |
| tests/Lib.Tests.ps1 | Adds unit tests validating Test-InMux behavior with env var save/restore. |
| powershell/os/33-psmux-pill.ps1 | Removes local Test-InMux copy and uses the shared helper; updates load-contract requires. |
| powershell/os/30-windows.ps1 | Uses shared Test-InMux for the psmux auto-attach guard; updates load-contract requires. |
| powershell/Dotfiles/Dotfiles.psd1 | Exports Test-InMux from the Dotfiles module. |
| powershell/core/05-lib.ps1 | Introduces the shared Test-InMux implementation and updates load-contract provides. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Moves the "are we inside a psmux pane?" check into the pure helper layer (
core/05-lib.ps1) asTest-InMux, exported from the Dotfiles module, and points both call sites at it. Follow-up to #75.Why
os/30-windows.ps1(psmux auto-attach guard) andos/33-psmux-pill.ps1(pill auto-arm/status) each hand-maintained their own pane-marker list — and had drifted. 30-windows checkedPSMUX/PSMUX_PANE(which psmux does not export), while the pill used the verifiedTMUX+PSMUX_SESSIONpair. #75 fixed 30-windows' markers inline; this removes the possibility of drift entirely by giving both one source of truth.Changes
core/05-lib.ps1— new pureTest-InMux(TMUX+PSMUX_SESSION, per psmuxsrc/pane.rs). Updatedprovides:.Dotfiles.psd1— exportTest-InMux.os/30-windows.ps1—$InMux = Test-InMux; dropped the inline list. Updatedrequires:.os/33-psmux-pill.ps1— removed the localscript:Test-InMuxcopy; call sites use the shared one. Updatedrequires:.tests/Lib.Tests.ps1—Test-InMuxcases with env save/restore.tests/Module.Tests.ps1— document the export.Verification
Test-InMuxbehavioral check: no markers →$false,TMUX→$true,PSMUX_SESSION→$true.LoadContractrequires:-vs-AST computation for all three touched fragments → exact match.🤖 Generated with Claude Code