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:
@@ -23,6 +23,11 @@ function extractSearch(pathname: string): string {
|
||||
: pathname.slice(queryIndex + 1);
|
||||
}
|
||||
|
||||
function extractHash(pathname: string): string {
|
||||
const hashIndex = pathname.indexOf("#");
|
||||
return hashIndex >= 0 ? pathname.slice(hashIndex) : "";
|
||||
}
|
||||
|
||||
function trimNonEmpty(value: NullableString): string | null {
|
||||
if (typeof value !== "string") {
|
||||
return null;
|
||||
@@ -298,6 +303,38 @@ export function parseHostWorkspaceRouteFromPathname(
|
||||
return { serverId, workspaceId };
|
||||
}
|
||||
|
||||
export function stripHostWorkspaceRouteEchoSearch(route: string): string {
|
||||
const pathname = stripSearchAndHash(route);
|
||||
const selection = parseHostWorkspaceRouteFromPathname(pathname);
|
||||
const search = extractSearch(route);
|
||||
if (!selection || !search) {
|
||||
return route;
|
||||
}
|
||||
|
||||
const params = new URLSearchParams(search);
|
||||
let didStrip = false;
|
||||
|
||||
const serverId = params.get("serverId");
|
||||
if (serverId && trimNonEmpty(decodeSegment(serverId)) === selection.serverId) {
|
||||
params.delete("serverId");
|
||||
didStrip = true;
|
||||
}
|
||||
|
||||
const workspaceId = params.get("workspaceId");
|
||||
if (workspaceId && decodeWorkspaceIdFromPathSegment(workspaceId) === selection.workspaceId) {
|
||||
params.delete("workspaceId");
|
||||
didStrip = true;
|
||||
}
|
||||
|
||||
if (!didStrip) {
|
||||
return route;
|
||||
}
|
||||
|
||||
const nextSearch = params.toString();
|
||||
const nextQuery = nextSearch ? `?${nextSearch}` : "";
|
||||
return `${pathname}${nextQuery}${extractHash(route)}`;
|
||||
}
|
||||
|
||||
export function buildHostWorkspaceRoute(serverId: string, workspaceId: string) {
|
||||
const normalizedServerId = trimNonEmpty(serverId);
|
||||
const normalizedWorkspaceId = trimNonEmpty(workspaceId);
|
||||
@@ -353,6 +390,14 @@ export function buildHostRootRoute(serverId: string) {
|
||||
return `/h/${encodeSegment(normalized)}` as const;
|
||||
}
|
||||
|
||||
export function buildHostOpenProjectRoute(serverId: string) {
|
||||
const base = buildHostRootRoute(serverId);
|
||||
if (base === "/") {
|
||||
return "/" as const;
|
||||
}
|
||||
return `${base}/open-project` as const;
|
||||
}
|
||||
|
||||
export function buildHostSessionsRoute(serverId: string) {
|
||||
const base = buildHostRootRoute(serverId);
|
||||
if (base === "/") {
|
||||
@@ -361,12 +406,32 @@ export function buildHostSessionsRoute(serverId: string) {
|
||||
return `${base}/sessions` as const;
|
||||
}
|
||||
|
||||
export function buildHostOpenProjectRoute(serverId: string) {
|
||||
const base = buildHostRootRoute(serverId);
|
||||
if (base === "/") {
|
||||
return "/" as const;
|
||||
export function buildSessionsRoute() {
|
||||
return "/sessions" as const;
|
||||
}
|
||||
|
||||
export function buildOpenProjectRoute() {
|
||||
return "/open-project" as const;
|
||||
}
|
||||
|
||||
export type KnownHostRouteResolution =
|
||||
| { kind: "render" }
|
||||
| { kind: "redirect"; href: ReturnType<typeof buildOpenProjectRoute> | "/welcome" };
|
||||
|
||||
export function resolveKnownHostRoute(input: {
|
||||
routeServerId: string | null | undefined;
|
||||
hosts: readonly { serverId: string }[];
|
||||
}): KnownHostRouteResolution {
|
||||
const routeServerId = trimNonEmpty(input.routeServerId);
|
||||
if (routeServerId && input.hosts.some((host) => host.serverId === routeServerId)) {
|
||||
return { kind: "render" };
|
||||
}
|
||||
return `${base}/open-project` as const;
|
||||
|
||||
if (input.hosts.length > 0) {
|
||||
return { kind: "redirect", href: buildOpenProjectRoute() };
|
||||
}
|
||||
|
||||
return { kind: "redirect", href: "/welcome" };
|
||||
}
|
||||
|
||||
export function buildHostNewWorkspaceRoute(
|
||||
@@ -448,6 +513,10 @@ export function buildSettingsSectionRoute(section: SettingsSectionSlug) {
|
||||
return `/settings/${section}` as const;
|
||||
}
|
||||
|
||||
export function buildSettingsAddHostRoute(intentId: string | number = "1") {
|
||||
return `/settings/general?addHost=${encodeURIComponent(String(intentId))}` as const;
|
||||
}
|
||||
|
||||
export function buildSettingsHostRoute(serverId: string) {
|
||||
const normalized = trimNonEmpty(serverId);
|
||||
if (!normalized) {
|
||||
@@ -475,30 +544,3 @@ export function buildProjectSettingsRoute(projectKey: string) {
|
||||
}
|
||||
return `/settings/projects/${encodeSegment(normalized)}` as const;
|
||||
}
|
||||
|
||||
export function mapPathnameToServer(pathname: string, nextServerId: string) {
|
||||
const normalized = trimNonEmpty(nextServerId);
|
||||
if (!normalized) {
|
||||
return "/" as const;
|
||||
}
|
||||
|
||||
const suffix = pathname.replace(/^\/h\/[^/]+\/?/, "");
|
||||
const base = buildHostRootRoute(normalized);
|
||||
if (suffix.startsWith("settings")) {
|
||||
return buildSettingsHostRoute(normalized);
|
||||
}
|
||||
if (suffix.startsWith("sessions")) {
|
||||
return `${base}/sessions` as const;
|
||||
}
|
||||
if (suffix.startsWith("open-project")) {
|
||||
return `${base}/open-project` as const;
|
||||
}
|
||||
const workspaceRoute = parseHostWorkspaceRouteFromPathname(pathname);
|
||||
if (workspaceRoute) {
|
||||
return buildHostWorkspaceRoute(normalized, workspaceRoute.workspaceId);
|
||||
}
|
||||
if (suffix.startsWith("agent/")) {
|
||||
return `${base}/${suffix}` as const;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user