Skip to content

Commit 965a057

Browse files
committed
refactor(drift): update drift label messaging and enhance pull logic
This commit modifies the drift label for the "dashboard-ahead" state to provide clearer instructions for syncing down changes. Additionally, it refines the pull logic to treat cases where local and platform hashes match as "clean," allowing for a more efficient reconciliation process. This change improves user experience by simplifying the output messages during resource synchronization.
1 parent 4de7f6d commit 965a057

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

src/drift.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function classifyDrift(input: ClassifyDriftInput): DriftDirection {
5353
export function formatDriftLabel(direction: DriftDirection): string {
5454
switch (direction) {
5555
case "dashboard-ahead":
56-
return "[dashboard-ahead — sync down via plain pull (preserves local) or push --overwrite to take ownership]";
56+
return "[dashboard-ahead — dashboard changed, local unchanged; run npm run pull to sync it down]";
5757
case "local-ahead":
5858
return "[local-ahead — run npm run push to propagate local edits up]";
5959
case "both-diverged":

src/pull.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -661,11 +661,20 @@ export async function pullResourceType(
661661
const platformHash = hashPayload(
662662
canonicalizeForHash(resource, state, credReverse),
663663
);
664-
const direction = classifyDrift({
665-
localHash,
666-
lastPulledHash: baseline,
667-
platformHash,
668-
});
664+
// Local and platform already agreeing means there is nothing to
665+
// reconcile, whatever the (possibly stale) baseline says — treat as
666+
// clean and fall through to the write path: the rewrite is a
667+
// content no-op that re-seeds the baseline from the disk form,
668+
// self-healing the stale pointer. Mirrors the same guard in
669+
// drift.ts's push gate.
670+
const direction =
671+
localHash === platformHash
672+
? "clean"
673+
: classifyDrift({
674+
localHash,
675+
lastPulledHash: baseline,
676+
platformHash,
677+
});
669678
if (driftCounts) driftCounts[direction]++;
670679

671680
// The drift baseline now lives in the hash store, NOT in the state
@@ -695,12 +704,16 @@ export async function pullResourceType(
695704
}
696705

697706
if (direction === "dashboard-ahead") {
707+
// ⬇️ — local is UNCHANGED since the last sync and the dashboard
708+
// moved ahead: the dashboard version is the natural next step
709+
// down. Sync it without ceremony (mirror of push's silent-push
710+
// rule for local-ahead). Nothing is lost — local had no edits.
711+
// Fall through to the write path, which overwrites the file and
712+
// re-seeds the baseline from the disk form.
698713
console.log(
699-
` ${resourceId} (locally modified, preserving) ${formatDriftLabel(direction)}`,
714+
` ${resourceId} (dashboard ahead, local unchanged — syncing down)`,
700715
);
701-
upsertState(newStateSection, resourceId, { uuid: resource.id });
702-
skipped++;
703-
continue;
716+
skipLegacyPreserveChecks = true;
704717
}
705718

706719
if (direction === "local-ahead") {

0 commit comments

Comments
 (0)