Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(desktop): share all local projects with approved LAN devices
vastsa1ba70fdb41d9
diff --git a/apps/desktop/electron/main/lan-webui/server.ts b/apps/desktop/electron/main/lan-webui/server.tsindex f685b479f..41b6e657e 100644--- a/apps/desktop/electron/main/lan-webui/server.ts+++ b/apps/desktop/electron/main/lan-webui/server.ts@@ -32,12 +32,14 @@ const secret = () => randomBytes(32).toString("base64url");function cleanGrants(value: unknown): LanGrants {const input = (value && typeof value === "object" ? value : {}) as Partial<Record<keyof LanGrants, unknown>>;- const projectIds = Array.isArray(input.projectIds)- ? [...new Set(input.projectIds.filter((id): id is string => typeof id === "string" && id.length > 0 && id.length < 200))]- : [];- const temporary = input.temporary === true;- if (!projectIds.length && !temporary) throw new LanError(400, "INVALID_SCOPE");- return { projectIds, temporary, chat: input.chat === true, organize: input.organize === true };+ // Never reinterpret an older project-id selection as consent to all local projects.+ if (input.projectScope !== "all-local") throw new LanError(400, "INVALID_SCOPE");+ return {+ projectScope: input.projectScope,+ temporary: input.temporary === true,+ chat: input.chat === true,+ organize: input.organize === true,+ };}const sameSecret = (a: string, b: string) => {@@ -408,8 +410,7 @@ export function createLanServer(options: {if (!device) throw new LanError(404, "NOT_FOUND");const next = cleanGrants(grants);const current = device.grants;- if (next.temporary === current.temporary && next.chat === current.chat && next.organize === current.organize- && next.projectIds.length === current.projectIds.length && next.projectIds.every((id) => current.projectIds.includes(id))) return;+ if (next.temporary === current.temporary && next.chat === current.chat && next.organize === current.organize) return;device.grants = next;closeStreams(device);changed();diff --git a/apps/desktop/electron/main/lan-webui/service.ts b/apps/desktop/electron/main/lan-webui/service.tsindex 370c0f8b7..4c0ff83e7 100644--- a/apps/desktop/electron/main/lan-webui/service.ts+++ b/apps/desktop/electron/main/lan-webui/service.ts@@ -55,8 +55,7 @@ export function createLanWebUiService(deps: {return server;};- async function view(error: string | null = null): Promise<LanAdminView> {- const projects = await workspace.operatorProjects().catch(() => []);+ function view(error: string | null = null): LanAdminView {const current = server;const running = current?.running() === true;return {@@ -68,7 +67,6 @@ export function createLanWebUiService(deps: {pending: running ? current!.pending() : [],devices: running ? current!.devices() : [],interfaces: listLanInterfaces(),- projects,error,};}diff --git a/apps/desktop/electron/main/lan-webui/workspace.ts b/apps/desktop/electron/main/lan-webui/workspace.tsindex 4f83b809a..e4ec0a3f9 100644--- a/apps/desktop/electron/main/lan-webui/workspace.ts+++ b/apps/desktop/electron/main/lan-webui/workspace.ts@@ -159,9 +159,6 @@ export function createLanWorkspace(deps: LanWorkspaceDeps) {return index.get(normalizeProjectKey(path))?.id;}- const allowed = (access: LanAccess, projectId: string | null | undefined) =>- projectId === null ? access.temporary : projectId !== undefined && access.projectIds.includes(projectId);-function sessionView(session: HostSession, projectId: string | null, meta: LanMeta): LanSession {const own = meta.sessionMeta[session.id] ?? {};const title = session.title?.trim() || "";@@ -198,13 +195,12 @@ export function createLanWorkspace(deps: LanWorkspaceDeps) {const session = sessions.find((candidate) => candidate.id === sessionId);if (!session) throw new LanError(404, "NOT_FOUND");const projectId = projectOf(session, rootIndex(list));- if (projectId === undefined || !allowed(access, projectId)) throw new LanError(404, "NOT_FOUND");+ if (projectId === undefined || (projectId === null && !access.temporary)) throw new LanError(404, "NOT_FOUND");const meta = deps.organization.read();return { session, projectId, meta, view: sessionView(session, projectId, meta) };}- async function authorizedProject(access: LanAccess, projectId: string) {- if (!access.projectIds.includes(projectId)) throw new LanError(404, "NOT_FOUND");+ async function requireLocalProject(projectId: string) {const group = (await groups()).find((candidate) => candidate.id === projectId);if (!group) throw new LanError(404, "NOT_FOUND");const meta = deps.organization.read();@@ -219,12 +215,11 @@ export function createLanWorkspace(deps: LanWorkspaceDeps) {const matches = (text: string, query: string) => !query || text.toLowerCase().includes(query.toLowerCase());- async function listProjects(access: LanAccess, query: URLSearchParams): Promise<LanPage<LanProject>> {+ async function listProjects(query: URLSearchParams): Promise<LanPage<LanProject>> {const meta = deps.organization.read();const archivedOnly = query.get("archived") === "1";const q = (query.get("q") ?? "").trim();const list = distinctViews(await groups(), meta)- .filter(({ group }) => access.projectIds.includes(group.id)).filter(({ view }) => view.archived === archivedOnly && matches(view.label, q)).sort((a, b) => Number(b.view.pinned) - Number(a.view.pinned) || b.group.lastOpenedAt - a.group.lastOpenedAt).map(({ view }) => view);@@ -234,9 +229,7 @@ export function createLanWorkspace(deps: LanWorkspaceDeps) {async function listSessions(access: LanAccess, query: URLSearchParams): Promise<LanPage<LanSession>> {const requested = query.get("projectId") ?? "";const wantTemporary = requested === LAN_TEMPORARY_PROJECT;- if (wantTemporary ? !access.temporary : !access.projectIds.includes(requested)) {- throw new LanError(404, "NOT_FOUND");- }+ if (wantTemporary && !access.temporary) throw new LanError(404, "NOT_FOUND");const [list, sessions] = await Promise.all([groups(), hostSessions()]);if (!wantTemporary && !list.some((group) => group.id === requested)) throw new LanError(404, "NOT_FOUND");const index = rootIndex(list);@@ -318,7 +311,7 @@ export function createLanWorkspace(deps: LanWorkspaceDeps) {if (projectId === null) {if (!access.temporary) throw new LanError(404, "NOT_FOUND");} else {- const { group, view } = await authorizedProject(access, projectId);+ const { group, view } = await requireLocalProject(projectId);if (view.archived) throw new LanError(409, "ARCHIVED");projectPath = group.primaryPath;}@@ -335,7 +328,7 @@ export function createLanWorkspace(deps: LanWorkspaceDeps) {async function organizeProject(access: LanAccess, projectId: string, body: Record<string, unknown>) {requireOrganize(access);const [field, value] = oneOrganizeField(body);- const { group, view } = await authorizedProject(access, projectId);+ const { group, view } = await requireLocalProject(projectId);if (body.revision !== view.revision) throw new LanError(409, "CONFLICT");if (field === "archived" && value === true) {const index = rootIndex([group]);@@ -424,18 +417,12 @@ export function createLanWorkspace(deps: LanWorkspaceDeps) {}return {- /** Operator-only list for the Desktop pairing dialog. */- async operatorProjects(): Promise<Array<{ id: string; label: string }>> {- const meta = deps.organization.read();- return distinctViews(await groups(), meta).map(({ view }) => ({ id: view.id, label: view.label }));- },-async handle(request: LanRequest, key: string | null): Promise<unknown> {const { method, path, access, query, body } = request;const parts = path.split("/").filter(Boolean).map(decodeURIComponent); // ["v1", ...]const [, resource, id, sub] = parts;if (method === "GET") {- if (resource === "projects" && !id) return listProjects(access, query);+ if (resource === "projects" && !id) return listProjects(query);if (resource === "sessions" && !id) return listSessions(access, query);if (resource === "sessions" && id && !sub) return conversation(access, id);if (resource === "sessions" && id && sub === "history") {diff --git a/apps/desktop/resources/lan-webui/locale.js b/apps/desktop/resources/lan-webui/locale.jsindex 0e245f611..6dc3aa80c 100644--- a/apps/desktop/resources/lan-webui/locale.js+++ b/apps/desktop/resources/lan-webui/locale.js@@ -14,7 +14,7 @@ window.LAN_LOCALES = {temporary: "Temporary conversations",search: "Search",showArchived: "Archived",- noProjects: "No shared projects.",+ noProjects: "No local projects.",noMatches: "Nothing matches.",noSessions: "No conversations yet.",newSession: "New conversation",@@ -77,7 +77,7 @@ window.LAN_LOCALES = {temporary: "临时会话",search: "搜索",showArchived: "已归档",- noProjects: "没有共享的项目。",+ noProjects: "没有本机项目。",noMatches: "没有匹配项。",noSessions: "还没有会话。",newSession: "新建会话",diff --git a/apps/desktop/src/features/lan-webui/LanGrantsEditor.tsx b/apps/desktop/src/features/lan-webui/LanGrantsEditor.tsxindex 40b2fc684..30f72aa48 100644--- a/apps/desktop/src/features/lan-webui/LanGrantsEditor.tsx+++ b/apps/desktop/src/features/lan-webui/LanGrantsEditor.tsx@@ -1,118 +1,54 @@-import { useId } from "react";import { useTranslation } from "react-i18next";import type { LanGrants } from "@pi-desktop/shared";-import { Button, Checkbox } from "../../components/ui";+import { Checkbox } from "../../components/ui";import { IconCheck, IconShield } from "../../components/icons";-export const NEW_DEVICE_GRANTS: LanGrants = { projectIds: [], temporary: false, chat: true, organize: true };+export const NEW_DEVICE_GRANTS: LanGrants = {+ projectScope: "all-local",+ temporary: false,+ chat: true,+ organize: true,+};-/**- * What one paired device may see (projects, temporary conversations) and do- * (chat, organize). Viewing is always allowed and shown as such.- */export function LanGrantsEditor({- projects,value,onChange,- disabled = false,+ disabled,}: {- projects: Array<{ id: string; label: string }>;value: LanGrants;onChange: (next: LanGrants) => void;- disabled?: boolean;+ disabled: boolean;}) {const { t } = useTranslation("lan");- const listId = useId();- const allSelected = projects.length > 0 && value.projectIds.length === projects.length;-- const toggleProject = (id: string, on: boolean) =>- onChange({- ...value,- projectIds: on ? [...new Set([...value.projectIds, id])] : value.projectIds.filter((candidate) => candidate !== id),- });+ const options = [+ { key: "temporary", label: t("scopeTemporary"), hint: t("temporaryHint") },+ { key: "chat", label: t("chat"), hint: t("chatHint") },+ { key: "organize", label: t("organize"), hint: t("organizeHint") },+ ] as const;return (<div className="lan-grants">- <section className="lan-grants-section" aria-labelledby={`${listId}-projects`}>- <div className="lan-grants-section-head">- <h3 id={`${listId}-projects`} className="lan-grants-section-title">{t("projects")}</h3>- {projects.length ? (- <span className="lan-grants-section-meta">- {t("selectedCount", { selected: value.projectIds.length, total: projects.length })}- <Button- type="button"- size="sm"- variant="ghost"- disabled={disabled}- onClick={() => onChange({ ...value, projectIds: allSelected ? [] : projects.map((project) => project.id) })}- >- {allSelected ? t("selectNone") : t("selectAll")}- </Button>- </span>- ) : null}- </div>- <div className="lan-grants-list" role="group" aria-labelledby={`${listId}-projects`}>- {projects.length ? projects.map((project) => (- <Checkbox- key={project.id}- className="lan-grants-option"- label={<span className="lan-grants-option-label">{project.label}</span>}- checked={value.projectIds.includes(project.id)}- disabled={disabled}- onChange={(event) => toggleProject(project.id, event.target.checked)}- />- )) : <p className="lan-grants-empty">{t("noProjects")}</p>}- <Checkbox- className="lan-grants-option lan-grants-option-separate"- label={- <span className="lan-grants-option-copy">- <span className="lan-grants-option-label">{t("scopeTemporary")}</span>- <span className="lan-grants-option-hint">{t("temporaryHint")}</span>- </span>- }- checked={value.temporary}- disabled={disabled}- onChange={(event) => onChange({ ...value, temporary: event.target.checked })}- />- </div>- </section>-- <section className="lan-grants-section" aria-labelledby={`${listId}-abilities`}>- <div className="lan-grants-section-head">- <h3 id={`${listId}-abilities`} className="lan-grants-section-title">{t("abilities")}</h3>+ <div className="lan-grants-list" role="group" aria-label={t("permissions")}>+ <div className="lan-grants-fixed">+ <IconCheck size={14} aria-hidden="true" />+ <span className="lan-grants-option-label">{t("scopeAll")}</span></div>- <div className="lan-grants-list" role="group" aria-labelledby={`${listId}-abilities`}>- <div className="lan-grants-fixed">- <IconCheck size={14} aria-hidden="true" />- <span className="lan-grants-option-label">{t("alwaysView")}</span>- </div>+ {options.map(({ key, label, hint }) => (<Checkbox+ key={key}className="lan-grants-option"label={<span className="lan-grants-option-copy">- <span className="lan-grants-option-label">{t("chat")}</span>- <span className="lan-grants-option-hint">{t("chatHint")}</span>+ <span className="lan-grants-option-label">{label}</span>+ <span className="lan-grants-option-hint">{hint}</span></span>}- checked={value.chat}+ checked={value[key]}disabled={disabled}- onChange={(event) => onChange({ ...value, chat: event.target.checked })}+ onChange={(event) => onChange({ ...value, [key]: event.target.checked })}/>- <Checkbox- className="lan-grants-option"- label={- <span className="lan-grants-option-copy">- <span className="lan-grants-option-label">{t("organize")}</span>- <span className="lan-grants-option-hint">{t("organizeHint")}</span>- </span>- }- checked={value.organize}- disabled={disabled}- onChange={(event) => onChange({ ...value, organize: event.target.checked })}- />- </div>- </section>-+ ))}+ </div><p className="lan-grants-note"><IconShield size={14} aria-hidden="true" />{t("approvalsStayHere")}diff --git a/apps/desktop/src/features/lan-webui/LanPairDialog.tsx b/apps/desktop/src/features/lan-webui/LanPairDialog.tsxindex 5d1ef39f9..f0084722f 100644--- a/apps/desktop/src/features/lan-webui/LanPairDialog.tsx+++ b/apps/desktop/src/features/lan-webui/LanPairDialog.tsx@@ -100,11 +100,10 @@ export function LanPairDialog({ origin, code, busy, error, issueCode, onClose }:/** Approve a pending browser, or change what a paired device may do. */export function LanAccessDialog({- mode, label, projects, initial, busy, error, onSubmit, onDeny, onClose,+ mode, label, initial, busy, error, onSubmit, onDeny, onClose,}: {mode: "approve" | "edit";label: string;- projects: LanAdminView["projects"];initial: LanGrants;busy: boolean;error: string | null;@@ -114,8 +113,6 @@ export function LanAccessDialog({}) {const { t } = useTranslation("lan");const [draft, setDraft] = useState(initial);- const projectIds = projects.filter((project) => draft.projectIds.includes(project.id)).map((project) => project.id);- const ready = projectIds.length > 0 || draft.temporary;return (<LanDialogid={`lan-access-${mode}`}@@ -127,7 +124,6 @@ export function LanAccessDialog({onClose={onClose}footer={<>- {!ready ? <span className="lan-dialog-footer-hint" role="status">{t("needScope")}</span> : null}{mode === "approve" ? (<Button type="button" variant="ghost" aria-disabled={busy || undefined} onClick={busy ? undefined : onDeny}>{t("deny")}</Button>) : (@@ -136,16 +132,15 @@ export function LanAccessDialog({<Buttontype="button"variant="primary"- disabled={!ready}aria-disabled={busy || undefined}- onClick={busy ? undefined : () => onSubmit({ ...draft, projectIds })}+ onClick={busy ? undefined : () => onSubmit(draft)}>{mode === "approve" ? t("allow") : t("save")}</Button></>}>- <LanGrantsEditor projects={projects} value={{ ...draft, projectIds }} onChange={setDraft} disabled={busy} />+ <LanGrantsEditor value={draft} onChange={setDraft} disabled={busy} /></LanDialog>);}diff --git a/apps/desktop/src/features/lan-webui/LanWebUiSection.tsx b/apps/desktop/src/features/lan-webui/LanWebUiSection.tsxindex 08e46e24f..d73d83e1d 100644--- a/apps/desktop/src/features/lan-webui/LanWebUiSection.tsx+++ b/apps/desktop/src/features/lan-webui/LanWebUiSection.tsx@@ -194,7 +194,7 @@ export function LanWebUiSection() {<div className="lan-device-name">{entry.label}</div><div className="lan-device-meta">{[- grants.projectIds.length ? t("scope", { count: grants.projectIds.length }) : null,+ t("scopeAll"),grants.temporary ? t("scopeTemporary") : null,actions.length ? list.format(actions) : t("viewOnly"),t("activeAt", { time: time(entry.lastActiveAt) }),@@ -233,7 +233,6 @@ export function LanWebUiSection() {key={request.id}mode="approve"label={request.label}- projects={view.projects}initial={NEW_DEVICE_GRANTS}busy={busy}error={errorText}@@ -247,7 +246,6 @@ export function LanWebUiSection() {key={device.id}mode="edit"label={device.label}- projects={view.projects}initial={device.grants}busy={busy}error={errorText}diff --git a/apps/desktop/src/locales/lan.ts b/apps/desktop/src/locales/lan.tsindex ee5029426..5a5cac4a0 100644--- a/apps/desktop/src/locales/lan.ts+++ b/apps/desktop/src/locales/lan.ts@@ -30,8 +30,7 @@ export const lanEn = {permissions: "Permissions",remove: "Remove",activeAt: "Active {{time}}",- scope_one: "{{count}} project",- scope_other: "{{count}} projects",+ scopeAll: "All local projects",scopeTemporary: "Temporary conversations",canChat: "Can send",canOrganize: "Can organize",@@ -46,22 +45,14 @@ export const lanEn = {waiting: "Waiting for the device…",close: "Close",approveTitle: "Allow {{label}}?",- approveDescription: "Choose which projects and actions to share with this device.",+ approveDescription: "This device can view current and future local projects, including archived conversations.",editTitle: "{{label}} permissions",- projects: "Projects",- selectedCount: "{{selected}} of {{total}} selected",- selectAll: "Select all",- selectNone: "Clear",- noProjects: "There are no projects yet.",temporaryHint: "Conversations that are not in a project",- abilities: "Allowed actions",- alwaysView: "View conversations and replies",chat: "Send messages and start conversations",chatHint: "Also stop a reply or cancel a queued message",organize: "Rename, pin and archive",organizeHint: "Applies to projects and conversations",approvalsStayHere: "Tool and plan approvals always stay on this computer.",- needScope: "Choose at least one project or Temporary conversations.",allow: "Allow",save: "Save",cancel: "Cancel",@@ -71,7 +62,7 @@ export const lanEn = {INVALID_PORT: "Use a port between 1024 and 65535.",NOT_RUNNING: "Turn the service on first.",NOT_FOUND: "This device or request is no longer available.",- INVALID_SCOPE: "Choose at least one project or Temporary conversations.",+ INVALID_SCOPE: "This approval uses outdated settings. Restart PI-Desktop and try again.",RATE_LIMITED: "Too many devices. Remove one first.",FAILED: "The action failed. Try again.",},@@ -108,8 +99,7 @@ export const lanZh: typeof lanEn = {permissions: "权限",remove: "移除",activeAt: "{{time}}活跃",- scope_one: "{{count}} 个项目",- scope_other: "{{count}} 个项目",+ scopeAll: "所有本机项目",scopeTemporary: "临时会话",canChat: "可发消息",canOrganize: "可整理",@@ -124,22 +114,14 @@ export const lanZh: typeof lanEn = {waiting: "等待设备输入配对码…",close: "关闭",approveTitle: "允许 {{label}} 连接?",- approveDescription: "选择要共享给这台设备的项目和操作权限。",+ approveDescription: "这台设备可查看现有和以后新增的本机项目,包括已归档的会话。",editTitle: "{{label}} 的权限",- projects: "项目",- selectedCount: "已选 {{selected}} / {{total}}",- selectAll: "全选",- selectNone: "清空",- noProjects: "还没有项目。",temporaryHint: "不属于任何项目的会话",- abilities: "允许的操作",- alwaysView: "查看会话和回复",chat: "发消息和新建会话",chatHint: "也可以停止回复、取消排队消息",organize: "重命名、置顶和归档",organizeHint: "适用于项目和会话",approvalsStayHere: "工具和计划审批始终只在这台电脑上完成。",- needScope: "至少选择一个项目或“临时会话”。",allow: "允许",save: "保存",cancel: "取消",@@ -149,7 +131,7 @@ export const lanZh: typeof lanEn = {INVALID_PORT: "请使用 1024 到 65535 之间的端口。",NOT_RUNNING: "请先开启服务。",NOT_FOUND: "该设备或请求已失效。",- INVALID_SCOPE: "至少选择一个项目或“临时会话”。",+ INVALID_SCOPE: "授权设置已过期,请重启 PI-Desktop 后重试。",RATE_LIMITED: "设备过多,请先移除一台。",FAILED: "操作失败,请重试。",},diff --git a/apps/desktop/src/styles/lan-webui.css b/apps/desktop/src/styles/lan-webui.cssindex 08c36fac8..d01516371 100644--- a/apps/desktop/src/styles/lan-webui.css+++ b/apps/desktop/src/styles/lan-webui.css@@ -64,7 +64,6 @@.lan-address-hint,.lan-device-meta,.lan-dialog-description,-.lan-dialog-footer-hint,.lan-code-meta,.lan-pair-waiting,.lan-grants-option-hint,@@ -113,14 +112,12 @@border-block-start: 1px solid var(--ds-border-subtle);}-.lan-device.is-request {background: color-mix(in oklab, var(--ds-accent) 7%, var(--ds-tile));}.lan-device-actions,-.lan-code-meta,-.lan-grants-section-meta {+.lan-code-meta {display: flex;flex-wrap: wrap;align-items: center;@@ -225,10 +222,6 @@border-top: 1px solid var(--ds-border-subtle);}-.lan-dialog-footer-hint {- margin-inline-end: auto;-}-.lan-pair-steps {display: grid;gap: 20px;@@ -337,27 +330,6 @@gap: 16px;}-.lan-grants-section-head {- display: flex;- align-items: center;- justify-content: space-between;- flex-wrap: wrap;- gap: 4px 8px;- margin-bottom: 6px;-}--.lan-grants-section-title {- margin: 0;- color: var(--ds-text-primary);- font-size: var(--text-md);- font-weight: var(--font-weight-semibold);-}--.lan-grants-section-meta {- color: var(--ds-text-secondary);- font-size: var(--text-sm);-}-.lan-grants-list {display: grid;border: 1px solid var(--ds-border-subtle);@@ -365,13 +337,11 @@background: var(--ds-tile);}-/* Keep one scroll region in the dialog; even long project lists share it. */.lan-grants-list > :not(:first-child) {border-top: 1px solid var(--ds-border-subtle);}.lan-grants-option.ui-checkbox,-.lan-grants-empty,.lan-grants-fixed {min-height: 40px;padding: 9px 12px;@@ -399,16 +369,6 @@font-size: var(--text-sm-plus);}-.lan-grants-option.ui-checkbox.lan-grants-option-separate {- border-top: 1px solid var(--ds-border-default);-}--.lan-grants-empty {- margin: 0;- color: var(--ds-text-secondary);- font-size: var(--text-sm-plus);-}-.lan-grants-fixed,.lan-grants-note {display: flex;diff --git a/apps/desktop/test/helpers/lan-webui-fixture.mjs b/apps/desktop/test/helpers/lan-webui-fixture.mjsindex fd10bd968..ba5bfd469 100644--- a/apps/desktop/test/helpers/lan-webui-fixture.mjs+++ b/apps/desktop/test/helpers/lan-webui-fixture.mjs@@ -19,6 +19,8 @@ export function desktop() {{ id: "s-b1", title: "Second root chat", projectPath: "/work/b2", mode: "agent", updatedAt: "2026-11-02" },{ id: "s-plan", title: "A plan", projectPath: "/work/a", mode: "plan", updatedAt: "2026-10-01" },{ id: "s-tmp", title: "Scratch", projectPath: null, mode: "agent", updatedAt: "2026-11-03" },+ { id: "s-ssh", title: "SSH session", projectPath: "/remote", mode: "agent" },+ { id: "s-ungrouped", title: "Ungrouped", projectPath: "/unregistered", mode: "agent" },];const meta = { projectMeta: {}, sessionMeta: {} };const calls = [];diff --git a/apps/desktop/test/lan-webui-browser-user-path.test.mjs b/apps/desktop/test/lan-webui-browser-user-path.test.mjsindex b6972440a..2e154673a 100644--- a/apps/desktop/test/lan-webui-browser-user-path.test.mjs+++ b/apps/desktop/test/lan-webui-browser-user-path.test.mjs@@ -40,7 +40,7 @@ const journey = String.raw`(async () => {code.value = window.__code;document.querySelector(".pair button[type=submit]").click();- // Desktop approves; the shared projects appear (the unshared one does not).+ // Desktop approves the device; both local projects appear, but the SSH project does not.await wait(() => rowByTitle("Alpha"), "projects");result.projects = [...document.querySelectorAll(".row-title")].map((n) => n.textContent);@@ -82,25 +82,23 @@ const journey = String.raw`(async () => {})()`;const afterGrantEdit = String.raw`(async () => {- const waitForRow = async (label) => {+ const waitForRow = async (label, ready = () => true) => {const deadline = performance.now() + 10_000;while (performance.now() < deadline) {const row = [...document.querySelectorAll(".row")].find((item) => item.querySelector(".row-title")?.textContent === label);- if (row) return row;+ if (row && ready(row)) return row;await new Promise(requestAnimationFrame);}throw new Error("Missing row after grant edit: " + label);};- const project = await waitForRow("Beta");+ const readOnly = (row) => !row.querySelector(".row-more") && !document.querySelector("main > button.primary");+ await waitForRow("Fix login", readOnly);+ history.back();+ await waitForRow("Alpha");const projectTitles = [...document.querySelectorAll(".row-title")].map((item) => item.textContent);- project.querySelector(".row-main").click();+ (await waitForRow("Beta")).querySelector(".row-main").click();const session = await waitForRow("Second root chat");- return {- projectTitles,- canOrganize: Boolean(session.querySelector(".row-more")),- canCreate: Boolean(document.querySelector("main > button.primary")),- pairingShown: Boolean(document.getElementById("pair-code")),- };+ return { projectTitles, readOnly: readOnly(session), pairingShown: Boolean(document.getElementById("pair-code")) };})()`;test("a phone pairs, organizes, chats and follows updated grants through the real page", { timeout: 60_000 }, async (t) => {@@ -113,7 +111,7 @@ test("a phone pairs, organizes, chats and follows updated grants through the rea// Desktop-side approval as soon as the phone asks.const approver = setInterval(() => {const [pending] = server.pending();- if (pending) server.confirm(pending.id, { projectIds: ["g-a"], temporary: false, chat: true, organize: true });+ if (pending) server.confirm(pending.id, { projectScope: "all-local", temporary: false, chat: true, organize: true });}, 50);const temp = await mkdtemp(join(process.env.PI_SCRATCH_DIR ?? tmpdir(), "lan-webui-ui-"));t.after(async () => {@@ -156,7 +154,7 @@ app.whenReady().then(async () => {if (edited || !stdout.includes("EDIT_GRANTS\n")) return;edited = true;const [device] = server.devices();- if (device) server.update(device.id, { projectIds: ["g-b"], temporary: false, chat: false, organize: false });+ if (device) server.update(device.id, { projectScope: "all-local", temporary: false, chat: false, organize: false });child.stdin.end("updated");});child.stderr.on("data", (chunk) => (stderr += chunk));@@ -166,7 +164,7 @@ app.whenReady().then(async () => {assert.ok(line, stdout + stderr);const result = JSON.parse(line.slice(7));- assert.deepEqual(result.projects, ["Alpha"]);+ assert.deepEqual(result.projects, ["Alpha", "Beta"]);assert.deepEqual(result.sessions, ["Fix login", "A plan"]);assert.equal(result.projectHash, "#/p/g-a");assert.ok(result.pinnedMeta.length > 0, "the pinned label is shown");@@ -181,5 +179,5 @@ app.whenReady().then(async () => {assert.equal(result.horizontalScroll, false);assert.equal(result.smallTargets, 0);assert.equal(result.backHash, "#/p/g-a");- assert.deepEqual(result.afterEdit, { projectTitles: ["Beta"], canOrganize: false, canCreate: false, pairingShown: false });+ assert.deepEqual(result.afterEdit, { projectTitles: ["Alpha", "Beta"], readOnly: true, pairingShown: false });});diff --git a/apps/desktop/test/lan-webui-settings-user-path.test.mjs b/apps/desktop/test/lan-webui-settings-user-path.test.mjsindex ee7f95dec..4d5dbdc4e 100644--- a/apps/desktop/test/lan-webui-settings-user-path.test.mjs+++ b/apps/desktop/test/lan-webui-settings-user-path.test.mjs@@ -34,7 +34,6 @@ const copied = [];const view = {running: false, origin: null, address: null, port: null, code: null, pending: [], devices: [], error: null,interfaces: [{ address: "192.168.1.20", name: "Wi-Fi" }],- projects: [{ id: "alpha", label: "Alpha" }, { id: "beta", label: "Beta" }],};let stateReads = 0;let startFails = true;@@ -175,29 +174,24 @@ window.lanSettingsProbe = async () => {emit();await wait(() => title() === "Allow iPhone?", "new request advances directly to approval");await wait(() => dialog().contains(document.activeElement), "focus moves into approval");- check(button(lanEn.allow, dialog()).disabled && !checkbox("Alpha").checked && !checkbox("Beta").checked, "no project preselected");+ check(!button(lanEn.allow, dialog()).disabled, "device approval does not require choosing a project");+ check(dialog().textContent.includes(lanEn.scopeAll) && dialog().textContent.includes(lanEn.approveDescription), "approval discloses access to all local projects");+ check(dialog().querySelectorAll('input[type="checkbox"]').length === 3 && !checkbox(lanEn.scopeTemporary).checked, "only optional permissions are configurable");q(".lan-dialog-close", dialog()).focus();- check(!press("Tab", true) && document.activeElement === button(lanEn.deny, dialog()), "Shift+Tab stays in the approval dialog");- click(button(lanEn.selectAll, dialog()));- await wait(() => checkbox("Alpha").checked && checkbox("Beta").checked, "select all");- click(button(lanEn.selectNone, dialog()));- await wait(() => button(lanEn.allow, dialog()).disabled, "clear selection");- click(checkbox("Alpha"));- await wait(() => !button(lanEn.allow, dialog()).disabled, "selected scope enables approval");+ check(!press("Tab", true) && document.activeElement === button(lanEn.allow, dialog()), "Shift+Tab stays in the approval dialog");click(button(lanEn.allow, dialog()));await wait(() => !dialog() && button(lanEn.permissions) && document.activeElement === button(lanEn.addDevice), "paired device row and restored focus");document.documentElement.dataset.theme = "light";click(button(lanEn.permissions));await wait(() => title() === "iPhone permissions", "edit device");- check(checkbox("Alpha").checked && !checkbox("Beta").checked && fitsDialog(), "permissions load and fit in a narrow light window");- click(checkbox("Alpha"));- click(checkbox("Beta"));+ check(dialog().textContent.includes(lanEn.scopeAll) && !checkbox(lanEn.scopeTemporary).checked && fitsDialog(), "device permissions fit in a narrow light window");click(checkbox(lanEn.chat));click(checkbox(lanEn.organize));await wait(() => !button(lanEn.save, dialog()).disabled && !checkbox(lanEn.chat).checked, "view-only edit");click(button(lanEn.save, dialog()));await wait(() => !dialog() && q(".lan-device:not(.is-request)")?.textContent.includes(lanEn.viewOnly), "device updates without re-pairing");+ check(q(".lan-device:not(.is-request)").textContent.includes(lanEn.scopeAll), "project access is retained in view-only mode");click(button(lanEn.deny, q(".lan-device.is-request")));await wait(() => !q(".lan-device.is-request"), "deny pre-existing request");click(button(lanEn.remove));@@ -262,8 +256,8 @@ app.whenReady().then(async () => {{ kind: "start", address: "192.168.1.20", port: 38180 },{ kind: "start", address: "192.168.1.20", port: 38180 },{ kind: "issueCode" }, { kind: "issueCode" }, { kind: "issueCode" },- { kind: "confirm", id: "phone", grants: { projectIds: ["alpha"], temporary: false, chat: true, organize: true } },- { kind: "update", id: "device", grants: { projectIds: ["beta"], temporary: false, chat: false, organize: false } },+ { kind: "confirm", id: "phone", grants: { projectScope: "all-local", temporary: false, chat: true, organize: true } },+ { kind: "update", id: "device", grants: { projectScope: "all-local", temporary: false, chat: false, organize: false } },{ kind: "deny", id: "old" }, { kind: "revoke", id: "device" }, { kind: "stop" },],copied: ["http://192.168.1.20:38180"],diff --git a/apps/desktop/test/lan-webui-user-path.test.mjs b/apps/desktop/test/lan-webui-user-path.test.mjsindex d4e83017a..96314c418 100644--- a/apps/desktop/test/lan-webui-user-path.test.mjs+++ b/apps/desktop/test/lan-webui-user-path.test.mjs@@ -3,6 +3,8 @@ import test from "node:test";import { request } from "node:http";import { browser, createLanServer, desktop } from "./helpers/lan-webui-fixture.mjs";+const allProjects = { projectScope: "all-local", temporary: false, chat: true, organize: true };+async function setup(t, grants, wrapHandler = (workspace) => workspace) {const fake = desktop();const server = createLanServer({ handler: wrapHandler(fake.workspace), assets: new Map([["/index.html", { type: "text/html", body: "<p>ok</p>" }]]) });@@ -18,18 +20,21 @@ async function setup(t, grants, wrapHandler = (workspace) => workspace) {assert.equal((await phone.request("POST", "/pair", { code, label: "iPhone" })).status, 200);assert.equal((await phone.request("GET", "/pair/status")).body.state, "pending");assert.equal((await phone.request("GET", "/v1/me")).status, 401, "no data before Desktop confirms");+ assert.equal((await phone.request("GET", "/v1/projects")).status, 401);const [pending] = server.pending();assert.equal(pending.label, "iPhone");+ assert.throws(() => server.confirm(pending.id, { projectIds: ["g-a"], temporary: false, chat: true, organize: true }), { code: "INVALID_SCOPE" });+ assert.equal((await phone.request("GET", "/pair/status")).body.state, "pending");server.confirm(pending.id, grants);assert.equal((await phone.request("GET", "/pair/status")).body.state, "paired");await phone.signIn();return { ...fake, server, phone, origin };}-test("pair, browse shared projects, create, chat and organize from a phone", async (t) => {- const { phone, calls, turns, activeTurns, meta, server } = await setup(t, { projectIds: ["g-a", "g-b"], temporary: false, chat: true, organize: true });+test("pair, browse all local projects, create, chat and organize from a phone", async (t) => {+ const { phone, calls, turns, activeTurns, meta, server } = await setup(t, allProjects);- // Only the shared local projects are listed; remote and unshared ones are not.+ // No project choices are required; the SSH-backed group stays hidden.const projects = await phone.request("GET", "/v1/projects?q=");assert.deepEqual(projects.body.items.map((p) => p.id), ["g-a", "g-b"]);@@ -44,6 +49,7 @@ test("pair, browse shared projects, create, chat and organize from a phone", asyassert.deepEqual(chat.body.messages.items.map((m) => [m.role, m.text]), [["user", "hello"], ["assistant", "hi there"], ["tool", "Bash"]]);assert.equal(JSON.stringify(chat.body).includes("/secret/path"), false);assert.equal((await phone.request("GET", "/v1/sessions/s-b1")).body.waiting, "approval");+ assert.equal((await phone.request("POST", "/v1/sessions", { projectId: "g-r" })).status, 404);// New session in the explicit project; a double tap with the same key creates one.const key = "create-key-123";@@ -95,12 +101,13 @@ test("pair, browse shared projects, create, chat and organize from a phone", asyassert.equal((await phone.request("GET", "/v1/projects")).status, 401);});-test("scope, grants and request guards fail closed", async (t) => {- const { phone, origin, server } = await setup(t, { projectIds: ["g-a"], temporary: false, chat: false, organize: false });+test("remote projects, temporary scope, mutation grants and request guards fail closed", async (t) => {+ const { phone, origin, server } = await setup(t, { ...allProjects, chat: false, organize: false });- for (const path of ["/v1/sessions?projectId=g-b", "/v1/sessions/s-b1", "/v1/sessions/s-tmp", "/v1/sessions?projectId=__temporary__"]) {+ for (const path of ["/v1/sessions?projectId=g-r", "/v1/sessions/s-ssh", "/v1/sessions/s-ungrouped", "/v1/sessions/s-tmp", "/v1/sessions?projectId=__temporary__"]) {assert.equal((await phone.request("GET", path)).status, 404, path);}+ assert.equal((await phone.request("GET", "/v1/sessions/s-b1")).status, 200);assert.equal((await phone.request("POST", "/v1/sessions", { projectId: "g-a" })).body.code, "FORBIDDEN");assert.equal((await phone.request("POST", "/v1/sessions/s-a1/turns", { text: "x" })).body.code, "FORBIDDEN");const session = (await phone.request("GET", "/v1/sessions?projectId=g-a")).body.items[0];@@ -134,35 +141,35 @@ test("scope, grants and request guards fail closed", async (t) => {assert.equal(server.devices().length, 0);});-test("projects with the same name are told apart without exposing paths", async (t) => {- const fake = desktop();- fake.groups.push({ id: "g-a2", name: "Alpha", primaryPath: "/elsewhere/clone/a", roots: [{ path: "/elsewhere/clone/a", name: "a", position: 0 }], pinned: false, lastOpenedAt: 0, createdAt: 0, updatedAt: 0 });- t.after(() => fake.workspace.dispose());- const labels = (await fake.workspace.operatorProjects()).map((p) => p.label);- assert.deepEqual(labels, ["Alpha · work", "Beta", "Remote", "Alpha · clone"].filter((l) => l !== "Remote"));- assert.equal(labels.some((l) => l.includes("/")), false);+test("a paired device sees newly added projects and distinguishes duplicate names without paths", async (t) => {+ const { phone, groups } = await setup(t, allProjects);+ assert.deepEqual((await phone.request("GET", "/v1/projects")).body.items.map((project) => project.id), ["g-a", "g-b"]);+ groups.push({ id: "g-a2", name: "Alpha", primaryPath: "/elsewhere/clone/a", roots: [{ path: "/elsewhere/clone/a", name: "a", position: 0 }], pinned: false, lastOpenedAt: 0, createdAt: 0, updatedAt: 0 });+ const projects = (await phone.request("GET", "/v1/projects")).body.items;+ assert.deepEqual(projects.map(({ id, label }) => [id, label]), [["g-a", "Alpha · work"], ["g-b", "Beta"], ["g-a2", "Alpha · clone"]]);+ assert.equal((await phone.request("GET", "/v1/sessions?projectId=g-a2")).status, 200);});test("temporary conversations need their own grant", async (t) => {- const { phone, calls } = await setup(t, { projectIds: [], temporary: true, chat: true, organize: false });+ const { phone, calls } = await setup(t, { ...allProjects, temporary: true, organize: false });assert.deepEqual((await phone.request("GET", "/v1/sessions?projectId=__temporary__")).body.items.map((s) => s.id), ["s-tmp"]);- assert.equal((await phone.request("GET", "/v1/sessions/s-a1")).status, 404);+ assert.equal((await phone.request("GET", "/v1/sessions/s-a1")).status, 200);const created = await phone.request("POST", "/v1/sessions", { projectId: null });assert.equal(created.status, 200);assert.deepEqual(calls.find(([c]) => c === "create")[1], [{}], "no project is inherited");});-test("editing a device applies the new grants without returning data from the old scope", { timeout: 10_000 }, async (t) => {+test("editing temporary and mutation grants discards stale results without pairing again", { timeout: 10_000 }, async (t) => {const prepared = Promise.withResolvers();const release = Promise.withResolvers();t.after(() => release.resolve());const { phone, server, calls } = await setup(t, {- projectIds: ["g-a", "g-b"], temporary: false, chat: true, organize: true,+ ...allProjects, temporary: true,}, (workspace) => ({...workspace,async handle(request, key) {const result = await workspace.handle(request, key);- if (request.path === "/v1/sessions/s-a1") {+ if (request.path === "/v1/sessions/s-tmp") {prepared.resolve();await release.promise;}@@ -170,27 +177,27 @@ test("editing a device applies the new grants without returning data from the ol},}));const id = server.devices()[0].id;- assert.throws(() => server.update(id, { projectIds: [], temporary: false, chat: true, organize: true }), { code: "INVALID_SCOPE" });+ assert.throws(() => server.update(id, { projectIds: ["g-a"], temporary: false, chat: true, organize: true }), { code: "INVALID_SCOPE" });const mutation = { "Idempotency-Key": "device-edit-create" };assert.equal((await phone.request("POST", "/v1/sessions", { projectId: "g-a" }, mutation)).status, 200);- const stream = await phone.events("/v1/sessions/s-a1/events", t.signal);+ const stream = await phone.events("/v1/sessions/s-tmp/events", t.signal);assert.equal(stream.status, 200);const reader = stream.body.getReader();assert.equal((await reader.read()).done, false);- const inFlight = phone.request("GET", "/v1/sessions/s-a1");+ const inFlight = phone.request("GET", "/v1/sessions/s-tmp");await prepared.promise;- server.update(id, { projectIds: ["g-b"], temporary: false, chat: false, organize: false });+ server.update(id, { ...allProjects, chat: false, organize: false });release.resolve();assert.deepEqual(await inFlight, { status: 409, body: { code: "CONFLICT" } });assert.equal((await reader.read()).done, true, "editing grants closes the subscribed stream");- assert.equal((await phone.events("/v1/sessions/s-a1/events", t.signal)).status, 404);+ assert.equal((await phone.events("/v1/sessions/s-tmp/events", t.signal)).status, 404);assert.equal((await phone.request("POST", "/v1/sessions", { projectId: "g-a" }, mutation)).status, 409);assert.equal(calls.filter(([channel]) => channel === "create").length, 1);const me = await phone.request("GET", "/v1/me");- assert.deepEqual(me.body.access, { deviceId: id, projectIds: ["g-b"], temporary: false, chat: false, organize: false });- assert.deepEqual((await phone.request("GET", "/v1/projects")).body.items.map((project) => project.id), ["g-b"]);- assert.equal((await phone.request("GET", "/v1/sessions/s-a1")).status, 404);+ assert.deepEqual(me.body.access, { deviceId: id, ...allProjects, chat: false, organize: false });+ assert.deepEqual((await phone.request("GET", "/v1/projects")).body.items.map((project) => project.id), ["g-a", "g-b"]);+ assert.equal((await phone.request("GET", "/v1/sessions/s-tmp")).status, 404);assert.equal((await phone.request("POST", "/v1/sessions", { projectId: "g-b" })).status, 403);});diff --git a/docs/adr/README.md b/docs/adr/README.mdindex a5534fb86..98c208080 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -26,6 +26,7 @@ git history.| ID | Title | Status ||---|---|---|+| lan-webui-project-access | [Device confirmation grants access to all local LAN WebUI projects](lan-webui-project-access.md) | Accepted || codemode-sandbox-boundary | [Codemode sandbox execution boundary](codemode-sandbox-boundary.md) | Accepted || mode-definitions | [User-definable modes as staged workflows](mode-definitions.md) | Proposed || sidebar-layout-recovery | [Recover sidebar layout independently of Chromium storage](sidebar-layout-recovery.md) | Accepted |diff --git a/docs/adr/lan-webui-project-access.md b/docs/adr/lan-webui-project-access.mdnew file mode 100644index 000000000..d2b49ca53--- /dev/null+++ b/docs/adr/lan-webui-project-access.md@@ -0,0 +1,34 @@+# ADR: Device confirmation grants access to all local LAN WebUI projects++- Status: Accepted+- Date: 2026-11-26+- Related: [ADR 0205](0205-remote-agent-control-boundary.md), [LAN WebUI MVP](../spec/01-product/03-lan-webui-mvp.md)++## Context++The LAN companion is an opt-in view of the running Desktop. Per-project+allowlists made each new device pairing depend on a second selection, and new+local projects remained hidden from already paired devices.++## Decision++The local user still confirms each browser after one-time code pairing. That+confirmation explicitly grants visibility of the current and future eligible+local projects, including archived history, without an individual checklist.+The Desktop edge reads the current local catalog for requests; it does not+snapshot project IDs or include SSH-backed projects. Temporary conversations+remain off by default, and the Chat and Organize grants and the remote `ask`+ceiling still apply. Transport, process ownership, and the RACP role model do+not change.++## Consequences++A paired device can read a newly registered local project without another+prompt. Keep this visible at confirmation and remove devices that should no+longer share the Desktop's projects. Keep the listener off on untrusted networks.++The private LAN admin contract and the WebUI's access metadata replace the MVP's+project ID list with an explicit `all-local` scope marker. Stale confirmation+or update requests without the marker fail closed. Pairings are memory-only;+updating/restarting Desktop requires a fresh confirmation, not a persisted grant+migration.diff --git a/docs/spec/01-product/03-lan-webui-mvp.md b/docs/spec/01-product/03-lan-webui-mvp.mdindex b715d1f8f..8fa377c81 100644--- a/docs/spec/01-product/03-lan-webui-mvp.md+++ b/docs/spec/01-product/03-lan-webui-mvp.md@@ -47,15 +47,16 @@ numbers refer to the [WebUI acceptance catalog](../06-delivery/e2e/live-and-remo3. Once the listener is on, the connection card shows a copyable address andthe Devices card shows pending requests and paired devices. **Add device**opens a two-step dialog with the address, one-time 6-digit code and expiry.- A new request while the dialog is open advances it to the grant review;+ A new request while the dialog is open advances it to device confirmation;requests already waiting can be reviewed or denied from the Devices card.- No catalog or history is sent until the user confirms locally and chooses- at least one project or Temporary scope. Each code lasts at most five- minutes, is single-use, and expires after five failed attempts. Only the+ Confirmation discloses access to all eligible local projects, including+ projects added later, and does not require individual project selections.+ No catalog or history is sent before confirmation. Each code lasts at most+ five minutes, is single-use, and expires after five failed attempts. OnlyDesktop can generate a replacement code. A QR code is deferred.4. Device rows show the label, last activity and access summary. **Permissions**- edits scopes and actions without pairing again. The listener closes existing- streams and does not return pending or cached results under the old grants.+ edits temporary access and actions without pairing again. The listener closes+ existing streams and does not return pending or cached results under the old grants.The browser refetches its access and view when it reconnects. **Remove** andbrowser sign-out invalidate that device's cookie and streams. Turning offcloses the listener and invalidates every pairing; turning it back on@@ -76,15 +77,17 @@ network checks, not a false claim that the desktop quit. Never open firewall orrouter ports, use UPnP, or set up a tunnel automatically.Desktop administration stays on the main-window-only LAN admin IPC channel.-The `update` action replaces grants for an existing device; the payload-free-`lanWebUiChanged` event asks the renderer to refetch after listener, pairing or-device changes. Neither is available through the browser API.+`confirm` and `update` require `projectScope: "all-local"`, not a list of project+IDs. A stale request without this marker is refused rather than widening a+prior selection. `/v1/me` reports the same marker; `/v1/projects` is the live+catalog, not a snapshot attached to pairing. The payload-free `lanWebUiChanged`+event asks the Desktop renderer to refetch after listener, pairing or device changes.## 3. Projects and sessions (W02, W03)| Surface | Required behavior ||---|---|-| Projects | Show authorized, existing desktop projects, including eligible closed or archived ones, not just the visible sidebar. A logical multi-root group is **one** project. Search by display name across the authorized catalog, switch, rename the display name, pin/unpin, archive/restore. Show pinned first, then recent; distinguish “nothing shared”, “no matches” and “no sessions”. Do not show absolute paths. |+| Projects | Show all eligible local desktop projects, including closed or archived ones and projects added after pairing, not just the visible sidebar. A logical multi-root group is **one** project. Search by display name across the catalog, switch, rename the display name, pin/unpin, archive/restore. Show pinned first, then recent; distinguish “no local projects”, “no matches” and “no sessions”. Do not show absolute paths. || Project sessions | Enter a project to see its sessions; search by title, open history, rename, pin/unpin, archive/restore. Show running, waiting, interrupted or failed status from the Host. Stable IDs, not names or list positions, distinguish equally named records. Use bounded pages; search is not limited to the first loaded page. || New in project | A project's **New session** targets that explicit project, even if the desktop or a second tab is viewing another. Use desktop defaults and the normal local Agent. Only reuse an existing empty conversation if it meets Desktop's pristine, same-scope reuse rule; never attach to a running session or another pending submission. Double-tapping one intent cannot create two sessions. || Temporary | **Temporary conversations** is a separate Desktop share scope, off by default. When granted, list/organize existing ordinary temporary sessions and allow a new temporary session with no project and normal temporary workspace isolation. Otherwise global **New session** opens the shared-project chooser; never inherit the last desktop project or disclose temporary titles/counts. |@@ -92,10 +95,10 @@ device changes. Neither is available through the browser API.Only existing locally owned, local-workspace projects and ordinary local Agentsessions are writable in P0. Local-Agent projects backed by an SSH workspace,-legacy remote-Agent sessions, and undisclosed projects are **not exposed**.-In a shared local scope, existing special sessions (e.g. Plan/Goal) may show-safe history and “Continue on Desktop”, but no unsupported mutation. Never-convert them to Agent or bind them to a different workspace as a fallback.+legacy remote-Agent sessions, and sessions outside a registered project or+the Temporary scope are **not exposed**. In a local project, existing special+sessions (e.g. Plan/Goal) may show safe history and “Continue on Desktop”, but+no unsupported mutation. Never convert them to Agent or change their workspace.Desktop-only deletion, scope removal or a change of project membership mustinvalidate stale rows and deep links; do not redirect to a different session.@@ -183,20 +186,21 @@ Stopping the WebUI removes access, not data.## 6. Access and privacy (W06)-Follow the [remote security contract](../05-security/02-remote-control-security.md).-The person at Desktop selects **named projects** and/or the separate Temporary-scope per device. None are shared by default; newly added projects are not-implicitly included. In a shared project, make clear that its eligible existing-and future sessions, including archived history, are visible. Label the device-and explain what it can read and which model-backed actions may incur usage.+Follow the [LAN WebUI project-access decision](../../adr/lan-webui-project-access.md)+and the applicable [remote permission policy](../05-security/02-remote-control-security.md).+A device that Desktop confirms can+view **all eligible local projects**, including future projects and archived+history. Temporary conversations still require a separate, off-by-default grant.+Label the device and disclose its access before confirmation; Chat and Organize+remain separate from the ability to view projects.History may contain sensitive text the user or model already put in theconversation; sharing is not an automatic redaction of authored messages.Never enrich it with credential records, absolute workspace paths or raw tooldiagnostics that the safe transcript projection does not already expose.-| Grant | Allowed within the selected scopes | Never implied |+| Grant | Allowed within eligible scopes | Never implied ||---|---|---|-| View | Catalog, safe history, current activity and scoped events | Other project names/counts, paths, secrets or arbitrary file reads |+| View | Local project catalog, safe history, current activity and scoped events | Remote project metadata, unauthorized Temporary conversations, paths, secrets or arbitrary file reads || Chat (explicit, includes View) | Create, send/queue, interrupt, cancel queued work, answer ordinary typed questions | Shell endpoint, remote approvals, raising permission mode, configuring providers || Organize (explicit, includes View) | Rename, set pin, set archive/restore on eligible objects | Permanent delete, project registration/root editing, widening the share or granting roles |@@ -213,8 +217,8 @@ desktop session setting. A browser cannot approve its own escalation.Session archive is **owner-only** in RACP. The LAN WebUI does not reuse RACP`session/archive` and never grants a phone the owner role: its Organize grant-is checked by the WebUI edge itself, per project, and only writes the same-Desktop organization record the sidebar uses (§5).+is checked by the WebUI edge against the current local catalog and only writes+the same Desktop organization record the sidebar uses (§5).Use a Host-issued `HttpOnly`, host-only, `SameSite=Strict` session cookie(12 hours; no `Secure` flag because the MVP is HTTP), exact Host/Origin@@ -282,7 +286,7 @@ settings) and `apps/desktop/src/features/lan-webui/lan-catalog-sync.ts`| Area | Delivered | Not yet ||---|---|---|-| W01 | Off by default; interface + port; guided pairing with local grant review; edit or remove devices; sign out; stop signs everyone out | QR code; HTTPS (deliberately deferred) |+| W01 | Off by default; interface + port; guided pairing with device confirmation; all local projects; edit or remove devices; stop signs everyone out | QR code; HTTPS (deliberately deferred) || W02/W03 | Shared-project and temporary scopes; search; archived filter; rename, pin, archive/restore with revision conflicts; new session in the explicit project | Reuse of an existing empty session || W04 | Paged history; live assistant text; send; queue; cancel queued; stop the named turn; “waiting on Desktop” for approvals and input | Answering ordinary questions from the browser; model label is the raw model id || W05 | Idempotency keys for every mutation; SSE change notices with refetch; reconnect banner | Cursor-based replay (refetch is used instead) |diff --git a/docs/spec/06-delivery/e2e/live-and-remote.md b/docs/spec/06-delivery/e2e/live-and-remote.mdindex c7007cf44..e526fedb5 100644--- a/docs/spec/06-delivery/e2e/live-and-remote.md+++ b/docs/spec/06-delivery/e2e/live-and-remote.md@@ -763,24 +763,25 @@ user's running instance.- **Preconditions:** Fresh Desktop profile with projects A and B; a real phoneon the selected private LAN. Repeat on iOS Safari and Android Chrome.- **Steps:** Choose the interface and start. Open **Add device**, copy the shown- `http://` address, and enter the displayed code on the phone. In the review- dialog, select A and allow the request. Open and close the dialog with the- keyboard, regenerate an expired code, and deny a separate waiting request.- Close/reopen the tab, hide Desktop, then stop, quit and relaunch Desktop.+ `http://` address, and enter the displayed code on the phone. Confirm the+ device without choosing projects. Add project C on Desktop after pairing.+ Open and close the dialog with the keyboard, regenerate an expired code,+ and deny a separate waiting request. Close/reopen the tab, hide Desktop,+ then stop, quit and relaunch Desktop.- **Expected:** No listener by default and no project data before confirmation.- A new request advances to review without polling or user refresh. The- approval action requires a scope; the paired device sees A only. An expired,- reused or five-times-wrong code fails. Hiding Desktop/closing the tab does not- sign out. Stopping closes streams, invalidates cookies and releases the port;- restarting requires pairing again. An occupied port or isolated Wi-Fi- produces actionable guidance, not a silent rebind.+ The request advances to device confirmation, which discloses access to all+ local projects. The paired device sees A, B and subsequently C without another+ approval; Temporary conversations remain off. An expired, reused or five-times-+ wrong code fails. Hiding Desktop/closing the tab does not sign out. Stopping+ closes streams, invalidates cookies and releases the port; restarting requires+ pairing again. An occupied port or isolated Wi-Fi produces actionable guidance.- **Acceptance:** A, E; W01, W06.### E2E-270: Organize projects and sessions without stealing navigation- **Preconditions:** Desktop is editing an unsent draft in A. The phone has- View and Organize for A and B; B is a closed local multi-root group with- existing sessions, one separately archived. Seed a duplicate display name.+ View and Organize; B is a closed local multi-root group with existing+ sessions, one separately archived. Seed a duplicate display name.- **Steps:** Search for B, open it, pin and rename it; rename/pin/archive/restorean idle session. Archive and restore B through the archived filter. Make acompeting rename from Desktop and submit the stale edit from the phone.@@ -847,21 +848,21 @@ user's running instance.### E2E-274: Enforce device grants, network boundary and revocation-- **Preconditions:** A View-only device, a second device with Chat/Organize for- A only, and unshared B, Temporary and SSH-backed fixtures. Use a controlled+- **Preconditions:** A View-only device, a second device with Chat, Organize and+ Temporary access, two local projects and an SSH-backed project. Use a controlledclock, a second interface and an allowed and a disallowed browser origin.- **Steps:** Exercise catalog, deep links, history, search/counts, commands andSSE with those identities. Check wrong Origin/Host, absent CSRF, expiredcookies, pairing throttles and rejected admin/owner operations. In **Permissions**,- replace A with B and switch to View only while a stream, a queued turn and an- in-flight catalog request exist. Remove the device and change the desktop- network. Inspect fixture logs/cache.+ turn off Temporary, Chat and Organize while a temporary history request and+ stream are in flight. Remove the device and change the desktop network.+ Inspect fixture logs/cache.- **Expected:** No out-of-scope metadata, events or writes, even for known IDs;View cannot mutate. No generic owner/SSH exemption or raw RPC, no leakedcredentials/content in logs or persistent browser caches. Permission edits- do not require re-pairing and the browser reflects the new access after- reconnecting. Lost scope closes affected streams and cancels its pending- queued work; a late or cached reply under the old grants cannot recover it.+ do not require re-pairing or change local project visibility. Temporary scope+ loss closes affected streams and cancels its pending queued work; a late or+ cached reply under the old grants cannot recover it.Expiry is not extended by a heartbeat. No connection on other interfaces orautomatic sharing on the new network.- **Acceptance:** D, E; W01, W02, W06.diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.mdindex 93ff6e250..ad83b32b8 100644--- a/docs/spec/08-meta/decisions-log.md+++ b/docs/spec/08-meta/decisions-log.md@@ -5426,3 +5426,10 @@ See ADR 0344.- Enable only generated session titles on first use. Keep next-messagesuggestions, prompt enhancement, and AI memory opt-in. Preserve explicitsettings and keep the deterministic fallback and manual-title protections.++## 2026-11-26 — LAN WebUI project access follows device confirmation (D686)++- A locally confirmed device can view all eligible current and future local+ projects. Remove the project checklist, keeping one-time pairing and local+ confirmation, the separate Temporary, Chat and Organize grants, and device+ revocation. See [LAN WebUI project access](../../adr/lan-webui-project-access.md).diff --git a/packages/shared/src/lan-webui.ts b/packages/shared/src/lan-webui.tsindex c3fd1b226..c146ae92b 100644--- a/packages/shared/src/lan-webui.ts+++ b/packages/shared/src/lan-webui.ts@@ -3,8 +3,8 @@* No native paths, host RPC or provider secrets cross this boundary.*/export interface LanGrants {- /** Host project group ids the device may see. */- projectIds: string[];+ /** All eligible local projects, resolved from the current Host catalog. */+ projectScope: "all-local";/** Temporary (projectless) conversations. */temporary: boolean;/** Create sessions, send, queue, stop. */@@ -79,7 +79,6 @@ export interface LanAdminView {pending: LanPairing[];devices: LanDevice[];interfaces: LanInterface[];- projects: Array<{ id: string; label: string }>;error: string | null;}export type LanAdminAction =