From 159f5332ed82c3163ebd2e6a499968d3a1d6b776 Mon Sep 17 00:00:00 2001 From: Marc Kassubeck Date: Tue, 26 May 2026 18:12:06 +0200 Subject: [PATCH] fix: restore workspace API calls after rebase --- .changeset/fix-workspace-api-reference.md | 5 +++++ src/client/src/controllers/workspaceController.ts | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/fix-workspace-api-reference.md diff --git a/.changeset/fix-workspace-api-reference.md b/.changeset/fix-workspace-api-reference.md new file mode 100644 index 0000000..60272d3 --- /dev/null +++ b/.changeset/fix-workspace-api-reference.md @@ -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`. diff --git a/src/client/src/controllers/workspaceController.ts b/src/client/src/controllers/workspaceController.ts index 79cd41e..bfe9d5a 100644 --- a/src/client/src/controllers/workspaceController.ts +++ b/src/client/src/controllers/workspaceController.ts @@ -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 { 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; }