Why Does the "Edit with AI" Feature Replace the Entire Code Block Instead of Modifying a Single Function?

This topic was automatically generated from Slack. You can find the original thread here.

Noticing a bug with the new “Edit with AI” where the “Edit Code” directive doesn’t really work, it replaces the entire code block. Here I am asking it to just adjust one function within my action step and it instead scraps the remainder of the code. This happens with all workflows I’ve tried…it rewrites the entire code block rather than editing it.

I’m making some changes to AI code gen that should address this

thank you

Posted thread to Discourse: Why Does the "Edit with AI" Feature Replace the Entire Code Block Instead of Just Editing It?

any idea when this will be fixed? I use Generate Code very often and this renders it useless since it deletes all existing code.

Should be shipping today, I’m just getting the code reviewed.

Pi (in the left pane) will generate all code now. I also made other improvements to the code we generate. Hoping it will address bugs with the old code gen popup and be a net better product

this should be out, let me know how it works for you. Pi will always try to suggest pre-built components if they’re available (e.g. if you ask “add a row to Google Sheets” it will suggest the standard action), but you can always say “write code to ” and it should write code for you

I tried it and it doesn’t seem to ahve the context of the action step I curently have. I asked it to edit my current action and it just wrote a totally new action step that had nothing to do with my current one

yes, this is a regression with the edit flow and I apologize. As a workaround for now, just copy and paste your code into the Pi query, but I’ll adjust the Edit with AI button to pass the context automatically and let you know when that’s done

If you paste a long code block into Pi the input box expands to fit it but doesn’t let you scroll through the pasted text. So if you’re like:

Question about my code. Here is my code:
[long code that pushes the question off the screen]

there’s no way to scroll back up in the input box and edit your questoin

I pushed some changes to code gen, and Pi (in the product, not in Slack) now has access to the configuration and code in your workflow, so if you try to simply say “edit to do “, or even ask it about props / config, it should work. Let me know how that feels — appreciate you iterating with us

Is Ask Pi not working? It’s just hanging for me, the button says “stop generating” but nothing generates even after 15-20m so far

it’s working for me, are you able to share your exact prompt?

Anthropic can have timeouts / other issues — it’s possible you hit that too

CleanShot 2025-01-23 at 15.19.33.jpg

I tested the debug error flow on one of my own workflows and that worked. Can you stop generating, create a new chat from Pi, then try to click the Debug with AI button once more?

same issue

CleanShot 2025-01-23 at 15.26.41.jpg

oh wait let me try to create a new chat

same issue

It’s likely a bug in some of the context being passed re: the step and the error behind the scenes. I’ll see if I can trace the request in our logs. Just to set expectations, I’m on another major project now so I may not be able to look into it this week