impeccable icon indicating copy to clipboard operation
impeccable copied to clipboard

[Feature] Inject variants in Live mode as framework specific components

Open JohannesKlauss opened this issue 6 months ago • 7 comments

What problem does this solve?

I have a stateful gamefied page that I'd like to improve with the impeccable live mode. I use SvelteKit and when impeccable generates variants of a selected UI element it writes it to the app.html which causes a full page reload, which in turn looses all the state of the page.

Proposed solution

Maybe it's fine to tell the LLM to write components in the framework that is being used and then inject it into the rendered tree, which should yield the same effect but keep the state stable during HMR.

JohannesKlauss avatar May 12 '26 18:05 JohannesKlauss

Having the same problem with Live mode. Also using in a Svelte / SvelteKit project with HMR.

denisdasilvarocha avatar May 16 '26 07:05 denisdasilvarocha

Let me take a look at this bug.

abdulwahabone avatar May 16 '26 20:05 abdulwahabone

I tried creating a new Svelte / SvelteKit project with npx sv@latest create test-svelte-live

Then I tried editing a stateful component on via the live editing.

It only edited the components and not the app.html.

But it did refresh the whole page and the state was lost.

Tested with Claude Haiku.

Can you guys double check on the latest and verify that the bug is only regarding the loss of state.

abdulwahabone avatar May 16 '26 20:05 abdulwahabone

Hi @abdulwahabone,

Tested with latest Impeccable, i can still reproduce it.

  1. Start Server with pnpm run dev - http://localhost:5173/
  2. $impeccable live its hooking the app.html with <script src="http://localhost:8401/live.js"></script>
  3. Pick a Element, Polish, 4 Variants

Here a small video:

https://github.com/user-attachments/assets/cf248e50-7348-4a11-91d7-572fa950b852

denisdasilvarocha avatar May 26 '26 09:05 denisdasilvarocha

Another data point for the framework-component approach: in a Vite + React 19 app I picked a header cluster (<div className="flex items-center gap-2">) and asked to improve two of its children. The catch is those children come from two different source files — one was an inline <button> in the parent component, the other a separate child component (<CreditCoin />) whose styling lives entirely in its own file.

So beyond writing variants as framework components, wrap/accept also needs to resolve the correct source file per sub-element: replacing the picked DOM node in one place can't cleanly persist a change that actually belongs to a child component's own file. In practice the deterministic wrap landed ambiguously (the parent has multiple identical flex items-center gap-2 divs, and the child's rendered text isn't a literal in source), so accept had nowhere clean to write the credit-pill change. Element → source-file mapping (and multi-file edits on accept) seems like part of the same problem.

(Filed #183 separately for an unrelated reload-loop issue hit in the same session.)

muhammadolim avatar Jun 01 '26 09:06 muhammadolim

Thanks for flagging this, @muhammadolim . The Svelte adapter is nearly ready, and I’ll be tackling the React Native adapter next. I’m tracking that work in #183

abdulwahabone avatar Jun 01 '26 20:06 abdulwahabone

The original Svelte/SvelteKit state-loss problem is resolved by Live v2 in #433. It introduced AST-backed Svelte component previews and includes a stateful SvelteKit fixture that proves state survives variant cycling, plus a mechanical accept path. The remaining framework-specific work is tracked more precisely in #454 for React/JSX recovery and #386 for Vue accept parity, so this older umbrella can close.\n\nAI-assisted maintainer triage: verified against the merged implementation and closed by Codex under @pbakaus's direction.

pbakaus avatar Sep 01 '26 03:09 pbakaus