@runfusion/fusion 0.17.1 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +1706 -787
- package/dist/client/assets/{AgentDetailView-BmxnuM0D.js → AgentDetailView-17J-F0Rl.js} +1 -1
- package/dist/client/assets/{AgentsView-1xSqjJxs.js → AgentsView-sbBkb7Wd.js} +3 -3
- package/dist/client/assets/ChatView-BR5cvK_B.js +1 -0
- package/dist/client/assets/{DevServerView-DIrmWI5T.js → DevServerView-GFFVXHVP.js} +1 -1
- package/dist/client/assets/{DirectoryPicker-Sqwdifcb.js → DirectoryPicker-WPDSBdT6.js} +1 -1
- package/dist/client/assets/{DocumentsView-Cx_02o_z.js → DocumentsView-BHpDsIIt.js} +1 -1
- package/dist/client/assets/{InsightsView-DAJSq4gV.js → InsightsView-Bxu0TJkt.js} +1 -1
- package/dist/client/assets/{MemoryView-CCIBAre3.js → MemoryView-CmnzZorw.js} +1 -1
- package/dist/client/assets/{NodesView-D02HxGCl.js → NodesView-CO9_4hCr.js} +1 -1
- package/dist/client/assets/{PiExtensionsManager-DD0fTQNf.js → PiExtensionsManager-4e3MlD62.js} +2 -2
- package/dist/client/assets/{PluginManager-Cfl0VBX9.js → PluginManager-DGN2rvOY.js} +1 -1
- package/dist/client/assets/{ResearchView-B9RqOVbr.js → ResearchView-Dsa6Gykl.js} +1 -1
- package/dist/client/assets/{RoadmapsView-DsH7Hicx.js → RoadmapsView-jHTOK0RQ.js} +1 -1
- package/dist/client/assets/{SettingsModal-Cn_CIPXu.js → SettingsModal-4Z8ZJMzD.js} +1 -1
- package/dist/client/assets/SettingsModal-D0kuJpBA.js +31 -0
- package/dist/client/assets/{SetupWizardModal-k5vqrHZU.js → SetupWizardModal-Bhumd4Rf.js} +1 -1
- package/dist/client/assets/{SkillsView-BIdt5cfB.js → SkillsView-MHweJTz4.js} +1 -1
- package/dist/client/assets/{folder-open-B3TO7t7Z.js → folder-open-BNQW9dE9.js} +1 -1
- package/dist/client/assets/{index-BIJgrHEn.css → index-DEVBHvyW.css} +1 -1
- package/dist/client/assets/index-k_85J1DS.js +682 -0
- package/dist/client/assets/{star-DW-M-BD_.js → star-7L86NZrT.js} +1 -1
- package/dist/client/assets/{upload-BzG6fknr.js → upload-DsAS6tno.js} +1 -1
- package/dist/client/assets/{users-DEicv0kj.js → users-D3u6f2Rz.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/client/version.json +1 -1
- package/dist/extension.js +1215 -524
- package/dist/pi-claude-cli/package.json +1 -1
- package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
- package/package.json +1 -1
- package/dist/client/assets/ChatView-CkWkEwXL.js +0 -1
- package/dist/client/assets/SettingsModal-YH_rM1ZT.js +0 -31
- package/dist/client/assets/index-BlkXZ4C5.js +0 -682
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fusion/pi-claude-cli",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.2",
|
|
4
4
|
"description": "Fusion vendored fork: pi coding-agent extension that routes LLM calls through the Claude Code CLI. Forked from rchern/pi-claude-cli (MIT). See UPSTREAM.md.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runfusion/fusion",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Fusion CLI: HTTP API server, daemon, dashboard launcher, and task tooling for the Fusion AI coding agent.",
|
|
6
6
|
"homepage": "https://github.com/Runfusion/Fusion#readme",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s,j as t}from"./vendor-react-K0fH_qHe.js";import{i as et,aT as Ht,y as Bt,aU as Gt,D as Vt,aV as Kt,aW as qt,aX as Xt,aY as Yt,aZ as Jt,a_ as Qt,s as Zt,a$ as es,w as ts,b0 as ss,u as ns,b1 as as,ae as pt,af as xt,S as is,_ as ot,O as Qe,ar as rs,a0 as ls,B as We,ab as vt,ac as wt,b2 as os,b3 as cs,b4 as ds,aK as us,b5 as hs,b6 as ms,b7 as ct,b8 as fs,h as gs,j as dt,l as ps}from"./index-BlkXZ4C5.js";import"./vendor-xterm-DzcZoU0P.js";const Ze="kb-chat-active-session";function xs(a){const i=a?.toolCalls;if(!Array.isArray(i))return;const r=i.map(o=>{if(!o||typeof o!="object")return null;const c=o,j=typeof c.toolName=="string"?c.toolName:"";if(!j)return null;const k=c.args;return{toolName:j,...k&&typeof k=="object"?{args:k}:{},isError:!!c.isError,result:c.result,status:"completed"}}).filter(o=>o!==null);return r.length>0?r:void 0}function ut(a){return{id:a.id,sessionId:a.sessionId,role:a.role,content:a.content,thinkingOutput:a.thinkingOutput,toolCalls:xs(a.metadata),attachments:a.attachments,createdAt:a.createdAt}}function vs(a){const[i,r]=s.useState([]),[o,c]=s.useState(null),[j,k]=s.useState(!0),[D,b]=s.useState([]),[P,U]=s.useState(!1),[g,$]=s.useState(!1),[A,C]=s.useState(""),[f,v]=s.useState(""),[M,S]=s.useState([]),[K,F]=s.useState(""),[se,q]=s.useState(""),[_,Y]=s.useState(!0),[m,T]=s.useState(new Map),w=s.useRef(null),L=s.useRef(!1),W=s.useRef(""),le=s.useRef(null),he=s.useRef(i),oe=s.useRef(o),ce=s.useRef(g);he.current=i,oe.current=o,ce.current=g,s.useEffect(()=>{W.current=K},[K]);const Ne=s.useRef(new Set),de=s.useRef(0),je=s.useRef(a);je.current!==a&&(je.current=a,de.current++),s.useEffect(()=>{const u=de.current;et(void 0,a).then(p=>{if(de.current!==u)return;const h=new Map;for(const y of p)h.set(y.id,y);T(h)}).catch(()=>{})},[a]);const ge=s.useCallback(async()=>{k(!0);try{const p=[...(await Ht(a)).sessions].sort((h,y)=>new Date(y.updatedAt).getTime()-new Date(h.updatedAt).getTime());r(p)}catch{}finally{k(!1)}},[a]);s.useEffect(()=>{ge()},[ge]);const Ce=s.useRef(()=>{});s.useEffect(()=>{if(j)return;const u=Bt(Ze,a);u&&i.find(h=>h.id===u)&&Ce.current(u)},[j,i,a]);const J=s.useCallback(async(u,p)=>{U(!0);try{const h=await Gt(u,{limit:50,...p},a),y=h.messages.map(ut);p?.offset&&p.offset>0?b(Z=>[...y,...Z]):b(y),Y(h.messages.length>=50)}catch{}finally{U(!1)}},[a]),Q=s.useCallback(()=>{le.current?.(),le.current=null,W.current="",F(""),C(""),v(""),S([]),$(!1)},[]),me=s.useCallback((u,p)=>{w.current&&(w.current.close(),w.current=null);const h=p??i.find(y=>y.id===u);c(h||null),Q(),Y(!0),u?J(u):b([]),h?.isGenerating&&($(!0),C("")),u?Vt(Ze,u,a):Kt(Ze,a)},[i,J,a,Q]);Ce.current=me;const ve=s.useCallback(async u=>{const p=await qt(u,a);w.current&&(w.current.close(),w.current=null);const h={id:p.session.id,title:p.session.title,agentId:p.session.agentId,status:p.session.status,modelProvider:p.session.modelProvider,modelId:p.session.modelId,createdAt:p.session.createdAt,updatedAt:p.session.updatedAt};return r(y=>y.some(Z=>Z.id===h.id)?y:[h,...y]),Q(),me(h.id,h),b([]),h},[a,Q,me]),we=s.useCallback(async u=>{await Xt(u,{status:"archived"},a),r(p=>p.filter(h=>h.id!==u)),o?.id===u&&(c(null),b([]))},[o,a]),pe=s.useCallback(async u=>{o?.id===u&&w.current&&(w.current.close(),w.current=null),await Yt(u,a),r(p=>p.filter(h=>h.id!==u)),o?.id===u&&(c(null),b([]))},[o,a]),be=s.useCallback(async()=>{!o||!_||await J(o.id,{offset:D.length})},[o,_,J,D.length]),fe=s.useCallback(()=>{o&&(L.current=!0,le.current?.(),le.current=null,w.current?.close(),w.current=null,Jt(o.id,a).catch(()=>{}),$(!1),C(""),v(""),S([]))},[o,a]),ne=s.useCallback(()=>{W.current="",F("")},[]),ae=s.useCallback((u,p)=>{if(!o)return;if(g){W.current=u,F(u);return}L.current=!1,w.current&&(w.current.close(),w.current=null);const h=`temp-${Date.now()}`,y={id:h,sessionId:o.id,role:"user",content:u,createdAt:new Date().toISOString()};b(x=>[...x,y]),C(""),v(""),S([]),$(!0);let Z="",X="",H=[],ie=null,ee=null;const z=()=>{ie=null,C(Z)},I=()=>{ee=null,v(X)},N=()=>{ie!==null&&(cancelAnimationFrame(ie),ie=null),ee!==null&&(cancelAnimationFrame(ee),ee=null)};le.current=N;const d={onThinking:x=>{X+=x,ee===null&&(ee=requestAnimationFrame(I))},onText:x=>{Z+=x,ie===null&&(ie=requestAnimationFrame(z))},onToolStart:x=>{H=[...H,{toolName:x.toolName,args:x.args,isError:!1,status:"running"}],S(H)},onToolEnd:x=>{const O=[...H];for(let E=O.length-1;E>=0;E--){const ue=O[E];if(ue?.toolName===x.toolName&&ue.status==="running"){O[E]={...ue,status:"completed",isError:x.isError,result:x.result},H=O,S(O);return}}H=[...O,{toolName:x.toolName,isError:x.isError,result:x.result,status:"completed"}],S(H)},onDone:x=>{N();const O={id:x.messageId||`msg-${Date.now()}`,sessionId:o.id,role:"assistant",content:Z,thinkingOutput:X,toolCalls:H.length>0?H:void 0,createdAt:new Date().toISOString()};Ne.current.add(O.id),b(ue=>[...ue,O]),C(""),v(""),S([]),$(!1),w.current=null,setTimeout(()=>{Ne.current.delete(O.id)},1e3),ge();const E=W.current.trim();E&&(W.current="",F(""),ae(E))},onError:x=>{if(N(),b(O=>O.filter(E=>E.id!==h)),C(""),v(""),S([]),$(!1),w.current=null,console.error("[useChat] Stream error:",x),!L.current){const O=W.current.trim();O&&(W.current="",F(""),ae(O))}}};w.current=Qt(o.id,u,d,p,a)},[o,g,a,ge]),Me=se?i.filter(u=>u.title?.toLowerCase().includes(se.toLowerCase())||u.agentId.toLowerCase().includes(se.toLowerCase())):i;return s.useEffect(()=>{const u=de.current,p=a?`?projectId=${encodeURIComponent(a)}`:"",h=()=>de.current!==u,y=z=>{if(h())return;const I=JSON.parse(z.data);r(N=>N.some(d=>d.id===I.id)?N:[I,...N])},Z=z=>{if(h())return;const I=JSON.parse(z.data);r(N=>[...N.map(x=>x.id===I.id?I:x)]),oe.current?.id===I.id&&c(I)},X=z=>{if(h())return;const{id:I}=JSON.parse(z.data);r(N=>N.filter(d=>d.id!==I)),oe.current?.id===I&&(c(null),b([]))},H=z=>{if(h())return;const I=JSON.parse(z.data),N=ut(I);if(!Ne.current.has(N.id)){if(oe.current?.id===N.sessionId&&ce.current&&!w.current&&N.role==="assistant"){b(d=>d.some(x=>x.id===N.id)?d:[...d,N]),C(""),v(""),S([]),$(!1);return}oe.current?.id===N.sessionId&&!ce.current&&b(d=>d.some(x=>x.id===N.id)?d:[...d,N])}},ie=z=>{if(h())return;const{id:I}=JSON.parse(z.data);b(N=>N.filter(d=>d.id!==I))};return Zt(`/api/events${p}`,{events:{"chat:session:created":y,"chat:session:updated":Z,"chat:session:deleted":X,"chat:message:added":H,"chat:message:deleted":ie}})},[a]),s.useEffect(()=>()=>{w.current&&(w.current.close(),w.current=null)},[]),{sessions:i,activeSession:o,sessionsLoading:j,messages:D,messagesLoading:P,isStreaming:g,streamingText:A,streamingThinking:f,streamingToolCalls:M,pendingMessage:K,selectSession:me,createSession:ve,archiveSession:we,deleteSession:pe,sendMessage:ae,stopStreaming:fe,clearPendingMessage:ne,loadMoreMessages:be,hasMoreMessages:_,searchQuery:se,setSearchQuery:q,filteredSessions:Me,refreshSessions:ge,agentsMap:m}}function bt(a){const i=new Date(a),o=new Date().getTime()-i.getTime(),c=Math.floor(o/1e3),j=Math.floor(c/60),k=Math.floor(j/60),D=Math.floor(k/24);return c<60?"just now":j<60?`${j}m ago`:k<24?`${k}h ago`:D<7?`${D}d ago`:i.toLocaleDateString()}function ht(a,i){if(!a||!i)return null;const r=i.toLowerCase();if(r.includes("claude")){let c=i.replace(/^claude[- ]/i,"Claude ").replace(/sonnet[- ](\d+)[- ](\d+)/i,"Sonnet $1.$2").replace(/sonnet[- ](\d+)/i,"Sonnet $1").replace(/haiku[- ](\d+)/i,"Haiku $1").replace(/opus[- ](\d+)/i,"Opus $1").replace(/sonnet/i,"Sonnet").replace(/haiku/i,"Haiku").replace(/opus/i,"Opus").replace(/-/g," ").trim();return c=c.replace(/\s+/g," "),c.length>30?c.slice(0,30)+"…":c}if(r.includes("gpt")||r.includes("openai")){const c=i.replace(/^gpt-4-turbo$/i,"GPT-4 Turbo").replace(/^gpt-4o-mini$/i,"GPT-4o Mini").replace(/^gpt-4o$/i,"GPT-4o").replace(/^gpt-4$/i,"GPT-4").replace(/^gpt-o1-preview$/i,"GPT-o1 Preview").replace(/^gpt-o1-mini$/i,"GPT-o1 Mini").replace(/^gpt-o1$/i,"GPT-o1").replace(/^gpt/i,"GPT").trim();return c.length>30?c.slice(0,30)+"…":c}if(r.includes("gemini")){const c=i.replace(/^gemini[- ]/i,"Gemini ").replace(/pro[- ](\d+)[- ](\d+)/i,"Pro $1.$2").replace(/pro[- ](\d+)/i,"Pro $1").replace(/-/g," ").replace(/\s+/g," ").trim();return c.length>30?c.slice(0,30)+"…":c}const o=i.replace(/-/g," ").replace(/^\w/,c=>c.toUpperCase()).replace(/\s+/g," ").trim();return o.length>30?o.slice(0,30)+"…":o}function Oe(a,i){return a.length<=i?a:`${a.slice(0,i)}…`}function ws(a){if(!a)return null;const i=Object.entries(a);return i.length===0?null:i.map(([r,o])=>{const c=typeof o=="string"?o:(()=>{try{return JSON.stringify(o)}catch{return String(o)}})();return`${r}=${Oe(c,50)}`}).join(", ")}function bs(a){if(a===void 0)return null;if(typeof a=="string")return Oe(a,200);try{return Oe(JSON.stringify(a),200)}catch{return Oe(String(a),200)}}function St(a){if(!a||a.length===0)return null;const i=(g,$)=>{const A=g.status==="running",C=g.status==="completed"&&g.isError,f=ws(g.args),v=bs(g.result),M=A?f:v?`result: ${v}`:f?`args: ${f}`:null,S=A?"running":C?"error":"completed";return t.jsxs("details",{className:`chat-tool-call${A?" chat-tool-call--running":""}${C?" chat-tool-call--error":""}`,open:A,children:[t.jsxs("summary",{children:[t.jsx("span",{className:"chat-tool-call-status-dot","aria-hidden":"true"}),t.jsx("span",{className:"chat-tool-call-name",children:g.toolName}),M&&t.jsx("span",{className:"chat-tool-call-preview",title:M,children:M}),t.jsx("span",{className:"chat-tool-call-status-text",children:S})]}),t.jsxs("div",{className:"chat-tool-call-content",children:[f&&t.jsxs("div",{className:"chat-tool-call-row",children:[t.jsx("span",{className:"chat-tool-call-label",children:"args"}),t.jsx("span",{className:"chat-tool-call-value",children:f})]}),v&&t.jsxs("div",{className:`chat-tool-call-row${C?" chat-tool-call-row--error":""}`,children:[t.jsx("span",{className:"chat-tool-call-label",children:"result"}),t.jsx("span",{className:"chat-tool-call-value",children:v})]})]})]},`${g.toolName}-${$}`)},r="chat-tool-calls";if(a.length===1)return t.jsxs("div",{className:r,"data-testid":"chat-tool-calls",children:[t.jsxs("div",{className:"chat-tool-calls-header",children:[t.jsx(ct,{size:12,"aria-hidden":"true"}),t.jsx("span",{children:"Tool calls"})]}),i(a[0],0)]});const o=a.filter(g=>g.status==="running").length,c=a.filter(g=>g.status==="completed"&&g.isError).length,j=o>0,k=Array.from(new Set(a.map(g=>g.toolName))),D=k.slice(0,5),b=Math.max(0,k.length-D.length),P=b>0?`${D.join(", ")}, +${b} more`:D.join(", "),U=j?`(${o} running)`:c>0?`(${c} ${c===1?"error":"errors"})`:null;return t.jsx("div",{className:r,"data-testid":"chat-tool-calls",children:t.jsxs("details",{className:"chat-tool-calls-group","data-testid":"chat-tool-calls-group",open:j,children:[t.jsxs("summary",{className:"chat-tool-calls-group-summary",children:[t.jsx(ct,{size:12,"aria-hidden":"true"}),t.jsxs("span",{children:[a.length," tool calls"]}),t.jsx("span",{className:"chat-tool-calls-names",title:P,children:P}),U&&t.jsx("span",{className:"chat-tool-calls-group-status",children:U})]}),a.map((g,$)=>i(g,$))]})})}const kt={pre:({children:a,...i})=>t.jsx("pre",{...i,className:"chat-markdown-pre",children:a}),table:({children:a,...i})=>t.jsx("table",{...i,className:"chat-markdown-table",children:a})},Ue="__fn_agent__",Ss=280,Le=180,ze=500,mt="fusion:chat-sidebar-width",ks=["image/png","image/jpeg","image/gif","image/webp","text/plain","application/json","text/yaml","text/markdown","text/csv","application/xml","text/x-log"];function ft(a){const i=/(^|[\s])\/([^\s]*)$/.exec(a);if(!i)return null;const r=i[1]??"",o=i[2]??"",c=i.index+r.length;return{filter:o,start:c,end:a.length}}function ys(a,i){const r=a.slice(0,i),o=/(^|[\s\n])@([\w-]*)$/.exec(r);if(!o)return null;const c=o[2]??"",j=r.length-c.length-1;return{filter:c,start:j,end:i}}function Ns({projectId:a,onClose:i,onCreate:r}){const[o,c]=s.useState("agent"),[j,k]=s.useState([]),[D,b]=s.useState(!0),[P,U]=s.useState(""),[g,$]=s.useState([]),[A,C]=s.useState(!0),[f,v]=s.useState(""),[M,S]=s.useState([]),[K,F]=s.useState([]);s.useEffect(()=>{let m=!1;return b(!0),et(void 0,a).then(T=>{m||k(T)}).catch(()=>{m||k([])}).finally(()=>{m||b(!1)}),()=>{m=!0}},[a]),s.useEffect(()=>{C(!0),gs().then(m=>{$(m.models),S(m.favoriteProviders),F(m.favoriteModels)}).catch(()=>{$([]),S([]),F([])}).finally(()=>{C(!1)})},[]);const se=s.useCallback(async m=>{const T=M,L=T.includes(m)?T.filter(W=>W!==m):[m,...T];S(L);try{await dt({favoriteProviders:L,favoriteModels:K})}catch{S(T)}},[M,K]),q=s.useCallback(async m=>{const T=K,L=T.includes(m)?T.filter(W=>W!==m):[m,...T];F(L);try{await dt({favoriteProviders:M,favoriteModels:L})}catch{F(T)}},[K,M]),_=m=>{if(m.preventDefault(),o==="agent"){if(!P)return;r({agentId:P});return}if(!f)return;const T=f.indexOf("/");if(T<=0)return;const w=f.slice(0,T),L=f.slice(T+1);r({agentId:Ue,modelProvider:w,modelId:L})},Y=o==="agent"?!P:!f;return t.jsx("div",{className:"chat-new-dialog-backdrop chat-view-dialog-backdrop",onClick:i,role:"dialog","aria-modal":"true",children:t.jsxs("div",{className:"chat-new-dialog chat-view-dialog",onClick:m=>m.stopPropagation(),children:[t.jsx("h3",{children:"New Chat"}),t.jsxs("div",{className:"chat-new-dialog-mode-toggle","data-testid":"chat-new-dialog-mode-toggle",children:[t.jsx("button",{type:"button",className:`chat-new-dialog-mode-btn${o==="agent"?" chat-new-dialog-mode-btn--active":""}`,"data-testid":"chat-new-dialog-mode-agent",onClick:()=>{c("agent"),v("")},children:"Agent"}),t.jsx("button",{type:"button",className:`chat-new-dialog-mode-btn${o==="model"?" chat-new-dialog-mode-btn--active":""}`,"data-testid":"chat-new-dialog-mode-model",onClick:()=>{c("model"),U("")},children:"Model"})]}),t.jsxs("form",{onSubmit:_,children:[o==="agent"&&t.jsxs("label",{className:"chat-new-dialog-model-label",children:["Agent",D?t.jsx("div",{className:"chat-new-dialog-loading",children:"Loading agents..."}):j.length===0?t.jsx("div",{className:"chat-new-dialog-empty",children:"No agents available"}):t.jsx("div",{className:"chat-new-dialog-agent-list",children:j.map(m=>t.jsxs("button",{type:"button",className:`chat-new-dialog-agent-item${P===m.id?" chat-new-dialog-agent-item--selected":""}`,onClick:()=>U(m.id),"data-testid":`agent-option-${m.id}`,children:[t.jsx(We,{size:16}),t.jsx("span",{className:"chat-new-dialog-agent-name",children:m.name}),t.jsx("span",{className:"chat-new-dialog-agent-role",children:m.role})]},m.id))})]}),o==="model"&&t.jsx("div",{className:"chat-new-dialog-model-dropdown","data-testid":"chat-new-dialog-model-section",children:A?t.jsx("div",{className:"chat-new-dialog-loading",children:"Loading models..."}):t.jsx(ps,{models:g,value:f,onChange:v,label:"Model",placeholder:"Select a model",favoriteProviders:M,onToggleFavorite:se,favoriteModels:K,onToggleModelFavorite:q})}),t.jsxs("div",{className:"chat-new-dialog-actions",children:[t.jsx("button",{type:"button",className:"btn btn-sm",onClick:i,children:"Cancel"}),t.jsx("button",{type:"submit",className:"btn btn-sm btn-primary",disabled:Y,children:"Create"})]})]})]})})}const gt=s.memo(function({message:i,forcePlain:r,agentName:o,showAssistantModelTag:c,activeModelTag:j,activeSessionId:k,mentionAgentsByName:D,onToggleRender:b}){const P=i.role==="assistant",U=s.useMemo(()=>{if(P)return null;const A=i.content,C=/@([\w-]+)/g,f=[];let v=0,M=C.exec(A);for(;M;){const[S,K=""]=M,F=M.index;F>v&&f.push(A.slice(v,F));const se=K.replace(/_/g," ").toLowerCase(),q=D.get(se);q?f.push(t.jsxs("span",{className:"chat-mention-chip",children:["@",q.name.replace(/\s+/g,"_")]},`${q.id}-${F}`)):f.push(S),v=F+S.length,M=C.exec(A)}return v<A.length&&f.push(A.slice(v)),f.length===0?A:f},[P,i.content,D]),g=s.useMemo(()=>{const A=i.attachments;if(!A||A.length===0||!k)return null;const C=`/api/chat/sessions/${encodeURIComponent(k)}/attachments/`;return t.jsx("div",{className:"chat-message-attachments",children:A.map(f=>{const v=f.mimeType.startsWith("image/"),M=f.id||f.filename,S=`${C}${encodeURIComponent(f.filename)}`;return v?t.jsx("a",{className:"chat-message-attachment-link","data-testid":"chat-message-attachment",href:S,target:"_blank",rel:"noopener noreferrer",children:t.jsx("img",{className:"chat-message-attachment",src:S,alt:f.originalName})},M):t.jsxs("a",{className:"chat-message-attachment-file","data-testid":"chat-message-attachment",href:S,target:"_blank",rel:"noopener noreferrer",children:[t.jsx(ms,{size:14}),t.jsx("span",{children:f.originalName})]},M)})})},[i.attachments,k]),$=s.useMemo(()=>P?r?t.jsx("div",{className:"chat-message-content chat-message-content--plain",children:i.content}):t.jsx("div",{className:"chat-message-content chat-message-content--markdown",children:t.jsx(pt,{remarkPlugins:[xt],components:kt,children:i.content})}):null,[P,r,i.content]);return t.jsxs("div",{className:`chat-message chat-message--${i.role}`,"data-testid":`chat-message-${i.id}`,children:[P&&t.jsxs("div",{className:"chat-message-avatar",children:[t.jsx(We,{size:14}),t.jsx("span",{children:o}),c&&j&&t.jsx("span",{className:"chat-model-tag",children:j}),t.jsx("button",{type:"button",className:`chat-message-render-toggle${r?" chat-message-render-toggle--plain":""}`,"data-testid":"chat-message-render-toggle","aria-label":r?"Show rendered markdown":"Show plain text",onClick:()=>b(i.id),children:r?t.jsx(vt,{size:14}):t.jsx(wt,{size:14})})]}),P?$:t.jsx("div",{className:"chat-message-content",children:U}),St(i.toolCalls),i.thinkingOutput&&t.jsxs("details",{className:"chat-message-thinking",children:[t.jsx("summary",{children:"Thinking"}),t.jsx("pre",{className:"chat-message-thinking-content",children:i.thinkingOutput})]}),g,t.jsx("div",{className:"chat-message-time",children:bt(i.createdAt)})]})});function As({projectId:a,addToast:i}){const{activeSession:r,sessionsLoading:o,messages:c,messagesLoading:j,isStreaming:k,streamingText:D,streamingThinking:b,streamingToolCalls:P,selectSession:U,createSession:g,archiveSession:$,deleteSession:A,sendMessage:C,stopStreaming:f,pendingMessage:v,clearPendingMessage:M,searchQuery:S,setSearchQuery:K,filteredSessions:F}=vs(a),[se,q]=s.useState(!1),[_,Y]=s.useState(""),[m,T]=s.useState(null),[w,L]=s.useState(null),[W,le]=s.useState(!0),[he,oe]=s.useState(Ss),[ce,Ne]=s.useState(new Map),[de,je]=s.useState([]),[ge,Ce]=s.useState(!0),[J,Q]=s.useState(!1),[me,ve]=s.useState(""),[we,pe]=s.useState(0),[be,fe]=s.useState(""),[ne,ae]=s.useState(!1),[Me,u]=s.useState(0),[p,h]=s.useState(-1),[y,Z]=s.useState(()=>new Set),[X,H]=s.useState([]),[ie,ee]=s.useState(!1),[,z]=s.useState(!1),[I,N]=s.useState({top:0,left:0}),d=es({projectId:a}),x=s.useCallback(e=>{if(!e||!d.mentionActive)return;const n=e.getBoundingClientRect();N({top:n.top-260,left:n.left+8})},[d.mentionActive]),O=s.useRef(null),E=s.useRef(null),ue=s.useRef(null),B=s.useRef(null),$e=s.useRef(!1),Ee=s.useRef(!1),tt=s.useRef(null),st=s.useRef([]),Te=s.useRef(0),G=ts()==="mobile";s.useEffect(()=>{try{const e=localStorage.getItem(mt);if(!e)return;const n=Number.parseInt(e,10);if(Number.isNaN(n))return;const l=Math.max(Le,Math.min(ze,n));oe(l)}catch{}},[]);const{keyboardOverlap:He,viewportHeight:nt,viewportOffsetTop:yt,keyboardOpen:at}=ss({enabled:G&&!!r}),Nt=at?{"--keyboard-overlap":`${He}px`,"--vv-offset-top":`${yt}px`,...nt!==null?{"--vv-height":`${nt}px`}:{}}:{},te=s.useMemo(()=>{const e=me.trim().toLowerCase();return(e?de.filter(l=>l.name.toLowerCase().includes(e)):de).slice(0,10)},[de,me]),Se=s.useMemo(()=>Array.from(ce.values()),[ce]),xe=s.useMemo(()=>{const e=be.trim().toLowerCase();return e?Se.filter(n=>n.name.toLowerCase().includes(e)):Se},[Se,be]),it=s.useMemo(()=>{const e=new Map;for(const n of Se)e.set(n.name.toLowerCase(),n);return e},[Se]);s.useEffect(()=>{pe(0)},[te]),s.useEffect(()=>{u(0)},[be,ne]),s.useEffect(()=>()=>{E.current!==null&&window.clearTimeout(E.current)},[]),s.useEffect(()=>{const e=ue.current;e&&(e.scrollTop=e.scrollHeight)},[c,D,b,k]),s.useEffect(()=>{if(He<=0)return;const e=ue.current;e&&(e.scrollTop=e.scrollHeight)},[He]),ns(G&&at),s.useEffect(()=>{const e=()=>T(null);if(m)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[m]),s.useEffect(()=>{let e=!1;const n=a;return et(void 0,a).then(l=>{if(e||n!==a)return;const R=new Map;for(const V of l)R.set(V.id,V);Ne(R)}).catch(()=>{}),()=>{e=!0}},[a]),s.useEffect(()=>{let e=!1;return Ce(!0),as(a).then(n=>{e||je(n)}).catch(()=>{e||je([])}).finally(()=>{e||Ce(!1)}),()=>{e=!0}},[a]),s.useEffect(()=>{st.current=X},[X]),s.useEffect(()=>()=>{for(const e of st.current)e.previewUrl&&URL.revokeObjectURL(e.previewUrl)},[]);const Pe=s.useCallback(e=>{if(!e||e.length===0)return;const n=[];for(const l of Array.from(e)){if(!ks.includes(l.type))continue;const R=l.type.startsWith("image/");n.push({file:l,previewUrl:R?URL.createObjectURL(l):""})}n.length>0&&H(l=>[...l,...n])},[]),jt=s.useCallback(e=>{H(n=>{const l=n[e];return l?.previewUrl&&URL.revokeObjectURL(l.previewUrl),n.filter((R,V)=>V!==e)})},[]),Ct=s.useCallback(e=>{const n=e.clipboardData?.files;if(!n||n.length===0)return;const l=Array.from(n).filter(R=>R.type.startsWith("image/"));l.length!==0&&Pe(l)},[Pe]),Mt=s.useCallback(async e=>{try{await g(e),q(!1),G&&le(!1)}catch{i("Failed to create chat session","error")}},[g,i,G]),Be=s.useCallback(()=>{Y(""),Q(!1),ve(""),ae(!1),fe(""),h(-1),H(e=>{for(const n of e)n.previewUrl&&URL.revokeObjectURL(n.previewUrl);return[]})},[]),Ae=s.useCallback(()=>{const e=_.trim(),n=X.map(l=>l.file);if(!(!e&&n.length===0||!r)){if(e==="/clear"){Be(),f(),M(),g({agentId:r.agentId,modelProvider:r.modelProvider??void 0,modelId:r.modelId??void 0}).catch(()=>{i("Failed to clear conversation","error")});return}Be(),C(e,n)}},[_,X,r,Be,f,M,g,i,C]),Fe=s.useCallback(()=>{if(typeof window>"u"||window.innerWidth>768)return;const e=B.current;if(!e||e.disabled)return;const n=window.scrollX,l=window.scrollY;e.focus({preventScroll:!0}),window.requestAnimationFrame(()=>{(window.scrollX!==n||window.scrollY!==l)&&window.scrollTo(n,l)})},[]),rt=s.useCallback(()=>{typeof window>"u"||window.innerWidth>768||($e.current=!0)},[]),Ge=s.useCallback(e=>{Y(n=>{const l=ft(n);if(!l)return n;const R=`/skill:${e.name} `,V=n.slice(0,l.start)+R+n.slice(l.end);return window.requestAnimationFrame(()=>{B.current&&(B.current.style.height="auto",B.current.style.height=`${Math.min(B.current.scrollHeight,120)}px`,B.current.focus())}),V}),Q(!1),ve(""),pe(0)},[]),Ve=s.useCallback(e=>{const n=B.current;if(!n||p<0)return;const l=n.selectionStart??Te.current,R=n.selectionEnd??l,V=Math.max(l,R),De=Math.min(p,V),ke=`${`@${e.name.replace(/\s+/g,"_")}`} `,Je=_.slice(0,De)+ke+_.slice(V),ye=De+ke.length;Y(Je),ae(!1),fe(""),u(0),h(-1),window.requestAnimationFrame(()=>{B.current&&(B.current.style.height="auto",B.current.style.height=`${Math.min(B.current.scrollHeight,120)}px`,B.current.focus(),B.current.setSelectionRange(ye,ye))})},[p,_]),Tt=s.useCallback(e=>{if(Te.current=e.currentTarget.selectionStart??Te.current,d.mentionActive&&d.files.length>0){if(d.handleKeyDown(e,_),e.key==="Enter"||e.key==="Tab"){const n=d.files[d.selectedIndex];if(n){const l=d.selectFile(n,_);Y(l),d.dismissMention(),z(!1)}}return}if(ne&&e.key==="ArrowDown"){e.preventDefault(),xe.length>0&&u(n=>(n+1)%xe.length);return}if(ne&&e.key==="ArrowUp"){e.preventDefault(),xe.length>0&&u(n=>n===0?xe.length-1:n-1);return}if(ne&&e.key==="Enter"){e.preventDefault();const n=xe[Me]??xe[0];n&&Ve(n);return}if(ne&&e.key==="Escape"){e.preventDefault(),ae(!1),fe(""),h(-1);return}if(J&&e.key==="ArrowDown"){e.preventDefault(),te.length>0&&pe(n=>(n+1)%te.length);return}if(J&&e.key==="ArrowUp"){e.preventDefault(),te.length>0&&pe(n=>n===0?te.length-1:n-1);return}if(J&&(e.key==="Enter"||e.key==="Tab")&&te.length>0){e.preventDefault();const n=te[we]??te[0];n&&Ge(n);return}if(J&&e.key==="Escape"){e.preventDefault(),Q(!1);return}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),Ae())},[ne,xe,Me,Ve,J,te,we,Ge,Ae,d,_]),Ie=s.useCallback((e,n)=>{const l=ys(e,n);if(l){ae(!0),fe(l.filter),h(l.start);return}ae(!1),fe(""),h(-1)},[]),At=s.useCallback(e=>{const n=e.target,l=n.value,R=n.selectionStart??l.length;Te.current=R,Y(l);const V=ft(l);V?(Q(!0),ve(V.filter)):(Q(!1),ve("")),Ie(l,R),d.detectMention(l,R),z(d.mentionActive),d.mentionActive&&x(n),n.style.height="auto",n.style.height=`${Math.min(n.scrollHeight,120)}px`},[Ie]),Ke=s.useCallback(e=>{const n=e.currentTarget,l=n.selectionStart??n.value.length;Te.current=l,Ie(n.value,l),d.detectMention(n.value,l),z(d.mentionActive),d.mentionActive&&x(n)},[Ie,d,x]),Rt=s.useCallback(e=>{e.key!=="Escape"&&Ke(e)},[Ke]),Dt=s.useCallback(()=>{if($e.current){window.requestAnimationFrame(()=>{Fe()});return}E.current!==null&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{Q(!1),ae(!1),fe(""),h(-1),z(!1),d.dismissMention(),E.current=null},120)},[d,Fe]),$t=s.useCallback(()=>{E.current!==null&&(window.clearTimeout(E.current),E.current=null)},[]),Et=s.useCallback(async e=>{T(null);try{await $(e),i("Conversation archived","success")}catch{i("Failed to archive conversation","error")}},[$,i]),Pt=s.useCallback(async e=>{L(null),T(null);try{await A(e),i("Conversation deleted","success")}catch{i("Failed to delete conversation","error")}},[A,i]),Re=s.useCallback(e=>{try{localStorage.setItem(mt,String(e))}catch{}},[]),Ft=s.useCallback(e=>{if(G)return;e.preventDefault(),e.stopPropagation();const n=e.currentTarget;typeof n.setPointerCapture=="function"&&n.setPointerCapture(e.pointerId);const l=e.clientX,R=he;let V=R;document.body.style.userSelect="none";const De=ke=>{const Je=ke.clientX-l,ye=Math.max(Le,Math.min(ze,R+Je));V=ye,oe(ye),Re(ye)},Ye=ke=>{typeof n.releasePointerCapture=="function"&&n.releasePointerCapture(ke.pointerId),document.body.style.userSelect="",document.removeEventListener("pointermove",De),document.removeEventListener("pointerup",Ye),Re(V)};document.addEventListener("pointermove",De),document.addEventListener("pointerup",Ye)},[G,Re,he]),It=s.useCallback(e=>{if(G||e.key!=="ArrowLeft"&&e.key!=="ArrowRight")return;e.preventDefault();const n=e.shiftKey?50:10,l=e.key==="ArrowLeft"?-n:n,R=Math.max(Le,Math.min(ze,he+l));oe(R),Re(R)},[G,Re,he]),_t=s.useCallback(e=>{U(e),G&&le(!1)},[U,G]),Lt=s.useCallback(()=>{U(""),le(!0)},[U]),zt=()=>t.jsxs("div",{className:"chat-empty-state",children:[t.jsx(fs,{size:48,strokeWidth:1.5}),t.jsx("h2",{children:"Start a new conversation"}),t.jsxs("button",{className:"btn btn-primary",onClick:()=>q(!0),children:[t.jsx(Qe,{size:16}),"New Chat"]})]}),re=ht(r?.modelProvider,r?.modelId),lt=r?.agentId===Ue?re??"Fusion":r?.title||ce.get(r?.agentId??"")?.name||r?.agentId||"Chat",Ot=!!(re&&re!==lt),_e=ce.get(r?.agentId??"")?.name||(r?.agentId===Ue?re??"Fusion":r?.agentId?.slice(0,30)??"Fusion"),qe=!!(re&&re!==_e),Ut=v.length>50?`${v.slice(0,50)}…`:v,Xe=s.useCallback(e=>{Z(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l})},[]),Wt=s.useCallback((e,n=!1)=>n?t.jsx("div",{className:"chat-message-content chat-message-content--plain",children:e}):t.jsx("div",{className:"chat-message-content chat-message-content--markdown",children:t.jsx(pt,{remarkPlugins:[xt],components:kt,children:e})}),[]);return t.jsxs("div",{className:"chat-view",children:[t.jsxs("div",{className:`chat-sidebar${W?"":" chat-sidebar--hidden"}`,style:G?void 0:{width:`${he}px`},children:[t.jsx("div",{className:"chat-sidebar-search",children:t.jsxs("div",{className:"chat-sidebar-search-wrapper",children:[t.jsx(is,{size:14,className:"chat-sidebar-search-icon"}),t.jsx("input",{type:"text",className:"chat-sidebar-search",placeholder:"Search conversations...",value:S,onChange:e=>K(e.target.value),"data-testid":"chat-search-input"})]})}),t.jsx("div",{className:"chat-session-list chat-sidebar-list",children:o?t.jsx("div",{style:{padding:"12px",color:"var(--text-secondary)",fontSize:"13px"},children:"Loading..."}):F.length===0?t.jsx("div",{style:{padding:"12px",color:"var(--text-secondary)",fontSize:"13px"},children:"No conversations yet"}):F.map(e=>t.jsxs("div",{className:`chat-session-item${r?.id===e.id?" chat-session-item--active":""}`,onClick:()=>_t(e.id),onContextMenu:n=>{n.preventDefault(),T({sessionId:e.id,x:n.clientX,y:n.clientY})},"data-testid":`chat-session-${e.id}`,children:[t.jsx("button",{className:"chat-session-delete-btn",onClick:n=>{n.stopPropagation(),L(e.id)},"data-testid":"chat-session-delete-btn","aria-label":"Delete conversation",children:t.jsx(ot,{size:14})}),t.jsx("div",{className:"chat-session-title",children:e.title||"Untitled"}),t.jsx("div",{className:"chat-session-preview",children:e.lastMessagePreview||"No messages"}),t.jsxs("div",{className:"chat-session-meta",children:[t.jsx("span",{children:ce.get(e.agentId)?.name||(e.agentId===Ue?ht(e.modelProvider,e.modelId)??"Fusion":e.agentId.slice(0,30))}),t.jsx("span",{children:e.updatedAt?bt(e.updatedAt):""})]})]},e.id))}),t.jsx("div",{className:"chat-sidebar-footer",children:t.jsxs("button",{className:"btn btn-sm btn-primary chat-sidebar-footer-btn",onClick:()=>q(!0),"data-testid":"chat-new-btn",children:[t.jsx(Qe,{size:14}),"New Chat"]})})]}),!G&&W&&t.jsx("div",{className:"chat-sidebar-resize-handle",role:"separator","aria-orientation":"vertical","aria-valuemin":Le,"aria-valuemax":ze,"aria-valuenow":he,"aria-label":"Resize chat sidebar",tabIndex:0,onPointerDown:Ft,onKeyDown:It}),m&&t.jsxs("div",{className:"chat-session-context-menu",style:{top:m.y,left:m.x},onClick:e=>e.stopPropagation(),children:[t.jsxs("button",{onClick:()=>Et(m.sessionId),"data-testid":"chat-context-archive",children:[t.jsx(rs,{size:14}),"Archive"]}),t.jsxs("button",{onClick:()=>{T(null),L(m.sessionId)},"data-testid":"chat-context-delete",children:[t.jsx(ot,{size:14}),"Delete"]})]}),w&&t.jsx("div",{className:"chat-new-dialog-backdrop chat-view-dialog-backdrop",onClick:()=>L(null),children:t.jsxs("div",{className:"chat-new-dialog chat-view-dialog",onClick:e=>e.stopPropagation(),children:[t.jsx("h3",{children:"Delete Conversation?"}),t.jsx("p",{className:"chat-view-delete-dialog-copy",children:"This action cannot be undone. All messages in this conversation will be permanently deleted."}),t.jsxs("div",{className:"chat-new-dialog-actions",children:[t.jsx("button",{className:"btn btn-sm",onClick:()=>L(null),children:"Cancel"}),t.jsx("button",{className:"btn btn-sm btn-danger",onClick:()=>void Pt(w),children:"Delete"})]})]})}),t.jsxs("div",{className:"chat-thread",style:Nt,children:[(r||!G)&&t.jsxs("div",{className:"chat-thread-header",children:[G&&r&&t.jsx("button",{className:"btn-icon",onClick:Lt,"data-testid":"chat-back-btn",children:t.jsx(ls,{size:16})}),t.jsx(We,{size:16}),t.jsx("span",{className:"chat-thread-header-title",children:lt}),Ot&&t.jsx("span",{className:"chat-model-tag",children:re}),!G&&t.jsxs("button",{className:"btn btn-sm btn-primary chat-thread-header-new-chat",onClick:()=>q(!0),"data-testid":"chat-thread-new-chat-btn",children:[t.jsx(Qe,{size:14}),"New Chat"]})]}),t.jsxs("div",{className:"chat-messages",ref:ue,children:[k?t.jsxs(t.Fragment,{children:[c.map(e=>t.jsx(gt,{message:e,forcePlain:y.has(e.id),agentName:_e,showAssistantModelTag:qe,activeModelTag:re,activeSessionId:r?.id??null,mentionAgentsByName:it,onToggleRender:Xe},e.id)),t.jsxs("div",{className:"chat-message chat-message--assistant chat-message--streaming",children:[t.jsxs("div",{className:"chat-message-avatar",children:[t.jsx(We,{size:14}),t.jsx("span",{children:_e}),qe&&t.jsx("span",{className:"chat-model-tag",children:re}),t.jsx("button",{type:"button",className:`chat-message-render-toggle${y.has("__streaming__")?" chat-message-render-toggle--plain":""}`,"data-testid":"chat-message-render-toggle","aria-label":y.has("__streaming__")?"Show rendered markdown":"Show plain text",onClick:()=>Xe("__streaming__"),children:y.has("__streaming__")?t.jsx(vt,{size:14}):t.jsx(wt,{size:14})})]}),D?Wt(D,y.has("__streaming__")):t.jsx("div",{className:"chat-message-content chat-message-content--waiting",children:b?"Thinking…":"Connecting…"}),St(P),b&&t.jsxs("details",{className:"chat-message-thinking",children:[t.jsx("summary",{children:"Thinking"}),t.jsx("pre",{className:"chat-message-thinking-content",children:b})]}),t.jsxs("div",{className:"chat-typing-indicator",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]})]})]}):j?t.jsx("div",{style:{color:"var(--text-secondary)",fontSize:"13px"},children:"Loading messages..."}):c.length===0&&!r?zt():c.length===0&&r?t.jsx("div",{style:{color:"var(--text-secondary)",fontSize:"13px"},children:"No messages yet. Start the conversation!"}):t.jsx(t.Fragment,{children:c.map(e=>t.jsx(gt,{message:e,forcePlain:y.has(e.id),agentName:_e,showAssistantModelTag:qe,activeModelTag:re,activeSessionId:r?.id??null,mentionAgentsByName:it,onToggleRender:Xe},e.id))}),t.jsx("div",{ref:O})]}),r&&t.jsxs("div",{className:"chat-input-area",children:[t.jsx("input",{ref:tt,type:"file",accept:"image/*,.txt,.json,.yaml,.yml,.log,.csv,.xml,.md",multiple:!0,style:{display:"none"},onChange:e=>{Pe(e.target.files),e.target.value=""}}),J&&t.jsx("div",{className:"chat-skill-menu","data-testid":"chat-skill-menu",role:"listbox","aria-label":"Skill suggestions",children:ge?t.jsx("div",{className:"chat-skill-menu-empty",children:"Loading skills…"}):te.length===0?t.jsx("div",{className:"chat-skill-menu-empty",children:me?"No skills found":"No skills available"}):te.map((e,n)=>t.jsxs("button",{type:"button",role:"option","aria-selected":n===we,className:`chat-skill-menu-item${n===we?" chat-skill-menu-item--highlighted":""}`,onMouseDown:l=>l.preventDefault(),onMouseEnter:()=>pe(n),onClick:()=>Ge(e),children:[t.jsx("span",{className:"chat-skill-menu-item-name",children:e.name}),t.jsx("span",{className:"chat-skill-menu-item-description",title:e.relativePath,children:e.relativePath})]},e.id))}),X.length>0&&t.jsx("div",{className:"chat-attachment-previews","data-testid":"chat-attachment-previews",children:X.map((e,n)=>t.jsxs("div",{className:"chat-attachment-preview","data-testid":`chat-attachment-preview-${n}`,children:[e.previewUrl?t.jsx("img",{src:e.previewUrl,alt:e.file.name}):t.jsx("span",{className:"chat-attachment-preview-name",children:e.file.name}),t.jsx("button",{type:"button",className:"chat-attachment-remove",onClick:()=>jt(n),"data-testid":`chat-attachment-remove-${n}`,"aria-label":`Remove ${e.file.name}`,children:"×"})]},e.previewUrl||`${e.file.name}-${n}`))}),t.jsxs("div",{className:"chat-input-row",children:[t.jsx("button",{type:"button",className:"btn-icon chat-attach-btn","data-testid":"chat-attach-btn","aria-label":"Attach files",onClick:()=>tt.current?.click(),children:t.jsx(os,{size:16})}),t.jsxs("div",{className:`chat-input-wrapper${ie?" chat-input-wrapper--dragover":""}`,onDragOver:e=>{e.preventDefault(),ee(!0)},onDragLeave:()=>ee(!1),onDrop:e=>{e.preventDefault(),ee(!1),Pe(e.dataTransfer.files)},children:[t.jsx("textarea",{ref:B,className:"chat-input-textarea",placeholder:"Type a message...",value:_,onChange:At,onKeyDown:Tt,onKeyUp:Rt,onClick:Ke,onBlur:Dt,onFocus:$t,onPaste:Ct,onTouchStart:e=>{typeof window>"u"||window.innerWidth>768||document.activeElement!==e.currentTarget&&(e.preventDefault(),e.currentTarget.focus({preventScroll:!0}))},rows:1,"data-testid":"chat-input"}),t.jsx(cs,{agents:Se,filter:be,highlightedIndex:Me,visible:ne,onSelect:Ve,position:"below"}),t.jsx(ds,{visible:d.mentionActive&&!ne,position:I,files:d.files,selectedIndex:d.selectedIndex,onSelect:e=>{const n=d.selectFile(e,_);Y(n),d.dismissMention(),z(!1),B.current?.focus()},loading:d.loading}),v&&t.jsxs("div",{className:"chat-pending-message","data-testid":"chat-pending-indicator",children:[t.jsx("span",{children:`Queued: ${Ut}`}),t.jsx("button",{type:"button",className:"chat-pending-message-dismiss","aria-label":"Dismiss queued message","data-testid":"chat-pending-dismiss",onClick:M,children:"×"})]})]}),k?t.jsx("button",{className:"chat-input-stop",onClick:f,"aria-label":"Stop generation","data-testid":"chat-stop-btn",children:t.jsx(us,{size:14})}):t.jsx("button",{type:"button",className:"chat-input-send",onPointerDown:e=>{typeof window>"u"||window.innerWidth>768||(e.preventDefault(),e.pointerType&&e.pointerType!=="mouse"&&(Ee.current=!0,rt(),Fe(),Ae(),window.setTimeout(()=>{$e.current=!1},1500)))},onTouchStart:e=>{typeof window>"u"||window.innerWidth>768||(e.preventDefault(),Ee.current=!0,rt(),Fe(),Ae(),window.setTimeout(()=>{$e.current=!1},1500))},onMouseDown:e=>{typeof window>"u"||window.innerWidth>768||e.preventDefault()},onClick:()=>{if(Ee.current){Ee.current=!1;return}Ae()},disabled:!_.trim()&&X.length===0,"data-testid":"chat-send-btn",children:t.jsx(hs,{size:16})})]})]})]}),se&&t.jsx(Ns,{projectId:a,onClose:()=>q(!1),onCreate:Mt})]})}export{As as ChatView};
|