import{ci as e,qn as t}from"./src-BOCweS1p.js";import{fs as n}from"./app-server-manager-signals-Yn0WSnoY.js";import{g as r,n as i}from"./vscode-api-DjORcpSo.js";import{t as a}from"./build-start-conversation-params-D8zijBOw.js";import{y as o}from"./browser-sidebar-open-source-_kvO2A9r.js";import{n as s}from"./set-pinned-thread-uATOh9_i.js";async function c({entry:e,workspaceRoot:t}){if(e.launchMode===`fork-conversation`)return e.targetTurnId==null?n(`fork-conversation-from-latest`,{hostId:e.hostId,conversationId:e.sourceConversationId,cwd:t,workspaceRoots:[t],collaborationMode:e.sourceCollaborationMode}):n(`fork-conversation-from-turn`,{conversationId:e.sourceConversationId,targetTurnId:e.targetTurnId,cwd:t,workspaceRoots:[t],collaborationMode:e.sourceCollaborationMode});if(e.launchMode!==`start-conversation`)throw Error(`Unsupported launch mode: ${e.launchMode}`);return n(`start-conversation`,{hostId:e.hostId,...a({...e.startConversationParamsInput,workspaceRoots:[t],cwd:t}),skipAutoTitleGeneration:e.initialThreadTitle!=null})}async function l({entry:e,conversationId:a,hostConfig:o}){if(e.worktreeGitRoot!=null)try{await i(`worktree-set-owner-thread`,{params:{hostId:o.id,worktree:t(e.worktreeGitRoot),conversationId:a}})}catch(e){r.warning(`Worktree created and conversation started, but failed to set worktree owner metadata: {}`,{safe:{},sensitive:{error:e}})}if(e.isPinned)try{await s(a,!0,e.pinnedBeforeThreadId)}catch(e){r.warning(`Worktree conversation started, but failed to set pinned metadata: {}`,{safe:{},sensitive:{error:e}})}e.launchMode===`start-conversation`&&e.threadGoalObjective!=null&&await n(`set-thread-goal`,{appendTranscriptItem:!1,conversationId:a,hostId:o.id,objective:e.threadGoalObjective});let c=(e.initialThreadTitle??(e.labelEdited?e.label:``)).trim();c.length!==0&&await n(`set-thread-title`,{conversationId:a,title:c})}function u(t,n){let r=t.browserTransferSourceConversationId;if(r==null)return;let i=t.browserTransferSourceBrowserTabIds,a=i!=null&&i.length>0,s=e(`${r}:legacy`),c=i!=null&&i.length>0?i:[t.browserTransferSourceBrowserTabId??s],l=t.browserTransferSourceBrowserTabId!=null&&c.includes(t.browserTransferSourceBrowserTabId)?t.browserTransferSourceBrowserTabId:c.at(-1);for(let i of c)o(n,{active:i===l,browserTabId:a||t.browserTransferSourceBrowserTabId!=null?i:e(`${n}:legacy`),transferSourceBrowserTabId:i,transferSourceConversationId:r})}export{c as n,u as r,l as t};
//# sourceMappingURL=pending-worktree-conversation-BLx_eb7U.js.map