Repository navigation
feat(atemschutz): model the Sicherheitstrupp instead of hoping for it - #408
Merged
Merged
Conversation
FwDV 7 expects a Sicherheitstrupp to be posted before a Trupp goes under air, and the Einsatzbericht is read afterwards to see that it was. Until now `grep -ri sicherheitstrupp src/` returned nothing: the concept lived only as a free-text Trupp-Art in the demo Stammdaten. There was no link from a deployed Trupp to the crew standing by for it, nothing separating a reserve crew from one merely bereitgestellt, and nothing in the report. `AtemschutzTrupp` gains a nullable `SafetyTruppId`. The link is by id, never by the German designation — #398 is removing the last behaviour that keys off a Trupp-Art name and this must not add another. Under each Trupp the grid now carries a picker of the Trupps currently bereitgestellt, and the assignment may be changed at any time, including while the covered Trupp is under air: a Sicherheitstrupp really is relieved mid-Einsatz, and a record that can never be corrected is worse than one that moves. Nothing is refused. One crew may stand by for several Trupps, because whether that is defensible is the Einsatzleiter's call and not the file's. The app says so instead: "kein Sicherheitstrupp" once a Trupp is under air with nobody behind it, "nicht mehr bereitgestellt" when the assigned crew goes under air itself, and "deckt auch Trupp N" when one crew is shared — the same amber, non-blocking shape as RolesView's UnknownRoleHint. The two things that are refused are the two that can only ever be bugs: a Trupp covering itself, and a link to a Trupp outside this incident. The ETB carries the chronology, so no second history table is introduced. Every festlegen, wechseln and aufheben is a system entry, the "im Einsatz" line names the Sicherheitstrupp or states its absence outright, and a standby crew that goes under air itself reports the loss for each Trupp it covered. Start is the only place that hook is needed: standing by means bereitgestellt, and Start is the sole way out of that state. The picker stacks under the Trupp name rather than taking a column of its own. Eight columns already need every pixel of a 1280px ELW screen, and the width for a ninth would have come out of the crew column or the action buttons — the first render of that version clipped RÜCKZUG. Vertical space is the one thing this grid has spare. The PDF makes the same trade for the same reason: a ninth column there would cut Mannschaft from 71pt to 55pt, so the Sicherheitstrupp rides as a grey sub-line in the Trupp cell. Schema V22 adds a nullable `safety_trupp_id`, additive so an older file reads back with no Sicherheitstrupp recorded — which is what was true of it. A stored id is never validated: a file must stay openable, so a dangling or unparseable value degrades to "none" rather than refusing the Einsatz. Joining already demands an exact version match, so the new command needed no wire shim. Closes #399 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
… freezing the grid The picker wrote to the domain from inside its own selection event, and the refresh that write set off replaced both the row object and the options list. Two things followed, and the second one is what the report showed. `RefreshTrupps` cleared and re-added the whole collection on every change (#294). `Clear()` raises a Reset, so Avalonia tears down and re-realises every container — including the ComboBox that was mid-selection, whose popup is a real top-level window holding the pointer grab. Orphaned, it stays on screen and keeps taking the clicks, and the app is unresponsive. Rows are now reconciled by id and updated in place, which is what `EtbViewModel.Sync` already does and what #294 asks for. Worse, and silent: each update also handed the ComboBox a brand-new options list. Avalonia reacts to a new ItemsSource by dropping its selection and writing back — first null, then `— kein —`. The guard only treated null as spurious, so the `— kein —` was read as the operator choosing "no Sicherheitstrupp" and wiped the assignment a moment after it was made. The options are now one collection for the row's life, mutated in place; because the options are records, an entry that has not really changed compares equal and the ComboBox sees no change at all. The instrumented run that settled it: SETTER trupp=2 value=Trupp 3 domainId= -> assign (lands) SETTER trupp=2 value=(null) domainId=712e -> inert SETTER trupp=2 value=— kein — domainId=712e -> assign (wipes it) Headless Avalonia cannot reproduce the freeze — it has no real popup window to strand — but the data loss reproduces exactly, and the demo flow caught it. Five tests cover both halves: the row and the options collection must survive an assignment and any later change, and the assignment must still be there afterwards. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
…ComboBox
Running the app and choosing a Sicherheitstrupp killed it outright:
System.ArgumentOutOfRangeException: Index was out of range
at Avalonia.Controls.ItemsSourceView`1.GetAt(Int32 index)
at …Selection.SelectedItems`1.GetEnumerator()+MoveNext()
at …InternalSelectionModel.OnSelectionChanged
at …SelectionModel`1.EndBatchUpdate()
at …SelectingItemsControl.UpdateSelection(…) ← nested
at …SelectingItemsControl.UpdateSelection(…) ← outer, from the click
at Avalonia.Controls.ComboBox.UpdateSelectionFromEvent
The two nested UpdateSelection frames are the whole story. Avalonia commits a
selection inside a BatchUpdateOperation holding indices into the ItemsSource.
Our SelectedItem setter wrote to the incident, that write came straight back
through Changed, and the refresh both re-wrote SelectedItem and mutated the
very collection the batch was indexing. On commit the indices no longer
matched.
This was the third failure of one design, each fix moving the symptom: clearing
the rows stranded the popup and froze the app; reconciling the rows exposed a
replaced options list that reset the selection and silently wiped the
assignment; a stable collection mutated in place removed that and made the
crash deterministic. A two-way-bound SelectedItem cannot drive a mutation that
feeds back into its own ItemsSource, so the selection model is gone rather than
timed around.
The picker is now a button and a Flyout whose entries are commands, the idiom
ForcesView already uses for the Stärke editor. A command runs after the flyout
dismisses, with no SelectionModel, no ItemsSourceView and no write-back.
SelectedSafetyTrupp is deleted outright; SafetyTruppChoice carries its own
command so the item template binds against the entry and never reaches out of
the popup's visual tree. The read-only guard moves into the ViewModel, where it
also covers a programmatic Execute — the rule ForceRow's setters already state.
Deferring instead was considered and rejected on the code: IUiDispatcher exists
and AppLogic can reach it, but AvaloniaUiDispatcher.Post deliberately runs
inline when already on the UI thread, so posting from a setter would not have
unwound the event and would have crashed identically.
Three acceptance tests now drive the real control end to end — open the flyout,
invoke an entry, assert the incident took it, and confirm Escape dismisses it.
The old design could not be tested this way at all: its failure lived inside
Avalonia's selection commit, which headless cannot reproduce even with
simulated clicks. The Rückzug-alarm row keeps its amber "kein Sicherheitstrupp"
warning, and the eight columns still fit a 1280px ELW screen.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
DeepDiver1975
force-pushed
the
feat/sicherheitstrupp
branch
from
September 20, 2026 20:04
26feb21 to
2d23ccc
Compare
DeepDiver1975
added a commit
that referenced
this pull request
Sep 24, 2026
The module table, the comparison and the Probefahrt still described the CO-Messprotokoll with a single ppm value and the sample incident with "zwei Atemschutztrupps". Since 0.6.0 every Wohnung keeps a Messreihe whose history goes into the ETB and the PDF (#432), and the sample incident holds an Angriffstrupp with an assigned Sicherheitstrupp (#408) and a Wohnung measured three times. Same wording as on codeforfire.github.io (CodeForFire/codeforfire.github.io#5). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
DeepDiver1975
added a commit
that referenced
this pull request
Sep 24, 2026
….0 (#479) The module table, the comparison and the Probefahrt still described the CO-Messprotokoll with a single ppm value and the sample incident with "zwei Atemschutztrupps". Since 0.6.0 every Wohnung keeps a Messreihe whose history goes into the ETB and the PDF (#432), and the sample incident holds an Angriffstrupp with an assigned Sicherheitstrupp (#408) and a Wohnung measured three times. Same wording as on codeforfire.github.io (CodeForFire/codeforfire.github.io#5). Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 1, 2026
Closed
DeepDiver1975
added a commit
that referenced
this pull request
Oct 1, 2026
…hem (#531) Every session.Changed -- a save in any tab, or a change pushed from a joined device -- cleared the Kräfte grid and re-added every row. The Reset made Avalonia re-realise each container, so the selected row lost its highlight and the STATUS combo lost keyboard focus right after the status it had just written. RowReconciler now brings a bound collection in line with the incident by id: rows whose unit is gone are removed, new ones inserted, rows out of place moved, and every kept row updated in place. ForceRow.Update carries an echo guard so a value pulled from the incident is not written back as a local edit, keeps a half-typed Stärke correction unless the incident's Stärke itself moved, and replaces StatusOptions only when the list really differs (the #408 trap). Funktionen and Aufgaben follow in their own pull requests. Refs #294 Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #399.
FwDV 7 expects a Sicherheitstrupp to be posted before a Trupp goes under air, and the
Einsatzbericht is read afterwards to see that it was. Until now
grep -ri sicherheitstrupp src/returned nothing — the concept existed only as a free-text Trupp-Art in the demo Stammdaten.
What this adds
AtemschutzTruppgains a nullableSafetyTruppId. The link is by id, never by the Germandesignation — #398 is removing the last behaviour that keys off a Trupp-Art name, and this must
not add another. A Trupp called "Sicherheitstrupp" is a naming convention; the link is the fact.
Under each Trupp the grid carries a picker of the Trupps currently
Bereitgestellt. Theassignment may be changed at any time, including while the covered Trupp is under air — a
Sicherheitstrupp really is relieved mid-Einsatz, and a record that can never be corrected is worse
than one that moves.
Nothing is refused. One crew may stand by for several Trupps, because whether that is
defensible is the Einsatzleiter's call and not the file's. The app says so instead, in the same
amber non-blocking shape as
RolesView'sUnknownRoleHint:kein Sicherheitstruppnicht mehr bereitgestelltdeckt auch Trupp 2The two things that are refused are the two that can only ever be bugs: a Trupp covering itself,
and a link to a Trupp outside this incident.
The ETB carries the chronology
No second history table. Every change is a system entry, and the "im Einsatz" line now names the
Sicherheitstrupp — or states its absence outright, which is the line the Einsatzbericht is read
for:
That last hook is needed only at
Start: standing by meansbereitgestellt, andStartis thesole way out of that state (
WithdrawrequiresIsActive,MarkRemovedrequiresIsWithdrawing), so the other two transitions would only repeat a loss already recorded.The picker is a flyout, and that is the interesting part of this PR
It started as a
ComboBoxwithSelectedItembound two-way. Running the app killed it:The two nested
UpdateSelectionframes are the whole story. Avalonia commits a selection inside aBatchUpdateOperationholding indices into theItemsSource. The setter wrote to theincident, that write came back through
Changed, and the refresh both re-wroteSelectedItemandmutated the very collection being indexed.
Three attempts, each moving the symptom rather than removing it:
Trupps.Clear()+ re-add (the original)b30ccec)— kein —back — silent data loss, the assignment wiped moments after it was madeObservableCollectionmutated in place (b30ccec)So the selection model is gone rather than timed around: a two-way-bound
SelectedItemcannotdrive a mutation that feeds back into its own
ItemsSource. The picker is now a button and aFlyoutwhose entries are commands — the idiomForcesViewalready uses for the Stärke editor. Acommand runs after the flyout dismisses, with no
SelectionModel, noItemsSourceViewand nowrite-back.
Deferring instead was checked and would not have worked:
IUiDispatcherexists and AppLogic canreach it, but
AvaloniaUiDispatcher.Postdeliberately runs inline when already on the UIthread, so posting from a setter would not have unwound the event.
Row reconciliation from the second attempt is kept — it is what #294 asks for, and it stops a row
being torn down while the operator is using it.
Screenshots
The picker stacks under the Trupp name rather than taking a column of its own. Eight columns
already need every pixel of a 1280px ELW screen —
LayoutAlignmentTestspins that — and the widthfor a ninth had to come from somewhere. The first attempt took 27px from AKTION and clipped the
RÜCKZUG button, so that version was abandoned. Vertical space is the one thing this grid has
spare. TRUPP grows 170 → 190px; no other column moves, and the Trupp name now fits instead of
truncating.
The PDF makes the same trade
A4 portrait less the 1.5 cm margins leaves ~510pt, of which the five constant columns already
claim 345 — so Mannschaft is ~71pt and already wraps. A ninth column would cut it to 55pt
(relative) or 45pt (constant). The Sicherheitstrupp therefore rides as a grey sub-line in the
Trupp cell, costing no width:
(#404 — the PDF is A4-only with hardcoded column widths — is what would make a real column
affordable later.)
Storage and sync
Schema V22 adds a nullable
safety_trupp_id; additive, so an older file reads back with noSicherheitstrupp recorded, which is exactly what was true of it.
SchemaGuard's expected-columntable (from #396) learns it too.
A stored id is deliberately never validated — the same stance
Rehydratealready takes on a crewit cannot validate. A dangling or unparseable value degrades to "none" rather than refusing to
open the Einsatz. A live command carrying an unknown id is a different thing and is refused.
Joining already demands an exact app-version match, so the new
setScbaSafetyTruppcommand neededno wire shim.
Tests
1437 pass, 48 new. Domain (13), ViewModel incl. all six ETB wordings and the re-entrancy guards
(21), sync serialization + applier + snapshot (5), persistence round-trip, a V21 file upgrading, a
corrupt id and a dangling id (4), plus the acceptance renders.
Three of those drive the real control end to end — open the flyout, invoke an entry, assert the
incident took it, confirm Escape dismisses it. The ComboBox design could not be tested this way
at all: its failure lived inside Avalonia's selection commit, which headless cannot reproduce
even with simulated clicks. That is the concrete argument for the control change, beyond the crash
itself.
docs/samples/uebung.fwincidentand the screenshots/GIF are regenerated; the demo Angriffstruppnow has a Sicherheitstrupp posted in the correct FwDV 7 order.
Not in this PR
CoMessprotokollView'sBuildingOptionsis the same hazard — anObservableCollectionclearedand refilled under a two-way
SelectedBuilding. They have already been bitten by a sibling of it(see the comment at
CoMessprotokollViewModel.cs:457-467) and worked around it. It avoids theindex crash only because
Clear()raises a Reset rather thanReplace/Remove. Worth its ownissue alongside #294.
🤖 Generated with Claude Code