Skip to content

feat: added experimental React-style function components - #48

Open
theobiabo wants to merge 13 commits into
1bye:mainfrom
theobiabo:feat/react-styled-function-component
Open

theobiabo wants to merge 13 commits into
1bye:mainfrom
theobiabo:feat/react-styled-function-component

Conversation

@theobiabo

Copy link
Copy Markdown

Summary

Added an opt-in function component API for #27, allowing components to use persistent state and lifecycle hooks while keeping Rake’s existing view! syntax.

The implementation is behind experimental-components. It remains experimental because render isolation and performance acceptance are unresolved.

Implementation

Component API

  • Added #[rake::component] to generate props and a retained GPUI view.
  • Preserved <Counter ... /> and {..defaults} syntax.
  • Supported renamed Rake dependencies.
  • Required cloneable props, with PartialEq required only for #[rake::component(memo)].

State and lifecycle

  • Added Scope, use_state, use_ref, use_memo, and use_effect.
  • Stored hooks on the component’s retained entity, preserving state across renders and keyed reordering.
  • Used component type, parent identity, and an explicit stable ID to distinguish instances.
  • Added Copy handles backed by a generation-aware registry with weak component ownership.
  • Returned disposal errors when handles outlive their components.
  • Added hook-order, kind, and type checks.
  • Deferred effects until after paint, with cleanup before replacement and on unmount.

Integrations

  • Added context and theme observation through existing GPUI globals.
  • Added resource hooks backed by Rake’s managed loading system.
  • Added bounded hook metadata to the inspector and CDP.
  • Shared handle and resource-access logic to reduce duplication.
  • Added examples, documentation, and comparison benchmarks.

@1bye

1bye commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Hey @theobiabo, first, an apology. You asked to take this issue, I said yes, and then after you'd put in all this work I changed the design under you. That's on me, not you. I should have told you on the issue as soon as I started rethinking hooks.

The work itself is really good. The report is unusually honest about where it falls short: the performance gate, the render isolation limits, what wasn't measured. That's exactly what I wanted from #27.

What changed: while reviewing the design I realised hooks fight GPUI's model, so #27 now uses signals instead. They're Copy handles over GPUI entities, setup runs once and the tail expression renders, and there are no rules of hooks. That means the hooks API can't merge as it is, but a lot of your work carries over directly:

  • the benchmark harness (plain, component and raw keyed) and the allocation counter
  • the identity and reorder findings, including the RenderOnce sibling collision
  • effect timing and cleanup, and data loading tied to loaders
  • the inspector/CDP metadata and its limits
  • the compile-fail and renamed-dependency tests

Your finding that equal props can't skip rendering without .cached() and fixed sizes is also what shaped the caching plan in the new issue.

If you're still up for it, I'd love for you to keep going on the signals version. If you'd rather not after this, that's completely understandable, and thank you either way. Happy to answer any design questions on the issue.

@theobiabo

Copy link
Copy Markdown
Author

Sure I'm still up.

@1bye

1bye commented Nov 12, 2026

Copy link
Copy Markdown
Owner

hey @theobiabo any updates?

@theobiabo

Copy link
Copy Markdown
Author

Yooo, @1bye will raise a PR, I migrated the configs to a more better PC, should do that before EOD.

@1bye

1bye commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@theobiabo that's cool, ty!

@theobiabo

Copy link
Copy Markdown
Author

Sure bro.

@theobiabo

Copy link
Copy Markdown
Author

Yo @1bye, please, you can confirm the PR now; all stated changes have been updated.

@theobiabo

Copy link
Copy Markdown
Author

@1bye this PR added experimental signal-based function components for #27 , including typed props, reactive state, effects, resources, context, and async cleanup.

@1bye

1bye commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@theobiabo awesome! Let CI run and I will review it, and merge

@theobiabo

Copy link
Copy Markdown
Author

Sure one chief.

@1bye

1bye commented Nov 13, 2026

Copy link
Copy Markdown
Owner

@theobiabo I reviewed the implementation against #27 and reran the feature suites: 262 tests passed. The core signals implementation is in place, but a few things need resolving before merging:

  1. Automatic caching changes layout. A root with absolute left-4 top-4 w-40 h-10 loses positioning in the generated cache style and pushes siblings into the wrong position. Please preserve the layout semantics or skip automatic caching for unsupported roots, with a regression test.
  2. Blaze behavior needs verification. Please demonstrate that a render-only patch preserves state and a setup patch remounts. Generating the setup hash alone doesn’t establish this.
  3. Some requested API behavior remains partial. Direct signal content in paragraphs, reactive attributes beyond disabled, rest forwarding, and flex-stretch cache inference have documented limits. Please identify which you’ll complete here and propose explicit follow-ups for the others so we can agree on scope.
  4. Performance acceptance remains open. Your report explains the overhead, but leaves the acceptance gate and alternative-storage comparison unresolved. Please propose the next step or the specific exception you want reviewed.

The unrelated CI installation issue and unused-parameter failures are being handled separately.

@theobiabo

Copy link
Copy Markdown
Author

Sure I'm gonna fix that.

@theobiabo

Copy link
Copy Markdown
Author

@1bye The issue has been fixed.

@theobiabo

Copy link
Copy Markdown
Author

Hey @1bye Let me know if there are any issues, would be on the standby.

@1bye

1bye commented Nov 13, 2026

Copy link
Copy Markdown
Owner

@theobiabo yep, here it is

@1bye

1bye commented Nov 13, 2026

Copy link
Copy Markdown
Owner

@theobiabo Before merging, please complete the remaining #27 requirements within Rake, using the existing pinned GPUI unchanged:

  • Direct signal/memo text in paragraphs, headings, and inline runs.
  • Consistent reactive attribute support beyond disabled.
  • Complete forwarding of supported undeclared aria-* and on:* attributes.
  • Safe automatic cache inference for flex-stretched components.
  • Performance improvements that satisfy the approximately 10% update/re-render overhead target.

We reran the full benchmark suite three times. All correctness and disposal assertions passed, but the measured performance overhead remains above the target.

Please profile and optimize the Rake-side implementation, then rerun the benchmark matrix and commit the results. Keep correctness, state identity, borrowed reads, and cleanup guarantees covered.

If the performance target proves unreachable under the unchanged-GPUI constraint, bring back measurements explaining the limitation before proposing a scope change.

@1bye

1bye commented Nov 13, 2026

Copy link
Copy Markdown
Owner

@theobiabo I have fixed CI problems and tiny other things

@theobiabo

theobiabo commented Nov 13, 2026 •

Copy link
Copy Markdown
Author

Okay, that sounds great, will make this updates.

I'm open to picking on other issues too.

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.

2 participants