Skip to content

fix(web): bind copied session selection to file identity - #584

Open
ooiuuii wants to merge 1 commit into
openpi-dev:mainfrom
ooiuuii:fix/web-session-file-identity
Open

ooiuuii wants to merge 1 commit into
openpi-dev:mainfrom
ooiuuii:fix/web-session-file-identity

Conversation

@ooiuuii

@ooiuuii ooiuuii commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Problem

Fixes #583.

Copying a Pi JSONL Session preserves its ID. The Web adapter currently treats that ID alone as ownership of the live SessionManager: reading a copy can return the original transcript, renaming the copy can write the original, and selecting the copy can skip the runtime switch. An ID-only frontend lookup can also drift to a newer copy during refresh.

Value

Keep the displayed, selected and edited Session bound to its actual file. A copied history entry must not silently alias the active original. If switching succeeds but confirming the new snapshot fails, the stale page must not send Session-bound operations until confirmation succeeds.

Approach

  • Reuse the live manager only when both ID and resolved file path match; preserve the existing synthetic path for the in-memory Session.
  • Apply that ownership check to reads, rename, default selection, projection retention and the HTTP selection shortcut. The runtime's file-aware switching implementation is unchanged.
  • Have the store consume the existing controller: web plus path identity instead of deriving ownership from ID equality.
  • Require the existing confirmed selectedPath at prompt, model/thinking and command-discovery gates and in Composer. No new state machine or API fields. A successful refresh restores normal operation.

The backend and these necessary UI consumers repair one file-identity invariant. Splitting them would leave the same copied-ID failure reachable. Stop/cancellation identity, general multi-client concurrency, archive policy and new Session schemas are outside this PR.

Validation

Baseline: f6b49ae59605b1276b8267f2886d22c03f01533c; source checkout tests, Node 22.22.3 and Bun 1.3.14 on Windows. Fixtures contain synthetic data in isolated temporary directories, not user histories or provider calls.

  • Native SessionManager creates and persists a real JSONL, which is copied and independently modified. Three regressions fail before the fix: selected-file transcript, rename target, and authenticated loopback /api/sessions/select runtime switching.
  • Actual store actions add two refresh/canonical-retry regressions and four failed-confirmation/Composer cases. They prove that a populated original snapshot plus a successful same-ID copy switch followed by a network error or invalid projection cannot issue prompt/model/thinking/command requests; sending resumes after a valid snapshot.
  • node --experimental-strip-types --test tests/web/pi-adapter.test.ts tests/web/web-host.test.ts tests/web/artifact-host.test.ts62/62 pass.
  • node node_modules/vitest/vitest.mjs run tests/web/web-store.spec.ts tests/web/app-render.spec.ts149/149 pass.
  • bun run check and git diff --check — pass. Tracked web/dist/app.js regenerated by the normal build.
  • Scoped structured review (autoreview --mode local --engine codex --model gpt-6-astra --thinking xhigh --no-web-search): final helper exit 0, no actionable findings. Two verified same-identity consumer gaps were fixed before this final review; no unrelated follow-ups folded in.
  • Full local suite is not claimed green: separate clean-baseline host timeouts and Windows background-process cleanup hangs prevent a reliable global local result. Fresh branch CI remains the broader verification gate; no test timeouts or unrelated fixtures changed here.

Impact

  • User-visible: copied sessions show their own transcript, rename their own file, and activate correctly; an unconfirmed page disables sending until refreshed successfully.
  • Model-visible context/tools: no schema or tool changes; transcript comes from the selected file.
  • Runtime/lifecycle: live-manager reuse and UI operation admission respect file identity; underlying Pi switching/cancellation unchanged.
  • Persisted config/data: no migration, format change or ID rewriting.
  • Compatibility/risk: uses existing paths/controller projection and optional Composer fallback; no path case-folding, permission changes or new configuration.

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.

bug(web): copied session IDs alias the active session file

1 participant