From be96b5f68fd84ecb4c2c596e1b90b04af440ee24 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 12:08:46 -0800 Subject: [PATCH] fix(aws): the copy-at-connect warning gets its own toast topic Co-Authored-By: Claude Opus 5.5 --- .../src/commands/project_commands.rs | 30 +++++++++++++------ app/src/hooks/useWorkspaceWarnings.test.ts | 17 +++++++++++ app/src/hooks/useWorkspaceWarnings.ts | 2 +- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/app/src-tauri/src/commands/project_commands.rs b/app/src-tauri/src/commands/project_commands.rs index 1bad944..751ee4c 100644 --- a/app/src-tauri/src/commands/project_commands.rs +++ b/app/src-tauri/src/commands/project_commands.rs @@ -1583,16 +1583,19 @@ fn emit_workspace_warning(app_handle: &tauri::AppHandle, project_id: &str, name: } /// Copy-at-connect's warning (Q2): the credentials could not be copied into -/// a connected workspace. Same `workspace-warning` event as the follower's. +/// a connected workspace. Same `workspace-warning` event as the follower's, +/// with its own `topic` so neither replaces the other's toast. fn emit_connect_warning(app_handle: &tauri::AppHandle, project_id: &str, name: &str, detail: &str) { - let _ = app_handle.emit( - "workspace-warning", - serde_json::json!({ - "project_id": project_id, - "message": format!("“{name}”: the credentials could not be copied into the workspace"), - "detail": detail, - }), - ); + let _ = app_handle.emit("workspace-warning", connect_warning_payload(project_id, name, detail)); +} + +fn connect_warning_payload(project_id: &str, name: &str, detail: &str) -> serde_json::Value { + serde_json::json!({ + "project_id": project_id, + "message": format!("“{name}”: the credentials could not be copied into the workspace"), + "detail": detail, + "topic": "connect", + }) } /// Port mappings that could not be forwarded to a connected AWS workspace @@ -2199,6 +2202,15 @@ pub async fn reconcile_aws_projects( #[cfg(test)] mod tests { + #[test] + fn the_connect_warning_has_its_own_toast_topic() { + let v = super::connect_warning_payload("p1", "demo", "upload failed"); + assert_eq!(v["topic"], "connect"); + assert_eq!(v["project_id"], "p1"); + assert_eq!(v["detail"], "upload failed"); + assert!(v["message"].as_str().unwrap().contains("demo")); + } + use super::*; // ── Pending-cleanup aging ──────────────────────────────────────────── diff --git a/app/src/hooks/useWorkspaceWarnings.test.ts b/app/src/hooks/useWorkspaceWarnings.test.ts index 53166d7..ecc2c34 100644 --- a/app/src/hooks/useWorkspaceWarnings.test.ts +++ b/app/src/hooks/useWorkspaceWarnings.test.ts @@ -55,4 +55,21 @@ describe("useWorkspaceWarnings", () => { expect(toasts).toHaveLength(2); expect(toasts[1].detail).toContain("already in use"); }); + + it("keeps a copy-at-connect warning beside the start's own warning", async () => { + renderHook(() => useWorkspaceWarnings()); + await vi.waitFor(() => expect(handler).not.toBeNull()); + handler!({ payload: { project_id: "p1", message: "started", detail: "clone failed" } }); + handler!({ + payload: { + project_id: "p1", + message: "“demo”: the credentials could not be copied into the workspace", + detail: "upload failed", + topic: "connect", + }, + }); + const { toasts } = useAppState.getState(); + expect(toasts).toHaveLength(2); + expect(toasts.map((t) => t.detail)).toEqual(["clone failed", "upload failed"]); + }); }); diff --git a/app/src/hooks/useWorkspaceWarnings.ts b/app/src/hooks/useWorkspaceWarnings.ts index 1bab718..8b90dc2 100644 --- a/app/src/hooks/useWorkspaceWarnings.ts +++ b/app/src/hooks/useWorkspaceWarnings.ts @@ -10,7 +10,7 @@ export interface WorkspaceWarningEvent { message: string; detail: string; /** Set when the warning is about something else than the start's own - * follow (`"ports"`): keeps it from replacing that toast. */ + * follow (`"ports"`, `"connect"`): keeps it from replacing that toast. */ topic?: string; }