chore(M001/S01): auto-commit after plan-slice

This commit is contained in:
2026-03-24 12:14:31 +01:00
parent c34b45dde3
commit 5ee30e3ab5
6 changed files with 81 additions and 151 deletions
@@ -1,56 +1,55 @@
---
estimated_steps: 4
estimated_files: 5
estimated_files: 4
skills_used:
- best-practices
- react-best-practices
- test
---
# T02: Persist Gmail thread metadata and harden import continuity
# T02: Surface live Gmail thread continuity in the job workspace
**Slice:** S01 — Smarter Gmail import and matching
**Milestone:** M001
## Description
Make imported Gmail correspondence durable enough to support real thread continuity. This task extends persistence and import handling so that once the user chooses a suggested Gmail message or thread, the app keeps the metadata needed for dedupe, timeline continuity, and later reply/follow-up context instead of collapsing everything down to a bare message body.
Complete S01 in the UI by turning the existing ranked Gmail import tab into a live linked-thread workspace. The executor should preserve the current ranked suggestion/import flow, then layer in automatic refresh for already-linked Gmail threads so the user sees new replies appear on the same job without using the import action again.
## Steps
1. Extend `Models/Correspondence.cs` so Gmail imports can retain thread/message identity and sender/recipient metadata that downstream slices can trust.
2. Update `JobTrackerApi/Controllers/GmailController.cs` import paths and `JobTrackerApi/Controllers/CorrespondenceController.cs` response behavior so imported records populate and expose the new Gmail metadata while keeping the existing no-auto-send boundary intact.
3. Update `JobTrackerApi/Program.cs` startup compatibility guards for SQLite/MySQL so older dev databases can gain the new correspondence columns without breaking local startup.
4. Add or extend `JobTrackerApi.Tests/GmailControllerTests.cs` assertions for repeat single-message imports, repeat thread imports, and import result payloads that distinguish imported vs skipped work.
1. Inspect the current Gmail UI in `job-tracker-ui/src/components/Correspondence.tsx`, the host wiring in `job-tracker-ui/src/components/JobDetailsDialog.tsx`, and the existing component test in `job-tracker-ui/src/correspondence-gmail-import.test.tsx`.
2. Update `job-tracker-ui/src/types.ts` and `job-tracker-ui/src/components/Correspondence.tsx` to consume the new backend linked-thread refresh contract and track refresh/loading/freshness state separately from the ranked import-suggestion state.
3. Wire `job-tracker-ui/src/components/Correspondence.tsx` so already-linked threads refresh automatically at the right moment in the job workspace flow, refresh the rendered correspondence list after sync, and make the linked/live state legible in the UI.
4. Extend `job-tracker-ui/src/correspondence-gmail-import.test.tsx` to prove the continuity path: after a thread is already linked, a refresh brings in a later Gmail reply and renders it on the same job without another import action.
## Must-Haves
- [ ] Imported Gmail correspondence keeps message/thread identity plus sender/recipient metadata in `Models/Correspondence.cs` rather than forcing later slices to re-derive it.
- [ ] Import endpoints clearly report imported vs skipped outcomes and continue deduping on repeat imports.
- [ ] Runtime schema guards in `JobTrackerApi/Program.cs` are updated alongside the model change so legacy/dev databases remain bootable.
- [ ] The UI keeps ranked job-aware Gmail suggestions for first import while clearly distinguishing already-linked live threads from new import candidates.
- [ ] Linked-thread refresh happens through the new backend contract and updates the visible correspondence list without requiring the user to click an import button again.
- [ ] The React test proves the continuity path, not just the original ranked-import path.
## Verification
- `dotnet test JobTrackerApi.Tests/JobTrackerApi.Tests.csproj --filter GmailControllerTests`
- Confirm the tests prove duplicate single-message import handling, duplicate thread import handling, and the enriched import payload contract.
- `CI=true npm --prefix job-tracker-ui test -- --watch=false --runTestsByPath src/correspondence-gmail-import.test.tsx`
- Manually inspect the Correspondence dialog to confirm linked-thread state, refresh/loading state, and the newly synced message all appear in the workspace.
## Observability Impact
- Signals added/changed: persisted Gmail metadata on correspondence records and explicit imported/skipped counts from Gmail import actions.
- How a future agent inspects this: inspect `Models/Correspondence.cs`, the import payloads in `JobTrackerApi/Controllers/GmailController.cs`, and startup column guards in `JobTrackerApi/Program.cs`.
- Failure state exposed: repeat imports should now reveal whether the issue is dedupe, missing metadata persistence, or schema mismatch on startup.
- Signals added/changed: visible linked/live thread state, refresh progress/freshness state, and clearer no-new-messages vs failure feedback.
- How a future agent inspects this: run `job-tracker-ui/src/correspondence-gmail-import.test.tsx` and inspect the Gmail area in `job-tracker-ui/src/components/Correspondence.tsx`.
- Failure state exposed: the UI should distinguish refresh failure, disconnected Gmail, no linked threads, and successful refresh with zero new messages.
## Inputs
- `JobTrackerApi/Controllers/GmailController.cs` — T01 job-aware matching/import contract and existing import behavior.
- `Models/Correspondence.cs` — current correspondence persistence model.
- `JobTrackerApi/Controllers/CorrespondenceController.cs` — current correspondence list/create/delete surface.
- `JobTrackerApi/Program.cs` — runtime schema repair path that must stay aligned with new columns.
- `JobTrackerApi.Tests/GmailControllerTests.cs` — backend Gmail coverage expanded in T01.
- `job-tracker-ui/src/components/Correspondence.tsx` — current ranked Gmail import UI.
- `job-tracker-ui/src/components/JobDetailsDialog.tsx` — host dialog that owns the job workspace.
- `job-tracker-ui/src/types.ts` — frontend Gmail and correspondence contracts.
- `job-tracker-ui/src/correspondence-gmail-import.test.tsx` — existing Gmail import component test.
- `JobTrackerApi/Controllers/GmailController.cs` T01 backend refresh contract consumed by the UI.
## Expected Output
- `Models/Correspondence.cs`persists Gmail message/thread and sender/recipient metadata.
- `JobTrackerApi/Controllers/GmailController.cs` — populates and reports the new import metadata cleanly.
- `JobTrackerApi/Controllers/CorrespondenceController.cs` — exposes the enriched correspondence records back to the UI.
- `JobTrackerApi/Program.cs` — keeps legacy/dev DB startup safe after the schema change.
- `JobTrackerApi.Tests/GmailControllerTests.cs` — proves continuity and duplicate-import behavior.
- `job-tracker-ui/src/components/Correspondence.tsx`renders linked-thread refresh state and continuity behavior.
- `job-tracker-ui/src/types.ts` — matches the backend refresh contract.
- `job-tracker-ui/src/correspondence-gmail-import.test.tsx` — proves the no-manual-reimport continuity path.
- `job-tracker-ui/src/components/JobDetailsDialog.tsx` — includes any required wiring for the refreshed workspace flow.