feat: post-write consistency hardening (Stage 2A) #5

Merged
mtkell merged 1 commits from feat/post-write-consistency into main 2026-04-11 20:13:36 +00:00
Owner

PR: feat/post-write-consistency → main

Objective

Stage 2A — Post-write consistency hardening. Make list/detail behavior predictable after edits and status changes, per the master development brief's Stage 2A requirements.

Inspection findings

The controller's load() method re-fetched all drafts and re-applied filters/search/sort correctly, but selectedDraft was only preserved across load() cycles — not after write-triggered reloads. After any write (updateStatus, updatePrice, updateName, updateDescription, updateCategory), the controller called load() which reset selectedDraft via _applyFilters(). The selected item's reference became stale (pointing to the pre-write snapshot) or was lost entirely when the item left an active filter. No existing tests covered post-write selection or state persistence.

Implementation

Single change: Added a private _refreshSelection() helper to ProductPublishingController. After every write-triggered load(), it re-finds the previously selected draft by id in the current filtered drafts list. If found, selectedDraft is refreshed with the latest data. If the item left the visible set (e.g., status change moved it out of the active filter), selectedDraft falls through to load()'s existing auto-select-first behavior.

No domain model changes. No repository changes. No UI changes. No new public API. Constraints preserved: strict package boundaries, no scope broadening, small reviewable diff.

Changed files

File Summary
.../product_publishing_controller.dart Added _refreshSelection() (~8 lines); wired into load() and all 5 write methods
.../product_publishing_controller_test.dart Added 11 tests in post-write consistency group; fixed 1 unused variable warning
docs/development/build_execution_tracker.md Updated slice entry with status, files, and validation
docs/development/master_development_brief.md Added Stage 2A branch status; updated next recommended branch

Validation

  • flutter test: 234/234 passed (was 223 on main)
  • dart analyze: no issues found
  • Commit: cf0889d on feat/post-write-consistency

Next slice

feat/publishing-ux-hardening — Stage 2B: Publishing workflow UX hardening. Refine success/failure wording, inline validation messaging, disabled/loading state consistency, and page-level vs row-level error separation.

## PR: feat/post-write-consistency → main ### Objective Stage 2A — Post-write consistency hardening. Make list/detail behavior predictable after edits and status changes, per the master development brief's Stage 2A requirements. ### Inspection findings The controller's `load()` method re-fetched all drafts and re-applied filters/search/sort correctly, but `selectedDraft` was only preserved across `load()` cycles — not after write-triggered reloads. After any write (`updateStatus`, `updatePrice`, `updateName`, `updateDescription`, `updateCategory`), the controller called `load()` which reset `selectedDraft` via `_applyFilters()`. The selected item's reference became stale (pointing to the pre-write snapshot) or was lost entirely when the item left an active filter. No existing tests covered post-write selection or state persistence. ### Implementation **Single change**: Added a private `_refreshSelection()` helper to `ProductPublishingController`. After every write-triggered `load()`, it re-finds the previously selected draft by id in the current filtered `drafts` list. If found, `selectedDraft` is refreshed with the latest data. If the item left the visible set (e.g., status change moved it out of the active filter), `selectedDraft` falls through to `load()`'s existing auto-select-first behavior. No domain model changes. No repository changes. No UI changes. No new public API. Constraints preserved: strict package boundaries, no scope broadening, small reviewable diff. ### Changed files | File | Summary | |------|---------| | `.../product_publishing_controller.dart` | Added `_refreshSelection()` (~8 lines); wired into `load()` and all 5 write methods | | `.../product_publishing_controller_test.dart` | Added 11 tests in `post-write consistency` group; fixed 1 unused variable warning | | `docs/development/build_execution_tracker.md` | Updated slice entry with status, files, and validation | | `docs/development/master_development_brief.md` | Added Stage 2A branch status; updated next recommended branch | ### Validation - **flutter test**: 234/234 passed (was 223 on main) - **dart analyze**: no issues found - **Commit**: `cf0889d` on `feat/post-write-consistency` ### Next slice **`feat/publishing-ux-hardening`** — Stage 2B: Publishing workflow UX hardening. Refine success/failure wording, inline validation messaging, disabled/loading state consistency, and page-level vs row-level error separation.
mtkell added 1 commit 2026-04-11 20:13:15 +00:00
Validate Docs / validate-docs (push) Successful in 1m4s Details
cf0889d4a9
feat: post-write consistency hardening (Stage 2A)
Add _refreshSelection() to ProductPublishingController to preserve and refresh selectedDraft by id after all write-triggered reloads. Selection stays on the same product with latest data, or auto-selects first visible item if the original leaves the active filter.

- 11 new post-write consistency tests (234 total)

- dart analyze clean
mtkell merged commit 7acff83bf4 into main 2026-04-11 20:13:36 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mtkell/kell_creations#5
No description provided.