Keep selected projects when switching hosts (#2700)
* fix(app): preserve project selection across hosts Rendered project identity and persisted equivalence were conflated after duplicate-project handling. Keep them separate so host changes resolve selectable equivalents deterministically without resetting legacy sidebar identity. * fix(app): restore selected clone after host round trip Keep manual origin and current destination placements separately so switching back restores the chosen checkout while archive gaps preserve the active host selection. * fix(app): key status icons by project view * fix(app): preserve origin during archive gaps
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import {
|
||||
canCreateWorkspaceForHostProject,
|
||||
filterWorkspaceProjectsForHost,
|
||||
resolveHostProjectCandidate,
|
||||
type HostProjectListItem,
|
||||
} from "@/projects/host-projects";
|
||||
import type { HostRuntimeConnectionStatus } from "@/runtime/host-runtime";
|
||||
@@ -25,35 +27,31 @@ function supportsAllProjects(
|
||||
return workspaceMultiplicityByServerId.get(serverId) === true;
|
||||
}
|
||||
|
||||
function getProjectForServer(input: {
|
||||
candidate: HostProjectListItem;
|
||||
projects: readonly HostProjectListItem[];
|
||||
serverId: string;
|
||||
}) {
|
||||
return (
|
||||
input.projects.find(
|
||||
(project) =>
|
||||
project.projectKey === input.candidate.projectKey &&
|
||||
project.hosts.some((host) => host.serverId === input.serverId),
|
||||
) ?? input.candidate
|
||||
);
|
||||
}
|
||||
|
||||
function canUseProjectForServer(input: {
|
||||
project: HostProjectListItem;
|
||||
projects: readonly HostProjectListItem[];
|
||||
serverId: string;
|
||||
workspaceMultiplicityByServerId: ReadonlyMap<string, boolean>;
|
||||
}) {
|
||||
const project = getProjectForServer({
|
||||
candidate: input.project,
|
||||
const allowAllProjects = supportsAllProjects(
|
||||
input.workspaceMultiplicityByServerId,
|
||||
input.serverId,
|
||||
);
|
||||
const selectableProjects = filterWorkspaceProjectsForHost({
|
||||
projects: input.projects,
|
||||
serverId: input.serverId,
|
||||
allowAllProjects,
|
||||
});
|
||||
const project =
|
||||
resolveHostProjectCandidate({
|
||||
candidate: input.project,
|
||||
projects: selectableProjects,
|
||||
serverId: input.serverId,
|
||||
}) ?? input.project;
|
||||
return canCreateWorkspaceForHostProject({
|
||||
project,
|
||||
serverId: input.serverId,
|
||||
allowAllProjects: supportsAllProjects(input.workspaceMultiplicityByServerId, input.serverId),
|
||||
allowAllProjects,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user