Repository navigation
feat: US-004 - Companion lifecycle on external launch (start/stop/resume + atomic persisted state) - #9
Merged
Conversation
…ume + atomic persisted state) - External launch: GameCompanionStore.StartForGameAsync already calls IGameCompanionStore.Start; for non-Embedded emulators it now also persists ExternalCompanionState and starts ExternalSaveMonitor (US-003). - Back in PKForge: HomePage.WatchTrophiesAfterResumeAsync (App.Resumed) calls companion.StopExternal() (monitor.Stop + persisted state cleared) before companion.Stop(), then the existing trophy watcher re-scans. - App restart mid-game: first HomePage appear calls ResumeExternalIfAny(), which restarts the monitor from the persisted state. Emulator killed or save gone -> the watch degrades to Missing, never crashes. - New Domain contract: ExternalCompanionState record + IExternalCompanionStateStore. Infrastructure: JsonExternalCompanionStateStore - same atomic JSON pattern as JsonConsoleEmulatorStore (temp + File.Move overwrite, corrupt file -> null). Registered in MauiProgram on AppDataDirectory/external-companion.json. 5 new store tests (empty, set/clear, reopen-after-kill, corrupt file, in-memory null path). prd.json: US-004 passes=true. progress.txt: appended learnings. Co-authored-by: Varonal <Varonal@users.noreply.github.com>
…on.cs Co-authored-by: Varonal <Varonal@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary (US-004)
Lifecycle du companion externe, branché sur les hooks existants :
GameCompanionStore.StartForGameAsync→IGameCompanionStore.Start) : pour un émulateur non-Embedded, on persisteExternalCompanionStateet on démarreExternalSaveMonitor(US-003).App.Resumed→HomePage.WatchTrophiesAfterResumeAsync) :companion.StopExternal()(monitor off + état clear) puiscompanion.Stop(), puis le watcher de trophées existant re-scanne — ordre conservé.ResumeExternalIfAny()relance le monitor depuis l'état persisté. Émulateur tué / save disparue → le watch voitMissing→ mode no-save, aucun crash.Persistance : nouveau contrat Domain
ExternalCompanionState+IExternalCompanionStateStore;JsonExternalCompanionStateStore(Infrastructure) suit le pattern JSON atomique existant (temp +File.Move(overwrite:true), fichier corrompu → null, path null → mémoire). DI dansMauiProgram(AppDataDirectory/external-companion.json).Tests : 5 nouveaux tests du store (empty, set/clear, réouverture façon app-kill, JSON corrompu, path null).
prd.json: US-004passes: true+ notes on-device.progress.txt: append.Verification
dotnet test tests/PKForge.Domain.Tests -c Release+dotnet build src/PKForge.App -f net10.0-android.