Skip to content

feat(agent-workspaces): add remove button to workspace detail view#1174

Merged
MarsKubeX merged 2 commits intokortex-hub:mainfrom
MarsKubeX:remove-button-workspace-detail
Mar 25, 2026
Merged

feat(agent-workspaces): add remove button to workspace detail view#1174
MarsKubeX merged 2 commits intokortex-hub:mainfrom
MarsKubeX:remove-button-workspace-detail

Conversation

@MarsKubeX
Copy link
Copy Markdown
Contributor

@MarsKubeX MarsKubeX commented Mar 25, 2026

Allow users to remove a workspace directly from the detail page with a confirmation dialog, then navigate back to the workspace list.

Closes #1164

Made-with: Claude-4.6-opus-high

Allow users to remove a workspace directly from the detail page with a
confirmation dialog, then navigate back to the workspace list.

Closes kortex-hub#1164

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Marcel Bertagnini <mbertagn@redhat.com>
Made-with: Cursor
@MarsKubeX MarsKubeX requested a review from a team as a code owner March 25, 2026 10:53
@MarsKubeX MarsKubeX requested review from fbricon and gastoner and removed request for a team March 25, 2026 10:53
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 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: 15aea590-295c-4759-833e-9b6045e77a5e

📥 Commits

Reviewing files that changed from the base of the PR and between eab8461 and 0e00eda.

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

📝 Walkthrough

Walkthrough

Adds a "Remove Workspace" action to the workspace details view that opens a confirmation dialog, calls window.removeAgentWorkspace(workspaceId) when confirmed, and navigates to the workspace list on success. Tests added to cover confirm, cancel, and failure cases.

Changes

Cohort / File(s) Summary
Workspace details UI
packages/renderer/src/lib/agent-workspaces/AgentWorkspaceDetails.svelte
Added trash icon, confirmation helper import, a "Remove Workspace" action button, and handleRemove(name: string) which wraps removal in withConfirmation, calls window.removeAgentWorkspace(...), and navigates on success.
Tests / Mocks
packages/renderer/src/lib/agent-workspaces/AgentWorkspaceDetails.spec.ts
Mocked window.showMessageBox and window.removeAgentWorkspace in setup. Added tests asserting the remove button renders, confirmation dialog invocation, confirmed removal triggers removeAgentWorkspace + navigation, cancelled removal prevents action, and rejection prevents navigation.

Sequence Diagram

sequenceDiagram
    actor User
    participant AgentWorkspaceDetails
    participant withConfirmation
    participant window as WindowAPI
    participant Router

    User->>AgentWorkspaceDetails: Click "Remove Workspace"
    AgentWorkspaceDetails->>withConfirmation: withConfirmation(handleRemove, text)
    withConfirmation->>window: showMessageBox(confirmation)
    window-->>withConfirmation: response (0=confirm, 1=cancel)

    alt response = 0 (confirm)
        withConfirmation->>window: removeAgentWorkspace(workspaceId)
        window-->>withConfirmation: success / error
        alt success
            withConfirmation->>Router: goto('/agent-workspaces')
        else error
            withConfirmation-->>AgentWorkspaceDetails: log error
        end
    else response = 1 (cancel)
        withConfirmation-->>AgentWorkspaceDetails: no-op
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 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 the workspace detail view.
Description check ✅ Passed The description is relevant to the changeset, explaining the removal flow with confirmation dialog and navigation back to the workspace list.
Linked Issues check ✅ Passed The code changes satisfy both requirements from issue #1164: the remove button is added to the workspace detail view and navigation to the workspace list occurs after successful removal.
Out of Scope Changes check ✅ Passed All changes are scoped to the workspace detail view functionality, with modifications limited to adding the remove button, confirmation logic, and navigation as specified in issue #1164.
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.


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.

Copy link
Copy Markdown

@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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/renderer/src/lib/agent-workspaces/AgentWorkspaceDetails.spec.ts (1)

160-193: Add a rejection-path test for removeAgentWorkspace before navigating.

Current coverage checks confirm/cancel, but not deletion failure. Please add a test asserting no navigation when window.removeAgentWorkspace rejects.

🧪 Suggested test case
+test('Expect not navigating when workspace removal fails', async () => {
+  vi.mocked(window.showMessageBox).mockResolvedValue({ response: 0 });
+  vi.mocked(window.removeAgentWorkspace).mockRejectedValue(new Error('remove failed'));
+  const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
+
+  render(AgentWorkspaceDetails, { workspaceId: 'ws-1' });
+
+  await waitFor(() => {
+    expect(screen.getByRole('button', { name: 'Remove Workspace' })).toBeInTheDocument();
+  });
+
+  await fireEvent.click(screen.getByRole('button', { name: 'Remove Workspace' }));
+
+  await waitFor(() => {
+    expect(window.removeAgentWorkspace).toHaveBeenCalledWith('ws-1');
+  });
+  expect(router.goto).not.toHaveBeenCalled();
+  expect(errorSpy).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/AgentWorkspaceDetails.spec.ts`
around lines 160 - 193, Add a test in AgentWorkspaceDetails.spec.ts that
simulates window.showMessageBox resolving with the confirm response and then
mocks window.removeAgentWorkspace to reject; render AgentWorkspaceDetails with
workspaceId 'ws-1', click the "Remove Workspace" button (use fireEvent.click),
await the removeAgentWorkspace rejection (e.g., by awaiting a waitFor that
expects removeAgentWorkspace toHaveBeenCalled), and assert that router.goto was
not called; reference the existing patterns for mocking window.showMessageBox,
window.removeAgentWorkspace, and checking router.goto to place the new test
alongside the confirm/cancel cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/renderer/src/lib/agent-workspaces/AgentWorkspaceDetails.svelte`:
- Around line 38-42: The confirmation callback in handleRemove currently
triggers removal and navigation without awaiting success and also gets invoked
on dialog rejection; change handleRemove to call withConfirmation so the
confirmed branch awaits window.removeAgentWorkspace(workspaceId) and only after
await resolves call router.goto('/agent-workspaces'), and ensure any errors from
removeAgentWorkspace are caught and logged/shown (e.g., catch and
processLogger/console.error) while not performing navigation; update usage or
signature of withConfirmation (or provide explicit onConfirm/onCancel callbacks)
so rejected dialog does not run the removal code.

---

Nitpick comments:
In `@packages/renderer/src/lib/agent-workspaces/AgentWorkspaceDetails.spec.ts`:
- Around line 160-193: Add a test in AgentWorkspaceDetails.spec.ts that
simulates window.showMessageBox resolving with the confirm response and then
mocks window.removeAgentWorkspace to reject; render AgentWorkspaceDetails with
workspaceId 'ws-1', click the "Remove Workspace" button (use fireEvent.click),
await the removeAgentWorkspace rejection (e.g., by awaiting a waitFor that
expects removeAgentWorkspace toHaveBeenCalled), and assert that router.goto was
not called; reference the existing patterns for mocking window.showMessageBox,
window.removeAgentWorkspace, and checking router.goto to place the new test
alongside the confirm/cancel cases.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4d14cbb8-8b48-4d58-a040-4b62209f3252

📥 Commits

Reviewing files that changed from the base of the PR and between 35f551f and eab8461.

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

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…ul removal

Await the removal IPC call before navigating, so the user stays on the
detail page if the removal fails.

Closes kortex-hub#1164

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Marcel Bertagnini <mbertagn@redhat.com>
@MarsKubeX MarsKubeX requested a review from jeffmaury March 25, 2026 15:14
@MarsKubeX MarsKubeX merged commit 3b17557 into kortex-hub:main Mar 25, 2026
15 checks passed
@MarsKubeX MarsKubeX deleted the remove-button-workspace-detail branch March 25, 2026 18:40
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 workspace button in workspace detail view

3 participants