Skip to content

feat(workspace-manager): added remove button to workspace card in wokspace list view#1103

Merged
benoitf merged 2 commits intokortex-hub:mainfrom
MarsKubeX:feat/remove-button-workspace
Mar 13, 2026
Merged

feat(workspace-manager): added remove button to workspace card in wokspace list view#1103
benoitf merged 2 commits intokortex-hub:mainfrom
MarsKubeX:feat/remove-button-workspace

Conversation

@MarsKubeX
Copy link
Contributor

  • Add a remove button (trash icon) to each workspace card in the Agent Workspaces list view
  • Clicking the button shows a confirmation dialog; on confirm, the workspace is removed via window.removeAgentWorkspace and the list refreshes

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

…kspace list view

Signed-off-by: Marcel Bertagnini <mbertagn@redhat.com>
@MarsKubeX MarsKubeX requested a review from a team as a code owner March 13, 2026 12:43
@MarsKubeX MarsKubeX requested review from benoitf, gastoner and jeffmaury and removed request for a team March 13, 2026 12:43
@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4b270740-3887-4428-b7b1-06cef9ca0a4f

📥 Commits

Reviewing files that changed from the base of the PR and between c13032e and b4cade4.

📒 Files selected for processing (1)
  • packages/renderer/src/lib/agent-workspaces/AgentWorkspaceCard.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/renderer/src/lib/agent-workspaces/AgentWorkspaceCard.spec.ts

📝 Walkthrough

Walkthrough

Adds a trash (remove) button to AgentWorkspaceCard that shows a confirmation dialog and, on confirmation, calls window.removeAgentWorkspace(workspace.id) then refreshes the workspace list via window.listAgentWorkspaces(). Tests added to cover rendering, confirmation, and conditional removal behavior.

Changes

Cohort / File(s) Summary
Test Coverage for Workspace Removal
packages/renderer/src/lib/agent-workspaces/AgentWorkspaceCard.spec.ts
Added Vitest setup/mocks and tests: render verification, remove button presence, confirmation dialog display, and conditional removal behavior for confirm/cancel flows.
Workspace Removal Feature
packages/renderer/src/lib/agent-workspaces/AgentWorkspaceCard.svelte
Added trash icon button and handleRemove flow: show confirmation, call window.removeAgentWorkspace(workspace.id) on confirm, then refresh list via fetchAgentWorkspaces() / window.listAgentWorkspaces().

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a remove button to workspace cards, though it contains a minor typo ('wokspace' instead of 'workspace').
Description check ✅ Passed The description is directly related to the changeset, detailing the remove button feature, confirmation dialog, workspace removal behavior, and unit tests.
Linked Issues check ✅ Passed The pull request successfully implements all requirements from issue #1102: adds a remove button to workspace cards and enables workspace removal with confirmation.
Out of Scope Changes check ✅ Passed All changes are within scope, focusing exclusively on the removal functionality feature as specified in issue #1102.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes.

Add @coderabbitai placeholder anywhere in the title of your PR and CodeRabbit will replace it with a title based on the changes in the PR. You can change the placeholder by changing the reviews.auto_title_placeholder setting.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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, but showMessageBox is 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 removeAgentWorkspace is called, but doesn't verify that listAgentWorkspaces is 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

📥 Commits

Reviewing files that changed from the base of the PR and between b6077ea and c13032e.

📒 Files selected for processing (2)
  • packages/renderer/src/lib/agent-workspaces/AgentWorkspaceCard.spec.ts
  • packages/renderer/src/lib/agent-workspaces/AgentWorkspaceCard.svelte

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...src/lib/agent-workspaces/AgentWorkspaceCard.svelte 85.71% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Signed-off-by: Marcel Bertagnini <mbertagn@redhat.com>
@benoitf benoitf enabled auto-merge (rebase) March 13, 2026 13:04
@benoitf benoitf merged commit 544691d into kortex-hub:main Mar 13, 2026
15 checks passed
@MarsKubeX MarsKubeX deleted the feat/remove-button-workspace branch March 13, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add remove button in workspace cards in workspace list view.

2 participants