fix(sessions): accept in-flight draft rewrite to the fallback directory

Create no longer aborts when recoverStaleDraftDirectory rewrites the
implicit new-chat draft to the active project during the create probe.
Also rank the Unreleased Chat bullet below the changelog highlights.

Co-authored-by: serkraser <serkraser@gmail.com>
This commit is contained in:
Cursor Agent
2026-08-15 06:33:28 +00:00
co-authored by serkraser
parent a500a5d4e9
commit d817c44c46
4 changed files with 47 additions and 3 deletions
+14 -1
View File
@@ -619,6 +619,8 @@ const resolveActiveProjectDirectory = (draft: NewSessionDraftState): string | nu
* path is confirmed missing (deleted worktree), fall back to the active project.
* Explicit worktree targets, in-flight worktree creation, and unknown/offline
* probes stay unchanged so a temporary outage cannot rewrite the destination.
* A concurrent rewrite of the same implicit draft to that fallback is accepted
* instead of aborting create.
*/
const resolveCreatableDraftDirectory = async (
draft: NewSessionDraftState,
@@ -645,15 +647,26 @@ const resolveCreatableDraftDirectory = async (
const draftDirectory = draft.directoryOverride
const availability = await opencodeClient.getDirectoryAvailability(directory)
const currentDraft = useSessionUIStore.getState().newSessionDraft
const currentDirectory = normalizePath(currentDraft.directoryOverride)
const capturedDirectory = normalizePath(draftDirectory)
// openNewSessionDraft may rewrite the same implicit draft to this fallback
// while createSession's probe is still in flight. That is the intended
// destination, not a user change, so do not abort the create.
const recoveredToActiveProject = currentDirectory === activeProjectDirectory
&& capturedDirectory !== activeProjectDirectory
const draftChanged = !currentDraft.open
|| currentDraft.preserveDirectoryOverride !== draft.preserveDirectoryOverride
|| currentDraft.pendingWorktreeRequestId !== draft.pendingWorktreeRequestId
|| normalizePath(currentDraft.directoryOverride) !== normalizePath(draftDirectory)
|| (currentDirectory !== capturedDirectory && !recoveredToActiveProject)
if (getRuntimeKey() !== runtimeKey || draftChanged) {
return { status: "aborted" }
}
if (recoveredToActiveProject) {
return { status: "ok", directory: activeProjectDirectory }
}
return {
status: "ok",
directory: availability === "missing" ? activeProjectDirectory : directory,