Skip to content

fix(app): verify session ownership by the engine's resolved workspace directory - #4825

Merged
yomgui merged 2 commits into
devfrom
fix/split-archive-workspace-verify
Sep 10, 2026
Merged

yomgui merged 2 commits into
devfrom
fix/split-archive-workspace-verify

Conversation

@yomgui

@yomgui yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member

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) and stopForegroundTree (#4649) compare session.directory to the workspace path the desktop stored with !==.

  • OpenCode resolves the directory it serves through realpath (FSUtil.resolve → realpathSync) and stamps that resolved path on every session it stores.
  • The desktop persists a newly created workspace path exactly as added: normalizeLocalWorkspacePath does realpath(...).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 Chat while the engine's SQLite rows carry /private/var/folders/.../OpenWork Chat (verified read-only in the affected profile's opencode.db; both sessions remained time_archived = NULL). The same applies to /tmp → /private/tmp on 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.ts asks the same engine which directory it serves for the workspace path (GET /path?directory=…) and compares session.directory against 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 /path route 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, /path is 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.
  • Existing session-archive-undo.e2e.test.ts now also passes locally on macOS (its /tmp workspace hits the same symlink).

Follow-up (not in this PR): normalizeLocalWorkspacePath could resolve the nearest existing ancestor so new workspace paths are persisted canonically; that would not help already-stored paths, which this fix covers.

… 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.
@vercel

vercel Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated
openwork-app Ignored Ignored Preview Sep 10, 2026 6:43pm UTC
openwork-den Ignored Ignored Preview Sep 10, 2026 6:43pm UTC
openwork-diagnostics Ignored Ignored Preview Sep 10, 2026 6:43pm UTC
openwork-landing Ignored Ignored Preview Sep 10, 2026 6:43pm UTC

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Warden review summary — Clear

Native 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

  • None.

Advisories

  • None.

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 2
  • Distinct heads in retained window: 2
  • Current unresolved Warden threads: 0 of 0 observed
  • Observed resolved/unresolved transitions in retained snapshots: 0 / 0
  • First observed resolved/unresolved (state at first collection, not event time): 0 / 0
  • Precision: unavailable (no adjudications; no TP/FP values are inferred)
  • Observation window: 2/20 run attempts retained; truncated: false
  • Transition snapshot: 0/0 current attributed threads retained (limit 500); truncated: false

Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority.

diff-warden[bot]
diff-warden Bot previously approved these changes Sep 10, 2026

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@different-ai different-ai deleted a comment from github-actions Bot Sep 10, 2026
@yomgui

yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

Test evidence — archiving a split-pane session works when the desktop stores the workspace by a linked path — ✅ passed

SHA 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()
[agent] run(session.open)
[probe] hash · eventually(conversation route opens)
[user] see(composer, editable) · label=Open side chat · click(label=Open side chat)
[probe] eventually(the conversation owns a new side chat) · eventually(the side chat is stamped with the engine's real path)
[agent] run(session.archive)
[user] see(text=Session archived, timeoutMs=30000) · notSee(text=Couldn't archive session) · notSee(text=Could not verify the conversation's workspace.)
[probe] eventually(only the side chat is archived on the engine) · eventually(the conversation stays open alone) · hash
[user] hover(testId=sidebar-session-ses_f735d2cabffeVZCACVYvAHggzO) · testId=session-archive-ses_f735d2cabffeVZCACVYvAHggzO · click(testId=session-archive-ses_f735d2cabffeVZCACVYvAHggzO) · see(text=Session archived, timeoutMs=30000) · notSee(text=Couldn't archive session) · notSee(text=This session is still working)
[probe] eventually(the conversation is archived on the engine) · eventually(the conversation leaves the tree and its neighbor stays) · hash · eventually(archive returns to the workspace start) · eventually(undo pill settles)
[user] label=Undo · click(label=Undo)
[probe] eventually(Undo restores the conversation) · hash · eventually(Undo reopens the conversation)
steps 1 ✅ the desktop addresses the workspace by its linked path while the engine stamps sessions with the real path (0.1s) · 2 ✅ a side chat opened beside the conversation is a new session the engine stamps the same way (1.5s) · 3 ✅ archiving the side chat succeeds and leaves the conversation and its neighbor open (7.1s) · 4 ✅ archiving the conversation from the sidebar succeeds, keeps its neighbor, and Undo restores it (6.8s)
verdict passed · 7 user observations (see ×3, notSee ×4) · 15 probes · steps 4/4

ℹ️ ASSERTION — 1. The desktop and the engine spell the same workspace differently

The 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.

  • ✅ PASS The desktop and the engine spell the same workspace differently — The 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 verification

session.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.

  • ✅ PASS A split-pane session in a linked-path workspace archives instead of failing verification — session.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 target

Hovering 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.

  • ✅ PASS The sidebar Archive button works in a linked-path workspace and Undo restores only its target — Hovering 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: evals/results/test-runs/2026-09-10T18-42-54-519Z-archiving-a-split-pane-session-works-when-the-desktop-stores-the-workspace-by-a-/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4825 --test-run 2026-09-10T18-42-54-519Z-archiving-a-split-pane-session-works-when-the-desktop-stores-the-workspace-by-a-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant