From 7ffdb17c040ec5dbb7386c2a2f6562e5a5a6a370 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 11:54:28 +0000 Subject: [PATCH] #2270: an accepted photo's bytes are moved into the message, not cloned Review follow-up (CodeRabbit): the clone doubled the memory a large photo takes for a moment. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AbegtYaPuwqZ81pGfELsFK --- apps/lightcraft-web/src/host.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/lightcraft-web/src/host.rs b/apps/lightcraft-web/src/host.rs index 17e95e9c10..fb10db2c8c 100644 --- a/apps/lightcraft-web/src/host.rs +++ b/apps/lightcraft-web/src/host.rs @@ -219,14 +219,19 @@ mod bridge { return; } let data = event.data(); - let bytes = bytes(&data); + // moved, not cloned: an accepted photo can be hundreds of MB + let (bytes, oversize) = match bytes(&data) { + Some(Ok(b)) => (Some(b), None), + Some(Err(len)) => (None, Some(len)), + None => (None, None), + }; let raw = Raw { kind: string(&data, "type"), name: string(&data, "name"), - bytes: bytes.as_ref().and_then(|b| b.as_ref().ok().cloned()), + bytes, id: string(&data, "id"), params: string(&data, "params"), - oversize: bytes.and_then(Result::err), + oversize, }; if let Some(m) = Incoming::parse(raw) { incoming.borrow_mut().push(m);