diff --git a/package-lock.json b/package-lock.json index 2965b7fb..4c2b6a7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "codemux", - "version": "0.7.0", + "version": "0.7.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "codemux", - "version": "0.7.0", + "version": "0.7.1", "license": "Elastic-2.0", "dependencies": { "@codemirror/commands": "^6.10.3", diff --git a/src/components/workspaces-overview/workspaces-overview-section.test.tsx b/src/components/workspaces-overview/workspaces-overview-section.test.tsx index a0dc869f..16755aa8 100644 --- a/src/components/workspaces-overview/workspaces-overview-section.test.tsx +++ b/src/components/workspaces-overview/workspaces-overview-section.test.tsx @@ -281,6 +281,23 @@ describe("WorkspacesOverviewSection", () => { expect(getByText("lost-and-found")).toBeInTheDocument(); }); + it("shows a configured host's bucket even when no workspaces live on it yet", () => { + // Regression for the "I added a device, it doesn't show up in the + // overview until I push a workspace" bug. The host has a server_id + // (i.e. it's synced cross-device), there are no workspaces on it, + // and there's a local workspace so the local bucket is non-empty. + // The configured-host bucket must still render — otherwise the + // user has no way to discover the device from the overview, nor + // any obvious target to push to. + mockHosts = [makeHost(7, "pandora")]; + mockWorkspaces = [ + makeWorkspace({ workspace_id: "local-1", title: "alpha" }), + ]; + const { getByText } = render(); + expect(getByText("This device")).toBeInTheDocument(); + expect(getByText("pandora")).toBeInTheDocument(); + }); + it("renders the bucket-level 'all hidden by filter' message when filters hide every workspace in a known device bucket", () => { // Intentional: when the user has a bucket they recognise but // every row in it is filtered out, the bucket stays visible diff --git a/src/components/workspaces-overview/workspaces-overview-section.tsx b/src/components/workspaces-overview/workspaces-overview-section.tsx index e5f6e150..ef3f0c81 100644 --- a/src/components/workspaces-overview/workspaces-overview-section.tsx +++ b/src/components/workspaces-overview/workspaces-overview-section.tsx @@ -352,9 +352,23 @@ export function WorkspacesOverviewSection() { bucket.items.sort(sorter); } - // Hide buckets that have neither items nor any unfiltered rows. + // Keep configured-host buckets (localHostId != null) even when + // empty — matches the intent stated above at the pre-create step: + // a device the user has set up should be visible in the overview + // the moment it's configured, not only after the first workspace + // lands on it. Without this, an empty pandora bucket gets created + // and then immediately stripped here, which is why the user only + // ever saw "This device" until they pushed a workspace. + // + // Orphan buckets (localHostId == null, hostServerId != null) and + // the special "local" bucket still follow the items/totalCount + // rule so the overview doesn't render a dangling "This device" + // row when the user has zero workspaces and zero remote rows. return Array.from(byKey.values()) - .filter((b) => b.items.length > 0 || b.totalCount > 0) + .filter( + (b) => + b.localHostId !== null || b.items.length > 0 || b.totalCount > 0, + ) .sort((a, b) => a.sortRank - b.sortRank); }, [allItems, filtered, hosts, sortBy, activeWorkspaceId]);