Skip to content

feat(dive-log): linear estimated tank pressure line for manual dives (#197)#493

Merged
ericgriffin merged 12 commits into
mainfrom
issue-197-linear-tank-pressure-line
Jul 6, 2026
Merged

feat(dive-log): linear estimated tank pressure line for manual dives (#197)#493
ericgriffin merged 12 commits into
mainfrom
issue-197-linear-tank-pressure-line

Conversation

@ericgriffin

@ericgriffin ericgriffin commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

Closes #197. When a dive has a tank with manually-entered start/end pressures but no air-integrated (AI) transmitter data, the profile chart previously drew no pressure line at all. This adds a linear estimated pressure line so manual-entry dives still get a pressure visualization.

The line is shaped like a real transmitter would have recorded it: flat at the start pressure while the tank is unused, dropping linearly while it is breathed (windowed by gas switches), flat during gaps, and flat at the end pressure afterward. The total drop is distributed across the tank's active windows in proportion to their duration. For the common single-tank dive this collapses to one straight start → end line.

Synthesis happens in memory at the chart-read path and is never persisted — SAC analysis and UDDF/other exports read the repository directly, so they continue to see real measured data only. The estimated line is drawn straight (real AI lines stay curved) and marked "(est.)" in the legend, tooltip, and readout so an interpolation is never mistaken for a transmitter trace.

Design spec and implementation plan: docs/superpowers/specs/2026-07-06-linear-tank-pressure-line-design.md, docs/superpowers/plans/2026-07-06-linear-tank-pressure-line.md.

Changes

  • buildActiveTankIntervals (gas_usage_segments_service.dart) — per-tank active [start,end) windows from gas switches, reusing the same starting-tank + switch-walk rules as buildGasUsageSegments (keyed by tankId, no gas-mix merging).
  • synthesizeEstimatedTankPressures + EstimatedTankPressures (new estimated_tank_pressure_synthesizer.dart) — pure flat–drop–flat series builder with duration-proportional drop distribution and full-dive fallbacks; only synthesizes when a tank has both pressures, start > end, no real time-series data, and the dive has a profile.
  • estimatedTankPressuresProvider (dive_providers.dart) — composes real pressures + estimates; chart-only.
  • Chart (dive_profile_chart.dart) — new estimatedTankIds field; estimated lines rendered isCurved: false; "(est.)" suffix in tooltip and draggable-readout rows.
  • Legend (dive_profile_legend.dart) — "(est.)" suffix on estimated tank rows in the Tank Pressures section.
  • Hosts (dive_profile_panel, dive_detail_page, fullscreen_profile_page) — pass the augmented map + estimatedTankIds to the chart only; SAC-normalization and marker builders keep reading the real map.
  • i18n — new diveLog_pressure_estimatedSuffix string translated across all 11 locales.

Test Plan

  • flutter analyze passes (whole project, locally clean)
  • flutter test test/features/dive_log/ passes (1825 tests; full suite runs in CI)
  • New coverage: interval derivation, synthesizer trigger/shape/edge cases (incl. the two spec worked examples), provider composition, straight-line rendering, and the "(est.)" label in tooltip/readout/legend.
  • Manual testing on: macOS deferred (branch built in a checkout shared with a concurrent session). Recommend a visual check on a real manual-entry dive before merge.

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../services/estimated_tank_pressure_synthesizer.dart 90.47% 4 Missing ⚠️
...e_log/presentation/widgets/dive_profile_chart.dart 81.81% 2 Missing ⚠️
...ive_log/presentation/providers/dive_providers.dart 90.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

Adds a chart-only, in-memory synthesized tank pressure series for dives that have manually entered start/end pressures but no air-integrated (AI) samples, so the dive profile chart still shows a pressure visualization for manual dives (issue #197). The synthesized series is explicitly labeled as estimated and rendered as a straight line to avoid confusion with real transmitter traces.

Changes:

  • Add per-tank “active breathing windows” derivation from gas switches and use it to synthesize flat–drop–flat (windowed) pressure series when only start/end pressures exist.
  • Introduce a composing Riverpod provider that augments real tankPressures with estimates (chart-only) and plumbs estimatedTankIds through chart/legend/tooltip/readout for labeling + straight-line rendering.
  • Add i18n key for the estimated suffix across all locales and expand unit/widget/provider tests for the new behavior.

Reviewed changes

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

Show a summary per file
File Description
test/features/dive_log/presentation/widgets/dive_profile_legend_test.dart Verifies legend marks estimated tank rows with the suffix.
test/features/dive_log/presentation/widgets/dive_profile_chart_test.dart Verifies estimated pressure lines render straight and tooltip labels include the suffix.
test/features/dive_log/presentation/providers/estimated_tank_pressures_provider_test.dart Tests provider composes real + estimated pressure series for manual tanks.
test/features/dive_log/data/services/gas_usage_segments_service_test.dart Adds coverage for buildActiveTankIntervals interval derivation.
test/features/dive_log/data/services/estimated_tank_pressure_synthesizer_test.dart Adds unit coverage for synthesis trigger rules and flat–drop–flat shape.
lib/l10n/arb/app_zh.arb Adds localized estimated suffix.
lib/l10n/arb/app_pt.arb Adds localized estimated suffix.
lib/l10n/arb/app_nl.arb Adds localized estimated suffix.
lib/l10n/arb/app_en.arb Adds estimated suffix key + description metadata.
lib/l10n/arb/app_de.arb Adds localized estimated suffix.
lib/l10n/arb/app_es.arb Adds localized estimated suffix.
lib/l10n/arb/app_fr.arb Adds localized estimated suffix.
lib/l10n/arb/app_it.arb Adds localized estimated suffix.
lib/l10n/arb/app_hu.arb Adds localized estimated suffix.
lib/l10n/arb/app_he.arb Adds localized estimated suffix.
lib/l10n/arb/app_ar.arb Adds localized estimated suffix.
lib/l10n/arb/app_localizations.dart Declares the new localization getter.
lib/l10n/arb/app_localizations_zh.dart Implements the getter for zh locale.
lib/l10n/arb/app_localizations_pt.dart Implements the getter for pt locale.
lib/l10n/arb/app_localizations_nl.dart Implements the getter for nl locale.
lib/l10n/arb/app_localizations_it.dart Implements the getter for it locale.
lib/l10n/arb/app_localizations_hu.dart Implements the getter for hu locale.
lib/l10n/arb/app_localizations_he.dart Implements the getter for he locale.
lib/l10n/arb/app_localizations_fr.dart Implements the getter for fr locale.
lib/l10n/arb/app_localizations_es.dart Implements the getter for es locale.
lib/l10n/arb/app_localizations_en.dart Implements the getter for en locale.
lib/l10n/arb/app_localizations_de.dart Implements the getter for de locale.
lib/l10n/arb/app_localizations_ar.dart Implements the getter for ar locale.
lib/features/dive_log/presentation/widgets/dive_profile_panel.dart Uses estimated provider output for chart-only rendering and passes estimatedTankIds.
lib/features/dive_log/presentation/widgets/dive_profile_legend.dart Adds estimatedTankIds to legend config and appends localized suffix in Tank Pressures rows.
lib/features/dive_log/presentation/widgets/dive_profile_chart.dart Adds estimatedTankIds, appends suffix in tooltip/readout, and renders estimated lines as straight.
lib/features/dive_log/presentation/providers/dive_providers.dart Adds estimatedTankPressuresProvider composing real + synthesized pressures.
lib/features/dive_log/presentation/pages/fullscreen_profile_page.dart Uses estimated provider output for chart-only rendering and passes estimatedTankIds.
lib/features/dive_log/presentation/pages/dive_detail_page.dart Uses estimated provider output for chart-only rendering and passes estimatedTankIds.
lib/features/dive_log/data/services/gas_usage_segments_service.dart Adds buildActiveTankIntervals (tank-keyed active windows from gas switches).
lib/features/dive_log/data/services/estimated_tank_pressure_synthesizer.dart New pure synthesizer building flat–drop–flat estimated pressure series.
docs/superpowers/specs/2026-07-06-linear-tank-pressure-line-design.md Design spec for the estimated pressure line feature.
docs/superpowers/plans/2026-07-06-linear-tank-pressure-line.md Implementation plan and test strategy for the feature.

Comment thread lib/features/dive_log/presentation/providers/dive_providers.dart
@ericgriffin ericgriffin merged commit e812e77 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 issue-197-linear-tank-pressure-line branch July 6, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

When no AI pressure data exists for a defined tank, show linear graph on dive profile chart

2 participants