Skip to content

Conversation

@mscolnick
Copy link
Contributor

@mscolnick mscolnick commented Dec 9, 2025

This keeps the state/buffer/bufferPaths in sync when sending to/from the backend for the widget. This changes some typings and adds a few more tests. This is an improvement, but not the final state as we can hopefully simplify further. This does fix a few errors when sending back binary data.

Prior work done by @manzt in 9426b13

@vercel
Copy link

vercel bot commented Dec 9, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
marimo-docs Ready Ready Preview Comment Dec 9, 2025 5:36pm

@mscolnick mscolnick changed the title push uzpwrntmkvtz Unify handling of widget state/buffers/bufferPaths Dec 9, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request unifies the handling of widget state, buffers, and buffer paths in the anywidget integration, introducing a standardized "wire format" ({state, bufferPaths, buffers}) for transmitting data between Python backend and TypeScript frontend. The changes improve type safety, fix binary data transmission errors, and add comprehensive test coverage for the new encode/decode functions.

Key Changes

  • Introduced wire format with explicit encode_to_wire() and decode_from_wire() functions in both Python and TypeScript to standardize binary buffer handling
  • Updated anywidget class to use wire format internally while exposing decoded state to users via the value property
  • Added extensive test coverage for wire format encoding/decoding, including round-trip tests and edge cases

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
marimo/_plugins/ui/_impl/from_anywidget.py Added wire format types and encode/decode functions; updated anywidget class to use wire format internally
marimo/_plugins/ui/_impl/anywidget/init.py Registered message handler for proper buffer handling
marimo/_runtime/runtime.py Added logging for function call exceptions
tests/_plugins/ui/_impl/test_anywidget.py Updated tests for wire format and added comprehensive TestWireFormat test class
marimo/_smoke_tests/anywidget_examples/scatter.py Added new smoke test for jupyter-scatter widget
frontend/src/utils/data-views.ts Implemented wire format serialization/deserialization with DataView handling
frontend/src/utils/__tests__/data-views.test.ts Added comprehensive tests for wire format functions including immutability tests
frontend/src/utils/json/base64.ts Added binaryToByteString utility function
frontend/src/plugins/impl/anywidget/model.ts Updated Model class to handle wire format; changed dirty fields tracking to use Map
frontend/src/plugins/impl/anywidget/__tests__/model.test.ts Updated tests to match new wire format and dirty fields behavior
frontend/src/plugins/impl/anywidget/AnyWidgetPlugin.tsx Updated plugin to decode wire format and serialize changes back to wire format
frontend/src/plugins/impl/anywidget/__tests__/AnyWidgetPlugin.test.tsx Updated tests to match new wire format
Comments suppressed due to low confidence (1)

marimo/_runtime/runtime.py:1995

  • This assignment to 'error_title' is unnecessary as it is redefined before this value is used.
    This assignment to 'error_title' is unnecessary as it is redefined before this value is used.
    This assignment to 'error_title' is unnecessary as it is redefined before this value is used.
    This assignment to 'error_title' is unnecessary as it is redefined before this value is used.
        error_title, error_message = "", ""

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mscolnick mscolnick merged commit e974123 into main Dec 9, 2025
17 of 32 checks passed
@mscolnick mscolnick deleted the push-uzpwrntmkvtz branch December 9, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants