Skip to content

[Core] Decoupled Rendering Loop (Fixed-FPS Render Thread) #90

@yashksaini-coder

Description

@yashksaini-coder

Goal

Keep the UI smooth at a fixed frame rate even during heavy I/O operations.

Description

Currently the TUI redraws on every event (keypress, channel message, etc.), which means the frame rate is tied to event frequency. During heavy I/O (large searches, installs), the UI can appear to stutter.

Decouple rendering from event handling with a dedicated render thread:

  1. Move the draw_ui call to a separate thread that targets a fixed FPS (e.g., 60 FPS = 16ms sleep between frames)
  2. The render thread reads from a shared Arc<RwLock<AppState>> (or similar snapshot) rather than mutable App
  3. The event/logic thread continues updating App state and writing to the shared snapshot
  4. Use double-buffering or dirty flags to skip renders when nothing has changed

This is a significant architectural refactor. Discuss the design — particularly around terminal ownership and Ratatui's DefaultTerminal — before starting.

Tech

Rust, Concurrency (Arc, RwLock), Ratatui

Difficulty

Level 3 – Advanced

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions