Skip to content

[Phase 7F] Framebuffer diff rendering: flat array + flush diffs only #33

@fissible

Description

@fissible

What

Replace per-render /dev/tty writes with a double-buffered framebuffer. Only changed cells are emitted per frame.

Architecture:

  • Two flat 1D arrays: _SF_FRAME_CURR[row*COLS+col] and _SF_FRAME_PREV[row*COLS+col] — each cell stores the rendered string for that position (character + ANSI codes).
  • All render functions write to _SF_FRAME_CURR instead of /dev/tty.
  • shellframe_screen_flush diffs CURR vs PREV, emits only changed cells as positioned escape sequences (\033[row;colH), then copies CURR → PREV.
  • shellframe_screen_clear resets both buffers and clears the terminal.

Migration note: Check src/screen.sh for any scaffolding already in place from task B.

Recommended approach — migrate incrementally:

  1. Add framebuffer array init + shellframe_screen_flush (diff + emit)
  2. Migrate one render function (e.g. shellframe_panel_render) to write to buffer; run tests
  3. Migrate remaining render functions one at a time, running tests after each
  4. Remove all direct /dev/tty writes from render paths
  5. Call shellframe_screen_flush at end of each app loop iteration in shellframe_shell

Files

  • src/screen.sh — framebuffer arrays, shellframe_screen_flush, clear reset
  • All widget render functions — write to _SF_FRAME_CURR instead of /dev/tty
  • src/shell.sh — call shellframe_screen_flush at end of loop

Done criteria

  • All render output goes through shellframe_screen_flush
  • Only changed cells emitted per flush — verified by a test that a no-change flush produces zero output
  • No direct /dev/tty writes remain in render functions
  • All existing assertions still pass after full migration
  • Tests: no-change flush emits nothing; single-cell change emits only that cell; full clear resets both buffers

IO/timing note (CLAUDE.md §5)

The no-change flush test must exercise an actual flush call — not a mock. Terminal behavior (what triggers output) must be verified in a real environment.

Effort

XL (2–3 days)

Deps

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions