vibe64 0.1.62 → 0.1.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/bin/upgrade-state.js +1701 -1700
  2. package/dist/assets/{GithubBrowserTabs-BJ2NXiuQ.js → GithubBrowserTabs-DEq5_tSs.js} +1 -1
  3. package/dist/assets/{LocalDatabaseServer-Z5VQcWgu.js → LocalDatabaseServer-CrQ9aolO.js} +1 -1
  4. package/dist/assets/{Vibe64AuthSettingsButton-B4FbKoV7.js → Vibe64AuthSettingsButton-Bbgu_IRu.js} +1 -1
  5. package/dist/assets/{Vibe64ConversationLog-Dk2jeU21.js → Vibe64ConversationLog-MGFaNVSu.js} +1 -1
  6. package/dist/assets/{Vibe64DashboardShell-BGE8m2VG.js → Vibe64DashboardShell-i01oU7QS.js} +1 -1
  7. package/dist/assets/{Vibe64DatabaseWorkspace-BrB-0zdd.js → Vibe64DatabaseWorkspace-BqOIE7at.js} +1 -1
  8. package/dist/assets/{Vibe64OutputControls-JHBVJBQ4.js → Vibe64OutputControls-eaoCQsYn.js} +1 -1
  9. package/dist/assets/{Vibe64RepositoryWorkspace-DFuF1aDy.js → Vibe64RepositoryWorkspace-CoSH_5qZ.js} +1 -1
  10. package/dist/assets/{Vibe64SessionFiles-Ih3aXiKq.js → Vibe64SessionFiles-Dt1EY-Qo.js} +1 -1
  11. package/dist/assets/{Vibe64SessionSourceEditor-EUExI1YB.js → Vibe64SessionSourceEditor-D5-abooo.js} +1 -1
  12. package/dist/assets/{Vibe64UiStoryboardView-DrE3Dqjr.js → Vibe64UiStoryboardView-CyuufVBB.js} +1 -1
  13. package/dist/assets/{Vibe64UnavailableSessions-CCWWp2-Y.js → Vibe64UnavailableSessions-CaLRMl-0.js} +1 -1
  14. package/dist/assets/{_pageId_-JF3VAGm5.js → _pageId_-M5CNslNQ.js} +1 -1
  15. package/dist/assets/{_sessionId_-DzhYkoTF.js → _sessionId_-jSlkZQLV.js} +1 -1
  16. package/dist/assets/{_slug_-CK9TQknP.js → _slug_-ClQKNEA9.js} +5 -5
  17. package/dist/assets/{access-BOqP7tK6.js → access-BqnqYSZR.js} +1 -1
  18. package/dist/assets/{app-C9NRUu1x.js → app-D7V6OMMB.js} +1 -1
  19. package/dist/assets/{changes-Df2TTLEm.js → changes-odK1bV6J.js} +1 -1
  20. package/dist/assets/{client-DdNHOrl8.js → client-BLY6SeL-.js} +1 -1
  21. package/dist/assets/{client-BzNAjCJm.js → client-DwF9Q0VQ.js} +2 -2
  22. package/dist/assets/{client-CiGvH-QO.js → client-P5LOKvwh.js} +2 -2
  23. package/dist/assets/{client-Bkk7jZD9.js → client-rknXpZ1o.js} +1 -1
  24. package/dist/assets/{conversation-ZN3-8jbz.css → conversation-BMyk8R_u.css} +1 -1
  25. package/dist/assets/{conversation-wiDH8Ni4.js → conversation-BoB7Drme.js} +2 -2
  26. package/dist/assets/{dashboard-Dt57zpvc.js → dashboard-D6JkBdZg.js} +1 -1
  27. package/dist/assets/{english-definitions-C0n2xolE.js → english-definitions-CwCZ8VJ-.js} +1 -1
  28. package/dist/assets/{env-CIJebqCq.js → env-CIy7uwLb.js} +1 -1
  29. package/dist/assets/{history-DqtrCyKI.js → history-IBqZqdSL.js} +1 -1
  30. package/dist/assets/{index-tPEeYKmw.js → index-DAareKn3.js} +4 -4
  31. package/dist/assets/{integrations-BST4Qw-s.js → integrations-BBMdyyMq.js} +1 -1
  32. package/dist/assets/{issues-CN8brLcd.js → issues-DwUO1HjX.js} +1 -1
  33. package/dist/assets/{learning-B8e42exz.js → learning-DAIqaO0B.js} +1 -1
  34. package/dist/assets/{pages-DWmGyVcJ.js → pages-DoUMcieZ.js} +1 -1
  35. package/dist/assets/{project-files-CiFrH7b9.js → project-files-DilujZdI.js} +1 -1
  36. package/dist/assets/{publish-D1Cm9dcY.js → publish-KZQ_gdoN.js} +1 -1
  37. package/dist/assets/{pull-requests-ujRUy7Rf.js → pull-requests-BB3CAadu.js} +1 -1
  38. package/dist/assets/{repository-v-kDk9e_.js → repository-B90tiuN6.js} +1 -1
  39. package/dist/assets/{settings-CMMTWcem.js → settings-DdbhtNHb.js} +1 -1
  40. package/dist/assets/{useArchivedVibe64Sessions-C3w4gzum.js → useArchivedVibe64Sessions-B_pM75gN.js} +1 -1
  41. package/dist/assets/{useVibe64ConversationLog-BfW5VQBw.js → useVibe64ConversationLog-Ch0ZbnCG.js} +2 -2
  42. package/dist/assets/{useVibe64SessionData-BZUDqDiW.js → useVibe64SessionData-COsXmbMm.js} +1 -1
  43. package/dist/assets/{useVibe64SessionSelection-ChkFsI6Y.js → useVibe64SessionSelection-CKBC-ZJw.js} +1 -1
  44. package/dist/assets/{vibe64RepositoryRealtime-BamEfp1M.js → vibe64RepositoryRealtime-BIXVm4u9.js} +1 -1
  45. package/dist/assets/{vibe64SessionFocus-CfH5XqgI.js → vibe64SessionFocus-C0LfHXbF.js} +1 -1
  46. package/dist/index.html +4 -4
  47. package/docs/colleague-usage/coding-agent-goals.md +16 -2
  48. package/node_modules/@jskit-ai/assistant-core/CHANGELOG.md +2 -0
  49. package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
  50. package/node_modules/@jskit-ai/assistant-runtime/CHANGELOG.md +1 -0
  51. package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
  52. package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
  53. package/node_modules/@jskit-ai/realtime/package.json +1 -1
  54. package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +75 -75
  55. package/package.json +5 -5
  56. package/server.bundle.mjs +18737 -18727
@@ -1 +1 @@
1
- import{Et as unref,ht as proxyRefs,it as watch,mt as onScopeDispose,u as computed,vt as ref}from"./runtime-core.esm-bundler-Bi1P1jMa.js";import{N as useQueryClient,t as useEndpointResource}from"./useEndpointResource-CmMwteuX.js";import{_ as useRouter,g as useRoute}from"./useApi-BPuI6ZR9-rsYWyW6m.js";import{s as normalizeObject}from"./normalize-BD25VwNK.js";import{o as projectSlugFromRoute}from"./vibe64ProjectScope.local-B9ZpdYlf.js";import{o as ROUTE_VISIBILITY_PUBLIC}from"./visibility-Cq31Xy7I.js";import{r as useRealtimeEvent}from"./useRealtimeEvent-B4oRg9Dt.js";import{t as useCommand}from"./useCommand-CNDe8gM-.js";import{t as usePaths}from"./usePaths-CvUbx5-V.js";import{t as useUiFeedback}from"./useUiFeedback-CWb6o71Z.js";import{t as readRefOrGetterValue}from"./vueRefOrGetterValue-y-4f_In7.js";import{r as vibe64RealtimeOriginPayload}from"./vibe64BrowserTabOrigin-vIN_87mi.js";import{H as vibe64SessionsQueryKey,I as vibe64SessionEventMatchesScope,L as vibe64SessionPath,V as vibe64SessionQueryKey,a as VIBE64_CURRENT_SESSION_API_SUFFIX,c as VIBE64_SESSION_SUMMARY_CHANGED_EVENT,o as VIBE64_SESSIONS_API_SUFFIX}from"./vibe64SessionRequestConfig-DVRCRAex.js";import{S as VIBE64_PROJECT_CHANGED_EVENT}from"./studioGateApi-UqmdV50W.js";import{N as useVibe64ProjectSlug}from"./index-tPEeYKmw.js";import{i as vibe64SessionDisplayTitle,o as vibe64SessionRevision,r as shortVibe64SessionId,t as isArchivedVibe64Session}from"./vibe64SessionViewModel-CQCds_jb.js";import{i as vibe64SessionDebugSummary,n as vibe64SessionDebugError,r as vibe64SessionDebugLog,t as vibe64SessionDebugDurationMs}from"./vibe64SessionDebugLog-BfO7tG1A.js";import{i as visibleVibe64Sessions,n as enrichVibe64SessionForDisplay}from"./vibe64SessionPanelModel-B-WkXnPu.js";import{n as useVibe64SessionSelection,t as selectedSessionIdFromRoute}from"./useVibe64SessionSelection-ChkFsI6Y.js";function refetchEndpointResource(resource){return resource.query.refetch({cancelRefetch:false})}function sessionChangedReason(payload){return String(payload.reason||``).trim()}function sessionRevision(value){const revision=Number(value);return Number.isSafeInteger(revision)&&revision>=0?revision:null}function agentTurnRealtimeOverlayFromPayload(input,selectedSessionId=``){const payload=normalizeObject(input);const changedSessionId=String(payload.sessionId||payload.entityId||``).trim();if(!changedSessionId||changedSessionId!==String(selectedSessionId||``).trim())return null;const agentSession=normalizeObject(payload.agentSession);const turn=normalizeObject(agentSession.turn);const run=normalizeObject(payload.agentRun);const revision=sessionRevision(payload.revision);if(revision===null||!Object.keys(turn).length&&!Object.keys(run).length)return null;const active=turn.active===true||run.active===true;return{active,agentRun:{...run,active},agentSession:{...agentSession,turn:{...turn,active}},reason:sessionChangedReason(payload),revision,sessionId:changedSessionId}}function latestAgentTurnRealtimeOverlay(current=null,candidate=null){if(!candidate)return current;if(!current||candidate.revision>current.revision)return candidate;return current}function mergeAgentRunOverlay(agentRuns=[],overlayRun={}){const runs=Array.isArray(agentRuns)?agentRuns:[];const runId=String(overlayRun.id||``).trim();if(!runId)return runs;const nextRun={...overlayRun,id:runId};const index=runs.findIndex(run=>String(run?.id||``).trim()===runId);if(index<0)return[...runs,nextRun];return runs.map((run,runIndex)=>runIndex===index?{...run,...nextRun}:run)}function sessionWithAgentTurnRealtimeOverlay(session=null,overlay=null){const currentRevision=sessionRevision(session?.revision);if(!session||!overlay||session?.ok===false||session.sessionId!==overlay.sessionId||currentRevision!==null&&overlay.revision<=currentRevision)return session;const overlayAgentSession=normalizeObject(overlay.agentSession);return{...session,agentRuns:mergeAgentRunOverlay(session.agentRuns,normalizeObject(overlay.agentRun)),agentSession:{...normalizeObject(session.agentSession),...overlayAgentSession,thread:{...normalizeObject(session.agentSession?.thread),...normalizeObject(overlayAgentSession.thread)},turn:{...normalizeObject(session.agentSession?.turn),...normalizeObject(overlayAgentSession.turn),active:overlay.active===true}},revision:overlay.revision}}function sessionRecordHasDetailProjection(session=null){return Boolean(session&&typeof session===`object`&&Object.hasOwn(session,`agentSession`))}function sessionRecordHasActiveAgentWork(session=null){return(session?.agentSession?.turn?.active??session?.agentActivity?.active)===true}function sessionRecordMatchesId(session=null,sessionId=``){const normalizedSessionId=String(sessionId||``).trim();return Boolean(normalizedSessionId&&session?.sessionId===normalizedSessionId&&session?.ok!==false)}function latestSessionDetailRecord(current=null,candidate=null,sessionId=``){if(!sessionRecordMatchesId(candidate,sessionId))return current;if(!sessionRecordMatchesId(current,sessionId))return candidate;const currentRevision=vibe64SessionRevision(current);const candidateRevision=vibe64SessionRevision(candidate);if(currentRevision!==null&&candidateRevision!==null&&candidateRevision<currentRevision)return current;return candidate}function mountedSessionRecord(detailSession=null,listSession=null,sessionId=``){const normalizedSessionId=String(sessionId||``).trim();const listSessionMatches=sessionRecordMatchesId(listSession,normalizedSessionId);if(!sessionRecordMatchesId(detailSession,normalizedSessionId))return listSessionMatches?listSession:null;const detailRevision=vibe64SessionRevision(detailSession);const listRevision=vibe64SessionRevision(listSession);if(listSessionMatches&&listRevision!==null&&detailRevision!==null&&listRevision>detailRevision){if(sessionRecordHasDetailProjection(detailSession)&&!sessionRecordHasDetailProjection(listSession))return detailSession;return listSession}return detailSession}function mountedSessionDetailRefreshReason(detailSession=null,listSession=null,sessionId=``){const normalizedSessionId=String(sessionId||``).trim();if(!sessionRecordMatchesId(detailSession,normalizedSessionId)||!sessionRecordMatchesId(listSession,normalizedSessionId))return``;const detailRevision=vibe64SessionRevision(detailSession);const listRevision=vibe64SessionRevision(listSession);if(listRevision!==null&&detailRevision!==null&&listRevision>detailRevision&&sessionRecordHasDetailProjection(detailSession)&&!sessionRecordHasDetailProjection(listSession))return`newer_summary_without_detail`;return``}function mountedSessionDetailLoadState({detailSession=null,fetching=false,listSession=null,loadError=``,loading=false,sessionId=``}={}){const normalizedSessionId=String(sessionId||``).trim();const hasDetail=sessionRecordMatchesId(detailSession,normalizedSessionId);const hasSummary=sessionRecordMatchesId(listSession,normalizedSessionId);const error=String(loadError||``).trim();if(!normalizedSessionId)return{error:``,label:``,loading:false,ready:false,restoring:false,sessionId:``,state:`summaryOnly`};if(error&&!hasDetail)return{error,label:`Session could not load.`,loading:false,ready:false,restoring:false,sessionId:normalizedSessionId,state:`detailError`};if(hasDetail)return{error:``,label:``,loading:false,ready:true,refreshing:Boolean(fetching||loading),restoring:false,sessionId:normalizedSessionId,state:`detailReady`};if(loading||fetching)return{error:``,label:`Loading session...`,loading:true,ready:false,restoring:false,sessionId:normalizedSessionId,state:`detailLoading`};return{error:``,label:hasSummary?`Session could not load.`:`Loading session...`,loading:false,ready:false,restoring:false,sessionId:normalizedSessionId,state:`summaryOnly`}}function mountedSessionRealtimeShouldRefresh({payload={}}={},sessionId=``,read=`includeDetail`){const changedSessionId=String(payload.sessionId||payload.entityId||``).trim();if(!changedSessionId||changedSessionId!==String(sessionId||``).trim())return false;return payload.clientRefresh?.[read]!==false}function useVibe64SessionDialogs({beginArchive,finishArchive,isSelectedSessionArchived,refreshSessionData,selectedSessionId,selectedSessionTitle,sessionsApiPath}){const archiveDialogOpen=ref(false);const archiveDialogSessionId=ref(``);const archiveDialogSessionTitle=ref(``);const archivingSessionId=ref(``);const resolvedSessionsApiPath=computed(()=>String(readRefOrGetterValue(sessionsApiPath)||``));const archiveCommand=useCommand({access:`never`,apiSuffix:VIBE64_SESSIONS_API_SUFFIX,buildRawPayload:()=>vibe64RealtimeOriginPayload(),buildCommandOptions:(_payload,{context})=>({method:`POST`,path:vibe64SessionPath(resolvedSessionsApiPath.value,context?.sessionId,`/archive`)}),fallbackRunError:`Vibe64 session could not be archived.`,messages:{error:`Vibe64 session could not be archived.`,success:`Vibe64 session archived.`},onRunSuccess:async response=>{if(response?.ok!==true)throw new Error(response?.errors?.[0]?.message||response?.error||`Vibe64 session could not be archived.`)},ownershipFilter:ROUTE_VISIBILITY_PUBLIC,placementSource:`vibe64.sessions.archive`,surfaceId:`app`,writeMethod:`POST`});function clearArchiveDialog(){archiveDialogOpen.value=false;archiveDialogSessionId.value=``;archiveDialogSessionTitle.value=``}function requestArchiveSelectedSession(){if(!unref(selectedSessionId)||archivingSessionId.value||archiveCommand.isRunning||unref(isSelectedSessionArchived))return;archiveDialogSessionId.value=unref(selectedSessionId);archiveDialogSessionTitle.value=unref(selectedSessionTitle);archiveDialogOpen.value=true}function cancelArchiveSession(){if(!archiveCommand.isRunning)clearArchiveDialog()}async function confirmArchiveSession(){if(!archiveDialogSessionId.value||archivingSessionId.value||archiveCommand.isRunning)return false;const sessionId=archiveDialogSessionId.value;archivingSessionId.value=sessionId;clearArchiveDialog();const archiveScope=beginArchive(sessionId);let succeeded=false;try{const response=await archiveCommand.run({sessionId});succeeded=response?.ok===true;return response}catch{return false}finally{finishArchive(sessionId,succeeded,archiveScope);if(archivingSessionId.value===sessionId)archivingSessionId.value=``;refreshSessionData({reason:`archive-session`}).catch(()=>null)}}return{archiving:computed(()=>Boolean(archivingSessionId.value)),archivingSessionId,cancel:cancelArchiveSession,command:archiveCommand,confirm:confirmArchiveSession,open:archiveDialogOpen,request:requestArchiveSelectedSession,sessionId:archiveDialogSessionId,sessionTitle:archiveDialogSessionTitle}}function useVibe64SessionCreation({projectSlug,refreshSessionDataInBackground,selectSessionId,sessionListQueryKey,sessionsApiPath}){const queryClient=useQueryClient();const createSessionCommand=useCommand({access:`never`,apiSuffix:VIBE64_SESSIONS_API_SUFFIX,buildCommandOptions:(_model,{context})=>({method:`POST`,path:context?.apiPath}),buildRawPayload:(_model,{context})=>vibe64RealtimeOriginPayload({assistantSelection:context?.assistantSelection||{},...context?.repositoryBranch?{repositoryBranch:context.repositoryBranch}:{},...context?.pullRequestNumber?{pullRequestNumber:context.pullRequestNumber}:{}}),fallbackRunError:`Vibe64 session could not be created.`,messages:{error:`Vibe64 session could not be created.`,success:`Vibe64 session created.`},ownershipFilter:ROUTE_VISIBILITY_PUBLIC,placementSource:`vibe64.sessions.create`,surfaceId:`app`,writeMethod:`POST`});const createSessionRunning=ref(false);let createSessionInFlight=null;let disposed=false;onScopeDispose(()=>{disposed=true});async function createSession(assistantSelection={},{pullRequestNumber,repositoryBranch}={}){if(createSessionInFlight)return createSessionInFlight;const startedAtMs=Date.now();const creationProjectSlug=String(projectSlug.value||``).trim();const creationApiPath=sessionsApiPath.value;const creationQueryKey=[...sessionListQueryKey.value];vibe64SessionDebugLog(`client.sessionData.createSession.start`);createSessionRunning.value=true;createSessionInFlight=(async()=>{try{const response=await createSessionCommand.run({assistantSelection,pullRequestNumber,repositoryBranch,apiPath:creationApiPath});if(!disposed&&creationProjectSlug===String(projectSlug.value||``).trim()){if(response?.creation&&response?.limits)queryClient.setQueryData(creationQueryKey,currentPayload=>{if(!currentPayload||typeof currentPayload!==`object`||Array.isArray(currentPayload))return currentPayload;const currentSessions=Array.isArray(currentPayload.sessions)?currentPayload.sessions:[];const createdSession=response.sessionId?Object.fromEntries(Object.entries(response).filter(([key])=>![`creation`,`limits`,`ok`].includes(key))):null;return{...currentPayload,creation:response.creation,limits:response.limits,...createdSession&&!currentSessions.some(item=>item?.sessionId===createdSession.sessionId)?{sessions:[...currentSessions,createdSession]}:{}}});if(response?.sessionId)selectSessionId(response.sessionId);refreshSessionDataInBackground({reason:`create-session`})}vibe64SessionDebugLog(`client.sessionData.createSession.done`,{...vibe64SessionDebugSummary(response||{}),code:String(response?.code||response?.errors?.[0]?.code||``),durationMs:vibe64SessionDebugDurationMs(startedAtMs),ok:response?.ok!==false});return response}catch(error){vibe64SessionDebugLog(`client.sessionData.createSession.error`,{durationMs:vibe64SessionDebugDurationMs(startedAtMs),error:vibe64SessionDebugError(error)});throw error}finally{createSessionRunning.value=false;createSessionInFlight=null}})();return createSessionInFlight}return{createSession,createSessionCommand,createSessionRunning}}function sessionIdExistsInList(sessionId=``,nextSessions=[]){const normalizedSessionId=String(sessionId||``).trim();return Boolean(normalizedSessionId)&&nextSessions.some(session=>session.sessionId===normalizedSessionId)}function renewedSuccessorSessionId({predecessorSessionId=``,sessions=[]}={}){const predecessorId=String(predecessorSessionId||``).trim();if(!predecessorId)return``;const matches=sessions.filter(session=>String(session?.metadata?.renewed_from||``).trim()===predecessorId);return matches.length===1?String(matches[0]?.sessionId||``).trim():``}function useVibe64SelectedSessionRenewal({availableSessions,projectSlug,route,router,selectedListSession,selectedSessionId,selectedSessionMissing,sessionList,sessionsApiPath}){let disposed=false;onScopeDispose(()=>{disposed=true});const selectionRenewalPredecessorId=computed(()=>{const selectedId=String(selectedSessionId.value||``).trim();if(!selectedId||sessionList.pages.length<1||String(sessionList.loadError||``).trim())return``;if(sessionList.unavailableItems.some(session=>session.sessionId===selectedId))return``;if(selectedSessionMissing.value)return selectedId;return String(selectedListSession.value?.metadata?.renewed_from||``).trim()});const selectionRenewalPath=computed(()=>selectionRenewalPredecessorId.value?vibe64SessionPath(sessionsApiPath.value,selectionRenewalPredecessorId.value,`/renewal`):``);const selectionRenewalResource=useEndpointResource({enabled:computed(()=>Boolean(selectionRenewalPredecessorId.value)),fallbackLoadError:`The selected session renewal could not be checked.`,path:selectionRenewalPath,queryKey:computed(()=>[...vibe64SessionQueryKey(`app`,ROUTE_VISIBILITY_PUBLIC,projectSlug.value),selectionRenewalPredecessorId.value,`renewal`]),queryOptions:{refetchOnMount:`always`,refetchOnWindowFocus:false},readMethod:`GET`,realtime:{event:VIBE64_SESSION_SUMMARY_CHANGED_EVENT,matches:({payload={}}={})=>mountedSessionRealtimeShouldRefresh({payload},selectionRenewalPredecessorId.value)},requestRecoveryLabel:`Selected session renewal`});let pendingRenewalNavigation=null;function syncRenewalSuccessorUrl(predecessorId,successorId){if(selectedSessionIdFromRoute(route)!==predecessorId)return;const capturedProject=String(projectSlug.value||``).trim();const capturedApiPath=sessionsApiPath.value;const predecessorUrl=route.fullPath;if(pendingRenewalNavigation?.predecessorUrl===predecessorUrl&&pendingRenewalNavigation?.successorId===successorId)return;const sameRenewal=()=>{const renewal=selectionRenewalResource.data.value?.renewal;return!disposed&&String(projectSlug.value||``).trim()===capturedProject&&sessionsApiPath.value===capturedApiPath&&selectedSessionId.value===successorId&&!selectionRenewalResource.loadError?.value&&!selectionRenewalResource.isInitialLoading?.value&&!selectionRenewalResource.isLoading?.value&&renewal?.status===`completed`&&String(renewal.sessionId||``).trim()===predecessorId&&String(renewal.successor?.sessionId||``).trim()===successorId&&renewedSuccessorSessionId({predecessorSessionId:predecessorId,sessions:availableSessions.value})===successorId};if(!sameRenewal())return;const target={path:route.path,hash:route.hash,query:{...route.query,session:successorId}};const targetUrl=router.resolve(target).fullPath;const navigation={predecessorUrl,successorId};const removeGuard=router.beforeResolve(to=>{if(to.fullPath===targetUrl&&(!sameRenewal()||route.fullPath!==predecessorUrl))return false});pendingRenewalNavigation=navigation;(async()=>{try{await router.replace(target)}catch(error){if(sameRenewal())vibe64SessionDebugLog(`client.sessionData.renewalNavigation.error`,{error:vibe64SessionDebugError(error),sessionId:successorId})}finally{removeGuard();if(pendingRenewalNavigation===navigation)pendingRenewalNavigation=null}})()}return{selectionRenewalPredecessorId,selectionRenewalResource,syncRenewalSuccessorUrl}}function ignorePublicationError(){}function createVibe64CurrentSessionPublisher({onError=ignorePublicationError,publish}){let pendingPublication=null;let publicationChain=Promise.resolve();let lastPublishedIdentity=null;let stopped=false;function request(publication={}){if(stopped)return publicationChain;const apiPath=String(publication.apiPath||``);const sessionId=String(publication.sessionId||``).trim();pendingPublication={apiPath,identity:JSON.stringify([apiPath,sessionId]),sessionId};publicationChain=publicationChain.catch(()=>null).then(async()=>{const publication=pendingPublication;pendingPublication=null;if(stopped||!publication)return;if(publication.identity===lastPublishedIdentity)return;try{await publish({apiPath:publication.apiPath,sessionId:publication.sessionId});lastPublishedIdentity=publication.identity}catch(error){onError(error,publication)}});return publicationChain}function stop(){stopped=true;pendingPublication=null}return Object.freeze({request,stop})}function selectedSessionIdForCurrentAlias({createSessionRunning=false,selectedSessionId=``,sessionListLoaded=true,sessionListLoadError=``,sessionListLoading=false,sessions=[]}={}){if(!sessionListLoaded||sessionListLoading||String(sessionListLoadError||``).trim())return null;const normalizedSessionId=String(selectedSessionId||``).trim();if(sessionIdExistsInList(normalizedSessionId,sessions))return normalizedSessionId;if(sessions.length>0||createSessionRunning)return null;return``}function useVibe64CurrentSessionPublication({selectionReconciliationState}){const updateCurrentSessionCommand=useCommand({access:`never`,apiSuffix:VIBE64_CURRENT_SESSION_API_SUFFIX,buildCommandOptions:(_model,{context})=>({method:`PUT`,path:String(context?.apiPath||``)}),buildRawPayload:(_model,{context})=>({sessionId:String(context?.sessionId||``).trim()}),fallbackRunError:`The current session shortcut could not be updated.`,messages:{error:`The current session shortcut could not be updated.`},ownershipFilter:ROUTE_VISIBILITY_PUBLIC,placementSource:`vibe64.sessions.current.update`,suppressSuccessMessage:true,surfaceId:`app`,writeMethod:`PUT`});const currentSessionPublisher=createVibe64CurrentSessionPublisher({async publish({apiPath,sessionId}){const response=await updateCurrentSessionCommand.run({apiPath,sessionId});if(!response||response.ok===false)throw new Error(String(response?.error||`The current session shortcut could not be updated.`))},onError(error,publication){vibe64SessionDebugLog(`client.sessionData.currentSession.error`,{error:vibe64SessionDebugError(error),sessionId:publication.sessionId})}});onScopeDispose(()=>{currentSessionPublisher.stop()});watch(selectionReconciliationState,state=>{const publicationSessionId=selectedSessionIdForCurrentAlias({createSessionRunning:state.createSessionRunning,selectedSessionId:state.selectedSessionId,sessionListLoaded:state.sessionListLoaded,sessionListLoadError:state.sessionListLoadError,sessionListLoading:state.sessionListLoading,sessions:state.nextSessions});if(publicationSessionId===null||!state.currentSessionApiPath)return;currentSessionPublisher.request({apiPath:state.currentSessionApiPath,sessionId:publicationSessionId})},{flush:`post`,immediate:true})}function sessionArchiveOperation(session){try{return JSON.parse(session?.metadata?.session_archive_operation||`null`)}catch{return{status:`failed`,error:`Session archive state could not be read.`}}}function sessionArchiveState(session){const operation=sessionArchiveOperation(session);const failed=operation?.status===`failed`;return{archiveError:failed?operation.error:``,archiving:!failed&&(operation?.status===`running`||session?.metadata?.session_closing_reason===`archived`),operation}}function routeQueryWithoutUnlistedSession({route={},projectSlug=``,sessions=[]}={}){const routeSessionId=selectedSessionIdFromRoute(route);if(!routeSessionId||projectSlugFromRoute(route)!==projectSlug||sessionIdExistsInList(routeSessionId,sessions))return null;const{session:_session,conversation:_conversation,chat:_chat,...query}=route.query||{};return query}function shouldPreserveSelectedSessionDuringRefresh({createSessionRunning=false,currentSessionId=``,nextSessions=[],sessionListLoading=false}={}){const normalizedSessionId=String(currentSessionId||``).trim();if(!normalizedSessionId||sessionIdExistsInList(normalizedSessionId,nextSessions))return false;return Boolean(sessionListLoading||createSessionRunning)}function sessionListRealtimeShouldRefresh({payload={}}={},projectSlug=``){return vibe64SessionEventMatchesScope(payload,{projectSlug})&&payload.clientRefresh?.includeList!==false}function useVibe64SessionData(){const projectSlug=useVibe64ProjectSlug();const route=useRoute();const router=useRouter();const paths=usePaths();const selectionScope=computed(()=>String(projectSlug.value||``).trim());const sessionsApiPath=computed(()=>paths.api(VIBE64_SESSIONS_API_SUFFIX,{surface:`app`}));const currentSessionApiPath=computed(()=>paths.api(VIBE64_CURRENT_SESSION_API_SUFFIX,{surface:`app`}));const sessionListQueryKey=computed(()=>vibe64SessionsQueryKey(`app`,ROUTE_VISIBILITY_PUBLIC,projectSlug.value));const sessionListResource=useEndpointResource({fallbackLoadError:`Vibe64 sessions could not be loaded.`,path:sessionsApiPath,queryKey:sessionListQueryKey,readQuery:{limit:20},queryOptions:{refetchOnMount:`always`,refetchOnWindowFocus:false},requestRecoveryLabel:`Vibe64 sessions`,realtime:{events:[VIBE64_SESSION_SUMMARY_CHANGED_EVENT,VIBE64_PROJECT_CHANGED_EVENT,`connect`],matches:event=>sessionListRealtimeShouldRefresh(event,projectSlug.value)}});const sessionList=proxyRefs({unavailableItems:computed(()=>sessionListResource.data.value?.unavailableSessions||[]),items:computed(()=>{const payload=sessionListResource.data.value||{};return Array.isArray(payload.sessions)?payload.sessions:[]}),loadError:computed(()=>sessionListResource.loadError.value),isInitialLoading:computed(()=>sessionListResource.isInitialLoading.value||!sessionListResource.query.isFetchedAfterMount.value),isLoading:computed(()=>sessionListResource.isLoading.value),pages:computed(()=>{const payload=sessionListResource.data.value;return payload&&typeof payload===`object`&&!Array.isArray(payload)?[payload]:[]}),reload:sessionListResource.reload,resource:sessionListResource});const sessionSelection=useVibe64SessionSelection({projectSlug,rememberedId:()=>sessionList.isInitialLoading?``:sessionList.pages[0]?.lastOpenedSessionId});const selectedSessionId=sessionSelection.selectedId;let emptySessionListObservedForProject=``;const{createSession,createSessionCommand,createSessionRunning}=useVibe64SessionCreation({projectSlug,refreshSessionDataInBackground,selectSessionId,sessionListQueryKey,sessionsApiPath});const archiveAttempts=ref({});const agentActivityBySessionId=ref({});const sessions=computed(()=>{const items=new Map((sessionList.items||[]).map(session=>[session.sessionId,session]));for(const[id,attempt]of Object.entries(archiveAttempts.value))if(attempt.succeeded)items.delete(id);else items.set(id,{...items.get(id)||attempt.session,archiving:true,archiveStartedAt:attempt.startedAt});return visibleVibe64Sessions([...items.values()]).map(session=>{const archiveState=sessionArchiveState(session);return{...session,agentActivity:latestAgentTurnRealtimeOverlay(session.agentActivity,agentActivityBySessionId.value[session.sessionId]),archiveOperation:archiveState.operation,archiveStartedAt:archiveState.operation?.startedAt||session.archiveStartedAt,archiveError:archiveState.archiveError,archiving:Boolean(session.archiving||archiveState.archiving)}})});const availableSessions=computed(()=>sessions.value.filter(session=>!session.archiving));const selectedListSession=computed(()=>{return sessions.value.find(session=>session.sessionId===selectedSessionId.value)||null});const selectedSessionMissing=computed(()=>{const selectedId=String(selectedSessionId.value||``).trim();if(!selectedId||sessionList.pages.length<1||String(sessionList.loadError||``).trim()||sessionIdExistsInList(selectedId,sessions.value))return false;return true});const{selectionRenewalPredecessorId,selectionRenewalResource,syncRenewalSuccessorUrl}=useVibe64SelectedSessionRenewal({availableSessions,projectSlug,route,router,selectedListSession,selectedSessionId,selectedSessionMissing,sessionList,sessionsApiPath});const creationOptions=computed(()=>sessionList.pages?.[0]?.creation||{});const selectedSession=computed(()=>enrichVibe64SessionForDisplay(selectedListSession.value));const isSelectedSessionArchived=computed(()=>isArchivedVibe64Session(selectedSession.value||{}));const canCreateSession=computed(()=>{return creationOptions.value.canCreate===true});const createSessionVisible=computed(()=>creationOptions.value.showCreateAction===true);const createSessionTitle=computed(()=>{if(creationOptions.value.disabledReason)return String(creationOptions.value.disabledReason);if(creationOptions.value.canCreate!==true)return`Session creation is unavailable.`;return`Create a new Vibe64 session`});const selectedSessionTitle=computed(()=>{return vibe64SessionDisplayTitle(selectedSession.value||{})||`Session ${shortVibe64SessionId(selectedSessionId.value)}`});async function refreshSessionList(){return refetchEndpointResource(sessionListResource)}let refreshSessionDataInFlight=null;async function refreshSessionData(options={}){const reason=typeof options===`string`?options:String(options.reason||``);if(refreshSessionDataInFlight){vibe64SessionDebugLog(`client.sessionData.refresh.join`,{reason,selectedSessionId:String(selectedSessionId.value||``)});return refreshSessionDataInFlight}const startedAtMs=Date.now();vibe64SessionDebugLog(`client.sessionData.refresh.start`,{reason,selectedSessionId:String(selectedSessionId.value||``)});refreshSessionDataInFlight=refreshSessionList();try{const result=await refreshSessionDataInFlight;vibe64SessionDebugLog(`client.sessionData.refresh.done`,{durationMs:vibe64SessionDebugDurationMs(startedAtMs),reason,selectedSessionId:String(selectedSessionId.value||``),sessionCount:sessions.value.length});return result}catch(error){vibe64SessionDebugLog(`client.sessionData.refresh.error`,{durationMs:vibe64SessionDebugDurationMs(startedAtMs),error:vibe64SessionDebugError(error),reason,selectedSessionId:String(selectedSessionId.value||``)});throw error}finally{refreshSessionDataInFlight=null}}function refreshSessionDataInBackground(options={}){refreshSessionData(options).catch(()=>{})}function selectSessionId(sessionId=``){const normalizedSessionId=String(sessionId||``).trim();if(sessions.value.some(session=>session.sessionId===normalizedSessionId&&session.archiving))return;vibe64SessionDebugLog(`client.sessionData.selectSession`,{fromSessionId:String(selectedSessionId.value||``),toSessionId:normalizedSessionId});if(normalizedSessionId)emptySessionListObservedForProject=``;sessionSelection.select(normalizedSessionId)}function clearSelectedSession(){emptySessionListObservedForProject=selectionScope.value;sessionSelection.clear()}function selectPreviousSession(sessionId){const navigation=sessions.value;const index=navigation.findIndex(session=>session.sessionId===sessionId);selectSessionId(navigation.slice(0,Math.max(0,index)).filter(session=>!session.archiving).at(-1)?.sessionId||availableSessions.value.at(-1)?.sessionId||``)}const archive=proxyRefs(useVibe64SessionDialogs({beginArchive(sessionId){archiveAttempts.value[sessionId]={startedAt:new Date().toISOString(),session:sessions.value.find(session=>session.sessionId===sessionId)};if(selectedSessionId.value===sessionId)selectPreviousSession(sessionId);return projectSlug.value},finishArchive(sessionId,succeeded,archiveProject){if(projectSlug.value!==archiveProject)return;if(succeeded)archiveAttempts.value[sessionId]={succeeded:true};else{delete archiveAttempts.value[sessionId];if(!selectedSessionId.value)selectSessionId(sessionId)}},isSelectedSessionArchived,refreshSessionData,selectedSessionId,selectedSessionTitle,sessionsApiPath}));const archiveFeedback=useUiFeedback({source:`vibe64.sessions.archive.remote`});const shownArchiveFailures=new Set;watch(projectSlug,()=>{archiveAttempts.value={};agentActivityBySessionId.value={};shownArchiveFailures.clear()});useRealtimeEvent({event:VIBE64_SESSION_SUMMARY_CHANGED_EVENT,matches:({payload={}}={})=>vibe64SessionEventMatchesScope(payload,{projectSlug:projectSlug.value}),onEvent:({payload={}}={})=>{const id=String(payload.sessionId||``);if(!id)return;const activity=agentTurnRealtimeOverlayFromPayload(payload,id);if(activity)agentActivityBySessionId.value[id]=latestAgentTurnRealtimeOverlay(agentActivityBySessionId.value[id],{active:activity.active,revision:activity.revision});if(payload.reason===`session-archiving`){const session=sessions.value.find(item=>item.sessionId===id);if(session)archiveAttempts.value[id]={session,startedAt:archiveAttempts.value[id]?.startedAt||new Date().toISOString()};if(selectedSessionId.value===id)selectPreviousSession(id)}else if(payload.reason===`session-archived`)archiveAttempts.value[id]={succeeded:true};else if(payload.reason===`session-archive-failed`){delete archiveAttempts.value[id];if(!selectedSessionId.value)selectSessionId(id)}}});watch(()=>sessionList.items,items=>{for(const id of Object.keys(agentActivityBySessionId.value))if(!items.some(session=>session.sessionId===id))delete agentActivityBySessionId.value[id];for(const[id,attempt]of Object.entries(archiveAttempts.value)){if(attempt.succeeded||archive.archivingSessionId===id)continue;const session=items.find(item=>item.sessionId===id);if(!session||!sessionArchiveState(session).archiving)delete archiveAttempts.value[id]}});watch(sessions,items=>{for(const session of items){const key=`${session.sessionId}:${session.metadata?.session_archive_operation}`;if(!session.archiveError||shownArchiveFailures.has(key))continue;shownArchiveFailures.add(key);if(archive.archivingSessionId!==session.sessionId)archiveFeedback.error(new Error(session.archiveError))}},{immediate:true});function dropUnlistedRouteSession(){const query=routeQueryWithoutUnlistedSession({route,projectSlug:projectSlug.value,sessions:sessions.value});if(query)router.replace({path:route.path,hash:route.hash,query}).catch(()=>null)}const selectionReconciliationState=computed(()=>{const nextSessions=availableSessions.value;return{createSessionRunning:createSessionRunning.value,currentSessionApiPath:currentSessionApiPath.value,selectionScope:selectionScope.value,selectionRenewal:selectionRenewalResource.data.value?.renewal||null,selectionRenewalLoadError:String(selectionRenewalResource.loadError?.value||``),selectionRenewalLoaded:Boolean(selectionRenewalResource.data.value&&typeof selectionRenewalResource.data.value===`object`&&!Array.isArray(selectionRenewalResource.data.value)),selectionRenewalLoading:Boolean(selectionRenewalResource.isInitialLoading?.value||selectionRenewalResource.isLoading?.value),selectionRenewalPredecessorId:selectionRenewalPredecessorId.value,projectSlug:String(projectSlug.value||``).trim(),selectedSessionMissing:selectedSessionMissing.value,nextSessions,selectedSessionId:String(selectedSessionId.value||``),sessionListInitialLoading:sessionList.isInitialLoading,sessionListLoaded:sessionList.pages.length>0,sessionListLoadError:String(sessionList.loadError||``),sessionListLoading:sessionList.isLoading}});watch(selectionReconciliationState,state=>{const nextSessions=state.nextSessions;if(sessions.value.some(session=>session.sessionId===state.selectedSessionId&&session.archiving)){selectPreviousSession(state.selectedSessionId);return}vibe64SessionDebugLog(`client.sessionData.sessions.changed`,{selectedSessionId:String(selectedSessionId.value||``),sessionCount:nextSessions.length});if(state.sessionListInitialLoading||state.sessionListLoadError||shouldPreserveSelectedSessionDuringRefresh({createSessionRunning:state.createSessionRunning,currentSessionId:state.selectedSessionId,nextSessions,sessionListLoading:state.sessionListLoading}))return;if(!state.selectedSessionId&&nextSessions.length===0)emptySessionListObservedForProject=state.selectionScope;if(state.selectionRenewalPredecessorId){if(state.selectionRenewalLoading||state.selectionRenewalLoadError||!state.selectionRenewalLoaded)return;const selectionRenewal=state.selectionRenewal;if(selectionRenewal&&String(selectionRenewal.sessionId||``).trim()===state.selectionRenewalPredecessorId){const renewalStatus=String(selectionRenewal.status||``).trim();if(renewalStatus===`completed`){const renewedSuccessorId=renewedSuccessorSessionId({predecessorSessionId:state.selectionRenewalPredecessorId,sessions:nextSessions});if(state.selectedSessionMissing){if(renewedSuccessorId)sessionSelection.selectAvailableId(nextSessions,{fallbackId:renewedSuccessorId,getId:session=>session.sessionId})}if(renewedSuccessorId&&selectedSessionId.value===renewedSuccessorId)syncRenewalSuccessorUrl(state.selectionRenewalPredecessorId,renewedSuccessorId);if(state.selectedSessionMissing)return}else if(state.selectedSessionMissing&&[`failed`,`running`].includes(renewalStatus))return;if([`failed`,`running`].includes(renewalStatus)){sessionSelection.select(state.selectionRenewalPredecessorId);return}}}if(!state.selectionRenewalPredecessorId)dropUnlistedRouteSession();if(!state.selectedSessionId&&emptySessionListObservedForProject===state.selectionScope)return;sessionSelection.selectAvailableId(nextSessions,{fallbackId:nextSessions.at(-1)?.sessionId||``,getId:session=>session.sessionId})},{immediate:true});useVibe64CurrentSessionPublication({selectionReconciliationState});return{archive,canCreateSession,clearSelectedSession,createSession,createSessionCommand,createSessionRunning,createSessionVisible,createSessionTitle,isSelectedSessionArchived,refreshSessionData,selectSessionId,selectedSession,selectedSessionId,selectedSessionTitle,sessionList,sessions,sessionsApiPath,shortSessionId:shortVibe64SessionId}}export{mountedSessionDetailRefreshReason as a,sessionRecordHasActiveAgentWork as c,sessionWithAgentTurnRealtimeOverlay as d,refetchEndpointResource as f,mountedSessionDetailLoadState as i,agentTurnRealtimeOverlayFromPayload as l,useVibe64SessionData as n,mountedSessionRealtimeShouldRefresh as o,latestSessionDetailRecord as r,mountedSessionRecord as s,sessionListRealtimeShouldRefresh as t,latestAgentTurnRealtimeOverlay as u};
1
+ import{Et as unref,ht as proxyRefs,it as watch,mt as onScopeDispose,u as computed,vt as ref}from"./runtime-core.esm-bundler-Bi1P1jMa.js";import{N as useQueryClient,t as useEndpointResource}from"./useEndpointResource-CmMwteuX.js";import{_ as useRouter,g as useRoute}from"./useApi-BPuI6ZR9-rsYWyW6m.js";import{s as normalizeObject}from"./normalize-BD25VwNK.js";import{o as projectSlugFromRoute}from"./vibe64ProjectScope.local-B9ZpdYlf.js";import{o as ROUTE_VISIBILITY_PUBLIC}from"./visibility-Cq31Xy7I.js";import{r as useRealtimeEvent}from"./useRealtimeEvent-B4oRg9Dt.js";import{t as useCommand}from"./useCommand-CNDe8gM-.js";import{t as usePaths}from"./usePaths-CvUbx5-V.js";import{t as useUiFeedback}from"./useUiFeedback-CWb6o71Z.js";import{t as readRefOrGetterValue}from"./vueRefOrGetterValue-y-4f_In7.js";import{r as vibe64RealtimeOriginPayload}from"./vibe64BrowserTabOrigin-vIN_87mi.js";import{H as vibe64SessionsQueryKey,I as vibe64SessionEventMatchesScope,L as vibe64SessionPath,V as vibe64SessionQueryKey,a as VIBE64_CURRENT_SESSION_API_SUFFIX,c as VIBE64_SESSION_SUMMARY_CHANGED_EVENT,o as VIBE64_SESSIONS_API_SUFFIX}from"./vibe64SessionRequestConfig-DVRCRAex.js";import{S as VIBE64_PROJECT_CHANGED_EVENT}from"./studioGateApi-UqmdV50W.js";import{N as useVibe64ProjectSlug}from"./index-DAareKn3.js";import{i as vibe64SessionDisplayTitle,o as vibe64SessionRevision,r as shortVibe64SessionId,t as isArchivedVibe64Session}from"./vibe64SessionViewModel-CQCds_jb.js";import{i as vibe64SessionDebugSummary,n as vibe64SessionDebugError,r as vibe64SessionDebugLog,t as vibe64SessionDebugDurationMs}from"./vibe64SessionDebugLog-BfO7tG1A.js";import{i as visibleVibe64Sessions,n as enrichVibe64SessionForDisplay}from"./vibe64SessionPanelModel-B-WkXnPu.js";import{n as useVibe64SessionSelection,t as selectedSessionIdFromRoute}from"./useVibe64SessionSelection-CKBC-ZJw.js";function refetchEndpointResource(resource){return resource.query.refetch({cancelRefetch:false})}function sessionChangedReason(payload){return String(payload.reason||``).trim()}function sessionRevision(value){const revision=Number(value);return Number.isSafeInteger(revision)&&revision>=0?revision:null}function agentTurnRealtimeOverlayFromPayload(input,selectedSessionId=``){const payload=normalizeObject(input);const changedSessionId=String(payload.sessionId||payload.entityId||``).trim();if(!changedSessionId||changedSessionId!==String(selectedSessionId||``).trim())return null;const agentSession=normalizeObject(payload.agentSession);const turn=normalizeObject(agentSession.turn);const run=normalizeObject(payload.agentRun);const revision=sessionRevision(payload.revision);if(revision===null||!Object.keys(turn).length&&!Object.keys(run).length)return null;const active=turn.active===true||run.active===true;return{active,agentRun:{...run,active},agentSession:{...agentSession,turn:{...turn,active}},reason:sessionChangedReason(payload),revision,sessionId:changedSessionId}}function latestAgentTurnRealtimeOverlay(current=null,candidate=null){if(!candidate)return current;if(!current||candidate.revision>current.revision)return candidate;return current}function mergeAgentRunOverlay(agentRuns=[],overlayRun={}){const runs=Array.isArray(agentRuns)?agentRuns:[];const runId=String(overlayRun.id||``).trim();if(!runId)return runs;const nextRun={...overlayRun,id:runId};const index=runs.findIndex(run=>String(run?.id||``).trim()===runId);if(index<0)return[...runs,nextRun];return runs.map((run,runIndex)=>runIndex===index?{...run,...nextRun}:run)}function sessionWithAgentTurnRealtimeOverlay(session=null,overlay=null){const currentRevision=sessionRevision(session?.revision);if(!session||!overlay||session?.ok===false||session.sessionId!==overlay.sessionId||currentRevision!==null&&overlay.revision<=currentRevision)return session;const overlayAgentSession=normalizeObject(overlay.agentSession);return{...session,agentRuns:mergeAgentRunOverlay(session.agentRuns,normalizeObject(overlay.agentRun)),agentSession:{...normalizeObject(session.agentSession),...overlayAgentSession,thread:{...normalizeObject(session.agentSession?.thread),...normalizeObject(overlayAgentSession.thread)},turn:{...normalizeObject(session.agentSession?.turn),...normalizeObject(overlayAgentSession.turn),active:overlay.active===true}},revision:overlay.revision}}function sessionRecordHasDetailProjection(session=null){return Boolean(session&&typeof session===`object`&&Object.hasOwn(session,`agentSession`))}function sessionRecordHasActiveAgentWork(session=null){return(session?.agentSession?.turn?.active??session?.agentActivity?.active)===true}function sessionRecordMatchesId(session=null,sessionId=``){const normalizedSessionId=String(sessionId||``).trim();return Boolean(normalizedSessionId&&session?.sessionId===normalizedSessionId&&session?.ok!==false)}function latestSessionDetailRecord(current=null,candidate=null,sessionId=``){if(!sessionRecordMatchesId(candidate,sessionId))return current;if(!sessionRecordMatchesId(current,sessionId))return candidate;const currentRevision=vibe64SessionRevision(current);const candidateRevision=vibe64SessionRevision(candidate);if(currentRevision!==null&&candidateRevision!==null&&candidateRevision<currentRevision)return current;return candidate}function mountedSessionRecord(detailSession=null,listSession=null,sessionId=``){const normalizedSessionId=String(sessionId||``).trim();const listSessionMatches=sessionRecordMatchesId(listSession,normalizedSessionId);if(!sessionRecordMatchesId(detailSession,normalizedSessionId))return listSessionMatches?listSession:null;const detailRevision=vibe64SessionRevision(detailSession);const listRevision=vibe64SessionRevision(listSession);if(listSessionMatches&&listRevision!==null&&detailRevision!==null&&listRevision>detailRevision){if(sessionRecordHasDetailProjection(detailSession)&&!sessionRecordHasDetailProjection(listSession))return detailSession;return listSession}return detailSession}function mountedSessionDetailRefreshReason(detailSession=null,listSession=null,sessionId=``){const normalizedSessionId=String(sessionId||``).trim();if(!sessionRecordMatchesId(detailSession,normalizedSessionId)||!sessionRecordMatchesId(listSession,normalizedSessionId))return``;const detailRevision=vibe64SessionRevision(detailSession);const listRevision=vibe64SessionRevision(listSession);if(listRevision!==null&&detailRevision!==null&&listRevision>detailRevision&&sessionRecordHasDetailProjection(detailSession)&&!sessionRecordHasDetailProjection(listSession))return`newer_summary_without_detail`;return``}function mountedSessionDetailLoadState({detailSession=null,fetching=false,listSession=null,loadError=``,loading=false,sessionId=``}={}){const normalizedSessionId=String(sessionId||``).trim();const hasDetail=sessionRecordMatchesId(detailSession,normalizedSessionId);const hasSummary=sessionRecordMatchesId(listSession,normalizedSessionId);const error=String(loadError||``).trim();if(!normalizedSessionId)return{error:``,label:``,loading:false,ready:false,restoring:false,sessionId:``,state:`summaryOnly`};if(error&&!hasDetail)return{error,label:`Session could not load.`,loading:false,ready:false,restoring:false,sessionId:normalizedSessionId,state:`detailError`};if(hasDetail)return{error:``,label:``,loading:false,ready:true,refreshing:Boolean(fetching||loading),restoring:false,sessionId:normalizedSessionId,state:`detailReady`};if(loading||fetching)return{error:``,label:`Loading session...`,loading:true,ready:false,restoring:false,sessionId:normalizedSessionId,state:`detailLoading`};return{error:``,label:hasSummary?`Session could not load.`:`Loading session...`,loading:false,ready:false,restoring:false,sessionId:normalizedSessionId,state:`summaryOnly`}}function mountedSessionRealtimeShouldRefresh({payload={}}={},sessionId=``,read=`includeDetail`){const changedSessionId=String(payload.sessionId||payload.entityId||``).trim();if(!changedSessionId||changedSessionId!==String(sessionId||``).trim())return false;return payload.clientRefresh?.[read]!==false}function useVibe64SessionDialogs({beginArchive,finishArchive,isSelectedSessionArchived,refreshSessionData,selectedSessionId,selectedSessionTitle,sessionsApiPath}){const archiveDialogOpen=ref(false);const archiveDialogSessionId=ref(``);const archiveDialogSessionTitle=ref(``);const archivingSessionId=ref(``);const resolvedSessionsApiPath=computed(()=>String(readRefOrGetterValue(sessionsApiPath)||``));const archiveCommand=useCommand({access:`never`,apiSuffix:VIBE64_SESSIONS_API_SUFFIX,buildRawPayload:()=>vibe64RealtimeOriginPayload(),buildCommandOptions:(_payload,{context})=>({method:`POST`,path:vibe64SessionPath(resolvedSessionsApiPath.value,context?.sessionId,`/archive`)}),fallbackRunError:`Vibe64 session could not be archived.`,messages:{error:`Vibe64 session could not be archived.`,success:`Vibe64 session archived.`},onRunSuccess:async response=>{if(response?.ok!==true)throw new Error(response?.errors?.[0]?.message||response?.error||`Vibe64 session could not be archived.`)},ownershipFilter:ROUTE_VISIBILITY_PUBLIC,placementSource:`vibe64.sessions.archive`,surfaceId:`app`,writeMethod:`POST`});function clearArchiveDialog(){archiveDialogOpen.value=false;archiveDialogSessionId.value=``;archiveDialogSessionTitle.value=``}function requestArchiveSelectedSession(){if(!unref(selectedSessionId)||archivingSessionId.value||archiveCommand.isRunning||unref(isSelectedSessionArchived))return;archiveDialogSessionId.value=unref(selectedSessionId);archiveDialogSessionTitle.value=unref(selectedSessionTitle);archiveDialogOpen.value=true}function cancelArchiveSession(){if(!archiveCommand.isRunning)clearArchiveDialog()}async function confirmArchiveSession(){if(!archiveDialogSessionId.value||archivingSessionId.value||archiveCommand.isRunning)return false;const sessionId=archiveDialogSessionId.value;archivingSessionId.value=sessionId;clearArchiveDialog();const archiveScope=beginArchive(sessionId);let succeeded=false;try{const response=await archiveCommand.run({sessionId});succeeded=response?.ok===true;return response}catch{return false}finally{finishArchive(sessionId,succeeded,archiveScope);if(archivingSessionId.value===sessionId)archivingSessionId.value=``;refreshSessionData({reason:`archive-session`}).catch(()=>null)}}return{archiving:computed(()=>Boolean(archivingSessionId.value)),archivingSessionId,cancel:cancelArchiveSession,command:archiveCommand,confirm:confirmArchiveSession,open:archiveDialogOpen,request:requestArchiveSelectedSession,sessionId:archiveDialogSessionId,sessionTitle:archiveDialogSessionTitle}}function useVibe64SessionCreation({projectSlug,refreshSessionDataInBackground,selectSessionId,sessionListQueryKey,sessionsApiPath}){const queryClient=useQueryClient();const createSessionCommand=useCommand({access:`never`,apiSuffix:VIBE64_SESSIONS_API_SUFFIX,buildCommandOptions:(_model,{context})=>({method:`POST`,path:context?.apiPath}),buildRawPayload:(_model,{context})=>vibe64RealtimeOriginPayload({assistantSelection:context?.assistantSelection||{},...context?.repositoryBranch?{repositoryBranch:context.repositoryBranch}:{},...context?.pullRequestNumber?{pullRequestNumber:context.pullRequestNumber}:{}}),fallbackRunError:`Vibe64 session could not be created.`,messages:{error:`Vibe64 session could not be created.`,success:`Vibe64 session created.`},ownershipFilter:ROUTE_VISIBILITY_PUBLIC,placementSource:`vibe64.sessions.create`,surfaceId:`app`,writeMethod:`POST`});const createSessionRunning=ref(false);let createSessionInFlight=null;let disposed=false;onScopeDispose(()=>{disposed=true});async function createSession(assistantSelection={},{pullRequestNumber,repositoryBranch}={}){if(createSessionInFlight)return createSessionInFlight;const startedAtMs=Date.now();const creationProjectSlug=String(projectSlug.value||``).trim();const creationApiPath=sessionsApiPath.value;const creationQueryKey=[...sessionListQueryKey.value];vibe64SessionDebugLog(`client.sessionData.createSession.start`);createSessionRunning.value=true;createSessionInFlight=(async()=>{try{const response=await createSessionCommand.run({assistantSelection,pullRequestNumber,repositoryBranch,apiPath:creationApiPath});if(!disposed&&creationProjectSlug===String(projectSlug.value||``).trim()){if(response?.creation&&response?.limits)queryClient.setQueryData(creationQueryKey,currentPayload=>{if(!currentPayload||typeof currentPayload!==`object`||Array.isArray(currentPayload))return currentPayload;const currentSessions=Array.isArray(currentPayload.sessions)?currentPayload.sessions:[];const createdSession=response.sessionId?Object.fromEntries(Object.entries(response).filter(([key])=>![`creation`,`limits`,`ok`].includes(key))):null;return{...currentPayload,creation:response.creation,limits:response.limits,...createdSession&&!currentSessions.some(item=>item?.sessionId===createdSession.sessionId)?{sessions:[...currentSessions,createdSession]}:{}}});if(response?.sessionId)selectSessionId(response.sessionId);refreshSessionDataInBackground({reason:`create-session`})}vibe64SessionDebugLog(`client.sessionData.createSession.done`,{...vibe64SessionDebugSummary(response||{}),code:String(response?.code||response?.errors?.[0]?.code||``),durationMs:vibe64SessionDebugDurationMs(startedAtMs),ok:response?.ok!==false});return response}catch(error){vibe64SessionDebugLog(`client.sessionData.createSession.error`,{durationMs:vibe64SessionDebugDurationMs(startedAtMs),error:vibe64SessionDebugError(error)});throw error}finally{createSessionRunning.value=false;createSessionInFlight=null}})();return createSessionInFlight}return{createSession,createSessionCommand,createSessionRunning}}function sessionIdExistsInList(sessionId=``,nextSessions=[]){const normalizedSessionId=String(sessionId||``).trim();return Boolean(normalizedSessionId)&&nextSessions.some(session=>session.sessionId===normalizedSessionId)}function renewedSuccessorSessionId({predecessorSessionId=``,sessions=[]}={}){const predecessorId=String(predecessorSessionId||``).trim();if(!predecessorId)return``;const matches=sessions.filter(session=>String(session?.metadata?.renewed_from||``).trim()===predecessorId);return matches.length===1?String(matches[0]?.sessionId||``).trim():``}function useVibe64SelectedSessionRenewal({availableSessions,projectSlug,route,router,selectedListSession,selectedSessionId,selectedSessionMissing,sessionList,sessionsApiPath}){let disposed=false;onScopeDispose(()=>{disposed=true});const selectionRenewalPredecessorId=computed(()=>{const selectedId=String(selectedSessionId.value||``).trim();if(!selectedId||sessionList.pages.length<1||String(sessionList.loadError||``).trim())return``;if(sessionList.unavailableItems.some(session=>session.sessionId===selectedId))return``;if(selectedSessionMissing.value)return selectedId;return String(selectedListSession.value?.metadata?.renewed_from||``).trim()});const selectionRenewalPath=computed(()=>selectionRenewalPredecessorId.value?vibe64SessionPath(sessionsApiPath.value,selectionRenewalPredecessorId.value,`/renewal`):``);const selectionRenewalResource=useEndpointResource({enabled:computed(()=>Boolean(selectionRenewalPredecessorId.value)),fallbackLoadError:`The selected session renewal could not be checked.`,path:selectionRenewalPath,queryKey:computed(()=>[...vibe64SessionQueryKey(`app`,ROUTE_VISIBILITY_PUBLIC,projectSlug.value),selectionRenewalPredecessorId.value,`renewal`]),queryOptions:{refetchOnMount:`always`,refetchOnWindowFocus:false},readMethod:`GET`,realtime:{event:VIBE64_SESSION_SUMMARY_CHANGED_EVENT,matches:({payload={}}={})=>mountedSessionRealtimeShouldRefresh({payload},selectionRenewalPredecessorId.value)},requestRecoveryLabel:`Selected session renewal`});let pendingRenewalNavigation=null;function syncRenewalSuccessorUrl(predecessorId,successorId){if(selectedSessionIdFromRoute(route)!==predecessorId)return;const capturedProject=String(projectSlug.value||``).trim();const capturedApiPath=sessionsApiPath.value;const predecessorUrl=route.fullPath;if(pendingRenewalNavigation?.predecessorUrl===predecessorUrl&&pendingRenewalNavigation?.successorId===successorId)return;const sameRenewal=()=>{const renewal=selectionRenewalResource.data.value?.renewal;return!disposed&&String(projectSlug.value||``).trim()===capturedProject&&sessionsApiPath.value===capturedApiPath&&selectedSessionId.value===successorId&&!selectionRenewalResource.loadError?.value&&!selectionRenewalResource.isInitialLoading?.value&&!selectionRenewalResource.isLoading?.value&&renewal?.status===`completed`&&String(renewal.sessionId||``).trim()===predecessorId&&String(renewal.successor?.sessionId||``).trim()===successorId&&renewedSuccessorSessionId({predecessorSessionId:predecessorId,sessions:availableSessions.value})===successorId};if(!sameRenewal())return;const target={path:route.path,hash:route.hash,query:{...route.query,session:successorId}};const targetUrl=router.resolve(target).fullPath;const navigation={predecessorUrl,successorId};const removeGuard=router.beforeResolve(to=>{if(to.fullPath===targetUrl&&(!sameRenewal()||route.fullPath!==predecessorUrl))return false});pendingRenewalNavigation=navigation;(async()=>{try{await router.replace(target)}catch(error){if(sameRenewal())vibe64SessionDebugLog(`client.sessionData.renewalNavigation.error`,{error:vibe64SessionDebugError(error),sessionId:successorId})}finally{removeGuard();if(pendingRenewalNavigation===navigation)pendingRenewalNavigation=null}})()}return{selectionRenewalPredecessorId,selectionRenewalResource,syncRenewalSuccessorUrl}}function ignorePublicationError(){}function createVibe64CurrentSessionPublisher({onError=ignorePublicationError,publish}){let pendingPublication=null;let publicationChain=Promise.resolve();let lastPublishedIdentity=null;let stopped=false;function request(publication={}){if(stopped)return publicationChain;const apiPath=String(publication.apiPath||``);const sessionId=String(publication.sessionId||``).trim();pendingPublication={apiPath,identity:JSON.stringify([apiPath,sessionId]),sessionId};publicationChain=publicationChain.catch(()=>null).then(async()=>{const publication=pendingPublication;pendingPublication=null;if(stopped||!publication)return;if(publication.identity===lastPublishedIdentity)return;try{await publish({apiPath:publication.apiPath,sessionId:publication.sessionId});lastPublishedIdentity=publication.identity}catch(error){onError(error,publication)}});return publicationChain}function stop(){stopped=true;pendingPublication=null}return Object.freeze({request,stop})}function selectedSessionIdForCurrentAlias({createSessionRunning=false,selectedSessionId=``,sessionListLoaded=true,sessionListLoadError=``,sessionListLoading=false,sessions=[]}={}){if(!sessionListLoaded||sessionListLoading||String(sessionListLoadError||``).trim())return null;const normalizedSessionId=String(selectedSessionId||``).trim();if(sessionIdExistsInList(normalizedSessionId,sessions))return normalizedSessionId;if(sessions.length>0||createSessionRunning)return null;return``}function useVibe64CurrentSessionPublication({selectionReconciliationState}){const updateCurrentSessionCommand=useCommand({access:`never`,apiSuffix:VIBE64_CURRENT_SESSION_API_SUFFIX,buildCommandOptions:(_model,{context})=>({method:`PUT`,path:String(context?.apiPath||``)}),buildRawPayload:(_model,{context})=>({sessionId:String(context?.sessionId||``).trim()}),fallbackRunError:`The current session shortcut could not be updated.`,messages:{error:`The current session shortcut could not be updated.`},ownershipFilter:ROUTE_VISIBILITY_PUBLIC,placementSource:`vibe64.sessions.current.update`,suppressSuccessMessage:true,surfaceId:`app`,writeMethod:`PUT`});const currentSessionPublisher=createVibe64CurrentSessionPublisher({async publish({apiPath,sessionId}){const response=await updateCurrentSessionCommand.run({apiPath,sessionId});if(!response||response.ok===false)throw new Error(String(response?.error||`The current session shortcut could not be updated.`))},onError(error,publication){vibe64SessionDebugLog(`client.sessionData.currentSession.error`,{error:vibe64SessionDebugError(error),sessionId:publication.sessionId})}});onScopeDispose(()=>{currentSessionPublisher.stop()});watch(selectionReconciliationState,state=>{const publicationSessionId=selectedSessionIdForCurrentAlias({createSessionRunning:state.createSessionRunning,selectedSessionId:state.selectedSessionId,sessionListLoaded:state.sessionListLoaded,sessionListLoadError:state.sessionListLoadError,sessionListLoading:state.sessionListLoading,sessions:state.nextSessions});if(publicationSessionId===null||!state.currentSessionApiPath)return;currentSessionPublisher.request({apiPath:state.currentSessionApiPath,sessionId:publicationSessionId})},{flush:`post`,immediate:true})}function sessionArchiveOperation(session){try{return JSON.parse(session?.metadata?.session_archive_operation||`null`)}catch{return{status:`failed`,error:`Session archive state could not be read.`}}}function sessionArchiveState(session){const operation=sessionArchiveOperation(session);const failed=operation?.status===`failed`;return{archiveError:failed?operation.error:``,archiving:!failed&&(operation?.status===`running`||session?.metadata?.session_closing_reason===`archived`),operation}}function routeQueryWithoutUnlistedSession({route={},projectSlug=``,sessions=[]}={}){const routeSessionId=selectedSessionIdFromRoute(route);if(!routeSessionId||projectSlugFromRoute(route)!==projectSlug||sessionIdExistsInList(routeSessionId,sessions))return null;const{session:_session,conversation:_conversation,chat:_chat,...query}=route.query||{};return query}function shouldPreserveSelectedSessionDuringRefresh({createSessionRunning=false,currentSessionId=``,nextSessions=[],sessionListLoading=false}={}){const normalizedSessionId=String(currentSessionId||``).trim();if(!normalizedSessionId||sessionIdExistsInList(normalizedSessionId,nextSessions))return false;return Boolean(sessionListLoading||createSessionRunning)}function sessionListRealtimeShouldRefresh({payload={}}={},projectSlug=``){return vibe64SessionEventMatchesScope(payload,{projectSlug})&&payload.clientRefresh?.includeList!==false}function useVibe64SessionData(){const projectSlug=useVibe64ProjectSlug();const route=useRoute();const router=useRouter();const paths=usePaths();const selectionScope=computed(()=>String(projectSlug.value||``).trim());const sessionsApiPath=computed(()=>paths.api(VIBE64_SESSIONS_API_SUFFIX,{surface:`app`}));const currentSessionApiPath=computed(()=>paths.api(VIBE64_CURRENT_SESSION_API_SUFFIX,{surface:`app`}));const sessionListQueryKey=computed(()=>vibe64SessionsQueryKey(`app`,ROUTE_VISIBILITY_PUBLIC,projectSlug.value));const sessionListResource=useEndpointResource({fallbackLoadError:`Vibe64 sessions could not be loaded.`,path:sessionsApiPath,queryKey:sessionListQueryKey,readQuery:{limit:20},queryOptions:{refetchOnMount:`always`,refetchOnWindowFocus:false},requestRecoveryLabel:`Vibe64 sessions`,realtime:{events:[VIBE64_SESSION_SUMMARY_CHANGED_EVENT,VIBE64_PROJECT_CHANGED_EVENT,`connect`],matches:event=>sessionListRealtimeShouldRefresh(event,projectSlug.value)}});const sessionList=proxyRefs({unavailableItems:computed(()=>sessionListResource.data.value?.unavailableSessions||[]),items:computed(()=>{const payload=sessionListResource.data.value||{};return Array.isArray(payload.sessions)?payload.sessions:[]}),loadError:computed(()=>sessionListResource.loadError.value),isInitialLoading:computed(()=>sessionListResource.isInitialLoading.value||!sessionListResource.query.isFetchedAfterMount.value),isLoading:computed(()=>sessionListResource.isLoading.value),pages:computed(()=>{const payload=sessionListResource.data.value;return payload&&typeof payload===`object`&&!Array.isArray(payload)?[payload]:[]}),reload:sessionListResource.reload,resource:sessionListResource});const sessionSelection=useVibe64SessionSelection({projectSlug,rememberedId:()=>sessionList.isInitialLoading?``:sessionList.pages[0]?.lastOpenedSessionId});const selectedSessionId=sessionSelection.selectedId;let emptySessionListObservedForProject=``;const{createSession,createSessionCommand,createSessionRunning}=useVibe64SessionCreation({projectSlug,refreshSessionDataInBackground,selectSessionId,sessionListQueryKey,sessionsApiPath});const archiveAttempts=ref({});const agentActivityBySessionId=ref({});const sessions=computed(()=>{const items=new Map((sessionList.items||[]).map(session=>[session.sessionId,session]));for(const[id,attempt]of Object.entries(archiveAttempts.value))if(attempt.succeeded)items.delete(id);else items.set(id,{...items.get(id)||attempt.session,archiving:true,archiveStartedAt:attempt.startedAt});return visibleVibe64Sessions([...items.values()]).map(session=>{const archiveState=sessionArchiveState(session);return{...session,agentActivity:latestAgentTurnRealtimeOverlay(session.agentActivity,agentActivityBySessionId.value[session.sessionId]),archiveOperation:archiveState.operation,archiveStartedAt:archiveState.operation?.startedAt||session.archiveStartedAt,archiveError:archiveState.archiveError,archiving:Boolean(session.archiving||archiveState.archiving)}})});const availableSessions=computed(()=>sessions.value.filter(session=>!session.archiving));const selectedListSession=computed(()=>{return sessions.value.find(session=>session.sessionId===selectedSessionId.value)||null});const selectedSessionMissing=computed(()=>{const selectedId=String(selectedSessionId.value||``).trim();if(!selectedId||sessionList.pages.length<1||String(sessionList.loadError||``).trim()||sessionIdExistsInList(selectedId,sessions.value))return false;return true});const{selectionRenewalPredecessorId,selectionRenewalResource,syncRenewalSuccessorUrl}=useVibe64SelectedSessionRenewal({availableSessions,projectSlug,route,router,selectedListSession,selectedSessionId,selectedSessionMissing,sessionList,sessionsApiPath});const creationOptions=computed(()=>sessionList.pages?.[0]?.creation||{});const selectedSession=computed(()=>enrichVibe64SessionForDisplay(selectedListSession.value));const isSelectedSessionArchived=computed(()=>isArchivedVibe64Session(selectedSession.value||{}));const canCreateSession=computed(()=>{return creationOptions.value.canCreate===true});const createSessionVisible=computed(()=>creationOptions.value.showCreateAction===true);const createSessionTitle=computed(()=>{if(creationOptions.value.disabledReason)return String(creationOptions.value.disabledReason);if(creationOptions.value.canCreate!==true)return`Session creation is unavailable.`;return`Create a new Vibe64 session`});const selectedSessionTitle=computed(()=>{return vibe64SessionDisplayTitle(selectedSession.value||{})||`Session ${shortVibe64SessionId(selectedSessionId.value)}`});async function refreshSessionList(){return refetchEndpointResource(sessionListResource)}let refreshSessionDataInFlight=null;async function refreshSessionData(options={}){const reason=typeof options===`string`?options:String(options.reason||``);if(refreshSessionDataInFlight){vibe64SessionDebugLog(`client.sessionData.refresh.join`,{reason,selectedSessionId:String(selectedSessionId.value||``)});return refreshSessionDataInFlight}const startedAtMs=Date.now();vibe64SessionDebugLog(`client.sessionData.refresh.start`,{reason,selectedSessionId:String(selectedSessionId.value||``)});refreshSessionDataInFlight=refreshSessionList();try{const result=await refreshSessionDataInFlight;vibe64SessionDebugLog(`client.sessionData.refresh.done`,{durationMs:vibe64SessionDebugDurationMs(startedAtMs),reason,selectedSessionId:String(selectedSessionId.value||``),sessionCount:sessions.value.length});return result}catch(error){vibe64SessionDebugLog(`client.sessionData.refresh.error`,{durationMs:vibe64SessionDebugDurationMs(startedAtMs),error:vibe64SessionDebugError(error),reason,selectedSessionId:String(selectedSessionId.value||``)});throw error}finally{refreshSessionDataInFlight=null}}function refreshSessionDataInBackground(options={}){refreshSessionData(options).catch(()=>{})}function selectSessionId(sessionId=``){const normalizedSessionId=String(sessionId||``).trim();if(sessions.value.some(session=>session.sessionId===normalizedSessionId&&session.archiving))return;vibe64SessionDebugLog(`client.sessionData.selectSession`,{fromSessionId:String(selectedSessionId.value||``),toSessionId:normalizedSessionId});if(normalizedSessionId)emptySessionListObservedForProject=``;sessionSelection.select(normalizedSessionId)}function clearSelectedSession(){emptySessionListObservedForProject=selectionScope.value;sessionSelection.clear()}function selectPreviousSession(sessionId){const navigation=sessions.value;const index=navigation.findIndex(session=>session.sessionId===sessionId);selectSessionId(navigation.slice(0,Math.max(0,index)).filter(session=>!session.archiving).at(-1)?.sessionId||availableSessions.value.at(-1)?.sessionId||``)}const archive=proxyRefs(useVibe64SessionDialogs({beginArchive(sessionId){archiveAttempts.value[sessionId]={startedAt:new Date().toISOString(),session:sessions.value.find(session=>session.sessionId===sessionId)};if(selectedSessionId.value===sessionId)selectPreviousSession(sessionId);return projectSlug.value},finishArchive(sessionId,succeeded,archiveProject){if(projectSlug.value!==archiveProject)return;if(succeeded)archiveAttempts.value[sessionId]={succeeded:true};else{delete archiveAttempts.value[sessionId];if(!selectedSessionId.value)selectSessionId(sessionId)}},isSelectedSessionArchived,refreshSessionData,selectedSessionId,selectedSessionTitle,sessionsApiPath}));const archiveFeedback=useUiFeedback({source:`vibe64.sessions.archive.remote`});const shownArchiveFailures=new Set;watch(projectSlug,()=>{archiveAttempts.value={};agentActivityBySessionId.value={};shownArchiveFailures.clear()});useRealtimeEvent({event:VIBE64_SESSION_SUMMARY_CHANGED_EVENT,matches:({payload={}}={})=>vibe64SessionEventMatchesScope(payload,{projectSlug:projectSlug.value}),onEvent:({payload={}}={})=>{const id=String(payload.sessionId||``);if(!id)return;const activity=agentTurnRealtimeOverlayFromPayload(payload,id);if(activity)agentActivityBySessionId.value[id]=latestAgentTurnRealtimeOverlay(agentActivityBySessionId.value[id],{active:activity.active,revision:activity.revision});if(payload.reason===`session-archiving`){const session=sessions.value.find(item=>item.sessionId===id);if(session)archiveAttempts.value[id]={session,startedAt:archiveAttempts.value[id]?.startedAt||new Date().toISOString()};if(selectedSessionId.value===id)selectPreviousSession(id)}else if(payload.reason===`session-archived`)archiveAttempts.value[id]={succeeded:true};else if(payload.reason===`session-archive-failed`){delete archiveAttempts.value[id];if(!selectedSessionId.value)selectSessionId(id)}}});watch(()=>sessionList.items,items=>{for(const id of Object.keys(agentActivityBySessionId.value))if(!items.some(session=>session.sessionId===id))delete agentActivityBySessionId.value[id];for(const[id,attempt]of Object.entries(archiveAttempts.value)){if(attempt.succeeded||archive.archivingSessionId===id)continue;const session=items.find(item=>item.sessionId===id);if(!session||!sessionArchiveState(session).archiving)delete archiveAttempts.value[id]}});watch(sessions,items=>{for(const session of items){const key=`${session.sessionId}:${session.metadata?.session_archive_operation}`;if(!session.archiveError||shownArchiveFailures.has(key))continue;shownArchiveFailures.add(key);if(archive.archivingSessionId!==session.sessionId)archiveFeedback.error(new Error(session.archiveError))}},{immediate:true});function dropUnlistedRouteSession(){const query=routeQueryWithoutUnlistedSession({route,projectSlug:projectSlug.value,sessions:sessions.value});if(query)router.replace({path:route.path,hash:route.hash,query}).catch(()=>null)}const selectionReconciliationState=computed(()=>{const nextSessions=availableSessions.value;return{createSessionRunning:createSessionRunning.value,currentSessionApiPath:currentSessionApiPath.value,selectionScope:selectionScope.value,selectionRenewal:selectionRenewalResource.data.value?.renewal||null,selectionRenewalLoadError:String(selectionRenewalResource.loadError?.value||``),selectionRenewalLoaded:Boolean(selectionRenewalResource.data.value&&typeof selectionRenewalResource.data.value===`object`&&!Array.isArray(selectionRenewalResource.data.value)),selectionRenewalLoading:Boolean(selectionRenewalResource.isInitialLoading?.value||selectionRenewalResource.isLoading?.value),selectionRenewalPredecessorId:selectionRenewalPredecessorId.value,projectSlug:String(projectSlug.value||``).trim(),selectedSessionMissing:selectedSessionMissing.value,nextSessions,selectedSessionId:String(selectedSessionId.value||``),sessionListInitialLoading:sessionList.isInitialLoading,sessionListLoaded:sessionList.pages.length>0,sessionListLoadError:String(sessionList.loadError||``),sessionListLoading:sessionList.isLoading}});watch(selectionReconciliationState,state=>{const nextSessions=state.nextSessions;if(sessions.value.some(session=>session.sessionId===state.selectedSessionId&&session.archiving)){selectPreviousSession(state.selectedSessionId);return}vibe64SessionDebugLog(`client.sessionData.sessions.changed`,{selectedSessionId:String(selectedSessionId.value||``),sessionCount:nextSessions.length});if(state.sessionListInitialLoading||state.sessionListLoadError||shouldPreserveSelectedSessionDuringRefresh({createSessionRunning:state.createSessionRunning,currentSessionId:state.selectedSessionId,nextSessions,sessionListLoading:state.sessionListLoading}))return;if(!state.selectedSessionId&&nextSessions.length===0)emptySessionListObservedForProject=state.selectionScope;if(state.selectionRenewalPredecessorId){if(state.selectionRenewalLoading||state.selectionRenewalLoadError||!state.selectionRenewalLoaded)return;const selectionRenewal=state.selectionRenewal;if(selectionRenewal&&String(selectionRenewal.sessionId||``).trim()===state.selectionRenewalPredecessorId){const renewalStatus=String(selectionRenewal.status||``).trim();if(renewalStatus===`completed`){const renewedSuccessorId=renewedSuccessorSessionId({predecessorSessionId:state.selectionRenewalPredecessorId,sessions:nextSessions});if(state.selectedSessionMissing){if(renewedSuccessorId)sessionSelection.selectAvailableId(nextSessions,{fallbackId:renewedSuccessorId,getId:session=>session.sessionId})}if(renewedSuccessorId&&selectedSessionId.value===renewedSuccessorId)syncRenewalSuccessorUrl(state.selectionRenewalPredecessorId,renewedSuccessorId);if(state.selectedSessionMissing)return}else if(state.selectedSessionMissing&&[`failed`,`running`].includes(renewalStatus))return;if([`failed`,`running`].includes(renewalStatus)){sessionSelection.select(state.selectionRenewalPredecessorId);return}}}if(!state.selectionRenewalPredecessorId)dropUnlistedRouteSession();if(!state.selectedSessionId&&emptySessionListObservedForProject===state.selectionScope)return;sessionSelection.selectAvailableId(nextSessions,{fallbackId:nextSessions.at(-1)?.sessionId||``,getId:session=>session.sessionId})},{immediate:true});useVibe64CurrentSessionPublication({selectionReconciliationState});return{archive,canCreateSession,clearSelectedSession,createSession,createSessionCommand,createSessionRunning,createSessionVisible,createSessionTitle,isSelectedSessionArchived,refreshSessionData,selectSessionId,selectedSession,selectedSessionId,selectedSessionTitle,sessionList,sessions,sessionsApiPath,shortSessionId:shortVibe64SessionId}}export{mountedSessionDetailRefreshReason as a,sessionRecordHasActiveAgentWork as c,sessionWithAgentTurnRealtimeOverlay as d,refetchEndpointResource as f,mountedSessionDetailLoadState as i,agentTurnRealtimeOverlayFromPayload as l,useVibe64SessionData as n,mountedSessionRealtimeShouldRefresh as o,latestSessionDetailRecord as r,mountedSessionRecord as s,sessionListRealtimeShouldRefresh as t,latestAgentTurnRealtimeOverlay as u};
@@ -1 +1 @@
1
- import{Et as unref,Tt as toValue,it as watch,u as computed,vt as ref}from"./runtime-core.esm-bundler-Bi1P1jMa.js";import{g as useRoute}from"./useApi-BPuI6ZR9-rsYWyW6m.js";import{t as browserSessionStorage}from"./browser-D8z6v6Ge.js";import{p as selectedSessionStorageKey}from"./vibe64SessionRequestConfig-DVRCRAex.js";import{N as useVibe64ProjectSlug}from"./index-tPEeYKmw.js";function readStoredValue(storageKey=``){try{return String(browserSessionStorage()?.getItem(storageKey)||``)}catch{return``}}function writeStoredValue(storageKey=``,value=``){try{const storage=browserSessionStorage();if(!storage)return;const normalizedValue=String(value||``).trim();if(normalizedValue){storage.setItem(storageKey,normalizedValue);return}storage.removeItem(storageKey)}catch{}}function readStorageKey(storageKey=``){return String(toValue(storageKey)||``).trim()}function readPreferredId(preferredId=``){return String(toValue(preferredId)||``).trim()}function useStoredSelection({preferredId=``,rememberedId,storageKey=``,enabled=true}){const selectionEnabled=computed(()=>Boolean(toValue(enabled)));const activeStorageKey=computed(()=>readStorageKey(storageKey));const activePreferredId=computed(()=>readPreferredId(preferredId));const restoredId=(key=activeStorageKey.value)=>rememberedId===void 0?readStoredValue(key):readPreferredId(rememberedId);const selectedId=ref(selectionEnabled.value?activePreferredId.value||restoredId():``);function select(id=``){if(!selectionEnabled.value)return;selectedId.value=String(id||``).trim();writeStoredValue(activeStorageKey.value,selectedId.value)}function clear(){select(``)}function selectAvailableId(items=[],{fallbackId=``,getId=item=>item?.id}={}){if(!selectionEnabled.value)return``;if(items.length===0){clear();return``}const itemIds=items.map(item=>String(getId(item)||``).trim()).filter(Boolean);if(itemIds.includes(selectedId.value)){select(selectedId.value);return selectedId.value}const preferredSelectionId=activePreferredId.value;if(itemIds.includes(preferredSelectionId)){select(preferredSelectionId);return selectedId.value}const restoredSelectionId=restoredId();select(itemIds.includes(restoredSelectionId)?restoredSelectionId:String(fallbackId||``).trim());return selectedId.value}function capture(){const key=activeStorageKey.value;const admitted=selectionEnabled.value;return Object.freeze({select(id=``){if(!admitted)return;const value=String(id||``).trim();writeStoredValue(key,value);if(selectionEnabled.value&&activeStorageKey.value===key)selectedId.value=value}})}watch(selectionEnabled,nextEnabled=>{selectedId.value=nextEnabled?activePreferredId.value||restoredId():``},{flush:`sync`});watch(activeStorageKey,nextStorageKey=>{if(selectionEnabled.value)selectedId.value=activePreferredId.value||restoredId(nextStorageKey)});watch(activePreferredId,nextPreferredId=>{if(selectionEnabled.value&&nextPreferredId)selectedId.value=nextPreferredId});return{capture,clear,select,selectAvailableId,selectedId}}function selectedSessionIdFromRoute(route={}){const rawValue=route.query?.session;const value=Array.isArray(rawValue)?rawValue[0]:rawValue;return String(value||``).trim()}function useVibe64SessionSelection({projectSlug=useVibe64ProjectSlug(),rememberedId,route=useRoute()}){return useStoredSelection({preferredId:computed(()=>selectedSessionIdFromRoute(route)),rememberedId,storageKey:computed(()=>selectedSessionStorageKey(unref(projectSlug)))})}export{useVibe64SessionSelection as n,selectedSessionIdFromRoute as t};
1
+ import{Et as unref,Tt as toValue,it as watch,u as computed,vt as ref}from"./runtime-core.esm-bundler-Bi1P1jMa.js";import{g as useRoute}from"./useApi-BPuI6ZR9-rsYWyW6m.js";import{t as browserSessionStorage}from"./browser-D8z6v6Ge.js";import{p as selectedSessionStorageKey}from"./vibe64SessionRequestConfig-DVRCRAex.js";import{N as useVibe64ProjectSlug}from"./index-DAareKn3.js";function readStoredValue(storageKey=``){try{return String(browserSessionStorage()?.getItem(storageKey)||``)}catch{return``}}function writeStoredValue(storageKey=``,value=``){try{const storage=browserSessionStorage();if(!storage)return;const normalizedValue=String(value||``).trim();if(normalizedValue){storage.setItem(storageKey,normalizedValue);return}storage.removeItem(storageKey)}catch{}}function readStorageKey(storageKey=``){return String(toValue(storageKey)||``).trim()}function readPreferredId(preferredId=``){return String(toValue(preferredId)||``).trim()}function useStoredSelection({preferredId=``,rememberedId,storageKey=``,enabled=true}){const selectionEnabled=computed(()=>Boolean(toValue(enabled)));const activeStorageKey=computed(()=>readStorageKey(storageKey));const activePreferredId=computed(()=>readPreferredId(preferredId));const restoredId=(key=activeStorageKey.value)=>rememberedId===void 0?readStoredValue(key):readPreferredId(rememberedId);const selectedId=ref(selectionEnabled.value?activePreferredId.value||restoredId():``);function select(id=``){if(!selectionEnabled.value)return;selectedId.value=String(id||``).trim();writeStoredValue(activeStorageKey.value,selectedId.value)}function clear(){select(``)}function selectAvailableId(items=[],{fallbackId=``,getId=item=>item?.id}={}){if(!selectionEnabled.value)return``;if(items.length===0){clear();return``}const itemIds=items.map(item=>String(getId(item)||``).trim()).filter(Boolean);if(itemIds.includes(selectedId.value)){select(selectedId.value);return selectedId.value}const preferredSelectionId=activePreferredId.value;if(itemIds.includes(preferredSelectionId)){select(preferredSelectionId);return selectedId.value}const restoredSelectionId=restoredId();select(itemIds.includes(restoredSelectionId)?restoredSelectionId:String(fallbackId||``).trim());return selectedId.value}function capture(){const key=activeStorageKey.value;const admitted=selectionEnabled.value;return Object.freeze({select(id=``){if(!admitted)return;const value=String(id||``).trim();writeStoredValue(key,value);if(selectionEnabled.value&&activeStorageKey.value===key)selectedId.value=value}})}watch(selectionEnabled,nextEnabled=>{selectedId.value=nextEnabled?activePreferredId.value||restoredId():``},{flush:`sync`});watch(activeStorageKey,nextStorageKey=>{if(selectionEnabled.value)selectedId.value=activePreferredId.value||restoredId(nextStorageKey)});watch(activePreferredId,nextPreferredId=>{if(selectionEnabled.value&&nextPreferredId)selectedId.value=nextPreferredId});return{capture,clear,select,selectAvailableId,selectedId}}function selectedSessionIdFromRoute(route={}){const rawValue=route.query?.session;const value=Array.isArray(rawValue)?rawValue[0]:rawValue;return String(value||``).trim()}function useVibe64SessionSelection({projectSlug=useVibe64ProjectSlug(),rememberedId,route=useRoute()}){return useStoredSelection({preferredId:computed(()=>selectedSessionIdFromRoute(route)),rememberedId,storageKey:computed(()=>selectedSessionStorageKey(unref(projectSlug)))})}export{useVibe64SessionSelection as n,selectedSessionIdFromRoute as t};
@@ -1 +1 @@
1
- import{$ as useId,Et as unref,G as renderList,H as openBlock,K as renderSlot,Kt as normalizeClass,N as nextTick,O as inject,Tt as toValue,Xt as toDisplayString,_ as createSlots,b as createVNode,d as createBaseVNode,f as createBlock,gt as reactive,i as Fragment,it as watch,m as createElementBlock,mt as onScopeDispose,ot as withCtx,p as createCommentVNode,st as withDirectives,u as computed,vt as ref,xt as shallowRef,y as createTextVNode}from"./runtime-core.esm-bundler-Bi1P1jMa.js";import{S as VIcon,cr as vShow,lr as withKeys,mt as useDisplay,ur as withModifiers}from"./VChip-D2IukBZw.js";import{s as normalizeObject}from"./normalize-BD25VwNK.js";import{r as VProgressCircular,t as VBtn}from"./VBtn-2vbH580C.js";import{t as VDialog}from"./VDialog-BCIrX462.js";import{t as _plugin_vue_export_helper_default}from"./_plugin-vue_export-helper-DNW4j-dv.js";import{y as LongTextInlineParts_default}from"./conversation-wiDH8Ni4.js";import{r as useRealtimeEvent}from"./useRealtimeEvent-B4oRg9Dt.js";var VIBE64_AI_TASKS_KEY=Symbol(`vibe64.ai-tasks`);var NO_AI_TASKS=Object.freeze({available:false});var AI_TASK_PHASES=Object.freeze({STARTING:`starting`,WORKING:`working`,CHECKING:`checking`,NEEDS_YOU:`needs_you`,CANCELLING:`cancelling`,DONE:`done`,NOT_DONE:`not_done`});var AI_TASK_REASONS=Object.freeze({AI_STUCK:`ai_stuck`,AI_UNAVAILABLE:`ai_unavailable`,ARCHIVED:`archived`,CANCELLED:`cancelled`,CHECK_STUCK:`check_stuck`,DRAFT_WAITING:`draft_waiting`,INTERRUPTED:`interrupted`,NO_RESULT:`no_result`,QUESTION:`question`,STOPPED:`stopped`,TURN_FAILED:`turn_failed`,UNCONFIRMED:`unconfirmed`,YOUR_TURN:`your_turn`});var AI_TASK_CHECKERS=Object.freeze({AGENT:`agent`,PERSON:`person`,VIBE64:`vibe64`});var AI_TASK_ACTIVE_PHASES=Object.freeze([AI_TASK_PHASES.STARTING,AI_TASK_PHASES.WORKING,AI_TASK_PHASES.CHECKING,AI_TASK_PHASES.CANCELLING]);var AI_TASK_ENDED_PHASES=Object.freeze([AI_TASK_PHASES.DONE,AI_TASK_PHASES.NOT_DONE]);function aiTaskEnded(task){return AI_TASK_ENDED_PHASES.includes(task.phase)}var AI_TASK_MESSAGES=Object.freeze({actions:Object.freeze({aiSetup:`Open AI setup`,answer:`Answer`,back:`Back`,cancel:`Cancel`,cancelling:`Cancelling…`,checkNow:`Check now`,close:`Close`,closing:`Closing…`,continue:`Continue`,details:`Details`,endNotDone:`End as not done`,finish:`Finish`,hide:`Hide`,keepGoing:`Keep going`,openChat:`Open chat`,review:`Review resolved conflicts`,waitForAi:`Wait for the AI`}),button:Object.freeze({busy:`Being fixed…`,fix:`Fix it with AI`,opening:`Opening…`,result:`See result`}),chat:Object.freeze({answer:`Type your answer…`,message:`Message the AI…`}),outcome:Object.freeze({done:`Done`,notDone:`Not done`,problem:`The problem`,seeConversation:`See the conversation`,showResult:`Show the result`,whatHappened:`What happened`,whatTheAiDid:`What the AI did`,whatsNext:`What's next`}),progress:Object.freeze({activity:`Activity`,unavailable:`Nothing is lost. The fix continues from here.`}),status:Object.freeze({aiStuck:`The AI could not finish this`,aiUnavailable:`The AI account can't run this right now`,cancelling:`Cancelling…`,draftWaiting:`The check failed. Your unsent message is waiting.`,interrupted:`Vibe64 restarted while the AI was working`,noResult:`The AI stopped without saying it finished`,question:`The AI needs your answer`,starting:`Starting…`,stopped:`Stopped. Tell the AI what to do next.`,turnFailed:`The AI ran into an error`,unconfirmed:`Vibe64 couldn't confirm the result`,working:`The AI is working on this`,yourTurn:`Your turn`}),tray:Object.freeze({cancelling:`Cancelling…`,done:`Done`,needsYou:`Needs you`,notDone:`Not done`,yourTurn:`Your turn`}),views:Object.freeze({chat:`Chat`,label:`Task views`,progress:`Progress`,waiting:`The AI is waiting for your answer`}),closeFailed:`That didn't finish. Try again.`,requestFailed:`That didn't reach Vibe64. Try again.`,attempt:(attempt,limit)=>`Attempt ${attempt} of ${limit}`,retrying:(attempt,limit)=>`The AI is trying again (attempt ${attempt} of ${limit})`,cancelQuestion:noun=>`Cancel this ${noun}? The AI stops. Anything it has changed stays in the session.`,cancelConfirm:noun=>`Cancel ${noun}`,cancelledByYou:noun=>`You cancelled this ${noun}.`,cancelledBy:(name,noun)=>`${name} cancelled this ${noun}.`,mainChatSince:time=>time?`The main chat's AI has been working since ${time}.`:`The main chat's AI is working.`,whatsNext:()=>`The problem is still there. Anything the AI changed stays in the session. To try again, close this and choose Fix it with AI.`,toast:(title,outcome)=>`${title}: ${outcome}.`});var AI_TASK_ACTIONS=Object.freeze({AI_SETUP:`ai-setup`,ANSWER:`answer`,CHECK:`check`,CONTINUE:`continue`,END:`end`,FINISH:`finish`,OPEN_CHAT:`open-chat`,REVIEW:`review`,RUN_NOW:`run-now`,WAIT_FOR_AI:`wait-for-ai`});var action=(id,label,primary=false)=>Object.freeze({id,label,primary});var OPEN_CHAT=action(AI_TASK_ACTIONS.OPEN_CHAT,AI_TASK_MESSAGES.actions.openChat);var CHECK_NOW=action(AI_TASK_ACTIONS.CHECK,AI_TASK_MESSAGES.actions.checkNow,true);var CONTINUE=action(AI_TASK_ACTIONS.CONTINUE,AI_TASK_MESSAGES.actions.continue,true);var NEEDS_YOU=Object.freeze({[AI_TASK_REASONS.QUESTION]:{status:AI_TASK_MESSAGES.status.question,chat:true,dot:true,actions:[action(AI_TASK_ACTIONS.ANSWER,AI_TASK_MESSAGES.actions.answer,true)]},[AI_TASK_REASONS.YOUR_TURN]:{glyph:`turn`,status:AI_TASK_MESSAGES.status.yourTurn,tray:AI_TASK_MESSAGES.tray.yourTurn,chat:true,dot:true,actions:[action(AI_TASK_ACTIONS.FINISH,AI_TASK_MESSAGES.actions.finish,true)]},[AI_TASK_REASONS.AI_STUCK]:{status:AI_TASK_MESSAGES.status.aiStuck,chat:true,actions:[action(AI_TASK_ACTIONS.END,AI_TASK_MESSAGES.actions.endNotDone),action(AI_TASK_ACTIONS.OPEN_CHAT,AI_TASK_MESSAGES.actions.openChat,true)]},[AI_TASK_REASONS.CHECK_STUCK]:{check:true,diagnostic:true,actions:[OPEN_CHAT,CHECK_NOW]},[AI_TASK_REASONS.NO_RESULT]:{status:AI_TASK_MESSAGES.status.noResult,actions:[OPEN_CHAT,CHECK_NOW]},[AI_TASK_REASONS.STOPPED]:{status:AI_TASK_MESSAGES.status.stopped,actions:[OPEN_CHAT,CONTINUE]},[AI_TASK_REASONS.AI_UNAVAILABLE]:{status:AI_TASK_MESSAGES.status.aiUnavailable,note:AI_TASK_MESSAGES.progress.unavailable,actions:[action(AI_TASK_ACTIONS.AI_SETUP,AI_TASK_MESSAGES.actions.aiSetup),CONTINUE]},[AI_TASK_REASONS.TURN_FAILED]:{status:AI_TASK_MESSAGES.status.turnFailed,actions:[OPEN_CHAT,CONTINUE]},[AI_TASK_REASONS.INTERRUPTED]:{status:AI_TASK_MESSAGES.status.interrupted,actions:[CONTINUE]},[AI_TASK_REASONS.UNCONFIRMED]:{status:AI_TASK_MESSAGES.status.unconfirmed,check:true,actions:[CHECK_NOW]},[AI_TASK_REASONS.DRAFT_WAITING]:{status:AI_TASK_MESSAGES.status.draftWaiting,chat:true,check:true,diagnostic:true,actions:[action(AI_TASK_ACTIONS.OPEN_CHAT,AI_TASK_MESSAGES.actions.openChat,true)]}});function stepsOf(task,needs){const[work,check]=task.steps;const counted=task.check.retryLimit>0?AI_TASK_MESSAGES.attempt(task.attempt,task.check.retryLimit):``;const ended=aiTaskEnded(task);const atCheck=task.phase===AI_TASK_PHASES.CHECKING||task.checkRunning||needs?.check===true;const passed=task.phase===AI_TASK_PHASES.DONE;const workState=passed||atCheck?`done`:ended?`failed`:`active`;const checkState=passed?`done`:needs?.check||ended&&atCheck?`failed`:atCheck?`active`:`pending`;const steps=[{label:work,state:workState,attempt:workState===`active`?counted:``}];if(check)steps.push({label:check,state:checkState,attempt:atCheck&&!ended?counted:``});return steps}function endedMessage(task,viewerId){if(task.message)return task.message;const by=task.endedBy;return by?.name&&by.id!==viewerId?AI_TASK_MESSAGES.cancelledBy(by.name,task.noun):AI_TASK_MESSAGES.cancelledByYou(task.noun)}function outcomeOf(task,viewerId){if(task.phase===AI_TASK_PHASES.DONE)return{heading:AI_TASK_MESSAGES.outcome.done,happened:task.message,report:task.report,next:``};return{heading:AI_TASK_MESSAGES.outcome.notDone,happened:endedMessage(task,viewerId),report:``,next:AI_TASK_MESSAGES.whatsNext()}}function runningStatus(task){if(task.phase===AI_TASK_PHASES.STARTING)return AI_TASK_MESSAGES.status.starting;if(task.phase===AI_TASK_PHASES.CANCELLING)return AI_TASK_MESSAGES.status.cancelling;if(task.phase===AI_TASK_PHASES.CHECKING)return task.waiting?task.message:task.check.label;return task.attempt>1?AI_TASK_MESSAGES.retrying(task.attempt,task.check.retryLimit):AI_TASK_MESSAGES.status.working}function noteOf(task,needs){if(task.phase===AI_TASK_PHASES.CANCELLING)return task.checkRunning?task.check.unstoppable:``;if(!needs)return``;return[needs.status&&task.message!==needs.status?task.message:``,needs.diagnostic&&!task.message.includes(task.diagnostic)?task.diagnostic:``,needs.note].filter(Boolean).join(` `)}function projectAiTask(task,{viewerId}){const ended=aiTaskEnded(task);const needs=task.phase===AI_TASK_PHASES.NEEDS_YOU?NEEDS_YOU[task.reason]:null;const whileAiWorks=task.phase===AI_TASK_PHASES.CHECKING&&task.waiting&&task.mainChatSince?task.check.whileAiWorks:null;const review=needs?.check&&task.reason===AI_TASK_REASONS.CHECK_STUCK&&task.conflictReview?[action(AI_TASK_ACTIONS.REVIEW,AI_TASK_MESSAGES.actions.review)]:[];const done=task.phase===AI_TASK_PHASES.DONE;const running=!ended&&!needs;return{glyph:done?`done`:ended?`not-done`:needs?needs.glyph||`attention`:`working`,status:done?AI_TASK_MESSAGES.outcome.done:ended?AI_TASK_MESSAGES.outcome.notDone:needs?needs.status||task.message:runningStatus(task),tray:done?AI_TASK_MESSAGES.tray.done:ended?AI_TASK_MESSAGES.tray.notDone:task.phase===AI_TASK_PHASES.CANCELLING?AI_TASK_MESSAGES.tray.cancelling:needs?needs.tray||AI_TASK_MESSAGES.tray.needsYou:task.tray,ended,chatDot:needs?.dot===true,opensOn:needs?.chat?`chat`:`progress`,composerOpen:Boolean(needs)||task.phase===AI_TASK_PHASES.WORKING,composerHint:task.reason===AI_TASK_REASONS.QUESTION?AI_TASK_MESSAGES.chat.answer:AI_TASK_MESSAGES.chat.message,note:whileAiWorks?`${AI_TASK_MESSAGES.mainChatSince(aiTaskTime(task.mainChatSince))} ${whileAiWorks.note}`:running&&task.phase!==AI_TASK_PHASES.CANCELLING?``:noteOf(task,needs),steps:stepsOf(task,needs),actions:needs?[...review,...needs.actions]:whileAiWorks?[action(AI_TASK_ACTIONS.WAIT_FOR_AI,AI_TASK_MESSAGES.actions.waitForAi),action(AI_TASK_ACTIONS.RUN_NOW,whileAiWorks.action,true)]:[],cancelQuestion:AI_TASK_MESSAGES.cancelQuestion(task.noun),outcome:ended?outcomeOf(task,viewerId):null}}function aiTaskFooterActions(actions,view){if(view!==`chat`)return actions;return actions.filter(({id})=>id!==AI_TASK_ACTIONS.ANSWER&&id!==AI_TASK_ACTIONS.OPEN_CHAT)}function aiTaskTime(at){const date=new Date(at);return Number.isNaN(date.getTime())?``:date.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}var SESSION_CHANGED_EVENT=`vibe64.session.changed`;var AI_TASK_CHANGED=`ai-task-changed`;function useAiTasks({sessionId,sessionsApiPath,projectSlug,enabled,request,onClosed}){const task=shallowRef(null);const loaded=ref(false);const error=ref(``);const cancelRequested=ref(false);const closing=ref(false);const starting=ref(false);const viewerId=ref(``);let readGeneration=0;const tasksPath=()=>`${toValue(sessionsApiPath)}/${encodeURIComponent(toValue(sessionId))}/ai-tasks`;const taskPath=(suffix=``)=>`${tasksPath()}/${encodeURIComponent(task.value.id)}${suffix}`;function remember(next){if(task.value?.id===next.id&&next.revision<task.value.revision)return;task.value=next}async function load(){const generation=++readGeneration;if(!toValue(enabled)||!toValue(sessionId))return;try{const{tasks,viewerId:viewer}=await request(tasksPath(),{method:`GET`});if(generation!==readGeneration)return;viewerId.value=viewer;const[saved=null]=tasks;if(saved)remember(saved);else task.value=null;loaded.value=true}catch{}}async function start(kind,input){error.value=``;starting.value=true;try{const answer=await request(tasksPath(),{method:`POST`,body:{kind,input}});remember(answer.task);return answer.task}catch(failure){error.value=failure.message||AI_TASK_MESSAGES.requestFailed;return null}finally{starting.value=false}}async function act(suffix,body={}){error.value=``;try{remember((await request(taskPath(suffix),{method:`POST`,body})).task)}catch(failure){error.value=failure.message||AI_TASK_MESSAGES.requestFailed;load()}}async function cancel(){cancelRequested.value=true;await act(`/cancel`);cancelRequested.value=false}const check=(input={})=>act(`/check`,input);const continueTask=()=>act(`/continue`);const finish=()=>act(`/finish`);async function close(){error.value=``;closing.value=true;try{await request(taskPath(),{method:`DELETE`});task.value=null}catch{error.value=AI_TASK_MESSAGES.closeFailed}finally{closing.value=false}}const matchesSession=payload=>payload.projectSlug===toValue(projectSlug)&&payload.sessionId===toValue(sessionId)&&payload.reason===AI_TASK_CHANGED;useRealtimeEvent({enabled:computed(()=>toValue(enabled)),event:SESSION_CHANGED_EVENT,matches:({payload={}}={})=>matchesSession(payload),onEvent({payload}){if(payload.aiTask){remember(payload.aiTask);return}if(payload.aiTaskClosed?.id!==task.value?.id)return;const closedHere=closing.value;task.value=null;if(!closedHere)onClosed(payload.aiTaskClosed)}});useRealtimeEvent({enabled:computed(()=>toValue(enabled)),event:`connect`,onEvent:()=>void load()});watch(()=>[toValue(sessionId),toValue(enabled)],([,on],previous)=>{if(previous?.[0]!==toValue(sessionId)){task.value=null;loaded.value=false}if(on)load()},{immediate:true});return{cancel,cancelRequested,check,close,closing,continueTask,error,finish,load,loaded,start,starting,task,viewerId}}var WINDOW_QUERY=`aiTask`;function useAiTaskWindow({task,loaded,active,opensOn,route,router}){const view=ref(`progress`);const transcriptOpen=ref(false);let opener=null;const wanted=computed(()=>String(route.query[WINDOW_QUERY]||``));const open=computed(()=>toValue(active)&&Boolean(wanted.value)&&toValue(task)?.id===wanted.value);function withoutWindow(){const{[WINDOW_QUERY]:_taskId,...query}=route.query;return{path:route.path,query,hash:route.hash}}async function show(element=null){const current=toValue(task);if(!current)return;opener=element;if(open.value)return;await router.push({path:route.path,query:{...route.query,[WINDOW_QUERY]:current.id},hash:route.hash})}function hide(){if(wanted.value)router.replace(withoutWindow())}function setView(next){view.value=next}watch(open,isOpen=>{if(!isOpen)return;view.value=toValue(opensOn);transcriptOpen.value=false},{immediate:true});watch(()=>[wanted.value,toValue(loaded),toValue(task)?.id,toValue(active)],()=>{if(wanted.value&&toValue(active)&&toValue(loaded)&&toValue(task)?.id!==wanted.value)router.replace(withoutWindow())},{immediate:true});return{hide,open,opener:()=>opener?.isConnected?opener:null,setView,show,transcriptOpen,view}}function useAiTaskHost({sessionId,sessionsApiPath,projectSlug,enabled,active,request,route,router,openAiSetup,reviewResolved,fallbackFocus}){const toast=ref(null);const tasks=useAiTasks({sessionId,sessionsApiPath,projectSlug,enabled,request,onClosed(closed){const heading=closed.phase===`done`?AI_TASK_MESSAGES.outcome.done:AI_TASK_MESSAGES.outcome.notDone;toast.value={text:AI_TASK_MESSAGES.toast(closed.title,heading),action:false}}});const projection=computed(()=>tasks.task.value&&projectAiTask(tasks.task.value,{viewerId:tasks.viewerId.value}));const taskWindow=useAiTaskWindow({task:tasks.task,loaded:tasks.loaded,active,opensOn:()=>projection.value?.opensOn||`progress`,route,router});function returnFocusTarget(){return taskWindow.opener()||document.querySelector(`[data-vibe64-ai-task-tray]`)||fallbackFocus()}async function start(kind,opener,input){const task=await tasks.start(kind,input);if(task)await nextTick();if(task)taskWindow.show(opener);else toast.value={text:tasks.error.value,action:false};return task}async function close(){const target=returnFocusTarget();await tasks.close();if(tasks.task.value)return;taskWindow.hide();await nextTick();(target?.isConnected?target:fallbackFocus())?.focus({preventScroll:true})}async function waitForAi(){taskWindow.hide();await nextTick();fallbackFocus()?.focus({preventScroll:true})}function run(actionId){const{task}=tasks;if(actionId===AI_TASK_ACTIONS.ANSWER||actionId===AI_TASK_ACTIONS.OPEN_CHAT)taskWindow.setView(`chat`);else if(actionId===AI_TASK_ACTIONS.CHECK)tasks.check();else if(actionId===AI_TASK_ACTIONS.RUN_NOW)tasks.check({whileAiWorks:true});else if(actionId===AI_TASK_ACTIONS.WAIT_FOR_AI)waitForAi();else if(actionId===AI_TASK_ACTIONS.CONTINUE)tasks.continueTask();else if(actionId===AI_TASK_ACTIONS.FINISH)tasks.finish();else if(actionId===AI_TASK_ACTIONS.END)tasks.cancel();else if(actionId===AI_TASK_ACTIONS.AI_SETUP)openAiSetup();else if(actionId===AI_TASK_ACTIONS.REVIEW&&task.value)reviewResolved()}function seeToastResult(){toast.value=null;taskWindow.show(null)}watch(()=>tasks.task.value&&aiTaskEnded(tasks.task.value),(ended,wasEnded)=>{if(!ended||wasEnded!==false||taskWindow.open.value||!toValue(active))return;toast.value={text:AI_TASK_MESSAGES.toast(tasks.task.value.title,projection.value.outcome.heading),action:true}});return reactive({cancel:tasks.cancel,cancelRequested:tasks.cancelRequested,check:tasks.check,close,closing:tasks.closing,error:tasks.error,hide:taskWindow.hide,open:taskWindow.open,projection,returnFocusTarget,run,seeToastResult,setTranscript:open=>{taskWindow.transcriptOpen.value=open},setView:taskWindow.setView,show:taskWindow.show,start,starting:tasks.starting,task:tasks.task,toast,transcriptOpen:taskWindow.transcriptOpen,view:taskWindow.view})}var _sfc_main$4={__name:`Vibe64AiTaskButton`,props:{kind:{required:true,type:String},allowed:{required:true,type:Boolean},title:{required:true,type:String},input:{required:true,type:Object}},emits:[`done`],setup(__props,{emit:__emit}){const props=__props;const emit=__emit;const tasks=inject(VIBE64_AI_TASKS_KEY);const own=computed(()=>tasks.task?.kind===props.kind?tasks.task:null);const linked=computed(()=>Boolean(own.value));const label=computed(()=>{if(tasks.starting)return AI_TASK_MESSAGES.button.opening;if(!own.value)return AI_TASK_MESSAGES.button.fix;return tasks.projection.ended?AI_TASK_MESSAGES.button.result:AI_TASK_MESSAGES.button.busy});const disabled=computed(()=>!own.value&&(!props.allowed||tasks.starting));watch(()=>own.value?.phase===AI_TASK_PHASES.DONE?own.value.id:``,doneId=>{if(doneId)emit(`done`)});function activate(event){const opener=event.currentTarget;if(own.value)tasks.show(opener);else tasks.start(props.kind,opener,props.input)}return(_ctx,_cache)=>{return openBlock(),createBlock(VBtn,{"aria-busy":label.value===unref(AI_TASK_MESSAGES).button.opening?`true`:void 0,class:`vibe64-ai-task-button`,"data-vibe64-ai-task-button":``,disabled:disabled.value,"prepend-icon":`$smartToy`,size:`small`,title:__props.title,type:`button`,variant:`tonal`,onClick:activate},createSlots({default:withCtx(()=>[createTextVNode(toDisplayString(label.value)+` `,1)]),_:2},[linked.value?{name:`append`,fn:withCtx(()=>[createVNode(VIcon,{icon:`$arrowForward`,size:`16`,"aria-hidden":`true`})]),key:`0`}:void 0]),1032,[`aria-busy`,`disabled`,`title`])}}};var Vibe64AiTaskButton_default=_plugin_vue_export_helper_default(_sfc_main$4,[[`__scopeId`,`data-v-2233af9d`]]);var _hoisted_1$3=[`aria-label`,`title`];var _hoisted_2$3={class:`vibe64-ai-task-tray__label`};var _sfc_main$3={__name:`Vibe64AiTaskTray`,setup(__props){const tasks=inject(VIBE64_AI_TASKS_KEY);const glyphIcons={attention:`$errorFilled`,done:`$checkCircleFilled`,"not-done":`$cancel`,turn:`$circle`};return(_ctx,_cache)=>{return openBlock(),createElementBlock(`button`,{"aria-label":`${unref(tasks).task.title}: ${unref(tasks).projection.tray}`,class:normalizeClass([`vibe64-ai-task-tray`,`vibe64-ai-task-tray--${unref(tasks).projection.glyph}`]),"data-vibe64-ai-task-tray":``,title:unref(tasks).projection.tray,type:`button`,onClick:_cache[0]||(_cache[0]=$event=>unref(tasks).show($event.currentTarget))},[unref(tasks).projection.glyph===`working`?(openBlock(),createBlock(VProgressCircular,{key:0,indeterminate:``,size:`16`,width:`2`,"aria-hidden":`true`})):(openBlock(),createBlock(VIcon,{key:1,icon:glyphIcons[unref(tasks).projection.glyph],size:`18`,"aria-hidden":`true`},null,8,[`icon`])),createBaseVNode(`span`,_hoisted_2$3,toDisplayString(unref(tasks).projection.tray),1)],10,_hoisted_1$3)}}};var Vibe64AiTaskTray_default=_plugin_vue_export_helper_default(_sfc_main$3,[[`__scopeId`,`data-v-56857b35`]]);var PHONE_WIDTH=600;var SHORT_HEIGHT=560;var EXPANDED_WIDTH=960;function aiTaskFit(width,height){const phone=width<PHONE_WIDTH;if(phone||height<SHORT_HEIGHT)return{fullscreen:true,phone,width:void 0,height:void 0};return width<EXPANDED_WIDTH?{fullscreen:false,phone,width:`min(92vw, 46rem)`,height:`88dvh`}:{fullscreen:false,phone,width:`46rem`,height:`min(80dvh, 46rem)`}}var REDUCED_MOTION=`(prefers-reduced-motion: reduce)`;function useAiTaskFocus({title,views,selectedView,setView,returnFocusTarget}){const tabElements=new Map;const motionQuery=globalThis.matchMedia(REDUCED_MOTION);const reducedMotion=ref(motionQuery.matches);const noteMotion=event=>{reducedMotion.value=event.matches};motionQuery.addEventListener(`change`,noteMotion);onScopeDispose(()=>motionQuery.removeEventListener(`change`,noteMotion));function focusTitle(){title.value?.focus({preventScroll:true})}function returnFocus(){returnFocusTarget()?.focus({preventScroll:true})}function setTab(view,element){if(element)tabElements.set(view,element);else tabElements.delete(view)}async function moveBetweenViews(event){const index=views.indexOf(selectedView());const next={ArrowLeft:views[(index+views.length-1)%views.length],ArrowRight:views[(index+1)%views.length],End:views.at(-1),Home:views[0]}[event.key];if(!next)return;event.preventDefault();setView(next);await nextTick();tabElements.get(next)?.focus()}return{focusTitle,moveBetweenViews,reducedMotion,returnFocus,setTab}}var _hoisted_1$2={class:`ai-task-outcome`};var _hoisted_2$2={key:0};var _hoisted_3$2={key:1};var _sfc_main$2={__name:`Vibe64AiTaskOutcome`,props:{task:{required:true,type:Object},projection:{required:true,type:Object}},emits:[`see-conversation`],setup(__props,{emit:__emit}){const emit=__emit;return(_ctx,_cache)=>{return openBlock(),createElementBlock(`div`,_hoisted_1$2,[createBaseVNode(`section`,null,[createBaseVNode(`h3`,null,toDisplayString(unref(AI_TASK_MESSAGES).outcome.problem),1),createBaseVNode(`p`,null,[createVNode(unref(LongTextInlineParts_default),{text:__props.task.problem.summary},null,8,[`text`])])]),createBaseVNode(`section`,null,[createBaseVNode(`h3`,null,toDisplayString(unref(AI_TASK_MESSAGES).outcome.whatHappened),1),createBaseVNode(`p`,null,[createVNode(unref(LongTextInlineParts_default),{text:__props.projection.outcome.happened},null,8,[`text`])])]),__props.projection.outcome.report?(openBlock(),createElementBlock(`section`,_hoisted_2$2,[createBaseVNode(`h3`,null,toDisplayString(unref(AI_TASK_MESSAGES).outcome.whatTheAiDid),1),createBaseVNode(`p`,null,[createVNode(unref(LongTextInlineParts_default),{text:__props.projection.outcome.report},null,8,[`text`])])])):createCommentVNode(``,true),__props.projection.outcome.next?(openBlock(),createElementBlock(`section`,_hoisted_3$2,[createBaseVNode(`h3`,null,toDisplayString(unref(AI_TASK_MESSAGES).outcome.whatsNext),1),createBaseVNode(`p`,null,toDisplayString(__props.projection.outcome.next),1)])):createCommentVNode(``,true),createVNode(VBtn,{class:`ai-task-outcome__conversation`,"data-vibe64-ai-task-transcript":``,variant:`text`,onClick:_cache[0]||(_cache[0]=$event=>emit(`see-conversation`))},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(AI_TASK_MESSAGES).outcome.seeConversation),1)]),_:1})])}}};var Vibe64AiTaskOutcome_default=_plugin_vue_export_helper_default(_sfc_main$2,[[`__scopeId`,`data-v-a9609028`]]);var _hoisted_1$1={class:`ai-task-progress`};var _hoisted_2$1={class:`ai-task-progress__steps`};var _hoisted_3$1={class:`ai-task-progress__label`};var _hoisted_4$1={key:0,class:`ai-task-progress__attempt`};var _hoisted_5$1={key:0,class:`ai-task-progress__note`};var _hoisted_6$1={key:1,class:`ai-task-progress__output`};var _hoisted_7$1=[`aria-label`];var _hoisted_8$1={class:`ai-task-progress__heading`};var _hoisted_9$1=[`datetime`];var _sfc_main$1={__name:`Vibe64AiTaskProgress`,props:{task:{required:true,type:Object},projection:{required:true,type:Object},output:{required:true,type:Boolean},commentary:{required:true,type:Array}},setup(__props){const props=__props;const stepIcons={active:`$radioOn`,done:`$checkCircleFilled`,failed:`$cancel`,pending:`$circle`};const activity=computed(()=>[...props.task.log,...props.commentary].sort((a,b)=>a.at.localeCompare(b.at)));return(_ctx,_cache)=>{return openBlock(),createElementBlock(`div`,_hoisted_1$1,[createBaseVNode(`ol`,_hoisted_2$1,[(openBlock(true),createElementBlock(Fragment,null,renderList(__props.projection.steps,step=>{return openBlock(),createElementBlock(`li`,{key:step.label,class:normalizeClass([`ai-task-progress__step`,`ai-task-progress__step--${step.state}`])},[createVNode(VIcon,{icon:stepIcons[step.state],size:`18`,"aria-hidden":`true`},null,8,[`icon`]),createBaseVNode(`span`,_hoisted_3$1,toDisplayString(step.label),1),step.attempt?(openBlock(),createElementBlock(`span`,_hoisted_4$1,toDisplayString(step.attempt),1)):createCommentVNode(``,true)],2)}),128))]),__props.projection.note?(openBlock(),createElementBlock(`p`,_hoisted_5$1,[createVNode(unref(LongTextInlineParts_default),{text:__props.projection.note},null,8,[`text`])])):createCommentVNode(``,true),_ctx.$slots[`check-output`]&&__props.output?(openBlock(),createElementBlock(`details`,_hoisted_6$1,[createBaseVNode(`summary`,null,toDisplayString(__props.task.check.output),1),renderSlot(_ctx.$slots,`check-output`,{},void 0,true)])):createCommentVNode(``,true),createBaseVNode(`section`,{class:`ai-task-progress__activity`,"aria-label":unref(AI_TASK_MESSAGES).progress.activity},[createBaseVNode(`h3`,_hoisted_8$1,toDisplayString(unref(AI_TASK_MESSAGES).progress.activity),1),createBaseVNode(`ol`,null,[(openBlock(true),createElementBlock(Fragment,null,renderList(activity.value,entry=>{return openBlock(),createElementBlock(`li`,{key:`${entry.at}:${entry.text}`},[createBaseVNode(`time`,{datetime:entry.at},toDisplayString(unref(aiTaskTime)(entry.at)),9,_hoisted_9$1),createBaseVNode(`span`,null,toDisplayString(entry.text),1)])}),128))])],8,_hoisted_7$1)])}}};var Vibe64AiTaskProgress_default=_plugin_vue_export_helper_default(_sfc_main$1,[[`__scopeId`,`data-v-8b486df1`]]);var _hoisted_1=[`aria-labelledby`,`data-vibe64-ai-task-phase`,`data-vibe64-ai-task-reason`];var _hoisted_2={class:`ai-task__header`};var _hoisted_3={class:`ai-task__heading`};var _hoisted_4=[`id`];var _hoisted_5={"aria-live":`polite`,class:`ai-task__status`,"data-vibe64-ai-task-status":``};var _hoisted_6={key:0,class:`ai-task__commands`};var _hoisted_7={class:`ai-task__problem`};var _hoisted_8=[`title`];var _hoisted_9=[`aria-expanded`,`aria-label`];var _hoisted_10={class:`ai-task__details-word`};var _hoisted_11={key:0,class:`ai-task__details`,"data-vibe64-ai-task-details-text":``,tabindex:`0`};var _hoisted_12=[`aria-label`];var _hoisted_13=[`id`,`aria-controls`,`aria-selected`,`data-vibe64-ai-task-view`,`tabindex`,`onClick`];var _hoisted_14=[`aria-label`];var _hoisted_15={class:`ai-task__body`};var _hoisted_16=[`id`,`aria-labelledby`];var _hoisted_17=[`id`,`aria-labelledby`,`role`];var _hoisted_18={key:1,class:`ai-task__error`,role:`alert`};var _hoisted_19={key:2,class:`ai-task__footer ai-task__footer--question`};var _hoisted_20={class:`ai-task__actions`};var _hoisted_21={key:3,class:`ai-task__footer`};var _hoisted_22={class:`ai-task__actions`};var _hoisted_23={key:4,class:`ai-task__footer`};var _hoisted_24={class:`ai-task__actions`};var _sfc_main={__name:`Vibe64AiTaskWindow`,props:{source:{required:true,type:Object},commentary:{required:true,type:Array},output:{required:true,type:Boolean}},setup(__props){const props=__props;const glyphIcons={attention:`$errorFilled`,done:`$checkCircleFilled`,"not-done":`$cancel`,turn:`$circle`};const titleId=useId();const title=ref(null);const task=computed(()=>props.source.task);const projection=computed(()=>props.source.projection);const footerActions=computed(()=>aiTaskFooterActions(projection.value.actions,props.source.view));const{width,height}=useDisplay();const fit=computed(()=>aiTaskFit(width.value,height.value));const detailsOpen=ref(false);const confirmingCancel=ref(false);const cancelling=computed(()=>props.source.cancelRequested||task.value.phase===`cancelling`);const tabs=[{id:`progress`,label:AI_TASK_MESSAGES.views.progress},{id:`chat`,label:AI_TASK_MESSAGES.views.chat}];const{focusTitle,moveBetweenViews,reducedMotion,returnFocus,setTab}=useAiTaskFocus({title,views:tabs.map(tab=>tab.id),selectedView:()=>props.source.view,setView:view=>props.source.setView(view),returnFocusTarget:()=>props.source.returnFocusTarget()});function requestCancel(){if(cancelling.value)props.source.cancel();else confirmingCancel.value=true}function cancel(){confirmingCancel.value=false;props.source.cancel()}function escape(){if(projection.value.ended)props.source.close();else props.source.hide()}watch(()=>projection.value.ended,async ended=>{if(!ended)return;confirmingCancel.value=false;await nextTick();focusTitle()});return(_ctx,_cache)=>{return openBlock(),createBlock(VDialog,{"aria-labelledby":unref(titleId),fullscreen:fit.value.fullscreen,height:fit.value.height,"model-value":__props.source.open,"no-click-animation":``,persistent:``,width:fit.value.width,transition:unref(reducedMotion)?false:void 0,onAfterEnter:unref(focusTitle),onAfterLeave:unref(returnFocus),onKeydown:withKeys(withModifiers(escape,[`stop`,`prevent`]),[`esc`])},{default:withCtx(()=>[createBaseVNode(`section`,{"aria-labelledby":unref(titleId),class:normalizeClass([`ai-task`,{"ai-task--fullscreen":fit.value.fullscreen,"ai-task--ended":projection.value.ended}]),"data-vibe64-ai-task":``,"data-vibe64-ai-task-phase":task.value.phase,"data-vibe64-ai-task-reason":task.value.reason},[createBaseVNode(`header`,_hoisted_2,[createBaseVNode(`span`,{class:normalizeClass([`ai-task__glyph`,`ai-task__glyph--${projection.value.glyph}`]),"aria-hidden":`true`},[projection.value.glyph===`working`?(openBlock(),createBlock(VProgressCircular,{key:0,indeterminate:!unref(reducedMotion),"model-value":unref(reducedMotion)?60:void 0,size:`20`,width:`2`},null,8,[`indeterminate`,`model-value`])):(openBlock(),createBlock(VIcon,{key:1,icon:glyphIcons[projection.value.glyph],size:`22`},null,8,[`icon`]))],2),createBaseVNode(`div`,_hoisted_3,[createBaseVNode(`h2`,{id:unref(titleId),ref_key:`title`,ref:title,tabindex:`-1`},toDisplayString(projection.value.ended?projection.value.outcome.heading:task.value.title),9,_hoisted_4),createBaseVNode(`p`,_hoisted_5,[projection.value.ended?(openBlock(),createElementBlock(Fragment,{key:0},[createTextVNode(toDisplayString(task.value.title),1)],64)):(openBlock(),createBlock(unref(LongTextInlineParts_default),{key:1,text:projection.value.status},null,8,[`text`]))])]),!projection.value.ended?(openBlock(),createElementBlock(`div`,_hoisted_6,[createVNode(VBtn,{"data-vibe64-ai-task-hide":``,variant:`text`,onClick:__props.source.hide},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(AI_TASK_MESSAGES).actions.hide),1)]),_:1},8,[`onClick`]),createVNode(VBtn,{"aria-busy":cancelling.value?`true`:void 0,"data-vibe64-ai-task-cancel":``,variant:`text`,onClick:requestCancel},{default:withCtx(()=>[createTextVNode(toDisplayString(cancelling.value?unref(AI_TASK_MESSAGES).actions.cancelling:unref(AI_TASK_MESSAGES).actions.cancel),1)]),_:1},8,[`aria-busy`])])):createCommentVNode(``,true)]),!projection.value.ended?(openBlock(),createElementBlock(Fragment,{key:0},[createBaseVNode(`div`,_hoisted_7,[createBaseVNode(`span`,{class:`ai-task__problem-line`,title:task.value.problem.summary},[createVNode(unref(LongTextInlineParts_default),{text:task.value.problem.summary},null,8,[`text`])],8,_hoisted_8),task.value.problem.details?(openBlock(),createElementBlock(`button`,{key:0,"aria-expanded":detailsOpen.value?`true`:`false`,"aria-label":unref(AI_TASK_MESSAGES).actions.details,class:`ai-task__details-toggle`,"data-vibe64-ai-task-details":``,type:`button`,onClick:_cache[0]||(_cache[0]=$event=>detailsOpen.value=!detailsOpen.value)},[createBaseVNode(`span`,_hoisted_10,toDisplayString(unref(AI_TASK_MESSAGES).actions.details),1),createVNode(VIcon,{icon:detailsOpen.value?`$collapse`:`$expand`,size:`18`,"aria-hidden":`true`},null,8,[`icon`])],8,_hoisted_9)):createCommentVNode(``,true)]),detailsOpen.value?(openBlock(),createElementBlock(`pre`,_hoisted_11,toDisplayString(task.value.problem.details),1)):createCommentVNode(``,true),createBaseVNode(`div`,{"aria-label":unref(AI_TASK_MESSAGES).views.label,class:`ai-task__views`,role:`tablist`,onKeydown:_cache[1]||(_cache[1]=(...args)=>unref(moveBetweenViews)&&unref(moveBetweenViews)(...args))},[(openBlock(),createElementBlock(Fragment,null,renderList(tabs,tab=>{return createBaseVNode(`button`,{id:`${unref(titleId)}-${tab.id}-tab`,key:tab.id,ref_for:true,ref:element=>unref(setTab)(tab.id,element),"aria-controls":`${unref(titleId)}-${tab.id}`,"aria-selected":__props.source.view===tab.id?`true`:`false`,class:normalizeClass([`ai-task__view`,{"ai-task__view--selected":__props.source.view===tab.id}]),"data-vibe64-ai-task-view":tab.id,role:`tab`,tabindex:__props.source.view===tab.id?0:-1,type:`button`,onClick:$event=>__props.source.setView(tab.id)},[createTextVNode(toDisplayString(tab.label)+` `,1),tab.id===`chat`&&projection.value.chatDot?(openBlock(),createElementBlock(`span`,{key:0,class:`ai-task__dot`,role:`img`,"aria-label":unref(AI_TASK_MESSAGES).views.waiting},null,8,_hoisted_14)):createCommentVNode(``,true)],10,_hoisted_13)}),64))],40,_hoisted_12)],64)):createCommentVNode(``,true),createBaseVNode(`div`,_hoisted_15,[!projection.value.ended?withDirectives((openBlock(),createElementBlock(`section`,{key:0,id:`${unref(titleId)}-progress`,"aria-labelledby":`${unref(titleId)}-progress-tab`,class:`ai-task__panel`,role:`tabpanel`},[createVNode(Vibe64AiTaskProgress_default,{commentary:__props.commentary,output:__props.output,projection:projection.value,task:task.value},{"check-output":withCtx(()=>[renderSlot(_ctx.$slots,`check-output`,{},void 0,true)]),_:3},8,[`commentary`,`output`,`projection`,`task`])],8,_hoisted_16)),[[vShow,__props.source.view===`progress`]]):!__props.source.transcriptOpen?(openBlock(),createBlock(Vibe64AiTaskOutcome_default,{key:1,projection:projection.value,task:task.value,onSeeConversation:_cache[2]||(_cache[2]=$event=>__props.source.setTranscript(true))},null,8,[`projection`,`task`])):createCommentVNode(``,true),withDirectives(createBaseVNode(`section`,{id:`${unref(titleId)}-chat`,"aria-labelledby":projection.value.ended?void 0:`${unref(titleId)}-chat-tab`,class:`ai-task__panel`,role:projection.value.ended?void 0:`tabpanel`},[renderSlot(_ctx.$slots,`chat`,{visible:__props.source.open&&(projection.value.ended?__props.source.transcriptOpen:__props.source.view===`chat`)},void 0,true)],8,_hoisted_17),[[vShow,!projection.value.ended?__props.source.view===`chat`:__props.source.transcriptOpen]])]),__props.source.error?(openBlock(),createElementBlock(`p`,_hoisted_18,toDisplayString(__props.source.error),1)):createCommentVNode(``,true),confirmingCancel.value?(openBlock(),createElementBlock(`footer`,_hoisted_19,[createBaseVNode(`p`,null,toDisplayString(projection.value.cancelQuestion),1),createBaseVNode(`div`,_hoisted_20,[createVNode(VBtn,{"data-vibe64-ai-task-keep-going":``,variant:`text`,onClick:_cache[3]||(_cache[3]=$event=>confirmingCancel.value=false)},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(AI_TASK_MESSAGES).actions.keepGoing),1)]),_:1}),createVNode(VBtn,{color:`error`,"data-vibe64-ai-task-cancel-confirm":``,variant:`flat`,onClick:cancel},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(AI_TASK_MESSAGES).cancelConfirm(task.value.noun)),1)]),_:1})])])):projection.value.ended?(openBlock(),createElementBlock(`footer`,_hoisted_21,[createBaseVNode(`div`,_hoisted_22,[__props.source.transcriptOpen?(openBlock(),createBlock(VBtn,{key:0,variant:`text`,onClick:_cache[4]||(_cache[4]=$event=>__props.source.setTranscript(false))},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(AI_TASK_MESSAGES).outcome.showResult),1)]),_:1})):createCommentVNode(``,true),createVNode(VBtn,{"aria-busy":__props.source.closing?`true`:void 0,color:`primary`,"data-vibe64-ai-task-close":``,variant:`flat`,onClick:__props.source.close},{default:withCtx(()=>[createTextVNode(toDisplayString(__props.source.closing?unref(AI_TASK_MESSAGES).actions.closing:unref(AI_TASK_MESSAGES).actions.close),1)]),_:1},8,[`aria-busy`,`onClick`])])])):footerActions.value.length?(openBlock(),createElementBlock(`footer`,_hoisted_23,[createBaseVNode(`div`,_hoisted_24,[(openBlock(true),createElementBlock(Fragment,null,renderList(footerActions.value,item=>{return openBlock(),createBlock(VBtn,{key:item.id,color:item.primary?`primary`:void 0,"data-vibe64-ai-task-action":item.id,variant:item.primary?`flat`:`text`,onClick:$event=>__props.source.run(item.id)},{default:withCtx(()=>[createTextVNode(toDisplayString(item.label),1)]),_:2},1032,[`color`,`data-vibe64-ai-task-action`,`variant`,`onClick`])}),128))])])):createCommentVNode(``,true)],10,_hoisted_1)]),_:3},8,[`aria-labelledby`,`fullscreen`,`height`,`model-value`,`width`,`transition`,`onAfterEnter`,`onAfterLeave`,`onKeydown`])}}};var Vibe64AiTaskWindow_default=_plugin_vue_export_helper_default(_sfc_main,[[`__scopeId`,`data-v-43823fc5`]]);var REPOSITORY_STATUS_SESSION_REASONS=new Set([`claude-stream-turn-idle`,`codex-app-server-turn-idle`,`opencode-server-turn-idle`,`repository-canonical-changed`,`session-pull-request`,`session-repository-checked`,`session-save-completed`,`session-save-failed`,`session-save-started`,`session-save-update-required`,`session-starter-applied`,`session-turn-checkpoint-failed`,`session-turn-checkpoint-updated`,`session-update-completed`,`session-update-failed`,`session-update-started`]);var REPOSITORY_UPDATE_CHECK_FAILED_REASON=`session-repository-check-failed`;var REPOSITORY_CANONICAL_RECHECK_REASONS=new Set([`repository-canonical-changed`,`session-pull-request`,`session-save-failed`,`session-save-update-required`,`session-update-failed`]);function repositoryStatusSessionId(payload={}){const event=normalizeObject(payload);return String(event.sessionId||event.session?.sessionId||``).trim()}function repositoryStatusRealtimeShouldRefresh(payload={}){return REPOSITORY_STATUS_SESSION_REASONS.has(String(normalizeObject(payload).reason||``).trim())}function repositoryStatusRealtimeNeedsCanonicalCheck(payload={}){return REPOSITORY_CANONICAL_RECHECK_REASONS.has(String(normalizeObject(payload).reason||``).trim())}export{Vibe64AiTaskWindow_default as a,useAiTaskHost as c,repositoryStatusSessionId as i,AI_TASK_PHASES as l,repositoryStatusRealtimeNeedsCanonicalCheck as n,Vibe64AiTaskTray_default as o,repositoryStatusRealtimeShouldRefresh as r,Vibe64AiTaskButton_default as s,REPOSITORY_UPDATE_CHECK_FAILED_REASON as t,VIBE64_AI_TASKS_KEY as u};
1
+ import{$ as useId,Et as unref,G as renderList,H as openBlock,K as renderSlot,Kt as normalizeClass,N as nextTick,O as inject,Tt as toValue,Xt as toDisplayString,_ as createSlots,b as createVNode,d as createBaseVNode,f as createBlock,gt as reactive,i as Fragment,it as watch,m as createElementBlock,mt as onScopeDispose,ot as withCtx,p as createCommentVNode,st as withDirectives,u as computed,vt as ref,xt as shallowRef,y as createTextVNode}from"./runtime-core.esm-bundler-Bi1P1jMa.js";import{S as VIcon,cr as vShow,lr as withKeys,mt as useDisplay,ur as withModifiers}from"./VChip-D2IukBZw.js";import{s as normalizeObject}from"./normalize-BD25VwNK.js";import{r as VProgressCircular,t as VBtn}from"./VBtn-2vbH580C.js";import{t as VDialog}from"./VDialog-BCIrX462.js";import{t as _plugin_vue_export_helper_default}from"./_plugin-vue_export-helper-DNW4j-dv.js";import{y as LongTextInlineParts_default}from"./conversation-BoB7Drme.js";import{r as useRealtimeEvent}from"./useRealtimeEvent-B4oRg9Dt.js";var VIBE64_AI_TASKS_KEY=Symbol(`vibe64.ai-tasks`);var NO_AI_TASKS=Object.freeze({available:false});var AI_TASK_PHASES=Object.freeze({STARTING:`starting`,WORKING:`working`,CHECKING:`checking`,NEEDS_YOU:`needs_you`,CANCELLING:`cancelling`,DONE:`done`,NOT_DONE:`not_done`});var AI_TASK_REASONS=Object.freeze({AI_STUCK:`ai_stuck`,AI_UNAVAILABLE:`ai_unavailable`,ARCHIVED:`archived`,CANCELLED:`cancelled`,CHECK_STUCK:`check_stuck`,DRAFT_WAITING:`draft_waiting`,INTERRUPTED:`interrupted`,NO_RESULT:`no_result`,QUESTION:`question`,STOPPED:`stopped`,TURN_FAILED:`turn_failed`,UNCONFIRMED:`unconfirmed`,YOUR_TURN:`your_turn`});var AI_TASK_CHECKERS=Object.freeze({AGENT:`agent`,PERSON:`person`,VIBE64:`vibe64`});var AI_TASK_ACTIVE_PHASES=Object.freeze([AI_TASK_PHASES.STARTING,AI_TASK_PHASES.WORKING,AI_TASK_PHASES.CHECKING,AI_TASK_PHASES.CANCELLING]);var AI_TASK_ENDED_PHASES=Object.freeze([AI_TASK_PHASES.DONE,AI_TASK_PHASES.NOT_DONE]);function aiTaskEnded(task){return AI_TASK_ENDED_PHASES.includes(task.phase)}var AI_TASK_MESSAGES=Object.freeze({actions:Object.freeze({aiSetup:`Open AI setup`,answer:`Answer`,back:`Back`,cancel:`Cancel`,cancelling:`Cancelling…`,checkNow:`Check now`,close:`Close`,closing:`Closing…`,continue:`Continue`,details:`Details`,endNotDone:`End as not done`,finish:`Finish`,hide:`Hide`,keepGoing:`Keep going`,openChat:`Open chat`,review:`Review resolved conflicts`,waitForAi:`Wait for the AI`}),button:Object.freeze({busy:`Being fixed…`,fix:`Fix it with AI`,opening:`Opening…`,result:`See result`}),chat:Object.freeze({answer:`Type your answer…`,message:`Message the AI…`}),outcome:Object.freeze({done:`Done`,notDone:`Not done`,problem:`The problem`,seeConversation:`See the conversation`,showResult:`Show the result`,whatHappened:`What happened`,whatTheAiDid:`What the AI did`,whatsNext:`What's next`}),progress:Object.freeze({activity:`Activity`,unavailable:`Nothing is lost. The fix continues from here.`}),status:Object.freeze({aiStuck:`The AI could not finish this`,aiUnavailable:`The AI account can't run this right now`,cancelling:`Cancelling…`,draftWaiting:`The check failed. Your unsent message is waiting.`,interrupted:`Vibe64 restarted while the AI was working`,noResult:`The AI stopped without saying it finished`,question:`The AI needs your answer`,starting:`Starting…`,stopped:`Stopped. Tell the AI what to do next.`,turnFailed:`The AI ran into an error`,unconfirmed:`Vibe64 couldn't confirm the result`,working:`The AI is working on this`,yourTurn:`Your turn`}),tray:Object.freeze({cancelling:`Cancelling…`,done:`Done`,needsYou:`Needs you`,notDone:`Not done`,yourTurn:`Your turn`}),views:Object.freeze({chat:`Chat`,label:`Task views`,progress:`Progress`,waiting:`The AI is waiting for your answer`}),closeFailed:`That didn't finish. Try again.`,requestFailed:`That didn't reach Vibe64. Try again.`,attempt:(attempt,limit)=>`Attempt ${attempt} of ${limit}`,retrying:(attempt,limit)=>`The AI is trying again (attempt ${attempt} of ${limit})`,cancelQuestion:noun=>`Cancel this ${noun}? The AI stops. Anything it has changed stays in the session.`,cancelConfirm:noun=>`Cancel ${noun}`,cancelledByYou:noun=>`You cancelled this ${noun}.`,cancelledBy:(name,noun)=>`${name} cancelled this ${noun}.`,mainChatSince:time=>time?`The main chat's AI has been working since ${time}.`:`The main chat's AI is working.`,whatsNext:()=>`The problem is still there. Anything the AI changed stays in the session. To try again, close this and choose Fix it with AI.`,toast:(title,outcome)=>`${title}: ${outcome}.`});var AI_TASK_ACTIONS=Object.freeze({AI_SETUP:`ai-setup`,ANSWER:`answer`,CHECK:`check`,CONTINUE:`continue`,END:`end`,FINISH:`finish`,OPEN_CHAT:`open-chat`,REVIEW:`review`,RUN_NOW:`run-now`,WAIT_FOR_AI:`wait-for-ai`});var action=(id,label,primary=false)=>Object.freeze({id,label,primary});var OPEN_CHAT=action(AI_TASK_ACTIONS.OPEN_CHAT,AI_TASK_MESSAGES.actions.openChat);var CHECK_NOW=action(AI_TASK_ACTIONS.CHECK,AI_TASK_MESSAGES.actions.checkNow,true);var CONTINUE=action(AI_TASK_ACTIONS.CONTINUE,AI_TASK_MESSAGES.actions.continue,true);var NEEDS_YOU=Object.freeze({[AI_TASK_REASONS.QUESTION]:{status:AI_TASK_MESSAGES.status.question,chat:true,dot:true,actions:[action(AI_TASK_ACTIONS.ANSWER,AI_TASK_MESSAGES.actions.answer,true)]},[AI_TASK_REASONS.YOUR_TURN]:{glyph:`turn`,status:AI_TASK_MESSAGES.status.yourTurn,tray:AI_TASK_MESSAGES.tray.yourTurn,chat:true,dot:true,actions:[action(AI_TASK_ACTIONS.FINISH,AI_TASK_MESSAGES.actions.finish,true)]},[AI_TASK_REASONS.AI_STUCK]:{status:AI_TASK_MESSAGES.status.aiStuck,chat:true,actions:[action(AI_TASK_ACTIONS.END,AI_TASK_MESSAGES.actions.endNotDone),action(AI_TASK_ACTIONS.OPEN_CHAT,AI_TASK_MESSAGES.actions.openChat,true)]},[AI_TASK_REASONS.CHECK_STUCK]:{check:true,diagnostic:true,actions:[OPEN_CHAT,CHECK_NOW]},[AI_TASK_REASONS.NO_RESULT]:{status:AI_TASK_MESSAGES.status.noResult,actions:[OPEN_CHAT,CHECK_NOW]},[AI_TASK_REASONS.STOPPED]:{status:AI_TASK_MESSAGES.status.stopped,actions:[OPEN_CHAT,CONTINUE]},[AI_TASK_REASONS.AI_UNAVAILABLE]:{status:AI_TASK_MESSAGES.status.aiUnavailable,note:AI_TASK_MESSAGES.progress.unavailable,actions:[action(AI_TASK_ACTIONS.AI_SETUP,AI_TASK_MESSAGES.actions.aiSetup),CONTINUE]},[AI_TASK_REASONS.TURN_FAILED]:{status:AI_TASK_MESSAGES.status.turnFailed,actions:[OPEN_CHAT,CONTINUE]},[AI_TASK_REASONS.INTERRUPTED]:{status:AI_TASK_MESSAGES.status.interrupted,actions:[CONTINUE]},[AI_TASK_REASONS.UNCONFIRMED]:{status:AI_TASK_MESSAGES.status.unconfirmed,check:true,actions:[CHECK_NOW]},[AI_TASK_REASONS.DRAFT_WAITING]:{status:AI_TASK_MESSAGES.status.draftWaiting,chat:true,check:true,diagnostic:true,actions:[action(AI_TASK_ACTIONS.OPEN_CHAT,AI_TASK_MESSAGES.actions.openChat,true)]}});function stepsOf(task,needs){const[work,check]=task.steps;const counted=task.check.retryLimit>0?AI_TASK_MESSAGES.attempt(task.attempt,task.check.retryLimit):``;const ended=aiTaskEnded(task);const atCheck=task.phase===AI_TASK_PHASES.CHECKING||task.checkRunning||needs?.check===true;const passed=task.phase===AI_TASK_PHASES.DONE;const workState=passed||atCheck?`done`:ended?`failed`:`active`;const checkState=passed?`done`:needs?.check||ended&&atCheck?`failed`:atCheck?`active`:`pending`;const steps=[{label:work,state:workState,attempt:workState===`active`?counted:``}];if(check)steps.push({label:check,state:checkState,attempt:atCheck&&!ended?counted:``});return steps}function endedMessage(task,viewerId){if(task.message)return task.message;const by=task.endedBy;return by?.name&&by.id!==viewerId?AI_TASK_MESSAGES.cancelledBy(by.name,task.noun):AI_TASK_MESSAGES.cancelledByYou(task.noun)}function outcomeOf(task,viewerId){if(task.phase===AI_TASK_PHASES.DONE)return{heading:AI_TASK_MESSAGES.outcome.done,happened:task.message,report:task.report,next:``};return{heading:AI_TASK_MESSAGES.outcome.notDone,happened:endedMessage(task,viewerId),report:``,next:AI_TASK_MESSAGES.whatsNext()}}function runningStatus(task){if(task.phase===AI_TASK_PHASES.STARTING)return AI_TASK_MESSAGES.status.starting;if(task.phase===AI_TASK_PHASES.CANCELLING)return AI_TASK_MESSAGES.status.cancelling;if(task.phase===AI_TASK_PHASES.CHECKING)return task.waiting?task.message:task.check.label;return task.attempt>1?AI_TASK_MESSAGES.retrying(task.attempt,task.check.retryLimit):AI_TASK_MESSAGES.status.working}function noteOf(task,needs){if(task.phase===AI_TASK_PHASES.CANCELLING)return task.checkRunning?task.check.unstoppable:``;if(!needs)return``;return[needs.status&&task.message!==needs.status?task.message:``,needs.diagnostic&&!task.message.includes(task.diagnostic)?task.diagnostic:``,needs.note].filter(Boolean).join(` `)}function projectAiTask(task,{viewerId}){const ended=aiTaskEnded(task);const needs=task.phase===AI_TASK_PHASES.NEEDS_YOU?NEEDS_YOU[task.reason]:null;const whileAiWorks=task.phase===AI_TASK_PHASES.CHECKING&&task.waiting&&task.mainChatSince?task.check.whileAiWorks:null;const review=needs?.check&&task.reason===AI_TASK_REASONS.CHECK_STUCK&&task.conflictReview?[action(AI_TASK_ACTIONS.REVIEW,AI_TASK_MESSAGES.actions.review)]:[];const done=task.phase===AI_TASK_PHASES.DONE;const running=!ended&&!needs;return{glyph:done?`done`:ended?`not-done`:needs?needs.glyph||`attention`:`working`,status:done?AI_TASK_MESSAGES.outcome.done:ended?AI_TASK_MESSAGES.outcome.notDone:needs?needs.status||task.message:runningStatus(task),tray:done?AI_TASK_MESSAGES.tray.done:ended?AI_TASK_MESSAGES.tray.notDone:task.phase===AI_TASK_PHASES.CANCELLING?AI_TASK_MESSAGES.tray.cancelling:needs?needs.tray||AI_TASK_MESSAGES.tray.needsYou:task.tray,ended,chatDot:needs?.dot===true,opensOn:needs?.chat?`chat`:`progress`,composerOpen:Boolean(needs)||task.phase===AI_TASK_PHASES.WORKING,composerHint:task.reason===AI_TASK_REASONS.QUESTION?AI_TASK_MESSAGES.chat.answer:AI_TASK_MESSAGES.chat.message,note:whileAiWorks?`${AI_TASK_MESSAGES.mainChatSince(aiTaskTime(task.mainChatSince))} ${whileAiWorks.note}`:running&&task.phase!==AI_TASK_PHASES.CANCELLING?``:noteOf(task,needs),steps:stepsOf(task,needs),actions:needs?[...review,...needs.actions]:whileAiWorks?[action(AI_TASK_ACTIONS.WAIT_FOR_AI,AI_TASK_MESSAGES.actions.waitForAi),action(AI_TASK_ACTIONS.RUN_NOW,whileAiWorks.action,true)]:[],cancelQuestion:AI_TASK_MESSAGES.cancelQuestion(task.noun),outcome:ended?outcomeOf(task,viewerId):null}}function aiTaskFooterActions(actions,view){if(view!==`chat`)return actions;return actions.filter(({id})=>id!==AI_TASK_ACTIONS.ANSWER&&id!==AI_TASK_ACTIONS.OPEN_CHAT)}function aiTaskTime(at){const date=new Date(at);return Number.isNaN(date.getTime())?``:date.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}var SESSION_CHANGED_EVENT=`vibe64.session.changed`;var AI_TASK_CHANGED=`ai-task-changed`;function useAiTasks({sessionId,sessionsApiPath,projectSlug,enabled,request,onClosed}){const task=shallowRef(null);const loaded=ref(false);const error=ref(``);const cancelRequested=ref(false);const closing=ref(false);const starting=ref(false);const viewerId=ref(``);let readGeneration=0;const tasksPath=()=>`${toValue(sessionsApiPath)}/${encodeURIComponent(toValue(sessionId))}/ai-tasks`;const taskPath=(suffix=``)=>`${tasksPath()}/${encodeURIComponent(task.value.id)}${suffix}`;function remember(next){if(task.value?.id===next.id&&next.revision<task.value.revision)return;task.value=next}async function load(){const generation=++readGeneration;if(!toValue(enabled)||!toValue(sessionId))return;try{const{tasks,viewerId:viewer}=await request(tasksPath(),{method:`GET`});if(generation!==readGeneration)return;viewerId.value=viewer;const[saved=null]=tasks;if(saved)remember(saved);else task.value=null;loaded.value=true}catch{}}async function start(kind,input){error.value=``;starting.value=true;try{const answer=await request(tasksPath(),{method:`POST`,body:{kind,input}});remember(answer.task);return answer.task}catch(failure){error.value=failure.message||AI_TASK_MESSAGES.requestFailed;return null}finally{starting.value=false}}async function act(suffix,body={}){error.value=``;try{remember((await request(taskPath(suffix),{method:`POST`,body})).task)}catch(failure){error.value=failure.message||AI_TASK_MESSAGES.requestFailed;load()}}async function cancel(){cancelRequested.value=true;await act(`/cancel`);cancelRequested.value=false}const check=(input={})=>act(`/check`,input);const continueTask=()=>act(`/continue`);const finish=()=>act(`/finish`);async function close(){error.value=``;closing.value=true;try{await request(taskPath(),{method:`DELETE`});task.value=null}catch{error.value=AI_TASK_MESSAGES.closeFailed}finally{closing.value=false}}const matchesSession=payload=>payload.projectSlug===toValue(projectSlug)&&payload.sessionId===toValue(sessionId)&&payload.reason===AI_TASK_CHANGED;useRealtimeEvent({enabled:computed(()=>toValue(enabled)),event:SESSION_CHANGED_EVENT,matches:({payload={}}={})=>matchesSession(payload),onEvent({payload}){if(payload.aiTask){remember(payload.aiTask);return}if(payload.aiTaskClosed?.id!==task.value?.id)return;const closedHere=closing.value;task.value=null;if(!closedHere)onClosed(payload.aiTaskClosed)}});useRealtimeEvent({enabled:computed(()=>toValue(enabled)),event:`connect`,onEvent:()=>void load()});watch(()=>[toValue(sessionId),toValue(enabled)],([,on],previous)=>{if(previous?.[0]!==toValue(sessionId)){task.value=null;loaded.value=false}if(on)load()},{immediate:true});return{cancel,cancelRequested,check,close,closing,continueTask,error,finish,load,loaded,start,starting,task,viewerId}}var WINDOW_QUERY=`aiTask`;function useAiTaskWindow({task,loaded,active,opensOn,route,router}){const view=ref(`progress`);const transcriptOpen=ref(false);let opener=null;const wanted=computed(()=>String(route.query[WINDOW_QUERY]||``));const open=computed(()=>toValue(active)&&Boolean(wanted.value)&&toValue(task)?.id===wanted.value);function withoutWindow(){const{[WINDOW_QUERY]:_taskId,...query}=route.query;return{path:route.path,query,hash:route.hash}}async function show(element=null){const current=toValue(task);if(!current)return;opener=element;if(open.value)return;await router.push({path:route.path,query:{...route.query,[WINDOW_QUERY]:current.id},hash:route.hash})}function hide(){if(wanted.value)router.replace(withoutWindow())}function setView(next){view.value=next}watch(open,isOpen=>{if(!isOpen)return;view.value=toValue(opensOn);transcriptOpen.value=false},{immediate:true});watch(()=>[wanted.value,toValue(loaded),toValue(task)?.id,toValue(active)],()=>{if(wanted.value&&toValue(active)&&toValue(loaded)&&toValue(task)?.id!==wanted.value)router.replace(withoutWindow())},{immediate:true});return{hide,open,opener:()=>opener?.isConnected?opener:null,setView,show,transcriptOpen,view}}function useAiTaskHost({sessionId,sessionsApiPath,projectSlug,enabled,active,request,route,router,openAiSetup,reviewResolved,fallbackFocus}){const toast=ref(null);const tasks=useAiTasks({sessionId,sessionsApiPath,projectSlug,enabled,request,onClosed(closed){const heading=closed.phase===`done`?AI_TASK_MESSAGES.outcome.done:AI_TASK_MESSAGES.outcome.notDone;toast.value={text:AI_TASK_MESSAGES.toast(closed.title,heading),action:false}}});const projection=computed(()=>tasks.task.value&&projectAiTask(tasks.task.value,{viewerId:tasks.viewerId.value}));const taskWindow=useAiTaskWindow({task:tasks.task,loaded:tasks.loaded,active,opensOn:()=>projection.value?.opensOn||`progress`,route,router});function returnFocusTarget(){return taskWindow.opener()||document.querySelector(`[data-vibe64-ai-task-tray]`)||fallbackFocus()}async function start(kind,opener,input){const task=await tasks.start(kind,input);if(task)await nextTick();if(task)taskWindow.show(opener);else toast.value={text:tasks.error.value,action:false};return task}async function close(){const target=returnFocusTarget();await tasks.close();if(tasks.task.value)return;taskWindow.hide();await nextTick();(target?.isConnected?target:fallbackFocus())?.focus({preventScroll:true})}async function waitForAi(){taskWindow.hide();await nextTick();fallbackFocus()?.focus({preventScroll:true})}function run(actionId){const{task}=tasks;if(actionId===AI_TASK_ACTIONS.ANSWER||actionId===AI_TASK_ACTIONS.OPEN_CHAT)taskWindow.setView(`chat`);else if(actionId===AI_TASK_ACTIONS.CHECK)tasks.check();else if(actionId===AI_TASK_ACTIONS.RUN_NOW)tasks.check({whileAiWorks:true});else if(actionId===AI_TASK_ACTIONS.WAIT_FOR_AI)waitForAi();else if(actionId===AI_TASK_ACTIONS.CONTINUE)tasks.continueTask();else if(actionId===AI_TASK_ACTIONS.FINISH)tasks.finish();else if(actionId===AI_TASK_ACTIONS.END)tasks.cancel();else if(actionId===AI_TASK_ACTIONS.AI_SETUP)openAiSetup();else if(actionId===AI_TASK_ACTIONS.REVIEW&&task.value)reviewResolved()}function seeToastResult(){toast.value=null;taskWindow.show(null)}watch(()=>tasks.task.value&&aiTaskEnded(tasks.task.value),(ended,wasEnded)=>{if(!ended||wasEnded!==false||taskWindow.open.value||!toValue(active))return;toast.value={text:AI_TASK_MESSAGES.toast(tasks.task.value.title,projection.value.outcome.heading),action:true}});return reactive({cancel:tasks.cancel,cancelRequested:tasks.cancelRequested,check:tasks.check,close,closing:tasks.closing,error:tasks.error,hide:taskWindow.hide,open:taskWindow.open,projection,returnFocusTarget,run,seeToastResult,setTranscript:open=>{taskWindow.transcriptOpen.value=open},setView:taskWindow.setView,show:taskWindow.show,start,starting:tasks.starting,task:tasks.task,toast,transcriptOpen:taskWindow.transcriptOpen,view:taskWindow.view})}var _sfc_main$4={__name:`Vibe64AiTaskButton`,props:{kind:{required:true,type:String},allowed:{required:true,type:Boolean},title:{required:true,type:String},input:{required:true,type:Object}},emits:[`done`],setup(__props,{emit:__emit}){const props=__props;const emit=__emit;const tasks=inject(VIBE64_AI_TASKS_KEY);const own=computed(()=>tasks.task?.kind===props.kind?tasks.task:null);const linked=computed(()=>Boolean(own.value));const label=computed(()=>{if(tasks.starting)return AI_TASK_MESSAGES.button.opening;if(!own.value)return AI_TASK_MESSAGES.button.fix;return tasks.projection.ended?AI_TASK_MESSAGES.button.result:AI_TASK_MESSAGES.button.busy});const disabled=computed(()=>!own.value&&(!props.allowed||tasks.starting));watch(()=>own.value?.phase===AI_TASK_PHASES.DONE?own.value.id:``,doneId=>{if(doneId)emit(`done`)});function activate(event){const opener=event.currentTarget;if(own.value)tasks.show(opener);else tasks.start(props.kind,opener,props.input)}return(_ctx,_cache)=>{return openBlock(),createBlock(VBtn,{"aria-busy":label.value===unref(AI_TASK_MESSAGES).button.opening?`true`:void 0,class:`vibe64-ai-task-button`,"data-vibe64-ai-task-button":``,disabled:disabled.value,"prepend-icon":`$smartToy`,size:`small`,title:__props.title,type:`button`,variant:`tonal`,onClick:activate},createSlots({default:withCtx(()=>[createTextVNode(toDisplayString(label.value)+` `,1)]),_:2},[linked.value?{name:`append`,fn:withCtx(()=>[createVNode(VIcon,{icon:`$arrowForward`,size:`16`,"aria-hidden":`true`})]),key:`0`}:void 0]),1032,[`aria-busy`,`disabled`,`title`])}}};var Vibe64AiTaskButton_default=_plugin_vue_export_helper_default(_sfc_main$4,[[`__scopeId`,`data-v-2233af9d`]]);var _hoisted_1$3=[`aria-label`,`title`];var _hoisted_2$3={class:`vibe64-ai-task-tray__label`};var _sfc_main$3={__name:`Vibe64AiTaskTray`,setup(__props){const tasks=inject(VIBE64_AI_TASKS_KEY);const glyphIcons={attention:`$errorFilled`,done:`$checkCircleFilled`,"not-done":`$cancel`,turn:`$circle`};return(_ctx,_cache)=>{return openBlock(),createElementBlock(`button`,{"aria-label":`${unref(tasks).task.title}: ${unref(tasks).projection.tray}`,class:normalizeClass([`vibe64-ai-task-tray`,`vibe64-ai-task-tray--${unref(tasks).projection.glyph}`]),"data-vibe64-ai-task-tray":``,title:unref(tasks).projection.tray,type:`button`,onClick:_cache[0]||(_cache[0]=$event=>unref(tasks).show($event.currentTarget))},[unref(tasks).projection.glyph===`working`?(openBlock(),createBlock(VProgressCircular,{key:0,indeterminate:``,size:`16`,width:`2`,"aria-hidden":`true`})):(openBlock(),createBlock(VIcon,{key:1,icon:glyphIcons[unref(tasks).projection.glyph],size:`18`,"aria-hidden":`true`},null,8,[`icon`])),createBaseVNode(`span`,_hoisted_2$3,toDisplayString(unref(tasks).projection.tray),1)],10,_hoisted_1$3)}}};var Vibe64AiTaskTray_default=_plugin_vue_export_helper_default(_sfc_main$3,[[`__scopeId`,`data-v-56857b35`]]);var PHONE_WIDTH=600;var SHORT_HEIGHT=560;var EXPANDED_WIDTH=960;function aiTaskFit(width,height){const phone=width<PHONE_WIDTH;if(phone||height<SHORT_HEIGHT)return{fullscreen:true,phone,width:void 0,height:void 0};return width<EXPANDED_WIDTH?{fullscreen:false,phone,width:`min(92vw, 46rem)`,height:`88dvh`}:{fullscreen:false,phone,width:`46rem`,height:`min(80dvh, 46rem)`}}var REDUCED_MOTION=`(prefers-reduced-motion: reduce)`;function useAiTaskFocus({title,views,selectedView,setView,returnFocusTarget}){const tabElements=new Map;const motionQuery=globalThis.matchMedia(REDUCED_MOTION);const reducedMotion=ref(motionQuery.matches);const noteMotion=event=>{reducedMotion.value=event.matches};motionQuery.addEventListener(`change`,noteMotion);onScopeDispose(()=>motionQuery.removeEventListener(`change`,noteMotion));function focusTitle(){title.value?.focus({preventScroll:true})}function returnFocus(){returnFocusTarget()?.focus({preventScroll:true})}function setTab(view,element){if(element)tabElements.set(view,element);else tabElements.delete(view)}async function moveBetweenViews(event){const index=views.indexOf(selectedView());const next={ArrowLeft:views[(index+views.length-1)%views.length],ArrowRight:views[(index+1)%views.length],End:views.at(-1),Home:views[0]}[event.key];if(!next)return;event.preventDefault();setView(next);await nextTick();tabElements.get(next)?.focus()}return{focusTitle,moveBetweenViews,reducedMotion,returnFocus,setTab}}var _hoisted_1$2={class:`ai-task-outcome`};var _hoisted_2$2={key:0};var _hoisted_3$2={key:1};var _sfc_main$2={__name:`Vibe64AiTaskOutcome`,props:{task:{required:true,type:Object},projection:{required:true,type:Object}},emits:[`see-conversation`],setup(__props,{emit:__emit}){const emit=__emit;return(_ctx,_cache)=>{return openBlock(),createElementBlock(`div`,_hoisted_1$2,[createBaseVNode(`section`,null,[createBaseVNode(`h3`,null,toDisplayString(unref(AI_TASK_MESSAGES).outcome.problem),1),createBaseVNode(`p`,null,[createVNode(unref(LongTextInlineParts_default),{text:__props.task.problem.summary},null,8,[`text`])])]),createBaseVNode(`section`,null,[createBaseVNode(`h3`,null,toDisplayString(unref(AI_TASK_MESSAGES).outcome.whatHappened),1),createBaseVNode(`p`,null,[createVNode(unref(LongTextInlineParts_default),{text:__props.projection.outcome.happened},null,8,[`text`])])]),__props.projection.outcome.report?(openBlock(),createElementBlock(`section`,_hoisted_2$2,[createBaseVNode(`h3`,null,toDisplayString(unref(AI_TASK_MESSAGES).outcome.whatTheAiDid),1),createBaseVNode(`p`,null,[createVNode(unref(LongTextInlineParts_default),{text:__props.projection.outcome.report},null,8,[`text`])])])):createCommentVNode(``,true),__props.projection.outcome.next?(openBlock(),createElementBlock(`section`,_hoisted_3$2,[createBaseVNode(`h3`,null,toDisplayString(unref(AI_TASK_MESSAGES).outcome.whatsNext),1),createBaseVNode(`p`,null,toDisplayString(__props.projection.outcome.next),1)])):createCommentVNode(``,true),createVNode(VBtn,{class:`ai-task-outcome__conversation`,"data-vibe64-ai-task-transcript":``,variant:`text`,onClick:_cache[0]||(_cache[0]=$event=>emit(`see-conversation`))},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(AI_TASK_MESSAGES).outcome.seeConversation),1)]),_:1})])}}};var Vibe64AiTaskOutcome_default=_plugin_vue_export_helper_default(_sfc_main$2,[[`__scopeId`,`data-v-a9609028`]]);var _hoisted_1$1={class:`ai-task-progress`};var _hoisted_2$1={class:`ai-task-progress__steps`};var _hoisted_3$1={class:`ai-task-progress__label`};var _hoisted_4$1={key:0,class:`ai-task-progress__attempt`};var _hoisted_5$1={key:0,class:`ai-task-progress__note`};var _hoisted_6$1={key:1,class:`ai-task-progress__output`};var _hoisted_7$1=[`aria-label`];var _hoisted_8$1={class:`ai-task-progress__heading`};var _hoisted_9$1=[`datetime`];var _sfc_main$1={__name:`Vibe64AiTaskProgress`,props:{task:{required:true,type:Object},projection:{required:true,type:Object},output:{required:true,type:Boolean},commentary:{required:true,type:Array}},setup(__props){const props=__props;const stepIcons={active:`$radioOn`,done:`$checkCircleFilled`,failed:`$cancel`,pending:`$circle`};const activity=computed(()=>[...props.task.log,...props.commentary].sort((a,b)=>a.at.localeCompare(b.at)));return(_ctx,_cache)=>{return openBlock(),createElementBlock(`div`,_hoisted_1$1,[createBaseVNode(`ol`,_hoisted_2$1,[(openBlock(true),createElementBlock(Fragment,null,renderList(__props.projection.steps,step=>{return openBlock(),createElementBlock(`li`,{key:step.label,class:normalizeClass([`ai-task-progress__step`,`ai-task-progress__step--${step.state}`])},[createVNode(VIcon,{icon:stepIcons[step.state],size:`18`,"aria-hidden":`true`},null,8,[`icon`]),createBaseVNode(`span`,_hoisted_3$1,toDisplayString(step.label),1),step.attempt?(openBlock(),createElementBlock(`span`,_hoisted_4$1,toDisplayString(step.attempt),1)):createCommentVNode(``,true)],2)}),128))]),__props.projection.note?(openBlock(),createElementBlock(`p`,_hoisted_5$1,[createVNode(unref(LongTextInlineParts_default),{text:__props.projection.note},null,8,[`text`])])):createCommentVNode(``,true),_ctx.$slots[`check-output`]&&__props.output?(openBlock(),createElementBlock(`details`,_hoisted_6$1,[createBaseVNode(`summary`,null,toDisplayString(__props.task.check.output),1),renderSlot(_ctx.$slots,`check-output`,{},void 0,true)])):createCommentVNode(``,true),createBaseVNode(`section`,{class:`ai-task-progress__activity`,"aria-label":unref(AI_TASK_MESSAGES).progress.activity},[createBaseVNode(`h3`,_hoisted_8$1,toDisplayString(unref(AI_TASK_MESSAGES).progress.activity),1),createBaseVNode(`ol`,null,[(openBlock(true),createElementBlock(Fragment,null,renderList(activity.value,entry=>{return openBlock(),createElementBlock(`li`,{key:`${entry.at}:${entry.text}`},[createBaseVNode(`time`,{datetime:entry.at},toDisplayString(unref(aiTaskTime)(entry.at)),9,_hoisted_9$1),createBaseVNode(`span`,null,toDisplayString(entry.text),1)])}),128))])],8,_hoisted_7$1)])}}};var Vibe64AiTaskProgress_default=_plugin_vue_export_helper_default(_sfc_main$1,[[`__scopeId`,`data-v-8b486df1`]]);var _hoisted_1=[`aria-labelledby`,`data-vibe64-ai-task-phase`,`data-vibe64-ai-task-reason`];var _hoisted_2={class:`ai-task__header`};var _hoisted_3={class:`ai-task__heading`};var _hoisted_4=[`id`];var _hoisted_5={"aria-live":`polite`,class:`ai-task__status`,"data-vibe64-ai-task-status":``};var _hoisted_6={key:0,class:`ai-task__commands`};var _hoisted_7={class:`ai-task__problem`};var _hoisted_8=[`title`];var _hoisted_9=[`aria-expanded`,`aria-label`];var _hoisted_10={class:`ai-task__details-word`};var _hoisted_11={key:0,class:`ai-task__details`,"data-vibe64-ai-task-details-text":``,tabindex:`0`};var _hoisted_12=[`aria-label`];var _hoisted_13=[`id`,`aria-controls`,`aria-selected`,`data-vibe64-ai-task-view`,`tabindex`,`onClick`];var _hoisted_14=[`aria-label`];var _hoisted_15={class:`ai-task__body`};var _hoisted_16=[`id`,`aria-labelledby`];var _hoisted_17=[`id`,`aria-labelledby`,`role`];var _hoisted_18={key:1,class:`ai-task__error`,role:`alert`};var _hoisted_19={key:2,class:`ai-task__footer ai-task__footer--question`};var _hoisted_20={class:`ai-task__actions`};var _hoisted_21={key:3,class:`ai-task__footer`};var _hoisted_22={class:`ai-task__actions`};var _hoisted_23={key:4,class:`ai-task__footer`};var _hoisted_24={class:`ai-task__actions`};var _sfc_main={__name:`Vibe64AiTaskWindow`,props:{source:{required:true,type:Object},commentary:{required:true,type:Array},output:{required:true,type:Boolean}},setup(__props){const props=__props;const glyphIcons={attention:`$errorFilled`,done:`$checkCircleFilled`,"not-done":`$cancel`,turn:`$circle`};const titleId=useId();const title=ref(null);const task=computed(()=>props.source.task);const projection=computed(()=>props.source.projection);const footerActions=computed(()=>aiTaskFooterActions(projection.value.actions,props.source.view));const{width,height}=useDisplay();const fit=computed(()=>aiTaskFit(width.value,height.value));const detailsOpen=ref(false);const confirmingCancel=ref(false);const cancelling=computed(()=>props.source.cancelRequested||task.value.phase===`cancelling`);const tabs=[{id:`progress`,label:AI_TASK_MESSAGES.views.progress},{id:`chat`,label:AI_TASK_MESSAGES.views.chat}];const{focusTitle,moveBetweenViews,reducedMotion,returnFocus,setTab}=useAiTaskFocus({title,views:tabs.map(tab=>tab.id),selectedView:()=>props.source.view,setView:view=>props.source.setView(view),returnFocusTarget:()=>props.source.returnFocusTarget()});function requestCancel(){if(cancelling.value)props.source.cancel();else confirmingCancel.value=true}function cancel(){confirmingCancel.value=false;props.source.cancel()}function escape(){if(projection.value.ended)props.source.close();else props.source.hide()}watch(()=>projection.value.ended,async ended=>{if(!ended)return;confirmingCancel.value=false;await nextTick();focusTitle()});return(_ctx,_cache)=>{return openBlock(),createBlock(VDialog,{"aria-labelledby":unref(titleId),fullscreen:fit.value.fullscreen,height:fit.value.height,"model-value":__props.source.open,"no-click-animation":``,persistent:``,width:fit.value.width,transition:unref(reducedMotion)?false:void 0,onAfterEnter:unref(focusTitle),onAfterLeave:unref(returnFocus),onKeydown:withKeys(withModifiers(escape,[`stop`,`prevent`]),[`esc`])},{default:withCtx(()=>[createBaseVNode(`section`,{"aria-labelledby":unref(titleId),class:normalizeClass([`ai-task`,{"ai-task--fullscreen":fit.value.fullscreen,"ai-task--ended":projection.value.ended}]),"data-vibe64-ai-task":``,"data-vibe64-ai-task-phase":task.value.phase,"data-vibe64-ai-task-reason":task.value.reason},[createBaseVNode(`header`,_hoisted_2,[createBaseVNode(`span`,{class:normalizeClass([`ai-task__glyph`,`ai-task__glyph--${projection.value.glyph}`]),"aria-hidden":`true`},[projection.value.glyph===`working`?(openBlock(),createBlock(VProgressCircular,{key:0,indeterminate:!unref(reducedMotion),"model-value":unref(reducedMotion)?60:void 0,size:`20`,width:`2`},null,8,[`indeterminate`,`model-value`])):(openBlock(),createBlock(VIcon,{key:1,icon:glyphIcons[projection.value.glyph],size:`22`},null,8,[`icon`]))],2),createBaseVNode(`div`,_hoisted_3,[createBaseVNode(`h2`,{id:unref(titleId),ref_key:`title`,ref:title,tabindex:`-1`},toDisplayString(projection.value.ended?projection.value.outcome.heading:task.value.title),9,_hoisted_4),createBaseVNode(`p`,_hoisted_5,[projection.value.ended?(openBlock(),createElementBlock(Fragment,{key:0},[createTextVNode(toDisplayString(task.value.title),1)],64)):(openBlock(),createBlock(unref(LongTextInlineParts_default),{key:1,text:projection.value.status},null,8,[`text`]))])]),!projection.value.ended?(openBlock(),createElementBlock(`div`,_hoisted_6,[createVNode(VBtn,{"data-vibe64-ai-task-hide":``,variant:`text`,onClick:__props.source.hide},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(AI_TASK_MESSAGES).actions.hide),1)]),_:1},8,[`onClick`]),createVNode(VBtn,{"aria-busy":cancelling.value?`true`:void 0,"data-vibe64-ai-task-cancel":``,variant:`text`,onClick:requestCancel},{default:withCtx(()=>[createTextVNode(toDisplayString(cancelling.value?unref(AI_TASK_MESSAGES).actions.cancelling:unref(AI_TASK_MESSAGES).actions.cancel),1)]),_:1},8,[`aria-busy`])])):createCommentVNode(``,true)]),!projection.value.ended?(openBlock(),createElementBlock(Fragment,{key:0},[createBaseVNode(`div`,_hoisted_7,[createBaseVNode(`span`,{class:`ai-task__problem-line`,title:task.value.problem.summary},[createVNode(unref(LongTextInlineParts_default),{text:task.value.problem.summary},null,8,[`text`])],8,_hoisted_8),task.value.problem.details?(openBlock(),createElementBlock(`button`,{key:0,"aria-expanded":detailsOpen.value?`true`:`false`,"aria-label":unref(AI_TASK_MESSAGES).actions.details,class:`ai-task__details-toggle`,"data-vibe64-ai-task-details":``,type:`button`,onClick:_cache[0]||(_cache[0]=$event=>detailsOpen.value=!detailsOpen.value)},[createBaseVNode(`span`,_hoisted_10,toDisplayString(unref(AI_TASK_MESSAGES).actions.details),1),createVNode(VIcon,{icon:detailsOpen.value?`$collapse`:`$expand`,size:`18`,"aria-hidden":`true`},null,8,[`icon`])],8,_hoisted_9)):createCommentVNode(``,true)]),detailsOpen.value?(openBlock(),createElementBlock(`pre`,_hoisted_11,toDisplayString(task.value.problem.details),1)):createCommentVNode(``,true),createBaseVNode(`div`,{"aria-label":unref(AI_TASK_MESSAGES).views.label,class:`ai-task__views`,role:`tablist`,onKeydown:_cache[1]||(_cache[1]=(...args)=>unref(moveBetweenViews)&&unref(moveBetweenViews)(...args))},[(openBlock(),createElementBlock(Fragment,null,renderList(tabs,tab=>{return createBaseVNode(`button`,{id:`${unref(titleId)}-${tab.id}-tab`,key:tab.id,ref_for:true,ref:element=>unref(setTab)(tab.id,element),"aria-controls":`${unref(titleId)}-${tab.id}`,"aria-selected":__props.source.view===tab.id?`true`:`false`,class:normalizeClass([`ai-task__view`,{"ai-task__view--selected":__props.source.view===tab.id}]),"data-vibe64-ai-task-view":tab.id,role:`tab`,tabindex:__props.source.view===tab.id?0:-1,type:`button`,onClick:$event=>__props.source.setView(tab.id)},[createTextVNode(toDisplayString(tab.label)+` `,1),tab.id===`chat`&&projection.value.chatDot?(openBlock(),createElementBlock(`span`,{key:0,class:`ai-task__dot`,role:`img`,"aria-label":unref(AI_TASK_MESSAGES).views.waiting},null,8,_hoisted_14)):createCommentVNode(``,true)],10,_hoisted_13)}),64))],40,_hoisted_12)],64)):createCommentVNode(``,true),createBaseVNode(`div`,_hoisted_15,[!projection.value.ended?withDirectives((openBlock(),createElementBlock(`section`,{key:0,id:`${unref(titleId)}-progress`,"aria-labelledby":`${unref(titleId)}-progress-tab`,class:`ai-task__panel`,role:`tabpanel`},[createVNode(Vibe64AiTaskProgress_default,{commentary:__props.commentary,output:__props.output,projection:projection.value,task:task.value},{"check-output":withCtx(()=>[renderSlot(_ctx.$slots,`check-output`,{},void 0,true)]),_:3},8,[`commentary`,`output`,`projection`,`task`])],8,_hoisted_16)),[[vShow,__props.source.view===`progress`]]):!__props.source.transcriptOpen?(openBlock(),createBlock(Vibe64AiTaskOutcome_default,{key:1,projection:projection.value,task:task.value,onSeeConversation:_cache[2]||(_cache[2]=$event=>__props.source.setTranscript(true))},null,8,[`projection`,`task`])):createCommentVNode(``,true),withDirectives(createBaseVNode(`section`,{id:`${unref(titleId)}-chat`,"aria-labelledby":projection.value.ended?void 0:`${unref(titleId)}-chat-tab`,class:`ai-task__panel`,role:projection.value.ended?void 0:`tabpanel`},[renderSlot(_ctx.$slots,`chat`,{visible:__props.source.open&&(projection.value.ended?__props.source.transcriptOpen:__props.source.view===`chat`)},void 0,true)],8,_hoisted_17),[[vShow,!projection.value.ended?__props.source.view===`chat`:__props.source.transcriptOpen]])]),__props.source.error?(openBlock(),createElementBlock(`p`,_hoisted_18,toDisplayString(__props.source.error),1)):createCommentVNode(``,true),confirmingCancel.value?(openBlock(),createElementBlock(`footer`,_hoisted_19,[createBaseVNode(`p`,null,toDisplayString(projection.value.cancelQuestion),1),createBaseVNode(`div`,_hoisted_20,[createVNode(VBtn,{"data-vibe64-ai-task-keep-going":``,variant:`text`,onClick:_cache[3]||(_cache[3]=$event=>confirmingCancel.value=false)},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(AI_TASK_MESSAGES).actions.keepGoing),1)]),_:1}),createVNode(VBtn,{color:`error`,"data-vibe64-ai-task-cancel-confirm":``,variant:`flat`,onClick:cancel},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(AI_TASK_MESSAGES).cancelConfirm(task.value.noun)),1)]),_:1})])])):projection.value.ended?(openBlock(),createElementBlock(`footer`,_hoisted_21,[createBaseVNode(`div`,_hoisted_22,[__props.source.transcriptOpen?(openBlock(),createBlock(VBtn,{key:0,variant:`text`,onClick:_cache[4]||(_cache[4]=$event=>__props.source.setTranscript(false))},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(AI_TASK_MESSAGES).outcome.showResult),1)]),_:1})):createCommentVNode(``,true),createVNode(VBtn,{"aria-busy":__props.source.closing?`true`:void 0,color:`primary`,"data-vibe64-ai-task-close":``,variant:`flat`,onClick:__props.source.close},{default:withCtx(()=>[createTextVNode(toDisplayString(__props.source.closing?unref(AI_TASK_MESSAGES).actions.closing:unref(AI_TASK_MESSAGES).actions.close),1)]),_:1},8,[`aria-busy`,`onClick`])])])):footerActions.value.length?(openBlock(),createElementBlock(`footer`,_hoisted_23,[createBaseVNode(`div`,_hoisted_24,[(openBlock(true),createElementBlock(Fragment,null,renderList(footerActions.value,item=>{return openBlock(),createBlock(VBtn,{key:item.id,color:item.primary?`primary`:void 0,"data-vibe64-ai-task-action":item.id,variant:item.primary?`flat`:`text`,onClick:$event=>__props.source.run(item.id)},{default:withCtx(()=>[createTextVNode(toDisplayString(item.label),1)]),_:2},1032,[`color`,`data-vibe64-ai-task-action`,`variant`,`onClick`])}),128))])])):createCommentVNode(``,true)],10,_hoisted_1)]),_:3},8,[`aria-labelledby`,`fullscreen`,`height`,`model-value`,`width`,`transition`,`onAfterEnter`,`onAfterLeave`,`onKeydown`])}}};var Vibe64AiTaskWindow_default=_plugin_vue_export_helper_default(_sfc_main,[[`__scopeId`,`data-v-43823fc5`]]);var REPOSITORY_STATUS_SESSION_REASONS=new Set([`claude-stream-turn-idle`,`codex-app-server-turn-idle`,`opencode-server-turn-idle`,`repository-canonical-changed`,`session-pull-request`,`session-repository-checked`,`session-save-completed`,`session-save-failed`,`session-save-started`,`session-save-update-required`,`session-starter-applied`,`session-turn-checkpoint-failed`,`session-turn-checkpoint-updated`,`session-update-completed`,`session-update-failed`,`session-update-started`]);var REPOSITORY_UPDATE_CHECK_FAILED_REASON=`session-repository-check-failed`;var REPOSITORY_CANONICAL_RECHECK_REASONS=new Set([`repository-canonical-changed`,`session-pull-request`,`session-save-failed`,`session-save-update-required`,`session-update-failed`]);function repositoryStatusSessionId(payload={}){const event=normalizeObject(payload);return String(event.sessionId||event.session?.sessionId||``).trim()}function repositoryStatusRealtimeShouldRefresh(payload={}){return REPOSITORY_STATUS_SESSION_REASONS.has(String(normalizeObject(payload).reason||``).trim())}function repositoryStatusRealtimeNeedsCanonicalCheck(payload={}){return REPOSITORY_CANONICAL_RECHECK_REASONS.has(String(normalizeObject(payload).reason||``).trim())}export{Vibe64AiTaskWindow_default as a,useAiTaskHost as c,repositoryStatusSessionId as i,AI_TASK_PHASES as l,repositoryStatusRealtimeNeedsCanonicalCheck as n,Vibe64AiTaskTray_default as o,repositoryStatusRealtimeShouldRefresh as r,Vibe64AiTaskButton_default as s,REPOSITORY_UPDATE_CHECK_FAILED_REASON as t,VIBE64_AI_TASKS_KEY as u};
@@ -1 +1 @@
1
- import{Et as unref,H as openBlock,N as nextTick,Xt as toDisplayString,b as createVNode,d as createBaseVNode,f as createBlock,i as Fragment,it as watch,m as createElementBlock,ot as withCtx,p as createCommentVNode,u as computed,vt as ref,y as createTextVNode}from"./runtime-core.esm-bundler-Bi1P1jMa.js";import{S as VIcon,_ as VProgressLinear}from"./VChip-D2IukBZw.js";import{t as useEndpointResource}from"./useEndpointResource-CmMwteuX.js";import{t as VSelect}from"./VSelect-Ch00dyiM.js";import{n as VAlert,t as VSkeletonLoader}from"./VSkeletonLoader-Bl9P5wdh.js";import{t as VTextField}from"./VTextField-B9R7EIjg.js";import{i as scopedDevelopmentApiUrl}from"./studioUrls-k_pQIuPs.js";import{l as requestVibe64AiOnboarding,y as useModelRouting}from"./client-BRcncaFt.js";import{t as VBtn}from"./VBtn-2vbH580C.js";import{t as VSheet}from"./VSheet-D5wAuyc2.js";import{t as VDialog}from"./VDialog-BCIrX462.js";import{i as VCardTitle,n as VCardText,o as VCardActions,t as VCard}from"./VCard-BFqQSnAE.js";import{t as VSpacer}from"./VSpacer-GgPR_AzN.js";import{t as VSwitch}from"./VSwitch-DftK1EyR.js";import{t as VTextarea}from"./VTextarea-CMgyRNk-.js";import{t as _plugin_vue_export_helper_default}from"./_plugin-vue_export-helper-DNW4j-dv.js";import{t as _sfc_main$2}from"./SelectField-RGWl_ms9.js";import{t as useUiFeedback}from"./useUiFeedback-CWb6o71Z.js";import{t as readRefOrGetterValue}from"./vueRefOrGetterValue-y-4f_In7.js";import{L as vibe64SessionPath,k as vibe64RepositoryApiPath,o as VIBE64_SESSIONS_API_SUFFIX}from"./vibe64SessionRequestConfig-DVRCRAex.js";import{b as sameVibe64AssistantSelection,c as vibe64AssistantSelectionLabel}from"./shared-B6plZPQ_.js";import{A as requestVibe64AccountConnectionsDialog,O as Vibe64SessionAssistantMenu_default}from"./index-tPEeYKmw.js";import{a as vibe64SessionPullRequest,i as vibe64SessionDisplayTitle}from"./vibe64SessionViewModel-CQCds_jb.js";import{a as githubProjectRepositoryName,t as GITHUB_BODY_MAX_LENGTH}from"./vibe64GithubProject-CJneIo5O.js";var _hoisted_1$1={class:`d-flex align-center justify-space-between ga-2 pa-5 pb-2`};var _hoisted_2$1={class:`d-flex align-center ga-3`};var _hoisted_3$1={class:`text-label-large`};var _hoisted_4$1={class:`text-body-medium mt-1`};var _hoisted_5$1={key:0,role:`status`};var _sfc_main$1={__name:`Vibe64CreatePullRequestDialog`,props:{modelValue:Boolean,dashboardContext:{required:true,type:Object}},emits:[`update:modelValue`,`created`],setup(__props,{emit:__emit}){const props=__props;const emit=__emit;const title=ref(``);const body=ref(``);const draft=ref(true);const pending=ref(false);const destinationReview=ref(null);const feedback=useUiFeedback({source:`vibe64.pullRequests.create`});const session=computed(()=>props.dashboardContext.session||{});const source=computed(()=>vibe64SessionPullRequest(session.value));const repository=computed(()=>githubProjectRepositoryName(props.dashboardContext.projectContext));const branch=computed(()=>{if(source.value?.headBranch)return source.value.headBranch;const destination=props.dashboardContext.workState?.destination;if(destination?.mode===`github`&&destination.branch!==props.dashboardContext.projectContext?.repository?.defaultBranch)return destination.branch;return`vibe64/pr-${props.dashboardContext.sessionId}`});const base=computed(()=>source.value?.baseBranch||props.dashboardContext.projectContext?.repository?.defaultBranch||``);const path=computed(()=>vibe64SessionPath(readRefOrGetterValue(props.dashboardContext.sessionsApiPath),props.dashboardContext.sessionId,`/pull-request`));const resource=useEndpointResource({path,queryKey:computed(()=>[`vibe64.createPullRequest`,path.value]),enabled:false});watch(()=>props.modelValue,open=>{if(open)destinationReview.value=props.dashboardContext.workState?.destination?{...props.dashboardContext.workState.destination}:null},{immediate:true});watch(()=>props.dashboardContext.sessionId,()=>{title.value=source.value?.title||vibe64SessionDisplayTitle(session.value);body.value=source.value?.body||``;draft.value=true},{immediate:true});async function submit(){if(pending.value||!title.value.trim())return;pending.value=true;try{const result=await resource.save({title:title.value.trim(),body:body.value,draft:draft.value,destinationReview:destinationReview.value},{method:`POST`});feedback.success(`Pull request created. Future commits update its source branch.`);emit(`created`,result.pullRequest);emit(`update:modelValue`,false);props.dashboardContext.refreshSessionWork?.()}catch(error){feedback.error(error,`The pull request could not be confirmed. Retry to check GitHub and continue.`)}finally{pending.value=false}}return(_ctx,_cache)=>{return openBlock(),createBlock(VDialog,{"model-value":__props.modelValue,"max-width":`38rem`,scrollable:``,persistent:pending.value,"onUpdate:modelValue":_cache[5]||(_cache[5]=$event=>emit(`update:modelValue`,$event))},{default:withCtx(()=>[createVNode(VCard,{rounded:`xl`},{default:withCtx(()=>[createBaseVNode(`div`,_hoisted_1$1,[createBaseVNode(`div`,_hoisted_2$1,[createVNode(VIcon,{icon:`$callMerge`,color:`primary`}),_cache[6]||(_cache[6]=createBaseVNode(`h2`,{class:`text-title-large`},`Create pull request`,-1))]),createVNode(VBtn,{icon:`$close`,size:`48`,variant:`text`,"aria-label":`Close pull request dialog`,disabled:pending.value,onClick:_cache[0]||(_cache[0]=$event=>emit(`update:modelValue`,false))},null,8,[`disabled`])]),createVNode(VCardText,{class:`d-flex flex-column ga-3`},{default:withCtx(()=>[createVNode(VSheet,{color:`surface-light`,rounded:`lg`,class:`pa-3 pr-destination`},{default:withCtx(()=>[createBaseVNode(`div`,_hoisted_3$1,toDisplayString(repository.value),1),createBaseVNode(`div`,_hoisted_4$1,toDisplayString(branch.value)+` → `+toDisplayString(base.value),1),_cache[7]||(_cache[7]=createBaseVNode(`p`,{class:`text-body-small on-surface-variant mt-2 mb-0`},`The base branch stays unchanged.`,-1))]),_:1}),_cache[8]||(_cache[8]=createBaseVNode(`p`,{class:`text-body-small ma-0`},`Save open file edits first.`,-1)),!destinationReview.value?(openBlock(),createElementBlock(`p`,_hoisted_5$1,`Refresh repository status before creating a pull request.`)):createCommentVNode(``,true),createVNode(VTextField,{modelValue:title.value,"onUpdate:modelValue":_cache[1]||(_cache[1]=$event=>title.value=$event),label:`Title`,variant:`outlined`,maxlength:`256`,disabled:pending.value,"hide-details":``},null,8,[`modelValue`,`disabled`]),createVNode(VTextarea,{modelValue:body.value,"onUpdate:modelValue":_cache[2]||(_cache[2]=$event=>body.value=$event),label:`Description`,placeholder:`What changed, and how did you check it?`,variant:`outlined`,rows:`3`,"auto-grow":``,maxlength:unref(GITHUB_BODY_MAX_LENGTH),disabled:pending.value,"hide-details":``},null,8,[`modelValue`,`maxlength`,`disabled`]),createVNode(VSwitch,{modelValue:draft.value,"onUpdate:modelValue":_cache[3]||(_cache[3]=$event=>draft.value=$event),color:`primary`,label:`Create as draft`,disabled:pending.value,"hide-details":``},null,8,[`modelValue`,`disabled`]),_cache[9]||(_cache[9]=createBaseVNode(`details`,{class:`pr-details text-body-small`},[createBaseVNode(`summary`,{class:`py-3`},`What gets pushed`),createBaseVNode(`p`,null,`All saved file changes are committed and pushed to the PR branch. Database data and chat history are separate. GitHub automation may run; this does not publish the app.`)],-1))]),_:1}),createVNode(VCardActions,{class:`pa-5 pt-2`},{default:withCtx(()=>[createVNode(VSpacer),createVNode(VBtn,{variant:`text`,disabled:pending.value,onClick:_cache[4]||(_cache[4]=$event=>emit(`update:modelValue`,false))},{default:withCtx(()=>[..._cache[10]||(_cache[10]=[createTextVNode(`Cancel`,-1)])]),_:1},8,[`disabled`]),createVNode(VBtn,{color:`primary`,variant:`flat`,rounded:`pill`,disabled:pending.value||!title.value.trim()||!destinationReview.value||__props.dashboardContext.sourceOperationsSuspended,"aria-busy":pending.value,onClick:submit},{default:withCtx(()=>[createTextVNode(toDisplayString(pending.value?`Creating…`:draft.value?`Create draft PR`:`Create pull request`),1)]),_:1},8,[`disabled`,`aria-busy`])]),_:1})]),_:1})]),_:1},8,[`model-value`,`persistent`])}}};var Vibe64CreatePullRequestDialog_default=_plugin_vue_export_helper_default(_sfc_main$1,[[`__scopeId`,`data-v-3f93a801`]]);var _hoisted_1={class:`vibe64-assistant-dialog__title-copy`};var _hoisted_2={class:`text-body-small`};var _hoisted_3={key:2,class:`vibe64-assistant-dialog__ai`};var _hoisted_4={class:`text-body-medium mb-0`};var _hoisted_5={key:3,class:`d-flex flex-column ga-2`};var _hoisted_6={key:0,class:`d-flex flex-column ga-3 mt-3`};var _hoisted_7={key:0,class:`text-body-small`,style:{"overflow-wrap":`anywhere`}};var _hoisted_8={key:0,class:`vibe64-assistant-dialog__progress`,role:`status`,"aria-live":`polite`};var _sfc_main={__name:`Vibe64AssistantSessionDialog`,props:{modelValue:Boolean,toolbar:{required:true,type:Object}},emits:[`created`,`update:model-value`],setup(__props,{emit:__emit}){const props=__props;const emit=__emit;const routing=useModelRouting({enabled:computed(()=>props.modelValue),view:`main`});const mainSelection=routing.mainChatSelection;const openConnectionSettings=()=>requestVibe64AccountConnectionsDialog({section:`ai`});const canChooseSessionAi=computed(()=>routing.resource.data.value?.canConfigure===true);const sessionAi=ref(null);const customOpen=ref(false);const changeButton=ref(null);const aiSummary=computed(()=>sessionAi.value?`This session runs on: ${vibe64AssistantSelectionLabel(sessionAi.value)}`:`Runs on your main AI: ${vibe64AssistantSelectionLabel(mainSelection.value)}`);function openSessionAiChoice(){if(canChooseSessionAi.value&&!submitting.value)customOpen.value=true}function chooseSessionAi(selection){sessionAi.value=sameVibe64AssistantSelection(selection,mainSelection.value)?null:selection;return{ok:true}}function useMainAi(){sessionAi.value=null}function setUpAi(){close();requestVibe64AiOnboarding()}const submitButton=ref(null);const submitting=computed(()=>props.toolbar.createSessionRunning===true);const branchMode=ref(`project`);const chooseBranch=computed(()=>branchMode.value!==`project`);const createBranch=computed(()=>branchMode.value===`new`);const branchName=ref(``);const newBranchName=ref(``);const branchProject=computed(()=>props.toolbar.projectContext||{});const branchSelectionAvailable=computed(()=>!props.toolbar.repositoryBranchSelectionDisabled&&[`github`,`managed_git`].includes(branchProject.value.repositoryMode||branchProject.value.repository?.mode));const branchChoices=computed(()=>[{title:`Project branch (${branchProject.value.repository?.defaultBranch||`main`})`,value:`project`},{title:`Create a new branch`,value:`new`},{title:`Use an existing branch`,value:`existing`}]);const branchRepository=computed(()=>branchProject.value.githubRepository?.fullName||branchProject.value.repository?.github?.fullName||branchProject.value.slug);const branchPath=computed(()=>scopedDevelopmentApiUrl(`${vibe64RepositoryApiPath(`/api${VIBE64_SESSIONS_API_SUFFIX}`)}/branches`,branchProject.value.slug));const branches=useEndpointResource({path:branchPath,queryKey:computed(()=>[`vibe64.branches`,branchPath.value]),enabled:computed(()=>props.modelValue&&branchSelectionAvailable.value&&chooseBranch.value),queryOptions:{retry:false},fallbackLoadError:`Repository branches could not load.`});const selectedBranch=computed(()=>branches.data.value?.branches?.find(item=>item.name===branchName.value));const branchAlreadyExists=computed(()=>branches.data.value?.branches?.some(item=>item.name===newBranchName.value.trim()));const branchSelectionReady=computed(()=>{if(!chooseBranch.value)return true;if(!selectedBranch.value||branches.isLoading.value||branches.loadError.value)return false;return!createBranch.value||Boolean(newBranchName.value.trim())&&!branchAlreadyExists.value});watch(()=>branches.data.value,value=>{if(!value?.branches?.some(item=>item.name===branchName.value))branchName.value=value?.defaultBranch||``},{immediate:true});function close(){if(!submitting.value)emit(`update:model-value`,false)}async function submit(){if(!mainSelection.value||submitting.value||!branchSelectionReady.value)return;let response;try{const options={};if(chooseBranch.value)options.repositoryBranch={name:createBranch.value?newBranchName.value.trim():branchName.value,...createBranch.value?{fromBranch:branchName.value}:{},expectedCommit:selectedBranch.value.commit};response=await props.toolbar.createSession(sessionAi.value||{},options)}catch{return}if(response?.ok!==false&&response?.sessionId){emit(`created`,response);emit(`update:model-value`,false)}}watch(()=>props.modelValue,open=>{if(!open)return;branchMode.value=`project`;branchName.value=branches.data.value?.defaultBranch||``;newBranchName.value=``;sessionAi.value=null;customOpen.value=false},{immediate:true});watch(submitting,async(running,wasRunning)=>{if(running||!wasRunning||!props.modelValue)return;await nextTick();const target=submitButton.value?.$el;if(target?.isConnected===true)target.focus({preventScroll:true})});return(_ctx,_cache)=>{return openBlock(),createBlock(VDialog,{"model-value":__props.modelValue,persistent:submitting.value,"max-width":`38rem`,scrollable:``,"onUpdate:modelValue":_cache[6]||(_cache[6]=$event=>!$event&&close())},{default:withCtx(()=>[createVNode(VCard,{class:`vibe64-assistant-dialog`,rounded:`xl`},{default:withCtx(()=>[createVNode(VCardTitle,{class:`vibe64-assistant-dialog__title`},{default:withCtx(()=>[createBaseVNode(`span`,_hoisted_1,[_cache[7]||(_cache[7]=createBaseVNode(`strong`,{class:`text-title-large`},`Start an AI session`,-1)),createBaseVNode(`small`,_hoisted_2,toDisplayString(sessionAi.value?`Starts in Custom. Choose Senior, Junior or Auto from chat.`:`Starts in Auto. Choose Senior or Junior from chat.`),1)]),createVNode(VBtn,{"aria-label":`Close AI session dialog`,disabled:submitting.value,icon:`$close`,title:`Close`,variant:`text`,onClick:close},null,8,[`disabled`])]),_:1}),createVNode(VCardText,{class:`vibe64-assistant-dialog__body`},{default:withCtx(()=>[unref(routing).resource.isInitialLoading.value?(openBlock(),createBlock(VSkeletonLoader,{key:0,type:`list-item-two-line`})):unref(routing).loadError.value?(openBlock(),createBlock(VAlert,{key:1,type:`error`,variant:`tonal`},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(routing).loadError.value)+` `,1),createVNode(VBtn,{variant:`text`,onClick:_cache[0]||(_cache[0]=$event=>unref(routing).resource.reload())},{default:withCtx(()=>[..._cache[8]||(_cache[8]=[createTextVNode(`Try again`,-1)])]),_:1})]),_:1})):unref(mainSelection)?(openBlock(),createElementBlock(`div`,_hoisted_3,[createBaseVNode(`p`,_hoisted_4,[createTextVNode(toDisplayString(aiSummary.value)+` `,1),canChooseSessionAi.value?(openBlock(),createBlock(VBtn,{key:0,ref_key:`changeButton`,ref:changeButton,disabled:submitting.value,size:`small`,variant:`text`,onClick:openSessionAiChoice},{default:withCtx(()=>[..._cache[9]||(_cache[9]=[createTextVNode(` Change `,-1)])]),_:1},8,[`disabled`])):createCommentVNode(``,true),sessionAi.value?(openBlock(),createBlock(VBtn,{key:1,disabled:submitting.value,size:`small`,variant:`text`,onClick:useMainAi},{default:withCtx(()=>[..._cache[10]||(_cache[10]=[createTextVNode(`Use main AI`,-1)])]),_:1},8,[`disabled`])):createCommentVNode(``,true)]),createVNode(VBtn,{class:`vibe64-assistant-dialog__main-ai`,disabled:submitting.value,"prepend-icon":`$settings`,size:`small`,variant:`text`,onClick:openConnectionSettings},{default:withCtx(()=>[..._cache[11]||(_cache[11]=[createTextVNode(` Change main AI for all sessions `,-1)])]),_:1},8,[`disabled`])])):(openBlock(),createElementBlock(`div`,_hoisted_5,[_cache[13]||(_cache[13]=createBaseVNode(`strong`,null,`No AI is set up yet`,-1)),_cache[14]||(_cache[14]=createBaseVNode(`span`,{class:`text-body-small`},`Set up your AI, then come back to start a session.`,-1)),createVNode(VBtn,{color:`primary`,variant:`flat`,class:`align-self-start`,onClick:setUpAi},{default:withCtx(()=>[..._cache[12]||(_cache[12]=[createTextVNode(`Set up your AI`,-1)])]),_:1})])),branchSelectionAvailable.value?(openBlock(),createElementBlock(Fragment,{key:4},[createVNode(VSelect,{modelValue:branchMode.value,"onUpdate:modelValue":_cache[1]||(_cache[1]=$event=>branchMode.value=$event),items:branchChoices.value,label:`Work on`,disabled:submitting.value,"hide-details":``,class:`mt-4`},null,8,[`modelValue`,`items`,`disabled`]),chooseBranch.value?(openBlock(),createElementBlock(`div`,_hoisted_6,[createBranch.value?(openBlock(),createBlock(VTextField,{key:0,modelValue:newBranchName.value,"onUpdate:modelValue":_cache[2]||(_cache[2]=$event=>newBranchName.value=$event),label:`New branch name`,placeholder:`e.g. improve-booking`,maxlength:`255`,disabled:submitting.value,"error-messages":newBranchName.value.trim()&&branchAlreadyExists.value?`That branch already exists. Choose an existing branch instead.`:``,"hide-details":`auto`},null,8,[`modelValue`,`disabled`,`error-messages`])):createCommentVNode(``,true),unref(branches).isLoading.value?(openBlock(),createBlock(VSkeletonLoader,{key:1,type:`list-item-two-line, paragraph`})):unref(branches).loadError.value?(openBlock(),createBlock(VAlert,{key:2,type:`error`,variant:`tonal`},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(branches).loadError.value)+` `,1),createVNode(VBtn,{variant:`text`,onClick:_cache[3]||(_cache[3]=$event=>unref(branches).reload())},{default:withCtx(()=>[..._cache[15]||(_cache[15]=[createTextVNode(`Try again`,-1)])]),_:1})]),_:1})):(openBlock(),createElementBlock(Fragment,{key:3},[createVNode(unref(_sfc_main$2),{modelValue:branchName.value,"onUpdate:modelValue":_cache[4]||(_cache[4]=$event=>branchName.value=$event),items:unref(branches).data.value?.branches||[],loading:unref(branches).isLoading.value,"item-title":`name`,"item-value":`name`,label:createBranch.value?`Create from`:`Branch`,disabled:submitting.value,"hide-details":``},null,8,[`modelValue`,`items`,`loading`,`label`,`disabled`]),selectedBranch.value?(openBlock(),createElementBlock(`p`,_hoisted_7,toDisplayString(createBranch.value?`Creates the branch and opens a new session.`:`Opens a new session on this branch.`)+` Your changes will be saved to `+toDisplayString(branchRepository.value)+`:`+toDisplayString(createBranch.value?newBranchName.value.trim()||`your new branch`:branchName.value)+`. `,1)):createCommentVNode(``,true),_cache[16]||(_cache[16]=createBaseVNode(`p`,{class:`text-body-small`},`Publishing the app still uses the project branch.`,-1))],64))])):createCommentVNode(``,true)],64)):createCommentVNode(``,true)]),_:1}),submitting.value?(openBlock(),createElementBlock(`div`,_hoisted_8,[createVNode(VProgressLinear,{indeterminate:``,color:`primary`,rounded:``}),_cache[17]||(_cache[17]=createBaseVNode(`p`,{class:`text-body-small mb-0`},` Copying the project source for the new session. This can take a little while for a large project. Any connected repositories and workspace setup then continue in the session, which shows their progress. `,-1))])):createCommentVNode(``,true),createVNode(VCardActions,{class:`vibe64-assistant-dialog__actions`},{default:withCtx(()=>[createVNode(VBtn,{disabled:submitting.value,variant:`text`,onClick:close},{default:withCtx(()=>[..._cache[18]||(_cache[18]=[createTextVNode(`Cancel`,-1)])]),_:1},8,[`disabled`]),createVNode(VBtn,{ref_key:`submitButton`,ref:submitButton,"aria-busy":submitting.value?`true`:void 0,color:`primary`,disabled:!unref(mainSelection)||submitting.value||!branchSelectionReady.value,variant:`flat`,onClick:submit},{default:withCtx(()=>[createTextVNode(toDisplayString(submitting.value?`Creating session…`:chooseBranch.value&&createBranch.value?`Create branch & session`:`Create session`),1)]),_:1},8,[`aria-busy`,`disabled`])]),_:1}),createVNode(Vibe64SessionAssistantMenu_default,{modelValue:customOpen.value,"onUpdate:modelValue":_cache[5]||(_cache[5]=$event=>customOpen.value=$event),target:changeButton.value?.$el||null,selection:sessionAi.value||unref(mainSelection),"can-configure":canChooseSessionAi.value,"changes-disabled":submitting.value,"save-selection":chooseSessionAi},null,8,[`modelValue`,`target`,`selection`,`can-configure`,`changes-disabled`])]),_:1})]),_:1},8,[`model-value`,`persistent`])}}};var Vibe64AssistantSessionDialog_default=_plugin_vue_export_helper_default(_sfc_main,[[`__scopeId`,`data-v-2024d654`]]);var CREATED_SESSION_FOCUS_TIMEOUT_MS=2e3;async function focusCreatedVibe64SessionTab(sessionId=``){const normalizedSessionId=String(sessionId||``).trim();if(!normalizedSessionId||typeof document===`undefined`)return false;const deadline=Date.now()+CREATED_SESSION_FOCUS_TIMEOUT_MS;while(Date.now()<deadline){const dialogVisible=[...document.querySelectorAll(`.vibe64-assistant-dialog`)].some(element=>element.getClientRects().length>0);const target=[...document.querySelectorAll(`[data-vibe64-session-id]`)].find(element=>element.getAttribute(`data-vibe64-session-id`)===normalizedSessionId&&element.getClientRects().length>0);if(!dialogVisible&&target){target.focus({preventScroll:true});return document.activeElement===target}await new Promise(resolve=>{(globalThis.requestAnimationFrame||(callback=>setTimeout(callback,16)))(resolve)})}return false}export{Vibe64AssistantSessionDialog_default as n,Vibe64CreatePullRequestDialog_default as r,focusCreatedVibe64SessionTab as t};
1
+ import{Et as unref,H as openBlock,N as nextTick,Xt as toDisplayString,b as createVNode,d as createBaseVNode,f as createBlock,i as Fragment,it as watch,m as createElementBlock,ot as withCtx,p as createCommentVNode,u as computed,vt as ref,y as createTextVNode}from"./runtime-core.esm-bundler-Bi1P1jMa.js";import{S as VIcon,_ as VProgressLinear}from"./VChip-D2IukBZw.js";import{t as useEndpointResource}from"./useEndpointResource-CmMwteuX.js";import{t as VSelect}from"./VSelect-Ch00dyiM.js";import{n as VAlert,t as VSkeletonLoader}from"./VSkeletonLoader-Bl9P5wdh.js";import{t as VTextField}from"./VTextField-B9R7EIjg.js";import{i as scopedDevelopmentApiUrl}from"./studioUrls-k_pQIuPs.js";import{l as requestVibe64AiOnboarding,y as useModelRouting}from"./client-BRcncaFt.js";import{t as VBtn}from"./VBtn-2vbH580C.js";import{t as VSheet}from"./VSheet-D5wAuyc2.js";import{t as VDialog}from"./VDialog-BCIrX462.js";import{i as VCardTitle,n as VCardText,o as VCardActions,t as VCard}from"./VCard-BFqQSnAE.js";import{t as VSpacer}from"./VSpacer-GgPR_AzN.js";import{t as VSwitch}from"./VSwitch-DftK1EyR.js";import{t as VTextarea}from"./VTextarea-CMgyRNk-.js";import{t as _plugin_vue_export_helper_default}from"./_plugin-vue_export-helper-DNW4j-dv.js";import{t as _sfc_main$2}from"./SelectField-RGWl_ms9.js";import{t as useUiFeedback}from"./useUiFeedback-CWb6o71Z.js";import{t as readRefOrGetterValue}from"./vueRefOrGetterValue-y-4f_In7.js";import{L as vibe64SessionPath,k as vibe64RepositoryApiPath,o as VIBE64_SESSIONS_API_SUFFIX}from"./vibe64SessionRequestConfig-DVRCRAex.js";import{b as sameVibe64AssistantSelection,c as vibe64AssistantSelectionLabel}from"./shared-B6plZPQ_.js";import{A as requestVibe64AccountConnectionsDialog,O as Vibe64SessionAssistantMenu_default}from"./index-DAareKn3.js";import{a as vibe64SessionPullRequest,i as vibe64SessionDisplayTitle}from"./vibe64SessionViewModel-CQCds_jb.js";import{a as githubProjectRepositoryName,t as GITHUB_BODY_MAX_LENGTH}from"./vibe64GithubProject-CJneIo5O.js";var _hoisted_1$1={class:`d-flex align-center justify-space-between ga-2 pa-5 pb-2`};var _hoisted_2$1={class:`d-flex align-center ga-3`};var _hoisted_3$1={class:`text-label-large`};var _hoisted_4$1={class:`text-body-medium mt-1`};var _hoisted_5$1={key:0,role:`status`};var _sfc_main$1={__name:`Vibe64CreatePullRequestDialog`,props:{modelValue:Boolean,dashboardContext:{required:true,type:Object}},emits:[`update:modelValue`,`created`],setup(__props,{emit:__emit}){const props=__props;const emit=__emit;const title=ref(``);const body=ref(``);const draft=ref(true);const pending=ref(false);const destinationReview=ref(null);const feedback=useUiFeedback({source:`vibe64.pullRequests.create`});const session=computed(()=>props.dashboardContext.session||{});const source=computed(()=>vibe64SessionPullRequest(session.value));const repository=computed(()=>githubProjectRepositoryName(props.dashboardContext.projectContext));const branch=computed(()=>{if(source.value?.headBranch)return source.value.headBranch;const destination=props.dashboardContext.workState?.destination;if(destination?.mode===`github`&&destination.branch!==props.dashboardContext.projectContext?.repository?.defaultBranch)return destination.branch;return`vibe64/pr-${props.dashboardContext.sessionId}`});const base=computed(()=>source.value?.baseBranch||props.dashboardContext.projectContext?.repository?.defaultBranch||``);const path=computed(()=>vibe64SessionPath(readRefOrGetterValue(props.dashboardContext.sessionsApiPath),props.dashboardContext.sessionId,`/pull-request`));const resource=useEndpointResource({path,queryKey:computed(()=>[`vibe64.createPullRequest`,path.value]),enabled:false});watch(()=>props.modelValue,open=>{if(open)destinationReview.value=props.dashboardContext.workState?.destination?{...props.dashboardContext.workState.destination}:null},{immediate:true});watch(()=>props.dashboardContext.sessionId,()=>{title.value=source.value?.title||vibe64SessionDisplayTitle(session.value);body.value=source.value?.body||``;draft.value=true},{immediate:true});async function submit(){if(pending.value||!title.value.trim())return;pending.value=true;try{const result=await resource.save({title:title.value.trim(),body:body.value,draft:draft.value,destinationReview:destinationReview.value},{method:`POST`});feedback.success(`Pull request created. Future commits update its source branch.`);emit(`created`,result.pullRequest);emit(`update:modelValue`,false);props.dashboardContext.refreshSessionWork?.()}catch(error){feedback.error(error,`The pull request could not be confirmed. Retry to check GitHub and continue.`)}finally{pending.value=false}}return(_ctx,_cache)=>{return openBlock(),createBlock(VDialog,{"model-value":__props.modelValue,"max-width":`38rem`,scrollable:``,persistent:pending.value,"onUpdate:modelValue":_cache[5]||(_cache[5]=$event=>emit(`update:modelValue`,$event))},{default:withCtx(()=>[createVNode(VCard,{rounded:`xl`},{default:withCtx(()=>[createBaseVNode(`div`,_hoisted_1$1,[createBaseVNode(`div`,_hoisted_2$1,[createVNode(VIcon,{icon:`$callMerge`,color:`primary`}),_cache[6]||(_cache[6]=createBaseVNode(`h2`,{class:`text-title-large`},`Create pull request`,-1))]),createVNode(VBtn,{icon:`$close`,size:`48`,variant:`text`,"aria-label":`Close pull request dialog`,disabled:pending.value,onClick:_cache[0]||(_cache[0]=$event=>emit(`update:modelValue`,false))},null,8,[`disabled`])]),createVNode(VCardText,{class:`d-flex flex-column ga-3`},{default:withCtx(()=>[createVNode(VSheet,{color:`surface-light`,rounded:`lg`,class:`pa-3 pr-destination`},{default:withCtx(()=>[createBaseVNode(`div`,_hoisted_3$1,toDisplayString(repository.value),1),createBaseVNode(`div`,_hoisted_4$1,toDisplayString(branch.value)+` → `+toDisplayString(base.value),1),_cache[7]||(_cache[7]=createBaseVNode(`p`,{class:`text-body-small on-surface-variant mt-2 mb-0`},`The base branch stays unchanged.`,-1))]),_:1}),_cache[8]||(_cache[8]=createBaseVNode(`p`,{class:`text-body-small ma-0`},`Save open file edits first.`,-1)),!destinationReview.value?(openBlock(),createElementBlock(`p`,_hoisted_5$1,`Refresh repository status before creating a pull request.`)):createCommentVNode(``,true),createVNode(VTextField,{modelValue:title.value,"onUpdate:modelValue":_cache[1]||(_cache[1]=$event=>title.value=$event),label:`Title`,variant:`outlined`,maxlength:`256`,disabled:pending.value,"hide-details":``},null,8,[`modelValue`,`disabled`]),createVNode(VTextarea,{modelValue:body.value,"onUpdate:modelValue":_cache[2]||(_cache[2]=$event=>body.value=$event),label:`Description`,placeholder:`What changed, and how did you check it?`,variant:`outlined`,rows:`3`,"auto-grow":``,maxlength:unref(GITHUB_BODY_MAX_LENGTH),disabled:pending.value,"hide-details":``},null,8,[`modelValue`,`maxlength`,`disabled`]),createVNode(VSwitch,{modelValue:draft.value,"onUpdate:modelValue":_cache[3]||(_cache[3]=$event=>draft.value=$event),color:`primary`,label:`Create as draft`,disabled:pending.value,"hide-details":``},null,8,[`modelValue`,`disabled`]),_cache[9]||(_cache[9]=createBaseVNode(`details`,{class:`pr-details text-body-small`},[createBaseVNode(`summary`,{class:`py-3`},`What gets pushed`),createBaseVNode(`p`,null,`All saved file changes are committed and pushed to the PR branch. Database data and chat history are separate. GitHub automation may run; this does not publish the app.`)],-1))]),_:1}),createVNode(VCardActions,{class:`pa-5 pt-2`},{default:withCtx(()=>[createVNode(VSpacer),createVNode(VBtn,{variant:`text`,disabled:pending.value,onClick:_cache[4]||(_cache[4]=$event=>emit(`update:modelValue`,false))},{default:withCtx(()=>[..._cache[10]||(_cache[10]=[createTextVNode(`Cancel`,-1)])]),_:1},8,[`disabled`]),createVNode(VBtn,{color:`primary`,variant:`flat`,rounded:`pill`,disabled:pending.value||!title.value.trim()||!destinationReview.value||__props.dashboardContext.sourceOperationsSuspended,"aria-busy":pending.value,onClick:submit},{default:withCtx(()=>[createTextVNode(toDisplayString(pending.value?`Creating…`:draft.value?`Create draft PR`:`Create pull request`),1)]),_:1},8,[`disabled`,`aria-busy`])]),_:1})]),_:1})]),_:1},8,[`model-value`,`persistent`])}}};var Vibe64CreatePullRequestDialog_default=_plugin_vue_export_helper_default(_sfc_main$1,[[`__scopeId`,`data-v-3f93a801`]]);var _hoisted_1={class:`vibe64-assistant-dialog__title-copy`};var _hoisted_2={class:`text-body-small`};var _hoisted_3={key:2,class:`vibe64-assistant-dialog__ai`};var _hoisted_4={class:`text-body-medium mb-0`};var _hoisted_5={key:3,class:`d-flex flex-column ga-2`};var _hoisted_6={key:0,class:`d-flex flex-column ga-3 mt-3`};var _hoisted_7={key:0,class:`text-body-small`,style:{"overflow-wrap":`anywhere`}};var _hoisted_8={key:0,class:`vibe64-assistant-dialog__progress`,role:`status`,"aria-live":`polite`};var _sfc_main={__name:`Vibe64AssistantSessionDialog`,props:{modelValue:Boolean,toolbar:{required:true,type:Object}},emits:[`created`,`update:model-value`],setup(__props,{emit:__emit}){const props=__props;const emit=__emit;const routing=useModelRouting({enabled:computed(()=>props.modelValue),view:`main`});const mainSelection=routing.mainChatSelection;const openConnectionSettings=()=>requestVibe64AccountConnectionsDialog({section:`ai`});const canChooseSessionAi=computed(()=>routing.resource.data.value?.canConfigure===true);const sessionAi=ref(null);const customOpen=ref(false);const changeButton=ref(null);const aiSummary=computed(()=>sessionAi.value?`This session runs on: ${vibe64AssistantSelectionLabel(sessionAi.value)}`:`Runs on your main AI: ${vibe64AssistantSelectionLabel(mainSelection.value)}`);function openSessionAiChoice(){if(canChooseSessionAi.value&&!submitting.value)customOpen.value=true}function chooseSessionAi(selection){sessionAi.value=sameVibe64AssistantSelection(selection,mainSelection.value)?null:selection;return{ok:true}}function useMainAi(){sessionAi.value=null}function setUpAi(){close();requestVibe64AiOnboarding()}const submitButton=ref(null);const submitting=computed(()=>props.toolbar.createSessionRunning===true);const branchMode=ref(`project`);const chooseBranch=computed(()=>branchMode.value!==`project`);const createBranch=computed(()=>branchMode.value===`new`);const branchName=ref(``);const newBranchName=ref(``);const branchProject=computed(()=>props.toolbar.projectContext||{});const branchSelectionAvailable=computed(()=>!props.toolbar.repositoryBranchSelectionDisabled&&[`github`,`managed_git`].includes(branchProject.value.repositoryMode||branchProject.value.repository?.mode));const branchChoices=computed(()=>[{title:`Project branch (${branchProject.value.repository?.defaultBranch||`main`})`,value:`project`},{title:`Create a new branch`,value:`new`},{title:`Use an existing branch`,value:`existing`}]);const branchRepository=computed(()=>branchProject.value.githubRepository?.fullName||branchProject.value.repository?.github?.fullName||branchProject.value.slug);const branchPath=computed(()=>scopedDevelopmentApiUrl(`${vibe64RepositoryApiPath(`/api${VIBE64_SESSIONS_API_SUFFIX}`)}/branches`,branchProject.value.slug));const branches=useEndpointResource({path:branchPath,queryKey:computed(()=>[`vibe64.branches`,branchPath.value]),enabled:computed(()=>props.modelValue&&branchSelectionAvailable.value&&chooseBranch.value),queryOptions:{retry:false},fallbackLoadError:`Repository branches could not load.`});const selectedBranch=computed(()=>branches.data.value?.branches?.find(item=>item.name===branchName.value));const branchAlreadyExists=computed(()=>branches.data.value?.branches?.some(item=>item.name===newBranchName.value.trim()));const branchSelectionReady=computed(()=>{if(!chooseBranch.value)return true;if(!selectedBranch.value||branches.isLoading.value||branches.loadError.value)return false;return!createBranch.value||Boolean(newBranchName.value.trim())&&!branchAlreadyExists.value});watch(()=>branches.data.value,value=>{if(!value?.branches?.some(item=>item.name===branchName.value))branchName.value=value?.defaultBranch||``},{immediate:true});function close(){if(!submitting.value)emit(`update:model-value`,false)}async function submit(){if(!mainSelection.value||submitting.value||!branchSelectionReady.value)return;let response;try{const options={};if(chooseBranch.value)options.repositoryBranch={name:createBranch.value?newBranchName.value.trim():branchName.value,...createBranch.value?{fromBranch:branchName.value}:{},expectedCommit:selectedBranch.value.commit};response=await props.toolbar.createSession(sessionAi.value||{},options)}catch{return}if(response?.ok!==false&&response?.sessionId){emit(`created`,response);emit(`update:model-value`,false)}}watch(()=>props.modelValue,open=>{if(!open)return;branchMode.value=`project`;branchName.value=branches.data.value?.defaultBranch||``;newBranchName.value=``;sessionAi.value=null;customOpen.value=false},{immediate:true});watch(submitting,async(running,wasRunning)=>{if(running||!wasRunning||!props.modelValue)return;await nextTick();const target=submitButton.value?.$el;if(target?.isConnected===true)target.focus({preventScroll:true})});return(_ctx,_cache)=>{return openBlock(),createBlock(VDialog,{"model-value":__props.modelValue,persistent:submitting.value,"max-width":`38rem`,scrollable:``,"onUpdate:modelValue":_cache[6]||(_cache[6]=$event=>!$event&&close())},{default:withCtx(()=>[createVNode(VCard,{class:`vibe64-assistant-dialog`,rounded:`xl`},{default:withCtx(()=>[createVNode(VCardTitle,{class:`vibe64-assistant-dialog__title`},{default:withCtx(()=>[createBaseVNode(`span`,_hoisted_1,[_cache[7]||(_cache[7]=createBaseVNode(`strong`,{class:`text-title-large`},`Start an AI session`,-1)),createBaseVNode(`small`,_hoisted_2,toDisplayString(sessionAi.value?`Starts in Custom. Choose Senior, Junior or Auto from chat.`:`Starts in Auto. Choose Senior or Junior from chat.`),1)]),createVNode(VBtn,{"aria-label":`Close AI session dialog`,disabled:submitting.value,icon:`$close`,title:`Close`,variant:`text`,onClick:close},null,8,[`disabled`])]),_:1}),createVNode(VCardText,{class:`vibe64-assistant-dialog__body`},{default:withCtx(()=>[unref(routing).resource.isInitialLoading.value?(openBlock(),createBlock(VSkeletonLoader,{key:0,type:`list-item-two-line`})):unref(routing).loadError.value?(openBlock(),createBlock(VAlert,{key:1,type:`error`,variant:`tonal`},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(routing).loadError.value)+` `,1),createVNode(VBtn,{variant:`text`,onClick:_cache[0]||(_cache[0]=$event=>unref(routing).resource.reload())},{default:withCtx(()=>[..._cache[8]||(_cache[8]=[createTextVNode(`Try again`,-1)])]),_:1})]),_:1})):unref(mainSelection)?(openBlock(),createElementBlock(`div`,_hoisted_3,[createBaseVNode(`p`,_hoisted_4,[createTextVNode(toDisplayString(aiSummary.value)+` `,1),canChooseSessionAi.value?(openBlock(),createBlock(VBtn,{key:0,ref_key:`changeButton`,ref:changeButton,disabled:submitting.value,size:`small`,variant:`text`,onClick:openSessionAiChoice},{default:withCtx(()=>[..._cache[9]||(_cache[9]=[createTextVNode(` Change `,-1)])]),_:1},8,[`disabled`])):createCommentVNode(``,true),sessionAi.value?(openBlock(),createBlock(VBtn,{key:1,disabled:submitting.value,size:`small`,variant:`text`,onClick:useMainAi},{default:withCtx(()=>[..._cache[10]||(_cache[10]=[createTextVNode(`Use main AI`,-1)])]),_:1},8,[`disabled`])):createCommentVNode(``,true)]),createVNode(VBtn,{class:`vibe64-assistant-dialog__main-ai`,disabled:submitting.value,"prepend-icon":`$settings`,size:`small`,variant:`text`,onClick:openConnectionSettings},{default:withCtx(()=>[..._cache[11]||(_cache[11]=[createTextVNode(` Change main AI for all sessions `,-1)])]),_:1},8,[`disabled`])])):(openBlock(),createElementBlock(`div`,_hoisted_5,[_cache[13]||(_cache[13]=createBaseVNode(`strong`,null,`No AI is set up yet`,-1)),_cache[14]||(_cache[14]=createBaseVNode(`span`,{class:`text-body-small`},`Set up your AI, then come back to start a session.`,-1)),createVNode(VBtn,{color:`primary`,variant:`flat`,class:`align-self-start`,onClick:setUpAi},{default:withCtx(()=>[..._cache[12]||(_cache[12]=[createTextVNode(`Set up your AI`,-1)])]),_:1})])),branchSelectionAvailable.value?(openBlock(),createElementBlock(Fragment,{key:4},[createVNode(VSelect,{modelValue:branchMode.value,"onUpdate:modelValue":_cache[1]||(_cache[1]=$event=>branchMode.value=$event),items:branchChoices.value,label:`Work on`,disabled:submitting.value,"hide-details":``,class:`mt-4`},null,8,[`modelValue`,`items`,`disabled`]),chooseBranch.value?(openBlock(),createElementBlock(`div`,_hoisted_6,[createBranch.value?(openBlock(),createBlock(VTextField,{key:0,modelValue:newBranchName.value,"onUpdate:modelValue":_cache[2]||(_cache[2]=$event=>newBranchName.value=$event),label:`New branch name`,placeholder:`e.g. improve-booking`,maxlength:`255`,disabled:submitting.value,"error-messages":newBranchName.value.trim()&&branchAlreadyExists.value?`That branch already exists. Choose an existing branch instead.`:``,"hide-details":`auto`},null,8,[`modelValue`,`disabled`,`error-messages`])):createCommentVNode(``,true),unref(branches).isLoading.value?(openBlock(),createBlock(VSkeletonLoader,{key:1,type:`list-item-two-line, paragraph`})):unref(branches).loadError.value?(openBlock(),createBlock(VAlert,{key:2,type:`error`,variant:`tonal`},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(branches).loadError.value)+` `,1),createVNode(VBtn,{variant:`text`,onClick:_cache[3]||(_cache[3]=$event=>unref(branches).reload())},{default:withCtx(()=>[..._cache[15]||(_cache[15]=[createTextVNode(`Try again`,-1)])]),_:1})]),_:1})):(openBlock(),createElementBlock(Fragment,{key:3},[createVNode(unref(_sfc_main$2),{modelValue:branchName.value,"onUpdate:modelValue":_cache[4]||(_cache[4]=$event=>branchName.value=$event),items:unref(branches).data.value?.branches||[],loading:unref(branches).isLoading.value,"item-title":`name`,"item-value":`name`,label:createBranch.value?`Create from`:`Branch`,disabled:submitting.value,"hide-details":``},null,8,[`modelValue`,`items`,`loading`,`label`,`disabled`]),selectedBranch.value?(openBlock(),createElementBlock(`p`,_hoisted_7,toDisplayString(createBranch.value?`Creates the branch and opens a new session.`:`Opens a new session on this branch.`)+` Your changes will be saved to `+toDisplayString(branchRepository.value)+`:`+toDisplayString(createBranch.value?newBranchName.value.trim()||`your new branch`:branchName.value)+`. `,1)):createCommentVNode(``,true),_cache[16]||(_cache[16]=createBaseVNode(`p`,{class:`text-body-small`},`Publishing the app still uses the project branch.`,-1))],64))])):createCommentVNode(``,true)],64)):createCommentVNode(``,true)]),_:1}),submitting.value?(openBlock(),createElementBlock(`div`,_hoisted_8,[createVNode(VProgressLinear,{indeterminate:``,color:`primary`,rounded:``}),_cache[17]||(_cache[17]=createBaseVNode(`p`,{class:`text-body-small mb-0`},` Copying the project source for the new session. This can take a little while for a large project. Any connected repositories and workspace setup then continue in the session, which shows their progress. `,-1))])):createCommentVNode(``,true),createVNode(VCardActions,{class:`vibe64-assistant-dialog__actions`},{default:withCtx(()=>[createVNode(VBtn,{disabled:submitting.value,variant:`text`,onClick:close},{default:withCtx(()=>[..._cache[18]||(_cache[18]=[createTextVNode(`Cancel`,-1)])]),_:1},8,[`disabled`]),createVNode(VBtn,{ref_key:`submitButton`,ref:submitButton,"aria-busy":submitting.value?`true`:void 0,color:`primary`,disabled:!unref(mainSelection)||submitting.value||!branchSelectionReady.value,variant:`flat`,onClick:submit},{default:withCtx(()=>[createTextVNode(toDisplayString(submitting.value?`Creating session…`:chooseBranch.value&&createBranch.value?`Create branch & session`:`Create session`),1)]),_:1},8,[`aria-busy`,`disabled`])]),_:1}),createVNode(Vibe64SessionAssistantMenu_default,{modelValue:customOpen.value,"onUpdate:modelValue":_cache[5]||(_cache[5]=$event=>customOpen.value=$event),target:changeButton.value?.$el||null,selection:sessionAi.value||unref(mainSelection),"can-configure":canChooseSessionAi.value,"changes-disabled":submitting.value,"save-selection":chooseSessionAi},null,8,[`modelValue`,`target`,`selection`,`can-configure`,`changes-disabled`])]),_:1})]),_:1},8,[`model-value`,`persistent`])}}};var Vibe64AssistantSessionDialog_default=_plugin_vue_export_helper_default(_sfc_main,[[`__scopeId`,`data-v-2024d654`]]);var CREATED_SESSION_FOCUS_TIMEOUT_MS=2e3;async function focusCreatedVibe64SessionTab(sessionId=``){const normalizedSessionId=String(sessionId||``).trim();if(!normalizedSessionId||typeof document===`undefined`)return false;const deadline=Date.now()+CREATED_SESSION_FOCUS_TIMEOUT_MS;while(Date.now()<deadline){const dialogVisible=[...document.querySelectorAll(`.vibe64-assistant-dialog`)].some(element=>element.getClientRects().length>0);const target=[...document.querySelectorAll(`[data-vibe64-session-id]`)].find(element=>element.getAttribute(`data-vibe64-session-id`)===normalizedSessionId&&element.getClientRects().length>0);if(!dialogVisible&&target){target.focus({preventScroll:true});return document.activeElement===target}await new Promise(resolve=>{(globalThis.requestAnimationFrame||(callback=>setTimeout(callback,16)))(resolve)})}return false}export{Vibe64AssistantSessionDialog_default as n,Vibe64CreatePullRequestDialog_default as r,focusCreatedVibe64SessionTab as t};
package/dist/index.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <style>@layer vuetify-core.reset, vuetify-core.base, vuetify-components, vuetify-overrides, vuetify-utilities.theme-base, vuetify-utilities.typography, vuetify-utilities.helpers, vuetify-utilities.theme-background, vuetify-utilities.theme-foreground, vuetify-final.transitions, vuetify-final.trumps;</style>
5
- <meta name="jskit-client-build" content="325ccd058ca5c892">
5
+ <meta name="jskit-client-build" content="1f21f1c4ae6657a9">
6
6
 
7
7
  <meta charset="UTF-8" />
8
8
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -24,7 +24,7 @@
24
24
  }, true);
25
25
  </script>
26
26
  <style>#startup-shell{color:#25232a;background:#faf9fc;grid-template-rows:56px 1fr;font:15px system-ui,sans-serif;display:grid;position:fixed;inset:0}#startup-shell header{border-bottom:1px solid #dedce3;align-items:center;padding:0 24px;font-weight:600;display:flex}#startup-shell main{grid-template-columns:240px 1fr;min-height:0;display:grid}#startup-shell aside{border-right:1px solid #dedce3;padding:24px}#startup-shell .startup-placeholder{background:#e5e2eb;border-radius:4px;height:16px;margin-bottom:20px}#startup-shell section{padding:32px}#startup-shell a{min-height:48px;color:inherit;align-items:center;display:inline-flex}@media (width<=600px){#startup-shell main{grid-template-columns:1fr}#startup-shell aside{display:none}}@media (prefers-color-scheme:dark){#startup-shell{color:#eeeaf3;background:#19181d}#startup-shell header,#startup-shell aside{border-color:#3c3942}#startup-shell .startup-placeholder{background:#35323d}}</style>
27
- <script type="module" crossorigin src="/assets/index-tPEeYKmw.js"></script>
27
+ <script type="module" crossorigin src="/assets/index-DAareKn3.js"></script>
28
28
  <link rel="modulepreload" crossorigin href="/assets/runtime-core.esm-bundler-Bi1P1jMa.js">
29
29
  <link rel="modulepreload" crossorigin href="/assets/normalize-BD25VwNK.js">
30
30
  <link rel="modulepreload" crossorigin href="/assets/returnToPath-CILshEkc.js">
@@ -95,7 +95,7 @@
95
95
  <link rel="modulepreload" crossorigin href="/assets/VTextarea-CMgyRNk-.js">
96
96
  <link rel="modulepreload" crossorigin href="/assets/useAssistantAttachments-BkYZckgz.js">
97
97
  <link rel="modulepreload" crossorigin href="/assets/thinkingText-mMYz6e03.js">
98
- <link rel="modulepreload" crossorigin href="/assets/conversation-wiDH8Ni4.js">
98
+ <link rel="modulepreload" crossorigin href="/assets/conversation-BoB7Drme.js">
99
99
  <link rel="modulepreload" crossorigin href="/assets/SelectField-RGWl_ms9.js">
100
100
  <link rel="modulepreload" crossorigin href="/assets/vueRefOrGetterValue-y-4f_In7.js">
101
101
  <link rel="modulepreload" crossorigin href="/assets/vibe64BrowserTabOrigin-vIN_87mi.js">
@@ -124,7 +124,7 @@
124
124
  <link rel="stylesheet" crossorigin href="/assets/VSwitch-DAlld-JI.css">
125
125
  <link rel="stylesheet" crossorigin href="/assets/client-CM6TGZc9.css">
126
126
  <link rel="stylesheet" crossorigin href="/assets/VTextarea--uW4w6nq.css">
127
- <link rel="stylesheet" crossorigin href="/assets/conversation-ZN3-8jbz.css">
127
+ <link rel="stylesheet" crossorigin href="/assets/conversation-BMyk8R_u.css">
128
128
  <link rel="stylesheet" crossorigin href="/assets/index-Ctygjyf8.css">
129
129
  </head>
130
130
  <body>
@@ -123,7 +123,12 @@ account ran out of credit shows **Out of credit: top up or switch AI account**.
123
123
  Open **Goal** to see how long it has been going.
124
124
  The control shows native **Running time** when available. Claude currently supplies
125
125
  only creation and status timestamps, so its timer is labelled **Elapsed since
126
- goal started (including pauses)**; this is not measured active runtime. On narrow
126
+ goal started (including pauses)**; this is not measured active runtime. It counts
127
+ from the goal's first start: **Pause goal**, **Resume goal** and a server restart
128
+ or deploy, whether the goal continues by itself or you resume it, never set it
129
+ back to zero. A goal you cancel or finish and then set again starts a new clock.
130
+ With no goal set, **Goal** opens a 360-pixel-wide panel (the screen's width on a
131
+ narrow phone) whose objective box fills it. On narrow
127
132
  panes, open **Goal** to see the timer. Pause, Resume and Cancel appear before long
128
133
  objectives or blocker explanations, so recovery does not require scrolling
129
134
  through the explanation.
@@ -159,6 +164,9 @@ for the native goal record linked to that exact command before saving its restar
159
164
  identity. It does not wait for the work to finish. If this record is still missing
160
165
  after 30 seconds, the control reports that the command was accepted but its goal
161
166
  attachment is pending. Check the original receipt; do not resend it blindly.
167
+ Whenever **Set goal** or **Resume goal** fails, the goal control shows the
168
+ server's reason, even when the command already appears in the conversation,
169
+ instead of only **Could not change the goal.**
162
170
 
163
171
  A Main-chat goal started or explicitly resumed after this release retains your
164
172
  request to keep working across server restarts, including an unexpected server
@@ -166,7 +174,13 @@ exit. Vibe64 verifies the previous process has stopped, rechecks your current
166
174
  project and AI access, then resumes the same native goal. Recovery does not
167
175
  need a browser tab or the original browser login cookie. If workspace preparation
168
176
  is already starting, recovery waits up to one minute for that operation's lock;
169
- it does not send a second goal command. A timeout stays visible on the goal control.
177
+ it does not send a second goal command. If continuing fails right after the
178
+ restart (for example the AI is still busy, slow to start or cannot be checked
179
+ yet), Vibe64 tries again about 30 seconds, 2 minutes and 10 minutes later. Until
180
+ then the goal control shows the error ending in **Vibe64 tries again shortly.**;
181
+ it disappears once the goal continues. A goal is never sent twice: an attempt
182
+ that may have reached the AI is checked, not repeated. An error still shown after
183
+ the last attempt stays visible on the goal control.
170
184
  **Pause goal**,
171
185
  **Cancel goal**, and **Stop** prevent that automatic continuation. A completed
172
186
  or cleared goal is not restarted. A Claude goal whose turn ended any other way,
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - A Claude goal's clock counts from its first start: Resume and restart recovery send the same unfinished objective again, which Claude starts anew, so the clock went back to zero after every Pause and Resume and after a server restart. The Claude history keeps that first start, also across the clear that suspends a paused goal's checker, and the goal value carries it as `startedAt` (ISO), which `AssistantGoalControl` counts its wall-clock time from (else `createdAt`). A goal finished or cancelled and then set again starts a new clock.
6
+ - The goal menu is 360 pixels wide, or the screen's width less the menu's 12-pixel margins on a narrower phone (the menu's `width` and `max-width`), so the new-goal objective box fills it instead of shrinking to its label.
5
7
  - `assistantConversationListItemOutputValidator` (from `@jskit-ai/assistant-core/shared`) is one conversation of `assistantContract`'s `conversationsList`, the record without its `metadata`; the contract's list output is built from it, and `@jskit-ai/assistant-runtime`'s conversations list route serializes its items with it.
6
8
  - `createConversationStorage`'s `write` saves nothing when its callback called no write method: the adapter's `writeRecord` does not run, so file storage no longer rewrites and flushes the whole conversation file, or creates an empty one for a missing conversation, when a write only looked (a delivery check, a message already saved), and the saved record stays cached.
7
9
  - Checking or recovering one message's delivery (`inspectDelivery`, and a send that finds its message already saved) finds that message's turn by its id instead of reading and cloning every turn of the conversation to find it.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/assistant-core",
3
- "version": "0.2.43",
3
+ "version": "0.2.44",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./client": "./src/client/index.js",
@@ -2,6 +2,7 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - A Set or Resume goal that the server refuses after its message already appeared in the conversation shows the server's reason (for example that Claude's goal attachment is not available yet) instead of only `jskit.assistant.runtime.goal.changeFailed` ("Could not change the goal."): the transcript turn settled the optimistic message first, so the failure's own text was dropped with it.
5
6
  - The saved-conversations list (`GET /api/assistant/:surfaceId/conversations`, and its workspace form) answers 200 again instead of 500 ("metadata is required!") once a person has a conversation: the route still serialized each item with the conversation's read schema, which requires `metadata`, after list items stopped carrying it. It serializes them with assistant-core's `assistantConversationListItemOutputValidator`, the item of `assistantContract`'s `conversationsList`. `conversationsListRoute.test.js` lists a saved conversation over HTTP through the real route, actions and SQL repositories.
6
7
  - Each conversation request authenticates once: the route's access check and the action's request context share one sign-in lookup instead of each asking again.
7
8
  - **Breaking.** Conversation list items no longer carry `metadata`: the conversations repository's `listForActorScope` reads only the fields a list shows, as `assistantContract`'s `conversationsList` now answers them. Upgrading: code that read `metadata` from a list item reads the conversation instead, with `findByIdForActorScope` or the conversation's messages read, which still answer it.