fix(windows): embed legacy cleanup tool in installer#82
Open
Sun-sunshine06 wants to merge 4 commits into
Open
Conversation
hqhq1025
reviewed
Mar 27, 2026
hqhq1025
left a comment
Collaborator
There was a problem hiding this comment.
⚠️ Conditional Approve — NSIS flow verified correct, minor issues
I traced the full NSIS installer flow end-to-end. The self-elevation mechanism is safe (no injection vectors — $PSCommandPath + known switches only). ExecShell "open" on .cmd files works correctly.
Security notes
- Low risk: Predictable
%TEMP%\Open-Cowork-Legacy-Cleanuppath could be pre-empted with a directory junction by a local attacker. Consider clearing any pre-existing directory before extraction:IfFileExists "$OpenCoworkCleanupDir\*.*" 0 +2 RMDir /r "$OpenCoworkCleanupDir"
-ExecutionPolicy Bypasson the elevated process is standard for embedded utilities but could trigger AV heuristics. Worth noting in release notes.
Code quality (non-blocking, suggest follow-up)
copyDirWithRetryhas unreachablereturn maxAttemptsafter the loop (dead code)listRelativeFiles(after-pack.js) andcollectRelativeFiles(stage-mcp-resources.js) are identical — should share- Retry-with-backoff logic is duplicated between files
- Extracted temp files (
%TEMP%\Open-Cowork-Legacy-Cleanup\) are never cleaned up after execution - Most new tests are string-matching source code rather than behavioral tests — very brittle
- Windows cleanup helpers are copied twice when using
build-windows.js(once viaafterAllArtifactBuildhook, once in script exit handler)
There was a problem hiding this comment.
Findings
- [Minor] The new MCP after-pack regression test only greps
scripts/after-pack.jsas text, so it will keep passing if the hook stops loading or if theresources/mcpcopy path fails at runtime. That leaves the exact packaging regression this PR is trying to prevent effectively untested. Evidencetests/after-pack-mcp.test.ts:7.
Suggested fix:const afterPack = require('../scripts/after-pack.js'); await afterPack({ ...fixtureContext }); expect(fs.existsSync(path.join(appOutDir, 'resources', 'mcp', 'gui-operate-server.js'))).toBe(true);
Summary
- Review mode: initial. One minor testing-gap finding on the new after-pack coverage; I did not identify a higher-confidence runtime or security regression in the changed installer/build logic.
Testing
- Not run (automation; local Vitest startup failed in this checkout because
vitestis not installed).
Open Cowork Bot
|
|
||
| describe('after-pack MCP handling', () => { | ||
| it('copies staged MCP bundles into resources with retry logic', () => { | ||
| const source = fs.readFileSync(path.resolve(process.cwd(), 'scripts/after-pack.js'), 'utf8'); |
There was a problem hiding this comment.
[MINOR] This only asserts that specific strings still exist in scripts/after-pack.js, so it will still pass if the hook stops loading or if the staged MCP copy fails at runtime. That leaves the packaging path introduced in this PR effectively unexecuted by test coverage.
Suggested fix:
const afterPack = require('../scripts/after-pack.js');
await afterPack({ ...fixtureContext });
expect(fs.existsSync(path.join(appOutDir, 'resources', 'mcp', 'gui-operate-server.js'))).toBe(true);
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.
Summary
.exe%TEMP%\Open-Cowork-Legacy-Cleanupand offer to launch it immediately when the legacy uninstaller fails.cmdand.ps1helpers with Windows build artifactsTesting
Verification
A direct Windows
electron-buildersmoke build completed successfully with the embedded-cleanup installer changes, and the shared artifact hook still emitted:Open Cowork-3.3.0-beta.7-win-x64.exeOpen-Cowork-Legacy-Cleanup.cmdOpen-Cowork-Legacy-Cleanup.ps1