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(notif-panel): don't double-encode already-encoded markdown links

Louis Beaumontbb232fb28d34
diff --git a/apps/screenpipe-app-tauri/src-tauri/swift/notification_panel.swift b/apps/screenpipe-app-tauri/src-tauri/swift/notification_panel.swift
index 1019cade6..6f532b7ef 100644
--- a/apps/screenpipe-app-tauri/src-tauri/swift/notification_panel.swift
+++ b/apps/screenpipe-app-tauri/src-tauri/swift/notification_panel.swift
@@ -434,7 +434,20 @@ struct MarkdownText: View {
if urlStr.hasPrefix("/") && !urlStr.hasPrefix("//") {
urlStr = "file://" + urlStr
}
- if let url = URL(string: urlStr.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? urlStr) ?? URL(string: urlStr) {
+ // Try the raw string first — markdown links are
+ // already valid URLs almost always, and
+ // `addingPercentEncoding(.urlQueryAllowed)` will
+ // re-encode existing `%xx` escapes (e.g. the
+ // `%2F`s in a `screenpipe://view?path=…` link
+ // produced by the /notify rewrite). That
+ // double-encoding silently corrupts the path,
+ // so the viewer ends up calling
+ // `read_viewer_file` with literal `%2F` in the
+ // filename and fails with ENOENT.
+ // Fall back to encoding only if the raw form
+ // doesn't parse (e.g. unencoded spaces).
+ if let url = URL(string: urlStr)
+ ?? URL(string: urlStr.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? urlStr) {
flushText()
let override = MarkdownText.viewerOverridePath(for: url)
segments.append(.link(label: linkText, url: url, viewerOverridePath: override))