Skip to main content

Dirty Tracking Strategies

Terminal emulators need to track which parts of the screen have changed to optimize rendering. This page explains the two main approaches and why MonoTerm chose line-based tracking.

What is Dirty Tracking?

Dirty tracking answers: “What changed since last render?”

Two Approaches: Epoch vs Content Comparison

Epoch (Sequence Number)

Epoch is a monotonically increasing counter that increments whenever a write happens.

Content Comparison

Content comparison examines the actual data. Same content = no change detected.

The Critical Difference

The key difference: what happens when the SAME content is written again.

The Fundamental Distinction: Actions vs Content

Why This Matters for AI CLI

AI CLI applications have a specific output pattern where content-based tracking excels.

Partial Update: Natural with Content Comparison

Content comparison makes partial updates natural.

Why Line-Level is the Sweet Spot

Terminal dirty tracking could be done at different granularities.

Why Line-Level Matches GPU Rendering

MonoTerm’s DiffHint System

MonoTerm uses DiffHint to communicate what changed.

Comparison Summary

Summary