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:
@@ -0,0 +1,28 @@
|
||||
import type { DaemonServerInfo } from "@/stores/session-store";
|
||||
|
||||
export type HostFeatureName = keyof NonNullable<DaemonServerInfo["features"]>;
|
||||
|
||||
export interface HostFeatureSessionState {
|
||||
sessions: Record<
|
||||
string,
|
||||
| {
|
||||
serverInfo: DaemonServerInfo | null;
|
||||
}
|
||||
| undefined
|
||||
>;
|
||||
}
|
||||
|
||||
export function hostSupportsFeature(
|
||||
serverInfo: DaemonServerInfo | null | undefined,
|
||||
feature: HostFeatureName,
|
||||
): boolean {
|
||||
return serverInfo?.features?.[feature] === true;
|
||||
}
|
||||
|
||||
export function selectHostFeature(
|
||||
state: HostFeatureSessionState,
|
||||
serverId: string,
|
||||
feature: HostFeatureName,
|
||||
): boolean {
|
||||
return hostSupportsFeature(state.sessions[serverId]?.serverInfo, feature);
|
||||
}
|
||||
@@ -1201,6 +1201,48 @@ describe("HostRuntimeController", () => {
|
||||
});
|
||||
|
||||
describe("HostRuntimeStore", () => {
|
||||
it("marks the host registry loaded after boot reads storage", async () => {
|
||||
const previousOverride = process.env.EXPO_PUBLIC_LOCAL_DAEMON;
|
||||
process.env.EXPO_PUBLIC_LOCAL_DAEMON = "not-an-endpoint";
|
||||
const store = new HostRuntimeStore({
|
||||
deps: {
|
||||
createClient: () => {
|
||||
throw new Error("createClient should not be called");
|
||||
},
|
||||
connectToDaemon: async () => {
|
||||
throw new Error("connectToDaemon should not be called");
|
||||
},
|
||||
getClientId: async () => "cid_test_runtime",
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
let hostListNotifications = 0;
|
||||
let unsubscribeHostList = () => {};
|
||||
const registryLoaded = new Promise<void>((resolve) => {
|
||||
unsubscribeHostList = store.subscribeHostList(() => {
|
||||
hostListNotifications += 1;
|
||||
if (store.isHostRegistryLoaded()) {
|
||||
unsubscribeHostList();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
store.boot();
|
||||
await registryLoaded;
|
||||
|
||||
expect(store.isHostRegistryLoaded()).toBe(true);
|
||||
expect(hostListNotifications).toBe(2);
|
||||
} finally {
|
||||
if (previousOverride === undefined) {
|
||||
delete process.env.EXPO_PUBLIC_LOCAL_DAEMON;
|
||||
} else {
|
||||
process.env.EXPO_PUBLIC_LOCAL_DAEMON = previousOverride;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("bootstraps agent directory subscription when host transitions online", async () => {
|
||||
const host = makeHost({
|
||||
connections: [
|
||||
|
||||
@@ -1345,6 +1345,7 @@ export class HostRuntimeStore {
|
||||
private hostListListeners = new Set<() => void>();
|
||||
private version = 0;
|
||||
private hostListVersion = 0;
|
||||
private hostRegistryLoaded = false;
|
||||
private hosts: HostProfile[] = [];
|
||||
private hostRegistryStatus: HostRegistryStatus = "loading";
|
||||
private deps: HostRuntimeControllerDeps;
|
||||
@@ -1380,6 +1381,10 @@ export class HostRuntimeStore {
|
||||
return this.hostListVersion;
|
||||
}
|
||||
|
||||
isHostRegistryLoaded(): boolean {
|
||||
return this.hostRegistryLoaded;
|
||||
}
|
||||
|
||||
boot(): void {
|
||||
if (this.bootStarted) {
|
||||
return;
|
||||
@@ -1391,6 +1396,7 @@ export class HostRuntimeStore {
|
||||
private async runBoot(): Promise<void> {
|
||||
const override = readConfiguredLocalDaemonOverride();
|
||||
await this.loadFromStorage();
|
||||
this.markHostRegistryLoaded();
|
||||
|
||||
let isE2E: string | null = null;
|
||||
try {
|
||||
@@ -1454,6 +1460,14 @@ export class HostRuntimeStore {
|
||||
}
|
||||
}
|
||||
|
||||
private markHostRegistryLoaded(): void {
|
||||
if (this.hostRegistryLoaded) {
|
||||
return;
|
||||
}
|
||||
this.hostRegistryLoaded = true;
|
||||
this.emitHostList();
|
||||
}
|
||||
|
||||
private async bootstrapDefaultLocalhost(): Promise<void> {
|
||||
const connection = connectionFromListen(LOCALHOST_FALLBACK_ENDPOINT);
|
||||
if (!connection || registryHasConnection(this.hosts, connection)) {
|
||||
@@ -2235,6 +2249,15 @@ export function useHostRegistryStatus(): HostRegistryStatus {
|
||||
);
|
||||
}
|
||||
|
||||
export function useHostRegistryLoaded(): boolean {
|
||||
const store = getHostRuntimeStore();
|
||||
return useSyncExternalStore(
|
||||
(onStoreChange) => store.subscribeHostList(onStoreChange),
|
||||
() => store.isHostRegistryLoaded(),
|
||||
() => store.isHostRegistryLoaded(),
|
||||
);
|
||||
}
|
||||
|
||||
export interface HostMutations {
|
||||
upsertDirectConnection: (input: {
|
||||
serverId: string;
|
||||
|
||||
Reference in New Issue
Block a user