Skip to content

fix(data): auto-sync and highlight Last column on service log close#772

Merged
cpcloud merged 5 commits intomainfrom
worktree-eventual-wobbling-sutton
Mar 14, 2026
Merged

fix(data): auto-sync and highlight Last column on service log close#772
cpcloud merged 5 commits intomainfrom
worktree-eventual-wobbling-sutton

Conversation

@cpcloud
Copy link
Copy Markdown
Collaborator

@cpcloud cpcloud commented Mar 14, 2026

Summary

  • Auto-sync maintenance LastServicedAt from the most recent service log entry on every CUD operation via a database trigger
  • Track mutations in detailContext.Mutated so closeDetail knows whether changes occurred
  • On closing a mutated service log detail, move the column cursor to the "Last" column and show a status bar message confirming the sync
  • Replace manual closeDetail loop in doc-search navigation with closeAllDetails

Reproduction (before fix)

  1. Create a maintenance item with no LastServicedAt
  2. Drill into its service logs and add an entry dated today
  3. Navigate back to the Maintenance tab
  4. Observe that the "Last" column is still empty and there's no visual indication that anything changed

closes #770

Copilot AI review requested due to automatic review settings March 14, 2026 10:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 syncLastServiced and invoke it after service log create/update/delete/restore.
  • Refactor soft-delete logic by extracting softDeleteWith for reuse in DeleteServiceLog.
  • Add store-level and app-level tests covering LastServicedAt sync 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.

Comment thread internal/data/store_test.go Outdated
Comment thread internal/data/store_test.go Outdated
Comment thread internal/data/store_test.go Outdated
Comment thread internal/app/handler_crud_test.go Outdated
Comment thread internal/app/handler_crud_test.go Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 14, 2026

Codecov Report

❌ Patch coverage is 58.10811% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.65%. Comparing base (66a5282) to head (e6d9ea7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/data/store.go 50.00% 20 Missing and 10 partials ⚠️
internal/app/search.go 0.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
internal/app/model.go 62.33% <100.00%> (+0.21%) ⬆️
internal/app/types.go 54.87% <ø> (ø)
internal/app/search.go 54.66% <0.00%> (+0.48%) ⬆️
internal/data/store.go 72.87% <50.00%> (-1.08%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cpcloud cpcloud force-pushed the worktree-eventual-wobbling-sutton branch from 1db7bb6 to c66b4cc Compare March 14, 2026 10:33
@cpcloud cpcloud changed the title fix(data): auto-sync maintenance LastServicedAt from service log entries Auto-sync and highlight Last column on service log close Mar 14, 2026
@cpcloud cpcloud changed the title Auto-sync and highlight Last column on service log close fix(data): auto-sync and highlight Last column on service log close Mar 14, 2026
cpcloud and others added 5 commits March 14, 2026 08:20
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>
@cpcloud cpcloud force-pushed the worktree-eventual-wobbling-sutton branch from 4f9f78a to e6d9ea7 Compare March 14, 2026 12:20
@cpcloud cpcloud merged commit 9025615 into main Mar 14, 2026
25 checks passed
@cpcloud cpcloud deleted the worktree-eventual-wobbling-sutton branch March 14, 2026 12:26
cpcloud added a commit that referenced this pull request Mar 19, 2026
…772)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.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.

Maintenance Last date should reflect Service Log

2 participants