Skip to content

fix(kraefte): reconcile the Kräfte rows by id instead of rebuilding them - #531

Merged
DeepDiver1975 merged 1 commit into
mainfrom
fix/294-forces-reconcile
Oct 1, 2026
Merged

DeepDiver1975 merged 1 commit into
mainfrom
fix/294-forces-reconcile

Conversation

@DeepDiver1975

Copy link
Copy Markdown
Contributor

Summary

First of three PRs for #294. Kräfte only; Funktionen and Aufgaben follow and build on the helper added here.

Every session.Changed (a save in any tab, or a change from a joined device) ran Forces.Clear() and re-added every row. The Reset makes Avalonia re-realise each row container, so the selected row lost its highlight and the STATUS combo lost focus right after it had saved. The next Down press moved the grid's cell cursor instead of changing the status.

Refs #294. The issue stays open until Funktionen and Aufgaben land.

Changes

  • RowReconciler (new, internal) brings an ObservableCollection in line with the incident by id:

    • removes rows whose item is gone;
    • inserts new rows at their position;
    • Moves rows that are out of place;
    • updates every kept row in place.

    It never raises a Reset and never replaces a row by index. The Move support is there for the sorted and filtered Aufgaben and Funktionen lists that come next.

  • ForceRow.Update brings a kept row up to date:

  • RefreshForces calls the reconciler. The totals, vehicle options and duplicate-Funkrufname code is unchanged.

  • The UpdateSourceTrigger=LostFocus in ForcesView.axaml stays. It is also what fixes Kräfte: typing a Bemerkung saves the whole incident file on every keystroke #33's write per keystroke.

No .axaml change and nothing visual, so there are no screenshots.

Tests (written first, all failed on main)

  • ForcesViewModelTests:
    • an unrelated change raises no Reset and keeps the same row instances;
    • adding or removing a unit raises no Reset;
    • a status change from elsewhere, directly and through SnapshotRoundTrippingSession, updates the row with no write-back (one Changed, no onChanged);
    • an off-catalogue status set elsewhere is selectable;
    • a half-typed Stärke survives an unrelated change;
    • a Stärke correction from elsewhere reaches the row.
  • ForcesSelectionSurvivesChangeTests ([AvaloniaFact], real ForcesView): the selected DataGrid row stays selected across an unrelated change and across its own status edit. On main the selection becomes null.

make clean ci: 8 test runs, all green, 0 warnings.

Checklist

  • Commits follow Conventional Commits and carry a DCO sign-off
  • Commits are cryptographically signed and show as Verified on GitHub
  • Build and tests pass locally
  • Changes under src/ add one changelog entry in changelog.d/
  • UI changes include before/after screenshots (n/a, no visual change)
  • No real master data / personnel data committed

🤖 Generated with Claude Code

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
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.

Kräfte: typing a Bemerkung saves the whole incident file on every keystroke

1 participant