[morethanwords/tweb/master](https://github.com/morethanwords/tweb/tree/master) • [a5c7327](https://github.com/morethanwords/tweb/commit/a5c732796ed9012459ef60b638d633fbe0deca0a) • _1 files, +42/-19_
Fix video streaming edge cases in service worker

- Fall back to the worker on any cache read error (incl. a bare cache
  timeout that rejects with undefined) instead of throwing TypeError on
  error.type and killing the range request
- Preload the file's last chunk at start (moov/bounds) instead of chunk 0
- Treat PRELOAD_SIZE as a read-ahead window from the current position
  rather than an absolute end offset (read-ahead was dead past 20MB)
- Align the preload window start to the chunk grid so preloaded offsets
  stay valid MTProto offsets
- Gate the second range part on overflow > 0 (a byte count was used as a
  boolean, so a negative value forced a wasteful extra chunk fetch)
- Clamp limit to a server-valid minimum (4KB) to avoid LIMIT_INVALID on
  tiny ranges; make SMALLEST_CHUNK_LIMIT a valid 4KB and use it
- Don't resurrect a destroyed stream from toggleStreamInUse(false); clamp
  inUse at 0 to stop zombie streams leaking in the map
- Re-arm the idle debounce instead of destroying a stream still bound to
  a live <video>
- Swallow rejections from best-effort cache writes and fire-and-forget
  preloads to avoid unhandled rejections
- Use Math.clz32 in alignLimit to drop the Math.log FP rounding; remove
  the unused Response-Time header

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

[morethanwords/tweb/master](https://github.com/morethanwords/tweb/tree/master) • [99de4a8](https://github.com/morethanwords/tweb/commit/99de4a88b830447105f01631172e2425d9501e12) • _2 files, +30/-4_
Fix rich-text paste/serialization of newlines around blockquotes

Three related fixes in the contenteditable rich-text path:

- getRichValueWithCaret paste reconciliation: the re-insertion pass used a
  drifting offset threshold (`offset > plainTextLength - lineIndex + 1`) that
  was only correct for one line index, shifting/losing entities on multi-line
  formatted pastes (e.g. a second line in bold). Use the splice index directly
  and adjust entity length, not just offset, in both removal and insertion.

- Paste handler: strip messageEntityLinebreak before insertRichTextAsHTML.
  wrapDraftText renders line breaks from the text itself; passing explicit
  linebreak entities made wrapRichText slice the one before a blockquote,
  dropping a &#092;n on e.g. `text&#092;n&#092;nquote`. Stripping them aligns paste with the
  edit/draft path (verified: no extra blank line, model preserves both &#092;n).

- getRichElementValue: a multiline blockquote built from block children
  (<br>/<div>, what Enter produces) lost its last character outside the quote,
  because the entity length is only grown by text nodes while block-generated
  &#092;n bypass it. Track the last real-content offset and re-span the blockquote
  up to it, excluding trailing block line breaks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

[#webk](?q=%23webk)