Skip to content

Yjs persistence redesign#462

Merged
InfinityBowman merged 3 commits into
mainfrom
yjs-persistence-redesign
Apr 7, 2026
Merged

Yjs persistence redesign#462
InfinityBowman merged 3 commits into
mainfrom
yjs-persistence-redesign

Conversation

@InfinityBowman
Copy link
Copy Markdown
Owner

@InfinityBowman InfinityBowman commented Apr 7, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced tool resource pages with expanded information including bias domains, FAQs, workflow details, version history, and citations.
  • Improvements

    • Optimized URL handling with automatic trailing-slash canonicalization.
    • Strengthened data persistence for study checklist progress across browser reloads.
  • Documentation

    • Updated edge configuration guidance for static assets and redirect rules.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 7, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d2ab82f5-e784-4455-9512-9b2eaf23b167

📥 Commits

Reviewing files that changed from the base of the PR and between f9f14b6 and b33e022.

⛔ Files ignored due to path filters (4)
  • packages/docs/audits/reconciliation-rerender-audit.md is excluded by !packages/docs/audits/**
  • packages/docs/audits/seo-libguide-outreach.md is excluded by !packages/docs/audits/**
  • packages/docs/audits/yjs-persistence-redesign.md is excluded by !packages/docs/audits/**
  • packages/docs/audits/yjs-sync-pipeline-redesign-a.md is excluded by !packages/docs/audits/**
📒 Files selected for processing (27)
  • .claude/CLAUDE.md
  • knip.config.ts
  • packages/web/e2e/persistence-recovery.spec.ts
  • packages/web/public/_redirects
  • packages/web/src/components/billing/PricingTable.tsx
  • packages/web/src/components/org/CreateOrgPage.tsx
  • packages/web/src/components/project/overview-tab/OverviewTab.tsx
  • packages/web/src/components/resources/ToolResourcePage.tsx
  • packages/web/src/components/settings/LinkedAccountsSection.tsx
  • packages/web/src/lib/__tests__/checklist-domain.test.ts
  • packages/web/src/lib/tool-content.ts
  • packages/web/src/stores/authStore.ts
  • packages/workers/src/commands/invitations/acceptInvitation.ts
  • packages/workers/src/durable-objects/ProjectDoc.ts
  • packages/workers/src/durable-objects/__tests__/ProjectDoc.persistence.test.ts
  • packages/workers/src/durable-objects/__tests__/ProjectDoc.rpc.test.ts
  • packages/workers/src/durable-objects/__tests__/ProjectDoc.test.ts
  • packages/workers/src/lib/__tests__/email-queue.test.ts
  • packages/workers/src/middleware/__tests__/requireAdmin.test.ts
  • packages/workers/src/routes/__tests__/project-invitations.test.ts
  • packages/workers/src/routes/avatars.ts
  • packages/workers/src/routes/billing/__tests__/paymentIntentHandlers.test.ts
  • packages/workers/src/routes/google-drive.ts
  • packages/workers/src/routes/invitations.ts
  • packages/workers/src/routes/orgs/invitations.ts
  • packages/workers/src/routes/orgs/members.ts
  • packages/workers/src/routes/test-seed.ts

📝 Walkthrough

Walkthrough

This PR introduces significant backend persistence redesign for Durable Objects (switching from debounced full-doc persistence to SQL-backed incremental Yjs updates), expands tool resource content models, adds persistence recovery E2E tests, refactors multiple worker routes for type safety, and includes various frontend component refinements and documentation updates.

Changes

Cohort / File(s) Summary
Documentation & Build Config
.claude/CLAUDE.md, knip.config.ts, packages/web/public/_redirects
Added edge configuration docs for static assets (_headers, _redirects behavior), compressed knip config formatting, and new trailing-slash canonicalization redirect rules (301 redirects for marketing/auth/resource pages).
E2E Testing - Persistence Recovery
packages/web/e2e/persistence-recovery.spec.ts
Added comprehensive end-to-end test validating persistence of partially-completed study checklist state across hard page reloads, including multiple reload cycles and WebSocket/IndexedDB resynchronization.
Frontend Component Refinements
packages/web/src/components/billing/PricingTable.tsx, packages/web/src/components/org/CreateOrgPage.tsx, packages/web/src/components/project/overview-tab/OverviewTab.tsx, packages/web/src/components/settings/LinkedAccountsSection.tsx, packages/web/src/lib/__tests__/checklist-domain.test.ts
Minor formatting and structure adjustments: fixed JSX conditional closure, reformatted authFetch call signatures (multi-line), simplified memoized computation syntax, and test file formatting cleanup.
Tool Resources Enhancement
packages/web/src/lib/tool-content.ts, packages/web/src/components/resources/ToolResourcePage.tsx
Expanded ToolContent interface with 14 new optional fields (fullName, domains, faq, citations, etc.) and 3 new exported types (DomainSummary, FaqEntry, Citation); significantly enriched AMSTAR 2, ROBINS-I, RoB 2 content with domains, FAQs, citations, and workflow descriptions; added FAQ JSON-LD schema generation for SEO.
Auth Store Refactoring
packages/web/src/stores/authStore.ts
Reformatted multiple authFetch call sites (signup, social signin, password reset, verification email) into multi-line argument structures without changing functional control flow or error handling.
Worker Route & Command Updates
packages/workers/src/commands/invitations/acceptInvitation.ts, packages/workers/src/routes/avatars.ts, packages/workers/src/routes/google-drive.ts, packages/workers/src/routes/invitations.ts, packages/workers/src/routes/orgs/invitations.ts, packages/workers/src/routes/orgs/members.ts, packages/workers/src/routes/test-seed.ts, packages/workers/src/routes/__tests__/*, packages/workers/src/middleware/__tests__/requireAdmin.test.ts, packages/workers/src/routes/billing/__tests__/paymentIntentHandlers.test.ts, packages/workers/src/lib/__tests__/email-queue.test.ts
Removed ContentfulStatusCode dependency and replaced with explicit status-code unions (400 | 403 | 500, etc.); refactored multi-line invocation formatting for readability; added OpenAPI 413 error response documentation for file upload endpoints; minor test whitespace cleanup.
ProjectDoc Persistence System Redesign
packages/workers/src/durable-objects/ProjectDoc.ts, packages/workers/src/durable-objects/__tests__/ProjectDoc.persistence.test.ts, packages/workers/src/durable-objects/__tests__/ProjectDoc.rpc.test.ts, packages/workers/src/durable-objects/__tests__/ProjectDoc.test.ts
Replaced debounced full Y.Doc KV persistence with synchronous, incremental SQL-backed persistence (yjs_updates table with update/snapshot rows); added schema versioning via ensureSchema() migration, legacy KV blob migration (migrateLegacyState()), chunked snapshots, transactional compaction, and comprehensive test coverage validating write/cold-load/compaction/migration paths; introduced PersistenceLogger abstraction for observability.

Sequence Diagram(s)

sequenceDiagram
    participant Client as WebSocket Client
    participant ProjectDoc
    participant DOState as Durable Object State<br/>(SQL + KV)
    participant Logger as PersistenceLogger

    Note over Client,Logger: Runtime Update Event

    Client->>ProjectDoc: Y.Doc update event
    ProjectDoc->>ProjectDoc: Capture update payload
    ProjectDoc->>DOState: INSERT INTO yjs_updates<br/>(kind='update', payload)
    DOState-->>ProjectDoc: Insert complete
    ProjectDoc->>Logger: Log persistence_insert_failed<br/>(if error)
    Logger-->>ProjectDoc: Logged

    Note over ProjectDoc,DOState: Opportunistic Compaction Check

    alt rowCount >= COMPACTION_THRESHOLD
        ProjectDoc->>ProjectDoc: Collect all rows<br/>from SQL
        ProjectDoc->>ProjectDoc: Reconstruct Y.Doc<br/>from updates/snapshots
        ProjectDoc->>ProjectDoc: chunkSnapshot()<br/>into CHUNK_SIZE pieces
        ProjectDoc->>DOState: BEGIN TRANSACTION
        DOState->>DOState: DELETE old rows
        DOState->>DOState: INSERT chunked<br/>snapshot rows
        DOState-->>ProjectDoc: COMMIT
        ProjectDoc->>Logger: Log compaction_failed<br/>(if INSERT fails)
        alt Compaction succeeded
            Logger-->>ProjectDoc: Success logged
        else Compaction failed
            Logger-->>ProjectDoc: Failure logged
            ProjectDoc->>DOState: Rollback to<br/>pre-compaction rows
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yjs-persistence-redesign

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
🔵 In progress
View logs
corates-workers-prod b33e022 Apr 07 2026, 07:24 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 7, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
corates b33e022 Apr 07 2026, 07:26 PM

@InfinityBowman InfinityBowman merged commit d29118e into main Apr 7, 2026
0 of 2 checks passed
@InfinityBowman InfinityBowman deleted the yjs-persistence-redesign branch April 7, 2026 19:25
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.

2 participants