AI boundary and privacy
AI is optional. Editing, files and language features never depend on it. The editor core does not depend on the AI crate; the desktop app connects them.
Explain selection (implemented)
- Select code and run AI: Explain Selection… (Code menu or command palette).
- If no provider is configured, the IDE says so and how to configure one. It never shows a fake response.
- A preview shows the exact messages, the endpoint and the model, plus warnings if the selection looks like it contains secrets. Nothing is sent until you press Send.
- The response streams into a read-only side panel with Cancel, Copy and Close. Files are never modified.
What is sent: the selected text (truncated at 16 000 chars), the language name and the file name (no directory). Nothing else from the workspace.
Providers
# settings.toml
[ai]
base_url = "https://api.example.com/v1" # or a local server, e.g. http://localhost:11434/v1
model = "model-name"
api_key_env = "MY_PROVIDER_KEY" # optional; name of an environment variable
The OpenAI-compatible adapter sends POST {base_url}/chat/completions with stream: true and reads Server-Sent Events (choices[0].delta.content, terminated by [DONE]). This shape is served by OpenAI and by local servers such as Ollama and LM Studio. API keys are read from the environment at request time, sent only as an Authorization: Bearer header, redacted from debug output and never written to configuration. Settings files reject unknown keys, so a raw api_key entry is an error rather than a silently stored secret.
Providers implement the AiProvider trait (describe, stream with a cancel token). A deterministic MockProvider backs the tests; a test HTTP server verifies the real adapter's request and streaming parser.
Rules for future AI features
- Workspace-wide context requires explicit permission per request and a trusted workspace.
- Tool use and file changes go through reviewable diffs applied as normal undoable edits.
- Requests stay cancellable and bounded in size, time and concurrency.
- Repository content and model output are untrusted data, never instructions.
Cancel stops the UI from accepting more text immediately. The network read ends at the next received chunk or after the 60 s read timeout.