Rewrite site copy from a plain-language instruction - #379
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the change you want in plain language and the editor rewrites the section copy from it. One instruction, one undo step.
The v0.4.0 teardown removed chat editing because it was an AI feature attached to a product that had no keys, no accounts and nothing to configure. This is narrower on purpose, so that stays true: an instance without a key does not show the button, and a fresh clone still runs on an empty environment.
What it does
commitSections, so it lands as a single undo step. The toast says so.eyebrow,heading,bodyandctaLabel. Nothing else. Layout, colours, images, button links, scroll heights and visibility are read back from the document, not from the reply, so a model that redirects a call to action or stretches a scroll track changes nothing.Not trusting the reply
The reply is copy, not a document. In order:
sectionsSchema— the same schema the editor's own document has to satisfy.Anything that fails returns a 422 and the document is left alone.
Configuration
SARVAM_API_KEYGET /api/edit-siteanswers{"available":false}and the editor renders no buttonSARVAM_MODELsarvam-105b(default) orsarvam-105b-conversationsSARVAM_BASE_URLRate limited at 10 per five minutes per IP, tighter than export's 30 per minute: an export costs CPU, a rewrite costs credit that runs out for everyone at once. Body capped at 400 KB with the same running-cap reader
export-siteuses, instruction capped at 600 characters, and at most 40 sections per call.maxDuration = 60with a 50s abort, so a slow completion returns this route's own error rather than a gateway timeout.Verified
42 new tests, suite 388 to 432, all passing.
Five guards mutated one at a time to prove the tests bite:
sectionsSchemavalidation of the replyEnd to end in headless Chrome against the production build, with a local endpoint standing in for Sarvam (
SARVAM_BASE_URL), driving the real UI:Undorestored the original list exactly.Authorization: Bearer <key>andmodel=sarvam-105b; the reply came back inside a ```json fence and parsed.ctaHref: "#section-9"while changing the heading.{"available":false},POST503, and no button in the DOM.Screenshotted at 1440x900 and 390x844: no horizontal overflow at either width, and the submit button is hit-testable via
elementFromPointonce enabled.tsc --noEmitclean,eslintclean, production build clean.Not verified: the live Sarvam API. There is no key in this environment, so every assertion above comes from mocked fetch or the local stub. The request shape is built from the published contract at
docs.sarvam.ai/api-reference/chat/chat-completions—POST /v1/chat/completions, bearer auth, OpenAI-shaped response — but nobody has run it againstapi.sarvam.ai. To try it: put a key in.envasSARVAM_API_KEYand runnpm run dev.Also
contactDetails.test.tshad a test called "promises no AI, which the product does not have". That premise is no longer true, so it is now two tests that check what still matters: the landing, presets, create and about pages must not promise a feature they cannot know is configured, none of them may use the marketing register v0.4.0 removed, and the README must mention the key in the same breath as the rewriting.Limits
It rewrites; it does not restructure. Adding, removing or reordering sections stays manual, because section count drives the scroll track and a model that quietly returns eight sections for nine would silently retime the page.