fix(host-service): do not broadcast "updated" for archived workspaces

Merged
ES
7h ago
+18-2

What & why

Patching an archived workspace brings it back into the sidebar, and restarting the app does not remove it.

Repro

  1. superset workspaces archive <id> --local
  2. superset workspaces update <id> --local --clear-tags (or --tag x)
  3. The archived workspace shows up in the sidebar again, although workspaces list does not list it. The renderer saves its list to IndexedDB (saveHostWorkspacesSnapshot), so a restart keeps it. Archived rows keep their tags, so the resurrected rows also recreated phantom tag folders. On one machine this resurrected about 2,900 archived workspaces.

Cause

  • updateLocalWorkspace (packages/host-service/src/workspaces/local-workspace-store.ts) patched an archived row and then always called emitWorkspaceChanged(ctx, "updated", row).
  • archiveLocalWorkspace broadcasts deleted and touchLocalWorkspaceActivity already skips archived rows, so updateLocalWorkspace was the odd one out.
  • applyWorkspaceChangedEvent (apps/desktop/src/renderer/hooks/host-workspaces/useHostWorkspaces/useHostWorkspaces.utils.ts) upserts any updated snapshot into the cached list.

Fix
updateLocalWorkspace still writes the patch to an archived row but no longer broadcasts updated for it.

  • I kept the write because the board's Merged/Deleted history reads archived rows, and a restore should come back with the user's latest tags and name. Rejecting the write would turn workspaces update on an archived row into a new error for CLI scripts.
  • I chose no event over deleted: clients already dropped the row on the archive event, so there is nothing to tell them.
  • Known limit: a client that already resurrected a row keeps it until the next list refetch. Closing that gap would need a renderer-side change, which I left out.
  • I did not touch the renderer. The snapshot payload carries no archivedAt, so a defense in applyWorkspaceChangedEvent would first need a protocol change.

Related, not duplicates: #8835 (empty sidebar folders), #8106 (local state kept for archived workspaces).

How I tested it

  • packages/host-service: bun test src/workspaces passes (33 tests). The new test in workspace-tags.test.ts archives a workspace, updates its tags, and checks that the tags are stored and no message is broadcast. It fails without the fix and passes with it.
  • bun run typecheck in packages/host-service: clean.
  • bun run lint (root): clean.
  • Full packages/host-service suite with --parallel: 2955 pass, plus 1 or 2 failures that change between runs and are unrelated to this change (startSandboxKeepalive activity ping and the 5 s worker-readiness test). I did not run them on main to confirm they also fail there.
  • Not run: the other workspaces' typecheck, and the desktop app. This is a host-side change with no UI change, so there are no screenshots.

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint and bun run typecheck pass (typecheck run for packages/host-service only)
  • "Allow edits from maintainers" is checked on fork PRs
  • I have signed the CLA (the bot asks on your first PR)

🤖 Generated with Claude Code


Summary by cubic

Stops updateLocalWorkspace from broadcasting updated for archived workspaces. Patching an archived workspace (for example, clearing its tags) previously emitted updated, which made the renderer upsert the row into its cached list and IndexedDB snapshot, resurrecting it in the sidebar—on one machine, about 2,900 archived workspaces came back. The patch is still written to the archived row so the board's history and a future restore keep the latest tags and name; only the broadcast is skipped, matching touchLocalWorkspaceActivity's existing behavior.

Added a test that archives a workspace, updates its tags, and asserts the tags are stored with no event broadcast.

Summary by CodeRabbit

  • Bug Fixes
    • Archived workspaces can still have their tags updated without sending a workspace-change notification. Archived workspaces are also no longer broadcast as updated, preventing them from reappearing for clients that removed them after archiving.