Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(chat): add error fallback for image rendering, try multiple src strategies

Louis Beaumont186389e308bd
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
index 563b93535..09b5f5983 100644
--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx
+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
@@ -589,13 +589,30 @@ function MarkdownBlock({ text, isUser }: { text: string; isUser: boolean }) {
if (src.toLowerCase().endsWith(".mp4")) {
return <VideoComponent filePath={src} className="my-2" />;
}
- const imgSrc = src.startsWith("/") ? convertFileSrc(src) : src;
+ // try asset protocol for local paths, fall back to http serve
+ let imgSrc = src;
+ if (src.startsWith("/")) {
+ try {
+ imgSrc = convertFileSrc(src);
+ } catch {
+ imgSrc = `http://localhost:3030/experimental/frames/from-file?path=${encodeURIComponent(src)}`;
+ }
+ }
return (
+ // eslint-disable-next-line @next/next/no-img-element
<img
src={imgSrc}
alt={alt || ""}
- className="max-w-full h-auto rounded-md my-2"
+ className="max-w-full h-auto rounded-md my-2 border border-border"
loading="lazy"
+ onError={(e) => {
+ // fallback: if asset protocol fails, try convertFileSrc or raw path
+ const target = e.currentTarget;
+ if (src.startsWith("/") && !target.dataset.retried) {
+ target.dataset.retried = "1";
+ target.src = convertFileSrc(src);
+ }
+ }}
{...props}
/>
);