@gooddata/sdk-ui-gen-ai 11.69.0-alpha.4 → 11.69.0-alpha.5
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/NOTICE +250 -51
- package/esm/components/GenAIChatOverlay.js +4 -4
- package/esm/components/Input.d.ts.map +1 -1
- package/esm/components/Input.js +1 -2
- package/esm/components/customized/LandingQuestion.js +1 -1
- package/esm/components/customized/MessageTextContent.js +1 -1
- package/esm/components/customized/types.d.ts +5 -0
- package/esm/components/customized/types.d.ts.map +1 -1
- package/esm/components/messages/ConversationItemContents.d.ts +1 -1
- package/esm/components/messages/ConversationItemContents.d.ts.map +1 -1
- package/esm/components/messages/ConversationItemContents.js +2 -2
- package/esm/components/messages/contents/Markdown.d.ts.map +1 -1
- package/esm/components/messages/contents/Markdown.js +22 -4
- package/esm/components/messages/conversationContents/ConversationVisualisation.d.ts.map +1 -1
- package/esm/components/messages/conversationContents/ConversationVisualisation.js +19 -4
- package/esm/components/messages/conversationContents/ConversationVisualizationContent.d.ts.map +1 -1
- package/esm/components/messages/conversationContents/ConversationVisualizationContent.js +12 -2
- package/esm/components/utils/markdownUtils.js +2 -2
- package/esm/copilot/CopilotHandler.d.ts +1 -0
- package/esm/copilot/CopilotHandler.d.ts.map +1 -1
- package/esm/copilot/CopilotHandler.js +12 -2
- package/esm/copilot/useDashboardCopilot.d.ts +56 -0
- package/esm/copilot/useDashboardCopilot.d.ts.map +1 -0
- package/esm/copilot/useDashboardCopilot.js +268 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/sdk-ui-gen-ai.d.ts +59 -0
- package/package.json +22 -23
- package/styles/css/main.css +25 -19
- package/styles/css/main.css.map +1 -1
- package/styles/css/messages.css +1 -1
- package/styles/css/window.css +0 -6
- package/styles/css/window.css.map +1 -1
- package/styles/scss/messages.scss +1 -1
- package/styles/scss/window.scss +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationItemContents.d.ts","sourceRoot":"","sources":["../../../src/components/messages/ConversationItemContents.tsx"],"names":[],"mappings":"AAIA,OAAO,EAGH,KAAK,0BAA0B,EAC/B,KAAK,iBAAiB,EACzB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,KAAK,kBAAkB,EAA0B,MAAM,0BAA0B,CAAC;AAO3F,KAAK,6BAA6B,GAAG;IACjC,OAAO,EAAE,0BAA0B,CAAC;IACpC,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,EACrC,OAAO,EACP,MAAM,EACN,UAAU,EACV,SAAS,EACT,MAAM,GACT,EAAE,6BAA6B,
|
|
1
|
+
{"version":3,"file":"ConversationItemContents.d.ts","sourceRoot":"","sources":["../../../src/components/messages/ConversationItemContents.tsx"],"names":[],"mappings":"AAIA,OAAO,EAGH,KAAK,0BAA0B,EAC/B,KAAK,iBAAiB,EACzB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,KAAK,kBAAkB,EAA0B,MAAM,0BAA0B,CAAC;AAO3F,KAAK,6BAA6B,GAAG;IACjC,OAAO,EAAE,0BAA0B,CAAC;IACpC,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,EACrC,OAAO,EACP,MAAM,EACN,UAAU,EACV,IAAI,EACJ,SAAS,EACT,MAAM,GACT,EAAE,6BAA6B,kDAwF/B"}
|
|
@@ -8,7 +8,7 @@ import { ConversationClarifyingAnswersContent } from "./conversationContents/Con
|
|
|
8
8
|
import { ConversationSkillActivatedContent } from "./conversationContents/ConversationSkillActivatedContent.js";
|
|
9
9
|
import { ConversationToolCallContent } from "./conversationContents/ConversationToolCallContent.js";
|
|
10
10
|
import { ConversationToolResultContent } from "./conversationContents/ConversationToolResultContent.js";
|
|
11
|
-
export function ConversationItemContents({ message, groups, references, isLoading, isLast, }) {
|
|
11
|
+
export function ConversationItemContents({ message, groups, references, role, isLoading, isLast, }) {
|
|
12
12
|
const { MessageTextContentComponent, MessageErrorContentComponent, MessageReasoningContentComponent, MessageMultipartContentComponent, } = useCustomization();
|
|
13
13
|
const agents = useSelector(agentsSelector);
|
|
14
14
|
const content = message.content;
|
|
@@ -16,7 +16,7 @@ export function ConversationItemContents({ message, groups, references, isLoadin
|
|
|
16
16
|
return _jsx(MessageErrorContentComponent, { ...content, isLoading: isLoading });
|
|
17
17
|
}
|
|
18
18
|
if (content.type === "text") {
|
|
19
|
-
return (_jsx(MessageTextContentComponent, { text: content.text, objects: [...(content.objects ?? []), ...references], isLoading: isLoading }));
|
|
19
|
+
return (_jsx(MessageTextContentComponent, { text: content.text, useMarkdown: role !== "user", objects: [...(content.objects ?? []), ...references], isLoading: isLoading }));
|
|
20
20
|
}
|
|
21
21
|
if (content.type === "reasoning") {
|
|
22
22
|
const groupIndex = groups.findIndex((group) => group.messages.some((m) => m.localId === message.localId));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../../src/components/messages/contents/Markdown.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAuD3D,KAAK,sBAAsB,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACjC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAqB,EAAE,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../../src/components/messages/contents/Markdown.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAuD3D,KAAK,sBAAsB,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACjC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAqB,EAAE,EAAE,sBAAsB,2CAiCxG"}
|
|
@@ -40,10 +40,28 @@ export function MarkdownComponent({ children, references, allowMarkdown = false
|
|
|
40
40
|
return createReferenceTooltip(intl, props, references, catalogItems) ?? _jsx("span", { ...props });
|
|
41
41
|
},
|
|
42
42
|
}), [intl, references, catalogItems]);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
return (_jsx(Markdown, { remarkPlugins: allowMarkdown ? [remarkEmoji, remarkGfm, remarkReferences()] : [], rehypePlugins: [
|
|
44
|
+
...(allowMarkdown ? [] : [rehypePlainText(text)]),
|
|
45
|
+
rehypeReferences(references ?? [], tokens),
|
|
46
|
+
], components: componentMap, urlTransform: customUrlTransform, children: text }));
|
|
47
|
+
}
|
|
48
|
+
function rehypePlainText(text) {
|
|
49
|
+
return function () {
|
|
50
|
+
return function () {
|
|
51
|
+
// Replace parsed markup after conversion to HTML nodes to preserve whitespace as well as text.
|
|
52
|
+
return {
|
|
53
|
+
type: "root",
|
|
54
|
+
children: [
|
|
55
|
+
{
|
|
56
|
+
type: "element",
|
|
57
|
+
tagName: "p",
|
|
58
|
+
properties: {},
|
|
59
|
+
children: [{ type: "text", value: text }],
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
47
65
|
}
|
|
48
66
|
const OBJECT_CLASS_NAME = "gd-gen-ai-chat__message__object";
|
|
49
67
|
function createReferenceTooltip(intl, props, references = [], catalogItems = []) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationVisualisation.d.ts","sourceRoot":"","sources":["../../../../src/components/messages/conversationContents/ConversationVisualisation.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,qCAAqC,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAGH,KAAK,aAAa,EAElB,KAAK,gBAAgB,EAIrB,KAAK,WAAW,EAWnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEH,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAInB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ConversationVisualisation.d.ts","sourceRoot":"","sources":["../../../../src/components/messages/conversationContents/ConversationVisualisation.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,qCAAqC,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAGH,KAAK,aAAa,EAElB,KAAK,gBAAgB,EAIrB,KAAK,WAAW,EAWnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEH,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAInB,MAAM,kBAAkB,CAAC;AAyB1B,OAAO,EACH,KAAK,kCAAkC,EAE1C,MAAM,4BAA4B,CAAC;AAkBpC,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AA2CpE,MAAM,MAAM,8BAA8B,GAAG;IACzC,OAAO,EAAE,0BAA0B,CAAC;IACpC,aAAa,EAAE,WAAW,CAAC,qCAAqC,CAAC,eAAe,CAAC,CAAC,CAAC;IACnF,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACzD,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;IACpC,YAAY,CAAC,EAAE,CACX,IAAI,EAAE;QACF,aAAa,EAAE,kCAAkC,EAAE,CAAC;QACpD,KAAK,EAAE,WAAW,CAAC;KACtB,GAAG,IAAI,KACP,IAAI,CAAC;IACV,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,4BAA4B,CAAC,EAAE,OAAO,CAAC;CAC1C,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,EACtC,OAAO,EACP,YAAY,EACZ,UAAU,EACV,aAAa,EACb,UAAU,EACV,WAAW,EACX,OAAO,EACP,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,cAAqB,EACrB,oBAA4B,EAC5B,yBAAiC,EACjC,mBAA0B,EAC1B,4BAAoC,GACvC,EAAE,8BAA8B,2CAsdhC"}
|
|
@@ -139,14 +139,14 @@ export function ConversationVisualisation({ message, colorPalette, separators, v
|
|
|
139
139
|
separators,
|
|
140
140
|
});
|
|
141
141
|
case "local:bar":
|
|
142
|
-
return renderBarChart(intl.locale, bucketsData, filters, sorts, colorPalette, handleSdkError, handleSuccess, handlerDrill, {
|
|
142
|
+
return renderBarChart(intl.locale, visualization, bucketsData, filters, sorts, colorPalette, handleSdkError, handleSuccess, handlerDrill, {
|
|
143
143
|
enableChangeAnalysis,
|
|
144
144
|
enableAccessibleChartTooltip,
|
|
145
145
|
execConfig,
|
|
146
146
|
separators,
|
|
147
147
|
});
|
|
148
148
|
case "local:column":
|
|
149
|
-
return renderColumnChart(intl.locale, bucketsData, filters, sorts, colorPalette, handleSdkError, handleSuccess, handlerDrill, {
|
|
149
|
+
return renderColumnChart(intl.locale, visualization, bucketsData, filters, sorts, colorPalette, handleSdkError, handleSuccess, handlerDrill, {
|
|
150
150
|
drillableItems,
|
|
151
151
|
enableChangeAnalysis,
|
|
152
152
|
enableAccessibleChartTooltip,
|
|
@@ -302,9 +302,10 @@ const renderAreaChart = (locale, visualization, buckets, filters, sortBy, colorP
|
|
|
302
302
|
stackMeasuresToPercent: controls?.["stackMeasuresToPercent"],
|
|
303
303
|
}, drillableItems: props.drillableItems, onDrill: onDrill, onError: onError, onExportReady: onSuccess, execConfig: props.execConfig }));
|
|
304
304
|
};
|
|
305
|
-
const renderBarChart = (locale, buckets, filters, sortBy, colorPalette, onError, onSuccess, onDrill, props) => {
|
|
305
|
+
const renderBarChart = (locale, visualization, buckets, filters, sortBy, colorPalette, onError, onSuccess, onDrill, props) => {
|
|
306
306
|
const { metrics, view, stack } = buckets;
|
|
307
307
|
const measures = stack[0] ? metrics.slice(0, 1) : metrics;
|
|
308
|
+
const secondaryAxis = getSecondaryAxisConfig(visualization.insight.properties["controls"]?.secondary_xaxis?.measures, measures);
|
|
308
309
|
return (_jsx(BarChart, { locale: locale, height: VIS_HEIGHT, measures: measures, viewBy: view, stackBy: stack[0], sortBy: sortsOver(sortBy, [...view, ...stack.slice(0, 1)], measures), config: {
|
|
309
310
|
...defaultsChartOptions,
|
|
310
311
|
...visualizationTooltipOptions,
|
|
@@ -314,11 +315,13 @@ const renderBarChart = (locale, buckets, filters, sortBy, colorPalette, onError,
|
|
|
314
315
|
// Better visibility with stacked bars if there are multiple metrics and dimensions
|
|
315
316
|
stackMeasures: stack.length >= 1,
|
|
316
317
|
enableAccessibleTooltip: props.enableAccessibleChartTooltip,
|
|
318
|
+
...(secondaryAxis ? { secondary_xaxis: secondaryAxis } : {}),
|
|
317
319
|
}, drillableItems: props.drillableItems, onDrill: onDrill, filters: filters, onError: onError, onExportReady: onSuccess, execConfig: props.execConfig }));
|
|
318
320
|
};
|
|
319
|
-
const renderColumnChart = (locale, buckets, filters, sortBy, colorPalette, onError, onSuccess, onDrill, props) => {
|
|
321
|
+
const renderColumnChart = (locale, visualization, buckets, filters, sortBy, colorPalette, onError, onSuccess, onDrill, props) => {
|
|
320
322
|
const { metrics, view, stack } = buckets;
|
|
321
323
|
const measures = stack[0] ? metrics.slice(0, 1) : metrics;
|
|
324
|
+
const secondaryAxis = getSecondaryAxisConfig(visualization.insight.properties["controls"]?.secondary_yaxis?.measures, measures);
|
|
322
325
|
return (_jsx(ColumnChart, { locale: locale, height: VIS_HEIGHT, measures: measures, viewBy: view, stackBy: stack[0], sortBy: sortsOver(sortBy, [...view, ...stack.slice(0, 1)], measures), config: {
|
|
323
326
|
...defaultsChartOptions,
|
|
324
327
|
...visualizationTooltipOptions,
|
|
@@ -328,6 +331,7 @@ const renderColumnChart = (locale, buckets, filters, sortBy, colorPalette, onErr
|
|
|
328
331
|
// Better visibility with stacked bars if there are multiple metrics and dimensions
|
|
329
332
|
stackMeasures: stack.length >= 1,
|
|
330
333
|
enableAccessibleTooltip: props.enableAccessibleChartTooltip,
|
|
334
|
+
...(secondaryAxis ? { secondary_yaxis: secondaryAxis } : {}),
|
|
331
335
|
}, drillableItems: props.drillableItems, onDrill: onDrill, filters: filters, onError: onError, onExportReady: onSuccess, execConfig: props.execConfig }));
|
|
332
336
|
};
|
|
333
337
|
const renderLineChart = (locale, visualization, buckets, filters, sortBy, colorPalette, onError, onSuccess, onDrill, props) => {
|
|
@@ -336,6 +340,7 @@ const renderLineChart = (locale, visualization, buckets, filters, sortBy, colorP
|
|
|
336
340
|
const anomalies = mapVisualizationAnomalyDetectionToChartConfig(visualization.insight.properties["controls"]);
|
|
337
341
|
const outliersConfig = mapVisualizationAnomalyDetectionToBackendConfig(visualization.insight.properties["controls"]);
|
|
338
342
|
const { metrics, trend, segment } = buckets;
|
|
343
|
+
const secondaryAxis = getSecondaryAxisConfig(visualization.insight.properties["controls"]?.secondary_yaxis?.measures, metrics);
|
|
339
344
|
return (_jsx(LineChart, { locale: locale, height: VIS_HEIGHT, measures: metrics, trendBy: trend[0], segmentBy: segment[0], filters: filters, sortBy: sortBy, config: {
|
|
340
345
|
...defaultsChartOptions,
|
|
341
346
|
...visualizationTooltipOptions,
|
|
@@ -345,6 +350,7 @@ const renderLineChart = (locale, visualization, buckets, filters, sortBy, colorP
|
|
|
345
350
|
enableAccessibleTooltip: props.enableAccessibleChartTooltip,
|
|
346
351
|
...(forecastConfig && forecast ? { forecast } : {}),
|
|
347
352
|
...(outliersConfig && anomalies ? { anomalies } : {}),
|
|
353
|
+
...(secondaryAxis ? { secondary_yaxis: secondaryAxis } : {}),
|
|
348
354
|
}, forecastConfig: forecastConfig, outliersConfig: outliersConfig, drillableItems: props.drillableItems, onDrill: onDrill, onError: onError, onExportReady: onSuccess, execConfig: props.execConfig }));
|
|
349
355
|
};
|
|
350
356
|
const renderSlicedChart = (Chart, locale, buckets, filters, sortBy, colorPalette, onError, onSuccess, onDrill, props) => {
|
|
@@ -550,6 +556,15 @@ function sortsOver(sortBy, attributes, measures) {
|
|
|
550
556
|
measureIdentifiers.every((id) => measureIds.includes(id)));
|
|
551
557
|
});
|
|
552
558
|
}
|
|
559
|
+
// The chart matches axis membership by exact measure local ID. Saved IDs of measures the chart does
|
|
560
|
+
// not receive (e.g. the extra measures a stacked bar drops) are left out; with none left, it keeps one axis.
|
|
561
|
+
function getSecondaryAxisConfig(secondaryMeasureIds, renderedMeasures) {
|
|
562
|
+
if (!Array.isArray(secondaryMeasureIds)) {
|
|
563
|
+
return undefined;
|
|
564
|
+
}
|
|
565
|
+
const measures = renderedMeasures.map(measureLocalId).filter((id) => secondaryMeasureIds.includes(id));
|
|
566
|
+
return measures.length > 0 ? { measures } : undefined;
|
|
567
|
+
}
|
|
553
568
|
function useBucketData(buckets) {
|
|
554
569
|
return useMemo(() => {
|
|
555
570
|
const metrics = buckets.find((b) => b.localIdentifier === "measures")?.items.filter(isMeasure) ?? [];
|
package/esm/components/messages/conversationContents/ConversationVisualizationContent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationVisualizationContent.d.ts","sourceRoot":"","sources":["../../../../src/components/messages/conversationContents/ConversationVisualizationContent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConversationVisualizationContent.d.ts","sourceRoot":"","sources":["../../../../src/components/messages/conversationContents/ConversationVisualizationContent.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAE,KAAK,qCAAqC,EAAE,MAAM,2BAA2B,CAAC;AAwBvF,OAAO,EAAE,KAAK,0BAA0B,EAAE,KAAK,mCAAmC,EAAE,MAAM,mBAAmB,CAAC;AAa9G,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAGlF,OAAO,EACH,KAAK,oDAAoD,EAE5D,MAAM,2BAA2B,CAAC;AAmBnC,KAAK,wBAAwB,GAAG,aAAa,GAAG,aAAa,GAAG,aAAa,CAAC;AAE9E,wBAAgB,kCAAkC,CAAC,EAC/C,QAAQ,EACR,oBAAoB,EACpB,QAAQ,EACR,SAAS,GACZ,EAAE;IACC,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IACrC,SAAS,CAAC,EAAE,oDAAoD,CAAC,WAAW,CAAC,CAAC;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oBAAoB,EAAE,OAAO,CAAC;CACjC,GAAG,wBAAwB,EAAE,CAyB7B;AAED,MAAM,MAAM,qCAAqC,GAAG;IAChD,OAAO,EAAE,0BAA0B,CAAC;IACpC,IAAI,EAAE,mCAAmC,CAAC;IAC1C,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IACrC,aAAa,EAAE,WAAW,CAAC,qCAAqC,CAAC,eAAe,CAAC,CAAC,CAAC;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,oDAAoD,CAAC,WAAW,CAAC,CAAC;IAC9E,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACrC,CAAC;AAEF,wBAAgB,gCAAgC,CAAC,EAC7C,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,SAAS,EACT,uBAAuB,GAC1B,EAAE,qCAAqC,2CAwIvC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// (C) 2024-2026 GoodData Corporation
|
|
3
|
-
import { useCallback, useId, useMemo, useRef, useState, } from "react";
|
|
3
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState, } from "react";
|
|
4
4
|
import cx from "classnames";
|
|
5
5
|
import copy from "copy-to-clipboard";
|
|
6
6
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
7
7
|
import { useDispatch, useSelector } from "react-redux";
|
|
8
8
|
import { insightVisualizationType } from "@gooddata/sdk-model";
|
|
9
9
|
import { isClusteringNotReceived, isDataTooLargeToCompute, isDataTooLargeToDisplay, isForecastNotReceived, isNegativeValues, isNoDataSdkError, useWorkspaceStrict, } from "@gooddata/sdk-ui";
|
|
10
|
+
import { DRILL_MENU_HOST_ATTRIBUTE, notifyDrillMenuExpandedChange } from "@gooddata/sdk-ui-charts";
|
|
10
11
|
import { canConvertToTable } from "@gooddata/sdk-ui-ext";
|
|
11
12
|
import { Dropdown, IconCopy, IconExternalLink, IconSave, UiIconButton, UiTooltip, } from "@gooddata/sdk-ui-kit";
|
|
12
13
|
import { catalogItemsSelector, colorPaletteSelector, settingsSelector, } from "../../../store/chatWindow/chatWindowSelectors.js";
|
|
@@ -206,6 +207,15 @@ function DrillState({ containerRef, filters, children, drillState, setDrillState
|
|
|
206
207
|
const intl = useIntl();
|
|
207
208
|
const dispatch = useDispatch();
|
|
208
209
|
const catalogItems = useSelector(catalogItemsSelector);
|
|
210
|
+
const openDrillEvent = drillState?.event;
|
|
211
|
+
useEffect(() => {
|
|
212
|
+
const target = openDrillEvent?.target;
|
|
213
|
+
if (!target) {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
notifyDrillMenuExpandedChange(target, true);
|
|
217
|
+
return () => notifyDrillMenuExpandedChange(target, false);
|
|
218
|
+
}, [openDrillEvent]);
|
|
209
219
|
return (_jsx(Dropdown, { enableAutoToggle: false, isOpen: Boolean(drillState), onToggle: (state) => {
|
|
210
220
|
if (!state) {
|
|
211
221
|
setDrillState(null);
|
|
@@ -233,7 +243,7 @@ function DrillState({ containerRef, filters, children, drillState, setDrillState
|
|
|
233
243
|
}, onClose: () => {
|
|
234
244
|
setDrillState(null);
|
|
235
245
|
} }));
|
|
236
|
-
}, renderButton: () => (_jsxs(_Fragment, { children: [children, _jsx(_Fragment, { children: drillState ? (_jsx("div", { className: "gd-gen-ai-chat__conversation__visualization__drill_overlay" })) : null })] })) }));
|
|
246
|
+
}, renderButton: () => (_jsxs(_Fragment, { children: [_jsx("div", { style: { display: "contents" }, [DRILL_MENU_HOST_ATTRIBUTE]: "true", children: children }), _jsx(_Fragment, { children: drillState ? (_jsx("div", { className: "gd-gen-ai-chat__conversation__visualization__drill_overlay" })) : null })] })) }));
|
|
237
247
|
}
|
|
238
248
|
function calculateOffset(container, drillEvent) {
|
|
239
249
|
const offest = getRelativeOffset(drillEvent?.target, container);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// (C) 2025-2026 GoodData Corporation
|
|
2
|
-
const MARKDOWN_ESCAPE_PATTERN = /(\{[^{}]*\})|[\\`*_{}[\]()
|
|
3
|
-
const MARKDOWN_UNESCAPE_PATTERN = /\\([\\`*_{}[\]()
|
|
2
|
+
const MARKDOWN_ESCAPE_PATTERN = /(\{[^{}]*\})|[\\`*_{}[\]()#+\-.!:]/g;
|
|
3
|
+
const MARKDOWN_UNESCAPE_PATTERN = /\\([\\`*_{}[\]()#+\-.!:])/g;
|
|
4
4
|
export function escapeMarkdown(text) {
|
|
5
5
|
return text.replace(MARKDOWN_ESCAPE_PATTERN, (match, inBraces) => inBraces || `\\${match}`);
|
|
6
6
|
}
|
|
@@ -54,6 +54,7 @@ export declare class CopilotHandler<TBuild extends string = CopilotBuildType> {
|
|
|
54
54
|
hasDefinition: (target: ICopilotTarget<TBuild>) => boolean;
|
|
55
55
|
/** Permanently stop processing and release all listeners. Idempotent. */
|
|
56
56
|
dispose: () => void;
|
|
57
|
+
private hasPendingClarification;
|
|
57
58
|
private shouldApplyDefinition;
|
|
58
59
|
private update;
|
|
59
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotHandler.d.ts","sourceRoot":"","sources":["../../src/copilot/CopilotHandler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAStF,OAAO,EACH,KAAK,gBAAgB,EAErB,KAAK,aAAa,EAClB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACtB,MAAM,YAAY,CAAC;AAUpB;;;;;;;;;GASG;AACH,qBAAa,cAAc,CAAC,MAAM,SAAS,MAAM,GAAG,gBAAgB;IAChE,OAAO,CAAC,KAAK,CAAkE;IAC/E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IACnD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgC;IAC9D,OAAO,CAAC,QAAQ,CAAS;IAEzB,8EAA8E;IAC9E,YAAmB,aAAa,EAAE,qBAAqB,CAAC,MAAM,CAAC,EAQ9D;IAED,+DAA+D;IACxD,WAAW,UAAW,SAAS,KAA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AEF,sFAAsF;IAC/E,gCAAgC,kBAAmB,MAAM,KAAG,IAAI,CAErE;IAEF,oDAAoD;IAC7C,WAAW,QAAO,gBAAgB,CAAC,MAAM,CAAC,CAAe;IAEhE,sFAAsF;IAC/E,SAAS,aAAc,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC,CAQrD;IAEF,+EAA+E;IACxE,SAAS,UAAW,aAAa,CAAC,MAAM,CAAC,KAAG,aAAa,CACrB;IAE3C,8EAA8E;IACvE,mBAAmB,SAAU,MAAM,KAAG,OAAO,CAAqD;IAEzG,6CAA6C;IACtC,iBAAiB,QAAO,MAAM,GAAG,SAAS,CAA4C;IAE7F,iFAAiF;IAC1E,gBAAgB,WAAY,cAAc,CAAC,MAAM,CAAC,KAAG,cAAc,GAAG,SAAS,CAC1C;IAE5C,4GAA4G;IACrG,aAAa,WAAY,cAAc,CAAC,MAAM,CAAC,KAAG,OAAO,CAG1D;IAEN,yEAAyE;IAClE,OAAO,QAAO,IAAI,CAGvB;IAEF,OAAO,CAAC,uBAAuB;IAoB/B,OAAO,CAAC,qBAAqB;IAwB7B,OAAO,CAAC,MAAM;CAgBjB"}
|
|
@@ -72,8 +72,8 @@ export class CopilotHandler {
|
|
|
72
72
|
event.type === "chatClarificationQuestions" &&
|
|
73
73
|
event.responses === undefined &&
|
|
74
74
|
event.questions.length > 0 &&
|
|
75
|
-
!
|
|
76
|
-
|
|
75
|
+
!this.hasPendingClarification(previous, event.interactionId) &&
|
|
76
|
+
this.hasPendingClarification(this.state, event.interactionId) &&
|
|
77
77
|
this.configuration.registrations.some(({ type }) => this.getStatus({
|
|
78
78
|
type,
|
|
79
79
|
objectId: this.state.context.objectId,
|
|
@@ -150,6 +150,16 @@ export class CopilotHandler {
|
|
|
150
150
|
this.disposed = true;
|
|
151
151
|
this.listeners.clear();
|
|
152
152
|
};
|
|
153
|
+
hasPendingClarification(snapshot, interactionId) {
|
|
154
|
+
return this.configuration.registrations.some(({ type }) => snapshot.requests.some((request) => !request.superseded &&
|
|
155
|
+
(request.type ?? request.generation) === type &&
|
|
156
|
+
request.pendingClarificationIds?.includes(interactionId)) ||
|
|
157
|
+
((snapshot.interaction.build?.type === type ||
|
|
158
|
+
(snapshot.generation === type &&
|
|
159
|
+
!snapshot.requests.some((request) => request.generation === type &&
|
|
160
|
+
request.revision > (snapshot.generationRevision ?? 0)))) &&
|
|
161
|
+
snapshot.interaction.pendingClarificationIds.includes(interactionId)));
|
|
162
|
+
}
|
|
153
163
|
shouldApplyDefinition(event, target) {
|
|
154
164
|
const { context } = this.state;
|
|
155
165
|
const builderTarget = context.builderTarget?.type === target.type ? context.builderTarget : undefined;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type IDashboardProps } from "@gooddata/sdk-ui-dashboard";
|
|
2
|
+
import { type GenAIAssistantProps } from "../components/GenAIChat.js";
|
|
3
|
+
import { type GenAiStoreProps } from "../components/GenAiStore.js";
|
|
4
|
+
import { CopilotHandler } from "./CopilotHandler.js";
|
|
5
|
+
import { type ICopilotInteractionComposingWithHandlerProps } from "./CopilotInteractionComposingWithHandler.js";
|
|
6
|
+
/** Props and actions connecting one dashboard to a shared assistant store. @alpha */
|
|
7
|
+
export interface IUseDashboardCopilotResult {
|
|
8
|
+
/** Hook-owned workflow handler, also usable by custom progress presentations. */
|
|
9
|
+
copilot: CopilotHandler;
|
|
10
|
+
/**
|
|
11
|
+
* Get props for the outer GenAiStore, not the nested assistant. Appends application event handlers
|
|
12
|
+
* after internal handlers and calls the internal onDispatcher before the application callback.
|
|
13
|
+
* Other props pass through unchanged. Call without arguments for the default connection.
|
|
14
|
+
*/
|
|
15
|
+
genAiStoreProps: (props?: Omit<GenAiStoreProps, "children">) => Omit<GenAiStoreProps, "children">;
|
|
16
|
+
/**
|
|
17
|
+
* Get props for Dashboard. Appends application event handlers after internal handlers and calls
|
|
18
|
+
* the internal onStateChange before the application callback. Merges config while keeping aiMode
|
|
19
|
+
* controlled by the copilot; other props pass through unchanged. Call without arguments for defaults.
|
|
20
|
+
*/
|
|
21
|
+
dashboardProps: (props?: IDashboardProps) => IDashboardProps;
|
|
22
|
+
/**
|
|
23
|
+
* Get props for the assistant inside the shared GenAiStore. Keeps dashboardSelector controlled by
|
|
24
|
+
* the hook to maintain ambient context; other props pass through unchanged. Attach chat event
|
|
25
|
+
* handlers to the outer store using genAiStoreProps. Call without arguments for defaults.
|
|
26
|
+
*/
|
|
27
|
+
assistantProps: (props?: GenAIAssistantProps) => GenAIAssistantProps;
|
|
28
|
+
/** Pass to CopilotInteractionComposingWithHandler around the dashboard. */
|
|
29
|
+
composingProps: Omit<ICopilotInteractionComposingWithHandlerProps, "children">;
|
|
30
|
+
/** Send a message in the current conversation. Ignored until the shared store is ready. */
|
|
31
|
+
sendMessage: (message: string) => void;
|
|
32
|
+
/** Start a new conversation and generate into a new, empty dashboard in edit mode. */
|
|
33
|
+
generateDashboard: (message: string) => void;
|
|
34
|
+
/** Clear creation intent; this does not cancel an assistant response already streaming. */
|
|
35
|
+
cancelGeneration: () => void;
|
|
36
|
+
/** Select the waiting workflow's originating conversation in the shared assistant. */
|
|
37
|
+
replyInChat: () => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Connect a dashboard and assistant using one CopilotHandler and one outer GenAiStore.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* Call once per dashboard/assistant pair. Call `dashboardProps`, `genAiStoreProps`, and `assistantProps` with optional
|
|
44
|
+
* application props, then spread their results onto the respective components. These getters compose
|
|
45
|
+
* event handlers and connection callbacks so application customizations do not replace internal wiring.
|
|
46
|
+
* Spread `composingProps` directly;
|
|
47
|
+
* keep the assistant beside the dashboard and wrap only the dashboard in the composing presentation.
|
|
48
|
+
* Definitions are applied only to an initialized dashboard in edit mode. To generate a new dashboard,
|
|
49
|
+
* mount an empty Dashboard in edit mode before calling `generateDashboard`; this hook does not navigate
|
|
50
|
+
* or replace an existing saved dashboard. Remount the pair when changing backend or workspace.
|
|
51
|
+
*
|
|
52
|
+
* @returns Component props and actions for the connected dashboard and assistant.
|
|
53
|
+
* @alpha
|
|
54
|
+
*/
|
|
55
|
+
export declare function useDashboardCopilot(): IUseDashboardCopilotResult;
|
|
56
|
+
//# sourceMappingURL=useDashboardCopilot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDashboardCopilot.d.ts","sourceRoot":"","sources":["../../src/copilot/useDashboardCopilot.ts"],"names":[],"mappings":"AAMA,OAAO,EAGH,KAAK,eAAe,EAWvB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAUnE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,KAAK,4CAA4C,EAAE,MAAM,6CAA6C,CAAC;AAKhH,qFAAqF;AACrF,MAAM,WAAW,0BAA0B;IACvC,iFAAiF;IACjF,OAAO,EAAE,cAAc,CAAC;IACxB;;;;OAIG;IACH,eAAe,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAClG;;;;OAIG;IACH,cAAc,EAAE,CAAC,KAAK,CAAC,EAAE,eAAe,KAAK,eAAe,CAAC;IAC7D;;;;OAIG;IACH,cAAc,EAAE,CAAC,KAAK,CAAC,EAAE,mBAAmB,KAAK,mBAAmB,CAAC;IACrE,2EAA2E;IAC3E,cAAc,EAAE,IAAI,CAAC,4CAA4C,EAAE,UAAU,CAAC,CAAC;IAC/E,2FAA2F;IAC3F,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,sFAAsF;IACtF,iBAAiB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,2FAA2F;IAC3F,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,sFAAsF;IACtF,WAAW,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,IAAI,0BAA0B,CAsEhE"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { anyDashboardEventHandler, changeDashboardDefinition, isDashboardCommandFailed, isDashboardCommandRejected, isDashboardDefinitionChanged, isDashboardDeinitialized, isDashboardSaved, selectDashboardId, selectDashboardLoading, selectIsInEditMode, } from "@gooddata/sdk-ui-dashboard";
|
|
4
|
+
import { makeUserItem } from "../model.js";
|
|
5
|
+
import { activateConversationAction, dashboardSavedAction, newMessageAction, startNewConversationAction, } from "../store/messages/messagesSlice.js";
|
|
6
|
+
import { CopilotHandler } from "./CopilotHandler.js";
|
|
7
|
+
import { selectCopilotReplyThreadId } from "./selectors.js";
|
|
8
|
+
import { CopilotBuildType } from "./types.js";
|
|
9
|
+
import { useCopilotSnapshot } from "./useCopilotSnapshot.js";
|
|
10
|
+
/**
|
|
11
|
+
* Connect a dashboard and assistant using one CopilotHandler and one outer GenAiStore.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* Call once per dashboard/assistant pair. Call `dashboardProps`, `genAiStoreProps`, and `assistantProps` with optional
|
|
15
|
+
* application props, then spread their results onto the respective components. These getters compose
|
|
16
|
+
* event handlers and connection callbacks so application customizations do not replace internal wiring.
|
|
17
|
+
* Spread `composingProps` directly;
|
|
18
|
+
* keep the assistant beside the dashboard and wrap only the dashboard in the composing presentation.
|
|
19
|
+
* Definitions are applied only to an initialized dashboard in edit mode. To generate a new dashboard,
|
|
20
|
+
* mount an empty Dashboard in edit mode before calling `generateDashboard`; this hook does not navigate
|
|
21
|
+
* or replace an existing saved dashboard. Remount the pair when changing backend or workspace.
|
|
22
|
+
*
|
|
23
|
+
* @returns Component props and actions for the connected dashboard and assistant.
|
|
24
|
+
* @alpha
|
|
25
|
+
*/
|
|
26
|
+
export function useDashboardCopilot() {
|
|
27
|
+
const [dashboardSelector, setDashboardSelector] = useState(null);
|
|
28
|
+
const connection = useMemo(() => createDashboardConnection(setDashboardSelector), []);
|
|
29
|
+
const getDashboardEventHandlers = useMemo(() => createEventHandlersGetter(connection.dashboardProps.eventHandlers), [connection]);
|
|
30
|
+
const getChatEventHandlers = useMemo(() => createEventHandlersGetter(connection.genAiStoreProps.eventHandlers), [connection]);
|
|
31
|
+
const { copilot } = connection;
|
|
32
|
+
const snapshot = useCopilotSnapshot(copilot);
|
|
33
|
+
const scope = {
|
|
34
|
+
type: CopilotBuildType.Dashboard,
|
|
35
|
+
objectId: snapshot.context.objectId,
|
|
36
|
+
isEditing: snapshot.context.isEditing,
|
|
37
|
+
};
|
|
38
|
+
const status = copilot.getStatus(scope);
|
|
39
|
+
const genAiStoreProps = useCallback((props = {}) => ({
|
|
40
|
+
...props,
|
|
41
|
+
eventHandlers: getChatEventHandlers(props.eventHandlers),
|
|
42
|
+
onDispatcher: props.onDispatcher
|
|
43
|
+
? (dispatch) => {
|
|
44
|
+
connection.genAiStoreProps.onDispatcher(dispatch);
|
|
45
|
+
props.onDispatcher?.(dispatch);
|
|
46
|
+
}
|
|
47
|
+
: connection.genAiStoreProps.onDispatcher,
|
|
48
|
+
}), [connection, getChatEventHandlers]);
|
|
49
|
+
const dashboardProps = useCallback((props = {}) => ({
|
|
50
|
+
...props,
|
|
51
|
+
eventHandlers: getDashboardEventHandlers(props.eventHandlers),
|
|
52
|
+
onStateChange: props.onStateChange
|
|
53
|
+
? (state, dispatch) => {
|
|
54
|
+
connection.dashboardProps.onStateChange(state, dispatch);
|
|
55
|
+
props.onStateChange?.(state, dispatch);
|
|
56
|
+
}
|
|
57
|
+
: connection.dashboardProps.onStateChange,
|
|
58
|
+
config: { ...props.config, aiMode: status === "idle" ? undefined : status },
|
|
59
|
+
}), [connection, getDashboardEventHandlers, status]);
|
|
60
|
+
const assistantProps = useCallback((props = {}) => ({ ...props, dashboardSelector }), [dashboardSelector]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
connection.activate();
|
|
63
|
+
return connection.deactivate;
|
|
64
|
+
}, [connection]);
|
|
65
|
+
return {
|
|
66
|
+
copilot,
|
|
67
|
+
genAiStoreProps,
|
|
68
|
+
dashboardProps,
|
|
69
|
+
assistantProps,
|
|
70
|
+
composingProps: { copilot, scope, onReplyInChat: connection.replyInChat },
|
|
71
|
+
sendMessage: connection.sendMessage,
|
|
72
|
+
generateDashboard: connection.generateDashboard,
|
|
73
|
+
cancelGeneration: connection.cancelGeneration,
|
|
74
|
+
replyInChat: connection.replyInChat,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function createEventHandlersGetter(internalHandlers) {
|
|
78
|
+
const cache = new WeakMap();
|
|
79
|
+
return (handlers) => {
|
|
80
|
+
if (!handlers) {
|
|
81
|
+
return internalHandlers;
|
|
82
|
+
}
|
|
83
|
+
let combined = cache.get(handlers);
|
|
84
|
+
if (!combined) {
|
|
85
|
+
combined = [...internalHandlers, ...handlers];
|
|
86
|
+
cache.set(handlers, combined);
|
|
87
|
+
}
|
|
88
|
+
return combined;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function createDashboardConnection(onSelectorChange) {
|
|
92
|
+
const type = CopilotBuildType.Dashboard;
|
|
93
|
+
let active = true;
|
|
94
|
+
let dashboardDispatch;
|
|
95
|
+
let chatDispatch;
|
|
96
|
+
const applications = new Map();
|
|
97
|
+
const copilot = new CopilotHandler({
|
|
98
|
+
registrations: [
|
|
99
|
+
{
|
|
100
|
+
type,
|
|
101
|
+
skills: ["dashboard_builder", "dashboard_editor"],
|
|
102
|
+
resolveDefinition: (event, context, snapshot) => {
|
|
103
|
+
if (!dashboardDispatch ||
|
|
104
|
+
!context.isEditing ||
|
|
105
|
+
event.definitionType !== "dashboard" ||
|
|
106
|
+
!event.dashboard) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
const ownsGeneration = snapshot.requests.some((request) => !request.superseded &&
|
|
110
|
+
request.revision > (snapshot.generationRevision ?? 0) &&
|
|
111
|
+
request.conversationId === event.conversationId &&
|
|
112
|
+
(request.generation === type ||
|
|
113
|
+
(request.type === type && request.intent === "create")));
|
|
114
|
+
return event.dashboard.identifier === context.objectId || ownsGeneration
|
|
115
|
+
? { type, objectId: event.dashboard.identifier }
|
|
116
|
+
: undefined;
|
|
117
|
+
},
|
|
118
|
+
onApplyDefinition: (event, applicationId, target) => {
|
|
119
|
+
applications.set(applicationId, target);
|
|
120
|
+
try {
|
|
121
|
+
dashboardDispatch(changeDashboardDefinition(event.dashboard, { insights: event.insights ?? [] }, applicationId));
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
applications.delete(applicationId);
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
onClarificationQuestions: () => replyInChat(),
|
|
131
|
+
});
|
|
132
|
+
function interruptApplications() {
|
|
133
|
+
for (const id of applications.keys()) {
|
|
134
|
+
copilot.definitionApplicationInterrupted(id);
|
|
135
|
+
}
|
|
136
|
+
applications.clear();
|
|
137
|
+
}
|
|
138
|
+
function disconnectDashboard() {
|
|
139
|
+
dashboardDispatch = undefined;
|
|
140
|
+
interruptApplications();
|
|
141
|
+
copilot.resetInteraction();
|
|
142
|
+
copilot.cancelGeneration(type);
|
|
143
|
+
copilot.setContext({});
|
|
144
|
+
onSelectorChange(() => null);
|
|
145
|
+
}
|
|
146
|
+
function replyInChat() {
|
|
147
|
+
if (!active) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const snapshot = copilot.getSnapshot();
|
|
151
|
+
const conversationId = selectCopilotReplyThreadId(snapshot, { type, ...snapshot.context });
|
|
152
|
+
if (conversationId) {
|
|
153
|
+
chatDispatch?.(activateConversationAction({ conversationId }));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function sendMessage(message) {
|
|
157
|
+
if (active && message.trim()) {
|
|
158
|
+
chatDispatch?.(newMessageAction(makeUserItem({ type: "text", text: message })));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const chatEventHandler = {
|
|
162
|
+
eval: (event) => event !== undefined,
|
|
163
|
+
handler: (event) => {
|
|
164
|
+
if (active) {
|
|
165
|
+
copilot.handleEvent(event);
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
return {
|
|
170
|
+
copilot,
|
|
171
|
+
genAiStoreProps: {
|
|
172
|
+
eventHandlers: [chatEventHandler],
|
|
173
|
+
onDispatcher: (dispatch) => {
|
|
174
|
+
chatDispatch = dispatch;
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
dashboardProps: {
|
|
178
|
+
onStateChange: (state, dispatch) => {
|
|
179
|
+
if (!active) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const loading = selectDashboardLoading(state);
|
|
183
|
+
if (loading.loading || !loading.result) {
|
|
184
|
+
if (dashboardDispatch) {
|
|
185
|
+
disconnectDashboard();
|
|
186
|
+
}
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (dashboardDispatch && dashboardDispatch !== dispatch) {
|
|
190
|
+
disconnectDashboard();
|
|
191
|
+
}
|
|
192
|
+
dashboardDispatch = dispatch;
|
|
193
|
+
const selector = (select) => select(state);
|
|
194
|
+
copilot.setContext({
|
|
195
|
+
type,
|
|
196
|
+
objectId: selectDashboardId(state),
|
|
197
|
+
isEditing: selectIsInEditMode(state),
|
|
198
|
+
});
|
|
199
|
+
onSelectorChange(() => selector);
|
|
200
|
+
},
|
|
201
|
+
eventHandlers: [
|
|
202
|
+
anyDashboardEventHandler((event) => {
|
|
203
|
+
if (!active) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (isDashboardDeinitialized(event)) {
|
|
207
|
+
disconnectDashboard();
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const target = event.correlationId ? applications.get(event.correlationId) : undefined;
|
|
211
|
+
if (target && event.correlationId) {
|
|
212
|
+
if (isDashboardDefinitionChanged(event)) {
|
|
213
|
+
applications.delete(event.correlationId);
|
|
214
|
+
copilot.definitionApplied(event.correlationId, target);
|
|
215
|
+
}
|
|
216
|
+
else if (isDashboardCommandFailed(event) || isDashboardCommandRejected(event)) {
|
|
217
|
+
applications.delete(event.correlationId);
|
|
218
|
+
copilot.definitionApplicationInterrupted(event.correlationId);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (isDashboardSaved(event)) {
|
|
222
|
+
const { dashboard, originalDashboardId, savedInsights } = event.payload;
|
|
223
|
+
const source = copilot.getAppliedSource({
|
|
224
|
+
type,
|
|
225
|
+
objectId: originalDashboardId ?? dashboard.identifier,
|
|
226
|
+
});
|
|
227
|
+
if (source) {
|
|
228
|
+
chatDispatch?.(dashboardSavedAction({
|
|
229
|
+
conversationId: source.conversationId,
|
|
230
|
+
originalDashboardId: originalDashboardId ?? dashboard.identifier,
|
|
231
|
+
savedDashboardId: dashboard.identifier,
|
|
232
|
+
savedInsights: savedInsights ?? [],
|
|
233
|
+
}));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}),
|
|
237
|
+
],
|
|
238
|
+
},
|
|
239
|
+
sendMessage,
|
|
240
|
+
generateDashboard: (message) => {
|
|
241
|
+
if (!active || !chatDispatch || !dashboardDispatch || !message.trim()) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const { context } = copilot.getSnapshot();
|
|
245
|
+
if (!context.isEditing || context.objectId) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
copilot.startGeneration(type);
|
|
249
|
+
chatDispatch(startNewConversationAction());
|
|
250
|
+
sendMessage(message);
|
|
251
|
+
},
|
|
252
|
+
cancelGeneration: () => copilot.cancelGeneration(type),
|
|
253
|
+
replyInChat,
|
|
254
|
+
activate: () => {
|
|
255
|
+
active = true;
|
|
256
|
+
},
|
|
257
|
+
deactivate: () => {
|
|
258
|
+
active = false;
|
|
259
|
+
interruptApplications();
|
|
260
|
+
// React StrictMode replays effects before this microtask; do not dispose a reactivated instance.
|
|
261
|
+
queueMicrotask(() => {
|
|
262
|
+
if (!active) {
|
|
263
|
+
copilot.dispose();
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
}
|
package/esm/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
export { CopilotHandler, useCopilotSnapshot, createCopilotState, transitionCopilot, selectCopilotGenerationPending, selectCopilotStatus, selectCopilotReasoningTitle, selectCopilotSource, CopilotBuildType, type CopilotStatus, type CopilotInput, type ICopilotTarget, type ICopilotContext, type ICopilotScope, type ICopilotSource, type ICopilotApplicationSource, type ICopilotInteraction, type ICopilotRequest, type ICopilotApplication, type ICopilotSnapshot, type ICopilotRegistration, type ICopilotConfiguration, } from "./copilot.js";
|
|
7
7
|
export { CopilotInteractionComposing, type ICopilotInteractionComposingProps, } from "./copilot/CopilotInteractionComposing.js";
|
|
8
8
|
export { CopilotInteractionComposingWithHandler, type ICopilotInteractionComposingWithHandlerProps, } from "./copilot/CopilotInteractionComposingWithHandler.js";
|
|
9
|
+
export { useDashboardCopilot, type IUseDashboardCopilotResult } from "./copilot/useDashboardCopilot.js";
|
|
9
10
|
export { GenAIChat, GenAIAssistant, type GenAIChatProps, type GenAIAssistantProps, } from "./components/GenAIChat.js";
|
|
10
11
|
export { GenAIConversations, type GenAIConversationsProps } from "./components/GenAiConversations.js";
|
|
11
12
|
export { GenAiStore, type GenAiStoreProps } from "./components/GenAiStore.js";
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH,OAAO,EACH,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,8BAA8B,EAC9B,mBAAmB,EACnB,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,GAC7B,MAAM,cAAc,CAAC;AACtB,OAAO,EACH,2BAA2B,EAC3B,KAAK,iCAAiC,GACzC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACH,sCAAsC,EACtC,KAAK,4CAA4C,GACpD,MAAM,qDAAqD,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH,OAAO,EACH,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,8BAA8B,EAC9B,mBAAmB,EACnB,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,GAC7B,MAAM,cAAc,CAAC;AACtB,OAAO,EACH,2BAA2B,EAC3B,KAAK,iCAAiC,GACzC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACH,sCAAsC,EACtC,KAAK,4CAA4C,GACpD,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE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