Skip to content

Dive planner Phase 5: contingencies — deviations, lost gas, turn pressure, rock bottom#489

Merged
ericgriffin merged 9 commits into
mainfrom
worktree-dive-planner-phase5-contingencies
Jul 6, 2026
Merged

Dive planner Phase 5: contingencies — deviations, lost gas, turn pressure, rock bottom#489
ericgriffin merged 9 commits into
mainfrom
worktree-dive-planner-phase5-contingencies

Conversation

@ericgriffin

@ericgriffin ericgriffin commented Jul 5, 2026

Copy link
Copy Markdown
Member

Summary

Phase 5 of the dive planner redesign (plan). Stacked on #488 (Phase 4 CCR) — review #484#485#486#488 first.

The slate-side features tech divers praise MultiDeco and Baltic for: one-tap deviation plans with ghost overlays, lost-deco-gas schedules, turn pressure, and rock-bottom validation.

ContingencyService

  • Deviations: deeper (+depth delta on the max-depth segments), longer (+minutes on bottom segments), and both — each a full PlanEngine outcome. Deltas are per-plan config (default +5 m / +5 min).
  • Lost gas: one recomputed schedule per carried deco/stage cylinder (the remaining gases absorb the stops). CCR plans skip this — loop loss is the Phase 4 bailout solver's job.

PlanEngine additions

  • Turn pressure per the plan's rule (all-usable / halves / thirds / custom fraction) on bottom tanks: turn = start − usable × fraction.
  • Rock bottom: a two-diver (configurable buddyFactor) stressed emergency exit from max depth — one minute at depth plus the direct ascent — as minGasBar per bottom tank, with a new minGasViolation alert when the tank ends above zero but below it (deliberately not double-reporting tanks that already ran dry).

Canvas UI

  • Contingency chips (Base / +5m / +5′ / both) under the status chips; the selected deviation renders as a grey dashed ghost profile over the live chart, with axes widened to fit it.
  • Results sheet gains a Contingencies section: a mini runtime table per deviation and per lost gas — exactly what gets copied to wet notes.
  • Gas rows show turn @ X · min gas Y; plan settings gain deviation-delta fields and the turn-rule dropdown (custom fraction field when selected).
  • 15 new l10n keys translated into all 10 non-en locales (gen-l10n: zero untranslated).

Verification

310 deco + 124 planner/dive_planner tests green; flutter analyze clean.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Implements Phase 5 “Contingencies” in the redesigned dive planner: generates deviation/lost-gas contingency outcomes via the existing PlanEngine, computes turn pressure + rock-bottom minimum gas per bottom tank, and surfaces these in the canvas UI (chips, ghost overlay, and results-sheet tables), with full localization and test coverage.

Changes:

  • Add ContingencyService to compute deviation (+depth/+time/both) and lost-gas variants and run them through PlanEngine.
  • Extend PlanEngine/outcome models with turn pressure + rock-bottom min gas, plus a new minGasViolation issue type and UI rendering.
  • Add canvas UI wiring (chips, ghost profile overlay, results-sheet contingency tables, settings section) and update l10n + tests.

Reviewed changes

Copilot reviewed 41 out of 41 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/features/planner/plan_results_widgets_test.dart Adjust widget expectations/scrolling to account for added contingency tables before warnings.
test/features/planner/plan_engine_issues_test.dart Add tests for turn-pressure computation and rock-bottom violation behavior.
test/features/planner/dive_plan_state_mapper_test.dart Update merge expectations and add round-trip tests for contingency config fields.
test/features/planner/contingency_ui_test.dart New widget tests for deviation selection (ghost line) and results-sheet contingency/turn pressure rendering.
test/features/planner/contingency_service_test.dart New unit tests validating deviation/lost-gas outcomes and CCR exclusions.
lib/l10n/arb/app_zh.arb Add contingency/turn/min-gas strings (zh).
lib/l10n/arb/app_pt.arb Add contingency/turn/min-gas strings (pt).
lib/l10n/arb/app_nl.arb Add contingency/turn/min-gas strings (nl).
lib/l10n/arb/app_it.arb Add contingency/turn/min-gas strings (it).
lib/l10n/arb/app_hu.arb Add contingency/turn/min-gas strings (hu).
lib/l10n/arb/app_he.arb Add contingency/turn/min-gas strings (he).
lib/l10n/arb/app_fr.arb Add contingency/turn/min-gas strings (fr).
lib/l10n/arb/app_es.arb Add contingency/turn/min-gas strings (es).
lib/l10n/arb/app_en.arb Add contingency/turn/min-gas strings and placeholder metadata (en).
lib/l10n/arb/app_de.arb Add contingency/turn/min-gas strings (de).
lib/l10n/arb/app_ar.arb Add contingency/turn/min-gas strings (ar).
lib/l10n/arb/app_localizations.dart Regenerate localization interface for new keys.
lib/l10n/arb/app_localizations_zh.dart Regenerate zh localization implementation.
lib/l10n/arb/app_localizations_pt.dart Regenerate pt localization implementation.
lib/l10n/arb/app_localizations_nl.dart Regenerate nl localization implementation.
lib/l10n/arb/app_localizations_it.dart Regenerate it localization implementation.
lib/l10n/arb/app_localizations_hu.dart Regenerate hu localization implementation.
lib/l10n/arb/app_localizations_he.dart Regenerate he localization implementation.
lib/l10n/arb/app_localizations_fr.dart Regenerate fr localization implementation.
lib/l10n/arb/app_localizations_es.dart Regenerate es localization implementation.
lib/l10n/arb/app_localizations_en.dart Regenerate en localization implementation.
lib/l10n/arb/app_localizations_de.dart Regenerate de localization implementation.
lib/l10n/arb/app_localizations_ar.dart Regenerate ar localization implementation.
lib/features/planner/presentation/widgets/plan_results_sheet.dart Add contingency section tables, display turn/min-gas on gas rows, and localize min-gas issue messaging.
lib/features/planner/presentation/widgets/plan_canvas_chart.dart Add ghost deviation profile series and widen axes to fit ghost series.
lib/features/planner/presentation/widgets/contingency_settings_section.dart New settings UI for deviation deltas + turn-pressure rule/fraction.
lib/features/planner/presentation/widgets/contingency_chips.dart New chip row for selecting Base/+depth/+time/both deviation ghost overlay.
lib/features/planner/presentation/providers/plan_canvas_providers.dart Add contingency providers, deviation selection state, and ghost series provider; refactor series builder for reuse.
lib/features/planner/presentation/pages/plan_canvas_page.dart Wire contingency chips into the page and add contingency settings section to settings panel.
lib/features/planner/domain/services/plan_engine.dart Compute per-tank turn pressure + min gas; emit minGasViolation issues; add config buddyFactor.
lib/features/planner/domain/services/dive_plan_state_mapper.dart Map contingency config fields between state and persisted domain plan.
lib/features/planner/domain/services/contingency_service.dart New service to generate deviation and lost-gas plan variants and compute outcomes.
lib/features/planner/domain/entities/plan_outcome.dart Extend issue types and tank-usage model with turn/min-gas fields.
lib/features/dive_planner/presentation/providers/dive_planner_providers.dart Add notifier API to update contingency configuration in editing state.
lib/features/dive_planner/domain/entities/plan_result.dart Add contingency config fields to DivePlanState (defaults + copyWith support).
docs/superpowers/plans/2026-07-05-dive-planner-phase5-contingencies.md Add Phase 5 implementation plan document.

Comment thread lib/features/planner/domain/services/contingency_service.dart
…ments

- lostGas now remaps user segments off the lost cylinder onto a fallback
  (back gas) and skips when no tank remains, so a contingency never keeps
  breathing the lost gas
- Deviation/lost-gas tables are collapsed by default; the expensive per-variant
  engine runs happen only when the section is expanded. The chart ghost runs
  just the one selected deviation (deviationFor) instead of all three
- Cover the contingency settings section and the new service paths
@ericgriffin ericgriffin moved this from Backlog to In review in Submersion Release Tracker Jul 6, 2026
@ericgriffin ericgriffin self-assigned this Jul 6, 2026
Base automatically changed from worktree-dive-planner-phase4-ccr to main July 6, 2026 02:18
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

@ericgriffin ericgriffin merged commit a922f60 into main Jul 6, 2026
19 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in Submersion Release Tracker Jul 6, 2026
@ericgriffin ericgriffin deleted the worktree-dive-planner-phase5-contingencies branch July 6, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants