@yuriai/web 0.3.6-beta.16 → 0.3.6-beta.17
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.
- package/dist/assets/{AgentAvatar-Cz7vWoUM.js → AgentAvatar-Bt0ODtE9.js} +1 -1
- package/dist/assets/{AgentSelector-tguIbO8e.js → AgentSelector-DRcx_ZQs.js} +1 -1
- package/dist/assets/{ArchivedSessionsDialog-C0Vf38jt.js → ArchivedSessionsDialog-D9Hrnoe8.js} +1 -1
- package/dist/assets/{AssistantConversationSurface-TNj9TKag.js → AssistantConversationSurface-B82MGZSI.js} +3 -3
- package/dist/assets/{AssistantSessionCard-BX_ck4KS.js → AssistantSessionCard-DZNj8yVx.js} +2 -2
- package/dist/assets/{AssistantUnreadBadge-DSjJfYrh.js → AssistantUnreadBadge-CQnnKD_O.js} +1 -1
- package/dist/assets/{AssistantView-eAuI94K6.js → AssistantView-EYFjOoP6.js} +1 -1
- package/dist/assets/{AssistantWorkingAvatar-OhfpjL1t.js → AssistantWorkingAvatar-Co7OP4xS.js} +1 -1
- package/dist/assets/{AssistantsSettingsPage-X19bTIju.js → AssistantsSettingsPage-DGgtOrSr.js} +1 -1
- package/dist/assets/{BinaryFileFallback-DDWawtzt.js → BinaryFileFallback-BcGlqAM1.js} +1 -1
- package/dist/assets/{BtwPanel-Dhn1iVrH.js → BtwPanel-CKSZ5LKq.js} +1 -1
- package/dist/assets/{BusyDots-q2aVrHbQ.js → BusyDots-dQIHo-Ma.js} +1 -1
- package/dist/assets/{ChatContainer-CYq3DRwu.js → ChatContainer-D_76doaH.js} +4 -4
- package/dist/assets/{ChatView-CD7B735C.js → ChatView-DU-_b_EH.js} +1 -1
- package/dist/assets/{DiagramView-D8qMjsAQ.js → DiagramView-C0tuHBMp.js} +1 -1
- package/dist/assets/{DiffView-BRUUP_UF.js → DiffView-CRHue4c1.js} +1 -1
- package/dist/assets/{DiffViewToggle-Bn4WLr8E.js → DiffViewToggle-D3uTowJs.js} +1 -1
- package/dist/assets/{ErrorBoundary-UqQdMytG.js → ErrorBoundary-n23yui_O.js} +1 -1
- package/dist/assets/{FadeInOnReveal-BV_4xYNR.js → FadeInOnReveal-D2SbjK6C.js} +1 -1
- package/dist/assets/{GuiPluginMount-CEXVtLmV.js → GuiPluginMount-Drl4CCU4.js} +1 -1
- package/dist/assets/{GuiPluginPage-BziZa4M0.js → GuiPluginPage-DFIwtUfj.js} +1 -1
- package/dist/assets/{GuiPluginSurface-gxhtskj7.js → GuiPluginSurface-nrFT4ztD.js} +1 -1
- package/dist/assets/{GuiPluginTitlebarItems-mIMh81nb.js → GuiPluginTitlebarItems-C-7Ph77t.js} +1 -1
- package/dist/assets/{GuiPluginWindow-DvVG8u7w.js → GuiPluginWindow-CDWjuvFN.js} +1 -1
- package/dist/assets/{Icon-C6Duv_oe.js → Icon-CfO_2i8z.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-BIQ6Y6SP.js → ImageLoadingPlaceholder-qgu85eJI.js} +1 -1
- package/dist/assets/{LoadingImage-Dk4wxhnT.js → LoadingImage-7JiIIaoG.js} +1 -1
- package/dist/assets/{MarkdownRenderer-BY310t1T.js → MarkdownRenderer-iKD6XWgd.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-nAHoW0Z9.js → MarkdownRendererImpl-Mcnt6PjF.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-shwGZ7Tl.js → MarkstreamRendererImpl-iG1jBKhy.js} +1 -1
- package/dist/assets/{MobileAssistantSettingsPage-DOJwDh_T.js → MobileAssistantSettingsPage-DmNuGjld.js} +1 -1
- package/dist/assets/{MobileAssistantTab-BAkvh3MP.js → MobileAssistantTab-CIvNRFvS.js} +1 -1
- package/dist/assets/{MobileBtwPage-BdPAeG7v.js → MobileBtwPage-D5mXBLA1.js} +1 -1
- package/dist/assets/{MobileChangesSurface-DmlszV_t.js → MobileChangesSurface-DhW8ecAl.js} +1 -1
- package/dist/assets/{MobileChatScreen-CEbQNMgn.js → MobileChatScreen-BKAI0EMZ.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-BUMzEYEL.js → MobileDetailNavigation-DscFc9cA.js} +1 -1
- package/dist/assets/{MobileFilesSurface-DCQsIn2I.js → MobileFilesSurface-BHbQRuuZ.js} +2 -2
- package/dist/assets/{MobileHtmlNetworkBoundary-DiuzUkq3.js → MobileHtmlNetworkBoundary-SkR4tADw.js} +2 -2
- package/dist/assets/{MobileOverlayPanel-DhGG1USg.js → MobileOverlayPanel-BWdpCuxm.js} +1 -1
- package/dist/assets/{MobileResizableSheet-BN5lO8_k.js → MobileResizableSheet-yfyTX8Oo.js} +1 -1
- package/dist/assets/{MobileSettingsTab-B4wkSo7K.js → MobileSettingsTab-C1zQ-7d4.js} +1 -1
- package/dist/assets/{MobileShareBridge-DUHyEHab.js → MobileShareBridge-BFbt-sk7.js} +1 -1
- package/dist/assets/{MobileSurface-CuAPWI6D.js → MobileSurface-y5ztB7tU.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-Bh1ILbqr.js → MobileTabPageHeader-DbpsZVSd.js} +1 -1
- package/dist/assets/{ModelLogo-R0TXf5Pt.js → ModelLogo-CmNLEE95.js} +1 -1
- package/dist/assets/{ModelSelector-D5pSGqN8.js → ModelSelector-BVX9JJcb.js} +1 -1
- package/dist/assets/{MultiRunWindow-DJb6RpVw.js → MultiRunWindow-oHtBAdJv.js} +1 -1
- package/dist/assets/{OnboardingScreen-CdHEr54c.js → OnboardingScreen-C3_aPUBH.js} +1 -1
- package/dist/assets/{OverlayScrollbar-CrwDy2Pt.js → OverlayScrollbar-D1mX1ML1.js} +1 -1
- package/dist/assets/{PierreDiffViewer-BYO9Wbwk.js → PierreDiffViewer-BNCT7k1n.js} +1 -1
- package/dist/assets/{ProviderLogo-C8aB3qlM.js → ProviderLogo-Dc-sC7dP.js} +1 -1
- package/dist/assets/{RemoteAssistantSessionCard-C_hCy6FE.js → RemoteAssistantSessionCard-DdwBtdTg.js} +1 -1
- package/dist/assets/{RemoteDesktopPanel-Cj6G6AyD.js → RemoteDesktopPanel-CtdvGhZf.js} +1 -1
- package/dist/assets/{ScheduledTasksDialog-z2v4fwrE.js → ScheduledTasksDialog-DDiPlJh7.js} +1 -1
- package/dist/assets/{ScrollableOverlay-BrA__-l0.js → ScrollableOverlay-ByQtZZ3X.js} +1 -1
- package/dist/assets/{SettingsGroup-DMAcPhM4.js → SettingsGroup-I-AOS-W6.js} +1 -1
- package/dist/assets/{SettingsView-BuGjKeb9.js → SettingsView-CO6x-AEZ.js} +1 -1
- package/dist/assets/{SettingsWindow-_sonrUby.js → SettingsWindow-LrZQ0kzk.js} +1 -1
- package/dist/assets/{SetupTourDialog-Cf1Jm1Gl.js → SetupTourDialog-QMFyakMf.js} +1 -1
- package/dist/assets/{SyncActions-BWHWdbi_.js → SyncActions-DMLAgyBA.js} +1 -1
- package/dist/assets/{TerminalView-DN60v7to.js → TerminalView-CM7WLYqz.js} +1 -1
- package/dist/assets/{TextSelectionMenu-YlWMOZkS.js → TextSelectionMenu-BNa9CCBn.js} +1 -1
- package/dist/assets/{ToolOutputDialog-B388thfl.js → ToolOutputDialog-DV0EAm53.js} +1 -1
- package/dist/assets/{assistantMessagePreview-DJVWTOKl.js → assistantMessagePreview-IXh41ri6.js} +1 -1
- package/dist/assets/{assistantQueries-C_SpnqtF.js → assistantQueries-JkdxtUmV.js} +1 -1
- package/dist/assets/{auto-read-context-BO5tE9k_.js → auto-read-context-CVIcuGan.js} +1 -1
- package/dist/assets/{capgoAdapter-qaeQqHpT.js → capgoAdapter-0ZrNrgn7.js} +1 -1
- package/dist/assets/{card-t-tgqQ79.js → card-4IJyHoCN.js} +1 -1
- package/dist/assets/{chatUpwardIntent-BEntur0S.js → chatUpwardIntent-BFgRZSrN.js} +1 -1
- package/dist/assets/{checkbox-D-OIaMB8.js → checkbox-B-alKvb4.js} +1 -1
- package/dist/assets/{collapsible-CCc6anWP.js → collapsible-BtvaDglG.js} +1 -1
- package/dist/assets/{connection-hint-DAQZ45pI.js → connection-hint-D1LPeZnY.js} +1 -1
- package/dist/assets/{context-menu-BhnOdTDq.js → context-menu-DEpAiC1U.js} +1 -1
- package/dist/assets/{diagram-sCh-Ausk.js → diagram-CB-IGhF7.js} +1 -1
- package/dist/assets/{dialog-C9DNMP08.js → dialog-Wb82rwEB.js} +1 -1
- package/dist/assets/{dropdown-menu-CcQq6JDI.js → dropdown-menu-y9slmwEK.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-HhfJS8d1.js → fileMentionTouchSelection-CtFbRCDI.js} +1 -1
- package/dist/assets/{gitApi-BNkkLnOi.js → gitApi-bb-bBVgY.js} +1 -1
- package/dist/assets/{icons-DlTcJ36Q.js → icons-PMky_BAk.js} +1 -1
- package/dist/assets/{input-DVzjAzTw.js → input-DWlzP3il.js} +1 -1
- package/dist/assets/{insertionBoundaries-WYUnaIac.js → insertionBoundaries-166bwz6m.js} +1 -1
- package/dist/assets/{kbd-DA0IyUcd.js → kbd-B3OadSB1.js} +1 -1
- package/dist/assets/{main-BpAkYb0H.js → main-B8v7kGWB.js} +2 -2
- package/dist/assets/{main-BfuLSPdJ.js → main-CO2_WUmS.js} +5 -5
- package/dist/assets/{markdownHeightCache-CcgRs1ER.js → markdownHeightCache-CmqFuEAk.js} +1 -1
- package/dist/assets/{mcpQueries-CCvxTdrj.js → mcpQueries-CgVNVr9H.js} +1 -1
- package/dist/assets/{miniChat-D2l_XXQe.js → miniChat-DWon-j9p.js} +2 -2
- package/dist/assets/{mobile-mVNRvGd5.js → mobile-Dhvk6j7o.js} +2 -2
- package/dist/assets/{mobileBackNavigation-B8wJO_pZ.js → mobileBackNavigation-DQ7Ks5Mg.js} +1 -1
- package/dist/assets/{mobileConnections-Ckzqn3Y9.js → mobileConnections-CzEUaSbB.js} +2 -2
- package/dist/assets/{multirun-B34hqzTY.js → multirun-BbzH49WH.js} +1 -1
- package/dist/assets/{native-config-CD8pMBkt.js → native-config-B0QosfID.js} +1 -1
- package/dist/assets/{nativeComposerCover-CEyD3731.js → nativeComposerCover-C2r8C1wi.js} +1 -1
- package/dist/assets/{navigation-atykJu0I.js → navigation-DXOStpft.js} +1 -1
- package/dist/assets/{openRemoteProjectSession-B63pkBaj.js → openRemoteProjectSession-CCu0VqnR.js} +1 -1
- package/dist/assets/{openSessionFromDeepLink-Bz07xQfv.js → openSessionFromDeepLink-ByuhkhhO.js} +2 -2
- package/dist/assets/{pluginPresentation-4xMNGtKI.js → pluginPresentation-BVl1Nl3W.js} +1 -1
- package/dist/assets/{pwa-uLk3vYDP.js → pwa-hhnaGlo-.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-C_L5pmK0.js → queue-abort-optimistic-BaXwT1o8.js} +1 -1
- package/dist/assets/{reference-history-CN8H7cQY.js → reference-history-6VQhRGyq.js} +1 -1
- package/dist/assets/{remoteSessionReference-BvbDndSv.js → remoteSessionReference-Bn8SUuKD.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-BImqnwc-.js → renderElectronMiniChatApp-CCJm3UWr.js} +2 -2
- package/dist/assets/{renderMobileApp-DjKpQ6id.js → renderMobileApp-CicHiIqo.js} +4 -4
- package/dist/assets/{runtimeConfig-Cs95Hj1_.js → runtimeConfig-CNi8OY9x.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-BeO-ZC0f.js → runtimeEndpointReset-zYV2dp-1.js} +2 -2
- package/dist/assets/{select-Cb6W8KRB.js → select-CvycH4RI.js} +1 -1
- package/dist/assets/{sessionLookup-MXum2sR5.js → sessionLookup-DKsuibUL.js} +1 -1
- package/dist/assets/{sessionOwnership-CgeZg9fN.js → sessionOwnership-78OvDQfC.js} +1 -1
- package/dist/assets/{shortcuts-5iHGo1f3.js → shortcuts-ByiK-hNh.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-D5MuRWnZ.js → sortable-tabs-strip-NufNSTHC.js} +1 -1
- package/dist/assets/{speechSettingsQueries-D2CugjM1.js → speechSettingsQueries-V_UQyei3.js} +1 -1
- package/dist/assets/{switch-DLlbkkU5.js → switch-BCU-vSI0.js} +1 -1
- package/dist/assets/{textarea-Cg3Yz3Oc.js → textarea-BPe3mQGO.js} +1 -1
- package/dist/assets/{tooltip-Chqxbwjz.js → tooltip-B1_fU6mY.js} +1 -1
- package/dist/assets/{truncated-path-DWUl2HQC.js → truncated-path-rTpv5zrZ.js} +1 -1
- package/dist/assets/{types-DfbaAnUB.js → types-BMWiwa3n.js} +1 -1
- package/dist/assets/{ui-lbbchWJP.js → ui-aKYupUMJ.js} +4 -4
- package/dist/assets/{useAppFontEffects-BDoatEWZ.js → useAppFontEffects-CxyttsAS.js} +2 -2
- package/dist/assets/{useDesktopWindowControlsLayout-C_VGQBG3.js → useDesktopWindowControlsLayout-W12iS1Ex.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-Dqdl58J7.js → useEffectiveDirectory-CvKtJ-KR.js} +1 -1
- package/dist/assets/{useGitStore-kco1LBfw.js → useGitStore-BfKvtfEf.js} +1 -1
- package/dist/assets/{useInlineCommentDraftStore-DFr7FLv-.js → useInlineCommentDraftStore-Ktp31o8d.js} +1 -1
- package/dist/assets/{useMcpConfigStore-C9SxNeU1.js → useMcpConfigStore-ebneJxuO.js} +1 -1
- package/dist/assets/{useMobileSwipeActions-vvnhP5zs.js → useMobileSwipeActions-C7NCJMnJ.js} +1 -1
- package/dist/assets/{useMobileTranscriptSyncHint-DVm8zIWR.js → useMobileTranscriptSyncHint-DtT_3oRi.js} +1 -1
- package/dist/assets/{useModelLists-CU3ffp2-.js → useModelLists-CrAJRZsV.js} +1 -1
- package/dist/assets/{useOpenCodeReadiness-KpQk8Bm7.js → useOpenCodeReadiness-CFmQ6kzC.js} +1 -1
- package/dist/assets/{usePluginsStore-BJNtJkXv.js → usePluginsStore-d8PkQjpx.js} +1 -1
- package/dist/assets/{useProjectGitActions-DuzvQm-w.js → useProjectGitActions-CV2Uv86S.js} +1 -1
- package/dist/assets/{useProjectGitStore-U9tDVHik.js → useProjectGitStore-DShehdFf.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-DJubGUM_.js → useProjectRuntimeAPIs-BUrgPkh7.js} +1 -1
- package/dist/assets/{useSessionBtwStore-D5bVhQ1l.js → useSessionBtwStore-CL3DE2A6.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-DlgF3Cnn.js → useStreamingTextThrottle-BBUIHFIK.js} +1 -1
- package/dist/assets/{worktreeManager-BJCsjptu.js → worktreeManager-D29PBBPo.js} +1 -1
- package/dist/assets/{worktreeSourceBranchPreference-qDpG1uyC.js → worktreeSourceBranchPreference-DJOBzShx.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +1 -1
- package/package.json +1 -1
- package/server/index.js +21 -10
- package/server/lib/session-index/DOCUMENTATION.md +8 -0
- package/server/lib/session-index/adopt-unindexed-session.js +46 -0
- package/server/lib/session-index/adopt-unindexed-session.test.js +77 -0
- package/server/lib/session-index/event-ingest.js +14 -1
- package/server/lib/session-index/event-ingest.test.js +18 -0
package/dist/assets/{useStreamingTextThrottle-DlgF3Cnn.js → useStreamingTextThrottle-BBUIHFIK.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./platform-B2ylz14u.js";import{st as n}from"./vendor-base-ui-wXsskyKm.js";import{r}from"./FadeInOnReveal-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./platform-B2ylz14u.js";import{st as n}from"./vendor-base-ui-wXsskyKm.js";import{r}from"./FadeInOnReveal-D2SbjK6C.js";var i=e(n(),1),a=(e,t,n)=>{let r=t-e;return Math.max(0,n-r)},o=e=>{e.timer&&=(clearTimeout(e.timer),null)},s=({text:e,isStreaming:n,throttleMs:s=r(t()).textThrottleMs,identityKey:c})=>{let[l,u]=i.useState(e),d=i.useRef(e),f=i.useRef(l),p=i.useRef({timer:null,pendingText:e,lastEmitAt:0});return i.useEffect(()=>{d.current=e},[e]),i.useEffect(()=>{f.current=l},[l]),i.useEffect(()=>{let e=p.current;o(e),e.pendingText=d.current,e.lastEmitAt=0,u(d.current)},[c]),i.useEffect(()=>{let t=p.current;t.pendingText=e;let r=f.current,i=n&&r.length>e.length?r:e;if(!n){o(t),t.lastEmitAt=Date.now(),u(i);return}let c=Date.now(),l=a(t.lastEmitAt,c,s);if(l<=0){o(t),t.lastEmitAt=c,u(i);return}return o(t),t.timer=setTimeout(()=>{t.timer=null,t.lastEmitAt=Date.now(),u(e=>n&&e.length>t.pendingText.length?e:t.pendingText)},l),()=>{o(t)}},[n,e,s]),i.useEffect(()=>{let e=p.current;return()=>{o(e)}},[]),l};export{s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t}from"./runtime-switch-DEPKHgdL.js";import{W as n}from"./gitApiHttp-CrPYe9Oc.js";import{Yr as r,b as i,ci as a,di as o,f as s,fi as c,li as l,oi as u,ui as d}from"./ui-
|
|
1
|
+
import{i as e,n as t}from"./runtime-switch-DEPKHgdL.js";import{W as n}from"./gitApiHttp-CrPYe9Oc.js";import{Yr as r,b as i,ci as a,di as o,f as s,fi as c,li as l,oi as u,ui as d}from"./ui-aKYupUMJ.js";import{d as f,i as p,l as m,m as h}from"./gitApi-bb-bBVgY.js";var g=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)};async function _(e){let t=g(e),n=await m(t);return{isDirty:!n.isClean,ahead:n.ahead,behind:n.behind,upstream:n.tracking}}var v=6e4,y=500,b=1048576,x=new Map,S=new Map,C=0,w=(e,t)=>e.length+t.length,T=(e,t)=>{x.delete(e),x.set(e,{root:t,resolvedAt:Date.now()});let n=0;for(let[e,t]of x)n+=w(e,t.root);for(;x.size>y||n>b&&x.size>1;){let e=x.entries().next().value;if(!e)break;n-=w(e[0],e[1].root),x.delete(e[0])}};function E(e){if(C+=1,typeof e==`string`&&e){let t=g(e);x.delete(t),S.delete(t);return}x.clear(),S.clear()}var D=async e=>h(e).catch(()=>e),O=async e=>{let t=x.get(e);if(t&&Date.now()-t.resolvedAt<v)return x.delete(e),x.set(e,t),t.root;t&&x.delete(e);let n=S.get(e);if(n)return n;let r=C,i=D(e).then(t=>(C===r&&T(e,t),t)).catch(()=>e).finally(()=>{S.get(e)===i&&S.delete(e)});return S.set(e,i),i};async function k(e,t){let n=g(e);if(!n)return`HEAD`;try{let e=await O(n).catch(()=>n),r=t?.knownBranch?.trim();if(r&&e===n)return r;let i=await m(e);return(typeof i.current==`string`?i.current.trim():``)||`HEAD`}catch{return`HEAD`}}var A=e=>{let t=(e.branch||``).trim(),n=(e.head||``).trim();return t?`branch`:n?`detached`:`unborn`},ee=(e,t)=>({worktreeRoot:t,worktreeStatus:`ready`,headState:A(e),worktreeSource:`existing`}),j=e=>{let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.length>1?t.replace(/\/+$/,``):t},M=e=>e.trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/\s+/g,`-`).replace(/^\/+|\/+$/g,``).split(`/`).join(`-`).replace(/[^A-Za-z0-9._-]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``).slice(0,80),N=e=>e.trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/\s+/g,`-`).replace(/^\/+|\/+$/g,``),P=(e,t)=>{let n=j(e);n&&s.setState(e=>{let r=!1,i=e=>j(e.path)!==n&&j(e.worktreeRoot??e.path)!==n||e.worktreeStatus===t?e:(r=!0,{...e,worktreeStatus:t}),a=e.availableWorktrees,o=!1,s=e.availableWorktrees.map(e=>{let t=i(e);return t!==e&&(o=!0),t});o&&(a=s);let c=e.availableWorktreesByProject;for(let[t,n]of e.availableWorktreesByProject){let r=!1,a=n.map(e=>{let t=i(e);return t!==e&&(r=!0),t});r&&(c===e.availableWorktreesByProject&&(c=new Map(e.availableWorktreesByProject)),c.set(t,a))}let l=e.worktreeMetadata;for(let[t,n]of e.worktreeMetadata){let r=i(n);r!==n&&(l===e.worktreeMetadata&&(l=new Map(e.worktreeMetadata)),l.set(t,r))}return r?{availableWorktrees:a,availableWorktreesByProject:c,worktreeMetadata:l}:{}})},F=e=>e?.status===`pending`?`pending`:e?.status===`failed`?`invalid`:`ready`,I=e=>{let t=j(e),n=t.split(`/`).filter(Boolean);return n[n.length-1]??t},L=e=>{let t=[];for(let n of e.setupCommands){let r=n.trim();r&&t.push(u(r,{rootWorktreePath:e.projectDirectory}))}let n=t.filter(Boolean).join(` && `);return n.trim().length>0?n:void 0},R=(e,t)=>{let n=e.mode===`existing`?`existing`:`new`,r=M(e.worktreeName??e.preferredName??``),i=N(e.branchName??(n===`new`?e.preferredName:void 0)??``),a=N(e.existingBranch??e.branchName??``),o=(e.startRef||``).trim(),s=L({projectDirectory:t,setupCommands:Array.isArray(e.setupCommands)?e.setupCommands:[]});return{mode:n,...r?{worktreeName:r}:{},...i?{branchName:i}:{},...a?{existingBranch:a}:{},...o?{startRef:o}:{},...s?{startCommand:s}:{},...e.setUpstream?{setUpstream:!0}:{},...e.upstreamRemote?{upstreamRemote:e.upstreamRemote}:{},...e.upstreamBranch?{upstreamBranch:e.upstreamBranch}:{},...e.ensureRemoteName?{ensureRemoteName:e.ensureRemoteName}:{},...e.ensureRemoteUrl?{ensureRemoteUrl:e.ensureRemoteUrl}:{},...e.returnAfterDirectoryCreated?{returnAfterDirectoryCreated:!0}:{}}},z=(e,t)=>{if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(!e||e.length!==r.length)return!1;for(let t=0;t<r.length;t++){let n=r[t],i=e[t];if(n.path!==i.path||n.branch!==i.branch||n.name!==i.name||n.label!==i.label||n.projectDirectory!==i.projectDirectory||n.worktreeRoot!==i.worktreeRoot||n.headState!==i.headState||n.worktreeSource!==i.worktreeSource||n.source!==i.source)return!1}}return!0},B=new Map,V=new Map,H=new Map,U=new Map,W=new Map,G=new WeakMap,K=3e4,q=``,J=()=>{let n=`${t()}\u0000${e()}`;return n!==q&&(q=n,B.clear(),V.clear(),H.clear(),U.clear(),W.clear()),n},Y=e=>`${J()}\u0000${j(e)}`,X=(e,t=Y(e))=>H.get(t)??0,Z=e=>{let t=Y(e),r=U.get(t)??j(e),i=Y(r);W.set(i,(W.get(i)??0)+1);let a=new Set([t,i]);for(let[e,t]of U)e.startsWith(`${J()}\u0000`)&&t===r&&a.add(e);for(let e of a)H.set(e,(H.get(e)??0)+1),B.delete(e);n(r),j(e)!==r&&n(e)},te=async(e,t,i)=>{let a=j(await h(e)),o=j(e),s=`${t}\u0000${a}`,c=i&&G.get(i);i&&!c&&(c=new Map,G.set(i,c)),i&&!c?.has(s)&&t===J()&&Z(a);let l=W.get(s)??0,u=c?.get(s);(!u||u.generation!==l)&&(i&&u&&n(a),u={generation:l,value:f.worktree.list(a)},c?.set(s,u));let d=await u.value;t===J()&&U.set(`${t}\u0000${e}`,a);let p=d.filter(e=>typeof e.path==`string`&&e.path.trim().length>0).map(e=>{let t=j(e.path),n=(e.branch||``).replace(/^refs\/heads\//,``).trim(),r=(e.name||``).trim(),i=ee(e,t);return{source:`sdk`,name:r||I(t),path:t,projectDirectory:a,branch:n,label:n||r||I(t),worktreeRoot:i.worktreeRoot,worktreeStatus:i.worktreeStatus,headState:i.headState,worktreeSource:i.worktreeSource}});return r(o,p).sort((e,t)=>{let n=(e.label||e.branch||e.path).toLowerCase(),r=(t.label||t.branch||t.path).toLowerCase();return n.localeCompare(r)})},ne=async(e,t,n,r)=>{for(;;){let i=X(e,t),a=await te(e,n,r);if(n!==J())return a;if(i===X(e,t))return B.set(t,{value:a,at:Date.now()}),a}};async function Q(e,t){let n=j(e.path),r=J(),i=`${r}\u0000${n}`,a=B.get(i);if(a&&Date.now()-a.at<K)return a.value;let o=V.get(i);if(o)return o;let s=ne(n,i,r,t).finally(()=>{V.get(i)===s&&V.delete(i)});return V.set(i,s),s}var re=(e,t)=>{let n=l(e.worktreeRoot??e.path),r=n?.status===`pending`?`pending`:n?.status===`failed`?`invalid`:t?.worktreeStatus;return r&&r!==e.worktreeStatus?{...e,worktreeStatus:r}:e},$=e=>{let t=new Set([...e].map(j));if(t.size===0)return;let n=s.getState().worktreeMetadata,r=new Map(n);for(let[e,i]of n)t.has(j(i.path))&&r.delete(e);for(let[e,n]of i.getState().attachments){let r=typeof n.worktreeRoot==`string`&&n.worktreeRoot.trim()?j(n.worktreeRoot):``,a=typeof n.cwd==`string`&&n.cwd.trim()?j(n.cwd):``;(r&&t.has(r)||a&&t.has(a))&&i.getState().clearAttachment(e)}r.size!==n.size&&s.setState({worktreeMetadata:r})};async function ie(e,t={}){let n=j(e.path),i=Y(n);H.set(i,X(n)+1),B.delete(i),V.delete(i);let a=await Q({...e,path:n},t.refreshBatch??{}),o=U.get(i);if(t.isCurrent&&!t.isCurrent())return{worktrees:a,addedDirectories:[],removedDirectories:[],repositoryDirectory:o};let c=a,l=[],u=[];return s.setState(e=>{let t=e.availableWorktreesByProject,i=r(n,t.get(n)??[]),o=new Map(i.map(e=>[j(e.path),e])),s=a.map(e=>re(e,o.get(j(e.path)))),d=new Set(s.map(e=>j(e.path)));if(l=s.filter(e=>!o.has(j(e.path))).map(e=>e.path),u=i.filter(e=>!d.has(j(e.path))).map(e=>e.path),c=s,i.length===s.length&&i.every((e,t)=>{let n=s[t];return n&&e.path===n.path&&e.branch===n.branch&&e.name===n.name&&e.label===n.label&&e.projectDirectory===n.projectDirectory&&e.worktreeRoot===n.worktreeRoot&&e.headState===n.headState&&e.worktreeSource===n.worktreeSource&&e.source===n.source&&e.worktreeStatus===n.worktreeStatus})&&i.every((e,r)=>e===t.get(n)?.[r])&&i.length===(t.get(n)?.length??0))return{};let f=new Map(t);return f.set(n,s),{availableWorktreesByProject:f,availableWorktrees:[...f.values()].flat()}}),$(u),{worktrees:c,addedDirectories:l,removedDirectories:u,repositoryDirectory:o}}async function ae(e,t){let n=j(e.path),i=j(await h(n));U.set(Y(n),i);let a=n===j(i)?[]:await f.worktree.list(i),l=R(t,n),u=await f.worktree.create(n,l),p=typeof u?.name==`string`?u.name:``,m=typeof u?.branch==`string`?u.branch:``,g=typeof u?.path==`string`?u.path:``;if(!p||!g)throw Error(`Worktree create missing name/path`);let _={source:`sdk`,name:p,path:j(g),projectDirectory:i,branch:m,label:m||p,worktreeRoot:j(g),worktreeStatus:F(u?.bootstrapStatus),headState:m?`branch`:`unborn`,worktreeSource:`created-for-session`},v=r(n,[...a.filter(e=>!!e.path).map(e=>({path:e.path,worktreeRoot:e.path,projectDirectory:i,branch:e.branch??``,label:e.branch??``})),_]).find(e=>e.worktreeRoot===_.worktreeRoot)??_,y=v.worktreeRoot??v.path;u?.bootstrapStatus?o(y,u.bootstrapStatus):d(y),c(y,{onFailed:()=>P(y,`invalid`),onReady:()=>P(y,`ready`)}),Z(n),E();let b=n;return s.setState(e=>{let t=new Map(e.availableWorktreesByProject),n=t.get(b)??[];return t.set(b,[...n.filter(e=>j(e.path)!==v.path),v]),{availableWorktreesByProject:t,availableWorktrees:[...t.values()].flat()}}),v}async function oe(e,t){let n=e.path,r=R(t,n);return f.worktree.validate(n,r)}async function se(e,t,n){let r=j(e.path),i=!!n?.deleteRemoteBranch,o=n?.deleteLocalBranch===!0,c=n?.remoteName;if(!(await f.worktree.remove(r,{directory:t.worktreeRoot??t.path,deleteLocalBranch:o}))?.success)throw Error(`Worktree removal failed`);a(t.worktreeRoot??t.path),Z(j(e.path)),E();let l=j(t.worktreeRoot??t.path),u=s.getState().availableWorktreesByProject,d=new Map(u),m=new Set([l,j(t.path)]);for(let[e,t]of u){let n=t.filter(e=>j(e.worktreeRoot??e.path)!==l||(m.add(j(e.path)),!1));n.length!==t.length&&(d.set(e,n),Z(e))}$(m),s.setState({availableWorktreesByProject:d,availableWorktrees:s.getState().availableWorktrees.filter(e=>j(e.worktreeRoot??e.path)!==l)});let h=(t.branch||``).replace(/^refs\/heads\//,``).trim();i&&h&&await p(r,{branch:h,remote:c}).catch(()=>void 0)}export{oe as a,_ as c,se as i,ie as n,z as o,Q as r,k as s,ae as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as e,s as t}from"./gitApi-
|
|
1
|
+
import{l as e,s as t}from"./gitApi-bb-bBVgY.js";import{s as n,t as r}from"./worktreeManager-D29PBBPo.js";var i=e=>{let t=String(e||``).trim().replace(/^remotes\//,``);if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{remote:t.slice(0,n),branch:t.slice(n+1)}},a=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),o=e=>e.branchName?a(e.branchName):e.mode===`existing`?a(e.existingBranch||e.preferredName||``):a(e.preferredName||``),s=async r=>{let a=await n(r);try{let e=i((await t(r)).branches?.[a]?.tracking||null);if(e?.remote)return e.remote}catch{}try{let t=i((await e(r)).tracking);if(t?.remote)return t.remote}catch{}return null},c=async(e,t)=>{let n=await s(e),r=a(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},l=async(e,t,n)=>{let r=o(t),i=n?.resolvedRootTrackingRemote,s=i===void 0?await c(e,r):i&&a(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:a(r)}:null;return s?{...t,setUpstream:t.setUpstream??s.setUpstream,upstreamRemote:t.upstreamRemote||s.upstreamRemote,upstreamBranch:t.upstreamBranch||s.upstreamBranch}:t},u=async(e,t,n)=>{let i=await l(e.path,t,n);return r(e,i)},d=`yuri:lastWorktreeSourceBranch`,f=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,p=({branches:e,savedSourceBranch:t,rootBranch:n})=>t&&e.includes(t)&&t?{sourceBranch:t,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&e.includes(n)?n:e.includes(`main`)?`main`:e.includes(`master`)?`master`:e[0]??``,shouldClearSavedSourceBranch:!!t};export{s as a,u as i,p as n,l as o,f as r,d as t};
|
package/dist/index.html
CHANGED
|
@@ -571,7 +571,7 @@
|
|
|
571
571
|
opacity: 0.72;
|
|
572
572
|
}
|
|
573
573
|
</style>
|
|
574
|
-
<script type="module" crossorigin src="/assets/main-
|
|
574
|
+
<script type="module" crossorigin src="/assets/main-B8v7kGWB.js"></script>
|
|
575
575
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-P2Xu9kJm.js">
|
|
576
576
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
577
577
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
|
@@ -610,12 +610,12 @@
|
|
|
610
610
|
<link rel="modulepreload" crossorigin href="/assets/gitApiHttp-CrPYe9Oc.js">
|
|
611
611
|
<link rel="modulepreload" crossorigin href="/assets/terminalApi-CsTh04jY.js">
|
|
612
612
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-CzZ_VAoB.js">
|
|
613
|
-
<link rel="modulepreload" crossorigin href="/assets/types-
|
|
614
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
615
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
613
|
+
<link rel="modulepreload" crossorigin href="/assets/types-BMWiwa3n.js">
|
|
614
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-0ZrNrgn7.js">
|
|
615
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-B0QosfID.js">
|
|
616
616
|
<link rel="modulepreload" crossorigin href="/assets/runtime-ead7P81A.js">
|
|
617
617
|
<link rel="modulepreload" crossorigin href="/assets/bootstrap-eLlfzqAI.js">
|
|
618
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
618
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-CNi8OY9x.js">
|
|
619
619
|
<link rel="stylesheet" crossorigin href="/assets/src-BacdFOCS.css">
|
|
620
620
|
</head>
|
|
621
621
|
<body class="h-full bg-background text-foreground">
|
package/dist/mini-chat.html
CHANGED
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
.dark #initial-loading img { filter: invert(1); }
|
|
78
78
|
</style>
|
|
79
79
|
|
|
80
|
-
<script type="module" crossorigin src="/assets/miniChat-
|
|
80
|
+
<script type="module" crossorigin src="/assets/miniChat-DWon-j9p.js"></script>
|
|
81
81
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-P2Xu9kJm.js">
|
|
82
82
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
83
83
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
|
@@ -116,12 +116,12 @@
|
|
|
116
116
|
<link rel="modulepreload" crossorigin href="/assets/gitApiHttp-CrPYe9Oc.js">
|
|
117
117
|
<link rel="modulepreload" crossorigin href="/assets/terminalApi-CsTh04jY.js">
|
|
118
118
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-CzZ_VAoB.js">
|
|
119
|
-
<link rel="modulepreload" crossorigin href="/assets/types-
|
|
120
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
121
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
119
|
+
<link rel="modulepreload" crossorigin href="/assets/types-BMWiwa3n.js">
|
|
120
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-0ZrNrgn7.js">
|
|
121
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-B0QosfID.js">
|
|
122
122
|
<link rel="modulepreload" crossorigin href="/assets/runtime-ead7P81A.js">
|
|
123
123
|
<link rel="modulepreload" crossorigin href="/assets/bootstrap-eLlfzqAI.js">
|
|
124
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
124
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-CNi8OY9x.js">
|
|
125
125
|
<link rel="stylesheet" crossorigin href="/assets/src-BacdFOCS.css">
|
|
126
126
|
</head>
|
|
127
127
|
<body class="h-full bg-background text-foreground">
|
package/dist/mobile.html
CHANGED
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
</script>
|
|
65
65
|
|
|
66
66
|
<style>.dark #mobile-startup-logo img { filter: invert(1); }</style>
|
|
67
|
-
<script type="module" crossorigin src="/assets/mobile-
|
|
67
|
+
<script type="module" crossorigin src="/assets/mobile-Dhvk6j7o.js"></script>
|
|
68
68
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-P2Xu9kJm.js">
|
|
69
69
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
70
70
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -76,6 +76,7 @@ import { createSessionIndexSyncRuntime } from './lib/session-index/sync-runtime.
|
|
|
76
76
|
import { createSessionDirectoryRuntime } from './lib/opencode/session-directory-runtime.js';
|
|
77
77
|
import { resolveSessionIndexDbPath } from './lib/session-index/resolve-db-path.js';
|
|
78
78
|
import { applySessionIndexEvent } from './lib/session-index/event-ingest.js';
|
|
79
|
+
import { createUnindexedSessionAdopter } from './lib/session-index/adopt-unindexed-session.js';
|
|
79
80
|
import { createTranscriptCacheService } from './lib/transcript-cache/service.js';
|
|
80
81
|
import { resolveTranscriptCacheDbPath } from './lib/transcript-cache/resolve-db-path.js';
|
|
81
82
|
import { createMessageQueueRuntime } from './lib/message-queue/runtime.js';
|
|
@@ -1535,12 +1536,26 @@ async function main(options = {}) {
|
|
|
1535
1536
|
});
|
|
1536
1537
|
sessionIndexSyncRuntimeRef = sessionIndexSyncRuntime;
|
|
1537
1538
|
|
|
1539
|
+
const fetchUpstreamSession = createUpstreamSessionFetcher({
|
|
1540
|
+
buildOpenCodeUrl,
|
|
1541
|
+
getOpenCodeAuthHeaders,
|
|
1542
|
+
});
|
|
1543
|
+
const projectSessionForIndex = (session) => {
|
|
1544
|
+
if (!sessionMetadataStore.isLoaded()) return null;
|
|
1545
|
+
const snap = sessionMetadataStore.getSnapshotSync();
|
|
1546
|
+
if (!snap) return null;
|
|
1547
|
+
return projectSessionWithStoredMap(session, snap);
|
|
1548
|
+
};
|
|
1549
|
+
const adoptUnindexedSession = createUnindexedSessionAdopter({
|
|
1550
|
+
service: sessionIndexService,
|
|
1551
|
+
fetchSession: fetchUpstreamSession,
|
|
1552
|
+
projectSession: projectSessionForIndex,
|
|
1553
|
+
onChanged: () => sessionIndexSyncRuntimeRef?.publishChange(),
|
|
1554
|
+
});
|
|
1555
|
+
|
|
1538
1556
|
sessionArchiveServiceRef = createSessionArchiveService({
|
|
1539
1557
|
sessionMetadataStore,
|
|
1540
|
-
fetchUpstreamSession
|
|
1541
|
-
buildOpenCodeUrl,
|
|
1542
|
-
getOpenCodeAuthHeaders,
|
|
1543
|
-
}),
|
|
1558
|
+
fetchUpstreamSession,
|
|
1544
1559
|
sessionIndexService,
|
|
1545
1560
|
broadcastSessionEvent: (payload, options = {}) => {
|
|
1546
1561
|
try {
|
|
@@ -1562,12 +1577,8 @@ async function main(options = {}) {
|
|
|
1562
1577
|
const unsubscribeSessionIndexEvents = globalMessageStreamHub.subscribeEvent((event) => {
|
|
1563
1578
|
if (applySessionIndexEvent(sessionIndexService, event, Date.now(), {
|
|
1564
1579
|
isHostReady: () => sessionMetadataStore.isLoaded(),
|
|
1565
|
-
projectSession:
|
|
1566
|
-
|
|
1567
|
-
const snap = sessionMetadataStore.getSnapshotSync();
|
|
1568
|
-
if (!snap) return null;
|
|
1569
|
-
return projectSessionWithStoredMap(session, snap);
|
|
1570
|
-
},
|
|
1580
|
+
projectSession: projectSessionForIndex,
|
|
1581
|
+
onUnindexedUserActivity: adoptUnindexedSession,
|
|
1571
1582
|
onSessionDeleted: (sessionID) => sessionArchiveServiceRef?.forgetSession(sessionID),
|
|
1572
1583
|
})) {
|
|
1573
1584
|
sessionIndexSyncRuntime?.publishChange();
|
|
@@ -168,6 +168,14 @@ completion events advance the separate `activity_updated_at` ordering field,
|
|
|
168
168
|
while session status transitions update `status` and `status_changed_at`.
|
|
169
169
|
Renderer event handling never performs these index writes and assistant
|
|
170
170
|
streaming events never change session ordering.
|
|
171
|
+
A user message for a session the index does not hold (an old session outside the
|
|
172
|
+
newest-20 window, or one resumed from history) is handed to
|
|
173
|
+
`adopt-unindexed-session.js`: it reads the session upstream, applies the Host
|
|
174
|
+
projection, lifts its clock to the message time so the retention bound accepts it,
|
|
175
|
+
writes the row and publishes a change. Concurrent messages share one read, a failed
|
|
176
|
+
read is retried by the next message, and a row written live meanwhile wins. Without
|
|
177
|
+
this the task view (which only lists indexed idle sessions) and recency ordering
|
|
178
|
+
would drop such a session as soon as its run ends.
|
|
171
179
|
Native creation projects the event's session identity, location, parent, metadata
|
|
172
180
|
and creation clock before the Host metadata overlay. User inbox enqueue advances
|
|
173
181
|
activity; native execution/retry events update status, and successful completion
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brings a session back into the index when the user writes to it while the
|
|
3
|
+
* index does not hold it (an old session outside the newest-20 window, or one
|
|
4
|
+
* resumed from history). `touchActivity` only updates existing rows, so without
|
|
5
|
+
* this the session never regains task-view membership or recency ordering.
|
|
6
|
+
*
|
|
7
|
+
* @param {object} deps
|
|
8
|
+
* @param {object} deps.service session-index service
|
|
9
|
+
* @param {(input: { sessionID: string, directory: string | null }) => Promise<object | null>} deps.fetchSession
|
|
10
|
+
* @param {(session: object) => object | null | undefined} deps.projectSession
|
|
11
|
+
* Host authority projection; `null` means Host metadata is unavailable.
|
|
12
|
+
* @param {() => void} deps.onChanged
|
|
13
|
+
* @param {(message: string, error?: unknown) => void} [deps.warn]
|
|
14
|
+
*/
|
|
15
|
+
export const createUnindexedSessionAdopter = ({
|
|
16
|
+
service,
|
|
17
|
+
fetchSession,
|
|
18
|
+
projectSession,
|
|
19
|
+
onChanged,
|
|
20
|
+
warn = console.warn,
|
|
21
|
+
}) => {
|
|
22
|
+
const inFlight = new Set();
|
|
23
|
+
|
|
24
|
+
return (sessionID, directory, activityAt) => {
|
|
25
|
+
if (inFlight.has(sessionID)) return;
|
|
26
|
+
inFlight.add(sessionID);
|
|
27
|
+
void (async () => {
|
|
28
|
+
try {
|
|
29
|
+
const upstream = await fetchSession({ sessionID, directory: directory || null });
|
|
30
|
+
if (!upstream || service.findBySessionId(sessionID)) return;
|
|
31
|
+
const projected = projectSession(upstream);
|
|
32
|
+
if (projected == null) return;
|
|
33
|
+
// The user message is newer than a possibly stale upstream clock; without
|
|
34
|
+
// this the newest-20 retention bound would refuse the row.
|
|
35
|
+
const time = { ...projected.time, updated: Math.max(Number(projected.time?.updated) || 0, activityAt) };
|
|
36
|
+
const upserted = service.upsertAndReportChange({ ...projected, time }, Date.now());
|
|
37
|
+
const touched = service.touchActivity(sessionID, activityAt);
|
|
38
|
+
if (upserted || touched) onChanged();
|
|
39
|
+
} catch (error) {
|
|
40
|
+
warn('[session-index] adopting an unindexed session failed:', error?.message ?? error);
|
|
41
|
+
} finally {
|
|
42
|
+
inFlight.delete(sessionID);
|
|
43
|
+
}
|
|
44
|
+
})();
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { createUnindexedSessionAdopter } from './adopt-unindexed-session.js';
|
|
3
|
+
|
|
4
|
+
const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
|
|
5
|
+
|
|
6
|
+
const setup = (overrides = {}) => {
|
|
7
|
+
const service = {
|
|
8
|
+
findBySessionId: vi.fn(() => null),
|
|
9
|
+
upsertAndReportChange: vi.fn(() => true),
|
|
10
|
+
touchActivity: vi.fn(() => true),
|
|
11
|
+
};
|
|
12
|
+
const deps = {
|
|
13
|
+
service,
|
|
14
|
+
fetchSession: vi.fn(async () => ({ id: 'ses_old', directory: '/repo', time: { created: 1, updated: 2 } })),
|
|
15
|
+
projectSession: vi.fn((session) => ({ ...session, projected: true })),
|
|
16
|
+
onChanged: vi.fn(),
|
|
17
|
+
warn: vi.fn(),
|
|
18
|
+
...overrides,
|
|
19
|
+
};
|
|
20
|
+
return { service, deps, adopt: createUnindexedSessionAdopter(deps) };
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
describe('createUnindexedSessionAdopter', () => {
|
|
24
|
+
it('writes the projected upstream session and advances activity to the user message', async () => {
|
|
25
|
+
const { service, deps, adopt } = setup();
|
|
26
|
+
adopt('ses_old', '/repo', 900);
|
|
27
|
+
await flush();
|
|
28
|
+
expect(deps.fetchSession).toHaveBeenCalledWith({ sessionID: 'ses_old', directory: '/repo' });
|
|
29
|
+
expect(service.upsertAndReportChange).toHaveBeenCalledWith(
|
|
30
|
+
expect.objectContaining({ id: 'ses_old', projected: true, time: { created: 1, updated: 900 } }),
|
|
31
|
+
expect.any(Number),
|
|
32
|
+
);
|
|
33
|
+
expect(service.touchActivity).toHaveBeenCalledWith('ses_old', 900);
|
|
34
|
+
expect(deps.onChanged).toHaveBeenCalledTimes(1);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('coalesces a burst of messages into one upstream read', async () => {
|
|
38
|
+
const { deps, adopt } = setup();
|
|
39
|
+
adopt('ses_old', '', 1);
|
|
40
|
+
adopt('ses_old', '', 2);
|
|
41
|
+
await flush();
|
|
42
|
+
expect(deps.fetchSession).toHaveBeenCalledTimes(1);
|
|
43
|
+
expect(deps.fetchSession).toHaveBeenCalledWith({ sessionID: 'ses_old', directory: null });
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('writes nothing when Host metadata is unavailable or the session is missing upstream', async () => {
|
|
47
|
+
const unavailable = setup({ projectSession: vi.fn(() => null) });
|
|
48
|
+
unavailable.adopt('ses_old', '/repo', 1);
|
|
49
|
+
const missing = setup({ fetchSession: vi.fn(async () => null) });
|
|
50
|
+
missing.adopt('ses_old', '/repo', 1);
|
|
51
|
+
await flush();
|
|
52
|
+
expect(unavailable.service.upsertAndReportChange).not.toHaveBeenCalled();
|
|
53
|
+
expect(missing.service.upsertAndReportChange).not.toHaveBeenCalled();
|
|
54
|
+
expect(unavailable.deps.onChanged).not.toHaveBeenCalled();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('keeps a live-written row instead of overwriting it with the upstream read', async () => {
|
|
58
|
+
const { service, adopt } = setup();
|
|
59
|
+
service.findBySessionId.mockReturnValue({ id: 'ses_old' });
|
|
60
|
+
adopt('ses_old', '/repo', 1);
|
|
61
|
+
await flush();
|
|
62
|
+
expect(service.upsertAndReportChange).not.toHaveBeenCalled();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('reports a failed fetch and allows a later message to retry', async () => {
|
|
66
|
+
const fetchSession = vi.fn()
|
|
67
|
+
.mockRejectedValueOnce(new Error('offline'))
|
|
68
|
+
.mockResolvedValueOnce({ id: 'ses_old', directory: '/repo', time: {} });
|
|
69
|
+
const { service, deps, adopt } = setup({ fetchSession });
|
|
70
|
+
adopt('ses_old', '/repo', 1);
|
|
71
|
+
await flush();
|
|
72
|
+
expect(deps.warn).toHaveBeenCalledTimes(1);
|
|
73
|
+
adopt('ses_old', '/repo', 2);
|
|
74
|
+
await flush();
|
|
75
|
+
expect(service.upsertAndReportChange).toHaveBeenCalledTimes(1);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -26,6 +26,9 @@ const withDirectory = (session, directory) => {
|
|
|
26
26
|
* @param {(sessionID: string) => void | Promise<void>} [options.onSessionDeleted]
|
|
27
27
|
* @param {() => boolean} [options.isHostReady]
|
|
28
28
|
* When false, session lifecycle upserts are skipped until metadata is ready.
|
|
29
|
+
* @param {(sessionID: string, directory: string, activityAt: number) => void} [options.onUnindexedUserActivity]
|
|
30
|
+
* Called when a user message targets a session the index does not hold (an old
|
|
31
|
+
* session outside the newest-20 window); the owner adopts it asynchronously.
|
|
29
32
|
*/
|
|
30
33
|
export const applySessionIndexEvent = (service, event, observedAt = Date.now(), options = {}) => {
|
|
31
34
|
if (!service || !event || typeof event !== 'object') return false;
|
|
@@ -35,6 +38,9 @@ export const applySessionIndexEvent = (service, event, observedAt = Date.now(),
|
|
|
35
38
|
const projectSession = typeof options.projectSession === 'function' ? options.projectSession : null;
|
|
36
39
|
const onSessionDeleted = typeof options.onSessionDeleted === 'function' ? options.onSessionDeleted : null;
|
|
37
40
|
const isHostReady = typeof options.isHostReady === 'function' ? options.isHostReady : null;
|
|
41
|
+
const onUnindexedUserActivity = typeof options.onUnindexedUserActivity === 'function'
|
|
42
|
+
? options.onUnindexedUserActivity
|
|
43
|
+
: null;
|
|
38
44
|
|
|
39
45
|
const baseType = normalizeSessionEventType(payload.type);
|
|
40
46
|
|
|
@@ -127,14 +133,21 @@ export const applySessionIndexEvent = (service, event, observedAt = Date.now(),
|
|
|
127
133
|
const activityAt = typeof info.time?.created === 'number' ? info.time.created : observedAt;
|
|
128
134
|
const activityChanged = service.touchActivity(info.sessionID, activityAt);
|
|
129
135
|
const settleCleared = service.clearSettleOverride?.(info.sessionID) ?? false;
|
|
136
|
+
if (!activityChanged && onUnindexedUserActivity && !service.findBySessionId?.(info.sessionID)) {
|
|
137
|
+
onUnindexedUserActivity(info.sessionID, directory, activityAt);
|
|
138
|
+
}
|
|
130
139
|
return activityChanged || settleCleared;
|
|
131
140
|
}
|
|
132
141
|
|
|
133
142
|
if (baseType === 'session.inbox.enqueued') {
|
|
134
143
|
const data = payload.data ?? properties;
|
|
135
144
|
if (data.item?.type !== 'user' || typeof data.sessionID !== 'string') return false;
|
|
136
|
-
const
|
|
145
|
+
const activityAt = data.item.time?.created ?? payload.created ?? observedAt;
|
|
146
|
+
const activityChanged = service.touchActivity(data.sessionID, activityAt);
|
|
137
147
|
const settleCleared = service.clearSettleOverride?.(data.sessionID) ?? false;
|
|
148
|
+
if (!activityChanged && onUnindexedUserActivity && !service.findBySessionId?.(data.sessionID)) {
|
|
149
|
+
onUnindexedUserActivity(data.sessionID, directory, activityAt);
|
|
150
|
+
}
|
|
138
151
|
return activityChanged || settleCleared;
|
|
139
152
|
}
|
|
140
153
|
|
|
@@ -61,6 +61,24 @@ describe('session index event ingest', () => {
|
|
|
61
61
|
expect(applySessionIndexEvent(service, { payload: { type: 'session.idle', properties: { sessionID: 'ses_a' } } }, 30)).toBe(false);
|
|
62
62
|
expect(service.clearSettleOverride).not.toHaveBeenCalled();
|
|
63
63
|
});
|
|
64
|
+
it('hands user input for a session the index does not hold to the adopter, once per event', () => {
|
|
65
|
+
const adopt = vi.fn();
|
|
66
|
+
const service = { touchActivity: vi.fn(() => false), findBySessionId: vi.fn(() => null), clearSettleOverride: vi.fn(() => false) };
|
|
67
|
+
const user = { directory: '/repo', payload: { type: 'message.updated', properties: { info: { role: 'user', sessionID: 'ses_old', time: { created: 5 } } } } };
|
|
68
|
+
applySessionIndexEvent(service, user, 30, { onUnindexedUserActivity: adopt });
|
|
69
|
+
expect(adopt).toHaveBeenCalledWith('ses_old', '/repo', 5);
|
|
70
|
+
adopt.mockClear();
|
|
71
|
+
applySessionIndexEvent(service, { directory: '/repo', payload: { type: 'session.inbox.enqueued', data: { sessionID: 'ses_old', item: { type: 'user', time: { created: 7 } } } } }, 30, { onUnindexedUserActivity: adopt });
|
|
72
|
+
expect(adopt).toHaveBeenCalledWith('ses_old', '/repo', 7);
|
|
73
|
+
});
|
|
74
|
+
it('does not adopt a session the index already holds, or assistant messages', () => {
|
|
75
|
+
const adopt = vi.fn();
|
|
76
|
+
const service = { touchActivity: vi.fn(() => false), findBySessionId: vi.fn(() => ({ id: 'ses_held' })), clearSettleOverride: vi.fn(() => false) };
|
|
77
|
+
const user = { payload: { type: 'message.updated', properties: { info: { role: 'user', sessionID: 'ses_held', time: { created: 5 } } } } };
|
|
78
|
+
applySessionIndexEvent(service, user, 30, { onUnindexedUserActivity: adopt });
|
|
79
|
+
applySessionIndexEvent({ ...service, findBySessionId: () => null }, { payload: { type: 'message.updated', properties: { info: { role: 'assistant', sessionID: 'ses_old' } } } }, 30, { onUnindexedUserActivity: adopt });
|
|
80
|
+
expect(adopt).not.toHaveBeenCalled();
|
|
81
|
+
});
|
|
64
82
|
it('takes moved ownership from native data rather than the old event envelope directory', () => {
|
|
65
83
|
const service = { move: vi.fn(() => true) };
|
|
66
84
|
expect(applySessionIndexEvent(service, { directory: '/old', payload: {
|