Skip to content

App: surface errors instead of swallowing them; fix battery-poll lifetime#2

Merged
lkasso merged 2 commits into
mainfrom
lkasso/app-error-handling
Jun 14, 2026
Merged

App: surface errors instead of swallowing them; fix battery-poll lifetime#2
lkasso merged 2 commits into
mainfrom
lkasso/app-error-handling

Conversation

@lkasso

@lkasso lkasso commented Jun 14, 2026

Copy link
Copy Markdown
Member

Summary

Robustness pass on the iOS app — stop silently dropping failures, fix a leaked background task, and harden CSV export.

Error handling

  • Logging download (DownloadViewModel): on a per-record decode failure, keep the board data (status .stopped) and warn the user to retry Download or clear from Settings, instead of marking .failed and discarding it. Also surfaces queryActiveLoggers and clearLog failures rather than swallowing them with try?.
  • Log session start (LogSessionViewModel): if starting a multi-sensor session fails partway, roll back the loggers that did start; any that can't be stopped stay .running and the user gets a clear partial-rollback error.
  • Live-buffer CSV export: write(...) now throws on a file-write failure (previously skipped silently); added an off-main-actor writeAsync wrapper.

Lifetime / resources

  • DeviceViewModel: battery polling moved into a BatteryPoller that cancels its task on deinit and on reassignment — prevents a leaked 60 s polling loop.

Features / misc

  • CSV export: support CorrectedCartesianFloat sessions; new CSVExporterTests.
  • Controls: motor duty (%) and pulse (ms) bindings.
  • Removed stray [Log] / [Export] debug prints.

Test plan

  • New CSVExporterTests covers corrected-cartesian export round-trip.
  • CI (this PR) runs the package unit suite. Note: the app target isn't built by CI (CI runs swift build/swift test on the SwiftPM package, not the Xcode app), so these app changes should be verified in Xcode before merge.

🤖 Generated with Claude Code

lkasso and others added 2 commits June 13, 2026 21:32
…time

- Logging download: on decode failure keep board data (status .stopped) and
  warn the user to retry/clear instead of marking .failed and dropping it;
  surface queryActiveLoggers and clearLog failures rather than ignoring them.
- Log session start: roll back partially-started loggers on failure; if some
  can't be stopped, stay .running for those and report a partial-rollback error.
- Live-buffer CSV export: throw on write failure (was skipped silently); add an
  off-main-actor async wrapper; drop debug prints.
- CSV export: support CorrectedCartesianFloat sessions; add CSVExporterTests.
- DeviceViewModel: move battery polling into a BatteryPoller that cancels its
  task on deinit/reassignment (prevents a leaked polling task).
- Controls: add motor duty (%) and pulse (ms) bindings.
- Remove stray [Log]/[Export] debug prints.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`\(value, default:)` is a LocalizedStringKey-only interpolation; it builds
on newer local toolchains but not on the CI runner's Swift. Use `?? false`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lkasso lkasso merged commit c8431f5 into main Jun 14, 2026
1 check passed
@lkasso lkasso deleted the lkasso/app-error-handling branch June 14, 2026 04:46
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.

1 participant