Conversation
## Summary Introduces a new `ValueOpType.Stream` operation that optimizes network diffs when strings are only appended to (`nextString.startsWith(prevString)`). This reduces bandwidth usage when streaming LLM generation into shapes by sending only the appended text instead of the full string value. ## Changes - Added `ValueOpType.Stream` constant and `StreamOp` type - Modified `diffObject()` and `diffValue()` to detect string streaming scenarios - Added `Stream` case to `applyObjectDiff()` for applying stream operations - Bumped `TLSYNC_PROTOCOL_VERSION` from 7 to 8 for backward compatibility - Added 15 comprehensive tests for string streaming behavior ## Test plan - [x] All 313 tests passing in sync-core package - [x] String append detection working for top-level and nested properties - [x] Stream operations correctly applied and validated (offset checks) - [x] Protocol version bump ensures no silent failures with old clients ## Example use case This optimization is particularly beneficial for AI-powered features where LLM responses are streamed token-by-token into text shapes. Instead of sending the entire text content on each update, only the newly generated tokens are transmitted. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ### Change type - [x] improvement ### Release notes Add stream operation for string append optimization in sync-core. ### API changes internal only <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds string append support in diffs/patches with protocol v8 and session capability gating, plus RoomSession refactor and related API/test updates. > > - **Diff/Apply mechanics**: > - Support string appends in `AppendOp` (`value: string | unknown[]`) and handle in `applyObjectDiff`. > - Extend `diffRecord`/internals to detect string appends; add `legacyAppendMode` to fall back to `put`. > - **Protocol & compatibility**: > - Bump `TLSYNC_PROTOCOL_VERSION` to `8`. > - Handshake sets `supportsStringAppend` false for v7 clients; introduce `getCanEmitStringAppend()` to decide legacy mode. > - **Room/session**: > - Refactor `RoomSession` into union over `RoomSessionBase`; add `supportsStringAppend` field. > - `TLSyncRoom` threads `legacyAppendMode` into `replaceState`/`mergeDiff`; stores and propagates `supportsStringAppend` across lifecycle. > - **API surface**: > - Export `RoomSessionBase`; update types for `AppendOp`, `diffRecord`, `DocumentState.mergeDiff/replaceState`, and `RoomSession`. > - **Tests**: > - Add/adjust tests for string append behavior, session lifecycle, and protocol v8; update expectations to use `append` for strings. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 4b6d514. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: David Sheldrick <d.j.sheldrick@gmail.com> Co-authored-by: Mime Čuvalo <mimecuvalo@gmail.com>
…rovider` (#7053) if you wanted to use TldrawEditor by itself, you weren't able to use some tldraw shapes b/c they relied on `TldrawUiContextProvider` being present which could bloat your bundle size unnecessarily if you didn't need all that extra stuff H/T to @derekcicerone for flagging this one — thanks! ### Change type - [x] `bugfix` - [ ] `improvement` - [ ] `feature` - [ ] `api` - [ ] `other` ### Test plan - [x] Unit tests - [ ] End to end tests ### Release notes - editor: be able to use TldrawEditor without needing `TldrawUiContextProvider` <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Make note shape RTL logic resilient to missing UI translation context so TldrawEditor works standalone, add CSS.supports polyfill, and expand shape rendering tests. > > - **Editor / Shapes**: > - Update `NoteShapeUtil` to use optional `TranslationsContext` (fallback to LTR) for RTL/tab navigation, avoiding hard dependency on `TldrawUiContextProvider`. > - **UI / Translations**: > - Export `TranslationsContext` from `ui/hooks/useTranslation/useTranslation` (marked internal). > - **Tests**: > - Revamp `TldrawEditor.test.tsx` to render and validate all core shapes (no error boundaries), use `defaultShapeUtils`, and test selection/tool switching with rich text helpers. > - **Tooling / Polyfills**: > - Add `CSS.supports` polyfill in `internal/config/vitest/setup.ts` for color space-related tests. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit da964bd. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )