feat: AI chat phase 5 (saved-query chips, user-defined slash commands)#1068
Merged
feat: AI chat phase 5 (saved-query chips, user-defined slash commands)#1068
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…gle-pass renderer, tests)
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.
Summary
Closes the remaining items in the AI Chat umbrella (#1047):
@and pick a saved SQL query. The chip carries the favorite's name; on send the chip resolves to the query body wrapped in a SQL code block under a## Saved Query: <name>header.{{query}}(current editor query),{{schema}}(active schema),{{database}}(active database name), and{{body}}(text typed after the command in the composer).Changes
5a — Saved query chips
ContextItem.savedQuery(id:name:)carries the name alongside the id (Codable migration: missingnamedecodes as empty string).AIChatViewModel.cachedSavedQueries: [UUID: SQLFavorite]populated on attach + on connection load.primeAttachmentDatanow handles.savedQueryby looking up the favorite viaSQLFavoriteManager.shared.fetchFavorite(id:).resolveSavedQueryAttachment(id:fallbackName:)formats the cached favorite as## Saved Query: <name>\n\``sql\n\n````.loadSavedQueries()populates a per-connection list. The chat panel's.task(id: connection.id)invokes it on open and on connection change.mentionCandidates(forQuery:)includes saved queries (filtered by name, alphabetical) sharing the popover budget with tables (each gets up to half of the 10-slot cap).5b — User-defined slash commands
CustomSlashCommandmodel (Codable, Identifiable):id,name,description,promptTemplate.CustomSlashCommandStorageis@Observable @MainActor, persists to UserDefaults underai.customSlashCommands.v1, and exposesadd/update/delete/command(named:).CustomSlashCommandRendererdoes mechanical placeholder substitution —{{query}},{{schema}},{{database}},{{body}}. Unknown placeholders pass through unchanged.AIChatViewModel.runCustomSlashCommand(_:body:)mirrors the built-in slash command flow: appends an invocationChatTurn, renders the template, sends throughsendWithContext.Customsection with the user's commands. Items hide whencommand.isValidis false (empty name or template).CustomSlashCommandsSectionslots intoAISettingsViewbetween the existing context section and privacy section. List rows show/<name> · descriptionwith Edit and Delete actions; an editor sheet handles add/edit with name, description, and a multi-line template field. Footer documents the available variables.Schema as a substitution variable
{{schema}}is currently passednilinrunCustomSlashCommandbecause rendering the schema synchronously is awkward (it requires the column/foreign-key data we fetch on demand). For v1, users who want schema in their template should attach the schema chip via@Schemaand reference it in the message naturally. A followup can wireensureSchemaLoaded+AISchemaContext.buildSchemaSectioninto the renderer if that turns out to be a common pattern.Risk
Low. New surface area is additive — no existing flows changed shape.
ContextItem.savedQueryenum case shape changed (UUID→(UUID, String)). Decoder defaultsnameto empty for older payloads, which then resolves through the chip'sfallbackNamepath. No persisted-data breakage.CHANGELOG
Two new
[Unreleased] / Addedlines covering 5a and 5b.Lint
swiftlint lint --strictclean across all 817 files.Test plan
@, pick one. Chip shows the favorite's name. Send. AI receives the SQL.review, descriptionSQL injection check, templateReview this query for SQL injection: {{query}}. Save./review. Confirm AI receives the rendered prompt with the editor query substituted.Umbrella status
This closes the implementation scope of #1047. Remaining followups (separate issues): write-side tools with safe-mode flow, Apple Intelligence transport (#1048), token cost surfacing.