launcher: run the emulator from a per-user data directory on macOS (#2491) #2514

Open
github-bot wants to merge 1 commit from github-bot/gh-2514 into main AGit
Owner

@⁠mitsa-ng on GitHub · 2026-11-22 09:50 UTC · original
mitsa-ng:launcher-macos-data-location → main · +28 −0 · 1 files · 1 commits · open

Fixes #2491.

Problem

The launcher started kyty_emulator with the working directory set to Contents/MacOS inside the bundle, so _SaveData, _PipelineCache, _TempData, _DownloadData and the log all lived inside KytyPS5.app: replacing the app (the usual macOS update path) deleted the saves, standard accounts in /Applications cannot write there, and the new folders break the code-signature seal.

Change

Implements the approach proposed by @⁠rafalohaki in the issue: on macOS run the emulator from ~/Library/Application Support/KytyPS5 (created on first launch) and move the four data folders an older launcher left in the bundle there once; a rename that fails (cross-volume, no write access) leaves the old copy in place rather than dropping anything. Other platforms keep the install-folder working directory.

Evidence

Green on Windows/Linux/macOS CI with this branch on my fork (run 44985643134).

Written with AI assistance (ZCode); built by the author.

**@⁠mitsa-ng** on GitHub · 2026-11-22 09:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2514) `mitsa-ng:launcher-macos-data-location` → `main` · +28 −0 · 1 files · 1 commits · open Fixes #2491. ## Problem The launcher started `kyty_emulator` with the working directory set to `Contents/MacOS` inside the bundle, so `_SaveData`, `_PipelineCache`, `_TempData`, `_DownloadData` and the log all lived inside `KytyPS5.app`: replacing the app (the usual macOS update path) deleted the saves, standard accounts in `/Applications` cannot write there, and the new folders break the code-signature seal. ## Change Implements the approach proposed by @⁠rafalohaki in the issue: on macOS run the emulator from `~/Library/Application Support/KytyPS5` (created on first launch) and move the four data folders an older launcher left in the bundle there once; a rename that fails (cross-volume, no write access) leaves the old copy in place rather than dropping anything. Other platforms keep the install-folder working directory. ## Evidence Green on Windows/Linux/macOS CI with this branch on my fork ([run 44985643134](https://github.com/mitsa-ng/KytyPS5/actions/runs/44985643134)). Written with AI assistance (ZCode); built by the author.
The emulator writes its saves, caches and log next to its working
directory, which the launcher set to Contents/MacOS inside the bundle;
replacing the app deleted them, standard accounts in /Applications
cannot write there, and the new folders break the code-signature seal.
Run from ~/Library/Application Support/KytyPS5 instead and move what an
older launcher left in the bundle there once. Other platforms keep the
install-folder working directory.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:21:46 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-22 09:54 UTC · original

Explain Change →

Walkthrough

On macOS, the launcher now selects a per-user app-data directory for the emulator’s working directory. It appends KytyPS5 when needed, falls back to the bundle directory if directory creation fails, and attempts to rename four existing data folders when their destinations do not exist. Other platforms continue to use the interpreter’s containing directory as the working directory.

Suggested reviewers: nmzik, pipe530

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Moderate · up to 9329a

On macOS, the launcher will no longer find a game's saves after they move to the per-user folder, so the remove-save-data action reports that nothing was found. If a save folder fails to migrate, the old saves stay inside the app and can be lost when the app is replaced. Fix both before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: on macOS the launcher runs the emulator from a per-user data directory. It matches the raw summary (EmulatorDataDirectory, working directory set to the per-user locati…
Description check Passed The description states the problem (emulator data stored inside KytyPS5.app, lost on update, write failures for standard users, broken code-signature seal), the change (per-user data directory on macO…
Linked Issues check Passed [#2491] requires that macOS emulator data leave KytyPS5.app, that saves survive app replacement, that standard accounts can write data, and that the bundle seal is not broken by new files. The diff to…
Out of Scope Changes check Passed The reviewed whole-PR diff against the merge base changes only src/launcher/src/mainDialog.cpp, with +28/-0 lines. The change adds the QStandardPaths include, the macOS-only EmulatorDataDirectory help…
Full details: Title check

Explanation

The title names the main change: on macOS the launcher runs the emulator from a per-user data directory. It matches the raw summary (EmulatorDataDirectory, working directory set to the per-user location) and the objectives. It also cites the issue number, which is acceptable. Length is slightly long but the title is clear and specific.

Full details: Description check

Explanation

The description states the problem (emulator data stored inside KytyPS5.app, lost on update, write failures for standard users, broken code-signature seal), the change (per-user data directory on macOS, one-time move of four data folders, fallback when a rename fails), and CI evidence. It is directly related to the changeset.

Full details: Linked Issues check

Explanation

[#2491] requires that macOS emulator data leave KytyPS5.app, that saves survive app replacement, that standard accounts can write data, and that the bundle seal is not broken by new files. The diff to src/launcher/src/mainDialog.cpp (merge base to head) adds EmulatorDataDirectory(). On APPLE, RunInterpreter() now sets the process working directory to ~/Library/Application Support/KytyPS5 (created with QDir().mkpath). The emulator resolves _SaveData, _PipelineCache, _TempData, _DownloadData and _kyty.txt relative to its working directory, so these now resolve outside the bundle. The function also moves the four data folders from the bundle to the new directory once, when the destination folder does not exist. Non-Apple builds keep the install-folder working directory, as the issue does not request a change there. Gaps: no automated test was added. The issue states that the behavior was verified only by a log-file check. The rename path depends on the filesystem and was not exercised. When a destination folder already exists, the bundle copy is left in place and is not moved. The author documents these cases as intended. The requirements are behavioral and the code implements them, so the assessment is PASS.

Full details: Out of Scope Changes check

Explanation

The reviewed whole-PR diff against the merge base changes only src/launcher/src/mainDialog.cpp, with +28/-0 lines. The change adds the QStandardPaths include, the macOS-only EmulatorDataDirectory helper, and a macOS-only branch for the working directory. Each change serves the objective of #2491. The Windows and Linux branch keeps the original behavior. No unrelated files or refactors were identified in the evidence available.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

**@⁠coderabbitai[bot]** on GitHub · 2026-11-22 09:54 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2514#issuecomment-7077451565) <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/2514?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> <br> On macOS, the launcher now selects a per-user app-data directory for the emulator’s working directory. It appends `KytyPS5` when needed, falls back to the bundle directory if directory creation fails, and attempts to rename four existing data folders when their destinations do not exist. Other platforms continue to use the interpreter’s containing directory as the working directory. **Suggested reviewers:** `nmzik`, `pipe530` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"9329a186ab63311570da53120d35903792e71532" --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> **Change:** Bug fix · **Severity of issue fixed:** Medium <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Moderate</strong> · up to <code>9329a</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `9329a` --> <!-- final_review_risk_coverage:{"sourceCommitId":"9329a186ab63311570da53120d35903792e71532","coveredCommitId":"9329a186ab63311570da53120d35903792e71532","kind":"reviewed"} --> On macOS, the launcher will no longer find a game's saves after they move to the per-user folder, so the remove-save-data action reports that nothing was found. If a save folder fails to migrate, the old saves stay inside the app and can be lost when the app is replaced. Fix both before merging. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary> <dl> <dd> <br> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title names the main change: on macOS the launcher runs the emulator from a per-user data directory. It matches the raw summary (EmulatorDataDirectory, working directory set to the per-user locati… | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description states the problem (emulator data stored inside KytyPS5.app, lost on update, write failures for standard users, broken code-signature seal), the change (per-user data directory on macO… | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | [`#2491`] requires that macOS emulator data leave KytyPS5.app, that saves survive app replacement, that standard accounts can write data, and that the bundle seal is not broken by new files. The diff to… | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The reviewed whole-PR diff against the merge base changes only src/launcher/src/mainDialog.cpp, with +28/-0 lines. The change adds the QStandardPaths include, the macOS-only EmulatorDataDirectory help… | <details> <summary><strong>Full details: Title check</strong></summary> <dl> <dd> <br> **Explanation** The title names the main change: on macOS the launcher runs the emulator from a per-user data directory. It matches the raw summary (EmulatorDataDirectory, working directory set to the per-user location) and the objectives. It also cites the issue number, which is acceptable. Length is slightly long but the title is clear and specific. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> <br> **Explanation** The description states the problem (emulator data stored inside KytyPS5.app, lost on update, write failures for standard users, broken code-signature seal), the change (per-user data directory on macOS, one-time move of four data folders, fallback when a rename fails), and CI evidence. It is directly related to the changeset. </dd> </dl> </details> <details> <summary><strong>Full details: Linked Issues check</strong></summary> <dl> <dd> <br> **Explanation** [`#2491`] requires that macOS emulator data leave KytyPS5.app, that saves survive app replacement, that standard accounts can write data, and that the bundle seal is not broken by new files. The diff to src/launcher/src/mainDialog.cpp (merge base to head) adds EmulatorDataDirectory(). On __APPLE__, RunInterpreter() now sets the process working directory to ~/Library/Application Support/KytyPS5 (created with QDir().mkpath). The emulator resolves _SaveData, _PipelineCache, _TempData, _DownloadData and _kyty.txt relative to its working directory, so these now resolve outside the bundle. The function also moves the four data folders from the bundle to the new directory once, when the destination folder does not exist. Non-Apple builds keep the install-folder working directory, as the issue does not request a change there. Gaps: no automated test was added. The issue states that the behavior was verified only by a log-file check. The rename path depends on the filesystem and was not exercised. When a destination folder already exists, the bundle copy is left in place and is not moved. The author documents these cases as intended. The requirements are behavioral and the code implements them, so the assessment is PASS. </dd> </dl> </details> <details> <summary><strong>Full details: Out of Scope Changes check</strong></summary> <dl> <dd> <br> **Explanation** The reviewed whole-PR diff against the merge base changes only src/launcher/src/mainDialog.cpp, with +28/-0 lines. The change adds the QStandardPaths include, the macOS-only EmulatorDataDirectory helper, and a macOS-only branch for the working directory. Each change serves the objective of `#2491`. The Windows and Linux branch keeps the original behavior. No unrelated files or refactors were identified in the evidence available. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=2514)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>Share</strong></summary> <dl> <dd> <br> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <!-- tips_end -->
@ -340,0 +354,4 @@
const QString from = QDir(bundle_dir).absoluteFilePath(QString::fromLatin1(name));
const QString to = data_dir + '/' + name;
if (QFile::exists(from) && !QFile::exists(to)) {
QDir().rename(from, to);
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-22 09:54 UTC · original

Major · Data Integrity & Integration · Quick win

Handle migration failure before continuing the launch.

If _SaveData cannot move, this call returns false, but the helper still returns data_dir. Qt 6.8 documents this failure result for QDir::rename. (doc.qt.io)

The old saves remain only inside the app bundle. Replacing the app can therefore still delete them, contrary to the migration objective.

Check the result. If required data cannot migrate, stop with an actionable error or complete a verified copy before continuing. Do not simply return bundle_dir after the loop: other folders might already have moved. Keep the current launch path when migration succeeds.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-22 09:54 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2514#discussion_r4657607052) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Quick win** **Handle migration failure before continuing the launch.** If `_SaveData` cannot move, this call returns `false`, but the helper still returns `data_dir`. Qt 6.8 documents this failure result for `QDir::rename`. ([doc.qt.io](https://doc.qt.io/qt-6.8/qdir.html)) The old saves remain only inside the app bundle. Replacing the app can therefore still delete them, contrary to the migration objective. Check the result. If required data cannot migrate, stop with an actionable error or complete a verified copy before continuing. Do not simply return `bundle_dir` after the loop: other folders might already have moved. Keep the current launch path when migration succeeds. <!-- fingerprinting:phantom:poseidon:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:331759e551fd0001c4f37b82 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -451,2 +475,4 @@
CmdCommand(QDir::toNativeSeparators(interpreter), args, close_terminal));
#endif
#if defined(__APPLE__)
process->setWorkingDirectory(EmulatorDataDirectory(QFileInfo(interpreter).absolutePath()));
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-22 09:54 UTC · original

Major · Functional Correctness · Quick win

The save-data lookup misses saves on macOS.

GetSaveDataDirs searches only the launcher's current directory, the application directory, and their parents. On macOS, the emulator now runs from ~/Library/Application Support/KytyPS5, and its saves are written there. That directory is not one of the lookup roots, and the launcher does not change its own current directory to it. As a result, the remove-save-data action reports "No save data folder found for this game." for macOS games whose saves are in the new location. The same lookup also determines the menu state at configurationListWidget.cpp:1280.

The save-data lookup must search the same per-user data root that RunInterpreter uses as the emulator working directory on macOS. Other platforms keep their current roots.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-22 09:54 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2514#discussion_r4657607055) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Quick win** **The save-data lookup misses saves on macOS.** `GetSaveDataDirs` searches only the launcher's current directory, the application directory, and their parents. On macOS, the emulator now runs from `~/Library/Application Support/KytyPS5`, and its saves are written there. That directory is not one of the lookup roots, and the launcher does not change its own current directory to it. As a result, the remove-save-data action reports "No save data folder found for this game." for macOS games whose saves are in the new location. The same lookup also determines the menu state at `configurationListWidget.cpp:1280`. The save-data lookup must search the same per-user data root that `RunInterpreter` uses as the emulator working directory on macOS. Other platforms keep their current roots. <!-- fingerprinting:phantom:poseidon:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:91e5a8ced5776326c12c944c --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-22 09:55 UTC · original · reviewed

Actionable comments posted: 2

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6133172164 and 9329a186ab.

Files selected for processing: 1

  • src/launcher/src/mainDialog.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-22 09:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2514#pullrequestreview-6011585890) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 2** <h6> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <br> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/613317216495ad7c98ea0e3743cded89d4596062/.coderabbit.yaml>) - **Commit**: [6133172](<https://github.com/KytyPS5/KytyPS5/commit/613317216495ad7c98ea0e3743cded89d4596062>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `5f6962cd-a9b1-47fa-8bb8-97ee2fddf7b5` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between 613317216495ad7c98ea0e3743cded89d4596062 and 9329a186ab63311570da53120d35903792e71532. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 1</summary> <dl> <dd> <br> * `src/launcher/src/mainDialog.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. </dd> </dl> </details> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=33d709ed-924d-4472-9f28-7cf517c0ddfe attempt=8cfcb075-db71-42bc-b7b7-1ed5bb9b5ae6 batch=1/1 -->
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2514/head:github-bot/gh-2514'
git switch 'github-bot/gh-2514'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2514'
git switch 'github-bot/gh-2514'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2514'
git switch 'github-bot/gh-2514'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2514'
git switch 'main'
git merge --squash 'github-bot/gh-2514'
git switch 'main'
git merge --ff-only 'github-bot/gh-2514'
git switch 'main'
git merge 'github-bot/gh-2514'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.