Skip to main content

Atomic State System

Overview

The Atomic State system is Monolex’s core terminal rendering engine. It solves a fundamental problem: traditional terminals render incomplete data, causing flickering and glitches.

Architecture


The H + 2V Buffer Model

The H + 2V formula is the mathematical foundation for scroll consistency.

The Problem

xterm.js calculates scroll position using buffer size. If buffer size does not match the scroll area, you get desync:

The Formula

Visual Buffer Structure

Safety Proof

Understanding Coordinates: Buffer vs Viewport


Line Fingerprinting (FNV-1a)

The core mechanism for efficient change detection.

How Fingerprinting Works

Hash includes: Content, colors, text attributes (bold, underline), wrap flag

Performance Comparison


DiffHint Enum

The DiffHint tells the frontend exactly how to handle each update.

Visual Guide

Decision Flow


Frontend Processing

When the frontend receives a GridUpdate, it follows this decision tree to determine how to display it:

Feed/Pull Cycle

The AtomicState operates on a simple feed/pull cycle with ACK-based flow control.

Public API

ACK Flow Control

Why ACK?
  • Prevents flooding frontend with updates
  • Ensures each frame is processed before next
  • Timeout (1s) prevents deadlock if frontend stuck

Sync Detection Mechanisms

AtomicState uses multiple mechanisms to detect frame boundaries:

Priority 1: BSU/ESU

Priority 2: Cursor Hide Pattern

Priority 3: Implicit Sync


Performance Results

IPC Data Comparison

Typical Use Cases


Epoch Ordering

The epoch system prevents stale updates after resize events.

Summary


Last updated: 2026-01-17