Skip to content

fix(web): bind workspace drafts to confirmed Pi sessions - #482

Merged
tt-a1i merged 3 commits into
openpi-dev:mainfrom
sowen1023:codex/fix-467-workspace-selection
Sep 8, 2026
Merged

tt-a1i merged 3 commits into
openpi-dev:mainfrom
sowen1023:codex/fix-467-workspace-selection

Conversation

@sowen1023

Copy link
Copy Markdown
Contributor

Problem

Fixes #467.

With an empty current Session in workspace A, selecting workspace B only updates the displayed workspace. A subsequent snapshot restores A from the current Session's cwd. Before that refresh, sending a prompt can still target A's existing Session even though the UI shows B.

Value

Workspace selection remains stable, and the first prompt from a workspace draft is admitted only after Pi confirms a new active Session in that workspace. Users can retry failures without losing their intended directory or prompt text, or accidentally sending work to the previous repository.

Approach

  • Separate in-memory workspace draft intent from canonical Pi Session state. Snapshots preserve that intent; explicitly opening an existing Session leaves draft mode.
  • Reuse native Session creation on first send. Verify the returned session path against the refreshed selected Session, requested cwd, and current Session ID before prompt admission.
  • Use the existing session epoch to reject superseded directory selections, late native chooser responses, and stale asynchronous creation/model results.
  • Keep model preselection local to a draft. Hide the previous Session's transcript, trajectory, activity, and stop/queue controls while showing the draft.
  • Describe the existing creation receipt's optional sessionPath in the client type and rebuild the tracked Web bundle. No backend protocol change or parallel Session lifecycle is introduced.
  • Add separate store, rendered-UI, and browser regressions, including cancellation, failed creation/retry, mismatched receipts, refreshed snapshots, rapid workspace changes, and explicit Session reopening.

Validation

  • NODE_OPTIONS=--no-webstorage bun run test: 1,461 Node tests passed, 1 skipped; 128 Vitest tests passed. The temporary flag avoids the local Node 25 experimental WebStorage/jsdom conflict; plain bun run test fails in that environment without it. No global configuration was changed.
  • OPENPI_WEB_BROWSER_EXECUTABLE='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' ./node_modules/.bin/playwright test --config tests/web/playwright.config.ts: 10/10 passed on the final full run. An earlier full run concurrent with other tests hit an existing logo-animation opacity timeout; subsequent full reruns passed without weakening assertions or timeouts.
  • The new browser regression uses an isolated real Host and real Pi Session creation, selects/imports a second workspace, triggers snapshot refresh, and verifies that the outgoing prompt's Session ID belongs to the new canonical Session in that directory. Only the final prompt request is intercepted, so it makes no provider call.
  • bun run check: config contract, discipline ledger, and Web checks/build passed; the aggregate command is blocked by formatting in an unrelated, pre-existing untracked local architecture JSON artifact. That user artifact is unchanged and excluded from this PR.
  • Tracked-file Biome formatting check: 369 files passed. bun run lint, bun run typecheck, and git diff --check: passed.
  • Local runtime smoke: verified the checkout/package source and served bundle, then confirmed that selecting another imported workspace survives refresh and shows draft controls. No prompt was sent and no Session was created in the user's running environment.

Impact

  • User-visible behavior: Selecting another workspace opens a draft view; its first send creates a native Session there. Failed creation retains the draft and input. Selecting the original workspace again remains a new draft; opening a Session explicitly resumes it.
  • Model-visible context/tools: No new tools or schema changes. Accepted prompts are bound to the confirmed target Session.
  • Runtime/lifecycle: Reuses existing Pi Session creation and serialized transitions. Unconfirmed or superseded creation does not admit a prompt.
  • Persisted config/data: No new settings or draft persistence. Session creation retains Pi's existing persistence behavior.
  • Compatibility/risk: Frontend-only lifecycle coordination plus a type correction for an existing receipt field; tracked bundle included. Missing or mismatched Session identity now fails closed with a retryable error rather than falling back to the previous Session.

@tt-a1i
tt-a1i merged commit 21a21a4 into openpi-dev:main Sep 8, 2026
6 checks passed
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): 空会话切换工作区仅改显示,发送仍命中原仓库

2 participants