Skip to content

[pull] main from tldraw:main#255

Merged
pull[bot] merged 2 commits intocode:mainfrom
tldraw:main
Nov 6, 2025
Merged

[pull] main from tldraw:main#255
pull[bot] merged 2 commits intocode:mainfrom
tldraw:main

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented Nov 6, 2025

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 : )

quasor and others added 2 commits November 6, 2025 12:46
## 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 -->
@pull pull Bot locked and limited conversation to collaborators Nov 6, 2025
@pull pull Bot added the ⤵️ pull label Nov 6, 2025
@pull pull Bot had a problem deploying to deploy-staging November 6, 2025 15:13 Failure
@pull pull Bot merged commit 7308566 into code:main Nov 6, 2025
@pull pull Bot had a problem deploying to deploy-production November 6, 2025 15:13 Failure
@pull pull Bot had a problem deploying to deploy-staging November 6, 2025 15:13 Failure
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants