Skip to content

Floating diagram widget with text reflow #3

Closed

Description

@1jehuang

Summary

Add a diagram display mode where the diagram floats as a non-rectangular widget anchored to the middle-right of the screen, and chat text reflows around it (filling empty space on the left side).

Motivation

When a diagram is too wide for the side panel but the user does not want a top panel stealing vertical space, neither existing pane position works well. A floating widget that text wraps around (like CSS float: right) would use screen real estate more efficiently, especially for oddly-shaped diagrams.

Proposed behavior

  • Diagram anchored to the right side, vertically centered in the visible area
  • Text lines adjacent to the diagram wrap to a narrower width
  • Text lines above/below the diagram use the full width
  • Only reflow on the left side of the diagram (text fills in to the left)
  • Should work alongside the existing pinned Side/Top modes as a third option

Implementation notes

The rendering pipeline is fundamentally line-based, so this requires changes at multiple layers:

  1. Per-line variable wrap width - wrap_lines currently wraps to a single fixed width. Needs to accept per-line widths based on which rows overlap the diagram.
  2. Per-line rendering - Paragraph::new() renders all lines at the same width. Would need to render each line individually or in groups with matching widths.
  3. Scroll-dependent layout - which lines are adjacent to the diagram depends on scroll position, which affects line count, which affects scroll. This feedback loop needs careful handling to avoid visual glitches.
  4. Body cache invalidation - cache key needs to include diagram position relative to scroll, not just terminal width.

Resource cost: Near-zero per frame. Same number of characters and one image render.
Engineering cost: Moderate (2-3 days). The complexity is in scroll/reflow interaction correctness, not performance.

Alternatives considered

  • Side pane (exists, but wastes space for wide diagrams)
  • Top pane (exists, but steals vertical space)
  • Pop-out viewer (exists via o key, but leaves the TUI)
  • Full-screen overlay (simpler, but hides chat context)

Activity

  1. added
    enhancement
    on Feb 22, 2026
  2. 1jehuang commented on Mar 27, 2026

    @1jehuang
    OwnerAuthor

    Closing this umbrella issue in favor of smaller implementation tickets with explicit success criteria:

    The original issue is well-defined, but splitting it makes it much easier to implement and validate incrementally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions