Title: fix(copilot): stream append previews as deltas instead of a snapshot per token by waleedlatif1 · Pull Request #7559 · simstudioai/sim · GitHub
Open Graph Title: fix(copilot): stream append previews as deltas instead of a snapshot per token by waleedlatif1 · Pull Request #7559 · simstudioai/sim
X Title: fix(copilot): stream append previews as deltas instead of a snapshot per token by waleedlatif1 · Pull Request #7559 · simstudioai/sim
Description: Summary An append file preview is existingContent + streamed, and buildPreviewContentUpdate forced a full snapshot on every emission — so the entire file was re-sent once per streamed token. Total bytes into the copilot stream buffer are O(file × tokens). The buffer's only trim is a 100,000-member rank cap. A count cap cannot bound a member whose size is the file, so it never fired: the keys held ~400 members and hundreds of MB. Removing the forced snapshot lets append delta like update already does. Rendered text is unchanged. Why this is safe deriveFilePreviewSession is the only thing in the repo that reads contentMode, and it has accumulated deltas since #4923. update has shipped deltas through it ever since. The forced snapshot was correct when written (#4090) — the consumer could not merge deltas then. It gained that two months later and the producer was never relaxed. The test pinning it said sidebar viewer uses replace mode; that viewer no longer exists. Both conditions that genuinely require a snapshot still force one: a base diverging mid-stream fails startsWith, and the checkpoint interval still emits a recoverable full snapshot, so no delta chain exceeds one second. Testing file-preview-append-roundtrip.test.ts drives the real producer into the real consumer and asserts byte-identical reconstruction — at token-scale chunking over a 250 KB base, across a diverging base, and under duplicate delivery. Both halves verified to fail when the behaviour they pin is reverted. 2,082 tests pass across lib/copilot and the preview/stream hooks. bun run lint:check, bun run check:audits 45/45, and type-check all pass. Measured against the session that prompted this — 42 appends taking a file 148 KB → 262 KB — buffer cost drops from 2.29 GiB to 55 MB. Follow-ups (not in this PR) Route this writer through lib/execution/redis-budget.server.ts, which already enforces per-write / per-session / per-owner byte budgets. Only event-buffer.ts and user-file-base64.server.ts use it today. Same bug class remains in table:stream:*:events (no byte budget) and filedoc:stream:* (XADD with no MAXLEN). Adds .claude/rules/sim-redis-payloads.md documenting the rule this violated: cap bytes, never count. Type of Change Bug fix Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
Open Graph Description: Summary An append file preview is existingContent + streamed, and buildPreviewContentUpdate forced a full snapshot on every emission — so the entire file was re-sent once per streamed token. Total...
X Description: Summary An append file preview is existingContent + streamed, and buildPreviewContentUpdate forced a full snapshot on every emission — so the entire file was re-sent once per streamed token. Total...
Opengraph URL: https://github.com/simstudioai/sim/pull/7559
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:844a28d7-ea71-a858-e685-99191f6f904b |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C69C:F138D:AC3CF7:EBF644:6AFB50D2 |
| html-safe-nonce | 964347f7491031988cec2913eb170a642a726e2ac313228c9ab6c7a37a938302 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjlDOkYxMzhEOkFDM0NGNzpFQkY2NDQ6NkFGQjUwRDIiLCJ2aXNpdG9yX2lkIjoiNTU2MzEzODgyMDk1MTE5OTk1NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8cc3c3a2655ba5a23ea90705e11ed44f1c71af5d55f1e9f07beb51b73b1180cc |
| hovercard-subject-tag | pull_request:4455665212 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/7559/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary An append file preview is existingContent + streamed, and buildPreviewContentUpdate forced a full snapshot on every emission — so the entire file was re-sent once per streamed token. Total... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cbf66c024bb6d10e6955baa7413c54cf13a201bb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width