diff --git a/src/ui/src/builder/sidebar/BuilderSidebarToolkit.vue b/src/ui/src/builder/sidebar/BuilderSidebarToolkit.vue
index d9bc28bf..dcd447b8 100644
--- a/src/ui/src/builder/sidebar/BuilderSidebarToolkit.vue
+++ b/src/ui/src/builder/sidebar/BuilderSidebarToolkit.vue
@@ -23,19 +23,10 @@
@dragend="handleDragEnd($event)"
@dragstart="handleDragStart($event, tool.type)"
>
-
{{ tool.name }}
@@ -54,12 +45,13 @@ import {
import injectionKeys from "@/injectionKeys";
import { useDragDropComponent } from "../useDragDropComponent";
import { Component } from "@/writerTypes";
+import SharedImgWithFallback from "@/components/shared/SharedImgWithFallback.vue";
+import { convertAbsolutePathtoFullURL } from "@/utils/url";
const wf = inject(injectionKeys.core);
const wfbm = inject(injectionKeys.builderManager);
const { removeInsertionCandidacy } = useDragDropComponent(wf);
const query = ref("");
-const isImageFallback = ref>({});
const displayedCategories = [
"Layout",
@@ -114,16 +106,6 @@ function getRelevantToolsInCategory(categoryId: string) {
return queryApplied;
}
-function handleImageError(
- ev: Event,
- type: Component["type"],
- categoryId: string,
-) {
- isImageFallback.value[type] = true; // Prevent calling more than once
- const imageEl = ev.target as HTMLImageElement;
- imageEl.src = `./../../../../components/category_${categoryId}.svg`;
-}
-
function handleDragStart(ev: DragEvent, type: Component["type"]) {
wfbm.setSelection(null);
ev.dataTransfer.setData(`application/json;writer=${type},`, "{}");
@@ -133,6 +115,13 @@ function handleDragEnd(ev: DragEvent) {
removeInsertionCandidacy(ev);
}
+function getToolIcons(tool: ReturnType[0]) {
+ return [
+ `/components/${tool.type}.svg`,
+ `/components/category_${tool.category}.svg`,
+ ].map((p) => convertAbsolutePathtoFullURL(p));
+}
+
watch(activeToolkit, () => {
query.value = "";
});
diff --git a/src/ui/src/components/core/content/CoreChatbot.vue b/src/ui/src/components/core/content/CoreChatbot.vue
index 521bfa16..0cba76b7 100644
--- a/src/ui/src/components/core/content/CoreChatbot.vue
+++ b/src/ui/src/components/core/content/CoreChatbot.vue
@@ -401,7 +401,7 @@ function scrollToBottom() {
}
const encodeFile = async (file: File) => {
- var reader = new FileReader();
+ const reader = new FileReader();
reader.readAsDataURL(file);
return new Promise((resolve, reject) => {
diff --git a/src/ui/src/components/shared/SharedImgWithFallback.spec.ts b/src/ui/src/components/shared/SharedImgWithFallback.spec.ts
new file mode 100644
index 00000000..846fc944
--- /dev/null
+++ b/src/ui/src/components/shared/SharedImgWithFallback.spec.ts
@@ -0,0 +1,37 @@
+import { describe, it, expect, vi, beforeEach, Mock } from "vitest";
+import SharedImgWithFallback from "./SharedImgWithFallback.vue";
+import { flushPromises, shallowMount } from "@vue/test-utils";
+
+describe("SharedImgWithFallback", () => {
+ let fetch: Mock;
+
+ beforeEach(() => {
+ fetch = vi.fn().mockResolvedValue({
+ ok: true,
+ headers: new Map([["Content-Type", "image/png"]]),
+ });
+ global.fetch = fetch;
+ });
+
+ it("should use the last image because the first two are not valid", async () => {
+ fetch
+ .mockRejectedValueOnce(new Error())
+ .mockResolvedValueOnce({
+ ok: true,
+ headers: new Map([["Content-Type", "text/html"]]),
+ })
+ .mockResolvedValue({
+ ok: true,
+ headers: new Map([["Content-Type", "image/png"]]),
+ });
+
+ const wrapper = shallowMount(SharedImgWithFallback, {
+ props: { urls: ["/img1.svg", "/img2.svg", "/img3.svg"] },
+ });
+ expect(wrapper.get("img").attributes().src).toBe("");
+
+ await flushPromises();
+
+ expect(wrapper.get("img").attributes().src).toBe("/img3.svg");
+ });
+});
diff --git a/src/ui/src/components/shared/SharedImgWithFallback.vue b/src/ui/src/components/shared/SharedImgWithFallback.vue
new file mode 100644
index 00000000..d4b0d7b4
--- /dev/null
+++ b/src/ui/src/components/shared/SharedImgWithFallback.vue
@@ -0,0 +1,31 @@
+
+
+
+
+
diff --git a/src/ui/src/components/workflows/abstract/WorkflowsNode.vue b/src/ui/src/components/workflows/abstract/WorkflowsNode.vue
index 5db673f1..757e4ec8 100644
--- a/src/ui/src/components/workflows/abstract/WorkflowsNode.vue
+++ b/src/ui/src/components/workflows/abstract/WorkflowsNode.vue
@@ -1,7 +1,7 @@
-
+