Skip to content

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

Merged
1bye merged 19 commits into
1bye:mainfrom
theobiabo:feat/react-styled-function-component
Nov 22, 2026
Merged

1bye merged 19 commits into
1bye:mainfrom
theobiabo:feat/react-styled-function-component

Conversation

@theobiabo

@theobiabo theobiabo commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds opt-in signal-based function components for #27 behind experimental-reactive. Components use #[rake::component] and compose with the existing view! syntax. A component that takes &mut Setup runs setup once per mount and retains its state by stable ID. The final expression renders with current props.

  • Adds typed Signal<T> and Memo<T> handles, dependency tracking, effects, cleanup, and component-owned tasks.
  • Supports tracked props, context, rerunnable children, resources, and signal inspection.
  • Includes a runnable example, documentation, and benchmarks against plain GPUI. Experimental API guide

Verification

The Rake and Function components workflows passed on 572772ec. The macOS and Linux component jobs covered runtime behavior and consumer builds. Rake CI · Function components CI

Experimental performance acceptance

The maintainer accepts the measured overhead for this opt-in merge. The approximately 10% target in #27 remains open.

  • In three interleaved headless runs on an Apple M1 Max, updating 10,000 uncached rows took 47.48 ms median process CPU time with plain GPUI and 63.40 ms with stock Rake. The median paired slowdown was 34.5%. Each run checked every updated row, one draw per update, and cleanup after unmount.
  • The earlier matched cached bulk benchmark measured 371.2 ms for plain GPUI and 561.9 ms for Rake. GPUI rebuilds every invalidated cache in this workload. cached = false helps components whose rows change together, while caching helps isolated updates.
  • A scratch control that fixed each row's dependencies at mount shaved little off the uncached bulk time. Removing the observer as well still missed the target and was tested only without cached ancestors.

Both sets of measurements used the existing gpui-pre 0.3.11 pin. Benchmark report

@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
Contributor 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
Contributor 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
Contributor Author

Sure bro.

@theobiabo

Copy link
Copy Markdown
Contributor Author

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

@theobiabo

Copy link
Copy Markdown
Contributor 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
Contributor 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
Contributor Author

Sure I'm gonna fix that.

@theobiabo

Copy link
Copy Markdown
Contributor Author

@1bye The issue has been fixed.

@theobiabo

Copy link
Copy Markdown
Contributor 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
Contributor Author

Okay, that sounds great, will make this updates.

I'm open to picking on other issues too.

@1bye

1bye commented Nov 16, 2026

Copy link
Copy Markdown
Owner

@theobiabo any updates? Just want to close this PR and forget about it, xd

@theobiabo

Copy link
Copy Markdown
Contributor Author

Oh, I thought you were fixing some tiny issues.

Okay will complete it.

1bye added 5 commits November 18, 2026 19:18
Resolve reactive markup and rest forwarding. Preserve caching for provably constrained flex roots and reuse render dependency storage.

Refs 1bye#27
Keep cache style storage on the mounted GPUI view and attach signal metadata using the shell element type.
TestAppContext already draws when an update flushes. Measure that
frame and check every row changed by a bulk update.
@theobiabo

Copy link
Copy Markdown
Contributor Author

Hello @1bye, looking into the issues? Or i should take it up too, amazing one buddy.

@1bye
1bye merged commit 98390c2 into 1bye:main Nov 22, 2026
13 checks passed
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