feat: add SessionPhase, pause(), and resume() to EncounterSession#26
Merged
Conversation
Adds a two-case SessionPhase enum (running/paused) as a public property on EncounterSession. Phase is enforced via pause()/resume() methods (private(set) prevents direct mutation). Codable round-trips cleanly and tolerates both missing phase keys (old sessions default to .running) and unknown future case strings (forward-compat fallback via raw-value decoding).
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
SessionPhaseenum (running/paused) as apublic private(set)property onEncounterSessionpause()andresume()methods as the sole mutation path for phaseCodablehandles backward compat (missingphasekey →.running) and forward compat (unknown future case string →.runningvia raw-value fallback)Test plan
newSessionPhaseIsRunning— default phase is.runningpauseSetsPhase—pause()transitions to.pausedresumeSetsPhase—resume()transitions to.running(initialised withphase: .pauseddirectly, independent ofpause())pauseIsIdempotent— callingpause()twice stays.pausedresumeIsIdempotent— callingresume()on a running session stays.runningphaseRoundTripsViaCodable— encode/decode preserves.pausedmissingPhaseKeyDecodesAsRunning— old JSON withoutphasekey decodes without errorunknownFuturePhaseValueDecodesAsRunning— future unknown case string falls back to.runningsessionMadeFromDefinitionStartsRunning— factory always produces.runningphaseCloses gwillish/encounter#102