Skip to content

refactor: consolidate the duplication from the repo review (DRY) (#470) - #473

Merged
Maxaubert merged 7 commits into
mainfrom
refactor/review-dry
Oct 13, 2026
Merged

Maxaubert merged 7 commits into
mainfrom
refactor/review-dry

Conversation

@Maxaubert

Copy link
Copy Markdown
Owner

Closes #470

Consolidates the duplication the 2026-10-13 repo review found (section "DRY and duplication" and related). Refactors only; each finding was re-checked against current main first.

What changed

  1. Exe folder and %LOCALAPPDATA%\Wind: cached wind::ExeDir() and wind::UserDataDir() in config_path.h replace the copies in ResolveIniPath, ResolveLogDir, main.cpp, WindTray (AppDir/g_appDir removed), WindConfig (ExeDir, the WebView2 folder) and SessionKeepPath/RunningModelPath.
  2. trim: one pure wind::TrimWs in ini_edit.h replaces the five copies (config, ini_edit, profiles, tray_items, flyout_tools).
  3. UIAccess token read: ProcessHasUiAccess() in the new Win32 header uiaccess_token.h (with the banned-probe note), used by the Refuse to run without UIAccess, with a message that says how to fix it #460 start gate and the transform engine.
  4. MPO: ReadOverlayTestMode() in mpo.h is the one OverlayTestMode read (it keeps KEY_WOW64_64KEY and the type check). MpoDisabledInRegistry and DetectMpoDisabled use it, and the startup log still shows the raw value.
  5. Kernel object names: kInstanceMutexName, kQuitEventName and kIniWriteMutexName sit next to the tray constants in tray_ipc.h, and all three binaries use them. installer/app.nsh, tools/testenv/lib.ps1, tools/gpu_ab.ps1 and tools/zoom_response_ab.ps1 keep their literals, each with a comment pointing to the header.
  6. Global / UI-only keys: kUiOnlyKeys in profiles.h is now the only C++ list. IsGlobalProfileKey, MakeLiveText, StripUiOnlyKeys and the test all loop over it. A new fixture, tests/fixtures/global_keys.txt, is checked from both sides: by a doctest against kUiOnlyKeys + profile, and by a new node test against the UI's GLOBAL_KEYS (it runs under npm run test:rules).
  7. Profile switch and relaunch: src/profile_switch.h now holds SwitchProfile, LaunchWindExe, RevertModelAfterFailedRelaunch and WriteSessionKeep/ClearSessionKeep. The tray switch, the Settings switch and the tray engine pick share them, and each surface keeps only its own messages and logs.
  8. Render path: RLog, ULog and DiagLog are now one-line macros over wind::Log, so no call site changes and lines are no longer formatted twice. CompileHlsl (hlsl_compile.h) is the one D3DCompile wrapper; each caller keeps its own flags.
  9. build.bat: a :core_exe <define> <manifest> subroutine builds Wind.exe for both the app and uiaccess targets. check now also compiles src\config_ui\main.cpp (into its own object folder).
  10. Version: tools/version.ps1 (Get-WindVersion) is dot-sourced by release.ps1, installer_check.ps1 and both workflows. The alpha and release workflows were changed together. A new tests/test_version.cpp checks WIND_VERSION_STR against the three numbers. It is a test and not a stringize, because the .rc files consume the literal.
  11. testenv: sweep.ps1, shimmer_ab.ps1 and ab_acryl.ps1 now use lib.ps1's Update-IniKnobs, Restart-WindClean and Stop-Wind instead of their own in-place ini rewrite and fixed 2 s quit. The settle time is unchanged.
  12. Theme data: WindConfig's ThemeBackground now reads the generated kPalettes[i].dark.menu instead of four hand-copied colours (same values). A new doctest checks each palette's menu colour against that theme's --bg in ui/src/design/themes.css. The kUiPalettes vs kPalettes id test already existed. flyout_icons.h is left hand-copied: the review says to generate it only if the icon set grows.

Docs: CLAUDE.md (the "add new UI-only keys" rule, the check target) and chapters 01, 02, 05, 08, 09 and 11 now point at the new helpers.

Behaviour notes (intended, minor)

  • The tray's profile switch now writes session.keep before a relaunch, as Settings already did; the copies had drifted. After a switch the session equals the profile, so the next start comes out the same either way.
  • When LOCALAPPDATA is unset (in practice it never is), session.keep and running.model now fall back to %TEMP%\Wind like the ini, logs and WebView2 folder, where before they used .\Wind.
  • WindConfig now launches Wind.exe with the exe folder as its working directory and checks that the file exists first, like the tray already did. Wind sets its own working directory anyway.
  • A failed render-engine shader compile now logs the compiler's error text (before, it failed silently).

Verified

  • build.bat check: exit 0, now including WindConfig's host.
  • build.bat test: exit 0, 632/632 test cases, 98195/98195 assertions. That includes the new fixture, version and themes.css tests.
  • build.bat (Wind.exe + WindTray.exe): exit 0. build.bat uiaccess: exit 0, and the embedded manifest reads uiAccess="true" ("false" for the plain build).
  • npm ci + build.bat config: exit 0.
  • npm run test:rules: 2/2 pass (keybind rules plus the new global keys test). npx playwright test: 205 passed.
  • build.bat installer: exit 0, all 63 installer checks OK. The install smoke test was skipped because the shell is not elevated. WindUA.exe was produced the way release.ps1 does it (uiaccess build renamed), without running release.ps1.
  • . tools/version.ps1; Get-WindVersion prints 0.29.3, which matches src/version.h and WIND_VERSION_STR. All touched .ps1 files parse, and both workflow YAMLs load.
  • Not deployed and not run. Wind.exe needs a field test with the signed UIAccess build.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TdjopXZfsUiesYxYLYHEdH

Maxaubert and others added 7 commits October 14, 2026 01:29
… compiles WindConfig (#470)

The app and uiaccess targets differed only in /DWIND_UIACCESS and the manifest; they now share
one compile/link block. check compiles src\config_ui\main.cpp into its own object folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TdjopXZfsUiesYxYLYHEdH
…470)

RLog, ULog and DiagLog formatted each line twice (vsnprintf, then wind::Log). They are now macros
over wind::Log, so no call site changes. render_engine and upscale_pass share CompileHlsl
(hlsl_compile.h) with their own flags; a failed render shader now logs the compiler text too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TdjopXZfsUiesYxYLYHEdH
#470)

- config_path.h: cached ExeDir() and UserDataDir() replace the GetModuleFileNameW and
  %LOCALAPPDATA%\Wind copies in Wind, WindTray (AppDir) and WindConfig; session.keep and
  running.model use UserDataDir.
- ini_edit.h: one pure TrimWs replaces five trim helpers.
- uiaccess_token.h: ProcessHasUiAccess() is the one token read (startup gate, transform engine).
- mpo.h: ReadOverlayTestMode() is the one OverlayTestMode read; DetectMpoDisabled uses it.
- tray_ipc.h: kInstanceMutexName, kQuitEventName and kIniWriteMutexName; the NSIS and PowerShell
  copies point there.
- profiles.h: kUiOnlyKeys is the one list behind IsGlobalProfileKey, MakeLiveText and
  StripUiOnlyKeys. tests/fixtures/global_keys.txt pins it and the UI's GLOBAL_KEYS together.
- profile_switch.h: SwitchProfile, LaunchWindExe, RevertModelAfterFailedRelaunch and the
  session.keep helpers, shared by the tray profile switch, the Settings switch and the tray
  engine pick. The tray switch now also writes session.keep before a relaunch, as Settings did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TdjopXZfsUiesYxYLYHEdH
…inst the numbers (#470)

tools/version.ps1 defines Get-WindVersion. release.ps1, installer_check.ps1 and the release and
alpha workflows dot-source it instead of carrying their own regex block. tests/test_version.cpp
fails when WIND_VERSION_STR drifts from WIND_VER_MAJOR.MINOR.PATCH (the .rc files need the
literal, so it is not stringized).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TdjopXZfsUiesYxYLYHEdH
…and ini helpers (#470)

The local Set-Knobs / Set-Mode / Restart-Wind copies rewrote the ini in place and assumed Wind
quit within a fixed 2 s. They now use Update-IniKnobs (sanity check, atomic replace),
Restart-WindClean and Stop-Wind (wait for the clean exit), keeping the same settle time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TdjopXZfsUiesYxYLYHEdH
…es, tested against themes.css (#470)

ThemeBackground hand-copied the four --bg colours. It now reads the generated flyout palette's
menu colour (same values), and tests/test_flyout_palettes.cpp checks each one against that theme's
--bg in ui/src/design/themes.css, so the two generators cannot drift apart unnoticed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TdjopXZfsUiesYxYLYHEdH
@Maxaubert
Maxaubert force-pushed the refactor/review-dry branch from 625b72b to 047165c Compare October 13, 2026 23:30
@Maxaubert
Maxaubert merged commit 4558701 into main Oct 13, 2026
1 check passed
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.

refactor: consolidate duplication from the 2026-10-13 repo review (DRY)

1 participant