fix: restore workspace API calls after rebase

This commit is contained in:
Marc Kassubeck
2026-05-26 18:12:06 +02:00
parent a142f5ed40
commit 159f5332ed
2 changed files with 8 additions and 3 deletions
@@ -0,0 +1,5 @@
---
"@jmfederico/pi-web": patch
---
Fix workspace selection in the web UI so local machine project and session loading no longer fails with `api is not defined`.
@@ -41,7 +41,7 @@ export class WorkspaceController {
this.setState({ selectedProject: project, selectedWorkspace: undefined, workspaces: [], isLoadingWorkspaces: true, ...resetWorkspaceScopedState() });
try {
const machineId = selectedMachineId(this.getState());
const workspaces = await api.workspaces(project.id, machineId);
const workspaces = await this.api.workspaces(project.id, machineId);
this.setState({ workspaces, workspacesByProjectId: { ...this.getState().workspacesByProjectId, [project.id]: workspaces }, isLoadingWorkspaces: false });
const workspace = selectPreferredWorkspace(workspaces, { targetWorkspaceId: target?.workspaceId, latestWorkspaceId: this.workspaceSelection.latestWorkspaceId(machineProjectKey(machineId, project.id)) });
if (workspace) await this.selectWorkspace(workspace, { sessionId: target?.sessionId, updateUrl: target?.updateUrl });
@@ -57,7 +57,7 @@ export class WorkspaceController {
this.sessions.clearActiveSession();
this.setState({ selectedWorkspace: workspace, isLoadingWorkspaces: false, ...resetWorkspaceScopedState() });
try {
const sessions = mergeCachedNewSessions(workspace.path, await api.sessions(workspace.path, machineId), machineId);
const sessions = mergeCachedNewSessions(workspace.path, await this.api.sessions(workspace.path, machineId), machineId);
this.setState({ sessions });
const session = this.sessions.preferredSession(workspace.path, sessions, target?.sessionId);
if (session) await this.sessions.selectSession(session, { updateUrl: target?.updateUrl });
@@ -70,7 +70,7 @@ export class WorkspaceController {
async refreshProjectWorkspaces(projectId: string): Promise<Workspace[]> {
const project = this.getState().projects.find((candidate) => candidate.id === projectId);
if (project === undefined) throw new Error("Project not found");
const workspaces = await this.api.workspaces(project.id);
const workspaces = await this.api.workspaces(project.id, selectedMachineId(this.getState()));
this.applyProjectWorkspaces(project.id, workspaces);
return workspaces;
}