Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Cherry-pick Ensu v0.1.9 non-migration fixes

Prateek Sunalbc7664b719b2
diff --git a/rust/apps/ensu/package.json b/rust/apps/ensu/package.json
index cac213affe..2a53a0141e 100644
--- a/rust/apps/ensu/package.json
+++ b/rust/apps/ensu/package.json
@@ -1,6 +1,6 @@
{
"name": "ensu-tauri",
- "version": "0.1.8",
+ "version": "0.1.9",
"private": true,
"scripts": {
"dev": "node scripts/tauri-dev.mjs",
diff --git a/rust/apps/ensu/src-tauri/Cargo.toml b/rust/apps/ensu/src-tauri/Cargo.toml
index 58b59f1099..625231ad52 100644
--- a/rust/apps/ensu/src-tauri/Cargo.toml
+++ b/rust/apps/ensu/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ensu-tauri"
-version = "0.1.8"
+version = "0.1.9"
description = "Ensu Desktop (Tauri)"
edition = "2021"
diff --git a/rust/apps/ensu/src-tauri/tauri.conf.json b/rust/apps/ensu/src-tauri/tauri.conf.json
index ff7f095108..4fe93a51ae 100644
--- a/rust/apps/ensu/src-tauri/tauri.conf.json
+++ b/rust/apps/ensu/src-tauri/tauri.conf.json
@@ -7,7 +7,7 @@
},
"package": {
"productName": "Ensu",
- "version": "0.1.8"
+ "version": "0.1.9"
},
"tauri": {
"windows": [
diff --git a/web/apps/ensu/package.json b/web/apps/ensu/package.json
index 8ee0e66bfc..0dfbe0888a 100644
--- a/web/apps/ensu/package.json
+++ b/web/apps/ensu/package.json
@@ -1,6 +1,6 @@
{
"name": "ensu",
- "version": "0.1.8",
+ "version": "0.1.9",
"private": true,
"dependencies": {
"@fontsource/cormorant-garamond": "^5.2.7",
diff --git a/web/apps/ensu/src/components/MarkdownRenderer.tsx b/web/apps/ensu/src/components/MarkdownRenderer.tsx
index 697024a51a..2bce7f0d64 100644
--- a/web/apps/ensu/src/components/MarkdownRenderer.tsx
+++ b/web/apps/ensu/src/components/MarkdownRenderer.tsx
@@ -95,6 +95,47 @@ const CodeBlock = ({ children, node: _node, ...rest }: PreProps) => {
);
};
+const openExternalUrl = async (url: string) => {
+ const hasTauriBridge =
+ typeof window !== "undefined" &&
+ ("__TAURI__" in window ||
+ "__TAURI_IPC__" in window ||
+ "__TAURI_INTERNALS__" in window ||
+ "__TAURI_METADATA__" in window);
+
+ if (hasTauriBridge) {
+ try {
+ const { open } = await import("@tauri-apps/api/shell");
+ await open(url);
+ return;
+ } catch {
+ // Fall back to the browser open path below.
+ }
+ }
+
+ if (typeof window !== "undefined") {
+ const popup = window.open(url, "_blank", "noopener,noreferrer");
+ if (!popup) {
+ window.location.href = url;
+ }
+ }
+};
+
+type AnchorProps = React.ComponentPropsWithoutRef<"a"> & { node?: unknown };
+
+const ExternalLink = ({ node: _node, href, children, ...rest }: AnchorProps) => (
+ <a
+ {...rest}
+ href={href}
+ onClick={(e) => {
+ e.preventDefault();
+ if (href) void openExternalUrl(href);
+ }}
+ >
+ {children}
+ </a>
+);
+
export const MarkdownRenderer = ({
content,
className,
@@ -109,7 +150,7 @@ export const MarkdownRenderer = ({
{ strict: false, throwOnError: false, trust: true },
],
]}
- components={{ pre: CodeBlock }}
+ components={{ pre: CodeBlock, a: ExternalLink }}
>
{content}
</ReactMarkdown>
diff --git a/web/apps/ensu/src/pages/chat.tsx b/web/apps/ensu/src/pages/chat.tsx
index 984c34516a..cc7f83e4bd 100644
--- a/web/apps/ensu/src/pages/chat.tsx
+++ b/web/apps/ensu/src/pages/chat.tsx
@@ -1895,6 +1895,7 @@ const Page: React.FC = () => {
});
});
+ // Clean up blob URLs for attachments no longer displayed.
setAttachmentPreviews((prev) => {
const next = { ...prev };
Object.keys(next).forEach((id) => {
@@ -1909,7 +1910,17 @@ const Page: React.FC = () => {
attachmentPreviewUrlsRef.current = next;
return next;
});
- }, [chatKey, displayMessages]);
+
+ // Load previews for persisted image attachments that do not have blob
+ // URLs yet, such as after reopening the app.
+ for (const message of displayMessages) {
+ for (const attachment of message.attachments ?? []) {
+ if (attachment.kind === "image") {
+ loadAttachmentPreview(attachment, message.sessionUuid);
+ }
+ }
+ }
+ }, [chatKey, displayMessages, loadAttachmentPreview]);
const showDrawerToggle = isSmall || drawerCollapsed;
const drawerWidth = isSmall ? 300 : drawerCollapsed ? 0 : 320;
@@ -2746,8 +2757,7 @@ const Page: React.FC = () => {
await writeBinaryFile({ path: filePath, contents: bytes });
- const fileUrl = encodeURI(`file://${filePath}`);
- await open(fileUrl);
+ await open(filePath);
return;
}