Repository navigation
Description
What I observed
Orchestrator.dispatchThreadMergeBack (apps/server/src/orchestration-v2/Orchestrator.ts:6119-6170) validates lineage, active/queued runs on the target, and fork-transfer presence, but never checks targetProjection.thread.deletedAt !== null, targetProjection.thread.archivedAt !== null, or sourceProjection.thread.deletedAt !== null. (By contrast, dispatchThreadFork right above it explicitly rejects sourceProjection.thread.deletedAt !== null.)
On the client side, resolveMergeBackTargetThreadId (packages/client-runtime/src/state/threadRelationships.ts:37-44) only checks forkedFrom.threadId / lineage.parentThreadId on the fork itself. Because deleting or archiving a parent thread only cascades to side chats (not full forks), the Merge back to source conversation action remains enabled in the fork on web, desktop, and mobile. Clicking it commits a stranded pending merge_back context transfer onto the dead/archived parent, returns Success with no error, and navigates the user straight into the deleted or archived parent thread.
Reproduction
- Commit:
main @ 9d3054a7bb - Environment: macOS 27.2.1, Node v26.13.1
UI steps (single user, single device, no race):
- Create a thread and complete at least one turn.
- Fork the thread (full fork) and complete a turn in the fork.
- Archive or delete the parent thread.
- Open the fork, open the Lineage panel, and click Merge back to source conversation (also reachable on mobile via
ThreadRouteScreen.tsxand via MCPt3_thread_transfer({ action: "merge_back" })).
Programmatic server repro (ThreadManagementService + OrchestratorV2):
- Create
parentId, finish Turn 1, dispatchthread.fork(parentId -> forkId), finish Turn 1 inforkId. - Dispatch
thread.archiveonparentId, then dispatchthread.merge_back(forkId -> parentId). - Dispatch
thread.deleteonparentId, then dispatchthread.merge_back(forkId -> parentId).
Expected behavior
dispatchThreadMergeBack rejects thread.merge_back with OrchestratorDispatchError (emitting 0 events) when the target thread is deleted or archived, or when the source thread is deleted (and clients should disable/hide merge-back when the target thread is no longer active).
Actual behavior
thread.merge_back succeeds against both archived and deleted parent threads, appends a pending context-transfer.created event onto the dead/archived parent, shows no error toast, and navigates the client into the deleted/archived parent (redirecting to home on web or landing on a missing thread on mobile).
Evidence
Observed output from the deterministic Effect/SQLite server repro:
REPRO 4: {"mergeIntoArchived":"Success","mergeIntoDeleted":"Success","parentDeleted":true,"pendingMergeBacks":1}
Additional investigation
- How found: Stateful property-based testing of
OrchestratorV2, minimized to a deterministic non-PBT Vitest/Effect repro. - Verified: Confirmed on
origin/main(9d3054a7bb) thatdispatchThreadMergeBackstill has nodeletedAtorarchivedAtchecks. - Duplicate check: Searched open and closed issues/PRs for
merge_back deletedandmerge back archived— no matching issue found. - Impact: Minor/moderate — silently creates a stranded transfer on a deleted/archived thread and navigates the user out of their fork with no error message.
Activity