Skip to content

test(files): collaborative agent-streaming coverage (two-writer, multi-editor, undo, persist round-trip) - #6199

Merged
waleedlatif1 merged 4 commits into
stagingfrom
files-collab-streaming-tests
Aug 3, 2026
Merged

test(files): collaborative agent-streaming coverage (two-writer, multi-editor, undo, persist round-trip)#6199
waleedlatif1 merged 4 commits into
stagingfrom
files-collab-streaming-tests

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

Adds deterministic regression coverage for the collaborative agent-streaming surface, following the blank-line-collapse fix (#6198, merged). These exercise the CRDT/merge/convert logic with genuine Yjs peers — they answer "does concurrent human editing during an agent stream corrupt the doc?" (it does not) and lock in the invariants.

Two-writer (apply-streamed-markdown.concurrent.test.ts): a peer edits while the agent streams —

  • non-overlapping (agent appends, peer edits elsewhere) → peer edit survives, no clobber
  • position-drift (agent inserts above, peer edits below) → peer edit stays attached, no misplacement
  • overlapping rewrite → both edits merge, converges
  • full rewrite → agent content clean, no duplication
  • all: converge, no duplication, no stray empty paragraphs

Integration / moving pieces (collab-streaming-integration.test.ts):

  • three-way (agent + 2 peers) convergence, both peer edits survive
  • undo isolation — a peer's undo reverts only its own edit, never the agent's stream
  • persist round-trip — stream → durable markdown → reopen is a fixed point, zero blank runs
  • empty-collapse on the live streaming path — a pathological blank run yields 0 empty paragraphs
  • late joiner — a peer syncing after the stream sees the full, clean doc

Type of Change

  • Test coverage (no production code change)

Testing

  • 10 new tests, all green; typecheck clean; biome clean.
  • Scope note (in the file headers): these cover CRDT/merge/convert logic deterministically; they do NOT cover the realtime socket transport, the RAF-paced stream loop, or real browser timing — those need a live 2-browser E2E harness.

Checklist

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

@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 3, 2026 2:00am

Request Review

@cursor

cursor Bot commented Aug 3, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only PR with no runtime behavior changes; risk is limited to CI time and test maintenance.

Overview
Adds 10 new Vitest/jsdom tests only—no production code changes. They lock in collaborative agent markdown streaming via the real beginAgentStream / applyAgentStreamFrame path with genuine Yjs peer wiring (not mocks).

Two-writer suite (apply-streamed-markdown.concurrent.test.ts): while a peer edits, the agent streams—asserting CRDT convergence, no stray empty paragraphs, and (where specified) that unrelated peer edits survive appends, position drift after inserts above, full rewrites, and overlapping edits (overlap is mostly diagnostic).

Integration suite (collab-streaming-integration.test.ts): three-way agent + two peers, undo isolation (peer undo does not revert agent stream), persist round-trip through yDocToMarkdown / markdownToYDoc, empty-collapse on a pathological blank run on the live stream path, and late joiner sync.

File headers note these cover CRDT/merge/convert logic only—not realtime transport, RAF streaming, or multi-browser E2E.

Reviewed by Cursor Bugbot for commit 8eea69d. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds deterministic Yjs regression coverage for collaborative agent streaming, including concurrent editors, convergence, undo isolation, persistence, empty-paragraph collapse, and late joining.

  • Adds two-writer scenarios covering non-overlapping edits, position drift, overlapping rewrites, and full-document rewrites.
  • Adds integration scenarios covering three peers, isolated undo, durable markdown round-trips, pathological blank runs, and post-stream synchronization.
  • Corrects the previously reported false-green by applying and asserting the full-rewrite peer edit before its target is removed.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported false-green is fixed by asserting the peer insertion while its target still exists before applying the full rewrite.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/collaboration/apply-streamed-markdown.concurrent.test.ts Adds concurrent two-writer regression scenarios; the revised full-rewrite case now verifies that the peer insertion executes before the rewrite and survives exactly once.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/collaboration/collab-streaming-integration.test.ts Adds deterministic integration coverage for multi-peer convergence, undo isolation, persistence stability, blank-run collapse, and late joining.

Reviews (3): Last reviewed commit: "test(files): assert every peer edit land..." | Re-trigger Greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8eea69d. Configure here.

@waleedlatif1
waleedlatif1 merged commit 2ccda18 into staging Aug 3, 2026
27 checks passed
@waleedlatif1
waleedlatif1 deleted the files-collab-streaming-tests branch August 3, 2026 02:21
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