fix(host-service): do not broadcast "updated" for archived workspaces
What & why
Patching an archived workspace brings it back into the sidebar, and restarting the app does not remove it.
Repro
superset workspaces archive <id> --localsuperset workspaces update <id> --local --clear-tags(or--tag x)- The archived workspace shows up in the sidebar again, although
workspaces listdoes 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 calledemitWorkspaceChanged(ctx, "updated", row).archiveLocalWorkspacebroadcastsdeletedandtouchLocalWorkspaceActivityalready skips archived rows, soupdateLocalWorkspacewas the odd one out.applyWorkspaceChangedEvent(apps/desktop/src/renderer/hooks/host-workspaces/useHostWorkspaces/useHostWorkspaces.utils.ts) upserts anyupdatedsnapshot 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 updateon 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 inapplyWorkspaceChangedEventwould 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/workspacespasses (33 tests). The new test inworkspace-tags.test.tsarchives 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 typecheckinpackages/host-service: clean.bun run lint(root): clean.- Full
packages/host-servicesuite with--parallel: 2955 pass, plus 1 or 2 failures that change between runs and are unrelated to this change (startSandboxKeepaliveactivity ping and the 5 s worker-readiness test). I did not run them onmainto 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 lintandbun run typecheckpass (typecheck run forpackages/host-serviceonly) - "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.