Add conversational Assistant panel to /query#12
Merged
Conversation
A chat panel where editors ask data questions and grow the semantic layer in plain language. One stateless POST /query/assistant turn runs a single structured-JSON LLM call that classifies intent and extracts a draft; the assistant only drafts — every write rides the existing REST + auto-embed endpoints, so authorization is unchanged. Intents: question -> sql_preview (reuses generate_sql_only), and editor-gated glossary/metric/dictionary/knowledge drafts. Dictionary resolves (table_name, column_name) -> column_id server-side and supports multiple value mappings per column. Viewers get questions only. Frontend: AssistantPanel renders per-intent confirmation cards that POST to the existing create endpoints and invalidate the relevant query caches; QueryResultView extracted from QueryPage for reuse. MCP stays external-only. Tests: 33 unit tests (agent normalizers + downgrade, service branching incl. dictionary column resolution). Full backend suite green (131); frontend tsc + eslint + build clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Adds a conversational Assistant panel on the
/querypage. Editors ask data questions and grow the semantic layer in plain language; the assistant only drafts — every write rides the existing REST + auto-embed endpoints, so authorization stays unchanged. MCP remains external-only.One stateless
POST /query/assistantturn runs a single structured-JSON LLM call that classifies intent and extracts a draft (no tool-calling loop, no provider changes, no chat-session table — history is passed from the client).Intents
questionsql_preview(reusesgenerate_sql_only)POST /query/execute-sqlglossaryglossary_draftPOST /connections/{id}/glossarymetricmetric_draftPOST /connections/{id}/metricsdictionarydictionary_draftPOST /columns/{column_id}/dictionary(per entry)knowledgeknowledge_draftPOST /connections/{id}/knowledgechatAll draft intents are editor-gated (
ctx.has_role(ROLE_EDITOR)); viewers get questions only. Dictionary resolves(table_name, column_name) → column_idserver-side against the schema cache and supports multiple value mappings per column, downgrading to a clear chat message when the column isn't found.Design notes
/query(bodyconnection_id,get_org_context) mirroring the existing query endpoints — inherits the/query/*rate limiter for free; the service'sget_connectionenforces read-authz.AssistantDecision{intent, message, payload}; per-intent normalizers validate/shape the payload and downgrade to chat when unusable.AssistantPanelrenders colour-coded, editable confirmation cards that POST to the existing create endpoints and invalidate the relevant query caches.QueryResultViewextracted fromQueryPagefor reuse.Test plan
ruffclean.tsc --noEmitclean, ESLint clean,npm run buildsucceeds.Plan / as-built notes in
docs/assistant-plan.md.🤖 Generated with Claude Code