diff --git a/.changeset/mobile-workspace-selection-stays-navigation.md b/.changeset/mobile-workspace-selection-stays-navigation.md
new file mode 100644
index 0000000..ba4dc1e
--- /dev/null
+++ b/.changeset/mobile-workspace-selection-stays-navigation.md
@@ -0,0 +1,5 @@
+---
+"@jmfederico/pi-web": patch
+---
+
+Keep mobile workspace selection in the Sessions view so users can confirm the remembered session before opening chat, and restore mobile URLs without an explicit view back to Sessions.
diff --git a/src/client/src/components/PiWebApp.ts b/src/client/src/components/PiWebApp.ts
index 8c622c2..2bd09b1 100644
--- a/src/client/src/components/PiWebApp.ts
+++ b/src/client/src/components/PiWebApp.ts
@@ -126,7 +126,7 @@ export class PiWebApp extends LitElement {
const route = readRoute();
const selectedFilePath = readNamespacedString(queryNamespace("core:workspace.files"), "file");
const selectedDiffPath = readNamespacedString(queryNamespace("core:workspace.git"), "diff");
- this.setState({ workspaceTool: route.tool ?? this.state.workspaceTool, mainView: route.view ?? this.state.mainView, selectedFilePath, selectedDiffPath });
+ this.setState({ workspaceTool: route.tool ?? this.state.workspaceTool, mainView: route.view ?? this.defaultRouteView(), selectedFilePath, selectedDiffPath });
if (route.projectId === undefined || route.projectId === "") return;
const project = this.state.projects.find((p) => p.id === route.projectId);
if (!project) return;
@@ -154,6 +154,10 @@ export class PiWebApp extends LitElement {
await this.chatView?.updateComplete;
}
+ private defaultRouteView(): AppState["mainView"] {
+ return this.isMobileNavigationLayout ? "navigation" : "chat";
+ }
+
private updateUrl(options?: { replace?: boolean | undefined }) {
writeRoute({
projectId: this.state.selectedProject?.id,
@@ -263,7 +267,7 @@ export class PiWebApp extends LitElement {
this.withChatScrollTransition(() => this.workspaces.selectProject(project))} .onClose=${(project: Project) => this.projects.closeProject(project.id)}>
- this.plugins.getWorkspaceLabelItems(this.state, workspace)} .onSelect=${(workspace: Workspace) => openChatAfter(() => this.workspaces.selectWorkspace(workspace))}>
+ this.plugins.getWorkspaceLabelItems(this.state, workspace)} .onSelect=${(workspace: Workspace) => this.withChatScrollTransition(() => this.workspaces.selectWorkspace(workspace))}>
openChatAfter(() => this.sessions.startSession())} .onSelect=${(session: SessionInfo) => openChatAfter(() => this.sessions.selectSession(session))} .onArchive=${(session: SessionInfo) => this.sessions.archiveSession(session)} .onRestore=${(session: SessionInfo) => openChatAfter(() => this.sessions.restoreSession(session))} .onDetachParent=${(session: SessionInfo) => this.sessions.detachParent(session)}>
`;
}