Skip to main content

Overview

Glass provides built-in multiplayer collaboration capabilities, allowing teams to work together in real-time on the same codebase. The collaboration system is built on a robust client-server architecture with conflict-free editing and awareness features.

User System

User Representation

// From crates/client/src/user.rs
pub struct User {
    pub id: UserId,
    pub github_login: SharedString,
    pub avatar_uri: SharedUri,
    pub name: Option<String>,
}
Each user in a collaboration session is identified by:
  • User ID: Unique identifier for the user
  • GitHub Login: GitHub username for authentication
  • Avatar: Profile picture URI
  • Display Name: Optional friendly name

Collaborator Information

pub struct Collaborator {
    pub peer_id: proto::PeerId,
    pub replica_id: ReplicaId,
    pub user_id: UserId,
    pub is_host: bool,
    pub committer_name: Option<String>,
    pub committer_email: Option<String>,
}
Active collaborators have additional metadata:

Network Identity

  • Peer ID for network communication
  • Replica ID for conflict-free editing

Git Integration

  • Committer name and email
  • Host status for session ownership

Contact Management

Contact System

Manage your professional network within Glass:
pub struct Contact {
    pub user: Arc<User>,
    pub online: bool,
    pub busy: bool,
}

Contact Request Flow

1

Send Request

Send a contact request to another Glass user
2

Request Status

Track request status: None, RequestSent, RequestReceived, or RequestAccepted
3

Accept or Decline

Recipient can accept or decline the contact request
4

Collaboration Ready

Once accepted, users can collaborate and see each other’s online status

Contact Events

pub enum ContactEventKind {
    Requested,
    Accepted,
    Cancelled,
}
The system emits events for:
  • New contact requests
  • Accepted contact requests
  • Cancelled requests

Real-Time Collaboration

Participant Tracking

The UserStore maintains:
  • All users by ID and GitHub login
  • Participant indices for each user
  • Online/offline status
  • Busy status indicators

Cursor and Selection Sharing

See collaborators’ cursors and selections in real-time:
  • Each collaborator has a unique color
  • Cursor positions update as collaborators type
  • Selection ranges are highlighted
  • Collaborator names appear next to cursors
Collaborator cursor display can be controlled with the DisplayCursorNames action in the editor.

Project Sharing

Project Collaboration

pub struct ProjectId(pub u64);

pub struct ParticipantIndex(pub u32);
Share entire projects with collaborators:
  • Host Controls: Project host manages permissions
  • Participant Indices: Unique index for each participant
  • Project Synchronization: Files and changes sync automatically

Shared Editing

The collaboration system provides:
  • Conflict-Free Editing: Operational transformation ensures edits don’t conflict
  • Replica IDs: Each editor instance has a unique replica ID for tracking changes
  • Automatic Merging: Changes from multiple users merge seamlessly

Network Architecture

Client-Server Communication

Glass uses a client-server architecture:

Client

  • Manages local editor state
  • Sends operations to server
  • Receives and applies remote operations
  • Handles presence updates

Server

  • Routes operations between clients
  • Maintains authoritative state
  • Manages user authentication
  • Tracks active sessions

Protocol

Communication uses the proto protocol:
// Network peer identification
pub peer_id: proto::PeerId,

// User data requests
rpc::proto::UsersResponse

User Management

User Store Events

pub enum Event {
    Contact {
        user: Arc<User>,
        kind: ContactEventKind,
    },
    ShowContacts,
    ParticipantIndicesChanged,
    PrivateUserInfoUpdated,
    PlanUpdated,
}
The user store emits events for:
  • Contact-related changes
  • Participant changes in active sessions
  • User profile updates
  • Subscription plan changes

Organization Support

pub current_organization: Option<Arc<Organization>>,
pub organizations: Vec<Arc<Organization>>,
pub plans_by_organization: HashMap<OrganizationId, Plan>,
Support for team organizations:
  • Organization membership tracking
  • Organization-specific plans
  • Team-wide collaboration features

Privacy and Permissions

Access Control

Only users you’ve accepted as contacts can see your online status and request to join your projects.
Privacy features:
  • Contact-Based: Only contacts can collaborate
  • Invitation System: Explicit invitations required for project access
  • Host Controls: Project host can remove participants

Status Management

Control your availability:
  • Online Status: Automatically tracked when app is active
  • Busy Status: Set busy to indicate focus time
  • Offline Mode: Work without broadcasting presence

Best Practices

Effective Collaboration

1

Add Contacts

Build your network by adding trusted collaborators as contacts
2

Share Projects

Share projects with specific collaborators when you need real-time help
3

Communicate

Use cursor positions and selections to show what you’re working on
4

Manage Presence

Set busy status when you need focused time without interruptions

Performance Considerations

  • Collaboration works best with stable internet connections
  • Large files may have slight latency in synchronization
  • The system automatically handles network interruptions and reconnections
For the best collaboration experience, ensure all participants are using recent versions of Glass.

Integration with Features

Collaborative Editing

Collaboration integrates with core editor features:
  • Multi-Cursor Awareness: See all collaborators’ cursors
  • Selection Sharing: View what others have selected
  • Git Integration: Committer information tracked per user
  • Language Server: Shared diagnostics and code actions

Future Enhancements

The collaboration system is designed to support:
  • Voice and video integration
  • Shared terminal sessions
  • Collaborative debugging
  • Team-wide extension sharing

Build docs developers (and LLMs) love