diff --git a/web-common/src/features/charts/prompt/ChartPromptStatusDisplay.svelte b/web-common/src/features/charts/prompt/ChartPromptStatusDisplay.svelte
index 1a689c045f6..8b6e303ad64 100644
--- a/web-common/src/features/charts/prompt/ChartPromptStatusDisplay.svelte
+++ b/web-common/src/features/charts/prompt/ChartPromptStatusDisplay.svelte
@@ -1,10 +1,9 @@
-{#if $chartPrompt && $chartPrompt.status !== ChartPromptStatus.Idle && $chartPrompt.status !== ChartPromptStatus.Error}
+{#if $chartPrompt && $chartPrompt?.status === ChartPromptStatus.Error}
+
+
+
+
Failed to generate chart using AI
+
Using prompt: "{$chartPrompt.prompt}"
+
{$chartPrompt.error}
+
+
+{:else if $chartPrompt && $chartPrompt.status !== ChartPromptStatus.Idle}
-
+
Generating {$chartPrompt.status === ChartPromptStatus.GeneratingData
diff --git a/web-common/src/features/charts/prompt/chartPrompt.ts b/web-common/src/features/charts/prompt/chartPrompt.ts
index 05311d7e2ba..d76c23bc750 100644
--- a/web-common/src/features/charts/prompt/chartPrompt.ts
+++ b/web-common/src/features/charts/prompt/chartPrompt.ts
@@ -14,7 +14,7 @@ export type ChartPrompt = {
prompt: string;
time: number;
status: ChartPromptStatus;
- // TODO: store error as well?
+ error?: string;
};
export type ChartPromptHistory = {
@@ -74,6 +74,20 @@ export class ChartPromptsStore {
});
}
+ public setPromptError(chartName: string, error: string) {
+ this.chartStatus.update((cs) => {
+ if (cs[chartName]) {
+ cs[chartName].status = ChartPromptStatus.Error;
+ cs[chartName].error = error;
+ }
+ return cs;
+ });
+ this.history.update((h) => {
+ if (!h.entities[chartName]?.length) return;
+ h.entities[chartName][0].status = ChartPromptStatus.Error;
+ });
+ }
+
private addToHistory(entityName: string, newEntry: ChartPrompt) {
let history = get(this.history);
history.entities[entityName] ??= [];
diff --git a/web-common/src/features/charts/prompt/generateChart.ts b/web-common/src/features/charts/prompt/generateChart.ts
index a9a8e3b4332..f44ef9b044b 100644
--- a/web-common/src/features/charts/prompt/generateChart.ts
+++ b/web-common/src/features/charts/prompt/generateChart.ts
@@ -43,7 +43,10 @@ export function createChartGenerator(instanceId: string, chart: string) {
),
});
} catch (e) {
- chartPromptsStore.updatePromptStatus(chart, ChartPromptStatus.Error);
+ chartPromptsStore.setPromptError(
+ chart,
+ e.message ?? e.response.data.message,
+ );
}
};
}
@@ -119,9 +122,9 @@ export function createFullChartGenerator(instanceId: string) {
),
});
} catch (e) {
- chartPromptsStore.updatePromptStatus(
+ chartPromptsStore.setPromptError(
newChartName,
- ChartPromptStatus.Error,
+ e.message ?? e.response.data.message,
);
}
};