Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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(<WorkspacesOverviewSection />);
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
Expand Down
18 changes: 16 additions & 2 deletions src/components/workspaces-overview/workspaces-overview-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
Loading