diff --git a/CHANGELOG.md b/CHANGELOG.md index 88fca1f..f4a4161 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This log records user-visible changes. GitHub releases contain package downloads ### 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. - Forget access and Remove connection work for a Tailscale HTTP route after its peer leaves the tailnet or Tailscale stops, instead of failing and leaving the saved grant in the credential store. ### Maintenance diff --git a/desktop/src-tauri/src/main.rs b/desktop/src-tauri/src/main.rs index d1c18bc..0ef46d0 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, @@ -685,7 +695,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 @@ -4946,6 +4960,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();