From 0492e8a145efc68ed1212a9b2966199ae596cc15 Mon Sep 17 00:00:00 2001 From: Brew Date: Sat, 14 Nov 2026 11:28:36 -0800 Subject: [PATCH] fix(threads): resolve project icons only for local environments Thread snapshots resolved each thread's workspaceRoot and projectFaviconPath against this computer's filesystem, including threads from paired remote environments. Those paths name files on the remote machine, so the remote could steer Bar to read local files (up to 2 MB, through NSImage on macOS) or show an unrelated local icon. Resolve favicons only for environments in Bar's local sources. Remote threads show the default icon. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 +++ desktop/src-tauri/src/main.rs | 54 +++++++++++++++++++++++++++++++---- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cb0685..d9de5f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ This log records user-visible changes. GitHub releases contain package downloads ## Unreleased +### Fixed + +- Threads from remote environments no longer resolve project icons from this computer's files. Remote project paths name files on the remote machine, so their threads show the default icon. + ### Maintenance - Add contribution, security, support, community, and issue-reporting guidance. diff --git a/desktop/src-tauri/src/main.rs b/desktop/src-tauri/src/main.rs index bb13801..87bca52 100644 --- a/desktop/src-tauri/src/main.rs +++ b/desktop/src-tauri/src/main.rs @@ -376,18 +376,28 @@ fn environment_cache_path(settings: &Path) -> PathBuf { fn iso(d: Option>) -> Option { d.map(|v| v.to_rfc3339_opts(chrono::SecondsFormat::Millis, true)) } +/// Project paths name files on the machine that reported them. Only a local +/// environment's paths are this machine's, so a remote thread never makes Bar +/// read local files for an icon. +fn project_favicon( + favicons: &favicons::Favicons, + t: &threads::ThreadItem, + local: bool, +) -> Option { + local + .then(|| favicons.resolve(t.workspace_root.as_deref(), t.project_favicon_path.as_deref())) + .flatten() +} fn thread_item( t: threads::ThreadItem, environment_id: &EnvironmentId, + local: bool, state: &RuntimeState, ) -> Option { let project_favicon = if state.fixture { None } else { - state.favicons.resolve( - t.workspace_root.as_deref(), - t.project_favicon_path.as_deref(), - ) + project_favicon(&state.favicons, &t, local) }; Some(ThreadItem { project_favicon, @@ -669,7 +679,11 @@ fn view_snapshot(state: &RuntimeState) -> Result { } snapshot.threads = hub .selected_threads() - .filter_map(|t| thread_item(t.item().clone(), &t.reference().environment_id, state)) + .filter_map(|t| { + let environment_id = &t.reference().environment_id; + let local = local_sources.contains_key(environment_id); + thread_item(t.item().clone(), environment_id, local, state) + }) .collect(); let selected_sources: Vec<_> = hub.selected_sources().collect(); let selected: Vec<_> = selected_sources @@ -4616,6 +4630,36 @@ while True: ); } + #[test] + fn only_local_threads_resolve_project_favicons_from_this_machine() { + let project = tempfile::tempdir().unwrap(); + std::fs::write(project.path().join("favicon.svg"), "").unwrap(); + let explicit = project.path().join("icon.svg"); + std::fs::write(&explicit, "").unwrap(); + let item = |root: Option<&Path>, favicon: Option<&Path>| -> threads::ThreadItem { + serde_json::from_value(json!({ + "id":"t", "projectId":"p", "projectTitle":"p", "title":"t", + "createdAt":"2024-01-01T00:00:00Z", "updatedAt":"2024-01-01T00:00:00Z", + "pendingUserInputCount":0, "pendingApprovalCount":0, "providers":[], + "hasGoal":false, "isPinned":false, "isSettled":false, "isSnoozed":false, + "isWoke":false, "pendingGuestMessageCount":0, "isBlockedOnThreadWait":false, + "hasRuns":false, "status":"Approval", "priority":0, "isRunning":false, + "isAttention":true, "showsLabelInMenuBar":true, + "workspaceRoot": root.map(|p| p.to_str().unwrap()), + "projectFaviconPath": favicon.map(|p| p.to_str().unwrap()), + })) + .unwrap() + }; + let by_root = item(Some(project.path()), None); + let by_path = item(None, Some(&explicit)); + let favicons = favicons::Favicons::default(); + assert!(project_favicon(&favicons, &by_root, true).is_some()); + assert!(project_favicon(&favicons, &by_path, true).is_some()); + let remote = favicons::Favicons::default(); + assert_eq!(project_favicon(&remote, &by_root, false), None); + assert_eq!(project_favicon(&remote, &by_path, false), None); + } + #[test] fn notification_and_thread_actions_resolve_one_source_per_environment() { let directory = tempfile::tempdir().unwrap();