Skip to content

feat(files): improve editor recovery and editing controls - #7519

Merged
waleedlatif1 merged 17 commits into
stagingfrom
codex/state-of-the-art-file-editor
Sep 8, 2026
Merged

feat(files): improve editor recovery and editing controls#7519
waleedlatif1 merged 17 commits into
stagingfrom
codex/state-of-the-art-file-editor

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Preserve unacknowledged collaborative edits across reconnects and reloads with bounded browser recovery, generation fencing, and atomic Redis replay/compaction. Keep routine reconnection quiet, without draft download/discard controls.
  • Reconcile external file changes through the transactional outbox, reject stale invalidations, authorize document-room membership before exposing frames, and drain accepted edits during shutdown.
  • Improve find/replace, link editing, image metadata/resizing, input rules, upload anchors, and editor lifecycle handling. Use the shared floating image toolbar and guard unfinished actions against incompatible peer changes.
  • Commit collaborative snapshots and Markdown pointers atomically under the existing file-row lock. Check content versions and exact cached revisions, bound snapshot sizes, and make concurrent seeds adopt one accepted identity.
  • Preserve native snapshots instead of privately normalizing their shared tree. Equivalent external Markdown bodies no longer delete live/offline edit targets. Keep the relay as snapshot owner for compatibility with older caches.
  • Close review gaps in post-append generation checks, accepted seed identities, missing-file admission, seed cancellation, malformed recovery entries, HTTP response cleanup, preview selection copying, and table-image detection.
  • Keep compaction off the durable-append acknowledgement wait, recheck current access before and after content-room admission, preserve valueless image attributes, and strengthen pending-delta recovery coverage.
  • Known limits remain: nested-list reparenting can lose delayed peer edits; unifying all cache-only historical operations needs a legacy compatibility plan; a literal bang immediately before a text link remains ambiguous in the upstream serializer. No unsafe schema migration, dependency patch, or history-reset fallback is included.
  • Deployment prerequisite: deploy compatible app outbox consumers and realtime relays and drain old consumers before enabling reconciliation producers. Drain older unconditional cache writers before relying on the new revision protocol. Deployment readiness is not verified here.

Type of Change

  • Bug fix
  • Enhancement

Testing

  • After reconciling staging: 379 realtime tests, 2,495 focused app tests, and 13 protocol tests passed; one environment-gated app integration test was skipped. The selection covers 175 passing files, not the entire application suite.
  • Isolated real Redis with two production store replicas: large pastes, byte-triggered compaction, alternating small edits, and exact fresh replay passed. The merged store preserves staging's byte threshold and cooldown with constant-space prefix accounting and generation-fenced snapshot/trim.
  • Real PostgreSQL checks exercise cache CAS, competing transactions, rollback, no-op validation, and byte bounds. Separate actual-Yjs tests cover seed races, legacy normalization compatibility, delayed edits, and equivalent-body updates.
  • Live two-tab editing, peer convergence, reloads, and downloaded durable-file bytes. The live pass exposed a legacy-cache regression in an intermediate implementation; the incompatible history-union change was removed and the same document saved successfully afterward.
  • All 26 workspace TypeScript checks, repository lint, 45 CI audits, block-registry validation, generated-artifact checks, and the previously completed eight scoped cleanup passes. React Doctor's supplemental full-repository scan was incomplete because its maintainability checks and score service did not complete.
  • Local tests are not proof of zero possible regressions. Every browser/device, native IME hardware, production session expiry, production failover, and historical-cache migration were not exercised.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new lint or type-check warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 7, 2026 11:40pm UTC

Request Review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@greptile-apps

greptile-apps Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR strengthens collaborative file editing and recovery across the browser, application, realtime relay, Redis, and durable storage layers.

  • Preserves bounded pending edits across reconnects and reloads with generation-fenced acknowledgement and replay.
  • Reconciles external file changes through transactional outbox processing and version-aware invalidation.
  • Tightens document-room authorization, shutdown draining, snapshot persistence, seeding, and compaction.
  • Improves rich Markdown editing behavior for find/replace, links, images, input rules, uploads, and editor lifecycle.
  • The changes since the previous review replace untyped Redis test scaffolding with scoped interfaces, resolving the remaining rule violation without changing runtime behavior.

Confidence Score: 5/5

The PR appears safe to merge because all previous findings are resolved and the latest changes introduce no new actionable issue.

The latest revision only replaces untyped Redis test-client scaffolding with scoped interfaces and shared stream-entry types. The current code also reflects the fixes or accepted resolutions recorded in every previous thread, leaving no outstanding merge blocker.

Important Files Changed

Filename Overview
apps/realtime/src/handlers/file-doc-store.ts Adds generation-fenced Redis replay, append, invalidation, seeding, and compaction behavior with bounded resource use.
apps/realtime/src/handlers/file-doc.ts Strengthens collaborative-room admission, authorization revalidation, synchronization, and invalidation handling.
apps/realtime/src/handlers/file-doc-store.test.ts Expands Redis stream race and recovery coverage and replaces the previously flagged any annotations with scoped test interfaces.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/collaboration/file-doc-provider.ts Adds acknowledged-update recovery and compatibility handling for disconnected and legacy collaborative sessions.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/collaboration/pending-update-journal.ts Implements bounded, validated browser recovery records with malformed-entry quarantine.
apps/sim/lib/collab-doc/persist.ts Coordinates durable collaborative snapshots and Markdown pointers under transactional version checks.
packages/realtime-protocol/src/file-doc.ts Extends the shared collaboration protocol used by the browser and realtime relay.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Editor[Rich Markdown editor] --> Journal[Bounded pending-update journal]
  Journal --> Provider[File document provider]
  Provider <--> Protocol[Realtime protocol]
  Protocol <--> Relay[Realtime file-document handler]
  Relay <--> Redis[(Generation-fenced Redis stream)]
  Relay --> App[Application seed and reconciliation APIs]
  App --> Outbox[Transactional outbox]
  App --> Database[(Durable file and snapshot state)]
Loading

Reviews (17): Last reviewed commit: "chore(files): type the Redis test client" | Re-trigger Greptile

Comment thread apps/realtime/src/handlers/file-doc-store.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

Comment thread apps/realtime/src/handlers/file-doc-store.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

Comment thread apps/sim/app/workspace/[workspaceId]/components/find-bar/find-bar.tsx Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 81 files

Re-trigger cubic

Comment thread apps/realtime/src/handlers/file-doc.ts
Comment thread apps/realtime/src/handlers/file-doc-store.ts Outdated
Comment thread apps/sim/lib/realtime/notify.ts
Comment thread apps/sim/lib/collab-doc/seed.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 84 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/realtime/src/handlers/file-doc-store.ts Outdated
Comment thread apps/realtime/src/handlers/file-doc.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

Comment thread apps/realtime/src/handlers/file-doc.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile Please re-review the actual PR diff against staging. The table-event concern may be valid upstream, but apps/sim/lib/realtime/event-log.ts and apps/sim/lib/table/events.ts are unchanged from the current staging merge base and are absent from GitHub's complete 84-file PR diff. git diff origin/staging...HEAD -- for those paths is empty. Their byte-budget implementation entered staging through #7568 (commit a69f416), not through this PR.

The last commit merged staging to resolve overlapping file-document compaction changes. Only apps/realtime/src/handlers/file-doc-store.ts and its tests required manual reconciliation. The billing and other Redis changes mentioned in the latest summary are unchanged upstream content carried by that merge, not additions in this PR's base-relative diff.

We have not fixed or claimed a hard per-entry table-event bound here. Please assess the editor PR against its staging base rather than attributing the merge's first-parent upstream changes to it. The file-document resolution retains the byte trigger, cooldown and compaction marker alongside bounded replay, constant-space prefix accounting and generation-fenced atomic snapshot/trim; focused tests and a two-replica real Redis probe passed.

Comment thread apps/realtime/src/handlers/file-doc-store.test.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
waleedlatif1 merged commit ea3f6ba into staging Sep 8, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the codex/state-of-the-art-file-editor branch September 8, 2026 00:04
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