Skip to content

refactor(windows): replace wallpaper helper with isolated Python runtime - #269

Merged
Lucas1479 merged 9 commits into
mainfrom
codex/python-wallpaper-helper
Oct 26, 2026
Merged

Lucas1479 merged 9 commits into
mainfrom
codex/python-wallpaper-helper

Conversation

@Lucas1479

@Lucas1479 Lucas1479 commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Problem and resulting behavior

Replace the self-contained .NET Windows wallpaper helper with an independent, standard-library Python helper shipped with Electron. All helper entry points use -I -S with the backend runtime selected by pythonRuntime.ts; the selected environment's site initialization and .pth hooks do not execute. Windows sessions prefer pythonw.exe beside the selected python.exe to avoid a detached venv interpreter allocating a console. Remove the replaced C# projects, runtime-only notices and .NET build/CI prerequisites.

Electron retains lifecycle/status ownership. Existing PascalCase journals, string phases, exact .NET UTC creation ticks and Settings field bytes remain compatible. Only Settings fields 28/48/49 are rewritten. The actual Set pipe receiver is persisted before any request bytes. Known Lively reporting/close limitations in #233 remain.

Refs #264; based after merged #261.

Review fixes

Current follow-up commit: 482f2365.

  • Cross-session discovery: read process/session membership from the native system snapshot before opening current-session Lively candidates. Foreign-session access restrictions cannot block every command. Snapshot failures and denied selected identities remain visible errors; access denial is never treated as proof that a receiver exited.
  • Interpreter isolation: use -I -S in Electron, setup, smoke and lifecycle helper invocations. Source/packaged resource tests use a controlled temporary-venv .pth hook, including a positive control proving that -I alone executes it.
  • Electron crash recovery: launch with detached: true while keeping pipes and normal shutdown waiting. Actual Electron parent tests exercise a Windows venv launcher and the real helper main/Session/journal lock with a synthetic desktop. A non-detached control reproduces interrupted recovery; the fixed launch restores after taskkill /F without /T and removes the journal. Normal shutdown passes too.
  • N1, detached venv console: the F3 fix introduced a console allocation regression despite windowsHide. Reproduced before production repair by adding GetConsoleWindow() == NULL to the real Electron fixture. Sessions now use the same-directory pythonw.exe when present; setup keeps the original interpreter. All three parent modes verify no associated console, usable standard pipes, isolated mode and absent site initialization. Source and packaged tests verify the windowed runtime path and mounted/stdin/exit round trip.
  • The earlier Unicode path repair remains covered: Windows ordinal comparison preserves physically distinct user projects. It intentionally follows Windows path casing, which differs from some .NET 8 managed comparer aliases.

The independent agent reviewed N1 without edits and independently passed 25 Electron isolation/lifecycle/parent-exit cases. It also verified actual pythonw.exe stderr failure propagation and missing-sibling/custom-name selection, finding no actionable defect. The earlier F1/F2/F3 review independently passed 95 helper tests. These are advisory reviews, not GitHub approval.

The earlier “actual parent death” claim tested a Python parent, which does not cover Electron/libuv's kill-on-parent-exit Job. Documentation and evidence now distinguish those scenarios. Detachment does not guarantee survival after explicit tree termination, logoff or power loss.

Validation

Current follow-up:

  • Python wallpaper contracts: 95 passed, including Pending dispatch/deadline/cancellation, live C#/Python creation-tick equality, old journals, raw Settings preservation and snapshot session filtering.
  • Full Electron suite: 706 passed, 0 skipped, including all three real-parent modes.
  • Build and Windows code-only unpacked packaging passed; native tray/helper smoke passed and packaged helper bytes match source.
  • Actual packaged model-less application: 15 checks passed, including frontend/backend exit.
  • Actual Electron + installed-Lively startup, scene connection, control-panel open/close and quit restoration passed with the windowed session launch.
  • Changed Python lint and whitespace checks passed.
  • Clean source/provenance gate at 482f2365: 4,288 selected files, 161 excluded, 0 errors/warnings; code-only source archive created.

Historical full Python coverage at initial candidate f7408163: 503 files, 6,703 passed, 19 skipped, 5 expected failures. This was a split/resumed run; only the stalled 55-case profile-contract file used UV_OFFLINE=1, retaining assertions and --locked. It is not a fresh full-Python run at the current head. The previous head 78b48a9c completed all 16 hosted checks successfully; new-head CI is evaluated separately. That head also passed installed-Lively normal exit, pipe loss, helper-crash recovery, Python-parent death and fresh-settings cold start.

Helper resources excluding the common setup script: 74,922,671 → 58,761 bytes. Ten alternating read-only samples at 78b48a9c measured local medians of 239.5 ms (-I) and 218 ms (-I -S). These measurements do not attribute the initial .NET-to-Python timing difference entirely to site initialization.

Commands, review repairs, evidence and limitations.

Draft / remaining qualification

  • Remains draft and requires formal non-author GitHub approval before merge.
  • Cross-session filtering uses fake APIs plus native snapshot checks; an actual second-account Lively session was not exercised. The Electron force-kill regression uses a synthetic desktop; real-desktop probes cover separate normal/crash-recovery paths.
  • If the windowed sibling is missing, or the selected command has a custom name, preserve the selected runtime. Console absence is not established for those fallback/custom distributions. Manually closing an unwanted terminal was not reproduced as a desktop-loss scenario.
  • Installed Lively is the locally repaired 2.2.1.0 from Windows wallpaper recovery: Lively false-empty reports and unconfirmed project close #233. Unmodified official Lively, a machine without a modern .NET SDK/runtime, physical multiple displays and full release artifacts still need qualification.
  • Unchanged dependency locks still fail the high-severity npm audit gate (Electron: 2 high/1 moderate; Pi: 1 high/1 moderate). No dependency version, audit exemption or test gate is relaxed.
  • .NET 8 support ends 2026-11-10. If replacement cannot be qualified in time, retarget the old release helper/CI to .NET 10 separately.

@Lucas1479
Lucas1479 marked this pull request as ready for review October 26, 2026 11:15
@Lucas1479
Lucas1479 merged commit 1ce2b07 into main Oct 26, 2026
16 checks passed
@Lucas1479
Lucas1479 deleted the codex/python-wallpaper-helper branch October 26, 2026 11:15
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.

1 participant