Skip to content

Conversation

@cngonzalez
Copy link
Member

@cngonzalez cngonzalez commented Feb 3, 2026

FIXES SDK-750

Description

This PR refactors document actions to use a source parameter, as we're doing for other stores.

Changes in core SDK:
This mostly involves updating the core document store to have a "source" key, using bindActionBySource instead of bindActionByDataset and updating actions (like applyDocumentActions) to match the signature required by bindActionBy Source.

Changes in React SDK:
In the React package, changes were made to be able to get a source outside of a hook (like in the applyDocumentActions function body) and to ensure source was passed along to the relevant functions.

Changes in Kitchensink:
Kitchensink was updated to abstract out the JsonDocumentEditor so we have an easy implementation of updating Media Library documents.
Kapture 2026-02-04 at 09 40 30

What to review

The biggest change here is that some supplementary functions like applyDocumentActions have a required source parameter. This isn't different from other functions where we use this helper, but is a bit of a mental shift. I think it tracks with "source is always required in core" (since we no longer want to rely on the instance to provide projectId/dataset) but it's what I'm looking for the most feedback for.

Testing

Updated tests to ensure sufficient coverage and matching the new signature. e2e tests seem necessary but will be done in an upcoming PR.

Fun gif

@vercel
Copy link

vercel bot commented Feb 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sdk-docs Ready Ready Preview, Comment Feb 6, 2026 4:48pm
sdk-kitchensink-react Ready Ready Preview, Comment Feb 6, 2026 4:48pm

Request Review

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 95.45% (🎯 95%) 7988 / 8368
🟢 Statements 95.45% (🎯 95%) 7988 / 8368
🟢 Functions 96.26% (🎯 95%) 387 / 402
🟢 Branches 92.81% (🎯 90%) 2363 / 2546
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/document/applyDocumentActions.ts 100% 100% 100% 100%
packages/core/src/document/documentStore.ts 92.65% 88.88% 77.77% 92.65% 207-214, 226-229, 281-284, 363, 461-462, 475-476, 510-511
packages/core/src/document/sharedListener.ts 100% 71.42% 100% 100%
packages/react/src/hooks/document/useApplyDocumentActions.ts 100% 96.55% 100% 100%
packages/react/src/hooks/document/useDocument.ts 100% 100% 100% 100%
packages/react/src/hooks/document/useDocumentEvent.ts 100% 100% 100% 100%
packages/react/src/hooks/document/useDocumentPermissions.ts 100% 100% 100% 100%
packages/react/src/hooks/document/useDocumentSyncStatus.ts 94.11% 100% 33.33% 94.11% 56
packages/react/src/hooks/document/useEditDocument.ts 98.21% 94.44% 100% 98.21% 315
packages/react/src/hooks/helpers/useNormalizedSourceOptions.ts 73.68% 78.57% 100% 73.68% 47-50, 55-56, 59-62
Generated in workflow #2923 for commit 64c35c1 by the Vitest Coverage Report Action

@cngonzalez cngonzalez force-pushed the 02-03-feat_document_update_document_store_to_accept_sources branch from 3da69ef to ecb1bad Compare February 3, 2026 16:40
@cngonzalez cngonzalez force-pushed the 01-30-test_e2e_create_e2e_tests_for_recent_source_changes branch from 8118fef to 414b5c2 Compare February 3, 2026 18:38
@cngonzalez cngonzalez force-pushed the 02-03-feat_document_update_document_store_to_accept_sources branch from ecb1bad to 2fc0f75 Compare February 3, 2026 18:38
@cngonzalez cngonzalez force-pushed the 01-30-test_e2e_create_e2e_tests_for_recent_source_changes branch from 414b5c2 to 5a03ef1 Compare February 3, 2026 20:47
@cngonzalez cngonzalez force-pushed the 02-03-feat_document_update_document_store_to_accept_sources branch from 2fc0f75 to fe62d9c Compare February 3, 2026 20:48
@cngonzalez cngonzalez force-pushed the 02-03-feat_document_update_document_store_to_accept_sources branch from fe62d9c to 6e66fe0 Compare February 4, 2026 14:15
@cngonzalez cngonzalez force-pushed the 01-30-test_e2e_create_e2e_tests_for_recent_source_changes branch from 5a03ef1 to 1ee130b Compare February 4, 2026 14:15
@cngonzalez cngonzalez force-pushed the 02-03-feat_document_update_document_store_to_accept_sources branch from 6e66fe0 to 14b1f0b Compare February 4, 2026 14:30
@cngonzalez cngonzalez marked this pull request as ready for review February 4, 2026 14:49
@cngonzalez cngonzalez requested a review from a team as a code owner February 4, 2026 14:49
@cngonzalez cngonzalez requested review from ryanbonial and somerandomdude and removed request for a team February 4, 2026 14:49
@cngonzalez cngonzalez force-pushed the 01-30-test_e2e_create_e2e_tests_for_recent_source_changes branch from 1ee130b to b4a3333 Compare February 5, 2026 14:54
@cngonzalez cngonzalez force-pushed the 02-03-feat_document_update_document_store_to_accept_sources branch from 14b1f0b to a1a8e01 Compare February 5, 2026 14:54
@cngonzalez cngonzalez force-pushed the 02-03-feat_document_update_document_store_to_accept_sources branch from a1a8e01 to ef129f0 Compare February 5, 2026 14:59
@cngonzalez cngonzalez force-pushed the 01-30-test_e2e_create_e2e_tests_for_recent_source_changes branch from b4a3333 to 29026a9 Compare February 5, 2026 14:59
@cngonzalez cngonzalez force-pushed the 01-30-test_e2e_create_e2e_tests_for_recent_source_changes branch from 29026a9 to 18535b3 Compare February 5, 2026 15:42
@cngonzalez cngonzalez force-pushed the 02-03-feat_document_update_document_store_to_accept_sources branch from ef129f0 to 07d8fea Compare February 5, 2026 15:42
@cngonzalez cngonzalez force-pushed the 01-30-test_e2e_create_e2e_tests_for_recent_source_changes branch from 18535b3 to cd6689d Compare February 5, 2026 20:36
@cngonzalez cngonzalez force-pushed the 02-03-feat_document_update_document_store_to_accept_sources branch from 07d8fea to f687768 Compare February 5, 2026 20:36
@cngonzalez cngonzalez changed the base branch from 01-30-test_e2e_create_e2e_tests_for_recent_source_changes to graphite-base/730 February 6, 2026 16:36
@cngonzalez cngonzalez force-pushed the 02-03-feat_document_update_document_store_to_accept_sources branch from f687768 to e80329b Compare February 6, 2026 16:47
@graphite-app graphite-app bot changed the base branch from graphite-base/730 to main February 6, 2026 16:47
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.

1 participant