Skip to content

feat: AI inline assistant for SQL editor#1084

Merged
datlechin merged 2 commits into
mainfrom
worktree-pr-f-inline-assistant
May 7, 2026
Merged

feat: AI inline assistant for SQL editor#1084
datlechin merged 2 commits into
mainfrom
worktree-pr-f-inline-assistant

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

Adds an inline AI assistant to the main SQL editor (PR F from docs/refactor/ai-chat-redesign.md).

  • Select SQL in the editor and press Ctrl+Return (or pick Rewrite with AI... from the right-click menu) to open a floating prompt strip anchored above the selection.
  • Type the change you want and press Return to stream the rewrite. The proposed text streams in below the prompt as a diff: the original selection is shown red with a strikethrough, the proposed replacement in green.
  • Accept with Cmd+Return to replace the selection in place via the editor's existing edit pipeline. Reject with Esc to dismiss.

Architecture

  • InlineAssistantSession (@Observable @MainActor) drives request → streamed response. Reuses AIProviderFactory.resolve(...) and ChatTransport.streamChat(...); no duplicated streaming logic.
  • AIPromptTemplates+Rewrite adds the system + user prompts for rewrite-in-place. Schema context is included when the user has it enabled in AI settings.
  • InlineAssistantPromptView is a SwiftUI view: text field, action buttons, and a streamed diff with monospaced strikethrough red / green tinting.
  • InlineAssistantOverlayController hosts the view in a borderless NSPanel child window anchored to the editor selection rect via textView.layoutManager.rectForOffset(...). The panel repositions on parent move/resize and clamps to the visible screen.
  • InlineAssistantPresenter owns the lifecycle inside the editor coordinator: builds the session, presents the overlay, applies the replacement on accept, and dismisses on reject/cancel.
  • SQLEditorCoordinator installs the presenter and a per-editor NSEvent.addLocalMonitorForEvents for Ctrl+Return. The monitor fires only when the editor is first responder, has a non-empty selection, and AI is enabled. The existing EditorEventRouter is untouched.

Test plan

  • Build the app, configure an AI provider in Settings > AI.
  • Open a SQL editor tab, select a query fragment, press Ctrl+Return. Confirm the prompt strip appears anchored above the selection.
  • Type a change ("rename users to people"), press Return, watch the diff stream in. Confirm strikethrough on the original and green proposed text.
  • Press Cmd+Return to accept. Confirm the selection is replaced in place and undo (Cmd+Z) reverts it.
  • Repeat and press Esc to reject. Confirm no edit and the panel closes.
  • Right-click a selection, pick Rewrite with AI.... Confirm same flow as the keyboard shortcut.
  • With no selection, press Ctrl+Return. Confirm beep and no panel (Ctrl+Return passes through to default text view behavior when nothing is selected).
  • Resize/move the editor window with the panel open. Confirm the panel re-anchors.
  • Disable AI in settings. Confirm Ctrl+Return no longer triggers the assistant.

References

  • Roadmap row: docs/refactor/ai-chat-redesign.md PR F.
  • New shortcut: docs/features/keyboard-shortcuts.mdx and docs/features/ai-assistant.mdx.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin datlechin merged commit 1463be9 into main May 7, 2026
1 check passed
@datlechin datlechin deleted the worktree-pr-f-inline-assistant branch May 7, 2026 12:42
datlechin added a commit that referenced this pull request May 7, 2026
* Revert "fix: inline assistant + tool registry compile errors (#1085)"

This reverts commit f9c9d51.

* Revert "feat: AI inline assistant for SQL editor (#1084)"

This reverts commit 1463be9.

* fix: keep ChatToolRegistry.isToolAllowed nonisolated after PR F revert
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.

1 participant