Summary
Implement the Phase 4A foundation for multi-tab GitHub sync in @knighted/develop by extending IndexedDB tab records with sync metadata and introducing deterministic dirty/reconcile state transitions.
This issue is the storage/state prerequisite for Phase 4B/4C and Phase 6 cleanup.
Context
Arbitrary Dynamic Editor Tabs (vNext): Named Multi-File Workspace Model for @knighted/develop #53 defines Phase 4 as GitHub PR/file mapping integration for dynamic tabs.
Multi-Tab Workspace (Dynamic Tabs, Local IndexedDB Persistence, and Modular Preview Architecture) #62 delivered phases 1-3 local-first multi-tab foundations.
We now need a robust per-tab sync state model so mapping UX and push workflows can be implemented safely.
Goals
Keep persistence boundaries clear:
localStorage for user preferences and lightweight form/config state only.
IndexedDB for workspace tab content plus sync metadata.
Add per-tab sync metadata needed for multi-file GitHub workflows.
Make dirty/clean transitions deterministic and testable.
Preserve backward compatibility for existing records.
In Scope
IndexedDB schema extension for tab sync metadata.
Normalization/migration defaults for older records.
Dirty/reconcile state transition logic in tab/workspace state orchestration.
Hydration/persistence of new fields across reload/context switches.
Status hooks for PR drawer messaging (no app-level toast changes).
Out of Scope
Multi-tab mapping UI controls (Phase 4B).
Open PR selection/binding UX (Phase 4B).
Bulk commit API migration (Phase 4C).
AI apply/undo by tab ID (Phase 5).
Fixed-assumption cleanup (Phase 6), except minimal compatibility hooks needed for this data model.
Proposed Data Model (tab-level)
targetPrFilePath: string | null
isDirty: boolean
syncedAt: number | null
lastSyncedRemoteSha: string | null
Notes:
Field names can be finalized in implementation, but semantics must remain equivalent.
Defaults for migrated records should be safe and non-breaking.
Dirty/Reconcile Contract
Edit tab content after last successful sync -> isDirty = true.
Successful push including that tab -> isDirty = false, syncedAt updated, remote marker updated.
If remote/reference mismatch is detected during reconcile -> expose warning/conflict state via PR drawer status text.
Unmapped tabs may still be dirty locally, but sync-specific indicators should be meaningful for mapped tabs.
Acceptance Criteria
Existing workspace records load without data loss after migration.
New sync fields persist in IndexedDB and survive reload.
Dirty state toggles correctly on edit, save, and successful push reconcile events.
Tab hydration restores sync metadata consistently across workspace/context restores.
No new global toast behavior is introduced; status remains in PR drawer channel.
Lint/build/tests pass.
Implementation Notes
Keep implementation modular:
storage schema/normalization in storage module.
state transitions in tab/workspace state logic.
status projection consumed by PR drawer.
Avoid coupling this work to UI redesign.
Preserve local-first behavior as primary workflow even without GitHub connectivity.
Verification
Automated:
migration tests for legacy records without sync fields.
unit/integration tests for dirty transition rules.
Playwright coverage for reload persistence and dirty-state behavior.
Manual:
edit mapped tab after sync and verify dirty state.
simulate successful push reconcile and verify clean state.
reload and verify metadata/state integrity.
Dependencies
Depends on: Arbitrary Dynamic Editor Tabs (vNext): Named Multi-File Workspace Model for @knighted/develop #53 , Multi-Tab Workspace (Dynamic Tabs, Local IndexedDB Persistence, and Modular Preview Architecture) #62 .
Blocks: Phase 4B/4C issue and Phase 6 cleanup tasks that rely on sync metadata.
Suggested Follow-ups
Phase 4B/4C issue: mapping UX + open PR binding + bulk push path.
Phase 5 issue: AI apply/undo by tab ID.
Phase 6 issue: remove fixed component/styles assumptions and finalize modular cleanup.
Summary
Implement the Phase 4A foundation for multi-tab GitHub sync in @knighted/develop by extending IndexedDB tab records with sync metadata and introducing deterministic dirty/reconcile state transitions.
This issue is the storage/state prerequisite for Phase 4B/4C and Phase 6 cleanup.
Context
Goals
In Scope
Out of Scope
Proposed Data Model (tab-level)
Notes:
Dirty/Reconcile Contract
Acceptance Criteria
Implementation Notes
Verification
Dependencies
Suggested Follow-ups