Skip to content

feat: prepare retained exited-session context in another workspace root - #96

Merged
johnnyhuy merged 1 commit into
mainfrom
agent/issue-94-exited-handoff
Nov 30, 2026
Merged

johnnyhuy merged 1 commit into
mainfrom
agent/issue-94-exited-handoff

Conversation

@johnnyhuy

@johnnyhuy johnnyhuy commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What changed

An exited tab now offers Continue in another root, the same explicit draft preparation that saved history already had. The retained transcript is prepared as a new-session draft in another registered root, with no archive present, no Pi launched and no prompt sent. Existing destination text is kept and the source's unsent draft stays in its own tab.

Part of #4. Closes #94.

Scope

  • prepareHandoff now accepts an exited session as its source, reusing the destination form and the retained snapshot Markdown.
  • The handoff identifies itself as a potentially incomplete window snapshot, with no resumable selection claim.
  • Preparation is refused for a busy workbench, an unavailable or same root, a root with the same folder, a live session or an empty transcript.
  • The exit recovery area is bounded at short window heights so the transcript stays readable while the form is open.
  • openSession is exposed on the workbench hook so the empty-transcript guard is directly testable.

How it was verified

bun install --frozen-lockfile     477 packages installed
bun run lint                       clean
bun run typecheck                  clean (tsconfig.json, tsconfig.main.json, tsconfig.preload.json)
mise run bundle                    built in 2.69s
bun run test:unit                  113 passed overall
bun run test:integration           128 passed overall
bun run test:e2e                   9 files, 78 tests passed

The Playwright e2e run reached every assertion in this slice, including the new Electron case.

New tests

  • tests/integration/useWorkbench.test.tsx
    • prepares an exited snapshot without an archive and preserves both roots drafts
    • rejects unavailable or same-root exited handoffs and live or empty transcripts
  • tests/integration/ExitedSessionExport.test.tsx
    • copies context without an archive path and keeps the unsent draft separate (extended with the handoff flow)
  • tests/e2e/session-activity.test.ts
    • prepares an exited snapshot in another root without launching Pi, even with a missing archive

Proof

The Electron test drives the real app: it removes the exact exited archive so no saved history is present, opens the handoff form on the exited tab, prepares the draft in another root and returns to the source tab. It checks the prepared text, the preserved destination and source drafts, the absence of any new session RPC and the absence of the archive file.

Captured and visually inspected:

  • .tmp/proof/exited-session-handoff.png (1280 x 840). The exit recovery form is open on an exited tab with no archive present. The form says the window snapshot may be incomplete, and the destination root is offered in the select.
  • .tmp/proof/exited-session-handoff-minimum.png (900 x 600). The recovery area scrolls inside its own bound and the transcript keeps 84 pixels of height rather than collapsing to 4.
  • .tmp/proof/exited-session-prepared-draft.png (1280 x 840). The destination root's composer holds the existing task, a separator and the retained transcript. Pi has not started, so the status reads PI READY.

The same captures are uploaded by the Electron CI run in the pidex-e2e artefact, from test-results/session-activity/. Run: https://github.com/echohello-dev/pidex/actions/runs/46330435916

What the reviewer should know

  • Two gates fail on origin/main as well and are unrelated to this slice. tests/integration/SettingsView.test.tsx has six failures because localStorage is undefined in the test environment. tests/unit/workbench.test.ts has git-timeout flakes on a 5 second limit under machine load. Both were reproduced on a clean checkout, where the unit file failed more often than it does here.
  • The short-window media query for .wb-conversation mirrors the existing .wb-history-conversation rules. Without it the exit recovery form squeezed the transcript to 4 pixels at 900 by 600.
  • The e2e capture needed ELECTRON_RUN_AS_NODE unset, because the harness environment sets it and it makes Electron run as plain Node.
  • The next slice under Improve workspace migration and export resume recovery flow #4 could cover a tab that exited before any transcript was retained, where the snapshot would carry no messages.

Exited tabs can copy and export their retained transcript, but Continue in
another root needed saved history. Offer the same explicit draft
preparation directly from an exited tab, even when no archive exists.

Reuse the existing destination form and the retained snapshot Markdown.
Keep existing destination text and the source's unsent draft separate.
Identify the handoff as a potentially incomplete window snapshot with no
resumable selection claim. Prepare only in an available, different
registered root, without opening Pi, sending prompts or reading an
archive.

Bound the exit recovery area at short window heights so the transcript
stays readable while the form is open.

Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
@johnnyhuy
johnnyhuy merged commit 30177c7 into main Nov 30, 2026
15 checks passed
@johnnyhuy
johnnyhuy deleted the agent/issue-94-exited-handoff branch November 30, 2026 00:46
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.

Prepare retained exited-session context in another workspace root

1 participant