fix: add skip_caret_positions option to reduce text layout memory
Summary
Add a skip_caret_positions field to LineStyle that enables callers to skip computing caret positions during text layout. This provides infrastructure for reducing memory usage in display-only text rendering.
Context
Sentry memory alert analysis (issue 7259255054) showed 11.6 GB of live memory during a 20+ hour Agent Mode session on macOS stable. Heap profile breakdown:
- ~3.5 GB (30%):
CaretPositionvectors fromcaret_positions_for_line— eagerly computed for every text line, including display-only UI text - ~2.8 GB (24.4%): tree-sitter parsing during
AgentManagementViewcreation - ~1.4 GB: Editor content/rendering (SumTree, syntax highlights)
Caret positions (cursor/selection snap points) are only needed for interactive text. Display-only text (menus, labels, banners, formatted text) never uses them but still pays the memory cost.
Changes
- Add
skip_caret_positions: booltoLineStyle(defaultfalse— backwards compatible) - Modify
line_from_ct_lineon macOS to skipcaret_positions_for_linewhen flag is set - Update
Line::first_index()andLine::last_index()to fall back to glyph data when caret positions are empty
Follow-ups
- Enable
skip_caret_positions: truefor specific display-only callers (formatted text elements, shimmering text, menu items) to realize the memory savings - Investigate tree-sitter memory growth during long Agent Mode sessions
Conversation: https://staging.warp.dev/conversation/9e759d18-e877-4fec-b797-9cfe08836188 Run: https://oz.staging.warp.dev/runs/019e710a-89c8-7a02-bc7c-adf502685bf9 This PR was generated with Oz.