Demo, all content is generated
Question

Asked Lovable to change a button color and it removed my whole checkout fix from yesterday

Solved · 461 views · asked by precious_n · edited

Yesterday I spent maybe 15 messages getting the checkout page to finally calculate shipping right (per country). Today I asked "make the pay button green" and the button is green but shipping is back to a flat 5 euro. The code for the country rates is just gone.

How do I get yesterday's version back without also losing the 6 other things I did today? And how do I stop this from happening, I feel like I can't trust it anymore.

What I’ve tried

Told Lovable "you removed the country shipping, put it back". It wrote a new version that is different from yesterday and now Belgium costs 0.

Comment
Which file was the shipping logic in, and roughly how long is it? sergio_ruiz · edited
Is your project connected to GitHub? If yes, this is a 2 minute fix. pixelpaulo · edited
Yes I connected it the first week because someone said to precious_n · edited

3 answers

Marked as helpful by the asker
sergio_ruiz · edited

Don't let it rewrite from memory, it doesn't have memory of yesterday's code, only what's in the files now.

  1. Since you're on GitHub: open the repo, go to the history of the checkout file (e.g. src/pages/Checkout.tsx → History). Find the commit from yesterday evening where shipping worked. Copy the shipping function from there.
  2. Paste it back yourself in Lovable's code editor (Dev Mode), or give it to Lovable as "replace calculateShipping with exactly this code, change nothing else".

Don't use the full-project revert in the history panel for this: that would also undo today's 6 changes.

To prevent it: move the rates out of the page. Ask for a separate file src/lib/shipping.ts with the rates as a plain object. Small, isolated files get touched much less when you ask for unrelated UI changes. And for UI tweaks, start the prompt with "Only edit the button styles in Checkout.tsx".

Comment
Found it in GitHub history, pasted it back. Belgium costs money again. Thank you!! precious_n · edited
The 'separate file' tip is underrated, I do this for anything with numbers in it now. frankie_r · edited
pixelpaulo · edited

Also: the history panel lets you preview an older version without restoring it. Handy to check what the working shipping looked like before you go digging in GitHub.

Comment
mariam_k · edited

What helped me: switch to chat mode first and ask "which files would you change for this?". If it lists your checkout file for a button color, you know to be more specific before it touches anything.

Comment