Dive planner Phase 5: contingencies — deviations, lost gas, turn pressure, rock bottom#489
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
ContingencyServiceto compute deviation (+depth/+time/both) and lost-gas variants and run them throughPlanEngine. - Extend
PlanEngine/outcome models with turn pressure + rock-bottom min gas, plus a newminGasViolationissue 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. |
4 tasks
…anner-phase5-contingencies
…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
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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
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
PlanEngineoutcome. Deltas are per-plan config (default +5 m / +5 min).PlanEngine additions
turn = start − usable × fraction.buddyFactor) stressed emergency exit from max depth — one minute at depth plus the direct ascent — asminGasBarper bottom tank, with a newminGasViolationalert when the tank ends above zero but below it (deliberately not double-reporting tanks that already ran dry).Canvas UI
turn @ X · min gas Y; plan settings gain deviation-delta fields and the turn-rule dropdown (custom fraction field when selected).Verification
310 deco + 124 planner/dive_planner tests green;
flutter analyzeclean.