Skip to content

Conversation

@forketyfork
Copy link
Owner

Solution:

  • Move grid render caching into a renderer-owned RenderCache keyed by session, and derive redraw decisions from SessionState render_epoch.
  • Replace direct dirty mutations with SessionState.markDirty to make invalidation explicit and decouple renderer from session state.
  • Reuse a per-frame SessionUiInfo buffer and add a short-lived foreground-process cache for UiHost snapshots to reduce per-frame churn.
  • Update architecture docs and engine plan notes to document cache ownership and epoch-based invalidation.

Issue: Reviewer flagged renderer mutating session cache/dirty state and per-frame syscalls for foreground process checks; update to reduce coupling and churn.

Solution: Move grid render caching into a renderer-owned RenderCache keyed by session and use a SessionState render epoch with markDirty for invalidation. Reuse a per-frame SessionUiInfo buffer and add a short-lived foreground-process cache for UiHost snapshots, then update docs to describe the new ownership and invalidation flow.
@forketyfork forketyfork requested a review from Copilot January 19, 2026 14:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors render caching by moving ownership from session state to the renderer, replacing boolean dirty flags with an epoch-based invalidation mechanism.

Changes:

  • Moved grid render cache from SessionState to a new RenderCache structure in the renderer
  • Replaced SessionState.dirty boolean with render_epoch counter and introduced markDirty() method
  • Added per-frame SessionUiInfo buffer reuse and foreground process caching to reduce allocations

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/session/state.zig Removed cache texture fields and dirty flag; added render_epoch and markDirty()
src/render/renderer.zig Added RenderCache struct with per-session entries tracking epochs and textures
src/main.zig Integrated RenderCache, reused SessionUiInfo buffer, added ForegroundProcessCache
docs/engine_plan_correction.md Updated to reflect renderer-owned cache resolution
docs/architecture.md Documented epoch-based invalidation and cache ownership

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@forketyfork forketyfork merged commit 1f3795c into main Jan 19, 2026
4 checks passed
@forketyfork forketyfork deleted the fix/renderer-cache-epoch branch January 19, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants