# feat\(server\): t3_thread_import, conversation only · PR \#16731 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/16731)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: open

Source repository: pingdotgg/t3code

Source branch: t3code/peer/thread-import

Target branch: t3code/peer/environment-chips

Head commit: 48dea790a657af09a50d188a5092ada32bab8542

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/16731)

[Commits](https://git.cafe/pingdotgg/t3code/pull/16731/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/16731/diffs?format=markdown)

## Description

---

Conversation import is the receiving half of a cross-environment handoff: persist user/assistant history, then optionally continue it through the existing provider-neutral text handoff. This layer transfers no code, files or checkout.

### Maintainer takeover: blocked on peer-stack integration (2026-10-19)

The reviewed rebuild is **unpublished**. This PR currently points to [2d266475ee](https://github.com/pingdotgg/t3code/commit/2d266475eebb6602d929cef97efb18b33f7fffa2), based on `t3code/peer/environment-chips` at [2b63f76e22](https://github.com/pingdotgg/t3code/commit/2b63f76e22ec6a4961f12896e663dd74a0c3c564). Current public checks cover that older author layer. No code was pushed or merged.

Local rebuild `923c8c2147eef331ba9b328fbc108f429ab64424` is preserved on `takeover-local/terminal-preview-22-16731-integrated` and as a [complete patch against the actual peer parent](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/6a080ac0a92fa123/16731-full.patch). Credit to @juliusmarminge for the original [#16731](https://github.com/pingdotgg/t3code/pull/16731). The external peer-stack refresh was retained; only the three maintainer commits were added atop it.

The service validates dates, project and new-import worktree membership before writing. History remains runless and marked imported; original message timestamps are retained while thread activity uses import time. Replay checks project/link ownership, returns the original continuation run after later turns, and cannot add work from changed input. Raced writes return `created:false` and cannot dispatch a losing continuation. The MCP handler calls the service and maps typed errors; existing creation mode ceilings and link stamping remain.

Verification at the local rebuild:

- Original import suite: one polling mega-test → **six focused cases**, using persisted milestones and Deferred signals. Four defect groups reproduced against original production, plus three meaningful history/identity mutation checks. Context and legacy tests were retained.
- Seven focused suites: **27/27 pass**; current-parent creation policy selection: **12 pass**. [Exact-head integrated test output](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/793bc25220c44f4e/16731-round1-focused.log).
- Scoped server/contracts types, all 16 layer files' lint/format, and whitespace checks pass.
- Two independent whole-layer review rounds, GPT-6 Sol and Claude Opus 5.5; final pair clear. Fixed first-round activity timestamps and unavailable locked-worktree handling with fail-before assertions in existing tests.
- Real SQLite/orchestrator plus a capturing provider adapter prove persisted history, text-context delivery, replay and interruption behavior. **No live two-environment, real provider CLI, relay or tunnel run is claimed.** The older real-server comment is not proof of this rebuild.

Accepted limits:

- If the creator is interrupted after history commits but before continuation commits, retry returns `created:false, runId:null` and cannot add work. An explicit ordinary thread message can continue it.
- Retrying the same handoff after the destination thread was deleted safely rejects with a generic typed write failure. It does not resurrect the thread; a new import needs a new handoff ID.
- IDs now use a JSON tuple and full SHA-256 digest; there is no migration for unpublished PoC import IDs.
- Per-message/count bounds remain; no aggregate import memory cap or full-history provider-context guarantee is claimed. Existing handoff summarization/truncation applies.

Required human/integration steps before publication:

1. Approve integration with the peer stack and refresh/register its actual chain using gh stack. Keep the import layer on the current environment-chips parent. Do not flatten prerequisite or upper handoff concerns into this PR.
2. Integrate the upper `handoff-git`, `handoff` and `handoff-ui` layers, which reviewers found still based on the older import chain. Prepared-workspace undo must run after raced-write recovery as well as write failure. When continuation was requested, `created:false, runId:null` must surface as needing attention instead of a completed move. Those neighboring layers were not edited in this batch.
3. Run two isolated environments from the final integrated revisions. Import identifiable user/assistant history, verify it appears once, and verify a real provider continuation receives it. Exercise runless import followed by an explicit turn, exact/changed retry, later-turn retry, different handoff, cross-project/link rejection, malformed date and removed/foreign/unavailable worktrees.
4. Interrupt between history commit and continuation; verify replay remains idle and the upper handoff reports attention. Exercise raced imports and prepared-checkout cleanup, plus destination deletion/retry. Verify no code/files are transferred by this conversation-only layer.
5. Repeat relevant receiving/continuation paths over local, remote/relay and tunnel connections with current link access/mode ceilings. Record current-head output; if UI claims are made, capture actual before/after client evidence.
6. After integration/proof/approval, non-force-push the maintainer commits to `pingdotgg/t3code:t3code/peer/thread-import`, update the body to the published SHA, and refresh CI and reviews. No merge is authorized in this batch.

No native macOS, Windows, iOS, Android or Electron client was exercised; no web/mobile UI or live provider execution was verified. This receiving layer has no new client UI entry point.

Models/harnesses: GPT-6 Astra tests; GPT-6.1 Sol implementation/coordination; GPT-6 Sol and Claude Opus 5.5 reviews, through Codex/Claude in T3 Code.

