feat(sidebar): show host name on every row in multi-host setups (#1775)
The host name previously appeared only in project grouping mode, and only for projects shared across hosts. It now shows on every workspace row in both project and status grouping modes whenever the sidebar spans more than one host, so you can always tell which machine a workspace lives on. Status rows read "Project · Host". Single-host setups are unchanged.
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
buildSidebarProjectsFromStructure,
|
||||
computeSidebarOrderUpdates,
|
||||
deriveSidebarLoadingState,
|
||||
shouldShowSidebarHostLabels,
|
||||
type SidebarProjectEntry,
|
||||
} from "./sidebar-workspaces-view-model";
|
||||
|
||||
@@ -297,6 +298,63 @@ describe("shared sidebar workspace model", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldShowSidebarHostLabels", () => {
|
||||
it("is false with no visible projects", () => {
|
||||
expect(shouldShowSidebarHostLabels([])).toBe(false);
|
||||
});
|
||||
|
||||
it("is false when every project lives on a single host", () => {
|
||||
const projects = buildSidebarProjectsFromStructure({
|
||||
projects: [
|
||||
project({ projectKey: "project-a", workspaceKeys: ["ws-1"] }),
|
||||
project({ projectKey: "project-b", workspaceKeys: ["ws-2"] }),
|
||||
],
|
||||
});
|
||||
|
||||
expect(shouldShowSidebarHostLabels(projects)).toBe(false);
|
||||
});
|
||||
|
||||
it("is true when projects span separate hosts", () => {
|
||||
const projects = buildSidebarProjectsFromStructure({
|
||||
projects: [
|
||||
project({
|
||||
projectKey: "project-a",
|
||||
hosts: [
|
||||
{ serverId: "host-a", iconWorkingDir: "/repo/project-a", canCreateWorktree: true },
|
||||
],
|
||||
workspaceKeys: ["host-a:ws-1"],
|
||||
}),
|
||||
project({
|
||||
projectKey: "project-b",
|
||||
hosts: [
|
||||
{ serverId: "host-b", iconWorkingDir: "/repo/project-b", canCreateWorktree: true },
|
||||
],
|
||||
workspaceKeys: ["host-b:ws-2"],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
expect(shouldShowSidebarHostLabels(projects)).toBe(true);
|
||||
});
|
||||
|
||||
it("is true for a single project shared across hosts", () => {
|
||||
const projects = buildSidebarProjectsFromStructure({
|
||||
projects: [
|
||||
project({
|
||||
projectKey: "getpaseo/paseo",
|
||||
hosts: [
|
||||
{ serverId: "host-a", iconWorkingDir: "/repo/paseo", canCreateWorktree: true },
|
||||
{ serverId: "host-b", iconWorkingDir: "/repo/paseo", canCreateWorktree: true },
|
||||
],
|
||||
workspaceKeys: ["host-a:main", "host-b:feature"],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
expect(shouldShowSidebarHostLabels(projects)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("computeSidebarOrderUpdates", () => {
|
||||
it("returns no updates when there are no visible projects", () => {
|
||||
const updates = computeSidebarOrderUpdates({
|
||||
|
||||
Reference in New Issue
Block a user