feat: @-mention attachments in AI chat composer (Schema / Table / Current Query / Query Results)#1060
Merged
Conversation
…rent Query / Query Results)
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…y; reuse AISchemaContext.buildSchemaSection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 3b.1 of #1047. Attach context to a chat message via an
@menu next to the slash menu. Items render as chips above the input and inside the user message bubble. Outgoing user turns carry the items as.attachment(ContextItem)blocks plus an expanded text section appended to the prompt.What you can attach
Saved Queries and File items exist in
ContextItem(defined in #1057) but are not exposed in the picker yet — those need async fetches and are deferred.Implementation
ContextItem+Display.swift—displayLabel,symbolName,stableKey. The chip view, picker, and the dedupe inattach(_:)all key offstableKey, so two.table(id, "Customer")references collapse to one attachment.AIChatViewModel:attachedContext: [ContextItem](observable) holds the currently-staged attachments.attach(_:)/detach(_:)mutate the list with stable-key dedupe.composePrompt(text:attachments:)joins typed text withresolveAttachment(_:)output, separated by---.sendMessage()builds aChatTurnwith[.text(prompt)] + attachments.map { .attachment($0) }. The text block is what the AI sees viaplainText; the attachment blocks are UI markers for chip rendering.attachedContextis cleared.AIChatContextChipView/AIChatContextChipStrip— small reusable chip (icon + label + optionalxmark).AIChatPanelView:mentionMenubutton betweenslashCommandMenuand the Send button. Categories show only when their data is available (Schema needsconnection.id, Tables needsviewModel.tables, etc.).AIChatMessageView:attachedContextItems(extracted from.attachmentblocks) as a chip strip above the message text. So scrolling history shows what was attached.Why this design
turn.plainText. They don't need to know about attachment blocks — they see the resolved text inline. No provider migration required.ChatTurn's Codable and survive across app restarts viaAIChatStorage. The chip rendering in user bubbles works on stored conversations.What's NOT in this PR
@-detection popover (filter as you type@cus...for the Customer table). Tracked as 3b.2 follow-up.AISchemaContext.buildSystemPrompt) — that's Phase 3c. Currently auto-context AND@-mention attachments both reach the AI; users can rely on the auto-shovel and just use mentions for emphasis. 3c will flip the default.Tests
AIChatViewModelMentionsTests: 6 tests covering attach idempotency, detach, attachment-block embedding on send, currentQuery resolution into the prompt, and the empty-input no-op.Test plan
@button is to the right of the slash menu and the model picker.@. Pick Schema. A "Schema" chip appears above the input.@again. Pick a Tables sub-item. Second chip appears.ChatTurn.blocks).