feat(workspace-manager): added remove button to workspace card in wokspace list view#1103
Conversation
…kspace list view Signed-off-by: Marcel Bertagnini <mbertagn@redhat.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a trash (remove) button to AgentWorkspaceCard that shows a confirmation dialog and, on confirmation, calls Changes
Sequence DiagramsequenceDiagram
participant User
participant Card as AgentWorkspaceCard
participant Dialog as Confirmation Dialog
participant IPC as window.removeAgentWorkspace()
participant Refresh as window.listAgentWorkspaces()
User->>Card: Click remove (trash icon)
Card->>Dialog: Show confirmation dialog
Dialog->>User: Display confirmation prompt
User->>Dialog: Click confirm (response: 0) or cancel (response: 1)
alt confirmed
Dialog->>Card: Return confirm
Card->>IPC: removeAgentWorkspace(workspace.id)
IPC-->>Card: Removal complete
Card->>Refresh: listAgentWorkspaces()
Refresh-->>Card: Updated list
else cancelled
Dialog->>Card: Return cancel
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can generate a title for your PR based on the changes.Add |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/renderer/src/lib/agent-workspaces/AgentWorkspaceCard.spec.ts (2)
96-105: Add wait before asserting negative condition.The assertion at line 104 runs immediately after
fireEvent.click, butshowMessageBoxis async. Although the mock resolves quickly, waiting for the promise chain to settle ensures deterministic behavior.♻️ Suggested fix
const removeButton = screen.getByRole('button', { name: 'Remove workspace api-refactor' }); await fireEvent.click(removeButton); + await vi.waitFor(() => { + expect(window.showMessageBox).toHaveBeenCalled(); + }); expect(window.removeAgentWorkspace).not.toHaveBeenCalled(); });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/renderer/src/lib/agent-workspaces/AgentWorkspaceCard.spec.ts` around lines 96 - 105, The test "Expect workspace not removed when user cancels" asserts immediately after fireEvent.click while window.showMessageBox is asynchronous; update the test (around the fireEvent.click and the expect that window.removeAgentWorkspace was not called) to await the async resolution before asserting—use a testing utility like waitFor (or an equivalent promise flush) to wait for the modal promise to settle, then assert that removeAgentWorkspace was not called so the expectation is deterministic.
83-94: Consider adding assertion for list refresh after removal.The test verifies
removeAgentWorkspaceis called, but doesn't verify thatlistAgentWorkspacesis called afterwards to refresh the workspace list. This is part of the expected behavior per the component's.then(fetchAgentWorkspaces)chain.♻️ Suggested addition
await vi.waitFor(() => { expect(window.removeAgentWorkspace).toHaveBeenCalledWith('ws-1'); }); + await vi.waitFor(() => { + expect(window.listAgentWorkspaces).toHaveBeenCalled(); + }); });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/renderer/src/lib/agent-workspaces/AgentWorkspaceCard.spec.ts` around lines 83 - 94, Add an assertion that the workspace list is refreshed after removal by expecting the listAgentWorkspaces function to have been called; e.g., ensure window.listAgentWorkspaces (or the exported listAgentWorkspaces/fetchAgentWorkspaces function used by AgentWorkspaceCard) is mocked beforehand and then, after the existing waitFor that checks window.removeAgentWorkspace('ws-1'), add an expectation like expect(window.listAgentWorkspaces).toHaveBeenCalled() so the test verifies the .then(fetchAgentWorkspaces) refresh behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/renderer/src/lib/agent-workspaces/AgentWorkspaceCard.spec.ts`:
- Around line 96-105: The test "Expect workspace not removed when user cancels"
asserts immediately after fireEvent.click while window.showMessageBox is
asynchronous; update the test (around the fireEvent.click and the expect that
window.removeAgentWorkspace was not called) to await the async resolution before
asserting—use a testing utility like waitFor (or an equivalent promise flush) to
wait for the modal promise to settle, then assert that removeAgentWorkspace was
not called so the expectation is deterministic.
- Around line 83-94: Add an assertion that the workspace list is refreshed after
removal by expecting the listAgentWorkspaces function to have been called; e.g.,
ensure window.listAgentWorkspaces (or the exported
listAgentWorkspaces/fetchAgentWorkspaces function used by AgentWorkspaceCard) is
mocked beforehand and then, after the existing waitFor that checks
window.removeAgentWorkspace('ws-1'), add an expectation like
expect(window.listAgentWorkspaces).toHaveBeenCalled() so the test verifies the
.then(fetchAgentWorkspaces) refresh behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3fd5eb54-f490-43b2-a8aa-28e8a7767f79
📒 Files selected for processing (2)
packages/renderer/src/lib/agent-workspaces/AgentWorkspaceCard.spec.tspackages/renderer/src/lib/agent-workspaces/AgentWorkspaceCard.svelte
packages/renderer/src/lib/agent-workspaces/AgentWorkspaceCard.spec.ts
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Signed-off-by: Marcel Bertagnini <mbertagn@redhat.com>
Unit tests for the remove button rendering, confirmation dialog trigger, confirmed removal, and cancelled removal
Closes #1102
Grabacion.de.pantalla.2026-03-13.a.las.13.30.26.mov