Repository navigation
fix(desktop): pre-check Windows install locations and guide drive-root ACL recovery - #666
oldwinter53 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Approve with nits (1 P2, 2 P3)
Scope: base main, merge base 00b9065d, 1 commit, 13 files reviewed at 3eff2715. Loaded coderbook, ponytail-review, karpathy-guidelines. Ran in a separate session.
Findings
P2
windowsPrivateLocationis a copy ofwindowsPrivatePath—packages/local-installation/src/windows-private.ts:446
Lines 446–466 repeat lines 420–438 line for line: samerun ? run(powershellPath(), …) : defaultWorker.execute(payload)dispatch, same timeout, sameprivatePathErrorthrow. The only difference iskind: "location"withrepair: false. Now there are two copies of the request/transport code, and any later change (timeout, worker routing, error shape) has to be made in both. Fix: widenwindowsPrivatePath'skindto"file" | "directory" | "location"and makewindowsPrivateLocation(dir, run)callwindowsPrivatePath(dir, "location", false, run). You could also drop the wrapper and call it directly fromlocal-server.ts.
P3
-
installLocationhas win32 handling that only the Linux test needs —apps/desktop/src/main/local-server.ts:4437-4441
On Windows,path.dirname("F:\\") === "F:\\"already detects a drive root, andpath.joinalready ispath.win32.join. So the/^[A-Za-z]:[\\/]$/root regex and thepath.win32.joinswitch only matter when the newinstallLocation("F:\\")assertion runs on Linux/macOS CI. Production code gains a branch that never runs in production. Fix: keeppath.dirname(picked) === pickedandpath.join, and drop the drive-letter assertion or make it Windows-only. -
The drive-root guidance always says to remove Everyone's Full Control —
apps/desktop/src/shell/setup.messages.ts:75(andlocationPickDriveRootHint, plus the zh-CN entries)
At a volume root, the ACL program refuses any untrusted Allow ACE that grantsDeleteSubdirectoriesAndFiles,ChangePermissionsorTakeOwnership(windows-private.ts:99-105). That can beUsers:(F)or a custom group, not only Everyone. In that case "remove Full Control for Everyone in F:\ Properties → Security" doesn't work, and the user is left with a refusal they can't clear. Fix: refer to "other accounts' Full Control" in the remedy sentence, as the first sentence already does with "such as Everyone".
Verified as fine
- Pre-check is read-only: the
locationbranch ofWINDOWS_PRIVATE_CHECK_BODYonly usesTest-Path/Get-Item/Get-Acl. The repair and DACL checks are wrapped inif ($request.kind -ne 'location')(windows-private.ts:110-146), and the ancestor rules (root vs. below-rootDelete,windows-private.ts:99-100) are shared unchanged. Volume-root security is not weakened, and the newFULL_CONTROL & mask(EVERYWHERE)test pins this. - Missing target: the probe walks up to the nearest existing ancestor. Through the picker, the candidate is either the picked folder or
picked\Linger, so at most one level is missing and the nearest ancestor is the picked folder itself. An existing drive root as the target throwsUNSAFE_TYPE(!$item.Parent), butinstallLocationnever returns a bare root without an existing installation. chooseLocationon refusal keeps the previous location, setsrefusal/rejectedPath, and does not recheck becauseprevious === #location(local-server.ts:820-836). Reset clears all four fields. A later disk-space error clears the stale refusal becauseproblem?.refusalis undefined.#installrefusal propagation: the thrown error carriesrefusal, and the failure path reads(error as {refusal}).refusalthroughwindowsPrivateRefusal(local-server.ts:1464), so the failed screen gets the code and reason. Covered by "fails fast with refusal…".- Non-Windows platforms skip the ACL check (
#checkLocationplatform guard). The default worker unrefs and idles out (windows-private.ts:295-301), so Desktop gains no lingering child process. - UI hints are keyed on
refusal.code/refusal.reason, not on message text. Other reasons fall back to the raw error (tested).setup-window.tspassesrejectedPaththroughshown()likepath. - English/zh-CN catalog parity holds. CJK appears only in
apps/desktop/src/i18n/locales/zh-CN.json(allowed), and the commit message is English.apps/desktop/AGENTS.mdis updated. - Unverified: the native Windows tests (
windows-private.native.test.ts) areskipIf(!win32), and no Windows CI job ran (computer-go-windowsskipped), so the PowerShelllocationbranch has only been checked by reading it and by string-contains tests.
Process notes
- The branch is behind
main(00b9065dvs8b7fe39b) andmainrequires up-to-date branches: rebase before merging. - One commit, no merge or fixup commits.
CI
All checks that ran passed: check (desktop), check (packages), check (installer), check (web), repository-gate, CodeQL. Go/contracts/web-test jobs were skipped as not affected. I ran no tests locally.
Automated review by Claude Code
Automated review of 3eff271 by Claude Code.
3eff271 to
de7da43
Compare
There was a problem hiding this comment.
Approve with nits (1 P3)
Scope: follow-up on 3eff271. Base main, merge base eafcfd41. Reviewed 1 commit (de7da430) and 10 files. The branch was force-pushed and rebased onto a main that now ships windowsPrivateLocation and the Windows install preflight, so I compared the old and new versions of the commit with git range-diff and re-reviewed the full merge-base diff. Loaded coderbook (sections 2, 3, 5), ponytail-review (sections 1–3) and karpathy-guidelines (sections 2–3). Ran in a separate session.
Previous findings
- P2
windowsPrivateLocationduplicatedwindowsPrivatePath: Resolved. The PR no longer touchespackages/local-installation/src/windows-private.ts. It now uses thewindowsPrivateLocationthatmainships (packages/local-installation/src/windows-private.ts:755). - P3
installLocationhad test-only branches: Resolved.apps/desktop/src/main/local-server.ts:4508detects a root only withpath.dirname(picked) === pickedand uses plainpath.join. TheF:\assertion now runs only onwin32(local-server.test.ts:3466). - P3 drive-root guidance always told users to remove Everyone: Resolved. Both the English text (
setup.messages.ts) and the zh-CN text now say to remove Full Control for other accounts. Everyone stays only as an example.
Findings
P3
apps/desktop/src/main/local-server.test.ts:3542: the test "fails fast with refusal when a chosen Windows folder becomes unsafe before install" tests behavior that already exists onmain. The install preflight (local-server.ts:1303-1327) and its refusal tagging are already covered bymain's "preserves the Windows private-path refusal when home preflight fails" (local-server.test.ts:3174). The only difference is that the new test uses a custom location. Its name also suggests this PR adds the behavior, but the PR only adds the picker check. Fix: drop the new test, or add one custom-location assertion to the existing test.
Verified as fine
- Picker check: on Windows,
chooseLocation→#checkLocation(local-server.ts:846-869) first runs the existing free-space and folder check, thenwindowsPrivateLocation. When the check refuses the folder,#locationstays at the previous valid folder (local-server.ts:839), andrefusalandrejectedPathare recorded. The recheck is skipped becauseprevious === this.#location. Choosingnullclears all of it (local-server.ts:828-833). The test atlocal-server.test.ts:3470covers refuse → valid → refuse-keeps-previous → reset. - The check does not change the picked folder: on
main, thelocationkind of the ACL program checks the folder if it exists, or else the nearest existing parent and every folder above it. It never runs the repair or create code. The native test (windows-private.native.test.ts:347-362) checks that a missing folder is not created and that an existing folder's inherited DACL is left alone. That test only runs on Windows, and CI has no Windows job for packages. - Drive roots: if
F:\is empty or can't be read,readdirfalls back to[]. Before, Linger would then install straight into the root. NowinstallLocationreturnsF:\Linger, while a root that already holdsinstancesorinstalleris still used as is (local-server.ts:4505-4510). On POSIX,/was never empty, so nothing changes there. - Install preflight still runs after a pick, because
main's#installcallscheckPrivate(home)before unpacking (local-server.ts:1303-1307). The PR description says this correctly. - Page guidance:
windowsDriveLocation(setup.html) tellsD:\a\b(nested) apart fromF:\Linger,F:\Linger\andF:\(directly on the drive). BothlocationHintandlocationErrorTextshow guidance only when the refusal isWINDOWS_PRIVATE_PATH_UNSAFE/UNSAFE_PARENT_ACCESS, and otherwise fall back to the raw error. Shortened paths thatshown()produces don't match the drive patterns, so they safely fall back as well. The decision is driven by structured codes, not by message text. - Reset: Customize reset now also fires when only
refusalis set (setup.html:4906). Since a refusal always comes witherror, this changes nothing but is harmless. - i18n: the English and zh-CN catalogs gain the same three keys. Chinese text appears only in
apps/desktop/src/i18n/locales/zh-CN.json, which the repo allows. There is no Chinese in code, comments or the commit message. - Docs:
apps/desktop/AGENTS.mdis updated to describe the picker check, the drive-root rule and the guidance. - Unverified: I could not run the Windows-only native tests (
windows-private.native.test.ts) here. CI skips them too.
Process notes
- The branch is 2 commits behind
main(963f4b52), andmainrequires up-to-date branches, so it needs a rebase before merge. - There is one commit and no merge or fixup commits. The commit author is
Dongdong Chen <cdd@simplexai.com>.
CI
These checks pass: check (desktop), check (packages), check (installer), check (web), repository-gate, changes, CodeQL. The other jobs were skipped by path filters. No job runs the Windows-native local-installation tests. I ran no tests myself.
Automated review by Claude Code
Automated review of de7da43 by Claude Code.
…t ACL recovery Secondary Windows NTFS data drives formatted with the stock Everyone:(OI)(CI)(F) ACL grant DeleteSubdirectoriesAndFiles, ChangePermissions, and TakeOwnership on the volume root. Private-path validation intentionally keeps rejecting that root ACL with UNSAFE_PARENT_ACCESS so other local accounts cannot replace the Linger home folder, but selecting such a drive passed location picking without structured refusal details and showed no recovery guidance for drive-root paths because locationHint only matched nested paths. - Record structured WindowsPrivateRefusal alongside error and rejectedPath in chooseLocation when windowsPrivateLocation refuses a candidate folder, keeping the previous valid location and disk-space metadata intact; install preflight still checks the home again before unpacking. - Always target a Linger subfolder when a drive or filesystem root is picked unless it already holds an installation. - Show localized recovery guidance in setup.html (English and Simplified Chinese) in the install-location bar and on the failed step when UNSAFE_PARENT_ACCESS refuses a folder directly on a drive or a nested drive path. - Cover windowsPrivateLocation on native Windows for refused, existing, and missing candidates without mutating them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
de7da43 to
97e7568
Compare
There was a problem hiding this comment.
Approve with nits (1 P3)
Scope: follow-up on de7da43. The PR was rebased since then, so I compared the two versions with git range-diff and also reviewed the full diff against merge base 6a511c15 (main, up to date). That covers 1 commit and 9 files. Loaded coderbook, ponytail-review and karpathy-guidelines. Ran in a separate session.
Previous findings
- Resolved: the duplicated install-preflight test was removed in the rebase. The "fails fast with refusal when a chosen Windows folder becomes unsafe before install" case is gone, and only the
chooseLocationpre-check test remains (apps/desktop/src/main/local-server.test.ts:4174).
Findings
P3
apps/desktop/src/main/local-server.ts:1124: the PR body overstates what this PR adds. It says the PR "now only adds the picker-time check" and thatchooseLocation"recordslocation.refusalandlocation.rejectedPath". The removed lines showmainalready ranwindowsPrivateLocationinchooseLocation, kept the previous location on refusal and recordedrejectedPath. The new part is the structuredrefusal(via#checkLocation), the drive-rootinstallLocationrule, and the guidance text. The commit message describes this correctly. Please align the PR body with it so reviewers don't look for a picker check thatmainalready had.
Verified as fine
- Refusal state lifecycle:
#locationRefusalis written alongside#locationErrorand#locationRejectedPathonly after the stale-choice guard (local-server.ts:1140-1149). It is cleared bychooseLocation(null)and by a successful pick, and withrejectedPathin#ready(local-server.ts:3939). The test covers refuse → valid → refuse-keeps-previous → reset, including the free-space metadata (local-server.test.ts:4206-4253). - The refusal sent to the page holds only
{code, reason}(windowsPrivateRefusal, asserted withtoEqualatlocal-server.test.ts:4217). The shownrejectedPathgoes throughshown()(setup-window.ts:640). installLocation(local-server.ts:5953-5960): an existing installation (instances/installer) still wins. Empty non-root folders still install in place. A root (path.dirname(p) === p, true forF:\and/) always getsLinger. Only roots whose only entries are dot entries change behaviour, and the docs say so.- Setup page:
locationErrorTextfalls back tolocation.error(setup.html:3145), so thespaceLow,shownLocationPathand reset-button logic behave as before for non-refusal errors. Drive-root and nested regexes are covered for pick-time and failed-step hints insetup-page.test.ts. The EN and zh-CN catalogs have the same keys. CJK appears only inapps/desktop/src/i18n/locales/zh-CN.json. apps/desktop/AGENTS.mddocuments the picker pre-check, the drive-root rule and where the guidance shows.
Process notes
- Single commit, no merge or fixup commits; the branch is up to date with
main.
CI
All checks that ran passed: desktop, packages, installer, web (quick pass), repository-gate, CodeQL. The rest were skipped as not affected. The native Windows windows-private.native.test.ts cases skip off Windows, so CI on Linux does not run them. I ran no tests myself.
Automated review by Claude Code
Automated review of 97e7568 by Claude Code.
There was a problem hiding this comment.
Approve with nits (1 P2)
Follow-up on 97e7568; the head is unchanged, so this re-checks the whole PR against merge base 6a511c15 on main (1 commit, 9 files). Helper skills loaded: coderbook, ponytail-review, karpathy-guidelines. Ran in a separate session.
Previous findings
- Resolved: PR description counted
main's existing pick-time pre-check as new (apps/desktop/src/main/local-server.ts:1124). The PR body now saysmainalready runswindowsPrivateLocationinchooseLocationand that this PR adds only the structuredrefusal, drive-root targeting, and guidance.
Findings
P2
apps/desktop/src/shell/setup.html:3136(locationErrorText, nested branch) and:3125(locationHint): the nested-path guidance sends users on a stock data drive to a location that will also be refused.
Scenario:D:\has the stockEveryone:(OI)(CI)(F)ACL that this PR targets. The user picksD:\Games, andinstallLocationturns it intoD:\Games\Linger. The ancestor loop inpackages/local-installation/src/windows-private.ts:231-262refusesD:\Games, which inherits the Everyone Full Control grant, withUNSAFE_PARENT_ACCESS.windowsDriveLocationclassifies the path as nested, so the bar says "Choose D:\ itself (Linger installs into D:\Linger)". The user does that, and the same loop refusesD:\Lingeron the root's own ACL, so only then does the user see the drive-root hint (properties → Security, or another drive). The shape of the path alone cannot tell "a nested folder's ACL is the problem" apart from "the drive root's ACL is the problem", becauseWindowsPrivateRefusalcarries onlycode/reason.
Fix: the simplest option is to wordlocationPickNestedHint(andlocationHint) so it also covers the drive-permission case, for example by adding the "or remove Full Control for other accounts in {drive} Properties → Security" clause. A more precise option is to pre-check the drive'sLingercandidate before suggesting it, which costs one more ACL probe.
Verified as fine
#checkLocation(apps/desktop/src/main/local-server.ts:1162-1185) keeps the earlier order: disk-space/checkLocationfirst, then the Windows private check, which runs only onwin32.windowsPrivateRefusal(packages/local-installation/src/windows-private.ts:803-815) returnsundefinedfor non-refusal errors, sorefusalis omitted and the UI falls back to the rawerror.- State transitions: on refusal,
#locationand#locationFreeBytesare not touched becauseupdateFreeBytesstays false (local-server.ts:1137-1151). A valid pick or Reset clears#locationRefusal(:1148), and#readyclears it too (:3939). A stale pick is dropped through#locationChoiceSeqbefore any field is written. installLocation(local-server.ts:5953-5960): an existing installation (instances/installer) still wins. Only a filesystem root (path.dirname(p) === p) that would otherwise be "empty" now goes to<root>\Linger. Non-root behaviour is unchanged, andlocal-server.test.ts:4159-4172covers it.- The
windowsDriveLocationregexes (setup.html:3104-3110) classifyF:\,F:\Linger, andF:\Linger\as drive-level andD:\a\bas nested. Non-drive paths (UNC) returnundefinedand fall back to the raw error. - The warning precedence in the welcome bar is the same as before: the location error comes before low-space, and Reset stays visible when there is an error (
setup.html:4405-4477). - English and zh-CN catalogs are in parity for the 3 new keys. There is no CJK outside
apps/desktop/src/i18n/locales/and none in the commit message.apps/desktop/AGENTS.mdis updated for the new behaviour. WindowsPrivateRefusalis imported from@linger/local-installation(a package), not acrossapps/*.
Process notes
- Single commit, no merge or fixup commits.
CI
All relevant checks pass: check (desktop), check (packages), check (installer), check (web), repository-gate, changes, CodeQL. Checks for other apps were skipped by path filters. The native Windows tests in windows-private.native.test.ts skip on Linux CI, so they are unverified here. I ran no tests myself.
Automated review by Claude Code
Automated review of 97e7568 by Claude Code.
Summary
Secondary Windows NTFS data drives formatted with the stock
Everyone:(OI)(CI)(F)ACL grantDeleteSubdirectoriesAndFiles,ChangePermissions, andTakeOwnershipon the volume root. Private-path validation intentionally keeps refusing that root ACL withWINDOWS_PRIVATE_PATH_UNSAFE(UNSAFE_PARENT_ACCESS), so another local account cannot replace the private Linger home folder or rewrite the drive root's ACL.mainalready runswindowsPrivateLocationduring Windows install preflight and inchooseLocation(keeping the previous valid location, recordingerrorandrejectedPath, and pre-checking disk space in the redesigned install-location bar). On top of that, this PR adds structured refusal metadata, drive-root subfolder targeting, and localized recovery guidance:apps/desktop/src/main/local-server.ts,shared/setup.ts): extract#checkLocationinLocalServerModulesochooseLocationrecords structuredlocation.refusal(WindowsPrivateRefusal) alongsideerrorandrejectedPathwhenwindowsPrivateLocationrefuses a candidate folder, preserving the previous valid location and itsfreeBytes/minFreeBytesmetadata and clearinglocation.refusalon valid selection, reset, or#ready.installLocationalways targets aLingersubfolder when a drive or filesystem root (such as an emptyF:\) is picked, unless the root already holdsinstancesorinstaller.apps/desktop/src/shell/setup.html,setup.messages.ts,i18n/locales/zh-CN.json):UNSAFE_PARENT_ACCESSon a folder directly on a drive (E:\Linger,F:\) now shows recovery guidance too: use the default location, pick another drive, or remove other accounts' Full Control in<drive> Properties → Security.#location-sub),locationErrorTextsurfaces matching recovery guidance forUNSAFE_PARENT_ACCESSrefusals of both drive-root and nested folders while falling back to the rawlocation.errorfor other errors and preserving disk-space warning precedence and Reset behavior.packages/local-installation/src/windows-private.native.test.ts): coverwindowsPrivateLocationfor refused, existing, and missing candidates and verify that candidates are not created or mutated.Verification
pnpm --filter @linger/desktop typecheck && pnpm --filter @linger/desktop lintpnpm --filter @linger/desktop exec vitest run src/main/local-server.test.ts src/main/setup-window.test.ts src/shell/setup-page.test.ts src/i18n/catalog.test.ts(4/4 test files, 290/290 tests)pnpm --filter @linger/local-installation typecheck && pnpm --filter @linger/local-installation lint && pnpm --filter @linger/local-installation exec vitest run src/windows-private.test.ts(10/10; native Windows tests skip on Linux)pnpm exec commitlint --from origin/main --to HEAD --verbose,pnpm env:inventory:check,bash scripts/ci/check-changed-files.sh origin/main HEAD scripts/ci/app-linted-paths.txt,make check-docscheck (desktop),check (packages),check (installer),check (web),repository-gate,changes,CodeQL)