Skip to content

fix(keystatic): detect local storage update conflicts - #1684

Open
MilindChatrabhuji wants to merge 1 commit into
Thinkmill:mainfrom
MilindChatrabhuji:fix/local-update-conflict-check-1679
Open

MilindChatrabhuji wants to merge 1 commit into
Thinkmill:mainfrom
MilindChatrabhuji:fix/local-update-conflict-check-1679

Conversation

@MilindChatrabhuji

Copy link
Copy Markdown
Contributor

Closes #1679

Summary

  • Prevents silent overwrites in local storage mode when editing or deleting an entry concurrently modified on disk (for example in another browser tab).
  • Extends local /api/keystatic/update validation with expectedShas, serializing directory updates so stale file/directory SHAs return HTTP 409 Conflict without partial disk writes.
  • Sends tracked entry tree SHAs from the client editor and delete hooks, preserving local tree state on 409 and showing with an option to reload the latest entry.

Changes

  • Server conflict detection, serialization, and 409 responses in packages/keystatic/src/api/api-node.ts with regression coverage in packages/keystatic/src/api/api-node.test.ts.
  • Client expectedShas tracking, conflict handling, and UI banner wiring in packages/keystatic/src/app/updating.tsx, packages/keystatic/src/app/local-conflict-notice.tsx, packages/keystatic/src/app/ItemPage.tsx, packages/keystatic/src/app/SingletonPage.tsx, packages/keystatic/src/app/create-item.tsx, and packages/keystatic/src/app/shell/data.tsx.
  • Client unit tests in packages/keystatic/src/app/updating.test.tsx and packages/keystatic/src/app/local-conflict-notice.test.tsx.
  • Changeset entry in .changeset/local-update-conflict-check.md.

Verification

  • pnpm.cmd exec vitest run packages/keystatic/src/api packages/keystatic/src/app: 4 test files passed, 22 tests passed.
  • pnpm.cmd check:types ( sc): exited 0.
  • pnpm.cmd check:lint (eslint): exited 0.
  • pnpm.cmd check:packages (preconstruct validate): passed.
  • pnpm.cmd exec prettier --check across all 11 touched/added files: passed.

This branch has not been deployed

No deployments
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.

Silent data loss when saving a stale entry from another browser tab in local storage mode

1 participant