Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(remote): give host project groups their own sidebar section
kyle1abcea09b1b7
diff --git a/apps/desktop/src/components/Sidebar.tsx b/apps/desktop/src/components/Sidebar.tsxindex d0c481a6e..816e4953e 100644--- a/apps/desktop/src/components/Sidebar.tsx+++ b/apps/desktop/src/components/Sidebar.tsx@@ -1,6 +1,7 @@import { IconClock } from "./icons";import { RemoteProjectGroups } from "./remote/RemoteProjectGroups";import { groupRemoteProjectSessions } from "../lib/remote-project-catalog";+import { compareProjectGroups } from "../lib/project-order";import { isRemoteSession, sessionAllows } from "../lib/remote-session-safety";import {useCallback,@@ -181,11 +182,6 @@ function projectName(path: string, fallback?: string) {return parts[parts.length - 1] || path;}-function timestamp(value?: string) {- const parsed = value ? Date.parse(value) : 0;- return Number.isFinite(parsed) ? parsed : 0;-}-function optionalTimestamp(value?: string): number | null {const parsed = value ? Date.parse(value) : NaN;return Number.isFinite(parsed) ? parsed : null;@@ -207,26 +203,6 @@ function projectDomId(path: string): string {return `sidebar-project-${(hash >>> 0).toString(36)}`;}-function firstSessionDate(- sessions: SessionSummary[],- field: "createdAt" | "updatedAt",-): number | null {- const values = sessions- .map((session) => timestamp(session[field]))- .filter((value) => value > 0);- return values.length ? Math.min(...values) : null;-}--function lastSessionDate(- sessions: SessionSummary[],- field: "createdAt" | "updatedAt",-): number | null {- const values = sessions- .map((session) => timestamp(session[field]))- .filter((value) => value > 0);- return values.length ? Math.max(...values) : null;-}-function compareOptionalDate(a: number | null,b: number | null,@@ -793,41 +769,27 @@ export function Sidebar({(entry) => showArchived || !entry.meta.archived,);for (const entry of result) entry.sessions.sort(compareSessions);- result.sort((a, b) => {- const archiveOrder = Number(!!a.meta.archived) - Number(!!b.meta.archived);- if (archiveOrder !== 0) return archiveOrder;- const pinOrder = Number(!!b.meta.pinned) - Number(!!a.meta.pinned);- if (pinOrder !== 0) return pinOrder;- if (displayProjectSort === "manual") {- const byOrder =- (a.meta.order ?? Number.MAX_SAFE_INTEGER) -- (b.meta.order ?? Number.MAX_SAFE_INTEGER);- if (byOrder !== 0) return byOrder;- } else if (displayProjectSort === "name") {- const byName = a.name.localeCompare(b.name, undefined, { sensitivity: "base" });- if (byName !== 0) return byName;- } else if (- displayProjectSort === "oldest" ||- displayProjectSort === "created"- ) {- const dateForProject =- displayProjectSort === "oldest" ? firstSessionDate : lastSessionDate;- const aCreated = dateForProject(a.sessions, "createdAt");- const bCreated = dateForProject(b.sessions, "createdAt");- const byCreated = compareOptionalDate(- aCreated,- bCreated,- displayProjectSort === "created",- );- if (byCreated !== 0) return byCreated;- } else {- const aRecent = lastSessionDate(a.sessions, "updatedAt");- const bRecent = lastSessionDate(b.sessions, "updatedAt");- const byRecent = compareOptionalDate(aRecent, bRecent, true);- if (byRecent !== 0) return byRecent;- }- return a.key.localeCompare(b.key);- });+ result.sort((a, b) =>+ compareProjectGroups(+ {+ key: a.key,+ name: a.name,+ sessions: a.sessions,+ archived: a.meta.archived,+ pinned: a.meta.pinned,+ manualOrder: a.meta.order,+ },+ {+ key: b.key,+ name: b.name,+ sessions: b.sessions,+ archived: b.meta.archived,+ pinned: b.meta.pinned,+ manualOrder: b.meta.order,+ },+ displayProjectSort,+ ),+ );return result;}, [filtered,@@ -1047,7 +1009,8 @@ export function Sidebar({);const remoteProjectGroups = useMemo(() => groupRemoteProjectSessions(filtered.filter((session) => isRemoteSession(session) && !pinnedSessionIds.has(session.id)), compareSessions,- ), [filtered, pinnedSessionIds, compareSessions]);+ displayProjectSort,+ ), [filtered, pinnedSessionIds, compareSessions, displayProjectSort]);// Flat ordered list of every visible session id — used for Shift+click range selection.const flatSessionOrder = useMemo(() => {const ids: string[] = [];@@ -2129,6 +2092,8 @@ export function Sidebar({projectPath?: string;global?: boolean;showLastReplyDate?: boolean;+ /** The `Remote` section heading already says these rows live on a host. */+ insideRemoteSection?: boolean;},) => items.map((session) => {const meta = sessionMeta[session.id] ?? {};@@ -2228,7 +2193,9 @@ export function Sidebar({{session.source === "pi-native" ? (<span className="thread-item-source" title="Native Pi session">Pi</span>) : null}- {isRemoteSession(session) && <span className="thread-item-source" title={session.remoteHostLabel}>{t("remote:remote")}</span>}+ {isRemoteSession(session) && !options?.insideRemoteSection ? (+ <span className="thread-item-source" title={session.remoteHostLabel}>{t("remote:remote")}</span>+ ) : null}<WorktreeBadge worktree={session.worktree} sessionId={session.id} /><span className="thread-item-title">{taskTitle(session.title)}</span>{options?.global ? (@@ -2756,11 +2723,23 @@ export function Sidebar({</div></section>)}- <RemoteProjectGroups groups={remoteProjectGroups}- renderSessions={(sessions) => renderSessionRows(sessions, {- temporary: false,- showLastReplyDate: settings?.sidebarSessionTime === true,- })} />+ {remoteProjectGroups.length > 0 ? (+ <>+ {/* Host-owned groups read as their own section, the same way the+ retained project list does, instead of trailing it unlabelled. */}+ <div className="sidebar-list-subheader" data-sidebar-section="remote">+ <span className="sidebar-list-label">+ {t("nav.remoteProjects", { defaultValue: "Remote" })}+ </span>+ </div>+ <RemoteProjectGroups groups={remoteProjectGroups}+ renderSessions={(sessions) => renderSessionRows(sessions, {+ temporary: false,+ showLastReplyDate: settings?.sidebarSessionTime === true,+ insideRemoteSection: true,+ })} />+ </>+ ) : null}</div><div className="sidebar-footer no-drag">diff --git a/apps/desktop/src/lib/project-order.ts b/apps/desktop/src/lib/project-order.tsnew file mode 100644index 000000000..cf4891903--- /dev/null+++ b/apps/desktop/src/lib/project-order.ts@@ -0,0 +1,103 @@+import type { SessionSummary } from "@pi-desktop/shared";+import type { ProjectSort } from "./sidebar-preferences";++/**+ * One sidebar project group, flattened to the fields that decide its order.+ *+ * Local project groups and host-owned remote groups both sort through this, so+ * a remote group cannot drift up or down the list just because its sessions+ * arrived in a different array order from the host.+ */+export type ProjectOrderInput = {+ /** Stable identity; the last tie-break, so equal groups never swap places. */+ key: string;+ name: string;+ sessions: readonly Pick<SessionSummary, "createdAt" | "updatedAt">[];+ archived?: boolean;+ pinned?: boolean;+ /** Manual position. Only consulted for the `manual` sort. */+ manualOrder?: number | null;+};++function timestamp(value?: string): number {+ const parsed = value ? Date.parse(value) : 0;+ return Number.isFinite(parsed) ? parsed : 0;+}++function firstSessionDate(+ sessions: ProjectOrderInput["sessions"],+ field: "createdAt" | "updatedAt",+): number | null {+ const values = sessions+ .map((session) => timestamp(session[field]))+ .filter((value) => value > 0);+ return values.length ? Math.min(...values) : null;+}++function lastSessionDate(+ sessions: ProjectOrderInput["sessions"],+ field: "createdAt" | "updatedAt",+): number | null {+ const values = sessions+ .map((session) => timestamp(session[field]))+ .filter((value) => value > 0);+ return values.length ? Math.max(...values) : null;+}++function compareOptionalDate(+ a: number | null,+ b: number | null,+ descending: boolean,+): number {+ if (a === null && b === null) return 0;+ if (a === null) return 1;+ if (b === null) return -1;+ return descending ? b - a : a - b;+}++/**+ * Sidebar project order for a given sort mode.+ *+ * Pinned and archived buckets lead regardless of mode, `manual` reads the+ * stored position, `name` compares labels, `created` / `oldest` read the+ * project's own session dates, and `recent` keeps the most recently active+ * project on top.+ */+export function compareProjectGroups(+ a: ProjectOrderInput,+ b: ProjectOrderInput,+ sort: ProjectSort,+): number {+ const archiveOrder = Number(!!a.archived) - Number(!!b.archived);+ if (archiveOrder !== 0) return archiveOrder;+ const pinOrder = Number(!!b.pinned) - Number(!!a.pinned);+ if (pinOrder !== 0) return pinOrder;+ if (sort === "manual") {+ const byOrder =+ (a.manualOrder ?? Number.MAX_SAFE_INTEGER) -+ (b.manualOrder ?? Number.MAX_SAFE_INTEGER);+ if (byOrder !== 0) return byOrder;+ } else if (sort === "name") {+ const byName = a.name.localeCompare(b.name, undefined, {+ sensitivity: "base",+ });+ if (byName !== 0) return byName;+ } else if (sort === "oldest" || sort === "created") {+ const dateForProject =+ sort === "oldest" ? firstSessionDate : lastSessionDate;+ const byCreated = compareOptionalDate(+ dateForProject(a.sessions, "createdAt"),+ dateForProject(b.sessions, "createdAt"),+ sort === "created",+ );+ if (byCreated !== 0) return byCreated;+ } else {+ const byRecent = compareOptionalDate(+ lastSessionDate(a.sessions, "updatedAt"),+ lastSessionDate(b.sessions, "updatedAt"),+ true,+ );+ if (byRecent !== 0) return byRecent;+ }+ return a.key.localeCompare(b.key);+}diff --git a/apps/desktop/src/lib/remote-project-catalog.ts b/apps/desktop/src/lib/remote-project-catalog.tsindex 6016394ff..92c7524be 100644--- a/apps/desktop/src/lib/remote-project-catalog.ts+++ b/apps/desktop/src/lib/remote-project-catalog.ts@@ -4,7 +4,9 @@ import type {SessionSummary,} from "@pi-desktop/shared";import type { RemoteProjectTarget } from "./remote-project-session";+import { compareProjectGroups } from "./project-order";import { isRemoteSession } from "./remote-session-safety";+import type { ProjectSort } from "./sidebar-preferences";export type RemoteProjectEntry = RemoteProjectTarget & {key: string;@@ -21,21 +23,45 @@ export type RemoteProjectGroup = {sessions: SessionSummary[];};-/** Rendering and range selection consume one grouped order. */+/**+ * Rendering and range selection consume one grouped order.+ *+ * Groups sort through the same project order the local list uses. Without it a+ * host group's position would follow whichever of its sessions happened to+ * arrive first, so opening a conversation in one host project could move that+ * group above another while the local list stayed put.+ */export function groupRemoteProjectSessions(sessions: SessionSummary[],compare: (left: SessionSummary, right: SessionSummary) => number,+ sort: ProjectSort,): RemoteProjectGroup[] {- return listRemoteProjects([], [], sessions).map((project) => ({- project,- sessions: sessions- .filter(- (session) =>- session.remoteHostKey === project.hostKey &&- session.remoteProjectId === project.projectId,- )- .sort(compare),- }));+ return listRemoteProjects([], [], sessions)+ .map((project) => ({+ project,+ sessions: sessions+ .filter(+ (session) =>+ session.remoteHostKey === project.hostKey &&+ session.remoteProjectId === project.projectId,+ )+ .sort(compare),+ }))+ .sort((left, right) =>+ compareProjectGroups(+ {+ key: left.project.key,+ name: left.project.label,+ sessions: left.sessions,+ },+ {+ key: right.project.key,+ name: right.project.label,+ sessions: right.sessions,+ },+ sort,+ ),+ );}export function listRemoteProjects(diff --git a/apps/desktop/src/styles/sessions.css b/apps/desktop/src/styles/sessions.cssindex 0d8bd1708..8ea31adf8 100644--- a/apps/desktop/src/styles/sessions.css+++ b/apps/desktop/src/styles/sessions.css@@ -725,6 +725,20 @@border-radius: var(--radius-sm);}+/* A section heading that lives inside the scrolling group list, used when a+ second group set follows the first (host project groups). It carries the same+ label styling and the same 8px section gap as `.sidebar-list-toolbar`, and+ its 2px side padding lands on the toolbar's 4px label inset once the list's+ own `px-0.5` is added. */+.sidebar-list-subheader {+ display: flex;+ flex: 0 0 auto;+ align-items: center;+ min-height: 24px;+ padding: 8px 2px 0;+ border-radius: var(--radius-sm);+}+.sidebar-list-label {color: var(--ds-text-muted);font-size: var(--text-sm); /* section labels less micro */diff --git a/apps/desktop/test/remote-project-groups.test.mjs b/apps/desktop/test/remote-project-groups.test.mjsnew file mode 100644index 000000000..03e157022--- /dev/null+++ b/apps/desktop/test/remote-project-groups.test.mjs@@ -0,0 +1,229 @@+import assert from "node:assert/strict";+import test from "node:test";+import { createElement } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { createInstance } from "i18next";+import { I18nextProvider } from "react-i18next";+import { catalogs } from "@pi-desktop/i18n";+import { createServer } from "vite";+import { readFile } from "node:fs/promises";+import { fileURLToPath } from "node:url";++/*+ * A host project group must sit in the sidebar like a local one, and the+ * sidebar must label the set it belongs to.+ *+ * The group is keyed by `[hostKey, projectId]` rather than a filesystem path,+ * so the section heading, the shared project sort, and the per-row source chip+ * are all reached through a different code path here than for a local project.+ * Without the heading a host group reads as a retained local one, and without+ * the shared sort its position follows whichever host session arrived first.+ *+ * The group body is rendered through the real component, store, and locale, so+ * the assertions are the markup the sidebar actually produces.+ */++const ROOT = fileURLToPath(new URL("..", import.meta.url));++// The section heading, its styling, and the row-level chip live outside the+// component, so they are checked against the sidebar source itself.+const sidebarSource = await readFile(+ new URL("../src/components/Sidebar.tsx", import.meta.url),+ "utf8",+);+const sidebarStyles = await readFile(+ new URL("../src/styles/sessions.css", import.meta.url),+ "utf8",+);++const project = {+ key: JSON.stringify(["ssh-fixture", "p7"]),+ hostKey: "ssh-fixture",+ projectId: "p7",+ label: "713Air",+ hostLabel: "mac-mini",+ connected: true,+};++const session = (id, title) => ({+ id: `remote:ssh-fixture:${id}`,+ source: "remote",+ remoteHostKey: project.hostKey,+ remoteHostLabel: project.hostLabel,+ remoteProjectId: project.projectId,+ remoteWorkspaceLabel: project.label,+ title,+ messageCount: 0,+ mode: "agent",+ permissionMode: "ask",+ thinkingLevel: "inherit",+ capabilities: {+ canPrompt: true,+ canStop: true,+ canRefresh: true,+ canReadWorkspace: true,+ canConfigureModel: false,+ canAttach: false,+ canSteer: false,+ canEditMessages: false,+ canUseLocalTools: false,+ canUseTerminal: false,+ },+ createdAt: "2026-01-01T00:00:00Z",+ updatedAt: "2026-01-01T00:00:00Z",+});++async function withGroups(run) {+ const server = await createServer({+ root: ROOT,+ configFile: false,+ server: { middlewareMode: true, hmr: false, ws: false },+ esbuild: { jsx: "automatic" },+ appType: "custom",+ optimizeDeps: { noDiscovery: true, include: [] },+ });+ try {+ const { RemoteProjectGroups } = await server.ssrLoadModule(+ "/src/components/remote/RemoteProjectGroups.tsx",+ );+ const { remoteProjectCollapseKey } = await server.ssrLoadModule(+ "/src/lib/remote-project-catalog.ts",+ );+ const { useAppStore } = await server.ssrLoadModule("/src/stores/app-store.ts");+ const i18n = createInstance();+ await i18n.init({+ lng: "en",+ resources: { en: { translation: catalogs.en } },+ });+ const render = (sessions, collapsed) => {+ const collapseKey = remoteProjectCollapseKey(project.key);+ Object.assign(useAppStore.getInitialState(), {+ projectCollapsed: collapsed ? { [collapseKey]: true } : {},+ });+ return renderToStaticMarkup(+ createElement(+ I18nextProvider,+ { i18n },+ createElement(RemoteProjectGroups, {+ groups: [{ project, sessions }],+ renderSessions: (rows) =>+ rows.map((row) =>+ createElement(+ "div",+ { className: "thread-item", key: row.id },+ row.title,+ ),+ ),+ }),+ ),+ );+ };+ await run({ render, useAppStore, remoteProjectCollapseKey });+ } finally {+ await server.close();+ }+}++test("a host project group folds through the same disclosure a local group uses", async () => {+ await withGroups(({ render }) => {+ const html = render([session("s1", "Remote work")], false);+ assert.match(html, /data-action="toggle-project-collapse"/);+ assert.match(html, /aria-expanded="true"/);+ assert.match(html, /aria-controls="[^"]*p7[^"]*-sessions"/);+ // Rows live in the animatable body, not as loose siblings of the header.+ assert.match(html, /class="sidebar-session-group-body project\s*"/);+ assert.match(html, /class="sidebar-session-group-clip"/);+ assert.match(html, /class="sidebar-session-group-list"/);+ assert.match(html, /Remote work/);+ assert.doesNotMatch(html, /is-collapsed/);+ });+});++test("collapsing a host project group folds its rows without dropping them", async () => {+ await withGroups(({ render }) => {+ const html = render([session("s1", "Remote work")], true);+ assert.match(html, /aria-expanded="false"/);+ assert.match(html, /is-collapsed/);+ assert.match(html, /sidebar-session-group-body project collapsed/);+ // Hidden from assistive tech and from pointer/keyboard while folded, so the+ // closed group is not a focus trap.+ assert.match(html, /aria-hidden="true"/);+ assert.match(html, /inert=""/);+ // The row is still in the DOM; only the collapsed row hides it, so+ // expanding restores the list without a refetch.+ assert.match(html, /Remote work/);+ });+});++test("the new-task action stays on the header and never becomes the fold toggle", async () => {+ await withGroups(({ render }) => {+ const collapsed = render([session("s1", "Remote work")], true);+ // The `+` action must survive a folded group: it is how a user creates the+ // first conversation in a project they just closed.+ assert.match(collapsed, /aria-label="New task: 713Air · mac-mini"/);+ });+});++test("the fold uses shared project state under a host-namespaced key", async () => {+ await withGroups(({ render, useAppStore, remoteProjectCollapseKey }) => {+ render([session("s1", "Remote work")], false);+ const collapseKey = remoteProjectCollapseKey(project.key);+ useAppStore.getState().setProjectCollapsed(collapseKey, true);+ const state = useAppStore.getState();+ assert.equal(+ state.projectCollapsed[collapseKey],+ true,+ "the fold is remembered per group",+ );+ assert.ok(collapseKey.startsWith("remote::"));+ // `openProjectPaths` is the retained local project list; a host catalog key+ // landing there would resurrect a group after the project is gone.+ assert.deepEqual(state.openProjectPaths, []);+ });+});++test("host groups sit under their own section heading beside Projects", () => {+ const heading = sidebarSource.match(+ /<div className="sidebar-list-subheader" data-sidebar-section="remote">[\s\S]*?<\/div>/,+ )?.[0];+ assert.ok(heading, "the sidebar emits a remote section heading");+ assert.match(heading, /t\("nav\.remoteProjects"/);+ // The heading owns the groups: it is emitted before them inside the same+ // list, so host groups read as a sibling section instead of trailing the+ // local project groups unlabelled.+ const headingAt = sidebarSource.indexOf('data-sidebar-section="remote"');+ const groupsAt = sidebarSource.indexOf("<RemoteProjectGroups");+ assert.ok(groupsAt > headingAt, "the heading precedes the host groups");+ // The heading is only emitted when a host actually has groups.+ assert.match(+ sidebarSource,+ /\{remoteProjectGroups\.length > 0 \? \([\s\S]*?data-sidebar-section="remote"[\s\S]*?<RemoteProjectGroups/,+ );++ const rule = sidebarStyles.match(/\.sidebar-list-subheader \{[\s\S]*?\n\}/)?.[0] ?? "";+ assert.ok(rule, "the heading has its own box, not the toolbar's");+ assert.match(rule, /display: flex;/);+ // Matches the Projects toolbar's side inset once the list's own padding is+ // added, so the two headings share one left rail.+ assert.match(rule, /padding: 8px 2px 0;/);++ // The heading already names the host class, so rows under it do not repeat a+ // "Remote" chip on every conversation.+ assert.match(sidebarSource, /insideRemoteSection: true/);+ assert.match(+ sidebarSource,+ /isRemoteSession\(session\) && !options\?\.insideRemoteSection/,+ );+});++test("every locale names the remote section", () => {+ for (const [locale, catalog] of Object.entries(catalogs)) {+ const label = catalog.nav?.remoteProjects;+ assert.equal(+ typeof label,+ "string",+ `${locale} is missing nav.remoteProjects`,+ );+ assert.ok(label.trim().length > 0, `${locale} has an empty nav.remoteProjects`);+ }+});\ No newline at end of filediff --git a/apps/desktop/test/remote-project-session.test.mjs b/apps/desktop/test/remote-project-session.test.mjsindex f1f009dba..6991a1464 100644--- a/apps/desktop/test/remote-project-session.test.mjs+++ b/apps/desktop/test/remote-project-session.test.mjs@@ -82,6 +82,7 @@ test("host project groups keep their rows keyed by the remote project id", () =>const groups = groupRemoteProjectSessions([remote("ssh-two"), remote()],(a, b) => 0,+ "recent",);const group = groups.find((entry) => entry.project.key === remoteProjectKey("ssh-one", "project"),@@ -217,8 +218,10 @@ test("remote project groups share sorted visible order with range selection", ()const a1 = { ...remote(), id: "a1", title: "Zulu" };const b1 = { ...remote("ssh-two"), id: "b1", title: "Other host" };const a2 = { ...remote(), id: "a2", title: "Alpha" };- const groups = groupRemoteProjectSessions([a1, b1, a2], (left, right) =>- left.title.localeCompare(right.title),+ const groups = groupRemoteProjectSessions(+ [a1, b1, a2],+ (left, right) => left.title.localeCompare(right.title),+ "recent",);assert.deepEqual(groups.map((group) => group.sessions.map((session) => session.id)),@@ -230,6 +233,41 @@ test("remote project groups share sorted visible order with range selection", ());});+test("remote group order follows the project sort, not the session array order", () => {+ const older = {+ ...remote(),+ id: "old",+ remoteProjectId: "p-old",+ updatedAt: "2026-11-14T15:00:00Z",+ };+ const newer = {+ ...remote(),+ id: "new",+ remoteProjectId: "p-new",+ updatedAt: "2026-11-16T05:00:00Z",+ };+ const byTitle = (left, right) => left.id.localeCompare(right.id);+ // The host may list the sessions of the project that was just opened first.+ // Group order comes from the sort mode, so selecting a conversation cannot+ // move its project above another one.+ const openedFirst = groupRemoteProjectSessions([newer, older], byTitle, "recent");+ const openedLast = groupRemoteProjectSessions([older, newer], byTitle, "recent");+ assert.deepEqual(+ openedFirst.map((group) => group.project.projectId),+ ["p-new", "p-old"],+ );+ assert.deepEqual(+ openedLast.map((group) => group.project.projectId),+ ["p-new", "p-old"],+ );+ assert.deepEqual(+ groupRemoteProjectSessions([newer, older], byTitle, "name").map(+ (group) => group.project.projectId,+ ),+ ["p-new", "p-old"],+ );+});+test("a cold RACP catalog count of zero never reuses a chat with actual history", async () => {const { createRemoteSessionCatalog } =await import("../electron/main/remote/remote-session-catalog.ts");diff --git a/docs/spec/04-ux/01-ui-ia.md b/docs/spec/04-ux/01-ui-ia.mdindex e075a9356..c4a66b58c 100644--- a/docs/spec/04-ux/01-ui-ia.md+++ b/docs/spec/04-ux/01-ui-ia.md@@ -211,10 +211,19 @@ destination, chat as the home surface, tools and permissions inline.scrolling internally, so standalone work stays visible without displacingproject navigation. The following `Projects` heading exposes thefolder-picker action; retained project groups use the remaining height and- scroll independently.+ scroll independently. Connected-host groups follow the local ones under their+ own `Remote` heading, emitted only while at least one host group is visible,+ so a host project never reads as a retained local one.- **Identity**: each project group is keyed by a host-owned logical group id;each root path remains canonical and is never inferred from an ambiguousfolder basename. Legacy single-folder projects are compatibility groups.+ Host-owned remote project groups use the same header and disclosure as local+ groups, and their catalog key is presentation state only: it never becomes a+ retained local project path. Their order follows the sidebar project sort+ (`recent`, `created`, `oldest`, `name`) instead of the arrival order of host+ session rows, so opening a conversation in one host project never moves that+ group above another. Because the section heading already names the host+ class, a row inside it does not repeat a per-row `Remote` chip.- **Header**: project name, current-workspace dot, disclosure, new-task action,and an overflow menu. Workspace context is not navigation selection: projectheaders have no persistent selected background, including when no conversationdiff --git a/docs/spec/06-delivery/e2e/live-and-remote.md b/docs/spec/06-delivery/e2e/live-and-remote.mdindex fc1fb47df..3a6b1a911 100644--- a/docs/spec/06-delivery/e2e/live-and-remote.md+++ b/docs/spec/06-delivery/e2e/live-and-remote.md@@ -544,6 +544,12 @@ browser milestones are scheduled.workspace-requiring plugin tool. Non-loopback peers and reused pairing tokensare rejected. Tampered bundles are refused before start; SSH login failuresare surfaced safely; version mismatch offers a matching-release recovery.+ Opening a listed remote session keeps it inside its host project group,+ because the attach snapshot reports the same `projectId` as the session list;+ that group's disclosure collapses and restores its rows exactly like a local+ project group. Host groups appear below the local ones under their own+ `Remote` heading, hide it when the host has no group left, and keep their+ order when a conversation in another host project is opened.The local session is untouched throughout.- **Specs linked**: `02-architecture/05-remote-agent-control.md` §§5.2 and6.3, `03-runtime/19-remote-agent-control-protocol.md` §§6.2, 9.4, anddiff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.tsindex 3594bd590..d86f2c8d1 100644--- a/packages/i18n/src/locales/de/index.ts+++ b/packages/i18n/src/locales/de/index.ts@@ -232,6 +232,7 @@ export const de = {"newTask": "Neue Aufgabe","newProject": "Neues Projekt","projects": "Projekte",+ "remoteProjects": "Remote","plugins": "Erweiterungen","settings": "Einstellungen","checkForUpdates": "Auf Updates prüfen",diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.tsindex 927337fdf..6590a7dea 100644--- a/packages/i18n/src/locales/en/index.ts+++ b/packages/i18n/src/locales/en/index.ts@@ -239,6 +239,7 @@ export const en = {newTask: "New task",newProject: "New project",projects: "Projects",+ remoteProjects: "Remote",plugins: "Extensions",settings: "Settings",checkForUpdates: "Check for updates",diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.tsindex d81f94b25..e3aba4a21 100644--- a/packages/i18n/src/locales/es/index.ts+++ b/packages/i18n/src/locales/es/index.ts@@ -232,6 +232,7 @@ export const es = {"newTask": "Nueva tarea","newProject": "Nuevo proyecto","projects": "Proyectos",+ "remoteProjects": "Remoto","plugins": "Extensiones","settings": "Configuración","checkForUpdates": "Buscar actualizaciones",diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.tsindex 90745ae56..87384bf03 100644--- a/packages/i18n/src/locales/fr/index.ts+++ b/packages/i18n/src/locales/fr/index.ts@@ -232,6 +232,7 @@ export const fr = {"newTask": "Nouvelle tâche","newProject": "Nouveau projet","projects": "Projets",+ "remoteProjects": "Distant","plugins": "Extensions","settings": "Paramètres","checkForUpdates": "Vérifier les mises à jour",diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.tsindex 8a8de219d..1925e4d7d 100644--- a/packages/i18n/src/locales/ko/index.ts+++ b/packages/i18n/src/locales/ko/index.ts@@ -241,6 +241,7 @@ export const ko = {newTask: "새 작업",newProject: "새 프로젝트",projects: "프로젝트",+ remoteProjects: "원격",plugins: "확장 기능",settings: "설정",checkForUpdates: "업데이트 확인",diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.tsindex 9277bd7e5..f60642d11 100644--- a/packages/i18n/src/locales/pt-BR/index.ts+++ b/packages/i18n/src/locales/pt-BR/index.ts@@ -231,6 +231,7 @@ export const ptBR = {newTask: "Nova tarefa",newProject: "Novo projeto",projects: "Projetos",+ remoteProjects: "Remoto",plugins: "Extensões",settings: "Configurações",checkForUpdates: "Verificar atualizações",diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.tsindex 493143bbc..a17c08de8 100644--- a/packages/i18n/src/locales/tr/index.ts+++ b/packages/i18n/src/locales/tr/index.ts@@ -241,6 +241,7 @@ export const tr = {newTask: "Yeni görev",newProject: "Yeni proje",projects: "Projeler",+ remoteProjects: "Uzak",plugins: "Uzantılar",settings: "Ayarlar",checkForUpdates: "Güncellemeleri denetle",diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.tsindex 3a79a2c2d..8c4e13634 100644--- a/packages/i18n/src/locales/zh-CN/index.ts+++ b/packages/i18n/src/locales/zh-CN/index.ts@@ -234,6 +234,7 @@ export const zhCN = {newTask: "新建任务",newProject: "新建项目",projects: "项目",+ remoteProjects: "远程",plugins: "扩展",settings: "设置",checkForUpdates: "检查更新",diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.tsindex a9cf965ce..f93fedb9e 100644--- a/packages/i18n/src/locales/zh-TW/index.ts+++ b/packages/i18n/src/locales/zh-TW/index.ts@@ -234,6 +234,7 @@ export const zhTW = {newTask: "新建任務",newProject: "新建專案",projects: "專案",+ remoteProjects: "遠端",plugins: "擴充套件",settings: "設定",checkForUpdates: "檢查更新",diff --git a/scripts/e2e-remote-project-groups-journey.mjs b/scripts/e2e-remote-project-groups-journey.mjsindex 29e4091c1..3286d1e6a 100644--- a/scripts/e2e-remote-project-groups-journey.mjs+++ b/scripts/e2e-remote-project-groups-journey.mjs@@ -58,6 +58,7 @@ const { createBackendRouter } =await import("../apps/desktop/electron/main/remote/backend-router.ts");const {groupRemoteProjectSessions,+ listRemoteProjects,remoteProjectKey,remoteProjectCollapseKey,} = await import("../apps/desktop/src/lib/remote-project-catalog.ts");@@ -524,7 +525,7 @@ try {// which group the session lands in.const compare = (left, right) =>(left.title ?? "").localeCompare(right.title ?? "");- const groups = groupRemoteProjectSessions(storeAfterAttach, compare);+ const groups = groupRemoteProjectSessions(storeAfterAttach, compare, "recent");record("groups-one-per-project",groups.length === 2,@@ -562,6 +563,45 @@ try {JSON.stringify(groupKeys),);+ // Stable project ordering: both arrays below describe the same two host+ // projects, and a host may list the project that was just opened first. Group+ // order must come from the sidebar project sort, so the rendered order is the+ // same for both. The unsorted project list is the negative control: it still+ // follows insertion order, which is what the sort has to override.+ const pickForProject = (projectId) => {+ const row = storeAfterAttach.find(+ (entry) => entry.remoteProjectId === projectId,+ );+ assert.ok(row, `a stored session under project ${projectId}`);+ return row;+ };+ const orderingProbe = {+ older: { ...pickForProject(registered1.id), updatedAt: "2026-01-01T00:00:00.000Z" },+ newer: { ...pickForProject(registered2.id), updatedAt: "2026-01-02T00:00:00.000Z" },+ };+ const orderFor = (rows) =>+ groupRemoteProjectSessions(rows, compare, "recent").map(+ (group) => group.project.projectId,+ );+ const openedFirst = orderFor([orderingProbe.older, orderingProbe.newer]);+ const openedLast = orderFor([orderingProbe.newer, orderingProbe.older]);+ record(+ "group-order-follows-project-sort-not-session-arrival",+ JSON.stringify(openedFirst) === JSON.stringify(openedLast) &&+ openedFirst[0] === registered2.id,+ `first=${JSON.stringify(openedFirst)} last=${JSON.stringify(openedLast)}`,+ );+ const arrivalOrder = listRemoteProjects(+ [],+ [],+ [orderingProbe.older, orderingProbe.newer],+ ).map((entry) => entry.projectId);+ record(+ "negative-unsorted-arrival-order-would-differ",+ JSON.stringify(arrivalOrder) !== JSON.stringify(openedFirst),+ JSON.stringify(arrivalOrder),+ );+const collapseKeys = groupKeys.map((key) => remoteProjectCollapseKey(key));record("collapse-keys-remote-namespaced-and-unique",@@ -581,6 +621,7 @@ try {const brokenGroups = groupRemoteProjectSessions(storeWithoutDecoration,compare,+ "recent",);const brokenExclusive =brokenGroups.length === 2 &&