Skip to content

[Bug] SystemSection handleChangeWorkspace button stuck spinning on IPC error #398

@samzong

Description

@samzong

Problem

SystemSection.handleChangeWorkspace calls setChangingWorkspace(true)await window.clawwork.changeWorkspace(selected)setChangingWorkspace(false) without a try/catch. If the IPC throws (workspace migration exception, invalid path, disk error), the final state reset never runs and the "Change Workspace" button is stuck showing a spinner until the user closes Settings.

Location

File: packages/desktop/src/renderer/layouts/Settings/sections/SystemSection.tsx:62-78

const handleChangeWorkspace = useCallback(async () => {
  const selected = await window.clawwork.browseWorkspace();
  if (!selected || selected === workspacePath) return;
  const oldPath = workspacePath;
  setChangingWorkspace(true);
  const result = await window.clawwork.changeWorkspace(selected);  // throw → stuck
  setChangingWorkspace(false);
  if (result.ok) {
    // ...
  } else {
    toast.error(t('settings.workspaceChangeFailed', { error: result.error }));
  }
}, [workspacePath, t]);

Fix Approach

Wrap the body in try/finally:

setChangingWorkspace(true);
try {
  const result = await window.clawwork.changeWorkspace(selected);
  if (result.ok) {
    setWorkspacePath(selected);
    toast.success(...);
  } else {
    toast.error(t('settings.workspaceChangeFailed', { error: result.error }));
  }
} catch (err) {
  console.error('[SystemSection] changeWorkspace failed:', err);
  toast.error(t('settings.workspaceChangeFailed', { error: String(err) }));
} finally {
  setChangingWorkspace(false);
}

Consider also wrapping browseWorkspace for consistency.

Verification

  1. Run pnpm check — must pass.
  2. Manual: simulate IPC failure during workspace change — button must return to idle state.

Context

  • WG: UI & Design System
  • Priority: Low (good first issue)
  • Estimated effort: 10-15 minutes

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/uiUI & Design System WGgood first issueGood for newcomerskind/bugCategorizes issue or PR as related to a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions