Skip to content

perf(tui): full-file view performs large synchronous reads and highlighting during render #833

Closed

Description

@PierrunoYT

Version / branch / commit

main at 097c2652cba22d929c598347aacc6f95591c9031

OS and environment

Any OS; TUI full-file view.

Steps to reproduce

  1. Open the TUI file view for a generated file containing thousands of large lines.
  2. Switch to full-file rendering.
  3. Observe input/render latency and memory growth while the view synchronously reads and highlights the file.

Relevant code: internal/tui/file_view.go:164-230.

renderFileViewFull performs disk I/O, retains up to 4,000 lines, allows scanner tokens up to 16 MiB each, syntax-highlights all accepted lines, and fits every rendered line synchronously in the view path. There is a line cap but no practical total-byte cap.

Expected behavior

Rendering should remain responsive and memory-bounded even for unusually large/generated files. The View path should render cached model state rather than perform blocking disk/highlighting work.

Actual behavior

A file within the current line/token limits can trigger long synchronous work and severe allocation pressure, freezing terminal interaction.

Suggested fix and regression test

Load and highlight through a cancellable tea.Cmd, cache by path plus modification identity, and enforce both a modest total-byte cap and a smaller per-line cap.

Add tests proving repeated View calls do not reread/rehighlight, and that large lines/files are truncated within a fixed byte budget.

Reported by PierrunoYT from a full codebase audit.

Activity

  1. Vasanthdev2004 commented on Aug 5, 2026

    @Vasanthdev2004
    Collaborator

    Still present: renderFileViewFull is at internal/tui/file_view.go:168 and does the read, the highlighting and the fitting inside the render path.

    Sorry for the wait. This one we would take, but it is behind the correctness reports you filed the same day. There is no wrong output here, only latency and memory on large files, so if you are picking one to work on first take #831 or #834. When you do get to this, the fix we want is moving the read and highlight off the render path with a total-byte cap, not just a smaller line cap.

  2. added
    bug
    enhancement
    and removed
    bug
    on Aug 5, 2026
  3. Vasanthdev2004 commented on Aug 12, 2026

    @Vasanthdev2004
    Collaborator

    @PierrunoYT same situation as #868: internal/tui/file_view.go still exists but renderFileViewFull does not, so the cited code has been renamed or restructured since you filed.

    The underlying concern is very likely still live, since nothing suggests the view moved off synchronous reads. But I do not want to approve a performance issue against a function that no longer exists, because whoever picks it up would start from a stale map.

    Could you re-point it at the current code? Happy to approve once it lands on something real.

  4. added 4 commits that reference this issue on Aug 26, 2026
    36fbd12
    ca6e69d
    159f69e
    6c6c1b0
  5. added
    issue-approved
    on Aug 27, 2026
  6. added a commit that references this issue on Sep 12, 2026
    37177bc
  7. added a commit that references this issue on Sep 21, 2026
    b46855a
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

    enhancementissue-approved

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions