551
*/
552
private async _resolveWorkingDirectoryBeforeSend(params: { session: string; chat: string; turnId: string; prompt: string }): Promise<URI | undefined> {
554
>
const pickedFolder = this._configurationService.getEffectiveWorkingDirectory(params.session);
555
>
const pickedFolderUri = pickedFolder ? URI.parse(pickedFolder) : undefined;
556
>
557
>
// Only worktree-isolation sessions defer directory resolution to the first
558
>
// send (so the prompt can name the branch); folder / workspace-less
559
>
// sessions run directly in the picked folder.
560
>
if (!this._worktree?.isWorkingDirectoryPending(sessionId)) {
561
>
return pickedFolderUri
562
? this._configurationService.resolveWorkingDirectoryForResume(params.session, pickedFolderUri)
564
>
}
565
566
// Fall back to the picked folder when worktree creation failed so the
567
// session still materializes in the user's folder rather than nowhere.
568
return await this._resolveWorktreeBeforeSend({ ...params, sessionId, pickedFolderUri }) ?? pickedFolderUri;
570
571
private async _resolveChatAttachmentTurns(resource: string): Promise<readonly Turn[]> {