Log mission name on send, log mission/drone-profile changes, auto-send on mission switch

Include the mission name in the "Mission sent"/"Mission upload failed"
System Messages (was just the waypoint count before).

Add MissionMeta.switchSeq, bumped only by an actual mission switch
(startNew/startNewFromPlace/loadMission) - not by the id a brand-new
mission gets from its first autosave, and not by restoreLastSession() on
app start. FlyScreen compares it to detect a genuine switch and reacts
two ways: logs "Mission changed to ..." and automatically re-uploads the
new route to the flight controller, reusing the same send path as the
manual send button (same _sending guard, same success/failure snackbar
and log entry).

Mission-change and drone-profile-change logging intentionally live in
FlyScreen's ref.listen callbacks, not in mission_meta_provider.dart /
active_drone_profile_provider.dart themselves - those providers have no
notion of the app mode (Plan vs Fly, tracked separately by AppModeCubit),
and logging there would record a change regardless of mode. Since
FlyScreen only exists while Fly mode is active, scoping the listeners
there means switching missions or drone profiles from Plan mode produces
no System Messages entries, and only a mission switch (not a drone
profile switch) triggers the automatic re-upload, matching what was
asked for.

Also splits systemMessageLogProvider (the plain message list + log(), no
telemetry dependency) from the new systemMessageAutoLogProvider (the
Connected/lost/battery/failsafe/connection-type auto-detection, which
does watch telemetryProvider) - discovered while wiring the mission-change
logging that logging a plain message from Plan-mode code was forcing the
entire telemetry/transport stack to spin up as a side effect, which broke
an unrelated Plan-mode test (UdpTransport threw on a double-disconnect
during teardown). Keeping the two concerns apart means calling log() for
a one-off message never has that side effect.

Verified end to end on the Pixel_10a emulator: switching to an empty
mission while in Fly mode correctly showed "No waypoints to send" and
logged "Mission changed to ..." automatically, without touching the send
button.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Constantin Leue
2026-08-06 12:04:35 +02:00
co-authored by Claude Sonnet 5
parent b09d00ab9f
commit b68c16d8e6
7 changed files with 349 additions and 106 deletions
@@ -15,18 +15,31 @@ import 'terrain_provider.dart';
/// currentMissionProvider (das nur die Wegpunkte haelt) um Name/Ort und die
/// Datenbank-id, sobald die Mission mindestens einmal gespeichert wurde.
class MissionMeta {
const MissionMeta({this.id, this.name = 'New mission', this.placeName});
const MissionMeta({this.id, this.name = 'New mission', this.placeName, this.switchSeq = 0});
/// Null, solange die Mission noch nie (auto-)gespeichert wurde.
final int? id;
final String name;
final String? placeName;
MissionMeta copyWith({int? id, String? name, String? placeName}) {
/// Zaehlt nur bei einem echten Missionswechsel hoch (startNew/
/// startNewFromPlace/loadMission), NICHT bei der id-Vergabe durch den
/// ersten Autosave einer neuen Mission (siehe _flushNow()) oder bei
/// restoreLastSession() (App-Start, kein Nutzerwechsel). FlyScreen
/// vergleicht darauf, um einen echten Missionswechsel waehrend des
/// Fly-Modus zu erkennen - sowohl fuer das System-Messages-Log (Doku:
/// "Wechsel der Mission ... nur im fly modus loggen") als auch fuer den
/// automatischen Missions-Upload (Doku: "automatisch die Wegpunktliste
/// übertragen, wenn die Mission gewechselt wird im fly modus"). Ein
/// simpler id-Vergleich waere durch die Autosave-id-Vergabe falsch positiv.
final int switchSeq;
MissionMeta copyWith({int? id, String? name, String? placeName, int? switchSeq}) {
return MissionMeta(
id: id ?? this.id,
name: name ?? this.name,
placeName: placeName ?? this.placeName,
switchSeq: switchSeq ?? this.switchSeq,
);
}
}
@@ -80,7 +93,7 @@ class CurrentMissionMetaNotifier extends Notifier<MissionMeta> {
_suppressAutosave = true;
ref.read(currentMissionProvider.notifier).replaceAll(const []);
_suppressAutosave = false;
state = newState;
state = newState.copyWith(switchSeq: state.switchSeq + 1);
ref.read(terrainProvider.notifier).restore(null);
await ref.read(appSettingsRepositoryProvider).setCurrentMissionId(null);
}
@@ -93,7 +106,8 @@ class CurrentMissionMetaNotifier extends Notifier<MissionMeta> {
_suppressAutosave = true;
ref.read(currentMissionProvider.notifier).replaceAll(loaded.waypoints);
_suppressAutosave = false;
state = MissionMeta(id: id, name: loaded.name, placeName: loaded.placeName);
state = MissionMeta(id: id, name: loaded.name, placeName: loaded.placeName)
.copyWith(switchSeq: state.switchSeq + 1);
ref.read(terrainProvider.notifier).restore(loaded.terrainProfile);
_fitMapToWaypoints(loaded.waypoints);
await ref.read(appSettingsRepositoryProvider).setCurrentMissionId(id);