fix(data): auto-sync and highlight Last column on service log close#772
Merged
fix(data): auto-sync and highlight Last column on service log close#772
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes service log CRUD operations automatically keep a maintenance item’s LastServicedAt in sync with the most recent non-deleted ServiceLogEntry.ServicedAt, fixing the UX gap described in #770.
Changes:
- Add transactional
syncLastServicedand invoke it after service log create/update/delete/restore. - Refactor soft-delete logic by extracting
softDeleteWithfor reuse inDeleteServiceLog. - Add store-level and app-level tests covering
LastServicedAtsync behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| internal/data/store.go | Sync MaintenanceItem.LastServicedAt to latest service log date on service log mutations; extract softDeleteWith helper. |
| internal/data/store_test.go | Add unit test verifying LastServicedAt sync across create/update/delete/restore and delete-all behavior. |
| internal/app/handler_crud_test.go | Add integration-style test ensuring the maintenance tab “Last” column updates after creating a service log via the form path. |
Codecov Report❌ Patch coverage is
Additional details and impacted files
🚀 New features to boost your workflow:
|
1db7bb6 to
c66b4cc
Compare
Creating a service log entry now automatically updates the parent maintenance item's LastServicedAt to reflect the most recent service date, eliminating the need to manually bump both fields. syncLastServiced is called transactionally after every service log mutation (create, update, delete, restore). When no entries remain the field is preserved, keeping any manually-set value intact. Closes #770 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When the user closes a service log detail view after adding or editing entries, move the column cursor to the "Last" column and display a status bar message confirming the sync. This gives immediate visual confirmation that the parent maintenance item's LastServicedAt was updated. - Add Mutated bool to detailContext, set by reloadAfterMutation - closeDetail checks Mutated + serviceLogHandler to move cursor - Replace manual closeDetail loop in search.go with closeAllDetails - Add detail_close_test.go with user-flow tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address roborev findings: - UpdateServiceLog now fetches the old entry before updating and syncs both old and new parent maintenance items when MaintenanceItemID changes, preventing stale LastServicedAt on the old parent - Guard closeDetail cursor logic with tab.Kind == tabMaintenance to prevent setting maintenanceColLast on a non-maintenance tab in nested detail scenarios Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add TestServiceLogMoveBetweenParentsSyncsBoth verifying that UpdateServiceLog syncs LastServicedAt on both the old and new parent when MaintenanceItemID changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Assert old parent's LastServicedAt value (not just non-nil) to catch silent zero-time or wrong-date regressions - Capture item IDs directly from CreateMaintenance instead of relying on ListMaintenance ordering Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4f9f78a to
e6d9ea7
Compare
cpcloud
added a commit
that referenced
this pull request
Mar 19, 2026
…772) Co-authored-by: Claude Opus 4.6 <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.
Summary
LastServicedAtfrom the most recent service log entry on every CUD operation via a database triggerdetailContext.MutatedsocloseDetailknows whether changes occurredcloseDetailloop in doc-search navigation withcloseAllDetailsReproduction (before fix)
LastServicedAtcloses #770