Skip to content

[diffs/edit] Add edit prediction support - #1024

Open
ije wants to merge 12 commits into
mainfrom
ije/tab-tab-tab
Open

[diffs/edit] Add edit prediction support#1024
ije wants to merge 12 commits into
mainfrom
ije/tab-tab-tab

Conversation

@ije

@ije ije commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator
Screen.Recording.2026-07-25.at.02.18.26.mov

Usage:

import type {
  EditorOptions,
  EditPredictProvider,
  EditPredictResponse,
} from '@pierre/diffs/edit';
import { File } from '@pierre/diffs/react';

const provider: EditPredictProvider = {
  async predict(request, { signal }) {
    const response = await fetch('/api/edit-prediction', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify(request),
      signal,
    });

    if (!response.ok) {
      throw new Error('Prediction failed');
    }

    return (await response.json()) as EditPredictResponse;
  },
};

const editorOptions: EditorOptions<undefined> = {
  editPrediction: {
    provider,
    mode: 'eager',
    include: ['**/*.ts', '**/*.tsx'],
    exclude: ['**/*.test.ts'],
  },
};

export function EditableFile() {
  return (
    <File
      file={{
        name: 'cart.ts',
        contents: 'const total = items.',
      }}
      edit
      editorOptions={editorOptions}
    />
  );
}

@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pierre-docs-diffs Ready Ready Preview Jul 27, 2026 12:28pm
pierre-docs-diffshub Ready Ready Preview Jul 27, 2026 12:28pm
pierre-docs-trees Ready Ready Preview Jul 27, 2026 12:28pm
pierrejs-diff-demo Ready Ready Preview Jul 27, 2026 12:28pm

Request Review

@ije ije changed the title [diffs/edit] add inline edit prediction support [diffs/edit] Add edit prediction support Jul 24, 2026
chatgpt-codex-connector[bot]

This comment was marked as outdated.

@ije

This comment was marked as outdated.

@ije

This comment was marked as outdated.

chatgpt-codex-connector[bot]

This comment was marked as outdated.

@ije

ije commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review again

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dae253f656

ℹ️ 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".

Comment thread packages/diffs/src/editor/editor.ts Outdated
Comment on lines +4510 to +4513
// Cross-line edits cannot share their boundary line with another
// preview overlay.
if (renderEdits.at(-1)?.range.end.line === line) {
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Support valid edits that share a boundary line

When one non-overlapping edit crosses into a line and the next edit starts later on that same line—for example, {0,2}->{1,0} followed by {1,1}->{1,2}—the previous render edit ends on line, so this branch returns from the response handler. The public provider contract permits non-overlapping edit batches, but this valid response is silently discarded: no preview appears and Tab cannot accept it. Compose the boundary-line overlays or otherwise render the batch without rejecting it.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed in 0b00db6

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​vercel/​firewall@​1.2.1731007692100

View full report

@fat

fat commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@ije can you add an example to the playground for this as well? that way we can make sure it works with virtualization libraries, etc

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.

2 participants