@burdenoff/microfe-semanticfed 2026.1109.15 → 2026.1109.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/semanticfed/components/AskQuestionPanel.js +6 -6
- package/dist/semanticfed/components/AskQuestionPanel.js.map +1 -1
- package/dist/semanticfed/components/NlAssistSettings.js +4 -4
- package/dist/semanticfed/components/NlAssistSettings.js.map +1 -1
- package/dist/semanticfed/components/OnboardingChecklist.js +2 -2
- package/dist/semanticfed/components/OnboardingChecklist.js.map +1 -1
- package/dist/semanticfed/components/SavedQueryRunsPanel.js +12 -12
- package/dist/semanticfed/components/SavedQueryRunsPanel.js.map +1 -1
- package/dist/semanticfed/components/TableHeaders.d.ts +1 -1
- package/dist/semanticfed/components/TableHeaders.js +3 -3
- package/dist/semanticfed/components/TableHeaders.js.map +1 -1
- package/dist/semanticfed/components/lineage/LineageDetails.d.ts +1 -0
- package/dist/semanticfed/components/lineage/LineageDetails.js +15 -11
- package/dist/semanticfed/components/lineage/LineageDetails.js.map +1 -1
- package/dist/semanticfed/components/lineage/LineageLanes.js +25 -25
- package/dist/semanticfed/components/lineage/LineageLanes.js.map +1 -1
- package/dist/semanticfed/components/lineage/LineageWarnings.js +1 -1
- package/dist/semanticfed/components/lineage/LineageWarnings.js.map +1 -1
- package/dist/semanticfed/components/lineage/lineageModel.d.ts +5 -1
- package/dist/semanticfed/components/lineage/lineageModel.js +11 -5
- package/dist/semanticfed/components/lineage/lineageModel.js.map +1 -1
- package/dist/semanticfed/components/queryConsole/QueryHistoryCard.js +1 -1
- package/dist/semanticfed/components/queryConsole/QueryHistoryCard.js.map +1 -1
- package/dist/semanticfed/components/queryConsole/SchemaBrowser.js +3 -3
- package/dist/semanticfed/components/queryConsole/SchemaBrowser.js.map +1 -1
- package/dist/semanticfed/components/queryConsole/SqlEditorCard.js +1 -1
- package/dist/semanticfed/components/queryConsole/SqlEditorCard.js.map +1 -1
- package/dist/semanticfed/components/queryConsole/SqlResultCard.js +1 -1
- package/dist/semanticfed/components/queryConsole/SqlResultCard.js.map +1 -1
- package/dist/semanticfed/hooks/useLineage.d.ts +2 -1
- package/dist/semanticfed/hooks/useLineage.js +24 -23
- package/dist/semanticfed/hooks/useLineage.js.map +1 -1
- package/dist/semanticfed/hooks/useSqlConsole.d.ts +2 -1
- package/dist/semanticfed/hooks/useSqlConsole.js +28 -27
- package/dist/semanticfed/hooks/useSqlConsole.js.map +1 -1
- package/dist/semanticfed/pages/AgentsPage.js +8 -8
- package/dist/semanticfed/pages/AgentsPage.js.map +1 -1
- package/dist/semanticfed/pages/AuditPage.js +4 -4
- package/dist/semanticfed/pages/AuditPage.js.map +1 -1
- package/dist/semanticfed/pages/CollaborationPage.js +1 -1
- package/dist/semanticfed/pages/CollaborationPage.js.map +1 -1
- package/dist/semanticfed/pages/ConfigurationPage.js +7 -7
- package/dist/semanticfed/pages/ConfigurationPage.js.map +1 -1
- package/dist/semanticfed/pages/DashboardPage.js +1 -1
- package/dist/semanticfed/pages/DashboardPage.js.map +1 -1
- package/dist/semanticfed/pages/HelpPage.js +1 -1
- package/dist/semanticfed/pages/HelpPage.js.map +1 -1
- package/dist/semanticfed/pages/KnowledgeGraphPage.js +107 -107
- package/dist/semanticfed/pages/KnowledgeGraphPage.js.map +1 -1
- package/dist/semanticfed/pages/LineagePage.js +59 -57
- package/dist/semanticfed/pages/LineagePage.js.map +1 -1
- package/dist/semanticfed/pages/MonitoringPage.js +76 -76
- package/dist/semanticfed/pages/MonitoringPage.js.map +1 -1
- package/dist/semanticfed/pages/OntologyPage.js +41 -41
- package/dist/semanticfed/pages/OntologyPage.js.map +1 -1
- package/dist/semanticfed/pages/PerformancePage.js +2 -2
- package/dist/semanticfed/pages/PerformancePage.js.map +1 -1
- package/dist/semanticfed/pages/PoliciesPage.js +10 -10
- package/dist/semanticfed/pages/PoliciesPage.js.map +1 -1
- package/dist/semanticfed/pages/ProtocolPage.js +42 -39
- package/dist/semanticfed/pages/ProtocolPage.js.map +1 -1
- package/dist/semanticfed/pages/QueryConsolePage.js +37 -37
- package/dist/semanticfed/pages/QueryConsolePage.js.map +1 -1
- package/dist/semanticfed/pages/RegistryPage.js +84 -84
- package/dist/semanticfed/pages/RegistryPage.js.map +1 -1
- package/dist/semanticfed/pages/TechStackPage.js +1 -1
- package/dist/semanticfed/pages/TechStackPage.js.map +1 -1
- package/dist/semanticfed/pages/TopologyPage.js +1 -1
- package/dist/semanticfed/pages/TopologyPage.js.map +1 -1
- package/dist/semanticfed/pages/VisualizationPage.js +7 -7
- package/dist/semanticfed/pages/VisualizationPage.js.map +1 -1
- package/dist/semanticfed/translations/english.js +514 -0
- package/dist/semanticfed/translations/english.js.map +1 -0
- package/dist/semanticfed/translations/english.json.d.ts +513 -0
- package/dist/semanticfed/utils/requestErrorI18n.d.ts +3 -0
- package/dist/semanticfed/utils/requestErrorI18n.js +15 -0
- package/dist/semanticfed/utils/requestErrorI18n.js.map +1 -0
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -34,3 +34,36 @@ commit tests with browser fetch disabled. Native context changes reset local
|
|
|
34
34
|
result/history/editor state and query data; ordinary bearer renewal in the same
|
|
35
35
|
context preserves that state. The tests are protocol and state fixtures, separate
|
|
36
36
|
from deployed doctor and Playwright acceptance. They are part of `sanity`.
|
|
37
|
+
|
|
38
|
+
## Product translations and RTL
|
|
39
|
+
|
|
40
|
+
`bun run i18n:extract` statically extracts the literal translation calls and the
|
|
41
|
+
finite onboarding, guide, lineage and label maps into
|
|
42
|
+
`src/semanticfed/translations/english.json`. It never imports or executes product
|
|
43
|
+
source. An unclassified dynamic call or conflicting English fallback fails the
|
|
44
|
+
command. `bun run i18n:check` verifies the checked-in catalog and extraction
|
|
45
|
+
regressions; `sanity` runs it after generating the GraphQL artifacts required by
|
|
46
|
+
the client tests.
|
|
47
|
+
|
|
48
|
+
The package exports `semanticfedEnglishCatalog`, a flat map of dot-notated keys
|
|
49
|
+
to their current English fallback values. The dedicated
|
|
50
|
+
`@burdenoff/microfe-semanticfed/translations/english` default export lets shells
|
|
51
|
+
load this data without eagerly importing the product component entry.
|
|
52
|
+
App shells can reconcile their bundled
|
|
53
|
+
fallbacks against the catalog of the exact package they pin. This catalog is
|
|
54
|
+
English source extraction, not a complete translation-seed bundle or proof that
|
|
55
|
+
online dictionaries or non-English translations are complete. Online changes
|
|
56
|
+
belong to the global i18n service's in-place seeder and reviewed plan, preserving
|
|
57
|
+
existing values and history.
|
|
58
|
+
|
|
59
|
+
Product spacing and text alignment use logical utilities. Pagination chevrons
|
|
60
|
+
mirror under the platform RTL mode; source/target graph direction and technical
|
|
61
|
+
SQL identifiers retain their meaning. The platform owns document direction:
|
|
62
|
+
use its supported `?dir=rtl` preview for browser acceptance rather than setting
|
|
63
|
+
`document.dir` in product components. Actual locale and RTL browser receipts are
|
|
64
|
+
separate from successful extraction and build checks.
|
|
65
|
+
|
|
66
|
+
Known fixed client request messages also use product translation keys. SQL parser
|
|
67
|
+
and service-provided diagnostic text remain verbatim; unknown messages are not
|
|
68
|
+
translated by guessing. The extraction gate rejects nonliteral metadata labels,
|
|
69
|
+
conflicting or duplicate fields, unsafe paths and unclassified dynamic calls.
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2,4 +2,5 @@ import { useSemanticFed as e } from "./semanticfed/providers/SemanticFedProvider
|
|
|
2
2
|
import { SemanticFedRoot as t } from "./semanticfed/SemanticFedRoot.js";
|
|
3
3
|
import { useSemanticFedStore as n } from "./semanticfed/store/semanticfedStore.js";
|
|
4
4
|
import "./semanticfed/index.js";
|
|
5
|
-
|
|
5
|
+
import r from "./semanticfed/translations/english.js";
|
|
6
|
+
export { t as SemanticFedRoot, r as semanticfedEnglishCatalog, e as useSemanticFed, n as useSemanticFedStore };
|
|
@@ -77,7 +77,7 @@ function A({ translation: e, governedLabel: t, onOpenInEditor: n, latest: r }) {
|
|
|
77
77
|
e.followUp && /* @__PURE__ */ v(y, {
|
|
78
78
|
variant: "outline",
|
|
79
79
|
"data-testid": r ? "nl-ask-followup" : void 0,
|
|
80
|
-
children: [/* @__PURE__ */ _(l, { className: "
|
|
80
|
+
children: [/* @__PURE__ */ _(l, { className: "me-1 h-3 w-3 rtl:-scale-x-100" }), a("semanticfed.queryConsole.ask.followUp", "Follow-up")]
|
|
81
81
|
}),
|
|
82
82
|
/* @__PURE__ */ _(y, {
|
|
83
83
|
variant: "outline",
|
|
@@ -99,7 +99,7 @@ function A({ translation: e, governedLabel: t, onOpenInEditor: n, latest: r }) {
|
|
|
99
99
|
variant: "outline",
|
|
100
100
|
onClick: () => n(e.sql ?? ""),
|
|
101
101
|
"data-testid": r ? "nl-ask-open-editor" : void 0,
|
|
102
|
-
children: [/* @__PURE__ */ _(p, { className: "
|
|
102
|
+
children: [/* @__PURE__ */ _(p, { className: "me-2 h-4 w-4" }), a("semanticfed.queryConsole.ask.openInEditor", "Edit as SQL")]
|
|
103
103
|
})]
|
|
104
104
|
}),
|
|
105
105
|
r ? s : /* @__PURE__ */ v("details", { children: [/* @__PURE__ */ _("summary", {
|
|
@@ -175,14 +175,14 @@ function N({ hasTurns: e, busy: t, showSettings: n, onNewConversation: r, onTogg
|
|
|
175
175
|
onClick: r,
|
|
176
176
|
disabled: t,
|
|
177
177
|
"data-testid": "nl-ask-new-conversation",
|
|
178
|
-
children: [/* @__PURE__ */ _(m, { className: "
|
|
178
|
+
children: [/* @__PURE__ */ _(m, { className: "me-2 h-4 w-4" }), a("semanticfed.queryConsole.ask.newConversation", "New conversation")]
|
|
179
179
|
}), /* @__PURE__ */ v(b, {
|
|
180
180
|
size: "sm",
|
|
181
181
|
variant: n ? "secondary" : "ghost",
|
|
182
182
|
onClick: i,
|
|
183
183
|
"aria-expanded": n,
|
|
184
184
|
"data-testid": "nl-assist-toggle",
|
|
185
|
-
children: [/* @__PURE__ */ _(g, { className: "
|
|
185
|
+
children: [/* @__PURE__ */ _(g, { className: "me-2 h-4 w-4" }), a("semanticfed.queryConsole.ask.assistSettings", "AI assistance")]
|
|
186
186
|
})]
|
|
187
187
|
})]
|
|
188
188
|
}), /* @__PURE__ */ _("p", {
|
|
@@ -219,7 +219,7 @@ function P({ question: e, onQuestionChange: t, onSubmit: n, isFollowUp: r, disab
|
|
|
219
219
|
className: "sm:self-stretch",
|
|
220
220
|
disabled: i || e.trim() === "" || a,
|
|
221
221
|
"data-testid": "nl-ask-submit",
|
|
222
|
-
children: [a ? /* @__PURE__ */ _(d, { className: "
|
|
222
|
+
children: [a ? /* @__PURE__ */ _(d, { className: "me-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ _(h, { className: "me-2 h-4 w-4" }), o("semanticfed.queryConsole.ask.submit", "Ask")]
|
|
223
223
|
})
|
|
224
224
|
]
|
|
225
225
|
});
|
|
@@ -251,7 +251,7 @@ function I({ modelId: i, maxRows: l, onAnswer: u, onError: d, onOpenInEditor: f
|
|
|
251
251
|
error: null
|
|
252
252
|
}]), h(""), u(e);
|
|
253
253
|
} catch (e) {
|
|
254
|
-
let n = a(e);
|
|
254
|
+
let n = a(e, p);
|
|
255
255
|
y((e) => [...e, {
|
|
256
256
|
id: o,
|
|
257
257
|
question: t,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AskQuestionPanel.js","names":["MAX_QUESTION_LENGTH","SUGGESTION_LIMIT","formatValue","value","describeStep","target","step","governedLabel","assistNote","tr","translation","Interpretation","useTr","sql","latest","Badge","CornerDownRight","withContentKeys","key","Button","onOpenInEditor","PencilLine","Clarification","HelpCircle","ConversationTurn","turn","note","Sparkles","AskPanelHeader","CardHeader","CardTitle","MessageSquareText","hasTurns","onNewConversation","busy","RotateCcw","showSettings","onToggleSettings","AskForm","onSubmit","question","onQuestionChange","isFollowUp","disabled","Loader2","Send","suggestionsToShow","turns","examples","AskQuestionPanel","setQuestion","useState","setTurns","conversationModel","setConversationModel","modelId","setShowSettings","nextTurnId","useRef","suggestions","useSemNlSuggestions","ask","useSemAskQuestion","submit","trimmed","text","history","conversationHistory","id","data","all","onAnswer","message","sqlErrorMessage","onError","askSuggestion","shownSuggestions","Card","v","CardContent","NlAssistSettings","index"],"sources":["../../../src/semanticfed/components/AskQuestionPanel.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { Badge, Button, Card, CardContent, CardHeader, CardTitle } from '@burdenoff/fe-libs/ui';\nimport {\n CornerDownRight,\n HelpCircle,\n Loader2,\n MessageSquareText,\n PencilLine,\n RotateCcw,\n Send,\n Sparkles,\n} from 'lucide-react';\n\nimport {\n type SemNlAnswer,\n type SemNlAssistStatus,\n type SemNlStep,\n type SemNlTranslation,\n useSemAskQuestion,\n useSemNlSuggestions,\n} from '../hooks/useNlQuery';\nimport { NlAssistSettings } from './NlAssistSettings';\nimport { conversationHistory, type Turn } from './askConversation';\nimport { withContentKeys } from '../utils/contentKeys';\nimport { sqlErrorMessage } from '../hooks/useSqlConsole';\nimport { useTr } from '../hooks/useTr';\n\n/** Longest question the service accepts (MAX_QUESTION_LENGTH in wspace-semanticfed-svc). */\nconst MAX_QUESTION_LENGTH = 1000;\n/** Example questions shown under the input. */\nconst SUGGESTION_LIMIT = 6;\nexport interface AskQuestionPanelProps {\n modelId: string | null;\n maxRows: number;\n /** Called with every answer, so the page can show its governed result rows. */\n onAnswer: (answer: SemNlAnswer) => void;\n /** Called when a question fails before it is answered (network, quota, access). */\n onError: (message: string) => void;\n /** Open the generated SQL in the console's editor for review or editing. */\n onOpenInEditor: (sql: string) => void;\n}\n\nfunction formatValue(value: unknown): string {\n if (value === null || value === undefined) return 'NULL';\n if (typeof value === 'string') return `'${value}'`;\n if (typeof value === 'object') return JSON.stringify(value);\n return String(value);\n}\n\n/** One interpretation step as a short phrase, e.g. \"SUM(revenue) (governed)\". */\nfunction describeStep(step: SemNlStep, governedLabel: string): string {\n const target = [step.entity, step.field].filter(Boolean).join('.');\n switch (step.kind) {\n case 'MEASURE':\n return `${step.aggregation ?? ''}(${target})${step.governed ? ` ${governedLabel}` : ''}`;\n case 'FILTER':\n return `${target} ${step.operator ?? '='} ${formatValue(step.value)}`;\n case 'ORDER':\n return `${target} ${step.direction ?? ''}`.trim();\n case 'LIMIT':\n return String(step.count ?? '');\n case 'JOIN':\n return step.relationship ? `${target} (${step.relationship})` : target;\n default:\n return target;\n }\n}\n\n/** A short, translated note on whether and how the workspace's AI provider helped. */\nfunction assistNote(\n translation: SemNlTranslation,\n tr: ReturnType<typeof useTr>\n): { text: string; tone: 'info' | 'warn' } | null {\n const provider = translation.assistProvider ?? '';\n const notes: Partial<Record<SemNlAssistStatus, { text: string; tone: 'info' | 'warn' }>> = {\n REPHRASED: {\n text: tr(\n 'semanticfed.queryConsole.ask.assist.rephrased',\n 'Reworded by your AI provider ({provider}) as: “{question}”',\n {\n provider,\n question: translation.rephrasedQuestion ?? '',\n }\n ),\n tone: 'info',\n },\n NO_IMPROVEMENT: {\n text: tr(\n 'semanticfed.queryConsole.ask.assist.noImprovement',\n 'Your AI provider could not reword this question into one the model can answer.'\n ),\n tone: 'warn',\n },\n QUOTA_EXHAUSTED: {\n text: tr(\n 'semanticfed.queryConsole.ask.assist.quota',\n 'AI assistance is paused: this workspace has used today’s AI operations.'\n ),\n tone: 'warn',\n },\n QUOTA_UNAVAILABLE: {\n text: tr(\n 'semanticfed.queryConsole.ask.assist.quotaUnavailable',\n 'AI assistance is unavailable: the AI-operation allowance for this workspace could not be checked.'\n ),\n tone: 'warn',\n },\n PROVIDER_ERROR: {\n text: tr(\n 'semanticfed.queryConsole.ask.assist.providerError',\n 'Your AI provider could not be used for this question (it was unreachable, refused the key, or returned an error).'\n ),\n tone: 'warn',\n },\n NOT_CONFIGURED: {\n text: tr(\n 'semanticfed.queryConsole.ask.assist.notConfigured',\n 'AI assistance is on, but its provider connection is missing or revoked. Choose a connection under AI assistance.'\n ),\n tone: 'warn',\n },\n };\n return notes[translation.assist] ?? null;\n}\n\n/** Steps, SQL and ignored words of a translated question. */\nfunction Interpretation({\n translation,\n governedLabel,\n onOpenInEditor,\n latest,\n}: {\n translation: SemNlTranslation;\n governedLabel: string;\n onOpenInEditor: (sql: string) => void;\n latest: boolean;\n}) {\n const tr = useTr();\n const sql = (\n <pre\n className=\"overflow-x-auto rounded bg-muted p-3 font-mono text-xs text-foreground\"\n data-testid={latest ? 'nl-ask-sql' : undefined}\n >\n {translation.sql}\n </pre>\n );\n return (\n <div\n className=\"space-y-2 rounded border p-3\"\n data-testid={latest ? 'nl-ask-interpretation' : undefined}\n >\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <div className=\"flex flex-wrap items-center gap-2 text-xs\">\n <span className=\"font-medium\">\n {tr('semanticfed.queryConsole.ask.interpretation', 'Interpretation')}\n </span>\n {translation.followUp && (\n <Badge variant=\"outline\" data-testid={latest ? 'nl-ask-followup' : undefined}>\n <CornerDownRight className=\"mr-1 h-3 w-3\" />\n {tr('semanticfed.queryConsole.ask.followUp', 'Follow-up')}\n </Badge>\n )}\n <Badge variant=\"outline\" data-testid={latest ? 'nl-ask-confidence' : undefined}>\n {tr('semanticfed.queryConsole.ask.confidence', 'Confidence {value}%', {\n value: Math.round(translation.confidence * 100),\n })}\n </Badge>\n {withContentKeys(\n translation.steps,\n (step) => `${step.kind}:${describeStep(step, governedLabel)}`\n ).map(({ key, item: step }) => (\n <Badge key={key} variant=\"secondary\" className=\"font-mono\">\n {step.kind.replace('_', ' ')}: {describeStep(step, governedLabel)}\n </Badge>\n ))}\n </div>\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => onOpenInEditor(translation.sql ?? '')}\n data-testid={latest ? 'nl-ask-open-editor' : undefined}\n >\n <PencilLine className=\"mr-2 h-4 w-4\" />\n {tr('semanticfed.queryConsole.ask.openInEditor', 'Edit as SQL')}\n </Button>\n </div>\n {latest ? (\n sql\n ) : (\n <details>\n <summary className=\"cursor-pointer text-xs text-muted-foreground\">\n {tr('semanticfed.queryConsole.ask.showSql', 'Show SQL')}\n </summary>\n {sql}\n </details>\n )}\n {translation.unmatchedTerms.length > 0 && (\n <p className=\"text-xs text-muted-foreground\">\n {tr('semanticfed.queryConsole.ask.ignored', 'Ignored words: {terms}', {\n terms: translation.unmatchedTerms.join(', '),\n })}\n </p>\n )}\n </div>\n );\n}\n\ntype Tr = ReturnType<typeof useTr>;\n\n/** The service's request for a clearer question, with the words it could not place. */\nfunction Clarification({\n translation,\n latest,\n tr,\n}: {\n translation: SemNlTranslation;\n latest: boolean;\n tr: Tr;\n}) {\n return (\n <div\n className=\"flex items-start gap-2 rounded border border-dashed p-3 text-sm\"\n data-testid={latest ? 'nl-ask-clarification' : undefined}\n >\n <HelpCircle className=\"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground\" />\n <div className=\"min-w-0 space-y-1\">\n <p>{translation.clarification}</p>\n {translation.unmatchedTerms.length > 0 && (\n <p className=\"text-xs text-muted-foreground\">\n {tr('semanticfed.queryConsole.ask.unmatched', 'Not found in the model: {terms}', {\n terms: translation.unmatchedTerms.join(', '),\n })}\n </p>\n )}\n </div>\n </div>\n );\n}\n\n/** One question of the thread with its error, AI note, clarification or interpretation. */\nfunction ConversationTurn({\n turn,\n latest,\n governedLabel,\n onOpenInEditor,\n tr,\n}: {\n turn: Turn;\n latest: boolean;\n governedLabel: string;\n onOpenInEditor: (sql: string) => void;\n tr: Tr;\n}) {\n const translation = turn.answer?.translation ?? null;\n const note = translation ? assistNote(translation, tr) : null;\n return (\n <li className=\"space-y-2\" data-testid=\"nl-ask-turn\">\n <p className=\"w-fit max-w-full rounded-lg bg-muted px-3 py-2 text-sm\">{turn.question}</p>\n {turn.error && <p className=\"text-xs text-destructive\">{turn.error}</p>}\n {note && (\n <p\n className={`flex items-start gap-1 text-xs ${note.tone === 'warn' ? 'text-muted-foreground' : 'text-primary'}`}\n data-testid={latest ? 'nl-ask-assist-note' : undefined}\n >\n <Sparkles className=\"mt-0.5 h-3 w-3 shrink-0\" />\n {note.text}\n </p>\n )}\n {translation?.status === 'NEEDS_CLARIFICATION' && (\n <Clarification translation={translation} latest={latest} tr={tr} />\n )}\n {translation?.status === 'TRANSLATED' && translation.sql && (\n <Interpretation\n translation={translation}\n governedLabel={governedLabel}\n onOpenInEditor={onOpenInEditor}\n latest={latest}\n />\n )}\n </li>\n );\n}\n\n/** Title row: start a new conversation and open the AI-assistance settings. */\nfunction AskPanelHeader({\n hasTurns,\n busy,\n showSettings,\n onNewConversation,\n onToggleSettings,\n tr,\n}: {\n hasTurns: boolean;\n busy: boolean;\n showSettings: boolean;\n onNewConversation: () => void;\n onToggleSettings: () => void;\n tr: Tr;\n}) {\n return (\n <CardHeader className=\"pb-3\">\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <CardTitle className=\"flex items-center gap-2 text-base\">\n <MessageSquareText className=\"h-4 w-4\" />\n {tr('semanticfed.queryConsole.ask.title', 'Ask a question')}\n </CardTitle>\n <div className=\"flex flex-wrap gap-2\">\n {hasTurns && (\n <Button\n size=\"sm\"\n variant=\"ghost\"\n onClick={onNewConversation}\n disabled={busy}\n data-testid=\"nl-ask-new-conversation\"\n >\n <RotateCcw className=\"mr-2 h-4 w-4\" />\n {tr('semanticfed.queryConsole.ask.newConversation', 'New conversation')}\n </Button>\n )}\n <Button\n size=\"sm\"\n variant={showSettings ? 'secondary' : 'ghost'}\n onClick={onToggleSettings}\n aria-expanded={showSettings}\n data-testid=\"nl-assist-toggle\"\n >\n <Sparkles className=\"mr-2 h-4 w-4\" />\n {tr('semanticfed.queryConsole.ask.assistSettings', 'AI assistance')}\n </Button>\n </div>\n </div>\n <p className=\"text-xs text-muted-foreground\">\n {tr(\n 'semanticfed.queryConsole.ask.conversationDescription',\n 'Ask in plain English, then refine with follow-ups such as “and by status?”, “only EU” or “top 3 instead”. Answers come from the model’s governed metrics and dimensions, with your access policies applied, and the SQL that ran is shown.'\n )}\n </p>\n </CardHeader>\n );\n}\n\n/** The question input and its submit button. */\nfunction AskForm({\n question,\n onQuestionChange,\n onSubmit,\n isFollowUp,\n disabled,\n busy,\n tr,\n}: {\n question: string;\n onQuestionChange: (value: string) => void;\n onSubmit: () => void;\n isFollowUp: boolean;\n disabled: boolean;\n busy: boolean;\n tr: Tr;\n}) {\n return (\n <form\n className=\"flex flex-col gap-2 sm:flex-row\"\n onSubmit={(e) => {\n e.preventDefault();\n onSubmit();\n }}\n >\n <label className=\"sr-only\" htmlFor=\"nl-ask-input\">\n {tr('semanticfed.queryConsole.ask.inputLabel', 'Your question')}\n </label>\n <input\n id=\"nl-ask-input\"\n data-testid=\"nl-ask-input\"\n className=\"min-w-0 flex-1 rounded border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary\"\n value={question}\n maxLength={MAX_QUESTION_LENGTH}\n onChange={(e) => onQuestionChange(e.target.value)}\n placeholder={\n isFollowUp\n ? tr(\n 'semanticfed.queryConsole.ask.followUpPlaceholder',\n 'Ask a follow-up, e.g. and by status?'\n )\n : tr('semanticfed.queryConsole.ask.placeholder', 'e.g. top 5 regions by revenue')\n }\n disabled={disabled}\n />\n <Button\n type=\"submit\"\n size=\"sm\"\n className=\"sm:self-stretch\"\n disabled={disabled || question.trim() === '' || busy}\n data-testid=\"nl-ask-submit\"\n >\n {busy ? (\n <Loader2 className=\"mr-2 h-4 w-4 animate-spin\" />\n ) : (\n <Send className=\"mr-2 h-4 w-4\" />\n )}\n {tr('semanticfed.queryConsole.ask.submit', 'Ask')}\n </Button>\n </form>\n );\n}\n\n/**\n * The example questions to offer: the service's suggestions while it asks\n * for clarification, the model's examples before the first question, and\n * none during a conversation.\n */\nfunction suggestionsToShow(turns: Turn[], examples: string[] | undefined): string[] {\n const translation = turns.at(-1)?.answer?.translation ?? null;\n if (translation?.status === 'NEEDS_CLARIFICATION') {\n return translation.suggestions.slice(0, SUGGESTION_LIMIT);\n }\n return turns.length === 0 ? (examples ?? []).slice(0, SUGGESTION_LIMIT) : [];\n}\n\n/**\n * \"Ask a question\" — natural-language questions over the semantic layer\n * (BOFF-4276), as a conversation (BOFF-10533). Each question is translated\n * into SQL over the model's governed metrics and dimensions and run with the\n * caller's access policies; a follow-up (\"and by status?\", \"only EU\", \"top 3\n * instead\") refines the previous answers. The interpretation (generated SQL,\n * steps, confidence, ignored words, and any AI rewording) is always shown so\n * the answer can be checked, and opened in the SQL editor.\n */\nexport function AskQuestionPanel({\n modelId,\n maxRows,\n onAnswer,\n onError,\n onOpenInEditor,\n}: AskQuestionPanelProps) {\n const tr = useTr();\n const [question, setQuestion] = useState('');\n const [turns, setTurns] = useState<Turn[]>([]);\n const [conversationModel, setConversationModel] = useState<string | null>(modelId);\n const [showSettings, setShowSettings] = useState(false);\n const nextTurnId = useRef(0);\n const suggestions = useSemNlSuggestions(modelId);\n const ask = useSemAskQuestion();\n\n // A conversation belongs to one model: switching models starts a new one.\n if (conversationModel !== modelId) {\n setConversationModel(modelId);\n setTurns([]);\n }\n\n const submit = async (text: string) => {\n const trimmed = text.trim();\n if (!modelId || trimmed === '' || ask.isPending) return;\n const history = conversationHistory(turns);\n nextTurnId.current += 1;\n const id = nextTurnId.current;\n try {\n const data = await ask.mutateAsync({\n question: trimmed,\n modelId,\n maxRows,\n ...(history.length > 0 ? { history } : {}),\n });\n setTurns((all) => [...all, { id, question: trimmed, answer: data, error: null }]);\n setQuestion('');\n onAnswer(data);\n } catch (e) {\n const message = sqlErrorMessage(e);\n setTurns((all) => [...all, { id, question: trimmed, answer: null, error: message }]);\n onError(message);\n }\n };\n\n const askSuggestion = (text: string) => {\n setQuestion(text);\n void submit(text);\n };\n\n const shownSuggestions = suggestionsToShow(turns, suggestions.data);\n const governedLabel = tr('semanticfed.queryConsole.ask.governed', '(governed)');\n\n return (\n <Card data-testid=\"nl-ask-panel\">\n <AskPanelHeader\n hasTurns={turns.length > 0}\n busy={ask.isPending}\n showSettings={showSettings}\n onNewConversation={() => setTurns([])}\n onToggleSettings={() => setShowSettings((v) => !v)}\n tr={tr}\n />\n <CardContent className=\"space-y-3\">\n {showSettings && <NlAssistSettings />}\n\n {turns.length > 0 && (\n <ol className=\"space-y-3\" data-testid=\"nl-ask-thread\" aria-live=\"polite\">\n {turns.map((turn, index) => (\n <ConversationTurn\n key={turn.id}\n turn={turn}\n latest={index === turns.length - 1}\n governedLabel={governedLabel}\n onOpenInEditor={onOpenInEditor}\n tr={tr}\n />\n ))}\n </ol>\n )}\n\n <AskForm\n question={question}\n onQuestionChange={setQuestion}\n onSubmit={() => void submit(question)}\n isFollowUp={turns.length > 0}\n disabled={!modelId}\n busy={ask.isPending}\n tr={tr}\n />\n\n {shownSuggestions.length > 0 && (\n <div className=\"flex flex-wrap gap-2\" data-testid=\"nl-ask-suggestions\">\n {shownSuggestions.map((text) => (\n <button\n key={text}\n type=\"button\"\n className=\"rounded-full border px-3 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground\"\n onClick={() => askSuggestion(text)}\n disabled={ask.isPending}\n >\n {text}\n </button>\n ))}\n </div>\n )}\n </CardContent>\n </Card>\n );\n}\n"],"mappings":";;;;;;;;;;;AA4BA,IAAMA,IAAsB,KAEtBC,IAAmB;AAYzB,SAASC,EAAY,GAAwB;CAI3C,OAHIC,KAAU,OAAoC,SAC9C,OAAOA,KAAU,WAAiB,IAAIA,EAAM,KAC5C,OAAOA,KAAU,WAAiB,KAAK,UAAUA,CAAK,IACnD,OAAOA,CAAK;AACrB;AAGA,SAASC,EAAa,GAAiB,GAA+B;CACpE,IAAMC,IAAS,CAACC,EAAK,QAAQA,EAAK,KAAK,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CACjE,QAAQA,EAAK,MAAb;EACE,KAAK,WACH,OAAO,GAAGA,EAAK,eAAe,GAAG,GAAGD,EAAO,GAAGC,EAAK,WAAW,IAAIC,MAAkB;EACtF,KAAK,UACH,OAAO,GAAGF,EAAO,GAAGC,EAAK,YAAY,IAAI,GAAGJ,EAAYI,EAAK,KAAK;EACpE,KAAK,SACH,OAAO,GAAGD,EAAO,GAAGC,EAAK,aAAa,KAAK,KAAK;EAClD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3,"file":"AskQuestionPanel.js","names":["MAX_QUESTION_LENGTH","SUGGESTION_LIMIT","formatValue","value","describeStep","target","step","governedLabel","assistNote","tr","translation","Interpretation","useTr","sql","latest","Badge","CornerDownRight","withContentKeys","key","Button","onOpenInEditor","PencilLine","Clarification","HelpCircle","ConversationTurn","turn","note","Sparkles","AskPanelHeader","CardHeader","CardTitle","MessageSquareText","hasTurns","onNewConversation","busy","RotateCcw","showSettings","onToggleSettings","AskForm","onSubmit","question","onQuestionChange","isFollowUp","disabled","Loader2","Send","suggestionsToShow","turns","examples","AskQuestionPanel","setQuestion","useState","setTurns","conversationModel","setConversationModel","modelId","setShowSettings","nextTurnId","useRef","suggestions","useSemNlSuggestions","ask","useSemAskQuestion","submit","trimmed","text","history","conversationHistory","id","data","all","onAnswer","message","sqlErrorMessage","onError","askSuggestion","shownSuggestions","Card","v","CardContent","NlAssistSettings","index"],"sources":["../../../src/semanticfed/components/AskQuestionPanel.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { Badge, Button, Card, CardContent, CardHeader, CardTitle } from '@burdenoff/fe-libs/ui';\nimport {\n CornerDownRight,\n HelpCircle,\n Loader2,\n MessageSquareText,\n PencilLine,\n RotateCcw,\n Send,\n Sparkles,\n} from 'lucide-react';\n\nimport {\n type SemNlAnswer,\n type SemNlAssistStatus,\n type SemNlStep,\n type SemNlTranslation,\n useSemAskQuestion,\n useSemNlSuggestions,\n} from '../hooks/useNlQuery';\nimport { NlAssistSettings } from './NlAssistSettings';\nimport { conversationHistory, type Turn } from './askConversation';\nimport { withContentKeys } from '../utils/contentKeys';\nimport { sqlErrorMessage } from '../hooks/useSqlConsole';\nimport { useTr } from '../hooks/useTr';\n\n/** Longest question the service accepts (MAX_QUESTION_LENGTH in wspace-semanticfed-svc). */\nconst MAX_QUESTION_LENGTH = 1000;\n/** Example questions shown under the input. */\nconst SUGGESTION_LIMIT = 6;\nexport interface AskQuestionPanelProps {\n modelId: string | null;\n maxRows: number;\n /** Called with every answer, so the page can show its governed result rows. */\n onAnswer: (answer: SemNlAnswer) => void;\n /** Called when a question fails before it is answered (network, quota, access). */\n onError: (message: string) => void;\n /** Open the generated SQL in the console's editor for review or editing. */\n onOpenInEditor: (sql: string) => void;\n}\n\nfunction formatValue(value: unknown): string {\n if (value === null || value === undefined) return 'NULL';\n if (typeof value === 'string') return `'${value}'`;\n if (typeof value === 'object') return JSON.stringify(value);\n return String(value);\n}\n\n/** One interpretation step as a short phrase, e.g. \"SUM(revenue) (governed)\". */\nfunction describeStep(step: SemNlStep, governedLabel: string): string {\n const target = [step.entity, step.field].filter(Boolean).join('.');\n switch (step.kind) {\n case 'MEASURE':\n return `${step.aggregation ?? ''}(${target})${step.governed ? ` ${governedLabel}` : ''}`;\n case 'FILTER':\n return `${target} ${step.operator ?? '='} ${formatValue(step.value)}`;\n case 'ORDER':\n return `${target} ${step.direction ?? ''}`.trim();\n case 'LIMIT':\n return String(step.count ?? '');\n case 'JOIN':\n return step.relationship ? `${target} (${step.relationship})` : target;\n default:\n return target;\n }\n}\n\n/** A short, translated note on whether and how the workspace's AI provider helped. */\nfunction assistNote(\n translation: SemNlTranslation,\n tr: ReturnType<typeof useTr>\n): { text: string; tone: 'info' | 'warn' } | null {\n const provider = translation.assistProvider ?? '';\n const notes: Partial<Record<SemNlAssistStatus, { text: string; tone: 'info' | 'warn' }>> = {\n REPHRASED: {\n text: tr(\n 'semanticfed.queryConsole.ask.assist.rephrased',\n 'Reworded by your AI provider ({provider}) as: “{question}”',\n {\n provider,\n question: translation.rephrasedQuestion ?? '',\n }\n ),\n tone: 'info',\n },\n NO_IMPROVEMENT: {\n text: tr(\n 'semanticfed.queryConsole.ask.assist.noImprovement',\n 'Your AI provider could not reword this question into one the model can answer.'\n ),\n tone: 'warn',\n },\n QUOTA_EXHAUSTED: {\n text: tr(\n 'semanticfed.queryConsole.ask.assist.quota',\n 'AI assistance is paused: this workspace has used today’s AI operations.'\n ),\n tone: 'warn',\n },\n QUOTA_UNAVAILABLE: {\n text: tr(\n 'semanticfed.queryConsole.ask.assist.quotaUnavailable',\n 'AI assistance is unavailable: the AI-operation allowance for this workspace could not be checked.'\n ),\n tone: 'warn',\n },\n PROVIDER_ERROR: {\n text: tr(\n 'semanticfed.queryConsole.ask.assist.providerError',\n 'Your AI provider could not be used for this question (it was unreachable, refused the key, or returned an error).'\n ),\n tone: 'warn',\n },\n NOT_CONFIGURED: {\n text: tr(\n 'semanticfed.queryConsole.ask.assist.notConfigured',\n 'AI assistance is on, but its provider connection is missing or revoked. Choose a connection under AI assistance.'\n ),\n tone: 'warn',\n },\n };\n return notes[translation.assist] ?? null;\n}\n\n/** Steps, SQL and ignored words of a translated question. */\nfunction Interpretation({\n translation,\n governedLabel,\n onOpenInEditor,\n latest,\n}: {\n translation: SemNlTranslation;\n governedLabel: string;\n onOpenInEditor: (sql: string) => void;\n latest: boolean;\n}) {\n const tr = useTr();\n const sql = (\n <pre\n className=\"overflow-x-auto rounded bg-muted p-3 font-mono text-xs text-foreground\"\n data-testid={latest ? 'nl-ask-sql' : undefined}\n >\n {translation.sql}\n </pre>\n );\n return (\n <div\n className=\"space-y-2 rounded border p-3\"\n data-testid={latest ? 'nl-ask-interpretation' : undefined}\n >\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <div className=\"flex flex-wrap items-center gap-2 text-xs\">\n <span className=\"font-medium\">\n {tr('semanticfed.queryConsole.ask.interpretation', 'Interpretation')}\n </span>\n {translation.followUp && (\n <Badge variant=\"outline\" data-testid={latest ? 'nl-ask-followup' : undefined}>\n <CornerDownRight className=\"me-1 h-3 w-3 rtl:-scale-x-100\" />\n {tr('semanticfed.queryConsole.ask.followUp', 'Follow-up')}\n </Badge>\n )}\n <Badge variant=\"outline\" data-testid={latest ? 'nl-ask-confidence' : undefined}>\n {tr('semanticfed.queryConsole.ask.confidence', 'Confidence {value}%', {\n value: Math.round(translation.confidence * 100),\n })}\n </Badge>\n {withContentKeys(\n translation.steps,\n (step) => `${step.kind}:${describeStep(step, governedLabel)}`\n ).map(({ key, item: step }) => (\n <Badge key={key} variant=\"secondary\" className=\"font-mono\">\n {step.kind.replace('_', ' ')}: {describeStep(step, governedLabel)}\n </Badge>\n ))}\n </div>\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => onOpenInEditor(translation.sql ?? '')}\n data-testid={latest ? 'nl-ask-open-editor' : undefined}\n >\n <PencilLine className=\"me-2 h-4 w-4\" />\n {tr('semanticfed.queryConsole.ask.openInEditor', 'Edit as SQL')}\n </Button>\n </div>\n {latest ? (\n sql\n ) : (\n <details>\n <summary className=\"cursor-pointer text-xs text-muted-foreground\">\n {tr('semanticfed.queryConsole.ask.showSql', 'Show SQL')}\n </summary>\n {sql}\n </details>\n )}\n {translation.unmatchedTerms.length > 0 && (\n <p className=\"text-xs text-muted-foreground\">\n {tr('semanticfed.queryConsole.ask.ignored', 'Ignored words: {terms}', {\n terms: translation.unmatchedTerms.join(', '),\n })}\n </p>\n )}\n </div>\n );\n}\n\ntype Tr = ReturnType<typeof useTr>;\n\n/** The service's request for a clearer question, with the words it could not place. */\nfunction Clarification({\n translation,\n latest,\n tr,\n}: {\n translation: SemNlTranslation;\n latest: boolean;\n tr: Tr;\n}) {\n return (\n <div\n className=\"flex items-start gap-2 rounded border border-dashed p-3 text-sm\"\n data-testid={latest ? 'nl-ask-clarification' : undefined}\n >\n <HelpCircle className=\"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground\" />\n <div className=\"min-w-0 space-y-1\">\n <p>{translation.clarification}</p>\n {translation.unmatchedTerms.length > 0 && (\n <p className=\"text-xs text-muted-foreground\">\n {tr('semanticfed.queryConsole.ask.unmatched', 'Not found in the model: {terms}', {\n terms: translation.unmatchedTerms.join(', '),\n })}\n </p>\n )}\n </div>\n </div>\n );\n}\n\n/** One question of the thread with its error, AI note, clarification or interpretation. */\nfunction ConversationTurn({\n turn,\n latest,\n governedLabel,\n onOpenInEditor,\n tr,\n}: {\n turn: Turn;\n latest: boolean;\n governedLabel: string;\n onOpenInEditor: (sql: string) => void;\n tr: Tr;\n}) {\n const translation = turn.answer?.translation ?? null;\n const note = translation ? assistNote(translation, tr) : null;\n return (\n <li className=\"space-y-2\" data-testid=\"nl-ask-turn\">\n <p className=\"w-fit max-w-full rounded-lg bg-muted px-3 py-2 text-sm\">{turn.question}</p>\n {turn.error && <p className=\"text-xs text-destructive\">{turn.error}</p>}\n {note && (\n <p\n className={`flex items-start gap-1 text-xs ${note.tone === 'warn' ? 'text-muted-foreground' : 'text-primary'}`}\n data-testid={latest ? 'nl-ask-assist-note' : undefined}\n >\n <Sparkles className=\"mt-0.5 h-3 w-3 shrink-0\" />\n {note.text}\n </p>\n )}\n {translation?.status === 'NEEDS_CLARIFICATION' && (\n <Clarification translation={translation} latest={latest} tr={tr} />\n )}\n {translation?.status === 'TRANSLATED' && translation.sql && (\n <Interpretation\n translation={translation}\n governedLabel={governedLabel}\n onOpenInEditor={onOpenInEditor}\n latest={latest}\n />\n )}\n </li>\n );\n}\n\n/** Title row: start a new conversation and open the AI-assistance settings. */\nfunction AskPanelHeader({\n hasTurns,\n busy,\n showSettings,\n onNewConversation,\n onToggleSettings,\n tr,\n}: {\n hasTurns: boolean;\n busy: boolean;\n showSettings: boolean;\n onNewConversation: () => void;\n onToggleSettings: () => void;\n tr: Tr;\n}) {\n return (\n <CardHeader className=\"pb-3\">\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <CardTitle className=\"flex items-center gap-2 text-base\">\n <MessageSquareText className=\"h-4 w-4\" />\n {tr('semanticfed.queryConsole.ask.title', 'Ask a question')}\n </CardTitle>\n <div className=\"flex flex-wrap gap-2\">\n {hasTurns && (\n <Button\n size=\"sm\"\n variant=\"ghost\"\n onClick={onNewConversation}\n disabled={busy}\n data-testid=\"nl-ask-new-conversation\"\n >\n <RotateCcw className=\"me-2 h-4 w-4\" />\n {tr('semanticfed.queryConsole.ask.newConversation', 'New conversation')}\n </Button>\n )}\n <Button\n size=\"sm\"\n variant={showSettings ? 'secondary' : 'ghost'}\n onClick={onToggleSettings}\n aria-expanded={showSettings}\n data-testid=\"nl-assist-toggle\"\n >\n <Sparkles className=\"me-2 h-4 w-4\" />\n {tr('semanticfed.queryConsole.ask.assistSettings', 'AI assistance')}\n </Button>\n </div>\n </div>\n <p className=\"text-xs text-muted-foreground\">\n {tr(\n 'semanticfed.queryConsole.ask.conversationDescription',\n 'Ask in plain English, then refine with follow-ups such as “and by status?”, “only EU” or “top 3 instead”. Answers come from the model’s governed metrics and dimensions, with your access policies applied, and the SQL that ran is shown.'\n )}\n </p>\n </CardHeader>\n );\n}\n\n/** The question input and its submit button. */\nfunction AskForm({\n question,\n onQuestionChange,\n onSubmit,\n isFollowUp,\n disabled,\n busy,\n tr,\n}: {\n question: string;\n onQuestionChange: (value: string) => void;\n onSubmit: () => void;\n isFollowUp: boolean;\n disabled: boolean;\n busy: boolean;\n tr: Tr;\n}) {\n return (\n <form\n className=\"flex flex-col gap-2 sm:flex-row\"\n onSubmit={(e) => {\n e.preventDefault();\n onSubmit();\n }}\n >\n <label className=\"sr-only\" htmlFor=\"nl-ask-input\">\n {tr('semanticfed.queryConsole.ask.inputLabel', 'Your question')}\n </label>\n <input\n id=\"nl-ask-input\"\n data-testid=\"nl-ask-input\"\n className=\"min-w-0 flex-1 rounded border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary\"\n value={question}\n maxLength={MAX_QUESTION_LENGTH}\n onChange={(e) => onQuestionChange(e.target.value)}\n placeholder={\n isFollowUp\n ? tr(\n 'semanticfed.queryConsole.ask.followUpPlaceholder',\n 'Ask a follow-up, e.g. and by status?'\n )\n : tr('semanticfed.queryConsole.ask.placeholder', 'e.g. top 5 regions by revenue')\n }\n disabled={disabled}\n />\n <Button\n type=\"submit\"\n size=\"sm\"\n className=\"sm:self-stretch\"\n disabled={disabled || question.trim() === '' || busy}\n data-testid=\"nl-ask-submit\"\n >\n {busy ? (\n <Loader2 className=\"me-2 h-4 w-4 animate-spin\" />\n ) : (\n <Send className=\"me-2 h-4 w-4\" />\n )}\n {tr('semanticfed.queryConsole.ask.submit', 'Ask')}\n </Button>\n </form>\n );\n}\n\n/**\n * The example questions to offer: the service's suggestions while it asks\n * for clarification, the model's examples before the first question, and\n * none during a conversation.\n */\nfunction suggestionsToShow(turns: Turn[], examples: string[] | undefined): string[] {\n const translation = turns.at(-1)?.answer?.translation ?? null;\n if (translation?.status === 'NEEDS_CLARIFICATION') {\n return translation.suggestions.slice(0, SUGGESTION_LIMIT);\n }\n return turns.length === 0 ? (examples ?? []).slice(0, SUGGESTION_LIMIT) : [];\n}\n\n/**\n * \"Ask a question\" — natural-language questions over the semantic layer\n * (BOFF-4276), as a conversation (BOFF-10533). Each question is translated\n * into SQL over the model's governed metrics and dimensions and run with the\n * caller's access policies; a follow-up (\"and by status?\", \"only EU\", \"top 3\n * instead\") refines the previous answers. The interpretation (generated SQL,\n * steps, confidence, ignored words, and any AI rewording) is always shown so\n * the answer can be checked, and opened in the SQL editor.\n */\nexport function AskQuestionPanel({\n modelId,\n maxRows,\n onAnswer,\n onError,\n onOpenInEditor,\n}: AskQuestionPanelProps) {\n const tr = useTr();\n const [question, setQuestion] = useState('');\n const [turns, setTurns] = useState<Turn[]>([]);\n const [conversationModel, setConversationModel] = useState<string | null>(modelId);\n const [showSettings, setShowSettings] = useState(false);\n const nextTurnId = useRef(0);\n const suggestions = useSemNlSuggestions(modelId);\n const ask = useSemAskQuestion();\n\n // A conversation belongs to one model: switching models starts a new one.\n if (conversationModel !== modelId) {\n setConversationModel(modelId);\n setTurns([]);\n }\n\n const submit = async (text: string) => {\n const trimmed = text.trim();\n if (!modelId || trimmed === '' || ask.isPending) return;\n const history = conversationHistory(turns);\n nextTurnId.current += 1;\n const id = nextTurnId.current;\n try {\n const data = await ask.mutateAsync({\n question: trimmed,\n modelId,\n maxRows,\n ...(history.length > 0 ? { history } : {}),\n });\n setTurns((all) => [...all, { id, question: trimmed, answer: data, error: null }]);\n setQuestion('');\n onAnswer(data);\n } catch (e) {\n const message = sqlErrorMessage(e, tr);\n setTurns((all) => [...all, { id, question: trimmed, answer: null, error: message }]);\n onError(message);\n }\n };\n\n const askSuggestion = (text: string) => {\n setQuestion(text);\n void submit(text);\n };\n\n const shownSuggestions = suggestionsToShow(turns, suggestions.data);\n const governedLabel = tr('semanticfed.queryConsole.ask.governed', '(governed)');\n\n return (\n <Card data-testid=\"nl-ask-panel\">\n <AskPanelHeader\n hasTurns={turns.length > 0}\n busy={ask.isPending}\n showSettings={showSettings}\n onNewConversation={() => setTurns([])}\n onToggleSettings={() => setShowSettings((v) => !v)}\n tr={tr}\n />\n <CardContent className=\"space-y-3\">\n {showSettings && <NlAssistSettings />}\n\n {turns.length > 0 && (\n <ol className=\"space-y-3\" data-testid=\"nl-ask-thread\" aria-live=\"polite\">\n {turns.map((turn, index) => (\n <ConversationTurn\n key={turn.id}\n turn={turn}\n latest={index === turns.length - 1}\n governedLabel={governedLabel}\n onOpenInEditor={onOpenInEditor}\n tr={tr}\n />\n ))}\n </ol>\n )}\n\n <AskForm\n question={question}\n onQuestionChange={setQuestion}\n onSubmit={() => void submit(question)}\n isFollowUp={turns.length > 0}\n disabled={!modelId}\n busy={ask.isPending}\n tr={tr}\n />\n\n {shownSuggestions.length > 0 && (\n <div className=\"flex flex-wrap gap-2\" data-testid=\"nl-ask-suggestions\">\n {shownSuggestions.map((text) => (\n <button\n key={text}\n type=\"button\"\n className=\"rounded-full border px-3 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground\"\n onClick={() => askSuggestion(text)}\n disabled={ask.isPending}\n >\n {text}\n </button>\n ))}\n </div>\n )}\n </CardContent>\n </Card>\n );\n}\n"],"mappings":";;;;;;;;;;;AA4BA,IAAMA,IAAsB,KAEtBC,IAAmB;AAYzB,SAASC,EAAY,GAAwB;CAI3C,OAHIC,KAAU,OAAoC,SAC9C,OAAOA,KAAU,WAAiB,IAAIA,EAAM,KAC5C,OAAOA,KAAU,WAAiB,KAAK,UAAUA,CAAK,IACn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IACC,CAAA;IAGN,kBAACa,GAAD;KACY;KACV,kBAAkBY;KAClB,gBAAgB,KAAKa,EAAOvB,CAAQ;KACpC,YAAYO,EAAM,SAAS;KAC3B,UAAU,CAACQ;KACX,MAAMM,EAAI;KACN;IACL,CAAA;IAEAe,EAAiB,SAAS,KACzB,kBAAC,OAAD;KAAK,WAAU;KAAuB,eAAY;KAC/C,UAAAA,EAAiB,KAAK,MACrB,kBAAC,UAAD;MAEE,MAAK;MACL,WAAU;MACV,eAAeD,EAAcV,CAAI;MACjC,UAAUJ,EAAI;MAEb,UAAAI;KACK,GAPDA,CAOC,CACT;IACE,CAAA;GAEI;EACT,CAAA,CAAA;;AAEV"}
|
|
@@ -14,7 +14,7 @@ function p() {
|
|
|
14
14
|
}) : n.isError || !n.data ? /* @__PURE__ */ u("p", {
|
|
15
15
|
className: "text-xs text-destructive",
|
|
16
16
|
"data-testid": "nl-assist-settings-error",
|
|
17
|
-
children: r(n.error)
|
|
17
|
+
children: r(n.error, e)
|
|
18
18
|
}) : /* @__PURE__ */ u(m, { initial: n.data }, n.data.updatedAt ?? "unsaved");
|
|
19
19
|
}
|
|
20
20
|
function m({ initial: t }) {
|
|
@@ -32,7 +32,7 @@ function m({ initial: t }) {
|
|
|
32
32
|
} catch (e) {
|
|
33
33
|
C({
|
|
34
34
|
ok: !1,
|
|
35
|
-
text: r(e)
|
|
35
|
+
text: r(e, p)
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
}, D = h.isSuccess && h.data.length === 0;
|
|
@@ -109,7 +109,7 @@ function m({ initial: t }) {
|
|
|
109
109
|
}),
|
|
110
110
|
h.isError && /* @__PURE__ */ u("p", {
|
|
111
111
|
className: "text-xs text-destructive",
|
|
112
|
-
children: r(h.error)
|
|
112
|
+
children: r(h.error, p)
|
|
113
113
|
}),
|
|
114
114
|
/* @__PURE__ */ d("div", {
|
|
115
115
|
className: "flex flex-wrap items-center gap-2",
|
|
@@ -119,7 +119,7 @@ function m({ initial: t }) {
|
|
|
119
119
|
onClick: () => void E(),
|
|
120
120
|
disabled: m.isPending,
|
|
121
121
|
"data-testid": "nl-assist-save",
|
|
122
|
-
children: [m.isPending ? /* @__PURE__ */ u(s, { className: "
|
|
122
|
+
children: [m.isPending ? /* @__PURE__ */ u(s, { className: "me-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ u(c, { className: "me-2 h-4 w-4" }), p("semanticfed.queryConsole.assist.save", "Save")]
|
|
123
123
|
}),
|
|
124
124
|
/* @__PURE__ */ d("a", {
|
|
125
125
|
className: "inline-flex items-center gap-1 text-xs text-primary hover:underline",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NlAssistSettings.js","names":["NlAssistSettings","tr","useTr","settings","useSemNlSettings","Loader2","sqlErrorMessage","NlAssistForm","update","useSemUpdateNlSettings","connections","useSemAiConnections","initial","enabled","setEnabled","useState","connectionId","setConnectionId","model","setModel","message","setMessage","selected","c","defaultModel","save","noConnections","Sparkles","Button","Save","ExternalLink"],"sources":["../../../src/semanticfed/components/NlAssistSettings.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { ExternalLink, Loader2, Save, Sparkles } from 'lucide-react';\n\nimport {\n type SemNlSettings,\n useSemAiConnections,\n useSemNlSettings,\n useSemUpdateNlSettings,\n} from '../hooks/useNlQuery';\nimport { sqlErrorMessage } from '../hooks/useSqlConsole';\nimport { useTr } from '../hooks/useTr';\n\n/**\n * LLM-assisted phrasing settings (BOFF-10533). When it is on, a question the\n * deterministic translator cannot answer is reworded by the workspace's own AI\n * provider (bring your own key) and translated again. The key lives in the\n * workspace's Integrations connection; SemanticFed stores only which\n * connection to use. Saving needs the governance permission that manages\n * access policies.\n */\nexport function NlAssistSettings() {\n const tr = useTr();\n const settings = useSemNlSettings();\n\n if (settings.isLoading) {\n return (\n <div className=\"flex items-center gap-2 text-xs text-muted-foreground\">\n <Loader2 className=\"h-3 w-3 animate-spin\" />\n {tr('semanticfed.queryConsole.assist.loading', 'Loading AI assistance settings…')}\n </div>\n );\n }\n if (settings.isError || !settings.data) {\n return (\n <p className=\"text-xs text-destructive\" data-testid=\"nl-assist-settings-error\">\n {sqlErrorMessage(settings.error)}\n </p>\n );\n }\n // Re-mount the form when saved settings change, so it starts from them.\n return <NlAssistForm key={settings.data.updatedAt ?? 'unsaved'} initial={settings.data} />;\n}\n\nfunction NlAssistForm({ initial }: { initial: SemNlSettings }) {\n const tr = useTr();\n const update = useSemUpdateNlSettings();\n const connections = useSemAiConnections(true, initial.supportedProviders);\n\n const [enabled, setEnabled] = useState(initial.llmAssistEnabled);\n const [connectionId, setConnectionId] = useState(initial.aiConnectionId ?? '');\n const [model, setModel] = useState(initial.aiModel ?? '');\n const [message, setMessage] = useState<{ ok: boolean; text: string } | null>(null);\n\n const selected = connections.data?.find((c) => c.id === connectionId) ?? null;\n const defaultModel =\n selected?.providerKey === 'anthropic'\n ? 'claude-opus-5-5'\n : selected?.providerKey === 'openai'\n ? 'gpt-4o-mini'\n : (initial.defaultAiModel ?? '');\n\n const save = async () => {\n setMessage(null);\n try {\n await update.mutateAsync({\n llmAssistEnabled: enabled,\n aiConnectionId: connectionId || null,\n aiModel: model.trim() || null,\n });\n setMessage({\n ok: true,\n text: tr('semanticfed.queryConsole.assist.saved', 'Settings saved.'),\n });\n } catch (e) {\n setMessage({ ok: false, text: sqlErrorMessage(e) });\n }\n };\n\n const noConnections = connections.isSuccess && connections.data.length === 0;\n\n return (\n <div className=\"space-y-3 rounded border p-3 text-sm\" data-testid=\"nl-assist-settings\">\n <div className=\"flex items-start gap-2\">\n <Sparkles className=\"mt-0.5 h-4 w-4 shrink-0 text-primary\" />\n <div className=\"min-w-0 space-y-1\">\n <p className=\"font-medium\">\n {tr('semanticfed.queryConsole.assist.title', 'AI assistance (bring your own key)')}\n </p>\n <p className=\"text-xs text-muted-foreground\">\n {tr(\n 'semanticfed.queryConsole.assist.description',\n 'When a question cannot be matched to the model, your own OpenAI or Anthropic key rewords it with the model’s names and it is translated again. The AI never writes or runs SQL. Only the model’s names, descriptions and your questions are sent, never data rows. Each rewrite counts as one AI operation.'\n )}\n </p>\n </div>\n </div>\n\n <label className=\"flex items-center gap-2 text-sm\">\n <input\n type=\"checkbox\"\n checked={enabled}\n onChange={(e) => setEnabled(e.target.checked)}\n data-testid=\"nl-assist-enabled\"\n />\n {tr(\n 'semanticfed.queryConsole.assist.enable',\n 'Reword unmatched questions with my AI provider'\n )}\n </label>\n\n <div className=\"grid gap-2 sm:grid-cols-2\">\n <label className=\"space-y-1 text-xs\">\n <span className=\"text-muted-foreground\">\n {tr('semanticfed.queryConsole.assist.connection', 'AI provider connection')}\n </span>\n <select\n className=\"w-full rounded border bg-background px-2 py-1.5 text-sm\"\n value={connectionId}\n onChange={(e) => setConnectionId(e.target.value)}\n data-testid=\"nl-assist-connection\"\n >\n <option value=\"\">{tr('semanticfed.queryConsole.assist.noConnection', 'None')}</option>\n {(connections.data ?? []).map((c) => (\n <option key={c.id} value={c.id}>\n {c.name} ({c.providerName || c.providerKey})\n </option>\n ))}\n </select>\n </label>\n <label className=\"space-y-1 text-xs\">\n <span className=\"text-muted-foreground\">\n {tr('semanticfed.queryConsole.assist.model', 'Model (optional)')}\n </span>\n <input\n className=\"w-full rounded border bg-background px-2 py-1.5 text-sm\"\n value={model}\n maxLength={128}\n onChange={(e) => setModel(e.target.value)}\n placeholder={defaultModel}\n data-testid=\"nl-assist-model\"\n />\n </label>\n </div>\n\n {noConnections && (\n <p className=\"text-xs text-muted-foreground\" data-testid=\"nl-assist-no-connections\">\n {tr(\n 'semanticfed.queryConsole.assist.connectFirst',\n 'No OpenAI or Anthropic connection yet. Add one in Integrations, then choose it here.'\n )}\n </p>\n )}\n {connections.isError && (\n <p className=\"text-xs text-destructive\">{sqlErrorMessage(connections.error)}</p>\n )}\n\n <div className=\"flex flex-wrap items-center gap-2\">\n <Button\n size=\"sm\"\n onClick={() => void save()}\n disabled={update.isPending}\n data-testid=\"nl-assist-save\"\n >\n {update.isPending ? (\n <Loader2 className=\"mr-2 h-4 w-4 animate-spin\" />\n ) : (\n <Save className=\"mr-2 h-4 w-4\" />\n )}\n {tr('semanticfed.queryConsole.assist.save', 'Save')}\n </Button>\n <a\n className=\"inline-flex items-center gap-1 text-xs text-primary hover:underline\"\n href=\"/integrations\"\n >\n <ExternalLink className=\"h-3 w-3\" />\n {tr('semanticfed.queryConsole.assist.manageConnections', 'Manage connections')}\n </a>\n {message && (\n <span\n className={`text-xs ${message.ok ? 'text-muted-foreground' : 'text-destructive'}`}\n data-testid=\"nl-assist-message\"\n role=\"status\"\n >\n {message.text}\n </span>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAqBA,SAAgBA,IAAmB;CACjC,IAAMC,IAAKC,EAAM,GACXC,IAAWC,EAAiB;CAkBlC,OAhBID,EAAS,YAET,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACE,GAAD,EAAS,WAAU,uBAAwB,CAAA,GAC1CJ,EAAG,2CAA2C,iCAAiC,CAC7E;C,KAGLE,EAAS,WAAW,CAACA,EAAS,OAE9B,kBAAC,KAAD;EAAG,WAAU;EAA2B,eAAY;EACjD,UAAAG,EAAgBH,EAAS,KAAK;CAC9B,CAAA,IAIA,kBAACI,GAAD,EAAyD,SAASJ,EAAS,KAAO,GAA/DA,EAAS,KAAK,aAAa,SAAoC;AAC3F;AAEA,SAASI,EAAa,EAAE,cAAuC;CAC7D,IAAMN,IAAKC,EAAM,GACXM,IAASC,EAAuB,GAChCC,IAAcC,EAAoB,IAAMC,EAAQ,kBAAkB,GAElE,CAACC,GAASC,KAAcC,EAASH,EAAQ,gBAAgB,GACzD,CAACI,GAAcC,KAAmBF,EAASH,EAAQ,kBAAkB,EAAE,GACvE,CAACM,GAAOC,KAAYJ,EAASH,EAAQ,WAAW,EAAE,GAClD,CAACQ,GAASC,KAAcN,EAA+C,IAAI,GAE3EO,IAAWZ,EAAY,MAAM,MAAM,MAAMa,E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AAqD,oBAAoB,CAC5E;;KACFmB,KACC,kBAAC,QAAD;MACE,WAAW,WAAWA,EAAQ,KAAK,0BAA0B;MAC7D,eAAY;MACZ,MAAK;MAEJ,UAAAA,EAAQ;KACL,CAAA;IAEL;;EACF;;AAET"}
|
|
1
|
+
{"version":3,"file":"NlAssistSettings.js","names":["NlAssistSettings","tr","useTr","settings","useSemNlSettings","Loader2","sqlErrorMessage","NlAssistForm","update","useSemUpdateNlSettings","connections","useSemAiConnections","initial","enabled","setEnabled","useState","connectionId","setConnectionId","model","setModel","message","setMessage","selected","c","defaultModel","save","noConnections","Sparkles","Button","Save","ExternalLink"],"sources":["../../../src/semanticfed/components/NlAssistSettings.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { ExternalLink, Loader2, Save, Sparkles } from 'lucide-react';\n\nimport {\n type SemNlSettings,\n useSemAiConnections,\n useSemNlSettings,\n useSemUpdateNlSettings,\n} from '../hooks/useNlQuery';\nimport { sqlErrorMessage } from '../hooks/useSqlConsole';\nimport { useTr } from '../hooks/useTr';\n\n/**\n * LLM-assisted phrasing settings (BOFF-10533). When it is on, a question the\n * deterministic translator cannot answer is reworded by the workspace's own AI\n * provider (bring your own key) and translated again. The key lives in the\n * workspace's Integrations connection; SemanticFed stores only which\n * connection to use. Saving needs the governance permission that manages\n * access policies.\n */\nexport function NlAssistSettings() {\n const tr = useTr();\n const settings = useSemNlSettings();\n\n if (settings.isLoading) {\n return (\n <div className=\"flex items-center gap-2 text-xs text-muted-foreground\">\n <Loader2 className=\"h-3 w-3 animate-spin\" />\n {tr('semanticfed.queryConsole.assist.loading', 'Loading AI assistance settings…')}\n </div>\n );\n }\n if (settings.isError || !settings.data) {\n return (\n <p className=\"text-xs text-destructive\" data-testid=\"nl-assist-settings-error\">\n {sqlErrorMessage(settings.error, tr)}\n </p>\n );\n }\n // Re-mount the form when saved settings change, so it starts from them.\n return <NlAssistForm key={settings.data.updatedAt ?? 'unsaved'} initial={settings.data} />;\n}\n\nfunction NlAssistForm({ initial }: { initial: SemNlSettings }) {\n const tr = useTr();\n const update = useSemUpdateNlSettings();\n const connections = useSemAiConnections(true, initial.supportedProviders);\n\n const [enabled, setEnabled] = useState(initial.llmAssistEnabled);\n const [connectionId, setConnectionId] = useState(initial.aiConnectionId ?? '');\n const [model, setModel] = useState(initial.aiModel ?? '');\n const [message, setMessage] = useState<{ ok: boolean; text: string } | null>(null);\n\n const selected = connections.data?.find((c) => c.id === connectionId) ?? null;\n const defaultModel =\n selected?.providerKey === 'anthropic'\n ? 'claude-opus-5-5'\n : selected?.providerKey === 'openai'\n ? 'gpt-4o-mini'\n : (initial.defaultAiModel ?? '');\n\n const save = async () => {\n setMessage(null);\n try {\n await update.mutateAsync({\n llmAssistEnabled: enabled,\n aiConnectionId: connectionId || null,\n aiModel: model.trim() || null,\n });\n setMessage({\n ok: true,\n text: tr('semanticfed.queryConsole.assist.saved', 'Settings saved.'),\n });\n } catch (e) {\n setMessage({ ok: false, text: sqlErrorMessage(e, tr) });\n }\n };\n\n const noConnections = connections.isSuccess && connections.data.length === 0;\n\n return (\n <div className=\"space-y-3 rounded border p-3 text-sm\" data-testid=\"nl-assist-settings\">\n <div className=\"flex items-start gap-2\">\n <Sparkles className=\"mt-0.5 h-4 w-4 shrink-0 text-primary\" />\n <div className=\"min-w-0 space-y-1\">\n <p className=\"font-medium\">\n {tr('semanticfed.queryConsole.assist.title', 'AI assistance (bring your own key)')}\n </p>\n <p className=\"text-xs text-muted-foreground\">\n {tr(\n 'semanticfed.queryConsole.assist.description',\n 'When a question cannot be matched to the model, your own OpenAI or Anthropic key rewords it with the model’s names and it is translated again. The AI never writes or runs SQL. Only the model’s names, descriptions and your questions are sent, never data rows. Each rewrite counts as one AI operation.'\n )}\n </p>\n </div>\n </div>\n\n <label className=\"flex items-center gap-2 text-sm\">\n <input\n type=\"checkbox\"\n checked={enabled}\n onChange={(e) => setEnabled(e.target.checked)}\n data-testid=\"nl-assist-enabled\"\n />\n {tr(\n 'semanticfed.queryConsole.assist.enable',\n 'Reword unmatched questions with my AI provider'\n )}\n </label>\n\n <div className=\"grid gap-2 sm:grid-cols-2\">\n <label className=\"space-y-1 text-xs\">\n <span className=\"text-muted-foreground\">\n {tr('semanticfed.queryConsole.assist.connection', 'AI provider connection')}\n </span>\n <select\n className=\"w-full rounded border bg-background px-2 py-1.5 text-sm\"\n value={connectionId}\n onChange={(e) => setConnectionId(e.target.value)}\n data-testid=\"nl-assist-connection\"\n >\n <option value=\"\">{tr('semanticfed.queryConsole.assist.noConnection', 'None')}</option>\n {(connections.data ?? []).map((c) => (\n <option key={c.id} value={c.id}>\n {c.name} ({c.providerName || c.providerKey})\n </option>\n ))}\n </select>\n </label>\n <label className=\"space-y-1 text-xs\">\n <span className=\"text-muted-foreground\">\n {tr('semanticfed.queryConsole.assist.model', 'Model (optional)')}\n </span>\n <input\n className=\"w-full rounded border bg-background px-2 py-1.5 text-sm\"\n value={model}\n maxLength={128}\n onChange={(e) => setModel(e.target.value)}\n placeholder={defaultModel}\n data-testid=\"nl-assist-model\"\n />\n </label>\n </div>\n\n {noConnections && (\n <p className=\"text-xs text-muted-foreground\" data-testid=\"nl-assist-no-connections\">\n {tr(\n 'semanticfed.queryConsole.assist.connectFirst',\n 'No OpenAI or Anthropic connection yet. Add one in Integrations, then choose it here.'\n )}\n </p>\n )}\n {connections.isError && (\n <p className=\"text-xs text-destructive\">{sqlErrorMessage(connections.error, tr)}</p>\n )}\n\n <div className=\"flex flex-wrap items-center gap-2\">\n <Button\n size=\"sm\"\n onClick={() => void save()}\n disabled={update.isPending}\n data-testid=\"nl-assist-save\"\n >\n {update.isPending ? (\n <Loader2 className=\"me-2 h-4 w-4 animate-spin\" />\n ) : (\n <Save className=\"me-2 h-4 w-4\" />\n )}\n {tr('semanticfed.queryConsole.assist.save', 'Save')}\n </Button>\n <a\n className=\"inline-flex items-center gap-1 text-xs text-primary hover:underline\"\n href=\"/integrations\"\n >\n <ExternalLink className=\"h-3 w-3\" />\n {tr('semanticfed.queryConsole.assist.manageConnections', 'Manage connections')}\n </a>\n {message && (\n <span\n className={`text-xs ${message.ok ? 'text-muted-foreground' : 'text-destructive'}`}\n data-testid=\"nl-assist-message\"\n role=\"status\"\n >\n {message.text}\n </span>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAqBA,SAAgBA,IAAmB;CACjC,IAAMC,IAAKC,EAAM,GACXC,IAAWC,EAAiB;CAkBlC,OAhBID,EAAS,YAET,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACE,GAAD,EAAS,WAAU,uBAAwB,CAAA,GAC1CJ,EAAG,2CAA2C,iCAAiC,CAC7E;C,KAGLE,EAAS,WAAW,CAACA,EAAS,OAE9B,kBAAC,KAAD;EAAG,WAAU;EAA2B,eAAY;EACjD,UAAAG,EAAgBH,EAAS,OAAOF,CAAE;CAClC,CAAA,IAIA,kBAACM,GAAD,EAAyD,SAASJ,EAAS,KAAO,GAA/DA,EAAS,KAAK,aAAa,SAAoC;AAC3F;AAEA,SAASI,EAAa,EAAE,cAAuC;CAC7D,IAAMN,IAAKC,EAAM,GACXM,IAASC,EAAuB,GAChCC,IAAcC,EAAoB,IAAMC,EAAQ,kBAAkB,GAElE,CAACC,GAASC,KAAcC,EAASH,EAAQ,gBAAgB,GACzD,CAACI,GAAcC,KAAmBF,EAASH,EAAQ,kBAAkB,EAAE,GACvE,CAACM,GAAOC,KAAYJ,EAASH,EAAQ,WAAW,EAAE,GAClD,CAACQ,GAASC,KAAcN,EAA+C,IAAI,GAE3EO,IAAWZ,EAAY,MAAM,MAAM,MAAMa,EAAE,OAAOP,CAAY,KAAK,MACnEQ,IACJF,GAAU,gBAAgB,cACtB,oBACAA,GAAU,gBAAgB,WACxB,gBACCV,EAAQ,kBAAkB,IAE7Ba,IAAO,YAAY;EACvB,EAAW,IAAI;EACf,IAAI;GAMF,AALA,MAAMjB,EAAO,YAAY;IACvB,kBAAkBK;IAClB,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e, seedDemo: t, removeDemo: n, tr: r }) {
|
|
|
167
167
|
disabled: i,
|
|
168
168
|
onClick: () => n.mutate(),
|
|
169
169
|
"data-testid": "semanticfed-onboarding-remove-demo",
|
|
170
|
-
children: [n.isPending ? /* @__PURE__ */ S(h, { className: "
|
|
170
|
+
children: [n.isPending ? /* @__PURE__ */ S(h, { className: "me-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ S(b, { className: "me-2 h-4 w-4" }), r("semanticfed.onboarding.demo.remove", "Remove demo data")]
|
|
171
171
|
}) : /* @__PURE__ */ C(T, {
|
|
172
172
|
size: "sm",
|
|
173
173
|
disabled: i,
|
|
174
174
|
onClick: () => t.mutate(),
|
|
175
175
|
"data-testid": "semanticfed-onboarding-seed-demo",
|
|
176
|
-
children: [t.isPending ? /* @__PURE__ */ S(h, { className: "
|
|
176
|
+
children: [t.isPending ? /* @__PURE__ */ S(h, { className: "me-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ S(v, { className: "me-2 h-4 w-4" }), r("semanticfed.onboarding.demo.load", "Load demo data")]
|
|
177
177
|
}),
|
|
178
178
|
a && /* @__PURE__ */ S("p", {
|
|
179
179
|
className: "w-full text-sm text-destructive",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnboardingChecklist.js","names":["STEP_DEFINITIONS","Plug","Database","FileCode2","BarChart3","Terminal","Shield","tourId","key","ChecklistHeader","isEmptyWorkspace","data","CardHeader","CardTitle","tr","Badge","percent","Button","collapsed","onToggle","jsx","ChevronDown","ChevronUp","ProgressBar","label","StepItem","Icon","step","Link","done","CheckCircle2","Circle","DemoDataPanel","busy","seedDemo","removeDemo","error","Sparkles","present","Loader2","Trash2","ChecklistLoading","Card","CardContent","ChecklistError","onRetry","useActivationViewed","analytics","useClientAnalytics","viewedScope","useRef","progress","OnboardingChecklist","useTr","useSemOnboardingProgress","useSemSeedWorkspaceDemoData","useSemRemoveWorkspaceDemoData","setCollapsed","useState","completedByKey","value"],"sources":["../../../src/semanticfed/components/OnboardingChecklist.tsx"],"sourcesContent":["/**\n * SemanticFed getting-started checklist.\n *\n * Six first-value steps (connector → data source → model → metric → query →\n * policy). Completion comes from `semOnboardingProgress`, which the backend\n * derives from the records the workspace actually holds, so progress persists\n * across sessions and devices and demo records never tick a step. Each step\n * deep-links to the page where the user does it. The demo panel loads (or\n * removes) a clearly labelled sample workspace.\n *\n * Every element a seeded `global-tours-svc` tour points at carries a stable\n * `data-tour` selector (`semanticfed-onboarding-*`).\n */\nimport { useEffect, useRef, useState, type FC } from 'react';\nimport { useClientAnalytics } from '../hooks/useClientAnalytics';\nimport { Link } from 'react-router-dom';\nimport {\n BarChart3,\n CheckCircle2,\n ChevronDown,\n ChevronUp,\n Circle,\n Database,\n FileCode2,\n Loader2,\n Plug,\n Shield,\n Sparkles,\n Terminal,\n Trash2,\n} from 'lucide-react';\nimport { Badge, Button, Card, CardContent, CardHeader, CardTitle } from '@burdenoff/fe-libs/ui';\n\nimport { useTr } from '../hooks/useTr';\nimport {\n type SemOnboardingProgress,\n type SemOnboardingStepKey,\n useSemOnboardingProgress,\n useSemRemoveWorkspaceDemoData,\n useSemSeedWorkspaceDemoData,\n} from '../hooks/useOnboarding';\n\ninterface StepDefinition {\n key: SemOnboardingStepKey;\n /** Route relative to the SemanticFed base path. */\n path: string;\n icon: typeof Plug;\n labelKey: string;\n label: string;\n descriptionKey: string;\n description: string;\n}\n\nconst STEP_DEFINITIONS: readonly StepDefinition[] = [\n {\n key: 'REGISTER_CONNECTOR',\n path: 'registry',\n icon: Plug,\n labelKey: 'semanticfed.onboarding.steps.registerConnector.label',\n label: 'Register a connector',\n descriptionKey: 'semanticfed.onboarding.steps.registerConnector.description',\n description:\n 'Tell SemanticFed which kind of system you run, such as Postgres, Snowflake or a REST API.',\n },\n {\n key: 'ADD_DATA_SOURCE',\n path: 'topology',\n icon: Database,\n labelKey: 'semanticfed.onboarding.steps.addDataSource.label',\n label: 'Add a data source',\n descriptionKey: 'semanticfed.onboarding.steps.addDataSource.description',\n description: 'Point a connector at a specific database or API endpoint.',\n },\n {\n key: 'CREATE_MODEL',\n path: 'ontology',\n icon: FileCode2,\n labelKey: 'semanticfed.onboarding.steps.createModel.label',\n label: 'Create a semantic model',\n descriptionKey: 'semanticfed.onboarding.steps.createModel.description',\n description: 'Describe your entities and how they relate, once, across every source.',\n },\n {\n key: 'DEFINE_METRIC',\n path: 'ontology',\n icon: BarChart3,\n labelKey: 'semanticfed.onboarding.steps.defineMetric.label',\n label: 'Define a metric',\n descriptionKey: 'semanticfed.onboarding.steps.defineMetric.description',\n description: 'Give a business measure, such as revenue, a single governed definition.',\n },\n {\n key: 'RUN_QUERY',\n path: 'query-console',\n icon: Terminal,\n labelKey: 'semanticfed.onboarding.steps.runQuery.label',\n label: 'Run a federated query',\n descriptionKey: 'semanticfed.onboarding.steps.runQuery.description',\n description: 'Query the model and let SemanticFed push work down to each source.',\n },\n {\n key: 'ADD_POLICY',\n path: 'policies',\n icon: Shield,\n labelKey: 'semanticfed.onboarding.steps.addPolicy.label',\n label: 'Add an access policy',\n descriptionKey: 'semanticfed.onboarding.steps.addPolicy.description',\n description: 'Control who can read which rows, columns and entities on every query.',\n },\n];\n\nconst tourId = (key: SemOnboardingStepKey): string =>\n `semanticfed-onboarding-step-${key.toLowerCase().replace(/_/g, '-')}`;\n\ntype Tr = ReturnType<typeof useTr>;\n\nfunction ChecklistHeader({\n data,\n percent,\n collapsed,\n onToggle,\n tr,\n}: {\n data: SemOnboardingProgress;\n percent: number;\n collapsed: boolean;\n onToggle: () => void;\n tr: Tr;\n}) {\n const isEmptyWorkspace = data.completedCount === 0 && !data.demoDataPresent;\n return (\n <CardHeader className=\"flex flex-row items-start justify-between gap-4 space-y-0\">\n <div className=\"space-y-1\">\n <CardTitle className=\"text-base\">\n {data.isComplete\n ? tr('semanticfed.onboarding.titleComplete', 'You have completed getting started')\n : tr('semanticfed.onboarding.title', 'Get started with SemanticFed')}\n </CardTitle>\n <p className=\"text-sm text-muted-foreground\">\n {isEmptyWorkspace\n ? tr(\n 'semanticfed.onboarding.emptyDescription',\n 'Your workspace has no sources yet. Work through these steps, or load the demo workspace to explore first.'\n )\n : tr(\n 'semanticfed.onboarding.description',\n '{{completed}} of {{total}} steps done. Steps tick off automatically as you create things.',\n { completed: data.completedCount, total: data.totalCount }\n )}\n </p>\n </div>\n <div className=\"flex items-center gap-2\">\n <Badge variant={data.isComplete ? 'default' : 'secondary'}>{`${percent}%`}</Badge>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n aria-expanded={!collapsed}\n aria-controls=\"semanticfed-onboarding-body\"\n onClick={onToggle}\n >\n {collapsed ? <ChevronDown className=\"h-4 w-4\" /> : <ChevronUp className=\"h-4 w-4\" />}\n <span className=\"sr-only\">\n {collapsed\n ? tr('semanticfed.onboarding.expand', 'Show checklist')\n : tr('semanticfed.onboarding.collapse', 'Hide checklist')}\n </span>\n </Button>\n </div>\n </CardHeader>\n );\n}\n\n/**\n * The progress bar. The fill is scaled along the x axis rather than resized,\n * so a change animates on the compositor without re-running layout, and the\n * animation is dropped for people who ask for reduced motion.\n */\nfunction ProgressBar({ percent, label }: { percent: number; label: string }) {\n return (\n <div\n className=\"h-2 w-full overflow-hidden rounded-full bg-muted\"\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={percent}\n aria-label={label}\n >\n <div\n className=\"h-full w-full origin-left bg-primary transition-transform duration-300 motion-reduce:transition-none\"\n style={{ transform: `scaleX(${percent / 100})` }}\n />\n </div>\n );\n}\n\nfunction StepItem({ step, done, tr }: { step: StepDefinition; done: boolean; tr: Tr }) {\n const Icon = step.icon;\n return (\n <li data-tour={tourId(step.key)}>\n <Link\n to={step.path}\n className=\"flex h-full items-start gap-3 rounded-md border p-3 transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n aria-label={`${tr(step.labelKey, step.label)}${\n done ? ` — ${tr('semanticfed.onboarding.stepDone', 'done')}` : ''\n }`}\n >\n {done ? (\n <CheckCircle2 className=\"mt-0.5 h-5 w-5 shrink-0 text-primary\" aria-hidden=\"true\" />\n ) : (\n <Circle className=\"mt-0.5 h-5 w-5 shrink-0 text-muted-foreground\" aria-hidden=\"true\" />\n )}\n <span className=\"min-w-0 space-y-0.5\">\n <span className=\"flex items-center gap-2 text-sm font-medium\">\n <Icon className=\"h-4 w-4 text-muted-foreground\" aria-hidden=\"true\" />\n <span className={done ? 'text-muted-foreground line-through' : undefined}>\n {tr(step.labelKey, step.label)}\n </span>\n </span>\n <span className=\"block text-xs text-muted-foreground\">\n {tr(step.descriptionKey, step.description)}\n </span>\n </span>\n </Link>\n </li>\n );\n}\n\n/** Load or remove the labelled demo workspace. */\nfunction DemoDataPanel({\n present,\n seedDemo,\n removeDemo,\n tr,\n}: {\n present: boolean;\n seedDemo: ReturnType<typeof useSemSeedWorkspaceDemoData>;\n removeDemo: ReturnType<typeof useSemRemoveWorkspaceDemoData>;\n tr: Tr;\n}) {\n const busy = seedDemo.isPending || removeDemo.isPending;\n const error = seedDemo.error ?? removeDemo.error;\n return (\n <div\n className=\"flex flex-wrap items-center justify-between gap-3 rounded-md border border-dashed p-3\"\n data-tour=\"semanticfed-onboarding-demo\"\n >\n <div className=\"flex items-start gap-2\">\n <Sparkles className=\"mt-0.5 h-4 w-4 shrink-0 text-primary\" aria-hidden=\"true\" />\n <p className=\"text-sm text-muted-foreground\">\n {present\n ? tr(\n 'semanticfed.onboarding.demo.present',\n 'Demo data is loaded: a sample Postgres connector, a sales model and a saved query, all labelled \"Demo\". It does not count towards your checklist.'\n )\n : tr(\n 'semanticfed.onboarding.demo.absent',\n 'Want to look around first? Load a small, clearly labelled demo workspace with a sample Postgres connector, a sales model and a saved query.'\n )}\n </p>\n </div>\n {present ? (\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled={busy}\n onClick={() => removeDemo.mutate()}\n data-testid=\"semanticfed-onboarding-remove-demo\"\n >\n {removeDemo.isPending ? (\n <Loader2 className=\"mr-2 h-4 w-4 animate-spin\" />\n ) : (\n <Trash2 className=\"mr-2 h-4 w-4\" />\n )}\n {tr('semanticfed.onboarding.demo.remove', 'Remove demo data')}\n </Button>\n ) : (\n <Button\n size=\"sm\"\n disabled={busy}\n onClick={() => seedDemo.mutate()}\n data-testid=\"semanticfed-onboarding-seed-demo\"\n >\n {seedDemo.isPending ? (\n <Loader2 className=\"mr-2 h-4 w-4 animate-spin\" />\n ) : (\n <Sparkles className=\"mr-2 h-4 w-4\" />\n )}\n {tr('semanticfed.onboarding.demo.load', 'Load demo data')}\n </Button>\n )}\n {error && (\n <p className=\"w-full text-sm text-destructive\" role=\"alert\">\n {tr('semanticfed.onboarding.demo.error', 'That did not work: {{message}}', {\n message: error.message,\n })}\n </p>\n )}\n </div>\n );\n}\n\nfunction ChecklistLoading({ tr }: { tr: Tr }) {\n return (\n <Card data-tour=\"semanticfed-onboarding-checklist\" aria-busy=\"true\">\n <CardContent className=\"flex items-center gap-2 py-6 text-sm text-muted-foreground\">\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n {tr('semanticfed.onboarding.loading', 'Loading your getting-started checklist…')}\n </CardContent>\n </Card>\n );\n}\n\nfunction ChecklistError({ onRetry, tr }: { onRetry: () => void; tr: Tr }) {\n return (\n <Card data-tour=\"semanticfed-onboarding-checklist\">\n <CardContent className=\"flex flex-wrap items-center justify-between gap-3 py-6\">\n <p className=\"text-sm text-muted-foreground\">\n {tr(\n 'semanticfed.onboarding.loadError',\n 'The getting-started checklist could not be loaded.'\n )}\n </p>\n <Button variant=\"outline\" size=\"sm\" onClick={onRetry}>\n {tr('semanticfed.onboarding.retry', 'Try again')}\n </Button>\n </CardContent>\n </Card>\n );\n}\n\n/** Records one activation view per analytics scope once settled progress is shown. */\nfunction useActivationViewed(progress: ReturnType<typeof useSemOnboardingProgress>) {\n const analytics = useClientAnalytics();\n const viewedScope = useRef<typeof analytics | null>(null);\n useEffect(() => {\n if (\n !progress.data ||\n progress.isFetching ||\n progress.isError ||\n viewedScope.current === analytics\n )\n return;\n viewedScope.current = analytics;\n analytics.activationViewed(\n progress.data.completedCount,\n progress.data.totalCount,\n progress.data.demoDataPresent\n );\n }, [analytics, progress.data, progress.isFetching, progress.isError]);\n}\n\nexport const OnboardingChecklist: FC = () => {\n const tr = useTr();\n const progress = useSemOnboardingProgress();\n // Owned here, not by the demo panel, so a pending action and its error\n // survive collapsing the checklist.\n const seedDemo = useSemSeedWorkspaceDemoData();\n const removeDemo = useSemRemoveWorkspaceDemoData();\n const [collapsed, setCollapsed] = useState(false);\n useActivationViewed(progress);\n\n // No workspace selected yet (the query is disabled): nothing to track.\n if (progress.fetchStatus === 'idle' && progress.status === 'pending') return null;\n if (progress.isPending) return <ChecklistLoading tr={tr} />;\n if (progress.isError) return <ChecklistError onRetry={() => void progress.refetch()} tr={tr} />;\n\n const data = progress.data;\n const completedByKey = new Map(data.steps.map((step) => [step.key, step.completed]));\n const percent =\n data.totalCount > 0 ? Math.round((data.completedCount / data.totalCount) * 100) : 0;\n\n return (\n <Card\n data-tour=\"semanticfed-onboarding-checklist\"\n data-testid=\"semanticfed-onboarding-checklist\"\n >\n <ChecklistHeader\n data={data}\n percent={percent}\n collapsed={collapsed}\n onToggle={() => setCollapsed((value) => !value)}\n tr={tr}\n />\n\n {!collapsed && (\n <CardContent id=\"semanticfed-onboarding-body\" className=\"space-y-4\">\n <ProgressBar\n percent={percent}\n label={tr('semanticfed.onboarding.progressLabel', 'Getting-started progress')}\n />\n\n <ol className=\"grid gap-2 md:grid-cols-2\" data-tour=\"semanticfed-onboarding-steps\">\n {STEP_DEFINITIONS.map((step) => (\n <StepItem\n key={step.key}\n step={step}\n done={completedByKey.get(step.key) ?? false}\n tr={tr}\n />\n ))}\n </ol>\n\n <DemoDataPanel\n present={data.demoDataPresent}\n seedDemo={seedDemo}\n removeDemo={removeDemo}\n tr={tr}\n />\n </CardContent>\n )}\n </Card>\n );\n};\n"],"mappings":";;;;;;;;;AAqDA,IAAMA,IAA8C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,EAAS,QAAQ;EAAO;CAAK,CAAA;CAE9F,IAAMxC,IAAOwC,EAAS,MAChBQ,IAAiB,IAAI,IAAIhD,EAAK,MAAM,KAAK,MAAS,CAACgB,EAAK,KAAKA,EAAK,SAAS,CAAC,CAAC,GAC7EX,IACJL,EAAK,aAAa,IAAI,KAAK,MAAOA,EAAK,iBAAiBA,EAAK,aAAc,GAAG,IAAI;CAEpF,OACE,kBAAC+B,GAAD;EACE,aAAU;EACV,eAAY;EAFd,UAAA,CAIE,kBAACjC,GAAD;GACQ;GACG;GACE;GACX,gBAAgBgD,GAAc,MAAU,CAACG,CAAK;GAC1C;EACL,CAAA,GAEA,CAAC1C,KACA,kBAACyB,GAAD;GAAa,IAAG;GAA8B,WAAU;GAAxD,UAAA;IACE,kBAACpB,GAAD;KACW;KACT,OAAOT,EAAG,wCAAwC,0BAA0B;IAC7E,CAAA;IAED,kBAAC,MAAD;KAAI,WAAU;KAA4B,aAAU;KACjD,UAAAd,EAAiB,KAAK,MACrB,kBAACyB,GAAD;MAEQ;MACN,MAAMkC,EAAe,IAAIhC,EAAK,GAAG,KAAK;MAClC;KACL,GAJMA,EAAK,GAIX,CACF;IACC,CAAA;IAEJ,kBAACK,GAAD;KACE,SAASrB,EAAK;KACJ;KACE;KACR;IACL,CAAA;GACU;EAEX,CAAA,CAAA;;AAEV"}
|
|
1
|
+
{"version":3,"file":"OnboardingChecklist.js","names":["STEP_DEFINITIONS","Plug","Database","FileCode2","BarChart3","Terminal","Shield","tourId","key","ChecklistHeader","isEmptyWorkspace","data","CardHeader","CardTitle","tr","Badge","percent","Button","collapsed","onToggle","jsx","ChevronDown","ChevronUp","ProgressBar","label","StepItem","Icon","step","Link","done","CheckCircle2","Circle","DemoDataPanel","busy","seedDemo","removeDemo","error","Sparkles","present","Loader2","Trash2","ChecklistLoading","Card","CardContent","ChecklistError","onRetry","useActivationViewed","analytics","useClientAnalytics","viewedScope","useRef","progress","OnboardingChecklist","useTr","useSemOnboardingProgress","useSemSeedWorkspaceDemoData","useSemRemoveWorkspaceDemoData","setCollapsed","useState","completedByKey","value"],"sources":["../../../src/semanticfed/components/OnboardingChecklist.tsx"],"sourcesContent":["/**\n * SemanticFed getting-started checklist.\n *\n * Six first-value steps (connector → data source → model → metric → query →\n * policy). Completion comes from `semOnboardingProgress`, which the backend\n * derives from the records the workspace actually holds, so progress persists\n * across sessions and devices and demo records never tick a step. Each step\n * deep-links to the page where the user does it. The demo panel loads (or\n * removes) a clearly labelled sample workspace.\n *\n * Every element a seeded `global-tours-svc` tour points at carries a stable\n * `data-tour` selector (`semanticfed-onboarding-*`).\n */\nimport { useEffect, useRef, useState, type FC } from 'react';\nimport { useClientAnalytics } from '../hooks/useClientAnalytics';\nimport { Link } from 'react-router-dom';\nimport {\n BarChart3,\n CheckCircle2,\n ChevronDown,\n ChevronUp,\n Circle,\n Database,\n FileCode2,\n Loader2,\n Plug,\n Shield,\n Sparkles,\n Terminal,\n Trash2,\n} from 'lucide-react';\nimport { Badge, Button, Card, CardContent, CardHeader, CardTitle } from '@burdenoff/fe-libs/ui';\n\nimport { useTr } from '../hooks/useTr';\nimport {\n type SemOnboardingProgress,\n type SemOnboardingStepKey,\n useSemOnboardingProgress,\n useSemRemoveWorkspaceDemoData,\n useSemSeedWorkspaceDemoData,\n} from '../hooks/useOnboarding';\n\ninterface StepDefinition {\n key: SemOnboardingStepKey;\n /** Route relative to the SemanticFed base path. */\n path: string;\n icon: typeof Plug;\n labelKey: string;\n label: string;\n descriptionKey: string;\n description: string;\n}\n\nconst STEP_DEFINITIONS: readonly StepDefinition[] = [\n {\n key: 'REGISTER_CONNECTOR',\n path: 'registry',\n icon: Plug,\n labelKey: 'semanticfed.onboarding.steps.registerConnector.label',\n label: 'Register a connector',\n descriptionKey: 'semanticfed.onboarding.steps.registerConnector.description',\n description:\n 'Tell SemanticFed which kind of system you run, such as Postgres, Snowflake or a REST API.',\n },\n {\n key: 'ADD_DATA_SOURCE',\n path: 'topology',\n icon: Database,\n labelKey: 'semanticfed.onboarding.steps.addDataSource.label',\n label: 'Add a data source',\n descriptionKey: 'semanticfed.onboarding.steps.addDataSource.description',\n description: 'Point a connector at a specific database or API endpoint.',\n },\n {\n key: 'CREATE_MODEL',\n path: 'ontology',\n icon: FileCode2,\n labelKey: 'semanticfed.onboarding.steps.createModel.label',\n label: 'Create a semantic model',\n descriptionKey: 'semanticfed.onboarding.steps.createModel.description',\n description: 'Describe your entities and how they relate, once, across every source.',\n },\n {\n key: 'DEFINE_METRIC',\n path: 'ontology',\n icon: BarChart3,\n labelKey: 'semanticfed.onboarding.steps.defineMetric.label',\n label: 'Define a metric',\n descriptionKey: 'semanticfed.onboarding.steps.defineMetric.description',\n description: 'Give a business measure, such as revenue, a single governed definition.',\n },\n {\n key: 'RUN_QUERY',\n path: 'query-console',\n icon: Terminal,\n labelKey: 'semanticfed.onboarding.steps.runQuery.label',\n label: 'Run a federated query',\n descriptionKey: 'semanticfed.onboarding.steps.runQuery.description',\n description: 'Query the model and let SemanticFed push work down to each source.',\n },\n {\n key: 'ADD_POLICY',\n path: 'policies',\n icon: Shield,\n labelKey: 'semanticfed.onboarding.steps.addPolicy.label',\n label: 'Add an access policy',\n descriptionKey: 'semanticfed.onboarding.steps.addPolicy.description',\n description: 'Control who can read which rows, columns and entities on every query.',\n },\n];\n\nconst tourId = (key: SemOnboardingStepKey): string =>\n `semanticfed-onboarding-step-${key.toLowerCase().replace(/_/g, '-')}`;\n\ntype Tr = ReturnType<typeof useTr>;\n\nfunction ChecklistHeader({\n data,\n percent,\n collapsed,\n onToggle,\n tr,\n}: {\n data: SemOnboardingProgress;\n percent: number;\n collapsed: boolean;\n onToggle: () => void;\n tr: Tr;\n}) {\n const isEmptyWorkspace = data.completedCount === 0 && !data.demoDataPresent;\n return (\n <CardHeader className=\"flex flex-row items-start justify-between gap-4 space-y-0\">\n <div className=\"space-y-1\">\n <CardTitle className=\"text-base\">\n {data.isComplete\n ? tr('semanticfed.onboarding.titleComplete', 'You have completed getting started')\n : tr('semanticfed.onboarding.title', 'Get started with SemanticFed')}\n </CardTitle>\n <p className=\"text-sm text-muted-foreground\">\n {isEmptyWorkspace\n ? tr(\n 'semanticfed.onboarding.emptyDescription',\n 'Your workspace has no sources yet. Work through these steps, or load the demo workspace to explore first.'\n )\n : tr(\n 'semanticfed.onboarding.description',\n '{{completed}} of {{total}} steps done. Steps tick off automatically as you create things.',\n { completed: data.completedCount, total: data.totalCount }\n )}\n </p>\n </div>\n <div className=\"flex items-center gap-2\">\n <Badge variant={data.isComplete ? 'default' : 'secondary'}>{`${percent}%`}</Badge>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n aria-expanded={!collapsed}\n aria-controls=\"semanticfed-onboarding-body\"\n onClick={onToggle}\n >\n {collapsed ? <ChevronDown className=\"h-4 w-4\" /> : <ChevronUp className=\"h-4 w-4\" />}\n <span className=\"sr-only\">\n {collapsed\n ? tr('semanticfed.onboarding.expand', 'Show checklist')\n : tr('semanticfed.onboarding.collapse', 'Hide checklist')}\n </span>\n </Button>\n </div>\n </CardHeader>\n );\n}\n\n/**\n * The progress bar. The fill is scaled along the x axis rather than resized,\n * so a change animates on the compositor without re-running layout, and the\n * animation is dropped for people who ask for reduced motion.\n */\nfunction ProgressBar({ percent, label }: { percent: number; label: string }) {\n return (\n <div\n className=\"h-2 w-full overflow-hidden rounded-full bg-muted\"\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={percent}\n aria-label={label}\n >\n <div\n className=\"h-full w-full origin-left bg-primary transition-transform duration-300 motion-reduce:transition-none\"\n style={{ transform: `scaleX(${percent / 100})` }}\n />\n </div>\n );\n}\n\nfunction StepItem({ step, done, tr }: { step: StepDefinition; done: boolean; tr: Tr }) {\n const Icon = step.icon;\n return (\n <li data-tour={tourId(step.key)}>\n <Link\n to={step.path}\n className=\"flex h-full items-start gap-3 rounded-md border p-3 transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n aria-label={`${tr(step.labelKey, step.label)}${\n done ? ` — ${tr('semanticfed.onboarding.stepDone', 'done')}` : ''\n }`}\n >\n {done ? (\n <CheckCircle2 className=\"mt-0.5 h-5 w-5 shrink-0 text-primary\" aria-hidden=\"true\" />\n ) : (\n <Circle className=\"mt-0.5 h-5 w-5 shrink-0 text-muted-foreground\" aria-hidden=\"true\" />\n )}\n <span className=\"min-w-0 space-y-0.5\">\n <span className=\"flex items-center gap-2 text-sm font-medium\">\n <Icon className=\"h-4 w-4 text-muted-foreground\" aria-hidden=\"true\" />\n <span className={done ? 'text-muted-foreground line-through' : undefined}>\n {tr(step.labelKey, step.label)}\n </span>\n </span>\n <span className=\"block text-xs text-muted-foreground\">\n {tr(step.descriptionKey, step.description)}\n </span>\n </span>\n </Link>\n </li>\n );\n}\n\n/** Load or remove the labelled demo workspace. */\nfunction DemoDataPanel({\n present,\n seedDemo,\n removeDemo,\n tr,\n}: {\n present: boolean;\n seedDemo: ReturnType<typeof useSemSeedWorkspaceDemoData>;\n removeDemo: ReturnType<typeof useSemRemoveWorkspaceDemoData>;\n tr: Tr;\n}) {\n const busy = seedDemo.isPending || removeDemo.isPending;\n const error = seedDemo.error ?? removeDemo.error;\n return (\n <div\n className=\"flex flex-wrap items-center justify-between gap-3 rounded-md border border-dashed p-3\"\n data-tour=\"semanticfed-onboarding-demo\"\n >\n <div className=\"flex items-start gap-2\">\n <Sparkles className=\"mt-0.5 h-4 w-4 shrink-0 text-primary\" aria-hidden=\"true\" />\n <p className=\"text-sm text-muted-foreground\">\n {present\n ? tr(\n 'semanticfed.onboarding.demo.present',\n 'Demo data is loaded: a sample Postgres connector, a sales model and a saved query, all labelled \"Demo\". It does not count towards your checklist.'\n )\n : tr(\n 'semanticfed.onboarding.demo.absent',\n 'Want to look around first? Load a small, clearly labelled demo workspace with a sample Postgres connector, a sales model and a saved query.'\n )}\n </p>\n </div>\n {present ? (\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled={busy}\n onClick={() => removeDemo.mutate()}\n data-testid=\"semanticfed-onboarding-remove-demo\"\n >\n {removeDemo.isPending ? (\n <Loader2 className=\"me-2 h-4 w-4 animate-spin\" />\n ) : (\n <Trash2 className=\"me-2 h-4 w-4\" />\n )}\n {tr('semanticfed.onboarding.demo.remove', 'Remove demo data')}\n </Button>\n ) : (\n <Button\n size=\"sm\"\n disabled={busy}\n onClick={() => seedDemo.mutate()}\n data-testid=\"semanticfed-onboarding-seed-demo\"\n >\n {seedDemo.isPending ? (\n <Loader2 className=\"me-2 h-4 w-4 animate-spin\" />\n ) : (\n <Sparkles className=\"me-2 h-4 w-4\" />\n )}\n {tr('semanticfed.onboarding.demo.load', 'Load demo data')}\n </Button>\n )}\n {error && (\n <p className=\"w-full text-sm text-destructive\" role=\"alert\">\n {tr('semanticfed.onboarding.demo.error', 'That did not work: {{message}}', {\n message: error.message,\n })}\n </p>\n )}\n </div>\n );\n}\n\nfunction ChecklistLoading({ tr }: { tr: Tr }) {\n return (\n <Card data-tour=\"semanticfed-onboarding-checklist\" aria-busy=\"true\">\n <CardContent className=\"flex items-center gap-2 py-6 text-sm text-muted-foreground\">\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n {tr('semanticfed.onboarding.loading', 'Loading your getting-started checklist…')}\n </CardContent>\n </Card>\n );\n}\n\nfunction ChecklistError({ onRetry, tr }: { onRetry: () => void; tr: Tr }) {\n return (\n <Card data-tour=\"semanticfed-onboarding-checklist\">\n <CardContent className=\"flex flex-wrap items-center justify-between gap-3 py-6\">\n <p className=\"text-sm text-muted-foreground\">\n {tr(\n 'semanticfed.onboarding.loadError',\n 'The getting-started checklist could not be loaded.'\n )}\n </p>\n <Button variant=\"outline\" size=\"sm\" onClick={onRetry}>\n {tr('semanticfed.onboarding.retry', 'Try again')}\n </Button>\n </CardContent>\n </Card>\n );\n}\n\n/** Records one activation view per analytics scope once settled progress is shown. */\nfunction useActivationViewed(progress: ReturnType<typeof useSemOnboardingProgress>) {\n const analytics = useClientAnalytics();\n const viewedScope = useRef<typeof analytics | null>(null);\n useEffect(() => {\n if (\n !progress.data ||\n progress.isFetching ||\n progress.isError ||\n viewedScope.current === analytics\n )\n return;\n viewedScope.current = analytics;\n analytics.activationViewed(\n progress.data.completedCount,\n progress.data.totalCount,\n progress.data.demoDataPresent\n );\n }, [analytics, progress.data, progress.isFetching, progress.isError]);\n}\n\nexport const OnboardingChecklist: FC = () => {\n const tr = useTr();\n const progress = useSemOnboardingProgress();\n // Owned here, not by the demo panel, so a pending action and its error\n // survive collapsing the checklist.\n const seedDemo = useSemSeedWorkspaceDemoData();\n const removeDemo = useSemRemoveWorkspaceDemoData();\n const [collapsed, setCollapsed] = useState(false);\n useActivationViewed(progress);\n\n // No workspace selected yet (the query is disabled): nothing to track.\n if (progress.fetchStatus === 'idle' && progress.status === 'pending') return null;\n if (progress.isPending) return <ChecklistLoading tr={tr} />;\n if (progress.isError) return <ChecklistError onRetry={() => void progress.refetch()} tr={tr} />;\n\n const data = progress.data;\n const completedByKey = new Map(data.steps.map((step) => [step.key, step.completed]));\n const percent =\n data.totalCount > 0 ? Math.round((data.completedCount / data.totalCount) * 100) : 0;\n\n return (\n <Card\n data-tour=\"semanticfed-onboarding-checklist\"\n data-testid=\"semanticfed-onboarding-checklist\"\n >\n <ChecklistHeader\n data={data}\n percent={percent}\n collapsed={collapsed}\n onToggle={() => setCollapsed((value) => !value)}\n tr={tr}\n />\n\n {!collapsed && (\n <CardContent id=\"semanticfed-onboarding-body\" className=\"space-y-4\">\n <ProgressBar\n percent={percent}\n label={tr('semanticfed.onboarding.progressLabel', 'Getting-started progress')}\n />\n\n <ol className=\"grid gap-2 md:grid-cols-2\" data-tour=\"semanticfed-onboarding-steps\">\n {STEP_DEFINITIONS.map((step) => (\n <StepItem\n key={step.key}\n step={step}\n done={completedByKey.get(step.key) ?? false}\n tr={tr}\n />\n ))}\n </ol>\n\n <DemoDataPanel\n present={data.demoDataPresent}\n seedDemo={seedDemo}\n removeDemo={removeDemo}\n tr={tr}\n />\n </CardContent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C1D,IAAIU,EAAS,SAAS,OAAO,kBAACP,GAAD;EAAgB,eAAe,KAAKO,EAAS,QAAQ;EAAO;CAAK,CAAA;CAE9F,IAAMxC,IAAOwC,EAAS,MAChBQ,IAAiB,IAAI,IAAIhD,EAAK,MAAM,KAAK,MAAS,CAACgB,EAAK,KAAKA,EAAK,SAAS,CAAC,CAAC,GAC7EX,IACJL,EAAK,aAAa,IAAI,KAAK,MAAOA,EAAK,iBAAiBA,EAAK,aAAc,GAAG,IAAI;CAEpF,OACE,kBAAC+B,GAAD;EACE,aAAU;EACV,eAAY;EAFd,UAAA,CAIE,kBAACjC,GAAD;GACQ;GACG;GACE;GACX,gBAAgBgD,GAAc,MAAU,CAACG,CAAK;GAC1C;EACL,CAAA,GAEA,CAAC1C,KACA,kBAACyB,GAAD;GAAa,IAAG;GAA8B,WAAU;GAAxD,UAAA;IACE,kBAACpB,GAAD;KACW;KACT,OAAOT,EAAG,wCAAwC,0BAA0B;IAC7E,CAAA;IAED,kBAAC,MAAD;KAAI,WAAU;KAA4B,aAAU;KACjD,UAAAd,EAAiB,KAAK,MACrB,kBAACyB,GAAD;MAEQ;MACN,MAAMkC,EAAe,IAAIhC,EAAK,GAAG,KAAK;MAClC;KACL,GAJMA,EAAK,GAIX,CACF;IACC,CAAA;IAEJ,kBAACK,GAAD;KACE,SAASrB,EAAK;KACJ;KACE;KACR;IACL,CAAA;GACU;EAEX,CAAA,CAAA;;AAEV"}
|
|
@@ -75,7 +75,7 @@ function B({ runId: e, tr: t }) {
|
|
|
75
75
|
if (o.isError) return /* @__PURE__ */ D("p", {
|
|
76
76
|
className: "text-sm text-destructive",
|
|
77
77
|
"data-testid": "saved-query-result-error",
|
|
78
|
-
children: t("semanticfed.queryConsole.saved.resultUnavailable", "The rows of this run are not available: {message}. Results are kept for a limited time and only for the person who ran the query; run it again to see current rows.", { message: l(o.error) })
|
|
78
|
+
children: t("semanticfed.queryConsole.saved.resultUnavailable", "The rows of this run are not available: {message}. Results are kept for a limited time and only for the person who ran the query; run it again to see current rows.", { message: l(o.error, t) })
|
|
79
79
|
});
|
|
80
80
|
let s = o.data;
|
|
81
81
|
if (!s) return null;
|
|
@@ -117,7 +117,7 @@ function B({ runId: e, tr: t }) {
|
|
|
117
117
|
/* @__PURE__ */ D("div", {
|
|
118
118
|
className: "max-h-[28rem] overflow-auto rounded border",
|
|
119
119
|
children: /* @__PURE__ */ O("table", {
|
|
120
|
-
className: "w-max min-w-full max-w-none table-auto text-
|
|
120
|
+
className: "w-max min-w-full max-w-none table-auto text-start text-xs",
|
|
121
121
|
children: [/* @__PURE__ */ D("thead", {
|
|
122
122
|
className: "sticky top-0 bg-muted",
|
|
123
123
|
children: /* @__PURE__ */ D("tr", { children: s.columns.map((e) => /* @__PURE__ */ O("th", {
|
|
@@ -157,7 +157,7 @@ function B({ runId: e, tr: t }) {
|
|
|
157
157
|
disabled: n.length <= 1 || o.isFetching,
|
|
158
158
|
onClick: () => r((e) => e.slice(0, -1)),
|
|
159
159
|
"data-testid": "saved-query-prev-page",
|
|
160
|
-
children: [/* @__PURE__ */ D(_, { className: "
|
|
160
|
+
children: [/* @__PURE__ */ D(_, { className: "me-1 h-4 w-4 rtl:rotate-180" }), t("semanticfed.queryConsole.saved.previous", "Previous")]
|
|
161
161
|
}), /* @__PURE__ */ O(A, {
|
|
162
162
|
size: "sm",
|
|
163
163
|
variant: "outline",
|
|
@@ -167,7 +167,7 @@ function B({ runId: e, tr: t }) {
|
|
|
167
167
|
e !== null && r((t) => [...t, e]);
|
|
168
168
|
},
|
|
169
169
|
"data-testid": "saved-query-next-page",
|
|
170
|
-
children: [t("semanticfed.queryConsole.saved.next", "Next {count}", { count: 100 }), /* @__PURE__ */ D(v, { className: "
|
|
170
|
+
children: [t("semanticfed.queryConsole.saved.next", "Next {count}", { count: 100 }), /* @__PURE__ */ D(v, { className: "ms-1 h-4 w-4 rtl:rotate-180" })]
|
|
171
171
|
})]
|
|
172
172
|
})
|
|
173
173
|
]
|
|
@@ -228,7 +228,7 @@ function U({ runId: e, tr: n }) {
|
|
|
228
228
|
let r = i(e), a = r.data;
|
|
229
229
|
return r.isError ? /* @__PURE__ */ D("p", {
|
|
230
230
|
className: "text-sm text-destructive",
|
|
231
|
-
children: l(r.error)
|
|
231
|
+
children: l(r.error, n)
|
|
232
232
|
}) : a ? /* @__PURE__ */ O("div", {
|
|
233
233
|
className: "space-y-3",
|
|
234
234
|
"data-testid": "saved-query-run",
|
|
@@ -270,7 +270,7 @@ function W({ queryId: e, selectedRunId: t, onSelect: n, tr: r }) {
|
|
|
270
270
|
i.isLoading && /* @__PURE__ */ D(S, { className: "h-4 w-4 animate-spin text-muted-foreground" }),
|
|
271
271
|
i.isError && /* @__PURE__ */ D("p", {
|
|
272
272
|
className: "text-xs text-destructive",
|
|
273
|
-
children: l(i.error)
|
|
273
|
+
children: l(i.error, r)
|
|
274
274
|
}),
|
|
275
275
|
i.isSuccess && i.data.length === 0 && /* @__PURE__ */ D("p", {
|
|
276
276
|
className: "text-xs text-muted-foreground",
|
|
@@ -283,7 +283,7 @@ function W({ queryId: e, selectedRunId: t, onSelect: n, tr: r }) {
|
|
|
283
283
|
type: "button",
|
|
284
284
|
onClick: () => n(e.id),
|
|
285
285
|
"aria-pressed": e.id === t,
|
|
286
|
-
className: e.id === t ? "flex w-full min-w-0 flex-wrap items-center gap-x-3 gap-y-1 rounded border border-primary bg-muted p-2 text-
|
|
286
|
+
className: e.id === t ? "flex w-full min-w-0 flex-wrap items-center gap-x-3 gap-y-1 rounded border border-primary bg-muted p-2 text-start text-xs" : "flex w-full min-w-0 flex-wrap items-center gap-x-3 gap-y-1 rounded border p-2 text-start text-xs hover:bg-muted",
|
|
287
287
|
children: [
|
|
288
288
|
/* @__PURE__ */ D(L, { status: e.status }),
|
|
289
289
|
/* @__PURE__ */ D("span", {
|
|
@@ -299,9 +299,9 @@ function W({ queryId: e, selectedRunId: t, onSelect: n, tr: r }) {
|
|
|
299
299
|
children: [e.durationMs, "ms"]
|
|
300
300
|
}),
|
|
301
301
|
/* @__PURE__ */ O("span", {
|
|
302
|
-
className: "
|
|
302
|
+
className: "ms-auto flex max-w-full min-w-0 items-center gap-1 text-muted-foreground",
|
|
303
303
|
children: [/* @__PURE__ */ D(y, { className: "h-3 w-3 shrink-0" }), /* @__PURE__ */ D("span", {
|
|
304
|
-
className: "min-w-0 break-words text-
|
|
304
|
+
className: "min-w-0 break-words text-end",
|
|
305
305
|
children: F(e.createdAt)
|
|
306
306
|
})]
|
|
307
307
|
})
|
|
@@ -337,7 +337,7 @@ function G({ queries: e, query: t, running: n, onChoose: r, onRun: i, tr: a }) {
|
|
|
337
337
|
onClick: i,
|
|
338
338
|
disabled: n || !t.modelId,
|
|
339
339
|
"data-testid": "saved-query-run-button",
|
|
340
|
-
children: [n ? /* @__PURE__ */ D(S, { className: "
|
|
340
|
+
children: [n ? /* @__PURE__ */ D(S, { className: "me-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ D(C, { className: "me-2 h-4 w-4" }), a("semanticfed.queryConsole.saved.run", "Run query")]
|
|
341
341
|
})]
|
|
342
342
|
}),
|
|
343
343
|
t.description && /* @__PURE__ */ D("p", {
|
|
@@ -368,7 +368,7 @@ function K({ modelId: e }) {
|
|
|
368
368
|
runId: e.id
|
|
369
369
|
});
|
|
370
370
|
} catch (e) {
|
|
371
|
-
m(l(e));
|
|
371
|
+
m(l(e, t));
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
};
|
|
@@ -389,7 +389,7 @@ function K({ modelId: e }) {
|
|
|
389
389
|
n.isLoading && /* @__PURE__ */ D(S, { className: "h-4 w-4 animate-spin text-muted-foreground" }),
|
|
390
390
|
n.isError && /* @__PURE__ */ D("p", {
|
|
391
391
|
className: "text-sm text-destructive",
|
|
392
|
-
children: l(n.error)
|
|
392
|
+
children: l(n.error, t)
|
|
393
393
|
}),
|
|
394
394
|
n.isSuccess && g.length === 0 && /* @__PURE__ */ D("p", {
|
|
395
395
|
className: "text-sm text-muted-foreground",
|