refactor(live_component): keep _AutoRefresh.__name__ honest via __coco_subpath_name__#2003
Merged
Merged
Conversation
…o_subpath_name__ The previous implementation overrode `_AutoRefresh.__name__` to the wrapped fn's name so `coco.mount(auto_refresh(fn, ...))` would derive the same subpath as `coco.mount(fn)`. That conflated subpath identity with class identity — tracebacks and `processor_name` in the exception handler reported the wrapper as if it were the wrapped fn, hiding the live-loop layer when something went wrong inside the scaffold. Introduce an opt-in `__coco_subpath_name__` attribute that `mount`/`use_mount`/`mount_each` consult before falling back to `__name__`. `auto_refresh` now keeps `_AutoRefresh.__name__` accurate and only overrides the subpath via the new attribute. Same user-visible subpath; honest class identity for debugging and for any future wrapper (or user-defined LiveComponent) that wants the same behavior.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
coco.auto_refreshno longer rewrites_AutoRefresh.__name__to the wrapped fn's name. That trick gave the right component subpath but lied about class identity — tracebacks and theprocessor_namein_resolve_exception_handlerreported the wrapper as if it were the wrapped fn, hiding the live-loop layer when something went wrong inside the scaffold.__coco_subpath_name__attribute.mount/use_mount/mount_eachnow consult it (via a new_default_subpath_name()helper) before falling back to__name__.auto_refreshsets it to the wrapped fn's name and leaves__name__alone.coco.mount(coco.auto_refresh(sync_users, ...))still mounts undersync_users, matching the "observationally identical to mountingprocess_fndirectly" guarantee. The same mechanism is now available to other wrappers or user-definedLiveComponentclasses.Test plan
pytest python/tests/core/test_auto_refresh.py+ broader core suite +mypy).