GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tui: transcript memory scales with the full session log, not the compaction window · Issue #61313 · anomalyco/opencode

tui: transcript memory scales with the full session log, not the compaction window #61313

New issue
Copy link
New issue
Copy link
Open
Open
tui: transcript memory scales with the full session log, not the compaction window#61313
Copy link

Description

@521ox
521ox
opened on Nov 3, 2026
Issue body actions

Description

The TUI keeps every transcript page it has loaded for the current session in its client JS heap. Compaction limits the model request, but nothing limits this store.

packages/client/src/solid/data.ts holds session.message[sessionID] as a full array. session.message.sync reads the last 20 rows, but loadMore() prepends older pages and never drops them; "jump to first message" calls loadMore(..., { all: true }) and walks the entire history. packages/client/src/solid/retention.ts evicts only session families whose root is not retained. The current root and open tabs are always retained (limit: 3 in packages/tui/src/context/session-tabs.tsx), so the active transcript never gets released.

Measured on a TUI left open for about 4.8 days with one root session:

  • Session: 39,412 messages, 176,132 parts, 1,092 MB of message JSON in SQLite.
  • TUI process: 2.88 GB working set, 3.92 GB private.
  • Only 2,493 messages / 50.8 MB were added during those 4.8 days.
  • The latest compaction leaves 165 messages / 2.1 MB in the model window.
  • In a separate Bun process, reading and JSON-parsing those 39,412 rows uses 3.7 GB RSS / 3.0 GB heapUsed, matching the TUI's private memory.
  • Restarting the TUI drops it to a few hundred MB. Loading the old pages again reproduces the growth.

The session is text-only tool output; the largest single messages are 63 MB patch diffs, so media refs are not the cause. The cost tracks the full stored transcript, while the model only needs the compacted window.

A bounded window for the active session (for example keep the most recent N messages and refetch older pages on scroll) would decouple client memory from transcript length. Related: #56737 covers evicted families; this report is the retained current session.

Plugins

None that affect the transcript (local session-memory plugin, codegraph and js-reverse MCP servers).

OpenCode version

2.2.0 (custom-lite build of the 2.2.0 tree; the client retention and loadMore code paths above match dev).

Steps to reproduce

  1. Use one root session long enough to accumulate tens of thousands of messages, or seed one.
  2. In the TUI, jump to the first message (or scroll back far enough that older pages load).
  3. Watch the TUI process memory: it grows with the loaded transcript and does not shrink after compaction.
  4. Restart the TUI: memory returns to baseline, and step 2 grows it again.

Screenshot

No screenshot; the numbers above come from Get-Process (WorkingSet64, PrivateMemorySize64) and length(data) over session_message.

Operating System

Windows 11 10.0.22631

Terminal

Windows Terminal 1.24

Activity

  1. opencodejr commented on Nov 3, 2026

    @opencodejr
    opencodejrBot
    on Nov 3, 2026
    Contributor
    More actions

    Thanks for the detailed measurements and the code pointers, they make this easy to follow.

    What you're asking for is a bounded message window for the active session in the TUI: keep the most recent N messages in memory and refetch older pages as you scroll, so client memory no longer grows with transcript length once you've scrolled back or jumped to the first message. Right now the current session is always kept whole on purpose: loadMore prepends pages and retention only evicts session families that aren't retained. So we're treating this as a feature request (a performance improvement) rather than a bug. Maintainers will consider it.

    Related issues and PRs:

    • fix(app,client): keep hidden transcripts to their tail under a size budget #58491: open PR that trims hidden retained transcripts to their tail under a size budget and refetches older pages on scroll. It still keeps the visible session whole, which is the part your request covers.
    • tui: new background steps refill transcripts of already-evicted session families #56737: background events refilling evicted session families (closed).
    • [FEATURE]: Paginated message loading for long sessions #6548: earlier request for paginated loading with a bounded message window (closed).
    • server: RSS ratchets up with accumulated session/DB history and full-resolution image attachments #56058: server-side RSS growth with accumulated session history.
  2. 521ox commented on Nov 3, 2026

    @521ox
    521ox
    on Nov 3, 2026
    Author
    More actions

    I disagree with the classification, and "kept whole on purpose" is the part I'm asking to change.

    Session completeness and runtime residency are independent properties. The full transcript stays in SQLite, session.export reads it from there, compaction keeps its own window, and the client already has a cursor for older pages. None of that needs every loaded page to remain in the JS heap. Once a page is off-screen it contributes only memory. The TUI already bounds rendering to a TRANSCRIPT_BACKFILL_CHUNK window; the store is the only unbounded part.

    The measured case is the visible session: 39,412 messages / 1,092 MB, 2.88 GB working set and 3.92 GB private after 4.8 days, while the model window after compaction is 165 messages / 2.1 MB. Only 2,493 messages / 50.8 MB were new in that period. Restarting returns to baseline and scrolling back reproduces it. That is unbounded cost with no functional benefit.

    Keeping a hidden family whole shortens a tab switch. Keeping the active session whole has no equivalent payoff: it is already open, and the pages beyond the viewport are pure cache.

    The referenced PR does not cover this case. #58491 says "The visible session, its ancestors ... and any running session stay whole" and "The family of the current session doesn't count toward the budget." The long-lived session is the visible one, so it remains whole under that change.

    Hot/cold separation is already the architecture on the server: compaction bounds what the model sees. The client should use the same boundary — a bounded loaded window plus the existing cursor, refetching on scroll or jump. That preserves completeness without materializing the whole log in RAM.

    Please don't downgrade this to a feature request. Memory scales with total history, is never released, and restart is the only recovery. A window cap (the last 2,000 messages are 36 MB in this session) is a resource bug fix, not a new capability. I can test a branch against this session.

  3. ericvhileman commented on Nov 18, 2026

    @ericvhileman
    ericvhileman
    on Nov 18, 2026
    More actions

    Another data point, from a host running many TUIs at once. In our case the growth comes from live events on the active session alone, with no scrolling back or jumping to the first message.

    Setup: OpenCode v2.2.0 on macOS (Apple silicon). About 70 TUIs, each attached with --session to one shared opencode serve --service, on long-running agent sessions. We read the v2.2.1 to v2.3.2 release notes and found no change to transcript retention, so we expect the same on current releases.

    What the TUIs hold:

    • 72 TUIs: 29.07 GiB physical footprint in total, median 410 MiB.
    • Footprint tracks TUI age (Pearson r 0.65) and message count (0.54) more than stored transcript bytes (0.38).
    TUI age footprint JS heap dirty (swapped)
    1.4 h 191 MB 157 MB (81 MB)
    27 h 351 MB 291 MB (67 MB)
    174 h 709 MB 629 MB (448 MB)

    The heap figures are from footprint --forkCorpse, App-Specific Tag 1 (the JavaScriptCore heap). Almost all of the growth is there.

    Growth follows the session's own activity:

    • Among 62 TUIs alive for the same 12 hours, those whose session wrote no messages grew a median of 28 MiB.
    • Those whose session wrote 200 or more messages grew a median of 85 MiB, for about 4-5 MiB of stored messages each: roughly 20 bytes of heap per byte of stored transcript.
    • The heap is not given back while the TUI runs.

    A fresh TUI on the same session starts at 190-215 MiB. Relaunching 19 idle TUIs onto their same sessions took the TUIs' total footprint from 27.78 GiB to 20.03 GiB (-7.75 GiB), with nothing lost on the server side.

    Since live appends alone produce this, a bounded window for the active session would need to cover messages arriving over the event stream as well as pages loaded by loadMore(). Related: #63360, the same effect for retained subagent transcripts.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.