Session import · implementation whiteboard
See a session before sharing it.
Browse what was asked, how the conversation evolved, and the last AI reply. Choose the sessions you want, then confirm their import in the terminal.
PR #1307Implemented · review in progressBased on latest main: bc980cfe
What changed
Previously
IDs, dates and message counts. Little evidence for “should I import this?”
→ Built
Request labels + conversation map + source excerpts. A terminal picker and a local browser reader share the same redacted content.
All ready sessions start selected. Deselection applies to this run. “Last AI reply” describes an excerpt; it does not imply completion.
Browser round trip
The browser round trip
ox session import --browseOpen directly in the browserox session import → press bCarry the picker’s current selection over 1 · Open 2 · Read 3 · Return IDs 4 · Confirm 5 · Import YOUR COMPUTER · READ + SELECTBrowser ↔ local ox server127.0.0.1:<random port>Native files → normalize → redact → reader YOUR COMPUTER · UPLOAD GATETerminal confirmationSelected IDs + pinned source snapshotsYou authorize the import here. VERIFIED DESTINATIONExisting import pipelineRecheck → stage → summarize → Ledger uploadOnly confirmed sessions
The CLI launches the reader through cli.OpenInBrowser, serving its bundled page and assets. The per-run token lives in the URL fragment. JavaScript carries it in X-Import-Token on local API calls.
Interactive coworker commands only. JSON, AI coworker, unattended and dry-run paths keep their structural output; --browse --no-input falls back without opening a browser.
The browser asks the local server for evidence. GET /api/sessions supplies the list. Visible labels use GET /api/preview?id=…&excerpt=1; focus uses the full GET /api/preview?id=…. Search reads opening requests with two workers.
The server reads only known native IDs, redacts before returning content, and checks source size/mtime on each request. Conversation context and tool activity are collapsed. Refocusing fetches again; stale responses cannot replace the current view.
“Return selection” posts {"ids":[…]} to POST /api/selection. The handler validates known, eligible, distinct IDs and sends the result through a Go channel to the waiting command. The first callback wins; the server shuts down.
This callback carries selection. It does not summarize or upload. POST /api/cancel cancels the review.
The terminal validates the selected set and source snapshots. A nonempty valid set produces the final upload prompt. Answering n stops. Clearing all or canceling exits before staging or confirmation.
The CLI also replans under the import lock and compares the reviewed snapshots, then preserves the existing just-before-stage checks.
After y, the existing pipeline imports the chosen set. It retains the redacted conversation and available tool activity, and generates a summary after confirmation. Existing deduplication and parallel processing remain in place.
Tilt is the destination for manual testing. The preview server’s random loopback port is independent of Tilt’s edge-router port.
Clear all / cancel / declineExit without staging, summary generation or upload.Source changed during reviewThe stale preview or reviewed selection is refused; restart review.
<!-- ox:details -->See the built browserActual application in Chrome, using test fixtures. Desktop, mobile and dark-mode layouts were exercised.
<!-- /ox:details -->Testing evidence
What was tested
23,130 passed
make test fast suite; 1,694 tests skipped by its defined short tier. Full import regressions and real Claude Code / Codex adapter fixtures also ran separately.
Real terminal + Chrome
Bubble Tea input and handoff; browser selection/search, safe rendering, mobile/dark layouts, source-refocus regression and callback behavior. Race checks passed.
Redaction + boundaries
Preview/import parity, sensitive tool output, invalid policies, source changes, exact Host/token/Origin, known IDs and first-wins callbacks. Lint and build passed.
Native import package coverage: 95.7%. Changed-line coverage: 95.8% (90% required), before the final review refinements. Tilt’s edge-router readiness and anonymous routes were probed; an authenticated end-to-end upload has not been run.
Manual testing
Manual testing against Tilt
Use a disposable repository and a local team. The eight-session Math Blitz fixture isolates testing from your personal native session stores.
cd /Users/lpavel/sageox/sageox-monorepo
make dev-ls
# If absent: make dev-shared-up; make dev; make dev-wait
# Edge router = 3000 + stack offset. The checked stack uses offset 100.
ox_import_stack=http://localhost:3100
ox_import_team='YOUR LOCAL TEAM SLUG'
ox_import_worktree=/Users/lpavel/.codex/worktrees/session-import-preview/ox
cd "$ox_import_worktree"
make build
ox_import_bin="$ox_import_worktree/bin/ox"
ox_import_parent=$(mktemp -d /private/tmp/ox-import-preview.XXXXXX)
ox_import_repo="$ox_import_parent/math-blitz"
python3 "$ox_import_worktree/scripts/session_import_testbed.py" create "$ox_import_repo"
"$ox_import_bin" login --endpoint "$ox_import_stack"
cd "$ox_import_repo"
"$ox_import_bin" init --endpoint "$ox_import_stack" --team "$ox_import_team"
"$ox_import_bin" config set session_recording auto --repo
"$ox_import_bin" sync
"$ox_import_bin" status
"$ox_import_bin" session import --from-test-data .git/ox-test-data --dry-run --json
"$ox_import_bin" session import --from-test-data .git/ox-test-data --preview --session 21bb267b
"$ox_import_bin" session import --from-test-data .git/ox-test-data
"$ox_import_bin" session import --from-test-data .git/ox-test-data --browse
Wait for Ledger provisioning/cloning. Actual import needs an installed, authenticated Claude Code or Codex CLI for summaries; choose --summarizer claude or --summarizer codex if needed. Preview makes no summary calls.
- Deselect a row with Space, then press
b: the selection carries over. - Search, jump among requests and expand retained conversation/tool activity. Hidden rows keep selection.
- Clear all and return: no confirmation. Select one and answer
n: no import. Answery: only that session imports. - Repeat dry-run: the imported session is recognized. Modify a selected fixture’s native file during review: stale content is refused or held.
- Try
--browse --no-inputand an uppercase--preview --session 21BB267Bprefix.
Implementation notes
| Boundary | Implementation |
|---|---|
| Shared content | PreviewEntries shares normalization and strict redaction with WriteRaw, including command-correlated tool output. Preview cache lives in memory, bounded to 32 MiB and two readers. |
| Local reader | Bundled assets, exact Host and constant-time token checks, exact Origin for POST, no-store, restrictive CSP and text insertion. IDs are exposed to the API; no filesystem-path endpoint. |
| Terminal | Adaptive picker, exact selection, source excerpts, eight excerpt-only cached previews and bounded prompt snippets. Full conversation is available in the browser. |
| Callback | The result channel ends the waiting browser runner. Cancel/signal and launch failure shut down the server. Terminal validation and confirmation precede staging. |
| SageOx requests | The CLI uses the existing repo-detail API for destination identity and ledger-status API for the Ledger URL. Browser API requests stay on loopback. Authenticated remote work is handled by the CLI. |
make lint
make test
go test -race ./cmd/ox ./internal/session/nativeimport \
-run 'TestImport|TestPreviewEntries|TestWriteRaw' -count=1
go test -tags browser ./cmd/ox -run '^TestImportBrowser' -count=1
node --check cmd/ox/session_import_browser.js
python3 scripts/session_import_testbed_test.py
Chrome/Chromium is required for browser tests. To capture QA images, append -args -import-browser-screenshots=/private/tmp/ox-import-qa. No new dependency, coverage exception or test-skip directive was added.
Built on codex/session-import-preview in an isolated worktree. The original checkout and its unrelated changes were preserved. PR remains unmerged.

