Skip to content

refactor(live_component): keep _AutoRefresh.__name__ honest via __coco_subpath_name__#2003

Merged
georgeh0 merged 1 commit into
mainfrom
g/auto-refresh-honest-subpath
May 22, 2026
Merged

refactor(live_component): keep _AutoRefresh.__name__ honest via __coco_subpath_name__#2003
georgeh0 merged 1 commit into
mainfrom
g/auto-refresh-honest-subpath

Conversation

@georgeh0
Copy link
Copy Markdown
Member

Summary

  • coco.auto_refresh no longer rewrites _AutoRefresh.__name__ to the wrapped fn's name. That trick gave the right component subpath but lied about class identity — tracebacks and the processor_name in _resolve_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. mount / use_mount / mount_each now consult it (via a new _default_subpath_name() helper) before falling back to __name__. auto_refresh sets it to the wrapped fn's name and leaves __name__ alone.
  • User-visible subpath is unchanged: coco.mount(coco.auto_refresh(sync_users, ...)) still mounts under sync_users, matching the "observationally identical to mounting process_fn directly" guarantee. The same mechanism is now available to other wrappers or user-defined LiveComponent classes.

Test plan

  • CI (pytest python/tests/core/test_auto_refresh.py + broader core suite + mypy).

…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.
@georgeh0 georgeh0 merged commit 7f6f3b4 into main May 22, 2026
18 checks passed
@georgeh0 georgeh0 deleted the g/auto-refresh-honest-subpath branch May 22, 2026 05:37
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.

1 participant