# Real-time collaboration

> Coordinate concurrent edits with OT, HTTP, WebSocket, persistence, and application deployment so people and agents can share content.

- Human documentation: [https://docs.univer.ai/overview/features/shared/collaboration](https://docs.univer.ai/overview/features/shared/collaboration)

- Agent Markdown: [https://docs.univer.ai/overview/features/shared/collaboration.md](https://docs.univer.ai/overview/features/shared/collaboration.md)

- Requested language: `en-US`

- Content language: `en-US`

- Documentation version: `1.6.1`

- Source: [features/shared/collaboration.mdx](https://github.com/dream-num/documentation/blob/dev/content/docs/features/shared/collaboration.mdx)

---

Real-time collaboration allows people and connected agents to work on the same document. An edit takes effect locally first. The server then orders the edits and distributes them to the other participants, so users receive immediate feedback while all participants converge on the same content.

## Concurrent editing and conflict handling

Univer uses OT (Operational Transformation) to coordinate concurrent edits. Clients group their editing operations into changesets, and the server transforms each changeset against the confirmed revisions before committing it. Clients converge after they receive each other's changes.

For example, Alice edits `C2` while Bob inserts a column before B. The transformed edit follows the cell to `D2`. Undo and redo also account for remote operations. OT attempts to preserve the user's intent, but it cannot resolve every business conflict automatically.

An operation that cannot be transformed or applied places the client in a conflict state and disables editing for that document. `CollaborationConflict` reports the reason and the local edits that were never acknowledged. Applications can use this information to recover or to save the user's work, but they must retain the local data before reloading. See [conflict recovery](https://docs.univer.ai/server/collaboration/browser-integration.md#conflict-recovery) and [OT and collaboration design](/blog/ot).

## HTTP, WebSocket, and reconnection

| Channel | Responsibility |
| --- | --- |
| HTTP | Loads snapshots and changesets, obtains a Session Ticket, and submits changesets. |
| WebSocket | Maintains the collaboration Session and the document Room, and receives ACKs, remote changes, and presence notifications. |

The client exchanges a one-time Session Ticket for a WebSocket connection and joins the document's Room. Presence shares online membership, cursors, and selections over the same connection. The client's state advances as the server confirms revisions. **A connected socket or a successful HTTP request does not indicate that the edit is saved.** Derive save status from ACKs, collaboration status, and pending edits.

While disconnected, the client can cache edits that have not yet been acknowledged. On reconnection, it fetches the revisions it missed and resends pending submissions. The server deduplicates submissions, so a retry is not applied twice. See [sync status and retries](https://docs.univer.ai/server/collaboration/browser-integration.md#sync-status) and [Presence](https://docs.univer.ai/server/collaboration/presence.md).

## Persistence and versioned snapshots

The collaboration service persists confirmed changesets and revisions, and generates snapshots according to its policy. Loading a document restores a snapshot and then applies the changes that followed it. Not every edit requires a new snapshot.

For calculation during snapshot generation, see [Headless and server-side calculation](https://docs.univer.ai/overview/features/shared/server-calculation.md). History panels, comments, and agent draft review are provided by separate [collaboration extensions](https://docs.univer.ai/server/collaboration/extensions.md), which can be added as needed.

## Deployment architecture

```mermaid
flowchart LR
    A["Client A"]
    B["Client B / Agent"]
    S["Application collaboration service<br/>OT · Confirm and broadcast"]
    D[("Application database")]
    A <-->|"HTTP / WebSocket"| S
    B <-->|"HTTP / WebSocket"| S
    S --> D
```

- **Single node:** assemble Transport, Endpoint, Service, and a Database Adapter inside your Node.js application. Memory is sufficient for temporary testing, SQLite suits local and small deployments, and other databases are connected through an Adapter provided by the application.
- **Scaling design:** shared persistence alone is insufficient. Document broadcasts across nodes, Presence, Session Ticket validation, and storage consistency must also be coordinated. Adding more service processes does not provide these capabilities, so follow the deployment design for the version you integrate.
- **Separate heavy tasks:** deploy CPU-intensive file conversion separately to reduce its interference with collaboration responsiveness.

See [module responsibilities](https://docs.univer.ai/server/collaboration/modules.md) for the full assembly, the [deployment guide](https://docs.univer.ai/server/deployment.md) for deployment steps, and the [multi-node example](https://docs.univer.ai/server/collaboration/examples.md#multi-node).

## Performance and capacity

**Performance benchmarks and capacity figures for the current version are still pending.** Capacity and collaboration latency depend on document size, editing frequency, the number of collaborators per document, and the deployment environment.

When you assess the system, consider submission acknowledgement time, remote display time, changesets per second, broadcast volume, and the memory used by active documents.

## Integration

Start with the [collaboration overview](https://docs.univer.ai/server/collaboration/overview.md) to understand how the modules relate, then run the two-browser [quick start](https://docs.univer.ai/server/collaboration/quick-start.md) to verify editing, acknowledgement, and broadcasting. Identity and authorization are connected through application Middleware. For durable data, select a persistent [Database Adapter](https://docs.univer.ai/server/collaboration/database-adapters.md) and verify that content survives a service restart.

## Scope

The core service supports Sheet, Doc, Slide, Canvases, and Relational Table; PDF is not included in this five-product core coverage. Applications provide identity, authorization, file management, and storage policies. History, comments, and Worktree are separate extensions.

[Back to all features](https://docs.univer.ai/overview/features.md)
