Skip to content

feat: add SessionPhase, pause(), and resume() to EncounterSession#26

Merged
gwillish merged 1 commit into
mainfrom
feat/session-phase
May 9, 2026
Merged

feat: add SessionPhase, pause(), and resume() to EncounterSession#26
gwillish merged 1 commit into
mainfrom
feat/session-phase

Conversation

@gwillish
Copy link
Copy Markdown
Owner

@gwillish gwillish commented May 9, 2026

Summary

  • Adds SessionPhase enum (running / paused) as a public private(set) property on EncounterSession
  • Adds pause() and resume() methods as the sole mutation path for phase
  • Codable handles backward compat (missing phase key → .running) and forward compat (unknown future case string → .running via raw-value fallback)

Test plan

  • newSessionPhaseIsRunning — default phase is .running
  • pauseSetsPhasepause() transitions to .paused
  • resumeSetsPhaseresume() transitions to .running (initialised with phase: .paused directly, independent of pause())
  • pauseIsIdempotent — calling pause() twice stays .paused
  • resumeIsIdempotent — calling resume() on a running session stays .running
  • phaseRoundTripsViaCodable — encode/decode preserves .paused
  • missingPhaseKeyDecodesAsRunning — old JSON without phase key decodes without error
  • unknownFuturePhaseValueDecodesAsRunning — future unknown case string falls back to .running
  • sessionMadeFromDefinitionStartsRunning — factory always produces .running phase

Closes gwillish/encounter#102

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).
@gwillish gwillish merged commit 5be6afb into main May 9, 2026
2 checks passed
@gwillish gwillish deleted the feat/session-phase branch May 9, 2026 16:16
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.

DHKit PR: add SessionPhase, pause(), resume() to EncounterSession

1 participant