Merge sidebar workspaces across all connected hosts (#1538)
* Merge workspaces across all hosts in the sidebar Replace per-host sidebar sections with a single merged project list. Projects that exist on multiple hosts (matched by projectKey) are collapsed into one row. Host identity is surfaced via: - A status-only footer pill showing online/offline host counts - Hover cards with a mandatory host row on every workspace entry - Subtitles showing the host name when a project spans >1 host - A host filter in the grouping dropdown (not a sidebar switcher) Order and group-mode stores migrated from per-server to global keys with zustand persist migrations. New-workspace screen now shows a merged project list with a host selector combobox. Key files: - workspace-structure.ts: merge algorithm by projectKey - sidebar-view-store.ts / sidebar-order-store.ts: global state - sidebar-workspace-list.tsx: context-based subtitle injection - new-workspace-screen.tsx: host selector in footer row * Add host filtering to the merged sidebar The sidebar now merges workspaces from every connected host, so a single global "active host" no longer fits. Host selection becomes explicit per action via a host chooser, and agent history pages across all hosts at once. Removes the active-host / active-server-id model and the all-agents-list hook that fed it. * Fix rebase fallout: translate archive host error, update stale workspace-key test archiveWorkspacesOptimistically used a raw "Host is not connected" string that the i18n completeness test forbids; route it through i18n.t with the existing hostDisconnected key. The selectors memoization test asserted un-prefixed workspace keys, but merged-sidebar keys are serverId-prefixed. * Fix sidebar review fallout * Address sidebar review followups * Fix sidebar workspace identity migration * Address sidebar review followups * Handle partial host history failures * Fix merged sidebar project removal and E2E drift * Restore history routes and project removal shape * Remove sidebar host context plumbing * Tighten sidebar status and host filter state * Keep new workspace project selection host-compatible * Migrate sidebar view storage * Streamline host selection flows * Update all-host history on archive * Fix empty project sidebar action Code regression: the main merge dropped the empty-project New workspace child row while keeping the empty project persistence contract. Restore the row using the project host target so the sidebar stays aligned with the no-host-selection model. * Fix Japanese shortcut translation key Stale-base integration: main added the Japanese locale after this branch added cycleAgentMode to the English shortcut help map. Merging main exposed the missing ja key in CI typecheck and resources.test. * Fix Playwright speech teardown race
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { WorkspaceDescriptor } from "@/stores/session-store";
|
||||
import type { WorkspaceStructureProject } from "@/projects/workspace-structure";
|
||||
import {
|
||||
appendMissingOrderKeys,
|
||||
applyStoredOrdering,
|
||||
buildSidebarStatusWorkspacePlacements,
|
||||
buildSidebarWorkspacePlacementModel,
|
||||
buildSidebarProjectsFromStructure,
|
||||
computeSidebarOrderUpdates,
|
||||
deriveSidebarLoadingState,
|
||||
@@ -23,12 +26,20 @@ function project(input: {
|
||||
projectKind?: WorkspaceStructureProject["projectKind"];
|
||||
iconWorkingDir?: string;
|
||||
workspaceKeys: string[];
|
||||
hosts?: WorkspaceStructureProject["hosts"];
|
||||
}): WorkspaceStructureProject {
|
||||
return {
|
||||
projectKey: input.projectKey,
|
||||
projectName: input.projectName ?? input.projectKey,
|
||||
projectKind: input.projectKind ?? "git",
|
||||
iconWorkingDir: input.iconWorkingDir ?? input.projectKey,
|
||||
hosts: input.hosts ?? [
|
||||
{
|
||||
serverId: "srv",
|
||||
iconWorkingDir: input.iconWorkingDir ?? input.projectKey,
|
||||
canCreateWorktree: true,
|
||||
},
|
||||
],
|
||||
workspaceKeys: input.workspaceKeys,
|
||||
};
|
||||
}
|
||||
@@ -36,10 +47,8 @@ function project(input: {
|
||||
function sidebarProject(input: {
|
||||
projectKey: string;
|
||||
workspaceKeys: string[];
|
||||
serverId?: string;
|
||||
}): SidebarProjectEntry {
|
||||
const projects = buildSidebarProjectsFromStructure({
|
||||
serverId: input.serverId ?? "srv",
|
||||
projects: [project({ projectKey: input.projectKey, workspaceKeys: input.workspaceKeys })],
|
||||
});
|
||||
const result = projects[0];
|
||||
@@ -49,6 +58,31 @@ function sidebarProject(input: {
|
||||
return result;
|
||||
}
|
||||
|
||||
function workspace(input: {
|
||||
id: string;
|
||||
name: string;
|
||||
projectId: string;
|
||||
projectDisplayName: string;
|
||||
status?: WorkspaceDescriptor["status"];
|
||||
statusEnteredAt?: Date | null;
|
||||
}): WorkspaceDescriptor {
|
||||
return {
|
||||
id: input.id,
|
||||
projectId: input.projectId,
|
||||
projectDisplayName: input.projectDisplayName,
|
||||
projectRootPath: `/repo/${input.projectId}`,
|
||||
workspaceDirectory: `/repo/${input.projectId}/${input.id}`,
|
||||
projectKind: "git",
|
||||
workspaceKind: input.name === "main" ? "local_checkout" : "worktree",
|
||||
name: input.name,
|
||||
status: input.status ?? "done",
|
||||
statusEnteredAt: input.statusEnteredAt ?? null,
|
||||
archivingAt: null,
|
||||
diffStat: null,
|
||||
scripts: [],
|
||||
};
|
||||
}
|
||||
|
||||
describe("applyStoredOrdering", () => {
|
||||
it("keeps unknown items on the baseline while applying stored order", () => {
|
||||
const result = applyStoredOrdering({
|
||||
@@ -107,7 +141,6 @@ describe("appendMissingOrderKeys", () => {
|
||||
describe("buildSidebarProjectsFromStructure", () => {
|
||||
it("creates structural workspace rows from ordered workspace keys", () => {
|
||||
const projects = buildSidebarProjectsFromStructure({
|
||||
serverId: "srv",
|
||||
projects: [
|
||||
project({
|
||||
projectKey: "project-1",
|
||||
@@ -131,7 +164,6 @@ describe("buildSidebarProjectsFromStructure", () => {
|
||||
|
||||
it("preserves the structure hook project order", () => {
|
||||
const projects = buildSidebarProjectsFromStructure({
|
||||
serverId: "srv",
|
||||
projects: [
|
||||
project({ projectKey: "project-b", workspaceKeys: ["ws-b"] }),
|
||||
project({ projectKey: "project-a", workspaceKeys: ["ws-a"] }),
|
||||
@@ -143,15 +175,126 @@ describe("buildSidebarProjectsFromStructure", () => {
|
||||
|
||||
it("preserves the structure hook workspace order", () => {
|
||||
const projects = buildSidebarProjectsFromStructure({
|
||||
serverId: "srv",
|
||||
projects: [project({ projectKey: "project-1", workspaceKeys: ["feature", "main"] })],
|
||||
});
|
||||
|
||||
expect(projects[0]?.workspaces.map((workspace) => workspace.workspaceId)).toEqual([
|
||||
expect(projects[0]?.workspaces.map((placement) => placement.workspaceId)).toEqual([
|
||||
"feature",
|
||||
"main",
|
||||
]);
|
||||
});
|
||||
|
||||
it("resolves workspace keys by known host prefix when server ids contain colons", () => {
|
||||
const projects = buildSidebarProjectsFromStructure({
|
||||
projects: [
|
||||
project({
|
||||
projectKey: "project-1",
|
||||
hosts: [
|
||||
{
|
||||
serverId: "relay:paseo-host",
|
||||
iconWorkingDir: "/repo/project-1",
|
||||
canCreateWorktree: true,
|
||||
},
|
||||
],
|
||||
workspaceKeys: ["relay:paseo-host:ws-main"],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
expect(projects[0]?.workspaces[0]).toMatchObject({
|
||||
workspaceKey: "relay:paseo-host:ws-main",
|
||||
serverId: "relay:paseo-host",
|
||||
workspaceId: "ws-main",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("shared sidebar workspace model", () => {
|
||||
it("feeds project placement and status grouping from the same cross-host workspace identities", () => {
|
||||
const model = buildSidebarWorkspacePlacementModel({
|
||||
projects: [
|
||||
project({
|
||||
projectKey: "getpaseo/paseo",
|
||||
projectName: "getpaseo/paseo",
|
||||
iconWorkingDir: "/repo/getpaseo/paseo",
|
||||
hosts: [
|
||||
{ serverId: "host-a", iconWorkingDir: "/repo/getpaseo/paseo", canCreateWorktree: true },
|
||||
{ serverId: "host-b", iconWorkingDir: "/repo/getpaseo/paseo", canCreateWorktree: true },
|
||||
],
|
||||
workspaceKeys: ["host-a:main", "host-b:feature"],
|
||||
}),
|
||||
],
|
||||
});
|
||||
const statusRows = buildSidebarStatusWorkspacePlacements({
|
||||
placements: model.workspaces,
|
||||
sessions: [
|
||||
{
|
||||
serverId: "host-a",
|
||||
workspaces: new Map([
|
||||
[
|
||||
"main",
|
||||
workspace({
|
||||
id: "main",
|
||||
name: "main",
|
||||
projectId: "getpaseo/paseo",
|
||||
projectDisplayName: "getpaseo/paseo",
|
||||
status: "done",
|
||||
}),
|
||||
],
|
||||
]),
|
||||
},
|
||||
{
|
||||
serverId: "host-b",
|
||||
workspaces: new Map([
|
||||
[
|
||||
"feature",
|
||||
workspace({
|
||||
id: "feature",
|
||||
name: "feature/status-flow",
|
||||
projectId: "getpaseo/paseo",
|
||||
projectDisplayName: "getpaseo/paseo",
|
||||
status: "running",
|
||||
statusEnteredAt: new Date("2026-06-10T00:00:00.000Z"),
|
||||
}),
|
||||
],
|
||||
]),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(model.workspaces.map((entry) => entry.workspaceKey)).toEqual([
|
||||
"host-a:main",
|
||||
"host-b:feature",
|
||||
]);
|
||||
expect(model.projects).toEqual([
|
||||
expect.objectContaining({
|
||||
projectKey: "getpaseo/paseo",
|
||||
hosts: [
|
||||
{ serverId: "host-a", iconWorkingDir: "/repo/getpaseo/paseo", canCreateWorktree: true },
|
||||
{ serverId: "host-b", iconWorkingDir: "/repo/getpaseo/paseo", canCreateWorktree: true },
|
||||
],
|
||||
workspaces: [
|
||||
expect.objectContaining({
|
||||
workspaceKey: "host-a:main",
|
||||
serverId: "host-a",
|
||||
name: "main",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
workspaceKey: "host-b:feature",
|
||||
serverId: "host-b",
|
||||
name: "feature",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
]);
|
||||
expect(statusRows.map((entry) => [entry.workspaceKey, entry.statusBucket, entry.name])).toEqual(
|
||||
[
|
||||
["host-a:main", "done", "main"],
|
||||
["host-b:feature", "running", "feature/status-flow"],
|
||||
],
|
||||
);
|
||||
expect(model.projectNamesByKey).toEqual(new Map([["getpaseo/paseo", "getpaseo/paseo"]]));
|
||||
});
|
||||
});
|
||||
|
||||
describe("computeSidebarOrderUpdates", () => {
|
||||
@@ -206,8 +349,8 @@ describe("deriveSidebarLoadingState", () => {
|
||||
expect(
|
||||
deriveSidebarLoadingState({
|
||||
isActive: true,
|
||||
serverId: "srv",
|
||||
hasHydratedWorkspaces: false,
|
||||
serverIds: ["srv"],
|
||||
hydratedServerIds: [],
|
||||
hasProjects: false,
|
||||
}),
|
||||
).toEqual({ isLoading: true, isInitialLoad: true, isRevalidating: false });
|
||||
@@ -217,8 +360,8 @@ describe("deriveSidebarLoadingState", () => {
|
||||
expect(
|
||||
deriveSidebarLoadingState({
|
||||
isActive: true,
|
||||
serverId: "srv",
|
||||
hasHydratedWorkspaces: false,
|
||||
serverIds: ["srv"],
|
||||
hydratedServerIds: [],
|
||||
hasProjects: true,
|
||||
}),
|
||||
).toEqual({ isLoading: true, isInitialLoad: false, isRevalidating: false });
|
||||
@@ -228,8 +371,8 @@ describe("deriveSidebarLoadingState", () => {
|
||||
expect(
|
||||
deriveSidebarLoadingState({
|
||||
isActive: true,
|
||||
serverId: "srv",
|
||||
hasHydratedWorkspaces: true,
|
||||
serverIds: ["srv"],
|
||||
hydratedServerIds: ["srv"],
|
||||
hasProjects: true,
|
||||
}),
|
||||
).toEqual({ isLoading: false, isInitialLoad: false, isRevalidating: false });
|
||||
@@ -239,8 +382,8 @@ describe("deriveSidebarLoadingState", () => {
|
||||
expect(
|
||||
deriveSidebarLoadingState({
|
||||
isActive: false,
|
||||
serverId: "srv",
|
||||
hasHydratedWorkspaces: false,
|
||||
serverIds: ["srv"],
|
||||
hydratedServerIds: [],
|
||||
hasProjects: false,
|
||||
}),
|
||||
).toEqual({ isLoading: false, isInitialLoad: false, isRevalidating: false });
|
||||
|
||||
Reference in New Issue
Block a user