Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send a new copy of the code to the server only when the code changes #1687

Merged
merged 3 commits into from
May 21, 2024

Conversation

JosiasAurel
Copy link
Contributor

previously the client chat feature will send 2 requests to the llm api. the first being a copy of the current code and then the chat message sent by the user.

with these changes, we hash the code and only send a new copy of the code to the server when the hash of the current code in the editor is different from the previous one.

…anges

previously the client chat feature will send 2 requests to the llm api. the first being a copy of the current code and then the chat message sent by the user.

with these changes, we hash the code and only send a new copy of the code to the server when the hash of the current code in the editor is different from the previous one.
Copy link

vercel bot commented May 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sprig ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2024 1:13pm

@vercel vercel bot temporarily deployed to Preview – sprig May 20, 2024 12:23 Inactive
@JosiasAurel JosiasAurel changed the title send a new copy of the code to the server only when the code chanes send a new copy of the code to the server only when the code changes May 20, 2024
const newCodeHash = await sha256Hash(codeMirror.value?.state.doc.toString()!);
if (newCodeHash !== codeHash) {
setCodeHash(newCodeHash);
await sendMessage(newSystemMessage.content);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we fail gracefully if this fails...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'll only set the code hash if the request is successful.
there error will also be bubbled-up and handle in the top-level try-catch

Copy link
Contributor

@grymmy grymmy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz test carefully and ensure this functions as expected when llm calls fail

will also set code hash only if the the request was successful|
@vercel vercel bot temporarily deployed to Preview – sprig May 20, 2024 19:46 Inactive
previously there were instances where the user message will reach the server before the code from the user got there (promises shenanigans). now, the message will be sent only if the code reached the server successfully otherwise it fails and bubbles the error
@vercel vercel bot temporarily deployed to Preview – sprig May 21, 2024 13:13 Inactive
@JosiasAurel JosiasAurel merged commit 46fe66c into main May 21, 2024
2 checks passed
@JosiasAurel JosiasAurel deleted the feat/send-code-on-change branch May 21, 2024 13:25
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.

None yet

2 participants