Skip to main content

0025: AI in the editor: previewed requests, strict edit proposals, scoped inline opt-in

  • Status: Proposed (implemented in Phase 2, task 018)
  • Date: 2026-12-06

Context​

Task 017 gave one service for providers, context and grants. The desktop needs chat, contextual commands, model-made edits and inline suggestions on top of it, without a second client, without trusting model output, and without the ordinary editor depending on AI.

Decision​

  • One path for every request. The desktop builds a Pending request (instruction, context requests, purpose), the service prepares it, the preview shows the exact body, and Send is the approval. Retry prepares again with fresh context.
  • Instructions carry their answer kind: prose, edit plan or inline text. Edit requests append a fixed answer format to the system prompt; the format names the revision attribute that the context now carries.
  • Edit answers are parsed strictly (ide_ai::edit): one JSON object, alone or in one fence, unknown fields refused, relative plain paths only, bounded size, files and edits. The core then turns a plan into an EditProposal only for files that were shared, at the shared revision, inside the canonical folder and not ignored, with the exact old text attached. The result goes to the existing review and transaction engine (0016); nothing is applied or saved by the AI path.
  • Inline suggestions run under a scoped grant (AutomaticCompletion) for the folder, inline route and endpoint, created only by an explicit opt-in that names the destination. Automatic requests are separately opt-in, and remote providers need a second setting. Suggestions are keyed to document, revision, caret, selection, configuration generation and permission epoch; any change cancels and drops them.
  • Model text is data. Links are offered only for existing workspace files; URLs and outside paths are plain text.

Alternatives considered​

  • Unified diffs from the model. Common, but fragile to apply and hard to check against a revision; line ranges with exact old text map directly onto the transaction preflight.
  • Previewing every inline request. Safest, but unusable for suggestions; the opt-in shows the destination and the shared window once, and is limited to one folder, route and session.
  • Free-text edits applied by heuristics. Rejected: no auto-apply of free text.

Consequences​

  • Edit proposals cannot create folders, rename or delete files; such proposals are refused.
  • A model that does not follow the format produces a note, never a partial change.
  • The chat panel and commands work with any route; no model picker beyond routes.

Validation​

ide-ai unit and service tests (strict parser, inline bounds, inline grant scope); ide-core ai tests (plan conversion: shared-only, revision, ignored, outside through links, stale, mismatch, undo); desktop UI tests against a local fake provider (setup states, exact preview, streaming, cancel, retry, failure, links, edit review partial and all with multi-file undo, malicious and stale answers, ghost opt-in, completion key priority, invalidation, debounce).