Skip to content

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

Open
waleedlatif1 wants to merge 9 commits into
stagingfrom
codex/state-of-the-art-file-editor
Open

feat(files): improve editor recovery and editing controls#7519
waleedlatif1 wants to merge 9 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 automatic and quiet; no draft download/discard controls.
  • Reconcile durable file changes through the transactional outbox. Ignore delayed invalidations for older document generations, retry deferred persistence, and drain accepted edits and presence cleanup before graceful shutdown.
  • Recover automatically from an initial connection timeout without seeding the authoritative document from a stale preview. Retain terminal handling for authorization and document replacement failures.
  • Authorize content-room membership before exposing document or presence frames; pending joins receive only invalidation notifications through a temporary server-side channel.
  • Add find/replace and improve links, image metadata, resizing, typed-image syntax, and narrow-pane toolbars. Preserve peer changes and collaborative selections during editing gestures. Accept the existing anonymous uploader attribution in the response contract.
  • Deployment prerequisite: deploy compatible app outbox consumers and realtime relays and drain old consumers before enabling the reconciliation producer. Old app workers can discard unfamiliar events. This requires a compatibility-first release sequence or a default-off rollout gate; deployment readiness is not yet verified.
  • Retain two documented limitations: conventional middle-list exit remains deferred because the tested lift loses delayed peer edits; a literal bang directly before a text link remains ambiguous in the upstream Markdown serializer. No dependency patch or unsafe restructuring is included.

Type of Change

  • Bug fix
  • Enhancement

Testing

  • 2,585 focused app tests, all 354 realtime tests, and all 13 realtime-protocol tests pass: 202 files and 2,952 non-overlapping tests.
  • App, realtime, and protocol TypeScript checks pass. All 26 repository lint tasks, all 45 CI audits, API boundary validation, block-registry validation, and generated-artifact checks pass.
  • Real Redis and two-relay checks cover invalidation races, persistence retry, final flush, ACK retry, deduplication, and same-socket destroy/reopen.
  • Three new admission regressions fail before the fix and pass after it. An additional two-relay, real Redis-adapter probe verifies pending joins receive remote invalidations but no document/presence broadcasts before their final permission decision.
  • Live two-tab editor checks cover peer image metadata, retained link drafts, typing, resizing, uploads, initial-outage recovery, immediate refresh, and graceful relay restart. A sole-tab close/reopen test verifies IndexedDB recovery without a surviving peer or in-memory document.
  • Eight cleanup passes and independent fix reviews completed. React Doctor is diagnostic only: existing/scoped findings were reviewed, its maintainability phase did not complete, and it is not counted as a passing gate.
  • Coverage is local and automated, not proof of zero possible regressions. Native IME hardware, every browser/device, production session expiry, and production failover 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 6, 2026 1:28am 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 across browser recovery, Redis-backed relay coordination, durable outbox reconciliation, and graceful shutdown. It also expands rich Markdown editing controls and preserves image, link, selection, and formatting behavior across collaborative updates.

  • Adds bounded client-side recovery for unacknowledged Yjs updates with generation fencing and malformed-record quarantine.
  • Adds atomic Redis stream replay, compaction, deduplication, invalidation, and acknowledged-update handling.
  • Reconciles durable file changes through the transactional outbox and drains pending persistence during shutdown.
  • Adds find/replace and improves links, images, resizing, narrow-pane controls, and collaboration-safe editing gestures.
  • Moves pending file-document joins to an invalidation-only room until final authorization succeeds.

Confidence Score: 5/5

The PR appears safe to merge based on the reviewed code, with all previous findings resolved and no actionable new failures identified.

The latest changes correctly keep pending joins out of content-bearing rooms until final authorization, preserve invalidation delivery through a separate admission room, and drain tracked disconnect cleanup before releasing Redis-backed dependencies. The earlier Redis replay, recovery, image handling, link selection, formatting-policy, comment-style, and authorization findings are resolved or withdrawn.

Important Files Changed

Filename Overview
apps/realtime/src/handlers/file-doc.ts Delays document-room membership until final authorization and uses a separate invalidation-only admission room.
apps/realtime/src/handlers/file-doc-store.ts Implements generation-fenced Redis replay, atomic append and compaction, acknowledged-update deduplication, and bounded stream processing.
apps/realtime/src/handlers/connection.ts Tracks asynchronous disconnect cleanup so shutdown can wait for presence removal.
apps/realtime/src/index.ts Reorders graceful shutdown to flush documents, close transports, drain cleanup, and then release Redis dependencies.
apps/realtime/src/routes/http.ts Fans document invalidations out to both admitted editors and pending admission rooms.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/collaboration/file-doc-provider.ts Adds acknowledged-update recovery, reconnect handling, generation validation, and terminal-state behavior.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/collaboration/pending-update-journal.ts Provides bounded IndexedDB recovery with validation, quarantine, and identity-safe acknowledgement.
apps/sim/lib/core/outbox/service.ts Extends transactional outbox processing for durable file-document reconciliation.
packages/realtime-protocol/src/file-doc.ts Extends the shared file-document protocol for readiness, acknowledgements, generation identity, and invalidation.

Sequence Diagram

sequenceDiagram
    participant B as Browser editor
    participant R as Realtime relay
    participant S as Redis stream
    participant A as App outbox consumer
    participant D as Durable file storage
    B->>R: Authenticate and request file join
    R->>R: Resolve initial authorization
    R->>S: Hydrate document and verify generation
    R->>R: Resolve final authorization
    R-->>B: Join content room and synchronize Yjs state
    B->>R: Send acknowledged collaborative update
    R->>S: Atomically append and deduplicate update
    R-->>B: Acknowledge accepted update
    R->>A: Request durable reconciliation
    A->>D: Persist projected Markdown
    A->>R: Deliver versioned invalidation/reconciliation
    R->>S: Fence stale generations
    R-->>B: Continue with current generation or rejoin
Loading

Reviews (9): Last reviewed commit: "fix(files): authorize joins before subsc..." | 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
@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 6, 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 6, 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.

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