[diffs/edit] Add edit prediction support#1024
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 303ba7f574
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| let upstream: Response; | ||
| try { | ||
| upstream = await fetch(CODESTRAL_FIM_URL, { |
There was a problem hiding this comment.
Add abuse protection before proxying Codestral
When MISTRAL_API_KEY is configured, this public app route accepts any valid JSON POST and immediately forwards it to Mistral with the server-side bearer token; I found no apps/docs middleware or rate-limit wiring guarding /api/edit-prediction. A third party can script requests directly to this endpoint and burn the paid quota even though the UI only exposes it behind the demo button, so add server-side abuse protection such as per-IP/session rate limiting before the upstream fetch.
Useful? React with 👍 / 👎.
| return; | ||
| } | ||
| if (isPromise(result)) { | ||
| if (result instanceof Promise) { |
There was a problem hiding this comment.
Detect promise-like storage results
If a custom persistStateStorage returns a thenable or a Promise created in another realm, this instanceof Promise check now treats the async read as a synchronous state object; the old isPromise helper accepted those values by checking for .then. In that case persisted selections/views are never restored correctly, and the matching write path also stops tracking pending async writes, so please keep the duck-typed promise detection or normalize with Promise.resolve.
Useful? React with 👍 / 👎.
| prediction.rendered ||= renderCtx.elements.size > elementCount; | ||
| } | ||
|
|
||
| if (isDeletion || !this.#isLineVisible(start.line)) { |
There was a problem hiding this comment.
Render newline-only deletion predictions
For deletion predictions that remove only a line break or an empty line, such as a range from end-of-line to the next line's character 0 with newText: '', #renderSelection produces no overlay because both slices are zero-width, and this branch skips rendering any ghost marker. Since Tab acceptance also requires prediction.rendered, join-line or empty-line deletion suggestions are silently impossible to accept; render a visible marker for these deletion ranges or mark them rendered when the affected newline is visible.
Useful? React with 👍 / 👎.
|
still working on it |
Screen.Recording.2026-07-25.at.02.18.26.mov
Usage: