Skip to content

Commit 74d7e9b

Browse files
committed
add error boundary
1 parent 6ce6f53 commit 74d7e9b

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

frontend/app/aipanel/aipanel.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { WaveUIMessagePart } from "@/app/aipanel/aitypes";
5+
import { ErrorBoundary } from "@/app/element/errorboundary";
56
import { atoms, getSettingsKeyAtom } from "@/app/store/global";
67
import { globalStore } from "@/app/store/jotaiStore";
78
import { getWebServerEndpoint } from "@/util/endpoints";
@@ -24,7 +25,7 @@ interface AIPanelProps {
2425
onClose?: () => void;
2526
}
2627

27-
const AIPanelComponent = memo(({ className, onClose }: AIPanelProps) => {
28+
const AIPanelComponentInner = memo(({ className, onClose }: AIPanelProps) => {
2829
const [input, setInput] = useState("");
2930
const [isDragOver, setIsDragOver] = useState(false);
3031
const model = WaveAIModel.getInstance();
@@ -220,9 +221,11 @@ const AIPanelComponent = memo(({ className, onClose }: AIPanelProps) => {
220221

221222
if (acceptableFiles.length < files.length) {
222223
const rejectedCount = files.length - acceptableFiles.length;
223-
const rejectedFiles = files.filter(f => !isAcceptableFile(f));
224-
const fileNames = rejectedFiles.map(f => f.name).join(", ");
225-
model.setError(`${rejectedCount} file${rejectedCount > 1 ? 's' : ''} rejected (unsupported type): ${fileNames}. Supported: images, PDFs, and text/code files.`);
224+
const rejectedFiles = files.filter((f) => !isAcceptableFile(f));
225+
const fileNames = rejectedFiles.map((f) => f.name).join(", ");
226+
model.setError(
227+
`${rejectedCount} file${rejectedCount > 1 ? "s" : ""} rejected (unsupported type): ${fileNames}. Supported: images, PDFs, and text/code files.`
228+
);
226229
}
227230
};
228231

@@ -332,6 +335,16 @@ const AIPanelComponent = memo(({ className, onClose }: AIPanelProps) => {
332335
);
333336
});
334337

338+
AIPanelComponentInner.displayName = "AIPanelInner";
339+
340+
const AIPanelComponent = ({ className, onClose }: AIPanelProps) => {
341+
return (
342+
<ErrorBoundary>
343+
<AIPanelComponentInner className={className} onClose={onClose} />
344+
</ErrorBoundary>
345+
);
346+
};
347+
335348
AIPanelComponent.displayName = "AIPanel";
336349

337350
export { AIPanelComponent as AIPanel };

0 commit comments

Comments
 (0)