Skip to content

fix(mister): launch AmigaVision from active install#847

Merged
wizzomafizzo merged 1 commit into
mainfrom
fix/mister-amigavision-launch
May 25, 2026
Merged

fix(mister): launch AmigaVision from active install#847
wizzomafizzo merged 1 commit into
mainfrom
fix/mister-amigavision-launch

Conversation

@wizzomafizzo
Copy link
Copy Markdown
Member

@wizzomafizzo wizzomafizzo commented May 25, 2026

Summary

  • ignore stale AmigaVision listing roots that do not contain an AmigaVision/MegaAGS boot image
  • prefer current games/Amiga installs when scanning MiSTer AmigaVision listings
  • write ags_boot to the active AmigaVision install when launching from a stale indexed path

Validation

  • go test ./pkg/platforms/mister/...
  • golangci-lint run ./pkg/platforms/mister/...

Summary by CodeRabbit

  • New Features

    • Enhanced Amiga scanner to intelligently detect and prioritize valid AmigaVision installations, preferring paths containing boot images and those matching the expected directory structure.
  • Tests

    • Added comprehensive test coverage for Amiga boot file generation and scanner validation with multiple installation scenarios.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

📝 Walkthrough

Walkthrough

This PR implements dynamic AmigaVision install path discovery for the Mister platform. The Amiga hook now detects the correct install by checking for boot images across configured root directories, optionally verifying game listing containment, and prioritizing paths ending with /games/amiga. The platform scanner reorders candidates accordingly, and tests validate the behavior with multiple installations.

Changes

AmigaVision Install Discovery

Layer / File(s) Summary
Install path discovery helpers
pkg/platforms/mister/cores/hooks.go
The Amiga hook adds bufio import and three helper functions: hasAmigaVisionBootImage checks for required HDF files, findAmigaVisionInstallPath selects from configured roots while prioritizing /games/amiga paths, and amigaListingContains scans listing files for game name matches. The hookAmiga function now computes installPath dynamically instead of using a fixed path.
Path prioritization at platform level
pkg/platforms/mister/platform.go
New helpers partition AmigaVision paths into preferred and other sets based on boot image presence and /games/amiga suffix matching. The AmigaVision launcher scanner iterates over reordered validPaths with preferred paths first, replacing direct iteration over raw system paths.
Hook behavior validation
pkg/platforms/mister/cores/cores_test.go
Test TestHookAmiga_WritesBootFileToActiveInstall creates stale and valid Amiga installs, configures search space, invokes hookAmiga, and verifies the boot file is written to the active install with correct content while the stale install remains unchanged. Helper writeAmigaVisionTestInstall builds directory structures and files for test setup.
Scanner integration tests
pkg/platforms/mister/custom_scanners_test.go
Tests TestAmigaScanner_IgnoresStaleListingRoot and TestAmigaScanner_RequiresBootImage verify the scanner selects valid installs when multiple roots exist and returns empty results without a boot image. Helpers locate the Amiga launcher and write minimal test files.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A rabbit hops through Amiga's dream,
Finding boot images in the stream,
Picking paths where games/amiga gleam,
No stale installs shall intervene,
Fresh discovery keeps the scene clean! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(mister): launch AmigaVision from active install' is concise, clear, and directly describes the primary change—enabling AmigaVision launching from the correct active install.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/mister-amigavision-launch

Comment @coderabbitai help to get the list of available commands and usage tips.

@sentry
Copy link
Copy Markdown

sentry Bot commented May 25, 2026

Codecov Report

❌ Patch coverage is 82.35294% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/platforms/mister/cores/hooks.go 75.00% 8 Missing and 3 partials ⚠️
pkg/platforms/mister/platform.go 95.83% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
pkg/platforms/mister/cores/cores_test.go (1)

34-57: ⚡ Quick win

Add branch tests for new Amiga hook paths.

This test validates the main path, but the new hook logic also introduced additional branches (e.g., demos.txt and alternate boot image handling). Please add focused cases so all new branches are covered.

As per coding guidelines, "Write tests for all new code — see TESTING.md and pkg/testing/README.md".

Also applies to: 59-72

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/platforms/mister/cores/cores_test.go` around lines 34 - 57, Add unit
tests to cover the new branches in the Amiga hook logic: create additional test
cases alongside TestHookAmiga_WritesBootFileToActiveInstall that exercise (1)
the demos.txt branch (call hookAmiga with a path ending in
"listings/demos.txt/<Name>") and (2) the alternate boot image handling (create
installs where the boot file is not "ags_boot" or is located/named differently
and assert correct copy/move behavior and absence in stale paths). Use the same
helpers used in the existing test (e.g., writeAmigaVisionTestInstall) to create
stale and valid installs, reuse config.NewConfig setup with IndexRoot entries,
call hookAmiga(cfg, nil, <path>) for each scenario, and assert the expected boot
file contents/locations and that stale paths no longer contain the boot image;
add separate focused test functions (e.g., TestHookAmiga_HandlesDemosList and
TestHookAmiga_AlternateBootImage) to keep branches isolated.
pkg/platforms/mister/cores/hooks.go (1)

200-207: ⚡ Quick win

Avoid duplicated Amiga boot-image detection logic across layers.

Line 200 and Line 209 duplicate behavior that also exists in pkg/platforms/mister/platform.go (hasAmigaVisionImage / preferred-path rules). Centralizing this into one shared helper reduces drift risk between scanner and hook decisions.

Also applies to: 209-234

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/platforms/mister/cores/hooks.go` around lines 200 - 207, The
hasAmigaVisionBootImage function duplicates logic already present as
hasAmigaVisionImage/preferred-path rules in pkg/platforms/mister/platform.go;
refactor by creating a single shared helper (e.g., ExportedHasAmigaVisionImage
or hasAmigaImageShared) in the mister package or a new helper file and update
both hasAmigaVisionBootImage and the scanner code to call that shared helper,
removing the duplicated checks around "AmigaVision.hdf"/"MegaAGS.hdf" so both
scanner and hooks use the same implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/platforms/mister/cores/hooks.go`:
- Around line 248-254: The scanner loop that searches for gameName (using
bufio.NewScanner, scanner.Scan(), scanner.Text()) currently ignores
scanner.Err() and can silently return false on I/O errors; after the for
scanner.Scan() loop, check scanner.Err() and handle it (return the error or log
it and propagate) instead of unconditionally returning false so calling code can
distinguish "not found" from a read failure; update the function that performs
this file listing check to surface or log the scanner error and only return
false when no error occurred and the name wasn't found.

---

Nitpick comments:
In `@pkg/platforms/mister/cores/cores_test.go`:
- Around line 34-57: Add unit tests to cover the new branches in the Amiga hook
logic: create additional test cases alongside
TestHookAmiga_WritesBootFileToActiveInstall that exercise (1) the demos.txt
branch (call hookAmiga with a path ending in "listings/demos.txt/<Name>") and
(2) the alternate boot image handling (create installs where the boot file is
not "ags_boot" or is located/named differently and assert correct copy/move
behavior and absence in stale paths). Use the same helpers used in the existing
test (e.g., writeAmigaVisionTestInstall) to create stale and valid installs,
reuse config.NewConfig setup with IndexRoot entries, call hookAmiga(cfg, nil,
<path>) for each scenario, and assert the expected boot file contents/locations
and that stale paths no longer contain the boot image; add separate focused test
functions (e.g., TestHookAmiga_HandlesDemosList and
TestHookAmiga_AlternateBootImage) to keep branches isolated.

In `@pkg/platforms/mister/cores/hooks.go`:
- Around line 200-207: The hasAmigaVisionBootImage function duplicates logic
already present as hasAmigaVisionImage/preferred-path rules in
pkg/platforms/mister/platform.go; refactor by creating a single shared helper
(e.g., ExportedHasAmigaVisionImage or hasAmigaImageShared) in the mister package
or a new helper file and update both hasAmigaVisionBootImage and the scanner
code to call that shared helper, removing the duplicated checks around
"AmigaVision.hdf"/"MegaAGS.hdf" so both scanner and hooks use the same
implementation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4501ef3d-1d05-4988-b2de-3b0e718df0f0

📥 Commits

Reviewing files that changed from the base of the PR and between 872bb1a and c97f2b2.

📒 Files selected for processing (4)
  • pkg/platforms/mister/cores/cores_test.go
  • pkg/platforms/mister/cores/hooks.go
  • pkg/platforms/mister/custom_scanners_test.go
  • pkg/platforms/mister/platform.go

Comment on lines +248 to +254
scanner := bufio.NewScanner(f)
for scanner.Scan() {
if scanner.Text() == gameName {
return true
}
}
return false
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Handle scanner read errors in listing checks.

On Line 248, bufio.Scanner errors are ignored; this can silently return false on I/O failure and mis-select the install path.

💡 Proposed fix
 scanner := bufio.NewScanner(f)
 for scanner.Scan() {
 	if scanner.Text() == gameName {
 		return true
 	}
 }
+if err := scanner.Err(); err != nil {
+	log.Warn().Err(err).Str("listing_path", listingPath).Msg("failed reading AmigaVision listing")
+}
 return false
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/platforms/mister/cores/hooks.go` around lines 248 - 254, The scanner loop
that searches for gameName (using bufio.NewScanner, scanner.Scan(),
scanner.Text()) currently ignores scanner.Err() and can silently return false on
I/O errors; after the for scanner.Scan() loop, check scanner.Err() and handle it
(return the error or log it and propagate) instead of unconditionally returning
false so calling code can distinguish "not found" from a read failure; update
the function that performs this file listing check to surface or log the scanner
error and only return false when no error occurred and the name wasn't found.

@wizzomafizzo wizzomafizzo merged commit baecb81 into main May 25, 2026
13 checks passed
@wizzomafizzo wizzomafizzo deleted the fix/mister-amigavision-launch branch May 25, 2026 06:44
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