Repository navigation
fix(app): verify session ownership by the engine's resolved workspace directory - #4825
Conversation
… directory Archiving (and Stop) compared `session.directory` to the workspace path the desktop stored, by string equality. OpenCode resolves the directory it serves through realpath and stamps that on every session, while the desktop keeps a newly created workspace path as added (realpath cannot resolve a folder that does not exist yet). Any workspace behind a symlink — macOS /var → /private/var, /tmp → /private/tmp, a linked folder — therefore failed every archive with "Couldn't archive session / Could not verify the conversation's workspace." and every Stop with "Stop was not confirmed." Ask the same engine which directory it serves for the workspace path (GET /path) and compare against that, so ownership is still enforced (sessions from another workspace and subtasks stamped elsewhere are refused) without depending on which spelling of the path the desktop persisted.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 4 Skipped Deployments
|
Warden review summary — ClearNative findings: 0. Blocking policy matches before consolidation: 0. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (64948 ms), confidentiality-review (89548 ms), spec-provenance-review (92793 ms), desktop-den-sync-review (124324 ms). Blockers
Advisories
Needs recheck
Observed review-thread metrics
Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority. |
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (488c45c65a27ea8990852b274d7ba60db07c1976). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (3fd30958cbf62bd5197cf5d727e92270bb87bab8). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
Test evidence — archiving a split-pane session works when the desktop stores the workspace by a linked path — ✅ passedSHA 3fd3095 · engine v1 ✅ passed · 3 expectations passed · 0 failed · 0 pending [world] desktop(daytona) · workspace(/tmp/openwork-session-archive-linked-1789065874945/link/OpenWork Chat) · sessions(2) · [seed:raw] evalIn() ℹ️ ASSERTION — 1. The desktop and the engine spell the same workspace differentlyThe persisted workspace path was the linked path /tmp/openwork-session-archive-linked-1789065874945/link/OpenWork Chat; the engine stamped both seeded sessions with /tmp/openwork-session-archive-linked-1789065874945/real/OpenWork Chat, which differs from it. Neither session was archived.
ℹ️ ASSERTION — 2. A split-pane session in a linked-path workspace archives instead of failing verificationsession.archive on the side chat ses_f735d1ad9ffeWJaQPWv5iuVxjU showed "Session archived" and never "Couldn't archive session" or "Could not verify the conversation's workspace."; the engine stamped only that session archived, the conversation and its neighbor stayed at 0, the secondary pane closed while the conversation route stayed selected, and exactly one PATCH targeted that session.
ℹ️ ASSERTION — 3. The sidebar Archive button works in a linked-path workspace and Undo restores only its targetHovering the conversation row and clicking Archive showed "Session archived" without the failure toast or a working-session prompt; the engine stamped the conversation archived while its neighbor stayed at 0, the sidebar moved only the conversation into Archived, the route returned to the workspace start, and Undo restored the conversation (neighbor still 0, the earlier side chat still archived) and reopened it.
Test run created 2026-09-10T18:42:54.520Z · Source: |
Problem
In a freshly launched dev desktop (
pnpm dev:worktree --blank-slate), creating a split session and archiving it failed with the toast "Couldn't archive session" / "Could not verify the conversation's workspace." Pressing Stop in the same profile fails the same way ("Stop was not confirmed.").Root cause
useSessionArchive(#4640) andstopForegroundTree(#4649) comparesession.directoryto the workspace path the desktop stored with!==.realpath(FSUtil.resolve→realpathSync) and stamps that resolved path on every session it stores.normalizeLocalWorkspacePathdoesrealpath(...).catch(() => resolved), and the folder does not exist yet at first launch /workspace.create, so no resolution happens.Any workspace whose path crosses a symlink therefore never matches: the blank-slate profile stores
/var/folders/.../OpenWork Chatwhile the engine's SQLite rows carry/private/var/folders/.../OpenWork Chat(verified read-only in the affected profile'sopencode.db; both sessions remainedtime_archived = NULL). The same applies to/tmp→/private/tmpon macOS and to any user folder behind a link. Split panes were only where it was first noticed; archiving any session in such a workspace fails.Fix
apps/app/src/app/lib/session-ownership.tsasks the same engine which directory it serves for the workspace path (GET /path?directory=…) and comparessession.directoryagainst that answer. Archive's tree read and Stop's root check both use it; child checks keep comparing against the verified root. Sessions from another workspace and subtasks stamped elsewhere are still refused with the existing errors, so the workspace safety check is not weakened. The v2 preview has no/pathroute and keeps its exact comparison.Proof
apps/app/tests/session-ownership.test.ts(bun, runs in CI app tests): fake engine stamps sessions with/private/var/...while the client addresses/var/...; archive tree read and Stop succeed,/pathis asked with the raw workspace path, and foreign sessions / foreign subtasks / cross-workspace reads are refused. Control with the pre-fix comparison fails with exactly the user's error.evals/specs/session-archive-linked-workspace.e2e.test.ts(desktop): creates a workspace under a symlinked parent that does not exist yet, asserts the desktop stored the linked path while the engine stamped the real one, opens a side chat, archives the side chat via the public action and the conversation via the sidebar button, asserts "Session archived", no "Couldn't archive session", the neighbor stays unarchived, and Undo restores. Control against the pre-fix comparison fails at the archive step.session-archive-undo.e2e.test.tsnow also passes locally on macOS (its/tmpworkspace hits the same symlink).Follow-up (not in this PR):
normalizeLocalWorkspacePathcould resolve the nearest existing ancestor so new workspace paths are persisted canonically; that would not help already-stored paths, which this fix covers.