ui: Mark the active mod profile #50

Merged
linus merged 1 commit from ash/active-profile into develop 2026-10-27 14:33:23 +00:00
Collaborator

Closes #49

Why

The window showed one button per profile and nothing told you which one the Game Mod Directory currently points at.

What changed

  • switcher.Active(profilesDir, modsPath) reads (never writes) the mods path: Lstat, Readlink, Stat only. It reports Linked (with the profile), RealFolder, Missing, Outside (link points outside the Mod Profiles Directory, or at the directory itself / a file) or Dangling (link to a profile that no longer exists). Relative link targets resolve against the link's folder; Windows paths compare case-insensitively.
  • main.go: fillGrid shows one plain status line at the top ("Active profile: X" or "No active profile: ..."), and the active profile's button is labeled "X (active)", high-importance, with a check icon. Other profiles are unmarked.
  • After any click, fillGrid re-reads the link, so the mark moves right away on success and stays on the truly active profile on failure; the error dialog is unchanged. Switch itself is untouched (#45/#46 behavior as is).

Tests

New switcher/active_test.go (6 tests): link to a profile (and the mark moving after a switch), relative link, real folder, missing folder, dangling link, link outside the profiles dir. Each test snapshots the tree before/after and fails if Active changed anything. No skips; they run in both the Linux Test job and the Windows "Test on windows" step. Local: go test -race -v -shuffle=on ./switcher/ = 10/10 PASS; GOOS=windows go vet ./switcher/ clean.

No CI or release files touched.

Risk / rollback

UI-only plus a read-only helper. Revert is a plain git revert; no data or config migration.

Closes #49 ## Why The window showed one button per profile and nothing told you which one the Game Mod Directory currently points at. ## What changed - `switcher.Active(profilesDir, modsPath)` reads (never writes) the mods path: `Lstat`, `Readlink`, `Stat` only. It reports Linked (with the profile), RealFolder, Missing, Outside (link points outside the Mod Profiles Directory, or at the directory itself / a file) or Dangling (link to a profile that no longer exists). Relative link targets resolve against the link's folder; Windows paths compare case-insensitively. - `main.go`: `fillGrid` shows one plain status line at the top ("Active profile: X" or "No active profile: ..."), and the active profile's button is labeled "X (active)", high-importance, with a check icon. Other profiles are unmarked. - After any click, `fillGrid` re-reads the link, so the mark moves right away on success and stays on the truly active profile on failure; the error dialog is unchanged. `Switch` itself is untouched (#45/#46 behavior as is). ## Tests New `switcher/active_test.go` (6 tests): link to a profile (and the mark moving after a switch), relative link, real folder, missing folder, dangling link, link outside the profiles dir. Each test snapshots the tree before/after and fails if `Active` changed anything. No skips; they run in both the Linux Test job and the Windows "Test on windows" step. Local: `go test -race -v -shuffle=on ./switcher/` = 10/10 PASS; `GOOS=windows go vet ./switcher/` clean. No CI or release files touched. ## Risk / rollback UI-only plus a read-only helper. Revert is a plain `git revert`; no data or config migration.
ui: Mark the active mod profile
All checks were successful
CI / Build windows (pull_request) Successful in 16s
CI / Lint (pull_request) Successful in 52s
CI / Build (pull_request) Successful in 56s
CI / Test (pull_request) Successful in 1m8s
bb17f12a65
ash requested review from eva 2026-10-27 14:29:39 +00:00
eva approved these changes 2026-10-27 14:32:11 +00:00
eva left a comment

GO on bb17f12.

This does what #49 asks. Active only reads the mods path (Lstat, Readlink, Stat), and the tests snapshot the tree before and after each call, so they'd catch a write. The checks match how Switch makes the link (a plain symlink on both platforms), relative targets resolve against the link's folder, and a link to the profiles folder itself or to a file isn't counted as a profile. Re-running fillGrid after every click keeps the mark honest even when the switch fails. Switch is unchanged.

The head is on the current develop tip and all four CI checks are green (Lint, Test, Build, Build windows). No CI, release, dependency or auth changes, so this doesn't need a security review. Linus can merge.

GO on bb17f12. This does what #49 asks. `Active` only reads the mods path (`Lstat`, `Readlink`, `Stat`), and the tests snapshot the tree before and after each call, so they'd catch a write. The checks match how `Switch` makes the link (a plain symlink on both platforms), relative targets resolve against the link's folder, and a link to the profiles folder itself or to a file isn't counted as a profile. Re-running `fillGrid` after every click keeps the mark honest even when the switch fails. `Switch` is unchanged. The head is on the current develop tip and all four CI checks are green (Lint, Test, Build, Build windows). No CI, release, dependency or auth changes, so this doesn't need a security review. Linus can merge.
linus merged commit 16b6e8fd36 into develop 2026-10-27 14:33:23 +00:00
linus deleted branch ash/active-profile 2026-10-27 14:33:23 +00:00
Sign in to join this conversation.
No reviewers
eva
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
s1d3sw1ped/SwipedModSwitcher!50
No description provided.