@openchambery/web 2.0.0-beta.16 → 2.0.0-beta.18

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 (50) hide show
  1. package/dist/assets/AssistantView-CV7caMrh.js +3 -0
  2. package/dist/assets/{DiagramView-Cn3O5_Y8.js → DiagramView-CDfSTjyI.js} +1 -1
  3. package/dist/assets/{MarkdownRenderer-BldzYti9.js → MarkdownRenderer-TW-h0HHu.js} +2 -2
  4. package/dist/assets/{MarkdownRendererImpl-fwcKAJYw.js → MarkdownRendererImpl-BDhsNSZZ.js} +1 -1
  5. package/dist/assets/{MarkstreamRendererImpl-7KUzIn3H.js → MarkstreamRendererImpl-CTRQuEcK.js} +1 -1
  6. package/dist/assets/{MobileDetailNavigation-C-b5DSQl.js → MobileDetailNavigation-Ba4FGle-.js} +1 -1
  7. package/dist/assets/{MobileShareBridge-DMezirfj.js → MobileShareBridge-CbLWGJA7.js} +1 -1
  8. package/dist/assets/{MobileSurface-Bt79wJBe.js → MobileSurface-C62mL-z4.js} +1 -1
  9. package/dist/assets/{MultiRunWindow-CnhaA2qb.js → MultiRunWindow--Kog5jbS.js} +1 -1
  10. package/dist/assets/{SettingsView-BOY_6tAP.js → SettingsView-DrHDWxUP.js} +6 -6
  11. package/dist/assets/{SettingsWindow-iCU14SSY.js → SettingsWindow-Dj3oYcuF.js} +1 -1
  12. package/dist/assets/{TerminalView-GA-BbM9g.js → TerminalView-BrQT3zTi.js} +1 -1
  13. package/dist/assets/{ToolOutputDialog-CUl0cRZG.js → ToolOutputDialog-zTkbimFp.js} +1 -1
  14. package/dist/assets/{appThemeRegistry-Dvw18-KP.js → appThemeRegistry-Dd-Mc_ae.js} +1 -1
  15. package/dist/assets/{fileMentionTouchSelection-CX2GBeT2.js → fileMentionTouchSelection-CZkJTpTW.js} +1 -1
  16. package/dist/assets/{gitApi-BuHteWeZ.js → gitApi-DDZeOQ0N.js} +3 -3
  17. package/dist/assets/insertionBoundaries-6cEF7UND.js +1 -0
  18. package/dist/assets/{main-CEhjJ7ze.js → main-B839_vtF.js} +2 -2
  19. package/dist/assets/{main-DINcXEAA.js → main-CboaV0z3.js} +12 -12
  20. package/dist/assets/{mcpQueries-BhVPqtnN.js → mcpQueries-Cirhjpkq.js} +1 -1
  21. package/dist/assets/{miniChat-Bo0rWV9V.js → miniChat-B0lH1mgT.js} +2 -2
  22. package/dist/assets/{mobile-sA03x4Fl.js → mobile-DCMqyVbF.js} +2 -2
  23. package/dist/assets/multirun-D45JAYPn.js +4 -0
  24. package/dist/assets/{projectMeta-n0t4_672.js → projectMeta-BZj0Lqsc.js} +2 -2
  25. package/dist/assets/{renderElectronMiniChatApp-DGE4xEtr.js → renderElectronMiniChatApp-KxK13wGq.js} +2 -2
  26. package/dist/assets/renderMobileApp-DLwJp7Ef.js +28 -0
  27. package/dist/assets/{runtimeConfig-B5vzmiw4.js → runtimeConfig-Dfmu3VWa.js} +1 -1
  28. package/dist/assets/{runtimeEndpointReset-BiynvIUH.js → runtimeEndpointReset-D4tNIDTD.js} +6 -6
  29. package/dist/assets/{sessionChangeSummary-BpEaUpIi.js → sessionChangeSummary-BUya3rIx.js} +1 -1
  30. package/dist/assets/{sessionLookup-CVS-ZMib.js → sessionLookup-Ba9vzhFN.js} +1 -1
  31. package/dist/assets/{useAppFontEffects-D-4aDydP.js → useAppFontEffects-C4YijXq2.js} +55 -55
  32. package/dist/assets/{useDesktopWindowControlsLayout-CuSkyPqt.js → useDesktopWindowControlsLayout-hhGCbHKE.js} +1 -1
  33. package/dist/assets/{useEffectiveDirectory-BFl2jc4W.js → useEffectiveDirectory-DB10GDme.js} +1 -1
  34. package/dist/assets/{useMobileNavigationStore-C3zrYwWb.js → useMobileNavigationStore-DXxkpRmA.js} +9 -9
  35. package/dist/assets/{useSessionAutoCleanup-BZAMbGcw.js → useSessionAutoCleanup-C7ONq7C-.js} +1 -1
  36. package/dist/assets/{useWorkerHighlightedLines-3sqUvjEF.js → useWorkerHighlightedLines-DWR_fwgu.js} +1 -1
  37. package/dist/index.html +2 -2
  38. package/dist/mini-chat.html +2 -2
  39. package/dist/mobile.html +2 -2
  40. package/package.json +1 -1
  41. package/server/lib/opencode/DOCUMENTATION.md +4 -0
  42. package/server/lib/opencode/config-entity-routes.js +1 -1
  43. package/server/lib/opencode/config-entity-routes.test.js +16 -0
  44. package/server/lib/scheduled-tasks/DOCUMENTATION.md +7 -1
  45. package/server/lib/scheduled-tasks/runtime.js +10 -1
  46. package/server/lib/scheduled-tasks/runtime.test.js +81 -6
  47. package/dist/assets/AssistantView-DSiX31eO.js +0 -3
  48. package/dist/assets/insertionBoundaries-B5Wzbzd3.js +0 -1
  49. package/dist/assets/multirun-CEuu10Xi.js +0 -4
  50. package/dist/assets/renderMobileApp-CRI1W3-J.js +0 -28
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t}from"./runtime-fetch-CiqQd__Y.js";import{En as n,in as r}from"./persistence-CMWO3jFo.js";import{nt as i,rt as a}from"./vendor-base-ui-CnHfUmDN.js";import{n as o}from"./platform-BxU3ZvQ0.js";import{v as s}from"./useUIStore-Brsa2mKs.js";import{n as c}from"./vendor-react-DLPElpoQ.js";import{a as l,n as u}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{f as d,r as f,t as p}from"./button-EzCcYrQl.js";import{n as m}from"./Icon-DKd015RD.js";import{i as h,n as g,t as _}from"./tooltip-DwUy2erJ.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{n as y}from"./markdownTheme-DM5h1i18.js";import{n as b}from"./MarkdownRenderer-BldzYti9.js";import{n as x,o as S,s as C,t as w}from"./markdown-worker-bS5OgGO3.js";import{a as T,i as E,o as D,t as ee}from"./imageSource-BpUsiwFd.js";import{t as te}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";var O=e(a(),1),k=c(),A=i(),ne=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,j={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},M=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,N=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,re=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,P=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,F=`${P} max-h-[min(22rem,50vh)] overflow-y-auto`,ie=`${P} w-full`,ae={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},I=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,oe=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,se=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ce=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,le=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ue={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},L={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},R=e=>{let t=(0,k.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:a}=d(),o=z.has(n.status)?n.status:`pending`,s=L[o],c;t[0]!==a||t[1]!==s?(c=a(s),t[0]=a,t[1]=s,t[2]=c):c=t[2];let l=c,u;t[3]===o?u=t[4]:(u=o===`in_progress`?(0,A.jsx)(m,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):o===`completed`?(0,A.jsx)(m,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,A.jsx)(m,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=o,t[4]=u);let p=u,v=r?`step`:void 0,y=r&&`bg-[var(--surface-muted)] before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-[var(--status-info)]`,b;t[5]===y?b=t[6]:(b=f(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,I,y),t[5]=y,t[6]=b);let x;t[7]!==p||t[8]!==l?(x=(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":l,children:p})}),t[7]=p,t[8]=l,t[9]=x):x=t[9];let S;t[10]===l?S=t[11]:(S=(0,A.jsx)(g,{side:`left`,sideOffset:6,children:l}),t[10]=l,t[11]=S);let C;t[12]!==x||t[13]!==S?(C=(0,A.jsxs)(_,{children:[x,S]}),t[12]=x,t[13]=S,t[14]=C):C=t[14];let w=ue[o],T;t[15]===w?T=t[16]:(T=f(`block whitespace-normal break-words`,w),t[15]=w,t[16]=T);let E;t[17]!==T||t[18]!==n.content?(E=(0,A.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,A.jsx)(`span`,{className:T,children:n.content})}),t[17]=T,t[18]=n.content,t[19]=E):E=t[19];let D;return t[20]!==i||t[21]!==E||t[22]!==v||t[23]!==b||t[24]!==C?(D=(0,A.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[C,E]}),t[20]=i,t[21]=E,t[22]=v,t[23]=b,t[24]=C,t[25]=D):D=t[25],D},z=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),B=`image/png`,V=l(`OpenChamberMedia`),H=e=>{let t=e.toLowerCase().split(`;`)[0]?.trim()||B;if(t===`image/jpeg`||t===`image/jpg`)return`jpg`;if(t===`image/webp`)return`webp`;if(t===`image/gif`)return`gif`;if(t===`image/svg+xml`)return`svg`;if(t===`image/png`)return`png`;let n=t.split(`/`)[1];return n&&/^[a-z0-9.+-]+$/i.test(n)?n:`png`},U=(e,t)=>{let n=`image.${H(t)}`,r=(((e||``).trim()||n).split(/[\\/]/).pop()||n).replace(/[^\w.\- ()[\]]+/g,`_`).replace(/^\.+/,``);return r?/\.[a-z0-9]{1,8}$/i.test(r)?r:`${r}.${H(t)}`:n},W=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{if(typeof r.result==`string`){t(r.result);return}n(Error(`Failed to encode image`))},r.onerror=()=>n(r.error??Error(`Failed to encode image`)),r.readAsDataURL(e)}),de=async e=>{let t=await W(e),n=t.indexOf(`,`);return n>=0?t.slice(n+1):t},fe=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),1e3)},G=async(e,t)=>{let n=await fetch(e,{signal:t,cache:`no-store`});if(!n.ok)throw Error(`Image fetch failed (${n.status})`);return n.blob()},pe=async(e,t=B)=>{if(!e.naturalWidth||!e.naturalHeight)return null;let n=e.currentSrc||e.src;if(n&&(/^(?:blob:|data:|openchamber-asset:)/i.test(n)||/^https?:/i.test(n)||/^\/api(?=\/|[?#]|$)/.test(n)))try{let e=await G(n);if(e.size>0)return e}catch{}try{let n=document.createElement(`canvas`);n.width=e.naturalWidth,n.height=e.naturalHeight;let r=n.getContext(`2d`);if(!r)return null;r.drawImage(e,0,0);let i=t.startsWith(`image/`)?t:B,a=await new Promise(e=>{n.toBlob(t=>e(t),i===`image/jpg`?`image/jpeg`:i)});return a&&a.size>0?a:null}catch{return null}},me=async(e,t)=>{let n=``;try{return n=await ee(e,t??new AbortController().signal),await G(n,t)}finally{n&&T(n)}},he=async(e,n)=>{let r=e.effectiveDirectory??``,i=null;e.prefetchedBlob&&e.prefetchedBlob.size>0&&(i=e.prefetchedBlob);let a=e.displayUrl?.trim();if(!i&&a)try{i=await G(a,n)}catch{i=null}if(!i){let a=e.sourceUrl.trim();if(!a)throw Error(`Image source is empty`);if(/^(?:data|blob):/i.test(a)||/^https?:/i.test(a)||/^\/api(?=\/|[?#]|$)/.test(a))i=await G(a,n);else{let e=D(a,r);if(E(e))try{i=await me(e.path,n)}catch{let r=await t(`/api/fs/raw`,{method:`GET`,cache:`no-store`,query:{path:e.path},signal:n});if(!r.ok)throw Error(`Image source request failed with status ${r.status}`);i=await r.blob()}else i=await G(e.source,n)}}if(!i||i.size<=0)throw Error(`Image is empty`);let o=(e.mimeType||(i.type&&i.type.startsWith(`image/`)?i.type:``)||B).split(`;`)[0].trim()||B;return{blob:i,filename:U(e.filename,o),mimeType:o}},ge=()=>!o()||u===void 0?!1:u.isPluginAvailable(`OpenChamberMedia`),_e=async(e,t)=>{let{blob:i,filename:a,mimeType:o}=await he(e,t);if(ge()){let e=await de(i);return await V.saveImage({dataBase64:e,mimeType:o,filename:a}),`saved`}if(r()){let e=n()?.vscode;if(e?.saveImage){let t=await W(i);return await e.saveImage({fileName:a,dataUrl:t}),`saved`}}return fe(i,a),`downloaded`},ve=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),ye=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,K=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=ye(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},be=e=>`<pre><code>${ve(e)}</code></pre>`,xe=e=>{let t=(0,k.c)(21),{code:n,language:r,className:i,style:a,codeStyle:o,wrap:s}=e,c=s!==void 0&&s,{currentTheme:l}=v(),u=O.useRef(null),d;t[0]===l?d=t[1]:(d=y(l),t[0]=l,t[1]=d);let p=d,m,h;t[2]!==n||t[3]!==o||t[4]!==c?(m=()=>{let e=u.current;e&&(e.innerHTML=be(n),K(e,c,o))},h=[n,c,o],t[2]=n,t[3]=o,t[4]=c,t[5]=m,t[6]=h):(m=t[5],h=t[6]),O.useLayoutEffect(m,h);let g,_;t[7]!==n||t[8]!==o||t[9]!==r||t[10]!==c?(g=()=>{let e=u.current;if(!e)return;let t=!0,i=new AbortController;return w(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,K(e,c,o))}),()=>{t=!1,i.abort()}},_=[n,r,c,o],t[7]=n,t[8]=o,t[9]=r,t[10]=c,t[11]=g,t[12]=_):(g=t[11],_=t[12]),O.useEffect(g,_);let b;t[13]===i?b=t[14]:(b=f(`typography-code`,i),t[13]=i,t[14]=b);let x=p,S;t[15]!==a||t[16]!==x?(S={...x,...a},t[15]=a,t[16]=x,t[17]=S):S=t[17];let C;return t[18]!==b||t[19]!==S?(C=(0,A.jsx)(`div`,{ref:u,className:b,style:S}),t[18]=b,t[19]=S,t[20]=C):C=t[20],C},Se=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},Ce=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},we=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,Te=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,Ee=(e,t)=>!e||typeof e!=`object`?String(e):C(e,t||``),q=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},De=e=>{if(!e||typeof e!=`object`)return;let t=q(e.patch)??q(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=q(e.patch)??q(e.diff);if(t)return t}},Oe=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},ke=(e,t,n)=>{let r=Se(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&we(r)&&(r=Te(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=De(n);if(e)return e}return r},Ae=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t}from"./runtime-fetch-CiqQd__Y.js";import{En as n,in as r}from"./persistence-CMWO3jFo.js";import{nt as i,rt as a}from"./vendor-base-ui-CnHfUmDN.js";import{n as o}from"./platform-BxU3ZvQ0.js";import{v as s}from"./useUIStore-Brsa2mKs.js";import{n as c}from"./vendor-react-DLPElpoQ.js";import{a as l,n as u}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{f as d,r as f,t as p}from"./button-EzCcYrQl.js";import{n as m}from"./Icon-DKd015RD.js";import{i as h,n as g,t as _}from"./tooltip-DwUy2erJ.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{n as y}from"./markdownTheme-DM5h1i18.js";import{n as b}from"./MarkdownRenderer-TW-h0HHu.js";import{n as x,o as S,s as C,t as w}from"./markdown-worker-bS5OgGO3.js";import{a as T,i as E,o as D,t as ee}from"./imageSource-BpUsiwFd.js";import{t as te}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";var O=e(a(),1),k=c(),A=i(),ne=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,j={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},M=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,N=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,re=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,P=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,F=`${P} max-h-[min(22rem,50vh)] overflow-y-auto`,ie=`${P} w-full`,ae={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},I=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,oe=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,se=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ce=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,le=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ue={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},L={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},R=e=>{let t=(0,k.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:a}=d(),o=z.has(n.status)?n.status:`pending`,s=L[o],c;t[0]!==a||t[1]!==s?(c=a(s),t[0]=a,t[1]=s,t[2]=c):c=t[2];let l=c,u;t[3]===o?u=t[4]:(u=o===`in_progress`?(0,A.jsx)(m,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):o===`completed`?(0,A.jsx)(m,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,A.jsx)(m,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=o,t[4]=u);let p=u,v=r?`step`:void 0,y=r&&`bg-[var(--surface-muted)] before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-[var(--status-info)]`,b;t[5]===y?b=t[6]:(b=f(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,I,y),t[5]=y,t[6]=b);let x;t[7]!==p||t[8]!==l?(x=(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":l,children:p})}),t[7]=p,t[8]=l,t[9]=x):x=t[9];let S;t[10]===l?S=t[11]:(S=(0,A.jsx)(g,{side:`left`,sideOffset:6,children:l}),t[10]=l,t[11]=S);let C;t[12]!==x||t[13]!==S?(C=(0,A.jsxs)(_,{children:[x,S]}),t[12]=x,t[13]=S,t[14]=C):C=t[14];let w=ue[o],T;t[15]===w?T=t[16]:(T=f(`block whitespace-normal break-words`,w),t[15]=w,t[16]=T);let E;t[17]!==T||t[18]!==n.content?(E=(0,A.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,A.jsx)(`span`,{className:T,children:n.content})}),t[17]=T,t[18]=n.content,t[19]=E):E=t[19];let D;return t[20]!==i||t[21]!==E||t[22]!==v||t[23]!==b||t[24]!==C?(D=(0,A.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[C,E]}),t[20]=i,t[21]=E,t[22]=v,t[23]=b,t[24]=C,t[25]=D):D=t[25],D},z=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),B=`image/png`,V=l(`OpenChamberMedia`),H=e=>{let t=e.toLowerCase().split(`;`)[0]?.trim()||B;if(t===`image/jpeg`||t===`image/jpg`)return`jpg`;if(t===`image/webp`)return`webp`;if(t===`image/gif`)return`gif`;if(t===`image/svg+xml`)return`svg`;if(t===`image/png`)return`png`;let n=t.split(`/`)[1];return n&&/^[a-z0-9.+-]+$/i.test(n)?n:`png`},U=(e,t)=>{let n=`image.${H(t)}`,r=(((e||``).trim()||n).split(/[\\/]/).pop()||n).replace(/[^\w.\- ()[\]]+/g,`_`).replace(/^\.+/,``);return r?/\.[a-z0-9]{1,8}$/i.test(r)?r:`${r}.${H(t)}`:n},W=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{if(typeof r.result==`string`){t(r.result);return}n(Error(`Failed to encode image`))},r.onerror=()=>n(r.error??Error(`Failed to encode image`)),r.readAsDataURL(e)}),de=async e=>{let t=await W(e),n=t.indexOf(`,`);return n>=0?t.slice(n+1):t},fe=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),1e3)},G=async(e,t)=>{let n=await fetch(e,{signal:t,cache:`no-store`});if(!n.ok)throw Error(`Image fetch failed (${n.status})`);return n.blob()},pe=async(e,t=B)=>{if(!e.naturalWidth||!e.naturalHeight)return null;let n=e.currentSrc||e.src;if(n&&(/^(?:blob:|data:|openchamber-asset:)/i.test(n)||/^https?:/i.test(n)||/^\/api(?=\/|[?#]|$)/.test(n)))try{let e=await G(n);if(e.size>0)return e}catch{}try{let n=document.createElement(`canvas`);n.width=e.naturalWidth,n.height=e.naturalHeight;let r=n.getContext(`2d`);if(!r)return null;r.drawImage(e,0,0);let i=t.startsWith(`image/`)?t:B,a=await new Promise(e=>{n.toBlob(t=>e(t),i===`image/jpg`?`image/jpeg`:i)});return a&&a.size>0?a:null}catch{return null}},me=async(e,t)=>{let n=``;try{return n=await ee(e,t??new AbortController().signal),await G(n,t)}finally{n&&T(n)}},he=async(e,n)=>{let r=e.effectiveDirectory??``,i=null;e.prefetchedBlob&&e.prefetchedBlob.size>0&&(i=e.prefetchedBlob);let a=e.displayUrl?.trim();if(!i&&a)try{i=await G(a,n)}catch{i=null}if(!i){let a=e.sourceUrl.trim();if(!a)throw Error(`Image source is empty`);if(/^(?:data|blob):/i.test(a)||/^https?:/i.test(a)||/^\/api(?=\/|[?#]|$)/.test(a))i=await G(a,n);else{let e=D(a,r);if(E(e))try{i=await me(e.path,n)}catch{let r=await t(`/api/fs/raw`,{method:`GET`,cache:`no-store`,query:{path:e.path},signal:n});if(!r.ok)throw Error(`Image source request failed with status ${r.status}`);i=await r.blob()}else i=await G(e.source,n)}}if(!i||i.size<=0)throw Error(`Image is empty`);let o=(e.mimeType||(i.type&&i.type.startsWith(`image/`)?i.type:``)||B).split(`;`)[0].trim()||B;return{blob:i,filename:U(e.filename,o),mimeType:o}},ge=()=>!o()||u===void 0?!1:u.isPluginAvailable(`OpenChamberMedia`),_e=async(e,t)=>{let{blob:i,filename:a,mimeType:o}=await he(e,t);if(ge()){let e=await de(i);return await V.saveImage({dataBase64:e,mimeType:o,filename:a}),`saved`}if(r()){let e=n()?.vscode;if(e?.saveImage){let t=await W(i);return await e.saveImage({fileName:a,dataUrl:t}),`saved`}}return fe(i,a),`downloaded`},ve=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),ye=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,K=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=ye(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},be=e=>`<pre><code>${ve(e)}</code></pre>`,xe=e=>{let t=(0,k.c)(21),{code:n,language:r,className:i,style:a,codeStyle:o,wrap:s}=e,c=s!==void 0&&s,{currentTheme:l}=v(),u=O.useRef(null),d;t[0]===l?d=t[1]:(d=y(l),t[0]=l,t[1]=d);let p=d,m,h;t[2]!==n||t[3]!==o||t[4]!==c?(m=()=>{let e=u.current;e&&(e.innerHTML=be(n),K(e,c,o))},h=[n,c,o],t[2]=n,t[3]=o,t[4]=c,t[5]=m,t[6]=h):(m=t[5],h=t[6]),O.useLayoutEffect(m,h);let g,_;t[7]!==n||t[8]!==o||t[9]!==r||t[10]!==c?(g=()=>{let e=u.current;if(!e)return;let t=!0,i=new AbortController;return w(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,K(e,c,o))}),()=>{t=!1,i.abort()}},_=[n,r,c,o],t[7]=n,t[8]=o,t[9]=r,t[10]=c,t[11]=g,t[12]=_):(g=t[11],_=t[12]),O.useEffect(g,_);let b;t[13]===i?b=t[14]:(b=f(`typography-code`,i),t[13]=i,t[14]=b);let x=p,S;t[15]!==a||t[16]!==x?(S={...x,...a},t[15]=a,t[16]=x,t[17]=S):S=t[17];let C;return t[18]!==b||t[19]!==S?(C=(0,A.jsx)(`div`,{ref:u,className:b,style:S}),t[18]=b,t[19]=S,t[20]=C):C=t[20],C},Se=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},Ce=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},we=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,Te=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,Ee=(e,t)=>!e||typeof e!=`object`?String(e):C(e,t||``),q=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},De=e=>{if(!e||typeof e!=`object`)return;let t=q(e.patch)??q(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=q(e.patch)??q(e.diff);if(t)return t}},Oe=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},ke=(e,t,n)=>{let r=Se(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&we(r)&&(r=Te(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=De(n);if(e)return e}return r},Ae=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
2
2
  `).split(`
3
3
  `),r=e=>/\(\s*File has more lines\..*offset.*\)/i.test(e.trim());return{type:t,lines:n.map(e=>{let n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);if(t!==`directory`){let t=e.match(/^(\d+):\s?(.*)$/);if(t){let e=t[2],n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);return{lineNumber:i?null:Number(t[1]),text:e,isInfo:i}}}return{lineNumber:null,text:e,isInfo:i}}).filter((e,t,n)=>{if(e.text.trim().length>0)return!0;let r=n[t-1],i=n[t+1],a=!!(r?.isInfo||i?.isInfo),o=e.lineNumber!==null;return!(a&&o)})}},je=(e,t)=>{try{let n=e.trim().split(`
4
4
  `).filter(Boolean);if(n.length===0)return null;let r=[];return n.forEach(e=>{let t=e.match(/^(\s*)(.+)$/);if(t){let[,e,n]=t,i=Math.floor(e.length/2),a=!n.endsWith(`/`);r.push({name:n.replace(/\/$/,``),depth:i,isFile:a})}}),(0,A.jsx)(`div`,{className:f(`w-full min-w-0 font-mono space-y-0.5`,t?.unstyled?null:`p-3 bg-muted/20 rounded-xl border border-border/30`),style:s.tool.popup,children:r.map((e,t)=>(0,A.jsx)(`div`,{className:`min-w-0`,style:{paddingLeft:`${e.depth*20}px`},children:e.isFile?(0,A.jsx)(`span`,{className:`text-foreground/90 block truncate`,children:e.name}):(0,A.jsxs)(`span`,{className:`font-semibold text-foreground block truncate`,children:[e.name,`/`]})},t))})}catch{return null}},Me={backgroundColor:`var(--status-info)`,opacity:.6},Ne=(e,t,n)=>{try{let r=e.trim().split(`
package/dist/index.html CHANGED
@@ -552,7 +552,7 @@
552
552
  opacity: 0.72;
553
553
  }
554
554
  </style>
555
- <script type="module" crossorigin src="/assets/main-CEhjJ7ze.js"></script>
555
+ <script type="module" crossorigin src="/assets/main-B839_vtF.js"></script>
556
556
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
557
557
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-D66yq6ie.js">
558
558
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-BJM2k_uH.js">
@@ -572,7 +572,7 @@
572
572
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-C6zlKnK1.js">
573
573
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
574
574
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
575
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-B5vzmiw4.js">
575
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-Dfmu3VWa.js">
576
576
  <link rel="stylesheet" crossorigin href="/assets/src-iyTfdRD7.css">
577
577
  </head>
578
578
  <body class="h-full bg-background text-foreground">
@@ -74,7 +74,7 @@
74
74
  }
75
75
  </style>
76
76
 
77
- <script type="module" crossorigin src="/assets/miniChat-Bo0rWV9V.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-B0lH1mgT.js"></script>
78
78
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
79
79
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-D66yq6ie.js">
80
80
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-BJM2k_uH.js">
@@ -94,7 +94,7 @@
94
94
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-C6zlKnK1.js">
95
95
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
96
96
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
97
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-B5vzmiw4.js">
97
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-Dfmu3VWa.js">
98
98
  <link rel="stylesheet" crossorigin href="/assets/src-iyTfdRD7.css">
99
99
  </head>
100
100
  <body class="h-full bg-background text-foreground">
package/dist/mobile.html CHANGED
@@ -63,7 +63,7 @@
63
63
  })();
64
64
  </script>
65
65
 
66
- <script type="module" crossorigin src="/assets/mobile-sA03x4Fl.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-DCMqyVbF.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-D66yq6ie.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-BJM2k_uH.js">
@@ -83,7 +83,7 @@
83
83
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-C6zlKnK1.js">
84
84
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
85
85
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
86
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-B5vzmiw4.js">
86
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-Dfmu3VWa.js">
87
87
  <link rel="stylesheet" crossorigin href="/assets/src-iyTfdRD7.css">
88
88
  </head>
89
89
  <body class="h-full bg-background text-foreground">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openchambery/web",
3
- "version": "2.0.0-beta.16",
3
+ "version": "2.0.0-beta.18",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -321,6 +321,10 @@ restart, then terminates only its own child and removes its temporary files.
321
321
  It makes no model requests and never reads real user credentials.
322
322
 
323
323
  ## Public exports (config-entity-routes.js)
324
+ The provider catalog's optional `model.default` lookup may fail independently:
325
+ available provider/model lists still return successfully without defaults.
326
+ Failures of either required list still return HTTP 502 for the caller to retry.
327
+
324
328
  - `registerConfigEntityRoutes(app, dependencies)`: registers configuration entity routes:
325
329
  - `GET /api/config/catalog/providers` resolves the request project directory, composes official v2 `provider.list` + `model.list` (+ `model.default`), and returns schema version `1` with an allowlisted provider/model catalog. Catalog model ids and defaults use `ModelInfo.id` (the external generate/session id). `ModelInfo.modelID` is an internal field and is not the catalog key. The route is available through the shared web host used by Web, Electron, hosted mobile, and Capacitor mobile, before generic OpenCode proxy handling.
326
330
  - Provider catalog responses include only provider `id`, `name`, and safe models. Safe models include `id`, `name`, fixed text/audio/image/video/pdf capability modalities, bounded cost/limit fields, `release_date`, and variant names with `{}` values. v2 `ModelInfo.variants` is an array of `{ id, settings?, headers?, body? }`; projection keeps ids in array order as empty-object keys and drops request payloads. v2 `capabilities.tools` maps to `toolcall`, and `input`/`output` modality name arrays map to boolean maps. v2 `cost` tier arrays keep the untiered base price. Identifiers are bounded to 512 characters, display names to 1024, release dates to 64, numeric values to absolute 1e9, and catalog collections to 200 providers, 500 models per provider, and 100 defaults or variants. Provider credentials/configuration and unallowlisted model fields stay server-side. Malformed catalog roots and SDK error envelopes return HTTP 502. `partial: true` is structural only: provider/model/default truncation, dropped providers/models/defaults, or truncated variant dictionaries. Soft allowlist stripping of optional metadata (unknown modalities, non-boolean capability flags, out-of-range cost/limit numbers, empty/null/invalid `release_date`, invalid variant ids) keeps valid models and must not set `partial: true`, or UI refresh retains a stale complete snapshot after OpenCode provider updates. The same input shapes are accepted by the VS Code projector and `packages/ui/src/lib/configCatalogParser.ts`.
@@ -186,7 +186,7 @@ export const registerConfigEntityRoutes = (app, dependencies) => {
186
186
  const [providersResult, modelsResult, defaultResult] = await Promise.all([
187
187
  client.provider.list({ location }),
188
188
  client.model.list({ location }),
189
- client.model.default({ location }),
189
+ client.model.default({ location }).catch(() => undefined),
190
190
  ]);
191
191
  const source = composeV2ProviderCatalogSource(
192
192
  providersResult?.data,
@@ -211,6 +211,22 @@ describe('config entity command metadata route', () => {
211
211
  });
212
212
 
213
213
  describe('provider catalog route', () => {
214
+ it('keeps the model catalog available when the optional default request fails', async () => {
215
+ const app = express();
216
+ createOpencodeClient.mockReturnValue({
217
+ provider: { list: vi.fn(async () => ({ data: [{ id: 'openai', name: 'OpenAI' }] })) },
218
+ model: {
219
+ list: vi.fn(async () => ({ data: [{ id: 'model', providerID: 'openai', name: 'Model' }] })),
220
+ default: vi.fn(async () => { throw new Error('default unavailable'); }),
221
+ },
222
+ });
223
+ registerConfigEntityRoutes(app, createDependencies(vi.fn()));
224
+ const response = await request(app).get('/api/config/catalog/providers').expect(200);
225
+ expect(response.body.providers[0].models.model).toEqual({ id: 'model', name: 'Model' });
226
+ expect(response.body.default).toEqual({});
227
+ expect(response.body.partial).toBe(false);
228
+ });
229
+
214
230
  it('uses the resolved directory, OpenCode auth, SDK providers call, and explicit catalog route', async () => {
215
231
  const app = express();
216
232
  const resolveProjectDirectory = vi.fn(async () => ({ directory: '/project/from-header' }));
@@ -215,7 +215,13 @@ Every actual run (timer or manual):
215
215
  `message.list({ limit: 50, order: 'desc' })` (newest first) — never
216
216
  `order: 'asc'` page-0 + `at(-1)`, which reads an old page once the
217
217
  session exceeds the limit.
218
- - Real terminal success requires an assistant tail with `time.completed`
218
+ - OpenCode 2.0.16 emits a native `idle` tail whose `outcome` is authoritative:
219
+ `succeeded` → success; `failed` / `interrupted` → error. An unknown idle
220
+ outcome keeps polling. Read it only after `session.active` confirms the
221
+ session is inactive; an older terminal record cannot settle live work.
222
+ This also applies to post-run continuation snapshots. Earlier servers
223
+ without idle records use the assistant-tail rules below.
224
+ - Assistant-tail terminal success requires `time.completed`
219
225
  and finish not `tool-calls` (prefer `finish: 'stop'`). `finish:
220
226
  'tool-calls'`, incomplete assistants (no `time.completed`), and
221
227
  non-assistant tails such as `model-switched` never succeed — including
@@ -304,7 +304,7 @@ const isUserMessage = (info) => (
304
304
  * - finish tool-calls is mid-loop, never success
305
305
  * - incomplete (no time.completed) is never success
306
306
  * - model-switched / non-assistant tails are not success
307
- * - only a completed assistant with a real terminal finish succeeds
307
+ * - native idle outcomes settle the execution; older servers use assistant finish
308
308
  */
309
309
  const classifyMessageTail = (messages) => {
310
310
  if (!Array.isArray(messages) || messages.length === 0) {
@@ -317,6 +317,15 @@ const classifyMessageTail = (messages) => {
317
317
  if (!latest) {
318
318
  return { outcome: 'unknown' };
319
319
  }
320
+ if (latest.type === 'idle') {
321
+ if (latest.outcome === 'succeeded') {
322
+ return { outcome: 'success' };
323
+ }
324
+ if (latest.outcome === 'failed' || latest.outcome === 'interrupted') {
325
+ return { outcome: 'error', error: `session execution ${latest.outcome}` };
326
+ }
327
+ return { outcome: 'unknown' };
328
+ }
320
329
  if (isAssistantMessage(latest)) {
321
330
  if (latest.error) {
322
331
  return {
@@ -1108,6 +1108,78 @@ describe('scheduled-tasks run history and session lifecycle', () => {
1108
1108
  expect(client.prompt).not.toHaveBeenCalled();
1109
1109
  });
1110
1110
 
1111
+ it.each([
1112
+ ['succeeded', 'success', null],
1113
+ ['failed', 'error', 'session execution failed'],
1114
+ ['interrupted', 'error', 'session execution interrupted'],
1115
+ ])('settles native idle outcome %s instead of timing out', async (outcome, status, error) => {
1116
+ vi.useFakeTimers();
1117
+ try {
1118
+ const history = createHistoryStore();
1119
+ const client = createSuccessfulClient({
1120
+ messageListImpl: async () => ({
1121
+ data: [
1122
+ { id: 'msg_idle', type: 'idle', outcome, time: { created: 1_200 } },
1123
+ outcome === 'succeeded' ? erroredAssistant() : completedAssistant(),
1124
+ ],
1125
+ }),
1126
+ });
1127
+ const updateState = vi.fn(async (_projectID, _taskID, state) => ({
1128
+ task: { ...scheduledTask, state: { ...scheduledTask.state, ...state } },
1129
+ }));
1130
+ const runtime = createRuntime(updateState, {
1131
+ runHistoryStore: history,
1132
+ waitForOpenCodeReady: vi.fn(async () => {}),
1133
+ maxRunDurationMs: 2_500,
1134
+ });
1135
+ await runtime.syncProject('project-1');
1136
+ const pending = runtime.runNow('project-1', 'task-1');
1137
+ await vi.advanceTimersByTimeAsync(2_500);
1138
+ const result = await pending;
1139
+ expect(result.status).toBe(status);
1140
+ expect(result.error ?? null).toBe(error);
1141
+ expect(history.finishRun).toHaveBeenCalledWith(
1142
+ expect.any(String), expect.objectContaining({ status }),
1143
+ );
1144
+ expect(client.interrupt).not.toHaveBeenCalled();
1145
+ expect(client.messageList).toHaveBeenCalledTimes(1);
1146
+ expect(history.finishRun.mock.calls[0][1].durationMs).toBeLessThan(2_500);
1147
+ runtime.stop();
1148
+ } finally {
1149
+ vi.useRealTimers();
1150
+ }
1151
+ });
1152
+
1153
+ it('does not settle an older idle record while the session is active', async () => {
1154
+ vi.useFakeTimers();
1155
+ try {
1156
+ const history = createHistoryStore();
1157
+ let busy = true;
1158
+ const client = createSuccessfulClient({
1159
+ activeImpl: async () => busy ? { ses_1: { type: 'running' } } : {},
1160
+ messageListImpl: async () => ({
1161
+ data: [{ id: 'msg_idle', type: 'idle', outcome: 'succeeded', time: { created: 1_200 } }],
1162
+ }),
1163
+ });
1164
+ const runtime = createRuntime(vi.fn(async () => ({ task: scheduledTask })), {
1165
+ runHistoryStore: history,
1166
+ waitForOpenCodeReady: vi.fn(async () => {}),
1167
+ maxRunDurationMs: 5_000,
1168
+ });
1169
+ await runtime.syncProject('project-1');
1170
+ const pending = runtime.runNow('project-1', 'task-1');
1171
+ await vi.advanceTimersByTimeAsync(1_000);
1172
+ expect(history.finishRun).not.toHaveBeenCalled();
1173
+ expect(client.messageList).not.toHaveBeenCalled();
1174
+ busy = false;
1175
+ await vi.advanceTimersByTimeAsync(1_000);
1176
+ expect((await pending).status).toBe('success');
1177
+ runtime.stop();
1178
+ } finally {
1179
+ vi.useRealTimers();
1180
+ }
1181
+ });
1182
+
1111
1183
  it('ordinary non-goal runs still create a session and settle on the assistant tail', async () => {
1112
1184
  const history = createHistoryStore();
1113
1185
  const client = createSuccessfulClient({ sessionID: 'ses_plain' });
@@ -1182,16 +1254,17 @@ describe('scheduled-tasks run history and session lifecycle', () => {
1182
1254
  );
1183
1255
  });
1184
1256
 
1185
- it('does not succeed when the latest message is model-switched', async () => {
1257
+ it.each([
1258
+ { id: 'msg_switch', type: 'model-switched', model: { providerID: 'openai', id: 'gpt-4.1' } },
1259
+ { id: 'msg_idle', type: 'idle', outcome: 'unknown' },
1260
+ ])('does not succeed on an unrecognized terminal: $type', async (tail) => {
1186
1261
  vi.useFakeTimers();
1187
1262
  const history = createHistoryStore();
1188
1263
  createSuccessfulClient({
1189
1264
  messageListImpl: async () => ({
1190
1265
  data: [{
1191
- id: 'msg_switch',
1192
- type: 'model-switched',
1266
+ ...tail,
1193
1267
  time: { created: Date.now() },
1194
- model: { providerID: 'openai', id: 'gpt-4.1' },
1195
1268
  }],
1196
1269
  }),
1197
1270
  });
@@ -1442,7 +1515,7 @@ describe('scheduled-tasks run history and session lifecycle', () => {
1442
1515
  vi.unstubAllGlobals();
1443
1516
  });
1444
1517
 
1445
- it('corrects lastStatus error → success on idle after a continuation, without rewriting history', async () => {
1518
+ it.each(['assistant', 'idle'])('corrects lastStatus error → success from %s after a continuation, without rewriting history', async (tailType) => {
1446
1519
  const history = createHistoryStore();
1447
1520
  const client = createSuccessfulClient({ settlement: 'assistant-error' });
1448
1521
  const fetchMock = vi.fn(async (url) => {
@@ -1468,7 +1541,9 @@ describe('scheduled-tasks run history and session lifecycle', () => {
1468
1541
  expect(history.finishRun).toHaveBeenCalledTimes(1);
1469
1542
 
1470
1543
  client.messageList.mockImplementation(async () => ({
1471
- data: [completedAssistant('msg_ok')],
1544
+ data: [tailType === 'idle'
1545
+ ? { id: 'msg_idle', type: 'idle', outcome: 'succeeded', time: { created: 1_200 } }
1546
+ : completedAssistant('msg_ok')],
1472
1547
  }));
1473
1548
 
1474
1549
  await runtime.observeSessionEvent({
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-CUl0cRZG.js","assets/rolldown-runtime-C0FnF6B9.js","assets/runtime-fetch-CiqQd__Y.js","assets/runtime-auth-D66yq6ie.js","assets/runtime-switch-BJM2k_uH.js","assets/vendor-base-ui-CnHfUmDN.js","assets/useUIStore-Brsa2mKs.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-pierre-diffs-DX7XTPG3.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/vendor-hast-util-to-html-B0p1k5Xa.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-DpDied8H.js","assets/vendor-reactuses-core-Dq5ocTF8.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-EzCcYrQl.js","assets/persistence-CMWO3jFo.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/store-jaP79mqI.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/dialog-Cpu-rKij.js","assets/Icon-DKd015RD.js","assets/useThemeSystem-DMzWVJaW.js","assets/markdownTheme-DM5h1i18.js","assets/appThemeRegistry-Dvw18-KP.js","assets/platform-BxU3ZvQ0.js","assets/vendor-opencode-client-C12gfjag.js","assets/useMobileNavigationStore-C3zrYwWb.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/useAssistantUIStore-B75cQm_z.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/MarkdownRenderer-BldzYti9.js","assets/markdownHeightCache-emzgqB2K.js","assets/dualLimitLru-D8Sphgua.js","assets/markdown-worker-bS5OgGO3.js","assets/useEffectiveDirectory-BFl2jc4W.js","assets/imageSource-BpUsiwFd.js","assets/relay-image-stream-D2XooXKZ.js","assets/useWorkerHighlightedLines-3sqUvjEF.js","assets/tooltip-DwUy2erJ.js","assets/vendor-tanstack-react-virtual-tlDgH6PG.js"])))=>i.map(i=>d[i]);
2
- import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{c as n,i as r,n as i}from"./runtime-switch-BJM2k_uH.js";import{G as a,H as o,J as s,Q as c,V as l,X as u,Y as d,dt as f,rt as p}from"./persistence-CMWO3jFo.js";import{a as m}from"./vendor-zustand-B4dlGEM2.js";import{nt as h,rt as g}from"./vendor-base-ui-CnHfUmDN.js";import{n as _,r as v}from"./platform-BxU3ZvQ0.js";import{n as y}from"./useUIStore-Brsa2mKs.js";import{n as b}from"./vendor-react-DLPElpoQ.js";import{o as x}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{s as S}from"./vendor-tanstack-react-query-D7pys_c9.js";import{r as C}from"./vendor-sonner-DVzioF3d.js";import{a as w,d as T,f as E,i as D,n as O,r as k}from"./vendor-reactuses-core-Dq5ocTF8.js";import{f as A,r as j,t as M}from"./button-EzCcYrQl.js";import{a as N,n as P}from"./MobileShareBridge-DMezirfj.js";import{C as F,_ as I,a as L,f as R,g as z,j as B,k as V,l as H,n as U,r as ee,s as te,t as W,u as ne,y as re}from"./MobileDetailNavigation-C-b5DSQl.js";import{br as ie,dt as ae,o as oe,oo as se,qt as ce,yn as le,yr as G}from"./useMobileNavigationStore-C3zrYwWb.js";import{i as K,n as q,r as ue}from"./useAssistantUIStore-B75cQm_z.js";import{a as de,i as J,n as Y,o as X,r as fe,t as pe}from"./dialog-Cpu-rKij.js";import{t as me}from"./AgentAvatar-Cxm7uMtK.js";import{n as Z}from"./Icon-DKd015RD.js";import{i as he}from"./OverlayScrollbar-SUdC3Pqe.js";import{n as ge}from"./textarea-B9pCxe-7.js";import{D as _e,S as ve,T as ye,a as be,c as xe,d as Se,f as Ce,i as we,l as Te,m as Ee,n as De,o as Oe,p as ke,r as Ae,t as je,u as Me}from"./sessionChangeSummary-BpEaUpIi.js";import{a as Ne,n as Pe,r as Fe,t as Ie}from"./fileMentionTouchSelection-CX2GBeT2.js";import{o as Le,t as Re}from"./MarkdownRenderer-BldzYti9.js";import{c as ze,s as Be}from"./imageSource-BpUsiwFd.js";import{a as Ve,t as He}from"./sessionLookup-CVS-ZMib.js";import{a as Ue,i as We,n as Ge,r as Ke,t as qe}from"./context-menu-DSrUbCPh.js";import{i as Je,n as Ye,r as Xe}from"./assistant-attachment-cache-sG8YQsVs.js";var Ze=b();function Qe(e){return[...e].sort((e,t)=>{let n=e.latestMessagePreview?.createdAt??-1/0,r=t.latestMessagePreview?.createdAt??-1/0;return n===r?0:r-n})}var Q=e(g(),1),$=h();function $e({snapshot:e,rowClassName:t}){let{t:n}=A(),[r,i]=Q.useState(!1),a=Q.useRef(!1),o=O(async()=>{if(!a.current){a.current=!0,i(!0);try{(await H(e)).failed&&C.error(n(`assistants.unread.markAllFailed`))}catch{C.error(n(`assistants.unread.markAllFailed`))}finally{a.current=!1,i(!1)}}});return e.assistants.some(e=>(e.unreadCount??0)>0)?(0,$.jsx)(`div`,{className:t,children:(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`xs`,onClick:o,className:`max-w-full whitespace-normal text-right`,disabled:r||!e.assistants.some(e=>(e.unreadCount??0)>0&&e.readTip),"aria-busy":r,children:n(`assistants.unread.markAll`)})}):null}var et=e=>{let t=(0,Ze.c)(17),{name:n,emoji:r,size:i,label:a,working:o,className:s}=e,c=i===void 0?24:i,l=o!==void 0&&o,{t:u}=A(),d=`calc(${c}px * var(--dpt-n, 1))`,f;t[0]===s?f=t[1]:(f=j(`relative inline-block shrink-0 align-middle leading-none`,s),t[0]=s,t[1]=f);let p;t[2]===d?p=t[3]:(p={width:d,height:d},t[2]=d,t[3]=p);let m;t[4]!==r||t[5]!==a||t[6]!==n||t[7]!==c?(m=(0,$.jsx)(me,{name:n,emoji:r,size:c,label:a,shape:`circle`}),t[4]=r,t[5]=a,t[6]=n,t[7]=c,t[8]=m):m=t[8];let h;t[9]!==u||t[10]!==l?(h=l?(0,$.jsx)(`span`,{className:`pointer-events-none absolute right-0 bottom-0 size-2.5 translate-x-0.5 translate-y-0.5 rounded-full bg-[var(--status-success)] ring-2 ring-background`,"data-assistant-working-dot":``,"aria-label":u(`assistants.contact.working`)}):null,t[9]=u,t[10]=l,t[11]=h):h=t[11];let g;return t[12]!==f||t[13]!==p||t[14]!==m||t[15]!==h?(g=(0,$.jsxs)(`span`,{className:f,style:p,"data-assistant-working-avatar":``,children:[m,h]}),t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g):g=t[16],g},tt=m(e=>({workingByID:{},setWorking:(t,n)=>e(e=>({workingByID:{...e.workingByID,[t]:n}}))})),nt=({sending:e=!1,processing:t=!1,serverWorking:n=!1})=>e||t||n,rt=(e,t)=>{let n=(0,Ze.c)(5),r=t!==void 0&&t,i;n[0]===e?i=n[1]:(i=t=>!!t.workingByID[e],n[0]=e,n[1]=i);let a=tt(i),o;return n[2]!==a||n[3]!==r?(o=nt({processing:a,serverWorking:r}),n[2]=a,n[3]=r,n[4]=o):o=n[4],o};function it(e){let t=(0,Ze.c)(12),{assistantID:n,position:a}=e,o=Q.useRef(null),s=Q.useRef(!1),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={busy:!1,done:!1,retryAt:0},t[0]=c):c=t[0];let l=Q.useRef(c),[u]=Q.useState(ut),d;t[1]!==n||t[2]!==a||t[3]!==u?(d=()=>{let e=o.current;if(!e||!s.current||l.current.busy||l.current.done||Date.now()<l.current.retryAt||u.transport!==r()||u.generation!==i()||document.visibilityState!==`visible`||(_()?!document.documentElement.classList.contains(`oc-native-app-active`):!document.hasFocus())||e.parentElement?.closest(`[inert], [aria-hidden="true"]`))return;let t=e.closest(`[data-assistant-contact-transcript]`);if(!t||t.scrollHeight-t.scrollTop-t.clientHeight>2)return;let c=e.getBoundingClientRect(),d=t.getBoundingClientRect(),f=window.visualViewport,p=f?.offsetTop??0,m=p+(f?.height??window.innerHeight);c.height<=0||c.width<=0||c.bottom>Math.min(d.bottom,m)||c.top<Math.max(d.top,p)||c.right<=Math.max(d.left,0)||c.left>=Math.min(d.right,window.innerWidth)||(l.current.busy=!0,ne(n,a).then(()=>{l.current.done=!0}).catch(()=>{l.current.retryAt=Date.now()+15e3}).finally(()=>{l.current.busy=!1}))},t[1]=n,t[2]=a,t[3]=u,t[4]=d):d=t[4];let f=O(d),p;t[5]===f?p=t[6]:(p=e=>{s.current=e.some(lt),f()},t[5]=f,t[6]=p);let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m={threshold:1},t[7]=m):m=t[7],D(o,O(p),m),k(`visibilitychange`,f,ct),k(`focus`,f,st),k(`resize`,f,ot);let h,g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>o.current?.closest(`[data-assistant-contact-transcript]`),g={passive:!0},t[8]=h,t[9]=g):(h=t[8],g=t[9]),k(`scroll`,f,h,g);let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v={attributes:!0,attributeFilter:[`class`]},t[10]=v):v=t[10],T(f,at,v),w(f,15e3);let y;return t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`span`,{ref:o,"aria-hidden":`true`,className:`block h-px w-px shrink-0`,"data-assistant-read-marker":``}),t[11]=y):y=t[11],y}function at(){return document.documentElement}function ot(){return window.visualViewport}function st(){return window}function ct(){return document}function lt(e){return e.isIntersecting&&e.intersectionRatio===1}function ut(){return{transport:r(),generation:i()}}var dt=e=>e?.directories.flatMap(({directory:e,sessions:t})=>e?t.filter(e=>!e.time.archived).map(t=>({...t,directory:e||t.location?.directory||t.directory||``})).filter(e=>e.directory.length>0):[])??null,ft=Q.forwardRef(({query:e,isMobile:t,listId:n,onHighlightChange:r,onSelect:i,onClose:a},o)=>{let{t:s}=A(),c=ze(),l=S({...ie(c),select:dt}),u=Q.useMemo(()=>ae({sessions:l.data??[],currentSessionId:null,searchQuery:e}),[l.data,e]),[d,f]=Q.useState({query:e,index:0}),p=Math.min(d.query===e?d.index:0,Math.max(0,u.length-1)),m=Q.useRef(null),h=Q.useRef([]),g=Q.useMemo(Ie,[]);k(`pointerdown`,e=>{e.target instanceof Node&&!m.current?.contains(e.target)&&a()},void 0,{capture:!0}),Q.useLayoutEffect(()=>{h.current[p]?.scrollIntoView?.({block:`nearest`})},[p]),Q.useLayoutEffect(()=>{r(u.length?`${n}-${p}`:void 0)},[p,n,u.length,r]);let _=O(t=>{if(t===`Escape`){a();return}u.length&&(t===`ArrowDown`&&f({query:e,index:(p+1)%u.length}),t===`ArrowUp`&&f({query:e,index:(p-1+u.length)%u.length}),(t===`Enter`||t===`Tab`)&&i(u[p]))});return Q.useImperativeHandle(o,()=>({keyDown:_}),[_]),(0,$.jsxs)(Pe,{ref:m,isMobile:t,className:`max-w-[640px] max-h-64`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 px-3 py-1`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,children:s(`assistants.contact.sessionMention.scope`)}),(0,$.jsx)(M,{type:`button`,size:`xs`,variant:`ghost`,"aria-label":s(`dialog.common.actions.close`),onClick:a,children:(0,$.jsx)(Z,{name:`close`,className:`size-4`})})]}),l.isPending?(0,$.jsx)(`p`,{role:`status`,className:`px-3 py-2 typography-meta text-muted-foreground`,children:s(`common.loading`)}):null,l.isError?(0,$.jsxs)(`div`,{role:`alert`,className:`px-3 py-2 typography-meta text-[var(--status-error)]`,children:[s(`assistants.contact.sessionMention.loadFailed`),(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void l.refetch(),children:s(`chat.history.retry`)})]}):null,l.isSuccess&&!u.length?(0,$.jsx)(`p`,{role:`status`,className:`px-3 py-2 typography-meta text-muted-foreground`,children:s(l.data===null?`common.unavailable`:`sessions.sidebar.empty.noMatches.title`)}):null,(0,$.jsx)(ge,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,$.jsx)(`div`,{id:n,role:`listbox`,"aria-label":s(`chat.fileMentionAutocomplete.groups.sessions`),className:`p-1.5`,children:u.map((r,a)=>(0,$.jsxs)(`div`,{id:`${n}-${a}`,role:`option`,"aria-selected":a===p,ref:e=>{h.current[a]=e},className:j(`flex min-h-10 cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 typography-ui-label`,Fe(t,a===p)),onMouseDown:e=>e.preventDefault(),onMouseMove:()=>f({query:e,index:a}),onPointerDown:e=>{e.pointerType===`touch`&&g.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&g.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&g.pointerUp(()=>i(r))&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>g.pointerCancel(),onClick:()=>g.click(()=>i(r)),children:[(0,$.jsx)(Z,{name:`chat-thread`,className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate font-medium leading-5`,title:r.title,children:r.title||s(`chat.fileMentionAutocomplete.untitledSession`)}),(0,$.jsx)(`div`,{className:`truncate text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,title:r.directory,children:r.directory})]})]},`${r.directory}:${r.id}`))})}),t?null:(0,$.jsx)(`div`,{className:`mx-1.5 shrink-0 border-t px-1.5 py-1 text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,children:s(`chat.autocomplete.keyboardHint`)})]})}),pt=e=>{let t=(0,Ze.c)(87),n,r,i,c;t[0]===e?(n=t[1],r=t[2],i=t[3],c=t[4]):({active:n,working:c,onChange:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=c);let p=c!==void 0&&c,{t:m}=A(),h;t[5]===i.value?h=t[6]:(h=()=>({canonical:i.value,document:a(i.value,new Map)}),t[5]=i.value,t[6]=h);let[g,_]=Q.useState(h),v;t[7]!==g.canonical||t[8]!==g.document||t[9]!==i.value?(v=g.canonical===i.value?g.document:a(i.value,new Map),t[7]=g.canonical,t[8]=g.document,t[9]=i.value,t[10]=v):v=t[10];let y=v,[b,x]=Q.useState(0),[S,C]=Q.useState(!0),[w,T]=Q.useState(!1),[E,D]=Q.useState(),k=Q.useRef(null),M=Q.useRef(null),N=Q.useRef(null),P=Q.useRef(null),F;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(F=Te(),t[11]=F):F=t[11];let I=Q.useRef(F),L=Q.useId(),R;t[12]!==n||t[13]!==w||t[14]!==b||t[15]!==S||t[16]!==y.text||t[17]!==i.disabled||t[18]!==i.pending?(R=n&&!i.pending&&!i.disabled&&!S&&!w?Ne({text:y.text,cursor:b}):null,t[12]=n,t[13]=w,t[14]=b,t[15]=S,t[16]=y.text,t[17]=i.disabled,t[18]=i.pending,t[19]=R):R=t[19];let z=R,B=z?.kind===`mention`?z:null,V;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{P.current!==null&&(k.current?.focus({preventScroll:!0}),k.current?.setSelectionRange(P.current,P.current),P.current=null)},t[20]=V):V=t[20];let H;t[21]===y?H=t[22]:(H=[y],t[21]=y,t[22]=H),Q.useLayoutEffect(V,H);let U;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>C(!0),t[23]=U):U=t[23];let ee=O(U),te;t[24]!==w||t[25]!==b||t[26]!==y||t[27]!==r?(te=(e,t,n)=>{let i=n===void 0||n,a=u(e);a.ok&&(i&&(I.current=Me(I.current,{before:xe(y,[],{start:k.current?.selectionStart??b,end:k.current?.selectionEnd??b}),after:xe(e,[],{start:t,end:t})})),w||(P.current=t),x(t),_({canonical:a.text,document:e}),r(a.text))},t[24]=w,t[25]=b,t[26]=y,t[27]=r,t[28]=te):te=t[28];let W=O(te),ne;t[29]!==W||t[30]!==y||t[31]!==B||t[32]!==m?(ne=e=>{if(!B)return;let t=e.title||m(`chat.fileMentionAutocomplete.untitledSession`),n=o(y,B.tokenStart,B.tokenEnd,{id:`session:${e.id}:${crypto.randomUUID()}`,kind:`session`,sessionId:e.id,display:f({trigger:`@`,icon:`chat-thread`,label:t})},{inlineBoundaries:!0,padDocumentEdges:!0}),r=n.caret+ +(n.document.text[n.caret]===` `);C(!0),W(n.document,r)},t[29]=W,t[30]=y,t[31]=B,t[32]=m,t[33]=ne):ne=t[33];let re=O(ne),ie;t[34]!==W||t[35]!==y?(ie=(e,t)=>{let n=e.currentTarget;if(n.selectionStart===n.selectionEnd||!e.clipboardData||!y.references.some(e=>e.start<n.selectionEnd&&e.end>n.selectionStart))return;let r=l(n.selectionStart,n.selectionEnd,y.references)??{start:n.selectionStart,end:n.selectionEnd},i=u({text:y.text.slice(r.start,r.end),references:y.references.filter(e=>e.start>=r.start&&e.end<=r.end).map(e=>({...e,start:e.start-r.start,end:e.end-r.start}))});if(i.ok&&(e.preventDefault(),e.clipboardData.setData(`text/plain`,i.text),t)){let e=s(y,y.text.slice(0,r.start)+y.text.slice(r.end),r.start,r.start);W(e.document,e.caret)}},t[34]=W,t[35]=y,t[36]=ie):ie=t[36];let ae=O(ie),oe;t[37]!==y.references||t[38]!==y.text?(oe=Ee(y.text,y.references.map(mt))?.map(ht),t[37]=y.references,t[38]=y.text,t[39]=oe):oe=t[39];let se=oe,ce=y.text,le=i.pending||p,G=i.pending===!0,K=i.layout===`inline`?`py-3 leading-6`:`pt-4 pb-2`,q;t[40]!==i.textLayoutClassName||t[41]!==K?(q=j(`whitespace-pre-wrap break-words overflow-hidden px-3 typography-markdown md:typography-ui-label`,K,i.textLayoutClassName),t[40]=i.textLayoutClassName,t[41]=K,t[42]=q):q=t[42];let ue;t[43]!==W||t[44]!==y?(ue=(e,t)=>{let n=s(y,e,t?.target.selectionStart??e.length,t?.target.selectionEnd??e.length);W(n.document,n.caret),C(t?.nativeEvent?.inputType===`insertFromPaste`)},t[43]=W,t[44]=y,t[45]=ue):ue=t[45];let de=B?L:void 0,J=B?E:void 0,Y;t[46]===i.textareaProps?Y=t[47]:(Y=e=>{i.textareaProps?.onScroll?.(e),M.current&&(M.current.scrollTop=e.currentTarget.scrollTop,M.current.scrollLeft=e.currentTarget.scrollLeft)},t[46]=i.textareaProps,t[47]=Y);let X,fe;t[48]!==ae||t[49]!==i.textareaProps?(X=e=>{i.textareaProps?.onCopy?.(e),e.defaultPrevented||ae(e,!1)},fe=e=>{i.textareaProps?.onCut?.(e),e.defaultPrevented||ae(e,!0)},t[48]=ae,t[49]=i.textareaProps,t[50]=X,t[51]=fe):(X=t[50],fe=t[51]);let pe;t[52]===i.textareaProps?pe=t[53]:(pe=e=>{x(e.currentTarget.selectionStart),i.textareaProps?.onSelect?.(e)},t[52]=i.textareaProps,t[53]=pe);let me,Z;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>{T(!0)},Z=e=>{T(!1),x(e.currentTarget.selectionStart)},t[54]=me,t[55]=Z):(me=t[54],Z=t[55]);let he;t[56]!==W||t[57]!==w||t[58]!==y||t[59]!==B||t[60]!==i.textareaProps?(he=e=>{if(i.textareaProps?.onKeyDown?.(e),!(e.defaultPrevented||ye(e))){if(w){e.key===`Enter`&&e.preventDefault();return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`z`){let t=e.shiftKey?Se(I.current,y):Ce(I.current,y);t&&(e.preventDefault(),I.current=t.history,W(t.snapshot.document,t.snapshot.selection.end,!1),C(!0));return}if(e.key===`Backspace`||e.key===`Delete`){let t=d(y,{key:e.key,selectionStart:e.currentTarget.selectionStart,selectionEnd:e.currentTarget.selectionEnd,altKey:e.altKey});if(t){e.preventDefault(),W(t.document,t.caret),C(!0);return}}B&&[`ArrowDown`,`ArrowUp`,`Enter`,`Tab`,`Escape`].includes(e.key)&&(e.preventDefault(),e.stopPropagation(),N.current?.keyDown(e.key))}},t[56]=W,t[57]=w,t[58]=y,t[59]=B,t[60]=i.textareaProps,t[61]=he):he=t[61];let ge;t[62]!==i.textareaProps||t[63]!==de||t[64]!==J||t[65]!==Y||t[66]!==X||t[67]!==fe||t[68]!==pe||t[69]!==he?(ge={...i.textareaProps,"aria-controls":de,"aria-activedescendant":J,"aria-autocomplete":`list`,onScroll:Y,onCopy:X,onCut:fe,onSelect:pe,onCompositionStart:me,onCompositionEnd:Z,onKeyDown:he},t[62]=i.textareaProps,t[63]=de,t[64]=J,t[65]=Y,t[66]=X,t[67]=fe,t[68]=pe,t[69]=he,t[70]=ge):ge=t[70];let _e;t[71]!==ee||t[72]!==L||t[73]!==B||t[74]!==i.isMobile||t[75]!==re?(_e=B?(0,$.jsx)(ft,{ref:N,query:B.query,isMobile:i.isMobile??!1,listId:L,onHighlightChange:D,onSelect:re,onClose:ee}):null,t[71]=ee,t[72]=L,t[73]=B,t[74]=i.isMobile,t[75]=re,t[76]=_e):_e=t[76];let be;return t[77]!==y.text||t[78]!==se||t[79]!==i||t[80]!==le||t[81]!==G||t[82]!==q||t[83]!==ue||t[84]!==ge||t[85]!==_e?(be=(0,$.jsx)(ve,{...i,value:ce,pending:le,disableInputWhilePending:G,inputRef:k,highlightedContent:se,highlightRef:M,textLayoutClassName:q,onChange:ue,textareaProps:ge,children:_e}),t[77]=y.text,t[78]=se,t[79]=i,t[80]=le,t[81]=G,t[82]=q,t[83]=ue,t[84]=ge,t[85]=_e,t[86]=be):be=t[86],be};function mt(e){return{start:e.start,end:e.end,priority:103,...c(e)}}function ht(e,t){return(0,$.jsx)(`span`,{className:e.className,children:e.visual?(0,$.jsx)(ke,{visual:e.visual,text:e.text}):e.text},`${t}-${e.text.length}`)}var gt=`max-h-72 max-w-full rounded-[1.35rem] border border-border/40 object-contain cursor-zoom-in`;function _t({assistantID:e,descriptor:t,onShowPopup:n}){let{t:r}=A(),i=ze(),{attachmentID:a,sha256:o,size:s,mime:c,filename:l}=t,u=Q.useMemo(()=>({type:`file`,attachmentID:a,sha256:o,size:s,mime:c,filename:l}),[a,o,s,c,l]),d=c.startsWith(`image/`),[f,p]=Q.useState(0),[m,h]=Q.useState(``),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),b=Q.useRef(null),x=Q.useRef([]);Q.useEffect(()=>{h(``),_(!1);let t=new AbortController,n;return d&&Xe(e,u,{signal:t.signal}).then(e=>{if(t.signal.aborted){e.release();return}n=e.release,h(e.url)}).catch(()=>{t.signal.aborted||_(!0)}),()=>{t.abort(),n?.()}},[e,u,i,d,f]),Q.useEffect(()=>()=>{b.current?.abort(),x.current.forEach(e=>URL.revokeObjectURL(e)),x.current=[]},[e,u,i]);let S=O(async()=>{if(b.current)return;let t=new AbortController;b.current=t,y(!0),_(!1);try{let n=await Ye(e,u,{signal:t.signal});if(t.signal.aborted)return;x.current.forEach(e=>URL.revokeObjectURL(e));let i=URL.createObjectURL(n);x.current=[i];let a=document.createElement(`a`);a.href=i,a.download=l||r(`assistants.contact.attachment.file`),document.body.appendChild(a),a.click(),a.remove()}catch{t.signal.aborted||_(!0)}finally{b.current===t&&(b.current=null),t.signal.aborted||y(!1)}}),C=l||r(d?`assistants.contact.attachment.image`:`assistants.contact.attachment.file`),w=O(()=>{!n||!m||n({open:!0,title:C,content:``,metadata:{tool:`image-preview`,filename:C,mime:c},image:{url:m,mimeType:c,filename:C,size:s,gallery:[{url:m,mimeType:c,filename:C,size:s}],index:0}})});return d&&m&&!g?(0,$.jsx)(`img`,{src:m,alt:C,className:gt,onError:()=>_(!0),onClick:w,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),w())},role:`button`,tabIndex:0,"data-assistant-contact-image":``}):(0,$.jsxs)(`div`,{className:`flex max-w-full flex-col gap-1 rounded-[1.25rem] bg-[var(--surface-muted)] px-3.5 py-2.5 ring-1 ring-inset ring-[var(--surface-subtle)]`,"data-assistant-contact-file":``,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,$.jsx)(Z,{name:`file-text`,className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate typography-ui`,children:C})]}),g?(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:r(`assistants.contact.attachment.loadFailed`)}):null,d&&!g||v?(0,$.jsx)(`span`,{role:`status`,className:`typography-micro text-muted-foreground`,children:r(`common.loading`)}):(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:d?()=>p(e=>e+1):()=>void S(),children:r(g?`chat.history.retry`:`assistants.contact.attachment.download`)})]})}function vt(e){let t=(0,Ze.c)(27),{part:n,onShowPopup:r}=e,{t:i}=A(),a=/^(?:https?:|data:|blob:)/i.test(n.url)?n.url:``,o=Be(a,``),[s,c]=Q.useState(!1),l;t[0]!==n.filename||t[1]!==i?(l=n.filename||i(`assistants.contact.attachment.image`),t[0]=n.filename,t[1]=i,t[2]=l):l=t[2];let u=l,d;t[3]!==u||t[4]!==r||t[5]!==o?(d=()=>{!r||!o||r({open:!0,title:u,content:``,metadata:{tool:`image-preview`,filename:u},image:{url:o,filename:u,gallery:[{url:o,filename:u}],index:0}})},t[3]=u,t[4]=r,t[5]=o,t[6]=d):d=t[6];let f=O(d);if(n.mime.startsWith(`image/`)&&o&&!s){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>c(!0),t[7]=e):e=t[7];let n;t[8]===f?n=t[9]:(n=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f())},t[8]=f,t[9]=n);let r;return t[10]!==u||t[11]!==f||t[12]!==o||t[13]!==n?(r=(0,$.jsx)(`img`,{src:o,alt:u,className:gt,onError:e,onClick:f,onKeyDown:n,role:`button`,tabIndex:0,"data-assistant-contact-image":``}),t[10]=u,t[11]=f,t[12]=o,t[13]=n,t[14]=r):r=t[14],r}let p;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Z,{name:`file-text`,className:`size-4 shrink-0 text-muted-foreground`}),t[15]=p):p=t[15];let m;t[16]!==n.filename||t[17]!==i?(m=n.filename||i(`assistants.contact.attachment.file`),t[16]=n.filename,t[17]=i,t[18]=m):m=t[18];let h;t[19]===m?h=t[20]:(h=(0,$.jsx)(`span`,{className:`truncate typography-ui`,children:m}),t[19]=m,t[20]=h);let g;t[21]!==s||t[22]!==i?(g=s?(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>c(!1),children:i(`chat.history.retry`)}):null,t[21]=s,t[22]=i,t[23]=g):g=t[23];let _;return t[24]!==h||t[25]!==g?(_=(0,$.jsxs)(`div`,{className:`flex max-w-full items-center gap-2.5 rounded-[1.25rem] bg-[var(--surface-muted)] px-3.5 py-2.5`,"data-assistant-contact-file":``,children:[p,h,g]}),t[24]=h,t[25]=g,t[26]=_):_=t[26],_}function yt(e){let t=(0,Ze.c)(5),{assistantID:n,part:r,onShowPopup:i}=e,a=ze(),o;return t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a?(o=`attachmentID`in r?(0,$.jsx)(_t,{assistantID:n,descriptor:r,onShowPopup:i},`${a}:${n}:${r.attachmentID}:${r.sha256}`):(0,$.jsx)(vt,{part:r,onShowPopup:i},`${a}:${r.url}`),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o):o=t[4],o}var bt=[],xt=e=>e.flatMap(e=>e.type===`text`&&e.text.trim()?[e.text]:[]).join(`
3
- `),St=(e,t,n,r=Date.now())=>({assistantID:e,messageID:t,parts:n,status:`sending`,createdAt:r}),Ct=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},wt=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},Tt=(e,t,n,r)=>({messageID:t?`${e.turnID}:preview:${t.bubbleIndex}`:`${e.turnID}:preview:${r}`,assistantID:e.assistantID,role:`assistant`,turnID:e.turnID,bubbleIndex:t?.bubbleIndex??0,createdAt:t?.occurredAt??e.occurredAt,ordinal:n,status:r,fromAssistantID:null,fromAssistantName:null,parts:t?[{type:`text`,text:t.text}]:[],text:t?.text??``,cards:[]}),Et=(e,t,n)=>{let r=e.bubbles.filter(e=>!t.has(e.bubbleIndex)).map((t,r)=>Tt(e,t,n+r,t.done?`complete`:`streaming`));return e.status===`failed`?[...r,Tt(e,null,n+r.length,`failed`)]:e.status===`admitted`||e.status===`streaming`?[...r,Tt(e,null,n+r.length,`admitted`)]:r},Dt=(e,t,n,r=[])=>{let i=new Set(e.map(e=>e.messageID)),a=t.flatMap((t,r)=>t.assistantID!==n||i.has(t.messageID)?[]:[{messageID:t.messageID,assistantID:n,role:`user`,turnID:t.messageID,bubbleIndex:0,createdAt:t.createdAt,ordinal:e.length+r,status:t.status,fromAssistantID:null,fromAssistantName:null,parts:[...t.parts],text:xt(t.parts),cards:[]}]),o=a.length===0?e:[...e,...a],s=r.filter(e=>e.assistantID===n);if(s.length===0)return o;let c=new Map,l=new Map;o.forEach((e,t)=>{if(c.set(e.turnID,t),e.role!==`assistant`||e.messageID.includes(`:preview:`))return;let n=l.get(e.turnID)??new Set;n.add(e.bubbleIndex),l.set(e.turnID,n)});let u=new Map,d=[];for(let e of s){let t=Et(e,l.get(e.turnID)??new Set,o.length+d.length);if(t.length===0)continue;let n=c.get(e.turnID);if(n===void 0){if(e.status===`failed`&&o.some(t=>t.turnID!==e.turnID))continue;d.push(...t);continue}let r=u.get(n)??[];r.push(...t),u.set(n,r)}return u.size===0&&d.length===0?o:o.flatMap((e,t)=>[e,...u.get(t)??[]]).concat(d)},Ot=(e,t)=>{let n=new Set(t.map(e=>e.messageID)),r=e.filter(e=>!n.has(e.messageID));return r.length===e.length?e:r},kt=(e,t)=>e.map(e=>e.messageID===t?{...e,status:`admitted`}:e),At=(e,t,n,r=Date.now())=>{let i=e.filter(e=>e.assistantID!==t||e.status!==`failed`||e.turnID===n);return i.some(e=>e.assistantID===t&&e.turnID===n)?i.length===e.length?e:i:[...i,{assistantID:t,turnID:n,status:`admitted`,bubbles:[],occurredAt:r}]},jt=(e,t,n)=>!t?.turnID||!t.assistantID||n?.has(t.turnID)?e:At(e,t.assistantID,t.turnID,t.admittedAt),Mt=(e,t)=>{let n=t.assistantID,r=t.pendingSendTurnIDs??new Set,i=t.settledTurnIDs??new Set,a=typeof t.snapshotRevision==`number`&&Number.isFinite(t.snapshotRevision)?t.snapshotRevision:null,o=t.admissionRevisionByTurnID instanceof Map?t.admissionRevisionByTurnID:new Map(Object.entries(t.admissionRevisionByTurnID??{}).map(([e,t])=>[e,Number(t)])),s=t.occurredAt??Date.now(),c=t.activeContactTurn&&t.activeContactTurn.turnID?t.activeContactTurn:null,l=!!(t.serverWorking||c),u=jt(e,c?{assistantID:n,turnID:c.turnID,admittedAt:c.admittedAt}:null,i),d=Array.isArray(t.messages)?t.messages:[];for(let e of d)e.role===`assistant`&&e.status===`error`&&(r.has(e.turnID)||i.has(e.turnID)||(u=Pt(u,{assistantID:n,turnID:e.turnID,status:`error`,error:e.text||`upstream_error`,occurredAt:s})));if(u=Ft(u,d),l){let t=u.filter(e=>{if(e.assistantID!==n||e.status!==`admitted`&&e.status!==`streaming`||r.has(e.turnID)||c&&e.turnID===c.turnID)return!0;let t=o.get(e.turnID);return typeof t==`number`&&a!=null&&a<t?!0:typeof t==`number`&&a!=null&&a>=t&&e.turnID!==c?.turnID?!1:!c||e.turnID===c.turnID});return t.length===e.length&&t.every((t,n)=>t===e[n])?e:t}if(a==null)return u.length===e.length&&u.every((t,n)=>t===e[n])?e:u;let f=u.filter(e=>{if(e.assistantID!==n||e.status!==`admitted`&&e.status!==`streaming`||r.has(e.turnID))return!0;if(i.has(e.turnID))return!1;let t=o.get(e.turnID);return typeof t==`number`&&a<t});return f.length===e.length&&f.every((t,n)=>t===e[n])?e:f.length===u.length?u:f},Nt=(e,t)=>At(e,t.assistantID,t.turnID,t.occurredAt).map(e=>{if(e.assistantID!==t.assistantID||e.turnID!==t.turnID||e.status===`failed`||e.status===`complete`)return e;let n=e.bubbles.find(e=>e.bubbleIndex===t.bubbleIndex);if(n?.done)return e;let r=n?{...n,text:`${n.text}${t.delta}`,done:t.done,occurredAt:t.occurredAt}:{bubbleIndex:t.bubbleIndex,text:t.delta,done:t.done,occurredAt:t.occurredAt},i=n?e.bubbles.map(e=>e.bubbleIndex===t.bubbleIndex?r:e):[...e.bubbles,r].sort((e,t)=>e.bubbleIndex-t.bubbleIndex);return{...e,status:`streaming`,bubbles:i}}),Pt=(e,t,n={})=>n.requireExisting&&!e.some(e=>e.assistantID===t.assistantID&&e.turnID===t.turnID)?e:At(e,t.assistantID,t.turnID,t.occurredAt).map(e=>e.assistantID!==t.assistantID||e.turnID!==t.turnID||e.status===`complete`||e.status===`failed`?e:{...e,status:t.status===`error`?`failed`:`complete`,...t.error?{error:t.error}:{}}),Ft=(e,t)=>{let n=new Set(t.map(e=>e.turnID).filter(Boolean)),r=t.length>0?t[t.length-1]?.turnID??null:null,i=[...e].reverse().find(e=>e.status===`admitted`||e.status===`streaming`)?.turnID??r,a=new Set(t.flatMap(e=>e.role===`assistant`?[e.turnID]:[])),o=e.filter(e=>e.status===`admitted`||e.status===`streaming`||!(e.status===`complete`&&a.has(e.turnID)||!n.has(e.turnID)||e.status===`failed`&&(i&&i!==e.turnID||r&&r!==e.turnID)));return o.length===e.length?e:o},It=(e,t,n)=>e.map(e=>e.messageID===t?{...e,status:`failed`,error:n}:e),Lt=(e,t)=>{if(e instanceof V){if(e.code===`no_provider`)return t.noProvider;if(e.code===`admission_timeout`||e.code===`generate_timeout`)return t.timedOut;if(e.message&&e.message!==e.code)return e.message}return B(e)?t.timedOut:t.sendFailed},Rt=()=>{let e=!1;return{tryAcquire:()=>!e&&(e=!0,!0),release:()=>{e=!1}}},zt=e=>{let t=e.text.trim();if(e.sending||!t&&e.attachments.length===0||!e.gate.tryAcquire())return{ok:!1};let n=[...t?[{type:`text`,text:t}]:[],...e.attachments.map(e=>({type:`file`,mime:e.mime,url:e.url,filename:e.name}))],r=e.createMessageID();return{ok:!0,messageID:r,parts:n,turn:St(e.assistantID,r,n,e.createdAt)}},Bt=e=>e.some(e=>e.status===`sending`),Vt=e=>e.some(e=>e.status===`admitted`||e.status===`streaming`),Ht=[`cursor-pointer rounded-[1.35rem] bg-[var(--surface-elevated)] ring-1 ring-inset ring-[var(--surface-subtle)]`,`px-3.5 py-3 text-left transition-[background-color,box-shadow,transform] duration-200 ease-out motion-reduce:transition-none`,`hover:-translate-y-px hover:bg-interactive-hover/45 hover:shadow-sm active:translate-y-0 motion-reduce:hover:translate-y-0`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`].join(` `),Ut=`${Ht} w-fit min-w-0 max-w-[min(100%,15rem)]`,Wt=`${Ht} w-fit min-w-0 max-w-[min(100%,20rem)]`;function Gt(e,t){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())}var Kt=e=>{let t=(0,Ze.c)(26),{card:n}=e,{t:r}=A(),i=_e(),a;t[0]===i?a=t[1]:(a=i&&!v(),t[0]=i,t[1]=a);let o=!!a,s=n.name,c=`${n.providerID}/${n.modelID}`,l;t[2]!==n.mode||t[3]!==c?(l=[c,n.mode].filter(Boolean),t[2]=n.mode,t[3]=c,t[4]=l):l=t[4];let u=l,d;t[5]!==n.assistantID||t[6]!==o?(d=()=>{if(o){oe.getState().openAssistant(n.assistantID);return}q(n.assistantID)},t[5]=n.assistantID,t[6]=o,t[7]=d):d=t[7];let f=O(d),p;t[8]===f?p=t[9]:(p=e=>{Gt(e,f)},t[8]=f,t[9]=p);let m=O(p),h;t[10]!==r||t[11]!==s?(h=r(`assistants.contact.card.assistant.aria`,{name:s}),t[10]=r,t[11]=s,t[12]=h):h=t[12];let g;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{className:`relative inline-block size-6 shrink-0 leading-none`,children:(0,$.jsx)(`span`,{className:`flex size-6 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(Z,{name:`robot-2`,className:`size-3`})})}),t[13]=g):g=t[13];let _;t[14]===s?_=t[15]:(_=(0,$.jsx)(`h3`,{className:`min-w-0 truncate typography-ui-label font-medium text-foreground`,children:s}),t[14]=s,t[15]=_);let y;t[16]===u?y=t[17]:(y=u.length>0?(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:u.join(` · `)}):null,t[16]=u,t[17]=y);let b;t[18]!==_||t[19]!==y?(b=(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[g,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[_,y]})]}),t[18]=_,t[19]=y,t[20]=b):b=t[20];let x;return t[21]!==m||t[22]!==f||t[23]!==b||t[24]!==h?(x=(0,$.jsx)(`article`,{className:Ut,role:`button`,tabIndex:0,"aria-label":h,"data-assistant-contact-card":`assistant`,onClick:f,onKeyDown:m,children:b}),t[21]=m,t[22]=f,t[23]=b,t[24]=h,t[25]=x):x=t[25],x},qt=e=>{let t=(0,Ze.c)(25),{card:n}=e,{t:r}=A(),i=n.name,a;t[0]!==n.kind||t[1]!==n.time||t[2]!==n.timezone?(a=[n.kind,n.time,n.timezone].filter(Boolean),t[0]=n.kind,t[1]=n.time,t[2]=n.timezone,t[3]=a):a=t[3];let o=a.join(` `),s;t[4]!==n.prompt||t[5]!==o?(s=o.trim()||(typeof n.prompt==`string`?n.prompt.trim():``),t[4]=n.prompt,t[5]=o,t[6]=s):s=t[6];let c=s,l=O(Jt),u;t[7]===l?u=t[8]:(u=e=>{Gt(e,l)},t[7]=l,t[8]=u);let d=O(u),f;t[9]!==r||t[10]!==i?(f=r(`assistants.contact.card.schedule.aria`,{name:i}),t[9]=r,t[10]=i,t[11]=f):f=t[11];let p;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`span`,{className:`relative inline-block size-6 shrink-0 leading-none`,children:(0,$.jsx)(`span`,{className:`flex size-6 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(Z,{name:`calendar`,className:`size-3`})})}),t[12]=p):p=t[12];let m;t[13]===i?m=t[14]:(m=(0,$.jsx)(`h3`,{className:`min-w-0 truncate typography-ui-label font-medium text-foreground`,children:i}),t[13]=i,t[14]=m);let h;t[15]===c?h=t[16]:(h=c?(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c}):null,t[15]=c,t[16]=h);let g;t[17]!==m||t[18]!==h?(g=(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[p,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[m,h]})]}),t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==d||t[21]!==l||t[22]!==f||t[23]!==g?(_=(0,$.jsx)(`article`,{className:Ut,role:`button`,tabIndex:0,"aria-label":f,"data-assistant-contact-card":`schedule`,onClick:l,onKeyDown:d,children:g}),t[20]=d,t[21]=l,t[22]=f,t[23]=g,t[24]=_):_=t[24],_};function Jt(){y.getState().setActiveMainTab(`schedule`),y.getState().setScheduledTasksDialogOpen(!0)}var Yt=(e,t)=>t===`cancelled`?t:e===`busy`||e===`retry`?e:t===`error`||t===`question`||t===`complete`?t:e===`idle`?`complete`:t===`busy`||t===`retry`||t===`idle`?t:t||`busy`,Xt=e=>e===`cancelled`?`assistants.contact.card.session.status.cancelled`:e===`busy`?`assistants.contact.card.session.status.busy`:e===`retry`?`assistants.contact.card.session.status.retry`:e===`idle`?`assistants.contact.card.session.status.idle`:e===`complete`?`assistants.contact.card.session.status.complete`:e===`error`?`assistants.contact.card.session.status.error`:e===`question`?`assistants.contact.card.session.status.question`:null,Zt=e=>e===`busy`?`bg-[var(--status-info)]/10 text-[var(--status-info)]`:e===`retry`||e===`question`?`bg-[var(--status-warning)]/10 text-[var(--status-warning)]`:e===`error`?`bg-[var(--status-error)]/10 text-[var(--status-error)]`:e===`idle`||e===`complete`?`bg-[var(--status-success)]/10 text-[var(--status-success)]`:`bg-[var(--surface-muted)] text-muted-foreground`,Qt=e=>e.split(/[/\\]/u).filter(Boolean).at(-1)||e,$t=e=>{let t=(0,Ze.c)(35),{card:n}=e,{t:r}=A(),i=_e(),a;t[0]===i?a=t[1]:(a=i&&!v(),t[0]=i,t[1]=a);let o=!!a,s;t[2]===n.sessionID?s=t[3]:(s=e=>e.activeSessions.find(e=>e.id===n.sessionID)??e.archivedSessions.find(e=>e.id===n.sessionID)??null,t[2]=n.sessionID,t[3]=s);let c=G(s),l=ce(n.sessionID),u=(typeof c?.title==`string`&&c.title.trim()?c.title.trim():null)||n.title||r(`assistants.contact.card.session.untitled`),d=Yt(l?.type,n.status),f=Xt(d),p=d===`busy`||d===`retry`,m=Qt(typeof c?.directory==`string`&&c.directory.trim()?c.directory.trim():n.directory),h=De(c)||n.branch,g=we(c),_=Ae(c),b=je(_),x=[m,g,h].filter(en),S;t[4]!==n.directory||t[5]!==n.sessionID||t[6]!==o?(S=()=>{let e=He(n.sessionID)?.directory||n.directory;le(n.sessionID,e,{phoneShell:o,switchToChat:!0}),o||y.getState().setActiveMainTab(`chat`)},t[4]=n.directory,t[5]=n.sessionID,t[6]=o,t[7]=S):S=t[7];let C=O(S),w;t[8]===C?w=t[9]:(w=e=>{Gt(e,C)},t[8]=C,t[9]=w);let T=O(w),E=Wt,D=r(`assistants.contact.card.session.aria`,{title:u}),k;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(`span`,{className:`flex size-6 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(Z,{name:`chat-3`,className:`size-3`})}),t[10]=k):k=t[10];let M;t[11]===p?M=t[12]:(M=p?(0,$.jsx)(`span`,{className:`pointer-events-none absolute right-0 bottom-0 size-2.5 translate-x-0.5 translate-y-0.5 rounded-full bg-[var(--status-success)] ring-2 ring-[var(--surface-elevated)]`,"data-assistant-working-dot":``,"aria-hidden":!0}):null,t[11]=p,t[12]=M);let N;t[13]===M?N=t[14]:(N=(0,$.jsxs)(`span`,{className:`relative inline-block size-6 shrink-0 leading-none`,children:[k,M]}),t[13]=M,t[14]=N);let P;t[15]===u?P=t[16]:(P=(0,$.jsx)(`h3`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:u}),t[15]=u,t[16]=P);let F=f?(0,$.jsx)(`span`,{className:j(`shrink-0 rounded-full px-1.5 py-0.5 typography-micro leading-none`,Zt(d)),children:r(f)}):null,I;t[17]!==P||t[18]!==F?(I=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[P,F]}),t[17]=P,t[18]=F,t[19]=I):I=t[19];let L;t[20]===x?L=t[21]:(L=x.length>0?(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:x.join(` · `)}):null,t[20]=x,t[21]=L);let R=b||_?.files!==void 0&&_.files>0?(0,$.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-1.5 typography-micro tabular-nums`,children:[_?.additions===void 0?null:(0,$.jsxs)(`span`,{className:`text-[var(--status-success)]`,children:[`+`,_.additions]}),_?.deletions===void 0?null:(0,$.jsxs)(`span`,{className:`text-[var(--status-error)]`,children:[`−`,_.deletions]}),_?.files===void 0?null:(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:_.files===1?r(`assistants.contact.card.session.changes.filesSingle`,{count:_.files}):r(`assistants.contact.card.session.changes.filesPlural`,{count:_.files})})]}):null,z;t[22]!==I||t[23]!==L||t[24]!==R?(z=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[I,L,R]}),t[22]=I,t[23]=L,t[24]=R,t[25]=z):z=t[25];let B;t[26]!==N||t[27]!==z?(B=(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[N,z]}),t[26]=N,t[27]=z,t[28]=B):B=t[28];let V;return t[29]!==T||t[30]!==C||t[31]!==B||t[32]!==E||t[33]!==D?(V=(0,$.jsx)(`article`,{className:E,role:`button`,tabIndex:0,"aria-label":D,"data-assistant-contact-card":`session`,onClick:C,onKeyDown:T,children:B}),t[29]=T,t[30]=C,t[31]=B,t[32]=E,t[33]=D,t[34]=V):V=t[34],V};function en(e){return!!(e&&e.trim())}var tn=2,nn=1500,rn=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),an=e=>e.scrollHeight-e.scrollTop-e.clientHeight,on=e=>an(e)<=tn,sn=(e,t)=>{let n=t instanceof Element?t:t instanceof Node?t.parentElement:null;for(;n&&n!==e;){if(n instanceof HTMLElement&&n.scrollHeight>n.clientHeight+1&&n.scrollTop+n.clientHeight<n.scrollHeight-1)return!0;n=n.parentElement}return!1},cn=e=>e.altKey||e.ctrlKey||e.metaKey?!1:e.key===`ArrowDown`||e.key===`PageDown`||e.key===`End`,ln=({active:e,assistantID:t,contentRevision:n,onLoadEarlier:r})=>{let i=Q.useRef(null),[a,o]=Q.useState(null),[s,c]=Q.useState(null),l=Q.useRef(!0),u=Q.useRef(null),d=Q.useRef(null),f=Q.useRef(null),p=Q.useRef(0),m=Q.useRef(null),h=Q.useRef(null),g=Q.useRef(e);g.current=e;let _=Q.useMemo(()=>e=>{i.current=e,o(t=>t===e?t:e)},[]),v=Q.useMemo(()=>e=>{c(t=>t===e?t:e)},[]),y=O(()=>{let e=i.current;if(!e||!g.current||l.current)return;let t=e.getBoundingClientRect().top,n=Array.from(e.querySelectorAll(`[data-message-id]`)).find(e=>e.getBoundingClientRect().bottom>t);u.current=n?{id:n.dataset.messageId,offset:n.getBoundingClientRect().top-t}:null}),b=O(()=>{let e=i.current,t=u.current;if(!e||!t||!g.current||l.current)return;if(Math.abs(e.scrollTop-p.current)>.5){p.current=e.scrollTop,y();return}let n=Array.from(e.querySelectorAll(`[data-message-id]`)).find(e=>e.dataset.messageId===t.id);if(!n){y();return}let r=n.getBoundingClientRect().top-e.getBoundingClientRect().top-t.offset;Math.abs(r)>.5&&(e.scrollTop+=r),p.current=e.scrollTop}),x=O(()=>{l.current=!1,p.current=i.current?.scrollTop??0,y()}),S=O(()=>{if(!g.current||!l.current)return!1;let e=i.current;if(!e)return!1;let t=rn(e),n=Math.min(p.current,Math.max(0,t.scrollHeight-t.clientHeight));return t.scrollTop<n-.5?(l.current=!1,p.current=t.scrollTop,y(),!1):on(t)?(p.current=t.scrollTop,!1):(e.scrollTop=e.scrollHeight,p.current=e.scrollTop,!0)}),C=O(e=>{h.current={direction:e,expiresAt:performance.now()+nn}}),w=O(()=>{let e=h.current;return e?performance.now()>e.expiresAt?(h.current=null,null):e.direction:null}),T=O(()=>{l.current=!1,y()}),D=O(()=>{if(!g.current)return;let e=i.current;if(!e)return;let t=rn(e),n=t.scrollTop>p.current,a=Math.min(p.current,Math.max(0,t.scrollHeight-t.clientHeight));if(p.current=t.scrollTop,l.current){t.scrollTop<a-.5&&T();return}let o=w();y(),t.scrollTop<=80&&o===`up`&&r?.(),n&&on(t)&&(o===`down`||o===`scrollbar`)&&(l.current=!0)}),A=O(e=>{let t=i.current;if(!(!t||e.deltaY===0)){if(e.deltaY<0){if(Oe(t,e.target))return;C(`up`),T(),t.scrollTop<=80&&r?.();return}sn(t,e.target)||C(`down`)}}),j=O(e=>{h.current=null;let t=e.touches.item(0);m.current=t?{x:t.clientX,y:t.clientY,deltaX:0,deltaY:0}:null}),M=O(e=>{let t=i.current,n=e.touches.item(0);if(!t||!n){m.current=null;return}let a=m.current;if(!a)return;let o=n.clientY-a.y,s=o*a.deltaY<0,c=(s?0:a.deltaX)+n.clientX-a.x,l=(s?0:a.deltaY)+o;if(m.current={x:n.clientX,y:n.clientY,deltaX:c,deltaY:l},!(Math.abs(c)>=Math.abs(l))){if(l>0&&Oe(t,e.target)||l<0&&sn(t,e.target)){m.current.deltaX=0,m.current.deltaY=0;return}C(l>0?`up`:`down`),l>2&&(T(),t.scrollTop<=80&&r?.())}}),N=O(()=>{m.current=null}),P=O(e=>{if(be(e)){C(`up`),T(),(i.current?.scrollTop??1/0)<=80&&r?.();return}cn(e)&&C(`down`)}),F=O(e=>{let t=i.current;e.pointerType===`mouse`&&e.target===t&&C(`scrollbar`)});Q.useLayoutEffect(()=>{let n=e?t:null,r=i.current;(d.current!==n||f.current!==r)&&(d.current=n,f.current=r,l.current=!0,u.current=null,h.current=null,m.current=null,p.current=r?.scrollTop??0),e&&(S(),b())},[e,t,n,a]);let I=Q.useMemo(()=>()=>void 0,[]),L=e&&a?a:I,R=Q.useMemo(()=>({passive:!0}),[]);k(`scroll`,D,L,R),k(`wheel`,A,L,R),k(`touchstart`,j,L,R),k(`touchmove`,M,L,R),k(`touchend`,N,L,R),k(`touchcancel`,N,L,R),k(`keydown`,P,L),k(`pointerdown`,F,L,R);let z=O(()=>{S(),b()});return E(typeof ResizeObserver<`u`&&e?s:null,z),{scrollRef:_,contentRef:v,preparePrepend:x}},un=64,dn=e=>{if(!e)return[];let t=Array.from(e.files||[]);return t.length>0?t:Array.from(e.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e instanceof File)},fn=e=>Array.from(e?.files||[]),pn=async(e,t=p)=>{let n=[],r=0;for(let i of Array.from(e||[])){if(!i||i.size<=0)continue;if(i.size>26214400){r+=1;continue}let e=URL.createObjectURL(i);n.push({id:t(),url:e,name:i.name.trim()||`attachment`,mime:i.type.trim()||`application/octet-stream`,file:i})}return{attachments:n,skippedTooLarge:r}},mn=(e,t)=>{let n=[...e,...t];for(let e of n.slice(un))e.url.startsWith(`blob:`)&&URL.revokeObjectURL(e.url);return n.slice(0,un)},hn=Le(()=>x(()=>import(`./ToolOutputDialog-CUl0cRZG.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52]))),gn=e=>e.trim().startsWith(`oc.settle.`),_n=({assistant:e,warning:t,active:n,overlayHeader:r=!1})=>{let{t:i}=A(),a=ze(),o=y(e=>e.isMobile),s=z(),c=re(),l=I(e.id,n),u=y(e=>e.isSettingsDialogOpen),d=n&&!u&&!l.hasMessageGap?F(e,l.data):null,f=N(e.name),m=f.displayName||e.name,h=(e,t)=>{let n=e?c.data?.assistants.find(t=>t.id===e):void 0;return n?N(n.name).displayName||n.name:t||i(`assistants.contact.peer.unknown`)},[g,_]=Q.useState(``),[v,b]=Q.useState([]),x=Q.useRef(null),S=Q.useRef(new Map),C=Q.useRef(new AbortController);Q.useEffect(()=>{let e=new AbortController;return C.current=e,()=>e.abort()},[e.id,a]);let w=Q.useRef(new Set);Q.useEffect(()=>{let e=new Set(v.map(e=>e.url));for(let t of w.current)e.has(t)||URL.revokeObjectURL(t);w.current=e},[v]),Q.useEffect(()=>()=>{for(let e of w.current)URL.revokeObjectURL(e)},[]);let[T,E]=Q.useState([]),[D,k]=Q.useState([]),[L,B]=Q.useState(null),[H,te]=Q.useState({open:!1,title:``,content:``}),W=y(e=>e.setImagePreviewOpen),ne=O(e=>{(e.image||e.mermaid)&&(te(e),W(!0))}),ie=O(e=>{te(t=>({...t,open:e})),W(e)});Q.useEffect(()=>()=>{W(!1)},[W]);let ae=Q.useRef(!1);Q.useEffect(()=>{S.current.clear(),x.current=null,E([]),k([]),B(null)},[a]);let oe=Q.useMemo(()=>Rt(),[]),ce=Q.useRef(new Set),le=Q.useRef(new Map),G=tt(e=>e.setWorking),K=l.data?.messages??bt,q=Ct(T,e.id),ue=wt(D,e.id),de=Dt(K,q,e.id,ue).filter(e=>{let t=Array.isArray(e.parts)?e.parts:[];return t.length===0||t.some(e=>!(e.type===`text`&&gn(e.text)))}),J=Bt(q),Y=Vt(ue),X=!!(e.working||e.activeContactTurn),fe=c.data?.revision??null,pe=ue.reduce((e,t)=>e+t.bubbles.reduce((e,t)=>e+t.text.length,0),0),me=new Map(ue.map(e=>[e.turnID,e])),he=Q.useRef(!1),ge=O(async(e=!1)=>{if(!(!n||he.current||l.isFetchingPreviousPage||l.isFillingMessageGap)&&!(e&&l.previousPageError)&&!(!l.hasPreviousPage&&!l.hasMessageGap)){he.current=!0,ye();try{l.hasMessageGap?await l.retryMessageGap():await l.fetchPreviousPage()}catch{}finally{he.current=!1}}}),{scrollRef:_e,contentRef:ve,preparePrepend:ye}=ln({active:n,assistantID:e.id,contentRevision:`${de[0]?.messageID}:${de.length}:${pe}:${l.isFetchingPreviousPage}:${l.hasPreviousPage}:${l.isFillingMessageGap}`,onLoadEarlier:()=>{ge(!0)}});Q.useEffect(()=>{B(null),ce.current.clear(),le.current=new Map,E(t=>Ct(t,e.id)),k(t=>wt(t,e.id)),te({open:!1,title:``,content:``}),W(!1)},[e.id,W]),Q.useEffect(()=>{E(e=>Ot(e,K))},[K]),Q.useEffect(()=>{let t=new Set(q.filter(e=>e.status===`sending`).map(e=>e.messageID));k(n=>Mt(n,{assistantID:e.id,activeContactTurn:e.activeContactTurn?{turnID:e.activeContactTurn.turnID,admittedAt:e.activeContactTurn.admittedAt}:null,serverWorking:X,snapshotRevision:fe,admissionRevisionByTurnID:le.current,pendingSendTurnIDs:t,messages:K,settledTurnIDs:ce.current}))},[e.activeContactTurn,e.id,K,q,X,fe]),Q.useEffect(()=>{G(e.id,J||Y||X)},[e.id,Y,J,X,G]),Q.useEffect(()=>{let t=e.id;return()=>{G(t,!1)}},[e.id,G]);let be=O(t=>{if(!(!(`assistantID`in t)||t.assistantID!==e.id)){if(t.type===`contact-turn-start`){ce.current.delete(t.turnID),k(e=>At(e,t.assistantID,t.turnID,t.occurredAt));return}if(t.type===`contact-bubble-delta`){if(ce.current.has(t.turnID))return;k(e=>Nt(e,t));return}t.type===`contact-turn-end`&&(ce.current.add(t.turnID),k(e=>Ft(Pt(e,t,{requireExisting:!0}),K)))}});Q.useEffect(()=>{if(n)return se(be)},[n,e.id]);let xe=O(async e=>{if(J)return;let t=C.current,n=await pn(e);if(t.signal.aborted){n.attachments.forEach(e=>URL.revokeObjectURL(e.url));return}n.skippedTooLarge>0&&B(i(`assistants.contact.attachment.tooLarge`)),n.attachments.length!==0&&b(e=>mn(e,n.attachments))}),Se=O(e=>{let t=dn(e.clipboardData);t.length!==0&&(e.preventDefault(),xe(t))}),Ce=O(e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}),we=O(e=>{let t=fn(e.dataTransfer);t.length!==0&&(e.preventDefault(),xe(t))}),Te=O(async()=>{let t=C.current,n=g,r=v,a=e.id,o=x.current,c=o?.assistantID===a&&o.text===n&&o.attachments===r?o.messageID:null,l=zt({gate:oe,sending:Bt(q),text:n,attachments:r,assistantID:a,createMessageID:()=>c||`oc_contact_${p()}`});if(!l.ok)return;x.current={assistantID:a,text:n,attachments:r,messageID:l.messageID},E(e=>[...e.filter(e=>e.messageID!==l.messageID),l.turn]),B(null);let u=()=>{_(e=>e===n?``:e),b(e=>e.filter(e=>!r.includes(e))),r.forEach(e=>S.current.delete(`${a}:${e.id}`)),x.current=null};try{let e=[];for(let n of r){let r=`${a}:${n.id}`,i=S.current.get(r);if(!i){if(i=await Je(a,n.file,n.id,t.signal),t.signal.aborted)return;S.current.set(r,i)}e.push(i)}if(t.signal.aborted)return;let n=[...l.parts.filter(e=>e.type===`text`),...e];E(e=>e.map(e=>e.messageID===l.messageID?{...e,parts:n}:e));let i=await R(a,l.messageID,{parts:n});if(t.signal.aborted)return;u(),typeof i.revision==`number`&&le.current.set(l.messageID,i.revision),E(e=>kt(e,l.messageID)),ce.current.has(l.messageID)||k(e=>At(e,a,l.messageID)),s.data?.serverInstanceID&&P({serverInstanceID:s.data.serverInstanceID,assistantID:a,name:m,avatarSeed:a,...f.avatarEmoji?{avatarEmoji:f.avatarEmoji}:{}}).catch(()=>void 0)}catch(e){if(t.signal.aborted)return;if(e instanceof V&&e.code===`admission_timeout`)try{let e=await ee(a,l.messageID);if(t.signal.aborted)return;if(e){u(),typeof e.revision==`number`&&le.current.set(l.messageID,e.revision),E(e=>kt(e,l.messageID)),ce.current.has(l.messageID)||k(e=>At(e,a,l.messageID));return}}catch{}let n=Lt(e,{noProvider:i(`assistants.contact.noProvider`),sendFailed:i(`assistants.contact.sendFailed`),timedOut:i(`assistants.contact.timedOut`)});E(e=>It(e,l.messageID,n)),B(n)}finally{oe.release()}}),Ee=O(async()=>{if(ae.current)return;ae.current=!0;let t=C.current;B(null);try{await U(e.id,e)}catch(e){t.signal.aborted||B(e instanceof Error?e.message:i(`settings.mcp.page.toast.unexpectedError`))}finally{ae.current=!1}}),De=l.isError&&de.length===0,Oe=l.isSuccess&&de.length===0,ke=new Map(q.map(e=>[e.messageID,e]));return(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,children:[(0,$.jsxs)(`div`,{ref:_e,className:j(`min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-4 pb-9 sm:px-8 sm:pb-12`,r?`pt-[calc(max(0.625rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height)+1.25rem)]`:`pt-5 sm:pt-7`),style:{overflowAnchor:`none`,overscrollBehavior:`contain`,overscrollBehaviorY:`contain`},"data-assistant-contact-transcript":``,children:[t?(0,$.jsx)(`p`,{className:`mb-3 typography-micro text-[var(--status-warning)]`,children:t}):null,De?(0,$.jsxs)(`div`,{ref:ve,className:`mx-auto flex h-full min-h-56 max-w-xs flex-col items-center justify-center pb-16 text-center`,"data-assistant-contact-error":``,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(et,{name:e.id,emoji:f.avatarEmoji,size:44,label:m}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`absolute -right-1 -bottom-1 flex size-5 items-center justify-center rounded-full bg-[var(--surface-elevated)] text-[var(--status-error)] ring-2 ring-background`,children:(0,$.jsx)(Z,{name:`error-warning`,className:`size-3`})})]}),(0,$.jsx)(`p`,{className:`mt-4 typography-ui-label font-medium text-foreground`,children:m}),(0,$.jsx)(`p`,{className:`mt-1.5 typography-ui leading-6 text-muted-foreground`,children:i(`assistants.contact.loadFailed`)}),(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>void l.refetch(),children:i(`chat.history.retry`)})]}):Oe?(0,$.jsxs)(`div`,{ref:ve,className:`mx-auto flex h-full min-h-56 max-w-sm flex-col items-center justify-center pb-16 text-center`,"data-assistant-contact-empty":``,children:[(0,$.jsx)(et,{name:e.id,emoji:f.avatarEmoji,size:48,label:m,className:`opacity-90`}),(0,$.jsx)(`p`,{className:`mt-5 typography-ui-header font-medium tracking-[-0.01em] text-foreground`,children:i(`assistants.conversation.emptyTitle`,{name:m})}),(0,$.jsx)(`p`,{className:`mt-2 max-w-xs typography-ui leading-6 text-muted-foreground/80`,children:i(`assistants.contact.empty`)})]}):(0,$.jsxs)(`div`,{ref:ve,className:`mx-auto flex w-full max-w-[42rem] flex-col`,children:[l.isPending?(0,$.jsx)(`p`,{role:`status`,className:`py-3 text-center typography-micro text-muted-foreground`,children:i(`common.loading`)}):null,l.hasPreviousPage||l.hasMessageGap?(0,$.jsxs)(`div`,{className:`mb-3 flex flex-col items-center gap-1`,"data-assistant-contact-pagination":``,"aria-busy":l.isFetchingPreviousPage||l.isFillingMessageGap,children:[l.previousPageError?(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:i(`chat.history.loadOlderFailed`)}):null,l.hasMessageGap?(0,$.jsx)(`p`,{role:`status`,className:`typography-micro text-muted-foreground`,children:i(`assistants.contact.history.gap`)}):null,(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,disabled:l.isFetchingPreviousPage||l.isFillingMessageGap,onClick:()=>void ge(),children:i(l.isFetchingPreviousPage||l.isFillingMessageGap?`chat.history.loadingMore`:l.previousPageError||l.hasMessageGap?`chat.history.retry`:`chat.history.loadOlder`)})]}):null,de.map((t,n)=>{let r=n>0?de[n-1]:null,o=t.role===`user`,s=t.role===`peer`,l=t.role===`assistant`&&r?.role===`assistant`&&r.turnID===t.turnID,u=r?.turnID!==t.turnID,f=!o&&(s||!l),p=s?h(t.fromAssistantID,t.fromAssistantName):m,g=s&&t.fromAssistantID?c.data?.assistants.find(e=>e.id===t.fromAssistantID):e,_=g?N(g.name):null,v=ke.get(t.messageID),y=me.get(t.turnID),b=t.status===`admitted`&&t.messageID.endsWith(`:preview:admitted`),x=t.status===`failed`&&t.messageID.endsWith(`:preview:failed`);return t.status===`error`||x?(0,$.jsxs)(`div`,{"data-message-id":t.messageID,"data-assistant-contact-error":``,className:`mt-3 px-1`,children:[(0,$.jsx)(`p`,{role:`alert`,className:`whitespace-pre-wrap typography-micro text-[var(--status-error)] [overflow-wrap:anywhere]`,children:t.text||y?.error||i(`assistants.contact.sendFailed`)}),d?.messageID===t.messageID?(0,$.jsx)(it,{assistantID:e.id,position:d},`${a}:${e.id}:${d.generation}:${d.ordinal}`):null]},t.messageID):(0,$.jsxs)(`div`,{"data-message-id":t.messageID,className:j(`flex w-full`,o?`justify-end`:`justify-start`,u?`mt-6 first:mt-0`:l?`mt-1.5`:`mt-3`),"data-assistant-contact-role":t.role,"data-assistant-contact-turn-status":v?.status??t.status,"data-assistant-contact-run-start":t.role===`assistant`&&!l?``:void 0,children:[o?null:(0,$.jsx)(`div`,{className:`mr-2.5 flex w-8 shrink-0 justify-center pt-0.5`,children:f?(0,$.jsx)(et,{name:g?.id||t.fromAssistantID||e.id,emoji:_?.avatarEmoji,size:28,label:p}):(0,$.jsx)(`span`,{className:`size-7`,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:j(`flex min-w-0 flex-col gap-1.5`,o?`max-w-[min(82%,30rem)] items-end`:`max-w-[min(84%,34rem)] items-start`),children:[s?(0,$.jsx)(`span`,{className:`mb-0.5 px-1 typography-micro text-muted-foreground/75`,children:i(`assistants.contact.peer.from`,{name:p})}):null,b?(0,$.jsxs)(`div`,{role:`status`,"aria-label":i(`assistants.contact.processing`),className:`inline-flex w-fit items-center gap-1 rounded-full bg-[var(--surface-muted)] px-3.5 py-2.5 text-muted-foreground/70`,"data-assistant-contact-processing":``,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-delay:-0.45s] [animation-duration:1.4s] motion-reduce:animate-none`}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-delay:-0.22s] [animation-duration:1.4s] motion-reduce:animate-none`}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-duration:1.4s] motion-reduce:animate-none`})]}):null,t.parts.map((n,r)=>{if(n.type===`card`&&n.cardType===`session`)return(0,$.jsx)($t,{card:n},`${t.messageID}:card:${r}`);if(n.type===`card`&&n.cardType===`assistant`)return(0,$.jsx)(Kt,{card:n},`${t.messageID}:card:${r}`);if(n.type===`card`&&n.cardType===`schedule`)return(0,$.jsx)(qt,{card:n},`${t.messageID}:card:${r}`);if(n.type===`file`)return(0,$.jsx)(yt,{assistantID:e.id,part:n,onShowPopup:ne},`${t.messageID}:file:${r}`);if(n.type===`text`&&gn(n.text))return null;if(n.type===`text`&&(n.text.trim()||t.status===`streaming`)){let e=!o;return(0,$.jsxs)(`div`,{"aria-label":s?i(`assistants.contact.peer.aria`,{name:p}):void 0,"data-assistant-contact-text":``,className:j(`min-w-0 max-w-full [overflow-wrap:anywhere] rounded-[1.35rem] px-4 py-2.5 typography-markdown leading-6`,e?null:`whitespace-pre-wrap`,o?`rounded-[1.15rem] rounded-br-lg bg-[var(--primary-base)]/90 text-[var(--primary-foreground)]`:s?`rounded-[1.25rem] border border-dashed border-border/50 bg-[var(--surface-muted)]/70 text-foreground`:j(`bg-[var(--surface-muted)] text-foreground`,l&&`rounded-tl-lg`)),children:[e?(0,$.jsx)(Re,{content:n.text,messageId:t.messageID,isAnimated:!1,isStreaming:t.status===`streaming`,variant:`assistant`,enableFileReferences:!1,onShowPopup:ne,className:`w-full min-w-0 [overflow-wrap:anywhere]`}):n.text,t.status===`streaming`&&r===t.parts.length-1?(0,$.jsx)(`span`,{"aria-hidden":!0,className:`ml-0.5 inline-block h-[1em] w-px translate-y-[0.12em] animate-pulse bg-current opacity-45 [animation-duration:1.1s] motion-reduce:animate-none`,"data-assistant-contact-streaming-caret":``}):null]},`${t.messageID}:text:${r}`)}return null}),v?.status===`sending`?(0,$.jsx)(`p`,{className:`px-1 typography-micro text-muted-foreground/75`,children:i(`assistants.contact.sending`)}):null,v?.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 typography-micro text-[var(--status-error)]`,children:v.error||i(`assistants.contact.sendFailed`)}):null,d?.messageID===t.messageID?(0,$.jsx)(it,{assistantID:e.id,position:d},`${a}:${e.id}:${d.generation}:${d.ordinal}`):null]})]},t.messageID)})]})]}),(0,$.jsxs)(`footer`,{className:`relative z-10 shrink-0 bg-background pt-1`,"data-assistant-contact-composer":``,children:[L?(0,$.jsxs)(`div`,{className:`chat-input-column mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:L}),x.current?(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,disabled:J,onClick:()=>void Te(),children:i(`chat.history.retry`)}):null]}):null,(0,$.jsx)(`form`,{className:j(`relative w-full pt-1.5 pb-4`,o&&`bottom-safe-area oc-mobile-composer`),onSubmit:e=>{e.preventDefault(),Te()},onDragOver:Ce,onDrop:we,children:(0,$.jsx)(`div`,{className:`chat-input-column relative overflow-visible`,children:(0,$.jsx)(pt,{active:n,layout:`inline`,value:g,attachments:v,pending:J,working:Y||X,onStop:Y||X?()=>{Ee()}:void 0,stopLabel:i(`chat.chatInput.actions.stopGeneratingAria`),isMobile:o,placeholder:i(`assistants.contact.placeholder`,{name:m}),sendLabel:i(`assistants.contact.send`),addFilesLabel:i(`assistants.contact.addFiles`),removeAttachmentLabel:i(`assistants.contact.removeAttachment`),fileAccept:`*/*`,onChange:e=>_(e),onSubmit:()=>{Te()},onAddFiles:e=>{xe(e)},onRemoveAttachment:t=>{J||(S.current.delete(`${e.id}:${t}`),x.current=null,b(e=>e.filter(e=>e.id!==t)))},onPaste:Se,onDragOver:Ce,onDrop:we,className:j(`relative z-10`,o&&`oc-mobile-composer-surface`),style:{borderRadius:`1.5rem`},"data-assistant-contact-composer-surface":``,textareaProps:{"aria-label":i(`assistants.contact.placeholder`,{name:m})}},`${a}:${e.id}`)})})]}),H.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(hn,{popup:H,onOpenChange:ie,isMobile:o})}):null]})};async function vn(e){await L(e);let t=K.getState().defaultShareAssistant;if(t?.assistantID!==e.id)return;let n=await te();n.serverInstanceID&&t.serverInstanceID===n.serverInstanceID&&K.getState().setDefaultShareAssistant(null)}function yn({assistant:e,open:t,onOpenChange:n,onDeleted:r}){let{t:i}=A(),[a,o]=Q.useState(!1),s=e?N(e.name).displayName||e.name:``,c=O(e=>{a&&!e||n(e)}),l=O(()=>{a||n(!1)}),u=O(async()=>{if(!(!e||a)){o(!0);try{await vn(e),r?.(e.id),n(!1),C.success(i(`assistants.settings.toast.deleted`))}catch{C.error(i(`assistants.settings.toast.deleteFailed`))}finally{o(!1)}}});return(0,$.jsx)(pe,{open:t&&e!==null,onOpenChange:c,children:(0,$.jsxs)(Y,{className:`max-w-md`,children:[(0,$.jsxs)(de,{children:[(0,$.jsx)(X,{children:i(`assistants.settings.delete`)}),(0,$.jsx)(fe,{children:i(`assistants.settings.deleteConfirm`,{name:s})})]}),(0,$.jsxs)(J,{children:[(0,$.jsx)(M,{size:`sm`,variant:`ghost`,onClick:l,disabled:a,children:i(`settings.common.actions.cancel`)}),(0,$.jsx)(M,{size:`sm`,variant:`destructive`,onClick:u,disabled:a,children:i(`settings.common.actions.delete`)})]})]})})}var bn=`line-clamp-2 min-w-0 max-w-full overflow-clip whitespace-normal [overflow-wrap:anywhere] typography-micro text-muted-foreground`,xn={image:`assistants.contact.attachment.image`,file:`assistants.contact.attachment.file`,session:`assistants.contact.card.session.untitled`,assistant:`assistants.title`,schedule:`assistants.settings.scheduledTasks.title`};function Sn(e,t){return e?.text.replace(/\s+/gu,` `).trim()||t(e?.fallbackKind?xn[e.fallbackKind]:`assistants.contact.empty`)}var Cn=e=>e.capabilityPending?`loading`:e.capabilityError||e.supported!==!0||e.capabilityEnabled!==!0?`unavailable`:e.snapshotPending?`loading`:e.snapshotEnabled===!0?e.assistantCount===0?`onboarding`:e.hasAssistant?`ready`:e.snapshotSettled?`unavailable`:`loading`:`unavailable`,wn=t({AssistantView:()=>Dn}),Tn=e=>{let t=(0,Ze.c)(22),{assistant:n,onBack:r,onOpenSettings:i}=e,{t:a}=A(),o=_e(),s;t[0]===n?s=t[1]:(s=n?N(n.name):null,t[0]=n,t[1]=s);let c=s,l=n&&c?c.displayName||n.name:``,u;t[2]!==n||t[3]!==o||t[4]!==i?(u=()=>{if(n){if(i){i(n.id);return}ue(n.id,o?{openMobileSettings:o.openSettings}:void 0)}},t[2]=n,t[3]=o,t[4]=i,t[5]=u):u=t[5];let d=O(u),f;t[6]!==n||t[7]!==l||t[8]!==c?.avatarEmoji||t[9]!==a?(f=n?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2.5`,children:[(0,$.jsx)(et,{name:n.id,emoji:c?.avatarEmoji,size:28,label:l}),(0,$.jsx)(`span`,{className:`truncate font-medium tracking-[-0.01em]`,children:l||a(`assistants.title`)})]}):l||a(`assistants.title`),t[6]=n,t[7]=l,t[8]=c?.avatarEmoji,t[9]=a,t[10]=f):f=t[10];let p;t[11]===a?p=t[12]:(p=a(`assistants.actions.backToChat`),t[11]=a,t[12]=p);let m;t[13]!==n||t[14]!==d||t[15]!==a?(m=n?[{icon:`settings-3`,ariaLabel:a(`assistants.conversation.openSettings`),onClick:d}]:[],t[13]=n,t[14]=d,t[15]=a,t[16]=m):m=t[16];let h;return t[17]!==r||t[18]!==f||t[19]!==p||t[20]!==m?(h=(0,$.jsx)(W,{title:f,backAriaLabel:p,onBack:r,actions:m,overlay:!0}),t[17]=r,t[18]=f,t[19]=p,t[20]=m,t[21]=h):h=t[21],h},En=e=>{let t=(0,Ze.c)(50),{unreadCount:n,summary:r,assistantID:i,displayName:a,avatarEmoji:o,selected:s,enabled:c,editLabel:l,deleteLabel:u,onSelect:d,onEdit:f,onDelete:p,serverWorking:m}=e,h=rt(i,m!==void 0&&m),[g,_]=Q.useState(!1),v;t[0]===d?v=t[1]:(v=()=>d(),t[0]=d,t[1]=v);let y=O(v),b;t[2]===f?b=t[3]:(b=()=>{_(!1),f()},t[2]=f,t[3]=b);let x=O(b),S;t[4]===p?S=t[5]:(S=()=>{_(!1),p()},t[4]=p,t[5]=S);let C=O(S),w;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(w=e=>{e.preventDefault(),_(!0)},t[6]=w):w=t[6];let T=s?`border-border/50 bg-[var(--surface-elevated)]`:`border-transparent hover:bg-interactive-hover`,E=!c&&`opacity-65`,D;t[7]!==T||t[8]!==E?(D=j(`flex w-full min-h-11 items-center gap-3 rounded-xl border px-3 py-3 text-left outline-none transition-[background-color,border-color,opacity] duration-150 ease-out active:bg-interactive-active focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,T,E),t[7]=T,t[8]=E,t[9]=D):D=t[9];let k;t[10]!==y||t[11]!==s||t[12]!==D?(k=(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":s,onClick:y,onContextMenu:w,className:D}),t[10]=y,t[11]=s,t[12]=D,t[13]=k):k=t[13];let A;t[14]!==i||t[15]!==o||t[16]!==a||t[17]!==h?(A=(0,$.jsx)(et,{name:i,emoji:o,size:24,label:a,working:h}),t[14]=i,t[15]=o,t[16]=a,t[17]=h,t[18]=A):A=t[18];let M;t[19]===a?M=t[20]:(M=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-medium`,children:a}),t[19]=a,t[20]=M);let N;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(N=j(bn,`mt-1.5`),t[21]=N):N=t[21];let P;t[22]===r?P=t[23]:(P=(0,$.jsx)(`span`,{className:N,children:r}),t[22]=r,t[23]=P);let F;t[24]!==M||t[25]!==P?(F=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[M,P]}),t[24]=M,t[25]=P,t[26]=F):F=t[26];let I;t[27]===n?I=t[28]:(I=(0,$.jsx)(Ve,{count:n}),t[27]=n,t[28]=I);let L;t[29]!==A||t[30]!==F||t[31]!==I||t[32]!==k?(L=(0,$.jsxs)(Ue,{render:k,children:[A,F,I]}),t[29]=A,t[30]=F,t[31]=I,t[32]=k,t[33]=L):L=t[33];let R;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(Z,{name:`edit`,className:`size-4`}),t[34]=R):R=t[34];let z;t[35]!==l||t[36]!==x?(z=(0,$.jsxs)(Ke,{onClick:x,children:[R,l]}),t[35]=l,t[36]=x,t[37]=z):z=t[37];let B;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(We,{}),t[38]=B):B=t[38];let V;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(Z,{name:`delete-bin`,className:`size-4`}),t[39]=V):V=t[39];let H;t[40]!==u||t[41]!==C?(H=(0,$.jsxs)(Ke,{onClick:C,className:`text-[var(--status-error)] focus:text-[var(--status-error)] data-[highlighted]:text-[var(--status-error)] [&_svg]:text-[var(--status-error)]`,children:[V,u]}),t[40]=u,t[41]=C,t[42]=H):H=t[42];let U;t[43]!==z||t[44]!==H?(U=(0,$.jsxs)(Ge,{className:`min-w-[10rem]`,children:[z,B,H]}),t[43]=z,t[44]=H,t[45]=U):U=t[45];let ee;return t[46]!==g||t[47]!==L||t[48]!==U?(ee=(0,$.jsxs)(qe,{open:g,onOpenChange:_,children:[L,U]}),t[46]=g,t[47]=L,t[48]=U,t[49]=ee):ee=t[49],ee},Dn=e=>{let t=(0,Ze.c)(118),{activeOverride:i,onMobileBack:a,onMobileOpenSettings:o}=e,{t:s}=A(),{isMobile:c}=he(),l=_e(),u=Q.useSyncExternalStore(n,r,r),d=y(On),f=i??d,p=y(kn),m=c||p,h=z(),g=re(),_=g.data;_?.assistants;let v;t[0]===_?.assistants?v=t[1]:(v=_?.assistants??[],t[0]=_?.assistants,t[1]=v);let b;t[2]===v?b=t[3]:(b=Qe(v),t[2]=v,t[3]=b);let x=b,S;t[4]===u?S=t[5]:(S=e=>e.assistantByTransport[u]??null,t[4]=u,t[5]=S);let C=K(S),w=K(An),T=K(jn),E;t[6]!==C||t[7]!==_?.assistants?(E=_?.assistants.find(e=>e.id===C)??null,t[6]=C,t[7]=_?.assistants,t[8]=E):E=t[8];let D=E,k;t[9]!==w||t[10]!==C||t[11]!==_?(k=()=>{!C&&_?.assistants[0]&&w(_.assistants[0].id)},t[9]=w,t[10]=C,t[11]=_,t[12]=k):k=t[12];let P=_?.assistants,F;t[13]!==w||t[14]!==C||t[15]!==P?(F=[w,C,P],t[13]=w,t[14]=C,t[15]=P,t[16]=F):F=t[16],Q.useEffect(k,F);let I;t[17]!==D||t[18]!==w||t[19]!==C||t[20]!==_?.assistants||t[21]!==g.isSuccess?(I=()=>{g.isSuccess&&C&&!D&&w(_?.assistants[0]?.id??null)},t[17]=D,t[18]=w,t[19]=C,t[20]=_?.assistants,t[21]=g.isSuccess,t[22]=I):I=t[22];let L=_?.assistants,R;t[23]!==D||t[24]!==w||t[25]!==C||t[26]!==g.isSuccess||t[27]!==L?(R=[D,w,C,L,g.isSuccess],t[23]=D,t[24]=w,t[25]=C,t[26]=g.isSuccess,t[27]=L,t[28]=R):R=t[28],Q.useEffect(I,R);let B;t[29]!==l||t[30]!==T?(B=()=>{if(T(),l){l.openSettings();return}let e=y.getState();e.setSettingsPage(`assistants`),e.setSettingsDialogOpen(!0)},t[29]=l,t[30]=T,t[31]=B):B=t[31];let V=O(B),H;t[32]===l?H=t[33]:(H=e=>{ue(e,l?{openMobileSettings:l.openSettings}:void 0)},t[32]=l,t[33]=H);let U=O(H),ee;t[34]!==D||t[35]!==l?(ee=()=>{D&&ue(D.id,l?{openMobileSettings:l.openSettings}:void 0)},t[34]=D,t[35]=l,t[36]=ee):ee=t[36];let te=O(ee),[W,ne]=Q.useState(null),ie;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>{ne(e)},t[37]=ie):ie=t[37];let ae=O(ie),oe;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>{e||ne(null)},t[38]=oe):oe=t[38];let se=O(oe),ce=O(Mn),le;t[39]!==a||t[40]!==ce?(le=()=>{if(a){a();return}ce()},t[39]=a,t[40]=ce,t[41]=le):le=t[41];let G=O(le),q=Cn({capabilityPending:h.isPending,snapshotPending:g.isPending,capabilityError:h.isError,supported:h.data?.supported,capabilityEnabled:h.data?.enabled,snapshotEnabled:_?.enabled,snapshotSettled:g.isSuccess,assistantCount:_?.assistants.length??0,hasAssistant:!!D}),de;t[42]!==D||t[43]!==G||t[44]!==m||t[45]!==o?(de=(e,t,n,r)=>(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[m?(0,$.jsx)(Tn,{assistant:D,onBack:G,onOpenSettings:o}):null,(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 pt-[calc(max(0.25rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height,3.5rem))] text-center`,children:[(0,$.jsx)(Z,{name:e,className:`size-6 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`mt-4 typography-ui-header font-semibold`,children:t}),n?(0,$.jsx)(`p`,{className:`mt-2 max-w-md typography-ui text-muted-foreground`,children:n}):null,r?(0,$.jsx)(`div`,{className:`mt-5`,children:r}):null]})]}),t[42]=D,t[43]=G,t[44]=m,t[45]=o,t[46]=de):de=t[46];let J=de;if(q===`loading`){let e;t[47]!==D||t[48]!==G||t[49]!==m||t[50]!==o?(e=m?(0,$.jsx)(Tn,{assistant:D,onBack:G,onOpenSettings:o}):null,t[47]=D,t[48]=G,t[49]=m,t[50]=o,t[51]=e):e=t[51];let n;t[52]===s?n=t[53]:(n=s(`common.loading`),t[52]=s,t[53]=n);let r;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Z,{name:`loader-4`,className:`size-6 animate-spin text-muted-foreground`}),t[54]=r):r=t[54];let i;t[55]===n?i=t[56]:(i=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 pt-[calc(max(0.25rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height,3.5rem))] text-center`,"aria-busy":`true`,"aria-label":n,"data-assistant-workspace-loading":``,children:r}),t[55]=n,t[56]=i);let a;return t[57]!==e||t[58]!==i?(a=(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[e,i]}),t[57]=e,t[58]=i,t[59]=a):a=t[59],a}if(q===`unavailable`){let e;return t[60]!==J||t[61]!==s?(e=J(`cloud-off`,s(`assistants.state.unavailable`)),t[60]=J,t[61]=s,t[62]=e):e=t[62],e}if(q===`onboarding`){let e;if(t[63]!==V||t[64]!==J||t[65]!==s){let n=s(`assistants.onboarding.title`),r=s(`assistants.onboarding.description`),i;t[67]===s?i=t[68]:(i=s(`assistants.onboarding.action`),t[67]=s,t[68]=i);let a;t[69]!==V||t[70]!==i?(a=(0,$.jsx)(M,{onClick:V,children:i}),t[69]=V,t[70]=i,t[71]=a):a=t[71],e=J(`ai-agent`,n,r,a),t[63]=V,t[64]=J,t[65]=s,t[66]=e}else e=t[66];return e}if(!_||!D){let e;return t[72]!==J||t[73]!==s?(e=J(`cloud-off`,s(`assistants.state.unavailable`)),t[72]=J,t[73]=s,t[74]=e):e=t[74],e}let Y;t[75]===D.name?Y=t[76]:(Y=N(D.name),t[75]=D.name,t[76]=Y);let X=Y,fe;t[77]!==D.enabled||t[78]!==g.isError||t[79]!==s?(fe=D.enabled?g.isError?s(`assistants.state.staleSnapshot`):null:s(`assistants.state.assistantDisabled`),t[77]=D.enabled,t[78]=g.isError,t[79]=s,t[80]=fe):fe=t[80];let pe=fe,me;t[81]!==x||t[82]!==m||t[83]!==V||t[84]!==U||t[85]!==ae||t[86]!==w||t[87]!==C||t[88]!==_||t[89]!==s?(me=m?null:(0,$.jsxs)(`section`,{className:`flex h-full min-h-0 w-[clamp(16rem,22vw,20rem)] shrink-0 flex-col overflow-hidden`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 px-4 pb-3 pt-4 sm:px-5`,children:[(0,$.jsx)(`h1`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:s(`assistants.title`)}),(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`assistants.settings.create`),onClick:V,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})})]}),(0,$.jsx)($e,{snapshot:_,rowClassName:`flex justify-end px-4 pb-2 sm:px-5`}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-4 sm:px-4`,role:`listbox`,"aria-label":s(`assistants.listAria`),children:(0,$.jsx)(`div`,{className:`flex flex-col gap-1 border-t border-border/40 pt-3`,children:x.map(e=>{let t=e.id===C,n=N(e.name);return(0,$.jsx)(En,{assistantID:e.id,unreadCount:e.unreadCount??0,summary:Sn(e.latestMessagePreview,s),displayName:n.displayName,avatarEmoji:n.avatarEmoji??void 0,selected:t,enabled:e.enabled,editLabel:s(`assistants.menu.edit`),deleteLabel:s(`assistants.settings.delete`),assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onSelect:()=>w(e.id),onEdit:()=>U(e.id),onDelete:()=>ae(e)},e.id)})})})]}),t[81]=x,t[82]=m,t[83]=V,t[84]=U,t[85]=ae,t[86]=w,t[87]=C,t[88]=_,t[89]=s,t[90]=me):me=t[90];let ge=W!==null,ve;t[91]!==W||t[92]!==se||t[93]!==ge?(ve=(0,$.jsx)(yn,{assistant:W,open:ge,onOpenChange:se}),t[91]=W,t[92]=se,t[93]=ge,t[94]=ve):ve=t[94];let ye=!m&&`border-l border-[var(--surface-subtle)]`,be;t[95]===ye?be=t[96]:(be=j(`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background`,ye),t[95]=ye,t[96]=be);let xe;t[97]!==D||t[98]!==G||t[99]!==m||t[100]!==o||t[101]!==te||t[102]!==X||t[103]!==s?(xe=m?(0,$.jsx)(Tn,{assistant:D,onBack:G,onOpenSettings:o}):(0,$.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center gap-3.5 border-b border-[var(--surface-subtle)]/70 px-5 sm:px-7`,children:[(0,$.jsx)(et,{name:D.id,emoji:X.avatarEmoji,size:30,label:X.displayName||D.name}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate typography-ui-label font-semibold tracking-[-0.01em] text-foreground`,children:X.displayName}),(0,$.jsx)(`div`,{className:`mt-1 truncate typography-micro leading-none text-muted-foreground/55`,children:s(`assistants.conversation.contactHint`)})]}),(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0 rounded-full text-muted-foreground/65 transition-colors hover:text-foreground`,onClick:te,"aria-label":s(`assistants.conversation.openSettings`),children:(0,$.jsx)(Z,{name:`settings-3`,className:`size-4`})})]}),t[97]=D,t[98]=G,t[99]=m,t[100]=o,t[101]=te,t[102]=X,t[103]=s,t[104]=xe):xe=t[104];let Se;t[105]!==f||t[106]!==D||t[107]!==m||t[108]!==pe?(Se=(0,$.jsx)(_n,{assistant:D,warning:pe,active:f,overlayHeader:m}),t[105]=f,t[106]=D,t[107]=m,t[108]=pe,t[109]=Se):Se=t[109];let Ce;t[110]!==be||t[111]!==xe||t[112]!==Se?(Ce=(0,$.jsxs)(`div`,{className:be,children:[xe,Se]}),t[110]=be,t[111]=xe,t[112]=Se,t[113]=Ce):Ce=t[113];let we;return t[114]!==me||t[115]!==ve||t[116]!==Ce?(we=(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 overflow-hidden bg-background`,"data-presentation":`workspace`,children:[me,ve,Ce]}),t[114]=me,t[115]=ve,t[116]=Ce,t[117]=we):we=t[117],we};function On(e){return e.activeMainTab===`assistant`}function kn(e){return e.isMobile}function An(e){return e.selectAssistant}function jn(e){return e.requestCreate}function Mn(){y.getState().setActiveMainTab(`chat`)}export{yn as a,$e as c,Sn as i,Qe as l,wn as n,rt as o,bn as r,et as s,Dn as t};