Skip to content

fix(zapscript): apply system launcher defaults to path launches#897

Merged
wizzomafizzo merged 3 commits into
mainfrom
fix/system-default-launcher-paths
Jun 6, 2026
Merged

fix(zapscript): apply system launcher defaults to path launches#897
wizzomafizzo merged 3 commits into
mainfrom
fix/system-default-launcher-paths

Conversation

@wizzomafizzo

@wizzomafizzo wizzomafizzo commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

  • apply configured system default launchers to path-based launches once the system can be inferred
  • apply defaults to launch.search and launch.random based on the selected media result
  • resolve launcher group defaults within the target system so API-accepted group values launch correctly

Verified locally with go test ./pkg/zapscript/, go test ./pkg/api/methods/, and task lint-fix.

Summary by CodeRabbit

  • New Features

    • System-default launcher selection now automatically applies when launching, searching, and using random media.
    • Path-based launcher inference picks the best launcher for a given file path when no explicit launcher is set.
    • Explicit launcher arguments continue to override inferred or system-default choices.
  • Tests

    • Added comprehensive tests covering launcher inference, system-default resolution, group-default behavior, and history-based launcher selection.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Need an answer fast? Review this PR in Change Stack to ask focused questions about the PR or a changed range.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0f82d998-d707-4f82-93e4-dbc279b64901

📥 Commits

Reviewing files that changed from the base of the PR and between fa09a29 and fb1cac6.

📒 Files selected for processing (3)
  • pkg/zapscript/launch.go
  • pkg/zapscript/launch_last_test.go
  • pkg/zapscript/launch_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/zapscript/launch.go

📝 Walkthrough

Walkthrough

Adds launcher-resolution and path-based inference, then applies resolved/inferred system-default launchers across launch-related command handlers and title handling, with tests validating inferred defaults, explicit overrides, and group-to-system resolution.

Changes

System default launcher resolution

Layer / File(s) Summary
Launcher resolution and inference mechanism
pkg/zapscript/launch.go
New functions resolve system-default launcher references to concrete IDs using platform launcher definitions, infer launchers from ROM filesystem/URI paths using a scoring heuristic, and apply inferred defaults to launch arguments.
Apply system defaults across command handlers
pkg/zapscript/launch.go, pkg/zapscript/titles.go
cmdLaunch, cmdRandom, cmdSearch, cmdLaunchLast, and cmdTitle call the launcher-application functions after system determination, path/URI resolution, and DB queries so a default launcher is set based on inferred system or result system ID.
Test coverage for launcher resolution
pkg/zapscript/launch_test.go, pkg/zapscript/launch_last_test.go
New tests verify absolute ROM path inference, explicit launcher argument precedence, system-default group resolution within target systems, default launcher application for search/random results, and launch.last history behavior.

Sequence Diagram

sequenceDiagram
  participant cmdLaunch as cmdLaunch/cmdRandom/cmdSearch/cmdLaunchLast
  participant apply as applySystemDefaultLauncher
  participant resolve as resolveLauncherRefForSystem
  participant infer as inferLauncherForPath
  participant launch as LaunchMedia

  cmdLaunch->>apply: invoke after system/media selection or path resolution
  apply->>resolve: resolve system-default reference to concrete launcher ID
  apply->>infer: infer launcher from path/URI when applicable
  apply->>launch: call LaunchMedia with resolved/inferred launcher
  launch-->>cmdLaunch: return launch result
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • ZaparooProject/zaparoo-core#778: Updates absolute path handling in launch command tests across platforms to support the new launcher inference from absolute ROM paths.

Poem

🐰 I sniff the paths, I tally scores with glee,
I match the launcher to the ROM I see,
Commands now ask, and I reply with grace—
The right emulator to run each case! 🎮

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.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 accurately summarizes the main change: applying system launcher defaults to path-based launches, which is the primary objective across all modified files (launch.go, launch_test.go, titles.go, launch_last_test.go).
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/system-default-launcher-paths

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

@sentry

sentry Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.51807% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/zapscript/launch.go 79.26% 14 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@wizzomafizzo

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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/zapscript/launch_test.go`:
- Around line 164-318: Add positive tests that exercise the new launcher-default
selection branches for launch.random's filesystem fallback and cmdLaunchLast:
create fixtures with multiple platforms.Launcher entries (including
grouped/default and explicit alternatives), stub mockPlatform.Launchers and
mockPlatform.RootDirs/Settings as needed, then call launch.random (or trigger it
via cmdLaunch with arguments that force random selection) and call cmdLaunchLast
with an absolute-path target to verify the chosen launcher ID (use
mockPlatform.On("LaunchMedia", ..., mock.MatchedBy(func(l *platforms.Launcher)
bool { return l != nil && l.ID == "<expected-id>" })) to assert selection).
Ensure tests cover both the filesystem fallback case and the DB-backed random
path so the branches in cmdLaunch and cmdLaunchLast that resolve default/group
launchers are exercised and assertions check result.MediaChanged and
mockPlatform.AssertExpectations.

In `@pkg/zapscript/launch.go`:
- Around line 97-101: The loop that returns a launcher ID currently ignores
SystemID and may return a launcher from the wrong system; update the resolution
in the code that iterates over launchers (the block using launchers, ref) to
only accept a match when either launchers[i].SystemID equals the intended target
system ID (e.g. a local systemID variable) or when launchers[i].SystemID is
empty (truly generic); do not fall back to the first global ID match, and ensure
the function returns no match (false) if no launcher for the target system or a
generic one is found.
🪄 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: 8b2d9cbd-7fda-454c-976b-d5d0cb87d058

📥 Commits

Reviewing files that changed from the base of the PR and between 46b1d7c and fa09a29.

📒 Files selected for processing (3)
  • pkg/zapscript/launch.go
  • pkg/zapscript/launch_test.go
  • pkg/zapscript/titles.go

Comment thread pkg/zapscript/launch_test.go
Comment thread pkg/zapscript/launch.go
@wizzomafizzo
wizzomafizzo merged commit bae4f00 into main Jun 6, 2026
12 checks passed
@wizzomafizzo
wizzomafizzo deleted the fix/system-default-launcher-paths branch June 6, 2026 00:04
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