Skip to content

[FEATURE]: Store per-message diffs separately and lazy-load them #16741

Closed as not planned

Description

@ualtinok

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Describe the enhancement you want to request

OpenCode currently stores per-message file diffs inline on user messages via message.summary.diffs, where each diff item includes full before and after file contents.

This has a major downside for long-lived coding sessions: message rows can become extremely large, especially when a turn touches generated files, large source maps, workflow files, or other bulky assets. Since session open/switch flows still load message rows from the session database, this can noticeably slow down the desktop app when switching between sessions.

I’d like to request a change to make per-message diffs lazy-loaded instead of embedding the full diff payload in MessageTable.data.

Proposed direction

  • Keep lightweight per-message summary metadata inline on the message row (for example: title/body/files/additions/deletions)
  • Move the full per-message diff payload (before / after content) into separate storage, ideally a dedicated table keyed by message_id
  • Reuse or extend the existing diff API path so full per-message diffs are only fetched when the user actually opens turn-level review
  • Leave session-level review diffs as a separate/lazy path as well

Why this would help

  • Prevent very large message rows in SQLite
  • Improve session switching/opening performance in the desktop app
  • Reduce the cost of session prefetching
  • Keep the review UX intact while moving heavy payloads off the hot path

Why I think this is worth doing

From local investigation, the main database growth came from oversized message rows containing summary.diffs[].after content. The hot path cost came from deserializing large message JSON blobs during normal session loading.

Minimal implementation shape

A low-risk version of this could be:

  • add a message_diff table (or equivalent separate storage)
  • stop persisting full summary.diffs inline on user messages
  • keep only lightweight summary counts inline
  • make the existing diff fetch path support messageID-scoped lazy loading
  • update the turn review UI to fetch full per-message diffs only when needed

I’d be happy to help create a PR for this feature

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Mar 9, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    perfIndicates a performance issue or need for optimization
    on Mar 9, 2026
  3. ualtinok commented on Mar 12, 2026

    @ualtinok
    ContributorAuthor

    Tagging also: #14543

  4. assigned and unassigned on Apr 26, 2026
  5. removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    perfIndicates a performance issue or need for optimization
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  6. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

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