fix: avoid showing local projects for remote machines

This commit is contained in:
Marc Kassubeck
2026-05-26 13:04:00 +02:00
parent 3270619f24
commit 418216b9b7
4 changed files with 24 additions and 5 deletions
+2 -2
View File
@@ -21,12 +21,12 @@ export class MachineList extends LitElement {
<div <div
class=${`action-row ${this.selected?.id === machine.id ? "selected" : ""}`} class=${`action-row ${this.selected?.id === machine.id ? "selected" : ""}`}
tabindex="0" tabindex="0"
title=${machine.baseUrl ?? machine.name} title=${machine.kind === "remote" ? "Remote project browsing is not available yet" : machine.baseUrl ?? machine.name}
@click=${(event: MouseEvent) => { activateSelectableRow(event, () => this.onSelect?.(machine)); }} @click=${(event: MouseEvent) => { activateSelectableRow(event, () => this.onSelect?.(machine)); }}
@keydown=${(event: KeyboardEvent) => { activateSelectableRowFromKeyboard(event, () => this.onSelect?.(machine)); }} @keydown=${(event: KeyboardEvent) => { activateSelectableRowFromKeyboard(event, () => this.onSelect?.(machine)); }}
> >
<div class="action-main"> <div class="action-main">
<span class="action-name">${machine.name}</span><small>${machine.kind === "local" ? "Local Pi Web" : machine.baseUrl}</small> <span class="action-name">${machine.name}</span><small>${machine.kind === "local" ? "Local Pi Web" : `${machine.baseUrl ?? "Remote Pi Web"} · projects coming soon`}</small>
</div> </div>
</div> </div>
`)} `)}
+11 -1
View File
@@ -315,6 +315,7 @@ export class PiWebApp extends LitElement {
private async restoreRoute(updateUrl: boolean) { private async restoreRoute(updateUrl: boolean) {
const route = readRoute(); const route = readRoute();
await this.restoreRouteMachine(route, updateUrl);
const selectedFilePath = readNamespacedString(queryNamespace("core:workspace.files"), "file"); const selectedFilePath = readNamespacedString(queryNamespace("core:workspace.files"), "file");
const selectedDiffPath = readNamespacedString(queryNamespace("core:workspace.git"), "diff"); const selectedDiffPath = readNamespacedString(queryNamespace("core:workspace.git"), "diff");
const selectedTerminalId = readNamespacedString(TERMINAL_ROUTE_NAMESPACE, "terminal"); const selectedTerminalId = readNamespacedString(TERMINAL_ROUTE_NAMESPACE, "terminal");
@@ -342,8 +343,17 @@ export class PiWebApp extends LitElement {
} }
} }
private async restoreRouteMachine(route: AppRoute, updateUrl: boolean): Promise<void> {
const routeMachineId = route.machineId ?? "local";
if (this.state.selectedMachine?.id === routeMachineId) return;
const machine = this.state.machines.find((candidate) => candidate.id === routeMachineId);
if (machine === undefined) return;
await this.machines.selectMachine(machine, { updateUrl });
}
private routeMatchesCurrentSelection(route: AppRoute): boolean { private routeMatchesCurrentSelection(route: AppRoute): boolean {
return route.workspaceId !== undefined return (route.machineId ?? "local") === (this.state.selectedMachine?.id ?? "local")
&& route.workspaceId !== undefined
&& route.workspaceId !== "" && route.workspaceId !== ""
&& this.state.selectedProject?.id === route.projectId && this.state.selectedProject?.id === route.projectId
&& this.state.selectedWorkspace?.id === route.workspaceId && this.state.selectedWorkspace?.id === route.workspaceId
@@ -19,7 +19,7 @@ export class MachineController {
} }
} }
async selectMachine(machine: Machine): Promise<void> { async selectMachine(machine: Machine, options: { updateUrl?: boolean | undefined } = {}): Promise<void> {
if (this.getState().selectedMachine?.id === machine.id) return; if (this.getState().selectedMachine?.id === machine.id) return;
this.setState({ this.setState({
selectedMachine: machine, selectedMachine: machine,
@@ -35,7 +35,7 @@ export class MachineController {
activity: undefined, activity: undefined,
...resetWorkspaceScopedState(), ...resetWorkspaceScopedState(),
}); });
this.updateUrl(); if (options.updateUrl !== false) this.updateUrl();
await this.projects.loadProjects(); await this.projects.loadProjects();
} }
} }
@@ -6,6 +6,11 @@ export class ProjectController {
constructor(private readonly getState: GetState, private readonly setState: SetState, private readonly workspaces: WorkspaceController) {} constructor(private readonly getState: GetState, private readonly setState: SetState, private readonly workspaces: WorkspaceController) {}
async loadProjects() { async loadProjects() {
const machine = this.getState().selectedMachine;
if (machine?.kind === "remote") {
this.setState({ projects: [], workspacesByProjectId: {}, error: "Remote project browsing is not available yet." });
return;
}
this.setState({ error: "", isLoadingProjects: true }); this.setState({ error: "", isLoadingProjects: true });
try { try {
const projects = await api.projects(); const projects = await api.projects();
@@ -20,6 +25,10 @@ export class ProjectController {
} }
async addProject(path: string, create?: boolean) { async addProject(path: string, create?: boolean) {
if (this.getState().selectedMachine?.kind === "remote") {
this.setState({ error: "Adding projects to remote machines is not available yet." });
return;
}
if (path.trim() === "") return; if (path.trim() === "") return;
try { try {
const project = await api.addProject(path.trim(), undefined, create); const project = await api.addProject(path.trim(), undefined, create);