Skip to content

feat(opencode): gzip compress json responses for up to 97% smaller payload#11378

Closed
brittlewis12 wants to merge 1 commit intoanomalyco:devfrom
brittlewis12:perf/gzip-session-messages
Closed

feat(opencode): gzip compress json responses for up to 97% smaller payload#11378
brittlewis12 wants to merge 1 commit intoanomalyco:devfrom
brittlewis12:perf/gzip-session-messages

Conversation

@brittlewis12
Copy link
Copy Markdown
Contributor

@brittlewis12 brittlewis12 commented Jan 30, 2026

What does this PR do?

fixes #10475

Large sessions can have 20MB+ JSON payloads which can take 20-30s to transfer over mobile networks. Gzip compression reduces this dramatically, improving mobile load times perceptibly. In one case a 400-message session went from 20-30s (23.9MB) to ~5s (580KB).

I attempted to use hono’s own compression middleware but that seemed to break the client, so I opted to implement a middleware with bun’s gzip compression directly.

How did you verify your code works?

ran the server locally (bun run dev web) and tested a session w 400 messages on my phone against v1.1.47:

before (v1.1.47)

custom client logging:

[sync] fetch complete: 19071ms, size=22.73MB
[sync] processing (filter/sort/clone messages): 29ms, count=400
[sync] batch/reconcile complete: 612ms
[sync] TOTAL: 19712ms

23.9MB for that one session:

IMG_7137

after (this PR)

custom client logging:


[sync] fetch complete: 5096ms, size=22.73MB
[sync] processing (filter/sort/clone messages): 35ms, count=400
[sync] batch/reconcile complete: 402ms
[sync] TOTAL: 5533ms

23.9MB -> 580KB for that one session

IMG_7138

@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title perf(server): gzip compress session messages response doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@brittlewis12 brittlewis12 changed the title perf(server): gzip compress session messages response feat(server): gzip compress session messages response Jan 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@brittlewis12
Copy link
Copy Markdown
Contributor Author

but it does have a linked issue? #10475

@brittlewis12 brittlewis12 changed the title feat(server): gzip compress session messages response feat(opencode): gzip compress session messages response Jan 30, 2026
@brittlewis12 brittlewis12 changed the title feat(opencode): gzip compress session messages response feat(opencode): gzip compress session messages response for 97% smaller payload Jan 30, 2026
opencode-agent Bot added a commit that referenced this pull request Jan 30, 2026
opencode-agent Bot added a commit that referenced this pull request Jan 30, 2026
@brittlewis12
Copy link
Copy Markdown
Contributor Author

brittlewis12 commented Jan 31, 2026

took a quick pass over other potentially desirable candidates for response gzip compression — i think the main ones that stood out were /file/contents and /:sessionId/diff

if you folks would like i’m happy to extend this to those as well, but i figured i’d stick with the pain i’ve actually felt!

edit: just implemented for all json responses

opencode-agent Bot added a commit that referenced this pull request Jan 31, 2026
opencode-agent Bot added a commit that referenced this pull request Jan 31, 2026
opencode-agent Bot added a commit that referenced this pull request Jan 31, 2026
opencode-agent Bot added a commit that referenced this pull request Jan 31, 2026
opencode-agent Bot added a commit that referenced this pull request Jan 31, 2026
opencode-agent Bot added a commit that referenced this pull request Jan 31, 2026
opencode-agent Bot added a commit that referenced this pull request Jan 31, 2026
opencode-agent Bot added a commit that referenced this pull request Jan 31, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
opencode-agent Bot added a commit that referenced this pull request Feb 1, 2026
Compresses JSON responses > 1KB when client sends Accept-Encoding: gzip.
Reduces /provider from 1.7MB to 102KB, /config from 13KB to 5KB, etc.
@brittlewis12 brittlewis12 force-pushed the perf/gzip-session-messages branch from 20e56a4 to a599cf2 Compare February 2, 2026 06:19
@brittlewis12 brittlewis12 changed the title feat(opencode): gzip compress session messages response for 97% smaller payload feat(opencode): gzip compress json responses for up to 97% smaller payload Feb 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Compression between server and desktop

1 participant