cc-viewer 1.5.29 → 1.5.30
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.
|
@@ -489,7 +489,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
489
489
|
`))}return r.join(`
|
|
490
490
|
|
|
491
491
|
|
|
492
|
-
`)}renderProjectStatsContent(){const{projectStats:n,projectStatsLoading:r}=this.state;if(r)return _.jsx("div",{className:pe.projectStatsCenter,children:_.jsx(Ba,{})});if(!n)return _.jsx("div",{className:pe.projectStatsEmpty,children:de("ui.projectStats.noData")});const{summary:i,models:s,updatedAt:o}=n;s&&Object.entries(s).sort((c,u)=>u[1]-c[1]);const a={};if(n.files){for(const c of Object.values(n.files))if(c.models)for(const[u,d]of Object.entries(c.models))a[u]||(a[u]={input:0,output:0,cacheRead:0,cacheCreation:0,count:0}),a[u].input+=d.input_tokens||0,a[u].output+=d.output_tokens||0,a[u].cacheRead+=d.cache_read_input_tokens||0,a[u].cacheCreation+=d.cache_creation_input_tokens||0,a[u].count+=d.count||0}const l=Object.entries(a).sort((c,u)=>u[1].count-c[1].count);return _.jsxs("div",{className:pe.projectStatsContent,children:[o&&_.jsx("div",{className:pe.projectStatsUpdated,children:de("ui.projectStats.updatedAt",{time:new Date(o).toLocaleString()})}),_.jsxs("div",{className:pe.projectStatsSummary,children:[_.jsxs("div",{className:pe.projectStatCard,children:[_.jsx("div",{className:pe.projectStatValue,children:(i==null?void 0:i.requestCount)??0}),_.jsx("div",{className:pe.projectStatLabel,children:de("ui.projectStats.totalRequests")})]}),_.jsxs("div",{className:pe.projectStatCard,children:[_.jsx("div",{className:pe.projectStatValue,children:(i==null?void 0:i.sessionCount)??0}),_.jsx("div",{className:pe.projectStatLabel,children:de("ui.projectStats.sessionCount")})]}),_.jsxs("div",{className:pe.projectStatCard,children:[_.jsx("div",{className:pe.projectStatValue,children:(i==null?void 0:i.fileCount)??0}),_.jsx("div",{className:pe.projectStatLabel,children:de("ui.projectStats.totalFiles")})]}),_.jsxs("div",{className:pe.projectStatCard,children:[_.jsx("div",{className:pe.projectStatValue,children:Rr(i==null?void 0:i.input_tokens)}),_.jsx("div",{className:pe.projectStatLabel,children:"Input Tokens"})]}),_.jsxs("div",{className:pe.projectStatCard,children:[_.jsx("div",{className:pe.projectStatValue,children:Rr(i==null?void 0:i.output_tokens)}),_.jsx("div",{className:pe.projectStatLabel,children:"Output Tokens"})]})]}),l.length>0&&_.jsxs("div",{className:pe.projectStatsSection,children:[_.jsx("div",{className:pe.projectStatsSectionTitle,children:de("ui.projectStats.modelUsage")}),l.map(([c,u])=>{const d=u.input+u.cacheRead+u.cacheCreation,h=d>0?(u.cacheRead/d*100).toFixed(1):"0.0";return _.jsxs("div",{className:pe.projectStatsModelCard,children:[_.jsxs("div",{className:pe.projectStatsModelHeader,children:[_.jsx("span",{className:pe.projectStatsModelName,children:c}),_.jsxs("span",{className:pe.projectStatsModelCount,children:[u.count," reqs"]})]}),_.jsx("table",{className:pe.statsTable,children:_.jsxs("tbody",{children:[_.jsxs("tr",{children:[_.jsx("td",{className:pe.label,children:"Token"}),_.jsx("td",{className:pe.th,children:"input"}),_.jsx("td",{className:pe.th,children:"output"})]}),_.jsxs("tr",{className:pe.rowBorder,children:[_.jsx("td",{className:pe.label}),_.jsx("td",{className:pe.td,children:Rr(d)}),_.jsx("td",{className:pe.td,children:Rr(u.output)})]}),_.jsxs("tr",{children:[_.jsx("td",{className:pe.label,children:"Cache"}),_.jsx("td",{className:pe.th,children:"create"}),_.jsx("td",{className:pe.th,children:"read"})]}),_.jsxs("tr",{className:pe.rowBorder,children:[_.jsx("td",{className:pe.label}),_.jsx("td",{className:pe.td,children:Rr(u.cacheCreation)}),_.jsx("td",{className:pe.td,children:Rr(u.cacheRead)})]}),_.jsxs("tr",{children:[_.jsx("td",{className:pe.label,children:de("ui.hitRate")}),_.jsxs("td",{colSpan:2,className:pe.td,children:[h,"%"]})]})]})})]},c)})]})]})}render(){const{requestCount:n,requests:r=[],viewMode:i,cacheType:s,onToggleViewMode:o,onImportLocalLogs:a,onLangChange:l,isLocalLog:c,localLogFile:u,projectName:d,collapseToolResults:h,onCollapseToolResultsChange:p,expandThinking:g,onExpandThinkingChange:v,expandDiff:$,onExpandDiffChange:b,filterIrrelevant:y,onFilterIrrelevantChange:Q,updateInfo:x,onDismissUpdate:w,cliMode:C,terminalVisible:T,onToggleTerminal:z,onReturnToWorkspaces:E,contextWindow:L}=this.props,{countdownText:A}=this.state,X=[{key:"import-local",icon:_.jsx(q6,{}),label:de("ui.importLocalLogs"),onClick:a},{key:"export-prompts",icon:_.jsx(Pve,{}),label:de("ui.exportPrompts"),onClick:this.handleShowPrompts},{key:"plugin-management",icon:_.jsx(Y6,{}),label:de("ui.pluginManagement"),onClick:this.handleShowPlugins},...C&&E?[{key:"switch-workspace",icon:_.jsx(q6,{style:{transform:"scaleX(-1)"}}),label:de("ui.switchWorkspace"),onClick:E}]:[],{key:"process-management",icon:_.jsx(sQ,{}),label:de("ui.processManagement"),onClick:this.handleShowProcesses},{type:"divider"},{key:"project-stats",icon:_.jsx(B6,{}),label:de("ui.projectStats"),onClick:this.handleShowProjectStats},...i==="raw"?[{key:"global-settings",icon:_.jsx(U6,{}),label:de("ui.globalSettings"),onClick:()=>this.setState({globalSettingsVisible:!0})}]:[],...i==="chat"?[{key:"display-settings",icon:_.jsx(U6,{}),label:de("ui.settings"),onClick:()=>this.setState({settingsDrawerVisible:!0})}]:[],{key:"language",icon:_.jsx(kve,{}),label:de("ui.languageSettings"),children:[{key:"lang-grid-container",type:"group",label:_.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px",padding:"8px 4px",minWidth:"360px",maxHeight:"none"},children:x1e.map(k=>_.jsx(yn,{size:"small",type:k.value===Qm()?"primary":"default",onClick:R=>{R.stopPropagation(),nk(k.value),l&&l()},style:{width:"100%",textAlign:"center"},children:k.label},k.value))})}]}];return _.jsxs("div",{className:pe.headerBar,children:[_.jsxs(Sl,{size:"middle",children:[_.jsx(DS,{menu:{items:X,className:"logo-dropdown-menu"},trigger:["hover"],onOpenChange:k=>this.setState({logoDropdownOpen:k}),align:{offset:[-4,0]},children:_.jsx("span",{className:`${pe.logoWrap}${this.state.logoDropdownOpen?` ${pe.logoWrapActive}`:""}`,children:_.jsx("img",{src:"/favicon.ico",alt:"Logo",className:`${pe.logoImage}${this.state.logoDropdownOpen?` ${pe.logoImageActive}`:""}`})})}),_.jsx(U$,{content:this.renderTokenStats(),trigger:"hover",placement:"bottomLeft",overlayInnerStyle:{background:"#1e1e1e",border:"1px solid #3a3a3a",borderRadius:8,padding:"8px 8px"},children:_.jsxs(Js,{className:pe.tokenStatsTag,children:[_.jsx(sQ,{className:pe.tokenStatsIcon}),de("ui.tokenStats")]})}),(()=>{var M,I,j;let k=0;if(!c){if((L==null?void 0:L.used_percentage)!=null)k=Math.min(100,Math.max(0,Math.round(L.used_percentage/83.5*100)));else if(r.length>0){const W=B=>{var q,D;const U=(D=(q=B.response)==null?void 0:q.body)==null?void 0:D.usage;return((U==null?void 0:U.input_tokens)||0)+((U==null?void 0:U.cache_creation_input_tokens)||0)+((U==null?void 0:U.cache_read_input_tokens)||0)};for(let B=r.length-1;B>=0;B--)if(ji(r[B])&&((I=(M=r[B].response)==null?void 0:M.body)!=null&&I.usage)){const U=W(r[B]),D=((L==null?void 0:L.context_window_size)||n0e((j=r[B].body)==null?void 0:j.model))*.835;D>0&&U>0&&(k=Math.min(100,Math.max(0,Math.round(U/D*100))));break}}}const R=k>=80?"#ff4d4f":k>=60?"#faad14":"#52c41a";return c?_.jsx(Js,{className:`${pe.liveTag} ${pe.liveTagHistory}`,children:_.jsx("span",{className:pe.liveTagText,children:de("ui.historyLog",{file:u})})}):_.jsxs("span",{className:pe.liveTag,style:{borderColor:R,color:R},children:[_.jsx("span",{className:pe.liveTagFill,style:{width:`${k}%`,backgroundColor:R}}),_.jsx("span",{className:pe.liveTagContent,children:_.jsxs("span",{className:pe.liveTagText,children:[de("ui.liveMonitoring"),d?`:${d}`:""]})})]})})(),x&&_.jsx(Js,{color:x.type==="completed"?"green":"orange",closable:!0,onClose:()=>w&&w(),children:x.type==="completed"?de("ui.update.completed",{version:x.version}):de("ui.update.majorAvailable",{version:x.version})})]}),_.jsxs(Sl,{size:"middle",children:[A&&_.jsxs(Js,{style:{background:"#2a2a2a",border:"1px solid #3a3a3a",color:A===de("ui.cacheExpired")?"#ff6b6b":"#ccc"},children:[de("ui.cacheCountdown",{type:s?`(${s})`:""}),_.jsx("strong",{className:pe.countdownStrong,children:A})]}),i==="chat"&&C&&!c&&this.state.localUrl&&_.jsx(U$,{content:_.jsxs("div",{className:pe.qrcodePopover,style:{width:800},children:[_.jsx("div",{className:pe.qrcodeTitle,children:de("ui.scanToCoding")}),_.jsx(TW,{value:this.state.localUrl,size:200,bgColor:"#141414",fgColor:"#d9d9d9",level:"M"}),_.jsx(Fd,{readOnly:!0,value:this.state.localUrl,className:pe.qrcodeUrlInput,suffix:_.jsx(Dp,{className:pe.qrcodeUrlCopy,onClick:()=>{navigator.clipboard.writeText(this.state.localUrl).then(()=>{vr.success(de("ui.copied"))}).catch(()=>{})}})})]}),trigger:"hover",placement:"bottomRight",overlayInnerStyle:{background:"#1e1e1e",border:"1px solid #3a3a3a",borderRadius:8,padding:"8px 8px"},children:_.jsx(yn,{className:pe.compactBtnNoBorder,icon:_.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{verticalAlign:"-3px"},children:[_.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),_.jsx("line",{x1:"12",y1:"18",x2:"12.01",y2:"18"})]})})}),C&&i==="chat"&&!c&&_.jsx(yn,{className:pe.compactBtn,type:T?"primary":"default",ghost:T,icon:_.jsx(s$,{}),onClick:z,children:de("ui.terminal")}),_.jsx(yn,{className:pe.compactBtn,type:i==="raw"?"primary":"default",icon:i==="raw"?_.jsx(gW,{}):_.jsx(r$,{}),onClick:o,children:de(i==="raw"?"ui.chatMode":"ui.rawMode")})]}),_.jsxs(Ci,{title:`${de("ui.userPrompt")} (${this.state.promptData.length}${de("ui.promptCountUnit")})`,open:this.state.promptModalVisible,onCancel:()=>this.setState({promptModalVisible:!1}),footer:null,width:700,children:[_.jsx("div",{className:pe.promptExportBar,children:_.jsx(yn,{icon:_.jsx(OP,{}),onClick:this.handleExportPromptsTxt,children:de("ui.exportPromptsTxt")})}),_.jsx(US,{activeKey:this.state.promptViewMode,onChange:k=>this.setState({promptViewMode:k}),size:"small",items:[{key:"original",label:de("ui.promptModeOriginal")},{key:"context",label:de("ui.promptModeContext")},{key:"text",label:de("ui.promptModeText")}]}),this.state.promptViewMode==="text"?_.jsx("textarea",{readOnly:!0,className:pe.promptTextarea,value:this.buildTextModeContent()}):_.jsxs("div",{className:pe.promptScrollArea,children:[this.state.promptData.length===0&&_.jsx("div",{className:pe.promptEmpty,children:de("ui.noPrompt")}),this.state.promptData.map((k,R)=>{const M=k.timestamp?new Date(k.timestamp).toLocaleString():de("ui.unknownTime");return _.jsxs("div",{children:[_.jsxs("div",{className:pe.promptTimestamp,children:[M,":"]}),this.state.promptViewMode==="original"?this.renderOriginalPrompt(k):this.renderTextPrompt(k)]},R)})]})]}),_.jsx(n$,{title:de("ui.settings"),placement:"left",width:360,open:this.state.settingsDrawerVisible,onClose:()=>this.setState({settingsDrawerVisible:!1}),children:_.jsxs("div",{className:pe.settingsGroupBox,children:[_.jsx("div",{className:pe.settingsGroupTitle,children:de("ui.chatDisplaySwitches")}),_.jsxs("div",{className:pe.settingsItem,children:[_.jsx("span",{className:pe.settingsLabel,children:de("ui.collapseToolResults")}),_.jsx(fu,{checked:!!h,onChange:k=>p&&p(k)})]}),_.jsxs("div",{className:pe.settingsItem,children:[_.jsx("span",{className:pe.settingsLabel,children:de("ui.expandThinking")}),_.jsx(fu,{checked:!!g,onChange:k=>v&&v(k)})]})]})}),_.jsxs(n$,{title:de("ui.globalSettings"),placement:"left",width:400,open:this.state.globalSettingsVisible,onClose:()=>this.setState({globalSettingsVisible:!1}),children:[_.jsxs("div",{className:pe.settingsItem,children:[_.jsx("span",{className:pe.settingsLabel,children:de("ui.filterIrrelevant")}),_.jsx(fu,{checked:!!y,onChange:k=>Q&&Q(k)})]}),_.jsxs("div",{className:pe.settingsItem,children:[_.jsx("span",{className:pe.settingsLabel,children:de("ui.expandDiff")}),_.jsx(fu,{checked:!!$,onChange:k=>b&&b(k)})]})]}),_.jsx(n$,{title:_.jsxs("span",{children:[_.jsx(B6,{style:{marginRight:8}}),de("ui.projectStats")]}),placement:"left",width:400,open:this.state.projectStatsVisible,onClose:()=>this.setState({projectStatsVisible:!1}),children:this.renderProjectStatsContent()}),_.jsxs(Ci,{title:_.jsxs("span",{children:[_.jsx(Y6,{style:{marginRight:8}}),de("ui.pluginManagement")]}),open:this.state.pluginModalVisible,onCancel:()=>this.setState({pluginModalVisible:!1}),footer:_.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[_.jsx(yn,{icon:_.jsx(H$,{}),onClick:this.handleAddPlugin,children:de("ui.plugins.add")}),_.jsx(yn,{icon:_.jsx(o6,{}),onClick:this.handleReloadPlugins,children:de("ui.plugins.reload")})]}),width:560,children:[this.state.pluginsDir&&_.jsxs("div",{className:pe.pluginDirHint,children:[_.jsxs("span",{style:{color:"#888"},children:[de("ui.plugins.pluginsDir"),":"]})," ",_.jsx("code",{className:pe.pluginDirPath,onClick:()=>{navigator.clipboard.writeText(this.state.pluginsDir).then(()=>{vr.success(de("ui.copied"))}).catch(()=>{})},children:this.state.pluginsDir})]}),this.state.pluginsList.length===0?_.jsxs("div",{className:pe.pluginEmpty,children:[_.jsx("div",{style:{fontSize:14,marginBottom:4},children:de("ui.plugins.empty")}),_.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:12},children:de("ui.plugins.emptyHint")}),_.jsx(yn,{icon:_.jsx(H$,{}),onClick:this.handleAddPlugin,children:de("ui.plugins.add")})]}):_.jsx("div",{className:pe.pluginList,children:this.state.pluginsList.map(k=>_.jsxs("div",{className:pe.pluginItem,children:[_.jsxs("div",{className:pe.pluginInfo,children:[_.jsx("span",{className:pe.pluginName,children:k.name}),_.jsx("span",{className:pe.pluginFile,children:k.file}),k.hooks.length>0&&_.jsx("span",{className:pe.pluginHooks,children:k.hooks.map(R=>_.jsx("span",{className:pe.pluginHookTag,children:R},R))})]}),_.jsxs("div",{className:pe.pluginActions,children:[_.jsx(fu,{size:"small",checked:k.enabled,onChange:R=>this.handleTogglePlugin(k.name,R)}),_.jsx(yn,{type:"text",size:"small",danger:!0,icon:_.jsx(r1,{}),onClick:()=>this.handleDeletePlugin(k.file,k.name)})]})]},k.file))})]}),_.jsx(Ci,{title:de("ui.plugins.delete"),open:this.state.deleteConfirmVisible,onCancel:()=>this.setState({deleteConfirmVisible:!1,deleteTarget:null}),onOk:this.handleDeletePluginConfirm,okType:"danger",okText:"OK",cancelText:"Cancel",children:_.jsx("p",{children:this.state.deleteTarget?de("ui.plugins.deleteConfirm",{name:this.state.deleteTarget.name}):""})}),_.jsx(Ci,{title:_.jsxs("span",{children:[_.jsx(sQ,{style:{marginRight:8}}),de("ui.processManagement")]}),open:this.state.processModalVisible,onCancel:()=>this.setState({processModalVisible:!1}),footer:_.jsx(yn,{icon:_.jsx(o6,{}),onClick:this.fetchProcesses,loading:this.state.processLoading,children:de("ui.processManagement.refresh")}),width:780,children:_.jsx(Yl,{dataSource:this.state.processList,rowKey:"pid",loading:this.state.processLoading,size:"middle",pagination:!1,columns:[{title:de("ui.processManagement.port"),dataIndex:"port",width:80,render:k=>k?_.jsx("a",{href:`${window.location.protocol}//127.0.0.1:${k}`,target:"_blank",rel:"noopener noreferrer",children:k}):""},{title:"PID",dataIndex:"pid",width:80},{title:de("ui.processManagement.command"),dataIndex:"command",ellipsis:!0},{title:de("ui.processManagement.startTime"),dataIndex:"startTime",width:200},{title:de("ui.processManagement.action"),width:100,render:(k,R)=>R.isCurrent?_.jsx(Js,{color:"green",children:de("ui.processManagement.current")}):_.jsx(yn,{size:"small",danger:!0,onClick:()=>this.handleKillProcess(R.pid),children:de("ui.processManagement.kill")})}]})})]})}};Rt(Oh,"COMMAND_TAGS",new Set(["command-name","command-message","command-args","local-command-caveat","local-command-stdout"]));let bP=Oh;const w1e="_centerEmpty_oxhcp_1",P1e="_scrollContainer_oxhcp_8",C1e="_listItem_oxhcp_15",T1e="_listItemActive_oxhcp_27",k1e="_itemContent_oxhcp_36",R1e="_itemHeader_oxhcp_41",E1e="_tagNoMargin_oxhcp_49",X1e="_modelName_oxhcp_54",z1e="_time_oxhcp_58",M1e="_detailRow_oxhcp_64",N1e="_urlText_oxhcp_71",j1e="_duration_oxhcp_80",I1e="_statusOk_oxhcp_85",L1e="_statusErr_oxhcp_91",A1e="_statusDefault_oxhcp_96",W1e="_usageBox_oxhcp_101",V1e="_cacheDot_oxhcp_111",Y1e="_cacheDotLoss_oxhcp_120",B1e="_cacheDotNormal_oxhcp_125",ii={centerEmpty:w1e,scrollContainer:P1e,listItem:C1e,listItemActive:T1e,itemContent:k1e,itemHeader:R1e,tagNoMargin:E1e,modelName:X1e,time:z1e,detailRow:M1e,urlText:N1e,duration:j1e,statusOk:I1e,statusErr:L1e,statusDefault:A1e,usageBox:W1e,cacheDot:V1e,cacheDotLoss:Y1e,cacheDotNormal:B1e};class q1e extends ne.Component{constructor(e){super(e),this.activeItemRef=ne.createRef()}componentDidMount(){this.scrollToSelected(!0)}componentDidUpdate(e){this.props.scrollCenter&&e.selectedIndex!==this.props.selectedIndex?this.scrollToSelected(!0):e.requests!==this.props.requests&&this.scrollToSelected(!1)}scrollToSelected(e){this.activeItemRef.current&&(this.activeItemRef.current.scrollIntoView({block:e?"center":"nearest",behavior:"instant"}),e&&this.props.onScrollDone&&this.props.onScrollDone())}render(){const{requests:e,selectedIndex:n,onSelect:r}=this.props;return e.length===0?_.jsx("div",{className:ii.centerEmpty,children:_.jsx(gs,{description:de("ui.waitingRequests")})}):_.jsx("div",{className:ii.scrollContainer,children:_.jsx(e1,{dataSource:e,size:"small",split:!1,renderItem:(i,s)=>{var x,w,C;const o=new Date(i.timestamp).toLocaleTimeString("zh-CN"),a=s===n,l=i.response&&i.response.status<400,c=i.response&&i.response.status>=400,u=a0e((x=i.body)==null?void 0:x.model),d=s+1<e.length?e[s+1]:null,{type:h,subType:p}=Nd(i,d),g=(C=(w=i.response)==null?void 0:w.body)==null?void 0:C.usage,v=g?(g.input_tokens||0)+(g.cache_read_input_tokens||0)+(g.cache_creation_input_tokens||0):null,$=(g==null?void 0:g.output_tokens)||null,b=(g==null?void 0:g.cache_read_input_tokens)||0,y=(g==null?void 0:g.cache_creation_input_tokens)||0;let Q=i.url;try{const T=new URL(i.url);Q=T.host+T.pathname}catch{}return _.jsx(e1.Item,{ref:a?this.activeItemRef:void 0,onClick:()=>r(s),className:`${ii.listItem} ${a?ii.listItemActive:""}`,children:_.jsxs("div",{className:ii.itemContent,children:[_.jsxs("div",{className:ii.itemHeader,children:[h==="MainAgent"?_.jsx(Js,{color:"orange",className:ii.tagNoMargin,children:"MainAgent"}):h==="Plan"?_.jsx(Js,{className:ii.tagNoMargin,style:{color:"#a33",borderColor:"#a33",backgroundColor:"#000"},children:gP(h,p)}):h==="Count"||h==="Preflight"?_.jsx(Js,{className:ii.tagNoMargin,style:{color:"#666",borderColor:"#444",backgroundColor:"#000"},children:h}):_.jsx(Js,{className:ii.tagNoMargin,children:gP(h,p)}),u&&_.jsx("span",{className:ii.modelName,style:{color:h==="MainAgent"?"#d4822d":"#8c8c8c"},children:u}),_.jsx("span",{className:ii.time,children:o})]}),_.jsxs("div",{className:ii.detailRow,children:[_.jsx("span",{className:ii.urlText,title:i.url,children:Q}),i.duration&&_.jsxs("span",{className:ii.duration,children:[i.duration,"ms"]}),i.response&&_.jsx("span",{className:l?ii.statusOk:c?ii.statusErr:ii.statusDefault,children:i.response.status})]}),g&&_.jsxs("div",{className:ii.usageBox,children:[_.jsxs("div",{children:["token: output:",Rr($)||0,", input: ",Rr(v)||0]}),(b>0||y>0)&&_.jsx("div",{children:(()=>{const T=kW(e,s),z={ttl:"ui.cacheLoss.ttl",system_change:"ui.cacheLoss.systemChange",tools_change:"ui.cacheLoss.toolsChange",model_change:"ui.cacheLoss.modelChange",msg_truncated:"ui.cacheLoss.msgTruncated",msg_modified:"ui.cacheLoss.msgModified",key_change:"ui.cacheLoss.keyChange"};let E;if(T){const A=(T.reasons||[T.reason]).map(X=>de(z[X]||z.key_change)).join(`
|
|
492
|
+
`)}renderProjectStatsContent(){const{projectStats:n,projectStatsLoading:r}=this.state;if(r)return _.jsx("div",{className:pe.projectStatsCenter,children:_.jsx(Ba,{})});if(!n)return _.jsx("div",{className:pe.projectStatsEmpty,children:de("ui.projectStats.noData")});const{summary:i,models:s,updatedAt:o}=n;s&&Object.entries(s).sort((c,u)=>u[1]-c[1]);const a={};if(n.files){for(const c of Object.values(n.files))if(c.models)for(const[u,d]of Object.entries(c.models))a[u]||(a[u]={input:0,output:0,cacheRead:0,cacheCreation:0,count:0}),a[u].input+=d.input_tokens||0,a[u].output+=d.output_tokens||0,a[u].cacheRead+=d.cache_read_input_tokens||0,a[u].cacheCreation+=d.cache_creation_input_tokens||0,a[u].count+=d.count||0}const l=Object.entries(a).sort((c,u)=>u[1].count-c[1].count);return _.jsxs("div",{className:pe.projectStatsContent,children:[o&&_.jsx("div",{className:pe.projectStatsUpdated,children:de("ui.projectStats.updatedAt",{time:new Date(o).toLocaleString()})}),_.jsxs("div",{className:pe.projectStatsSummary,children:[_.jsxs("div",{className:pe.projectStatCard,children:[_.jsx("div",{className:pe.projectStatValue,children:(i==null?void 0:i.requestCount)??0}),_.jsx("div",{className:pe.projectStatLabel,children:de("ui.projectStats.totalRequests")})]}),_.jsxs("div",{className:pe.projectStatCard,children:[_.jsx("div",{className:pe.projectStatValue,children:(i==null?void 0:i.sessionCount)??0}),_.jsx("div",{className:pe.projectStatLabel,children:de("ui.projectStats.sessionCount")})]}),_.jsxs("div",{className:pe.projectStatCard,children:[_.jsx("div",{className:pe.projectStatValue,children:(i==null?void 0:i.fileCount)??0}),_.jsx("div",{className:pe.projectStatLabel,children:de("ui.projectStats.totalFiles")})]}),_.jsxs("div",{className:pe.projectStatCard,children:[_.jsx("div",{className:pe.projectStatValue,children:Rr(i==null?void 0:i.input_tokens)}),_.jsx("div",{className:pe.projectStatLabel,children:"Input Tokens"})]}),_.jsxs("div",{className:pe.projectStatCard,children:[_.jsx("div",{className:pe.projectStatValue,children:Rr(i==null?void 0:i.output_tokens)}),_.jsx("div",{className:pe.projectStatLabel,children:"Output Tokens"})]})]}),l.length>0&&_.jsxs("div",{className:pe.projectStatsSection,children:[_.jsx("div",{className:pe.projectStatsSectionTitle,children:de("ui.projectStats.modelUsage")}),l.map(([c,u])=>{const d=u.input+u.cacheRead+u.cacheCreation,h=d>0?(u.cacheRead/d*100).toFixed(1):"0.0";return _.jsxs("div",{className:pe.projectStatsModelCard,children:[_.jsxs("div",{className:pe.projectStatsModelHeader,children:[_.jsx("span",{className:pe.projectStatsModelName,children:c}),_.jsxs("span",{className:pe.projectStatsModelCount,children:[u.count," reqs"]})]}),_.jsx("table",{className:pe.statsTable,children:_.jsxs("tbody",{children:[_.jsxs("tr",{children:[_.jsx("td",{className:pe.label,children:"Token"}),_.jsx("td",{className:pe.th,children:"input"}),_.jsx("td",{className:pe.th,children:"output"})]}),_.jsxs("tr",{className:pe.rowBorder,children:[_.jsx("td",{className:pe.label}),_.jsx("td",{className:pe.td,children:Rr(d)}),_.jsx("td",{className:pe.td,children:Rr(u.output)})]}),_.jsxs("tr",{children:[_.jsx("td",{className:pe.label,children:"Cache"}),_.jsx("td",{className:pe.th,children:"create"}),_.jsx("td",{className:pe.th,children:"read"})]}),_.jsxs("tr",{className:pe.rowBorder,children:[_.jsx("td",{className:pe.label}),_.jsx("td",{className:pe.td,children:Rr(u.cacheCreation)}),_.jsx("td",{className:pe.td,children:Rr(u.cacheRead)})]}),_.jsxs("tr",{children:[_.jsx("td",{className:pe.label,children:de("ui.hitRate")}),_.jsxs("td",{colSpan:2,className:pe.td,children:[h,"%"]})]})]})})]},c)})]})]})}render(){const{requestCount:n,requests:r=[],viewMode:i,cacheType:s,onToggleViewMode:o,onImportLocalLogs:a,onLangChange:l,isLocalLog:c,localLogFile:u,projectName:d,collapseToolResults:h,onCollapseToolResultsChange:p,expandThinking:g,onExpandThinkingChange:v,expandDiff:$,onExpandDiffChange:b,filterIrrelevant:y,onFilterIrrelevantChange:Q,updateInfo:x,onDismissUpdate:w,cliMode:C,terminalVisible:T,onToggleTerminal:z,onReturnToWorkspaces:E,contextWindow:L}=this.props,{countdownText:A}=this.state,X=[{key:"import-local",icon:_.jsx(q6,{}),label:de("ui.importLocalLogs"),onClick:a},{key:"export-prompts",icon:_.jsx(Pve,{}),label:de("ui.exportPrompts"),onClick:this.handleShowPrompts},{key:"plugin-management",icon:_.jsx(Y6,{}),label:de("ui.pluginManagement"),onClick:this.handleShowPlugins},...C&&E?[{key:"switch-workspace",icon:_.jsx(q6,{style:{transform:"scaleX(-1)"}}),label:de("ui.switchWorkspace"),onClick:E}]:[],{key:"process-management",icon:_.jsx(sQ,{}),label:de("ui.processManagement"),onClick:this.handleShowProcesses},{type:"divider"},{key:"project-stats",icon:_.jsx(B6,{}),label:de("ui.projectStats"),onClick:this.handleShowProjectStats},...i==="raw"?[{key:"global-settings",icon:_.jsx(U6,{}),label:de("ui.globalSettings"),onClick:()=>this.setState({globalSettingsVisible:!0})}]:[],...i==="chat"?[{key:"display-settings",icon:_.jsx(U6,{}),label:de("ui.settings"),onClick:()=>this.setState({settingsDrawerVisible:!0})}]:[],{key:"language",icon:_.jsx(kve,{}),label:de("ui.languageSettings"),children:[{key:"lang-grid-container",type:"group",label:_.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px",padding:"8px 4px",minWidth:"360px",maxHeight:"none"},children:x1e.map(k=>_.jsx(yn,{size:"small",type:k.value===Qm()?"primary":"default",onClick:R=>{R.stopPropagation(),nk(k.value),l&&l()},style:{width:"100%",textAlign:"center"},children:k.label},k.value))})}]}];return _.jsxs("div",{className:pe.headerBar,children:[_.jsxs(Sl,{size:"middle",children:[_.jsx(DS,{menu:{items:X,className:"logo-dropdown-menu"},trigger:["hover"],onOpenChange:k=>this.setState({logoDropdownOpen:k}),align:{offset:[-4,0]},children:_.jsx("span",{className:`${pe.logoWrap}${this.state.logoDropdownOpen?` ${pe.logoWrapActive}`:""}`,children:_.jsx("img",{src:"/favicon.ico",alt:"Logo",className:`${pe.logoImage}${this.state.logoDropdownOpen?` ${pe.logoImageActive}`:""}`})})}),_.jsx(U$,{content:this.renderTokenStats(),trigger:"hover",placement:"bottomLeft",overlayInnerStyle:{background:"#1e1e1e",border:"1px solid #3a3a3a",borderRadius:8,padding:"8px 8px"},children:_.jsxs(Js,{className:pe.tokenStatsTag,children:[_.jsx(sQ,{className:pe.tokenStatsIcon}),de("ui.tokenStats")]})}),(()=>{var M,I,j;let k=0;if(!c){if((L==null?void 0:L.used_percentage)!=null)k=Math.min(100,Math.max(0,Math.round(L.used_percentage/83.5*100)));else if(r.length>0){const W=B=>{var q,D;const U=(D=(q=B.response)==null?void 0:q.body)==null?void 0:D.usage;return((U==null?void 0:U.input_tokens)||0)+((U==null?void 0:U.cache_creation_input_tokens)||0)+((U==null?void 0:U.cache_read_input_tokens)||0)};for(let B=r.length-1;B>=0;B--)if(ji(r[B])&&((I=(M=r[B].response)==null?void 0:M.body)!=null&&I.usage)){const U=W(r[B]),D=((L==null?void 0:L.context_window_size)||n0e((j=r[B].body)==null?void 0:j.model))*.835;D>0&&U>0&&(k=Math.min(100,Math.max(0,Math.round(U/D*100))));break}}}const R=k>=80?"#ff4d4f":k>=60?"#faad14":"#52c41a";return c?_.jsx(Js,{className:`${pe.liveTag} ${pe.liveTagHistory}`,children:_.jsx("span",{className:pe.liveTagText,children:de("ui.historyLog",{file:u})})}):_.jsxs("span",{className:pe.liveTag,style:{borderColor:R,color:R},children:[_.jsx("span",{className:pe.liveTagFill,style:{width:`${k}%`,backgroundColor:R}}),_.jsx("span",{className:pe.liveTagContent,children:_.jsxs("span",{className:pe.liveTagText,children:[de("ui.liveMonitoring"),d?`:${d}`:""]})})]})})(),x&&_.jsx(Js,{color:x.type==="completed"?"green":"orange",closable:!0,onClose:()=>w&&w(),children:x.type==="completed"?de("ui.update.completed",{version:x.version}):de("ui.update.majorAvailable",{version:x.version})})]}),_.jsxs(Sl,{size:"middle",children:[A&&_.jsxs(Js,{style:{background:"#2a2a2a",border:"1px solid #3a3a3a",color:A===de("ui.cacheExpired")?"#ff6b6b":"#ccc"},children:[de("ui.cacheCountdown",{type:s?`(${s})`:""}),_.jsx("strong",{className:pe.countdownStrong,children:A})]}),i==="chat"&&C&&!c&&this.state.localUrl&&_.jsx(U$,{content:_.jsxs("div",{className:pe.qrcodePopover,children:[_.jsx("div",{className:pe.qrcodeTitle,children:de("ui.scanToCoding")}),_.jsx(TW,{value:this.state.localUrl,size:200,bgColor:"#141414",fgColor:"#d9d9d9",level:"M"}),_.jsx(Fd,{readOnly:!0,value:this.state.localUrl,className:pe.qrcodeUrlInput,suffix:_.jsx(Dp,{className:pe.qrcodeUrlCopy,onClick:()=>{navigator.clipboard.writeText(this.state.localUrl).then(()=>{vr.success(de("ui.copied"))}).catch(()=>{})}})})]}),trigger:"hover",placement:"bottomRight",overlayInnerStyle:{background:"#1e1e1e",border:"1px solid #3a3a3a",borderRadius:8,padding:"8px 8px"},children:_.jsx(yn,{className:pe.compactBtnNoBorder,icon:_.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{verticalAlign:"-3px"},children:[_.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),_.jsx("line",{x1:"12",y1:"18",x2:"12.01",y2:"18"})]})})}),C&&i==="chat"&&!c&&_.jsx(yn,{className:pe.compactBtn,type:T?"primary":"default",ghost:T,icon:_.jsx(s$,{}),onClick:z,children:de("ui.terminal")}),_.jsx(yn,{className:pe.compactBtn,type:i==="raw"?"primary":"default",icon:i==="raw"?_.jsx(gW,{}):_.jsx(r$,{}),onClick:o,children:de(i==="raw"?"ui.chatMode":"ui.rawMode")})]}),_.jsxs(Ci,{title:`${de("ui.userPrompt")} (${this.state.promptData.length}${de("ui.promptCountUnit")})`,open:this.state.promptModalVisible,onCancel:()=>this.setState({promptModalVisible:!1}),footer:null,width:700,children:[_.jsx("div",{className:pe.promptExportBar,children:_.jsx(yn,{icon:_.jsx(OP,{}),onClick:this.handleExportPromptsTxt,children:de("ui.exportPromptsTxt")})}),_.jsx(US,{activeKey:this.state.promptViewMode,onChange:k=>this.setState({promptViewMode:k}),size:"small",items:[{key:"original",label:de("ui.promptModeOriginal")},{key:"context",label:de("ui.promptModeContext")},{key:"text",label:de("ui.promptModeText")}]}),this.state.promptViewMode==="text"?_.jsx("textarea",{readOnly:!0,className:pe.promptTextarea,value:this.buildTextModeContent()}):_.jsxs("div",{className:pe.promptScrollArea,children:[this.state.promptData.length===0&&_.jsx("div",{className:pe.promptEmpty,children:de("ui.noPrompt")}),this.state.promptData.map((k,R)=>{const M=k.timestamp?new Date(k.timestamp).toLocaleString():de("ui.unknownTime");return _.jsxs("div",{children:[_.jsxs("div",{className:pe.promptTimestamp,children:[M,":"]}),this.state.promptViewMode==="original"?this.renderOriginalPrompt(k):this.renderTextPrompt(k)]},R)})]})]}),_.jsx(n$,{title:de("ui.settings"),placement:"left",width:360,open:this.state.settingsDrawerVisible,onClose:()=>this.setState({settingsDrawerVisible:!1}),children:_.jsxs("div",{className:pe.settingsGroupBox,children:[_.jsx("div",{className:pe.settingsGroupTitle,children:de("ui.chatDisplaySwitches")}),_.jsxs("div",{className:pe.settingsItem,children:[_.jsx("span",{className:pe.settingsLabel,children:de("ui.collapseToolResults")}),_.jsx(fu,{checked:!!h,onChange:k=>p&&p(k)})]}),_.jsxs("div",{className:pe.settingsItem,children:[_.jsx("span",{className:pe.settingsLabel,children:de("ui.expandThinking")}),_.jsx(fu,{checked:!!g,onChange:k=>v&&v(k)})]})]})}),_.jsxs(n$,{title:de("ui.globalSettings"),placement:"left",width:400,open:this.state.globalSettingsVisible,onClose:()=>this.setState({globalSettingsVisible:!1}),children:[_.jsxs("div",{className:pe.settingsItem,children:[_.jsx("span",{className:pe.settingsLabel,children:de("ui.filterIrrelevant")}),_.jsx(fu,{checked:!!y,onChange:k=>Q&&Q(k)})]}),_.jsxs("div",{className:pe.settingsItem,children:[_.jsx("span",{className:pe.settingsLabel,children:de("ui.expandDiff")}),_.jsx(fu,{checked:!!$,onChange:k=>b&&b(k)})]})]}),_.jsx(n$,{title:_.jsxs("span",{children:[_.jsx(B6,{style:{marginRight:8}}),de("ui.projectStats")]}),placement:"left",width:400,open:this.state.projectStatsVisible,onClose:()=>this.setState({projectStatsVisible:!1}),children:this.renderProjectStatsContent()}),_.jsxs(Ci,{title:_.jsxs("span",{children:[_.jsx(Y6,{style:{marginRight:8}}),de("ui.pluginManagement")]}),open:this.state.pluginModalVisible,onCancel:()=>this.setState({pluginModalVisible:!1}),footer:_.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[_.jsx(yn,{icon:_.jsx(H$,{}),onClick:this.handleAddPlugin,children:de("ui.plugins.add")}),_.jsx(yn,{icon:_.jsx(o6,{}),onClick:this.handleReloadPlugins,children:de("ui.plugins.reload")})]}),width:560,children:[this.state.pluginsDir&&_.jsxs("div",{className:pe.pluginDirHint,children:[_.jsxs("span",{style:{color:"#888"},children:[de("ui.plugins.pluginsDir"),":"]})," ",_.jsx("code",{className:pe.pluginDirPath,onClick:()=>{navigator.clipboard.writeText(this.state.pluginsDir).then(()=>{vr.success(de("ui.copied"))}).catch(()=>{})},children:this.state.pluginsDir})]}),this.state.pluginsList.length===0?_.jsxs("div",{className:pe.pluginEmpty,children:[_.jsx("div",{style:{fontSize:14,marginBottom:4},children:de("ui.plugins.empty")}),_.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:12},children:de("ui.plugins.emptyHint")}),_.jsx(yn,{icon:_.jsx(H$,{}),onClick:this.handleAddPlugin,children:de("ui.plugins.add")})]}):_.jsx("div",{className:pe.pluginList,children:this.state.pluginsList.map(k=>_.jsxs("div",{className:pe.pluginItem,children:[_.jsxs("div",{className:pe.pluginInfo,children:[_.jsx("span",{className:pe.pluginName,children:k.name}),_.jsx("span",{className:pe.pluginFile,children:k.file}),k.hooks.length>0&&_.jsx("span",{className:pe.pluginHooks,children:k.hooks.map(R=>_.jsx("span",{className:pe.pluginHookTag,children:R},R))})]}),_.jsxs("div",{className:pe.pluginActions,children:[_.jsx(fu,{size:"small",checked:k.enabled,onChange:R=>this.handleTogglePlugin(k.name,R)}),_.jsx(yn,{type:"text",size:"small",danger:!0,icon:_.jsx(r1,{}),onClick:()=>this.handleDeletePlugin(k.file,k.name)})]})]},k.file))})]}),_.jsx(Ci,{title:de("ui.plugins.delete"),open:this.state.deleteConfirmVisible,onCancel:()=>this.setState({deleteConfirmVisible:!1,deleteTarget:null}),onOk:this.handleDeletePluginConfirm,okType:"danger",okText:"OK",cancelText:"Cancel",children:_.jsx("p",{children:this.state.deleteTarget?de("ui.plugins.deleteConfirm",{name:this.state.deleteTarget.name}):""})}),_.jsx(Ci,{title:_.jsxs("span",{children:[_.jsx(sQ,{style:{marginRight:8}}),de("ui.processManagement")]}),open:this.state.processModalVisible,onCancel:()=>this.setState({processModalVisible:!1}),footer:_.jsx(yn,{icon:_.jsx(o6,{}),onClick:this.fetchProcesses,loading:this.state.processLoading,children:de("ui.processManagement.refresh")}),width:780,children:_.jsx(Yl,{dataSource:this.state.processList,rowKey:"pid",loading:this.state.processLoading,size:"middle",pagination:!1,columns:[{title:de("ui.processManagement.port"),dataIndex:"port",width:80,render:k=>k?_.jsx("a",{href:`${window.location.protocol}//127.0.0.1:${k}`,target:"_blank",rel:"noopener noreferrer",children:k}):""},{title:"PID",dataIndex:"pid",width:80},{title:de("ui.processManagement.command"),dataIndex:"command",ellipsis:!0},{title:de("ui.processManagement.startTime"),dataIndex:"startTime",width:200},{title:de("ui.processManagement.action"),width:100,render:(k,R)=>R.isCurrent?_.jsx(Js,{color:"green",children:de("ui.processManagement.current")}):_.jsx(yn,{size:"small",danger:!0,onClick:()=>this.handleKillProcess(R.pid),children:de("ui.processManagement.kill")})}]})})]})}};Rt(Oh,"COMMAND_TAGS",new Set(["command-name","command-message","command-args","local-command-caveat","local-command-stdout"]));let bP=Oh;const w1e="_centerEmpty_oxhcp_1",P1e="_scrollContainer_oxhcp_8",C1e="_listItem_oxhcp_15",T1e="_listItemActive_oxhcp_27",k1e="_itemContent_oxhcp_36",R1e="_itemHeader_oxhcp_41",E1e="_tagNoMargin_oxhcp_49",X1e="_modelName_oxhcp_54",z1e="_time_oxhcp_58",M1e="_detailRow_oxhcp_64",N1e="_urlText_oxhcp_71",j1e="_duration_oxhcp_80",I1e="_statusOk_oxhcp_85",L1e="_statusErr_oxhcp_91",A1e="_statusDefault_oxhcp_96",W1e="_usageBox_oxhcp_101",V1e="_cacheDot_oxhcp_111",Y1e="_cacheDotLoss_oxhcp_120",B1e="_cacheDotNormal_oxhcp_125",ii={centerEmpty:w1e,scrollContainer:P1e,listItem:C1e,listItemActive:T1e,itemContent:k1e,itemHeader:R1e,tagNoMargin:E1e,modelName:X1e,time:z1e,detailRow:M1e,urlText:N1e,duration:j1e,statusOk:I1e,statusErr:L1e,statusDefault:A1e,usageBox:W1e,cacheDot:V1e,cacheDotLoss:Y1e,cacheDotNormal:B1e};class q1e extends ne.Component{constructor(e){super(e),this.activeItemRef=ne.createRef()}componentDidMount(){this.scrollToSelected(!0)}componentDidUpdate(e){this.props.scrollCenter&&e.selectedIndex!==this.props.selectedIndex?this.scrollToSelected(!0):e.requests!==this.props.requests&&this.scrollToSelected(!1)}scrollToSelected(e){this.activeItemRef.current&&(this.activeItemRef.current.scrollIntoView({block:e?"center":"nearest",behavior:"instant"}),e&&this.props.onScrollDone&&this.props.onScrollDone())}render(){const{requests:e,selectedIndex:n,onSelect:r}=this.props;return e.length===0?_.jsx("div",{className:ii.centerEmpty,children:_.jsx(gs,{description:de("ui.waitingRequests")})}):_.jsx("div",{className:ii.scrollContainer,children:_.jsx(e1,{dataSource:e,size:"small",split:!1,renderItem:(i,s)=>{var x,w,C;const o=new Date(i.timestamp).toLocaleTimeString("zh-CN"),a=s===n,l=i.response&&i.response.status<400,c=i.response&&i.response.status>=400,u=a0e((x=i.body)==null?void 0:x.model),d=s+1<e.length?e[s+1]:null,{type:h,subType:p}=Nd(i,d),g=(C=(w=i.response)==null?void 0:w.body)==null?void 0:C.usage,v=g?(g.input_tokens||0)+(g.cache_read_input_tokens||0)+(g.cache_creation_input_tokens||0):null,$=(g==null?void 0:g.output_tokens)||null,b=(g==null?void 0:g.cache_read_input_tokens)||0,y=(g==null?void 0:g.cache_creation_input_tokens)||0;let Q=i.url;try{const T=new URL(i.url);Q=T.host+T.pathname}catch{}return _.jsx(e1.Item,{ref:a?this.activeItemRef:void 0,onClick:()=>r(s),className:`${ii.listItem} ${a?ii.listItemActive:""}`,children:_.jsxs("div",{className:ii.itemContent,children:[_.jsxs("div",{className:ii.itemHeader,children:[h==="MainAgent"?_.jsx(Js,{color:"orange",className:ii.tagNoMargin,children:"MainAgent"}):h==="Plan"?_.jsx(Js,{className:ii.tagNoMargin,style:{color:"#a33",borderColor:"#a33",backgroundColor:"#000"},children:gP(h,p)}):h==="Count"||h==="Preflight"?_.jsx(Js,{className:ii.tagNoMargin,style:{color:"#666",borderColor:"#444",backgroundColor:"#000"},children:h}):_.jsx(Js,{className:ii.tagNoMargin,children:gP(h,p)}),u&&_.jsx("span",{className:ii.modelName,style:{color:h==="MainAgent"?"#d4822d":"#8c8c8c"},children:u}),_.jsx("span",{className:ii.time,children:o})]}),_.jsxs("div",{className:ii.detailRow,children:[_.jsx("span",{className:ii.urlText,title:i.url,children:Q}),i.duration&&_.jsxs("span",{className:ii.duration,children:[i.duration,"ms"]}),i.response&&_.jsx("span",{className:l?ii.statusOk:c?ii.statusErr:ii.statusDefault,children:i.response.status})]}),g&&_.jsxs("div",{className:ii.usageBox,children:[_.jsxs("div",{children:["token: output:",Rr($)||0,", input: ",Rr(v)||0]}),(b>0||y>0)&&_.jsx("div",{children:(()=>{const T=kW(e,s),z={ttl:"ui.cacheLoss.ttl",system_change:"ui.cacheLoss.systemChange",tools_change:"ui.cacheLoss.toolsChange",model_change:"ui.cacheLoss.modelChange",msg_truncated:"ui.cacheLoss.msgTruncated",msg_modified:"ui.cacheLoss.msgModified",key_change:"ui.cacheLoss.keyChange"};let E;if(T){const A=(T.reasons||[T.reason]).map(X=>de(z[X]||z.key_change)).join(`
|
|
493
493
|
`);E=_.jsx(_c,{title:_.jsx("span",{style:{whiteSpace:"pre-line"},children:A}),children:_.jsx("span",{className:`${ii.cacheDot} ${ii.cacheDotLoss}`})})}else E=_.jsx("span",{className:`${ii.cacheDot} ${ii.cacheDotNormal}`});return _.jsxs(_.Fragment,{children:["cache",E,": ",b>0?`read:${Rr(b)}`:"",b>0&&y>0?", ":"",y>0?`create:${Rr(y)}`:""]})})()})]})]})})}})})}}const U1e=t=>typeof t=="boolean"||t instanceof Boolean,D1e=t=>typeof t=="number"||t instanceof Number,Z1e=t=>typeof t=="bigint"||t instanceof BigInt,DW=t=>!!t&&t instanceof Date,G1e=t=>typeof t=="string"||t instanceof String,F1e=t=>Array.isArray(t),ZW=t=>typeof t=="object"&&t!==null,GW=t=>!!t&&t instanceof Object&&typeof t=="function";function O1(t,e){return e===void 0&&(e=!1),!t||e?`"${t}"`:t}function H1e(t,e,n){return n?JSON.stringify(t):e?`"${t}"`:t}function FW(t){let{field:e,value:n,data:r,lastElement:i,openBracket:s,closeBracket:o,level:a,style:l,shouldExpandNode:c,clickToExpandNode:u,outerRef:d,beforeExpandChange:h}=t;const p=f.useRef(!1),[g,v]=f.useState(()=>c(a,n,e)),$=f.useRef(null);f.useEffect(()=>{p.current?v(c(a,n,e)):p.current=!0},[c]);const b=f.useId();if(r.length===0)return K1e({field:e,openBracket:s,closeBracket:o,lastElement:i,style:l});const y=g?l.collapseIcon:l.expandIcon,Q=g?l.ariaLables.collapseJson:l.ariaLables.expandJson,x=a+1,w=r.length-1,C=E=>{g!==E&&(!h||h({level:a,value:n,field:e,newExpandValue:E}))&&v(E)},T=E=>{if(E.key==="ArrowRight"||E.key==="ArrowLeft")E.preventDefault(),C(E.key==="ArrowRight");else if(E.key==="ArrowUp"||E.key==="ArrowDown"){E.preventDefault();const L=E.key==="ArrowUp"?-1:1;if(!d.current)return;const A=d.current.querySelectorAll("[role=button]");let X=-1;for(let R=0;R<A.length;R++)if(A[R].tabIndex===0){X=R;break}if(X<0)return;const k=(X+L+A.length)%A.length;A[X].tabIndex=-1,A[k].tabIndex=0,A[k].focus()}},z=()=>{var E;C(!g);const L=$.current;if(!L)return;const A=(E=d.current)===null||E===void 0?void 0:E.querySelector('[role=button][tabindex="0"]');A&&(A.tabIndex=-1),L.tabIndex=0,L.focus()};return f.createElement("div",{className:l.basicChildStyle,role:"treeitem","aria-expanded":g,"aria-selected":void 0},f.createElement("span",{className:y,onClick:z,onKeyDown:T,role:"button","aria-label":Q,"aria-expanded":g,"aria-controls":g?b:void 0,ref:$,tabIndex:a===0?0:-1}),(e||e==="")&&(u?f.createElement("span",{className:l.clickableLabel,onClick:z,onKeyDown:T},O1(e,l.quotesForFieldNames),":"):f.createElement("span",{className:l.label},O1(e,l.quotesForFieldNames),":")),f.createElement("span",{className:l.punctuation},s),g?f.createElement("ul",{id:b,role:"group",className:l.childFieldsContainer},r.map((E,L)=>f.createElement(yP,{key:E[0]||L,field:E[0],value:E[1],style:l,lastElement:L===w,level:x,shouldExpandNode:c,clickToExpandNode:u,beforeExpandChange:h,outerRef:d}))):f.createElement("span",{className:l.collapsedContent,onClick:z,onKeyDown:T}),f.createElement("span",{className:l.punctuation},o),!i&&f.createElement("span",{className:l.punctuation},","))}function K1e(t){let{field:e,openBracket:n,closeBracket:r,lastElement:i,style:s}=t;return f.createElement("div",{className:s.basicChildStyle,role:"treeitem","aria-selected":void 0},(e||e==="")&&f.createElement("span",{className:s.label},O1(e,s.quotesForFieldNames),":"),f.createElement("span",{className:s.punctuation},n),f.createElement("span",{className:s.punctuation},r),!i&&f.createElement("span",{className:s.punctuation},","))}function J1e(t){let{field:e,value:n,style:r,lastElement:i,shouldExpandNode:s,clickToExpandNode:o,level:a,outerRef:l,beforeExpandChange:c}=t;return FW({field:e,value:n,lastElement:i||!1,level:a,openBracket:"{",closeBracket:"}",style:r,shouldExpandNode:s,clickToExpandNode:o,data:Object.keys(n).map(u=>[u,n[u]]),outerRef:l,beforeExpandChange:c})}function eSe(t){let{field:e,value:n,style:r,lastElement:i,level:s,shouldExpandNode:o,clickToExpandNode:a,outerRef:l,beforeExpandChange:c}=t;return FW({field:e,value:n,lastElement:i||!1,level:s,openBracket:"[",closeBracket:"]",style:r,shouldExpandNode:o,clickToExpandNode:a,data:n.map(u=>[void 0,u]),outerRef:l,beforeExpandChange:c})}function tSe(t){let{field:e,value:n,style:r,lastElement:i}=t,s,o=r.otherValue;return n===null?(s="null",o=r.nullValue):n===void 0?(s="undefined",o=r.undefinedValue):G1e(n)?(s=H1e(n,!r.noQuotesForStringValues,r.stringifyStringValues),o=r.stringValue):U1e(n)?(s=n?"true":"false",o=r.booleanValue):D1e(n)?(s=n.toString(),o=r.numberValue):Z1e(n)?(s=`${n.toString()}n`,o=r.numberValue):DW(n)?s=n.toISOString():GW(n)?s="function() { }":s=n.toString(),f.createElement("div",{className:r.basicChildStyle,role:"treeitem","aria-selected":void 0},(e||e==="")&&f.createElement("span",{className:r.label},O1(e,r.quotesForFieldNames),":"),f.createElement("span",{className:o},s),!i&&f.createElement("span",{className:r.punctuation},","))}function yP(t){const e=t.value;return F1e(e)?f.createElement(eSe,Object.assign({},t)):ZW(e)&&!DW(e)&&!GW(e)?f.createElement(J1e,Object.assign({},t)):f.createElement(tSe,Object.assign({},t))}var br={"container-light":"_2IvMF _GzYRV","basic-element-style":"_2bkNM","child-fields-container":"_1BXBN","label-light":"_1MGIk","clickable-label-light":"_2YKJg _1MGIk _1MFti","punctuation-light":"_3uHL6 _3eOF8","value-null-light":"_2T6PJ","value-undefined-light":"_1Gho6","value-string-light":"_vGjyY","value-number-light":"_1bQdo","value-boolean-light":"_3zQKs","value-other-light":"_1xvuR","collapse-icon-light":"_oLqym _f10Tu _1MFti _1LId0","expand-icon-light":"_2AXVT _f10Tu _1MFti _1UmXx","collapsed-content-light":"_2KJWg _1pNG9 _1MFti","container-dark":"_11RoI _GzYRV","expand-icon-dark":"_17H2C _f10Tu _1MFti _1UmXx","collapse-icon-dark":"_3QHg2 _f10Tu _1MFti _1LId0","collapsed-content-dark":"_3fDAz _1pNG9 _1MFti","label-dark":"_2bSDX","clickable-label-dark":"_1RQEj _2bSDX _1MFti","punctuation-dark":"_gsbQL _3eOF8","value-null-dark":"_LaAZe","value-undefined-dark":"_GTKgm","value-string-dark":"_Chy1W","value-number-dark":"_2bveF","value-boolean-dark":"_2vRm-","value-other-dark":"_1prJR"};const HW={collapseJson:"collapse JSON",expandJson:"expand JSON"},lQ={container:br["container-light"],basicChildStyle:br["basic-element-style"],childFieldsContainer:br["child-fields-container"],label:br["label-light"],clickableLabel:br["clickable-label-light"],nullValue:br["value-null-light"],undefinedValue:br["value-undefined-light"],stringValue:br["value-string-light"],booleanValue:br["value-boolean-light"],numberValue:br["value-number-light"],otherValue:br["value-other-light"],punctuation:br["punctuation-light"],collapseIcon:br["collapse-icon-light"],expandIcon:br["expand-icon-light"],collapsedContent:br["collapsed-content-light"],noQuotesForStringValues:!1,quotesForFieldNames:!1,ariaLables:HW,stringifyStringValues:!1},nSe={container:br["container-dark"],basicChildStyle:br["basic-element-style"],childFieldsContainer:br["child-fields-container"],label:br["label-dark"],clickableLabel:br["clickable-label-dark"],nullValue:br["value-null-dark"],undefinedValue:br["value-undefined-dark"],stringValue:br["value-string-dark"],booleanValue:br["value-boolean-dark"],numberValue:br["value-number-dark"],otherValue:br["value-other-dark"],punctuation:br["punctuation-dark"],collapseIcon:br["collapse-icon-dark"],expandIcon:br["expand-icon-dark"],collapsedContent:br["collapsed-content-dark"],noQuotesForStringValues:!1,quotesForFieldNames:!1,ariaLables:HW,stringifyStringValues:!1},rSe=()=>!0,iSe=t=>{let{data:e,style:n=lQ,shouldExpandNode:r=rSe,clickToExpandNode:i=!1,beforeExpandChange:s,compactTopLevel:o,...a}=t;const l=f.useRef(null);return f.createElement("div",Object.assign({"aria-label":"JSON view"},a,{className:n.container,ref:l,role:"tree"}),o&&ZW(e)?Object.entries(e).map(c=>{let[u,d]=c;return f.createElement(yP,{key:u,field:u,value:d,style:{...lQ,...n},lastElement:!0,level:1,shouldExpandNode:r,clickToExpandNode:i,beforeExpandChange:s,outerRef:l})}):f.createElement(yP,{value:e,style:{...lQ,...n},lastElement:!0,level:0,shouldExpandNode:r,clickToExpandNode:i,outerRef:l,beforeExpandChange:s}))},sSe="_container_1h2lr_1",oSe={container:sSe},aSe={...nSe,container:"rjv-container"};class h1 extends ne.Component{shouldComponentUpdate(e){return e.data!==this.props.data||e.defaultExpand!==this.props.defaultExpand||e.expandNode!==this.props.expandNode}render(){const{data:e,defaultExpand:n,expandNode:r}=this.props;if(e==null)return null;const i=typeof r=="function"?r:n==="all"?()=>!0:n==="root"?s=>s<2:s=>s<1;return _.jsx("div",{className:oSe.container,children:_.jsx(iSe,{data:e,shouldExpandNode:i,style:aSe})})}}function lSe({currentId:t,visibleIds:e=[],key:n}){if(n!=="ArrowUp"&&n!=="ArrowDown")return null;const r=e.findIndex(s=>s===t),i=n==="ArrowUp"?-1:1;return r>=0?e[r+i]??null:null}const cSe="_tag_17wfp_1",uSe="_tagActive_17wfp_22",dSe="_tagLoading_17wfp_27",OSe="_spinner_17wfp_32",Hv={tag:cSe,tagActive:uSe,tagLoading:dSe,spinner:OSe};function Ok({text:t,onTranslated:e}){const[n,r]=f.useState("idle"),i=f.useRef(null),s=f.useCallback(a=>{if(a.stopPropagation(),n==="loading")return;if(n==="done"){r("idle"),e==null||e(null);return}if(i.current){r("done"),e==null||e(i.current);return}r("loading");const l=window.location.port||"7008",c=`${window.location.protocol}//${window.location.hostname}:${l}`;fetch(`${c}/api/translate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t,to:Qm()})}).then(u=>{if(!u.ok)throw new Error(`HTTP ${u.status}`);return u.json()}).then(u=>{const d=u.text||"";i.current=d,r("done"),e==null||e(d)}).catch(()=>{r("idle")})},[n,t,e]),o=de(n==="loading"?"ui.translating":"ui.translate");return _.jsxs("span",{className:`${Hv.tag} ${n==="done"?Hv.tagActive:""} ${n==="loading"?Hv.tagLoading:""}`,onClick:s,children:[n==="loading"&&_.jsx("span",{className:Hv.spinner}),o]})}const hSe="_root_1a6ku_1",fSe="_sidebar_1a6ku_9",pSe="_section_1a6ku_18",mSe="_sectionHeader_1a6ku_22",gSe="_arrow_1a6ku_48",vSe="_sectionTitle_1a6ku_54",$Se="_sectionCount_1a6ku_62",SSe="_sectionBody_1a6ku_71",bSe="_historyToggle_1a6ku_76",ySe="_historyToggleLabel_1a6ku_102",_Se="_item_1a6ku_107",QSe="_itemActive_1a6ku_133",xSe="_itemContent_1a6ku_143",wSe="_itemLabel_1a6ku_149",PSe="_itemSublabel_1a6ku_157",CSe="_itemTime_1a6ku_166",TSe="_content_1a6ku_175",kSe="_contentEmpty_1a6ku_183",RSe="_contentInner_1a6ku_190",ESe="_emptyWrap_1a6ku_194",XSe="_roleHeader_1a6ku_202",zSe="_roleBadge_1a6ku_210",MSe="_role_user_1a6ku_219",NSe="_role_assistant_1a6ku_225",jSe="_roleLabel_1a6ku_231",ISe="_contentTime_1a6ku_238",LSe="_turnDivider_1a6ku_246",ASe="_textBlock_1a6ku_253",WSe="_textBlockBar_1a6ku_260",VSe="_textBlockBody_1a6ku_269",YSe="_textBlockCompact_1a6ku_277",BSe="_textBlockCompactFloat_1a6ku_284",qSe="_thinkingBlock_1a6ku_291",USe="_thinkingHeader_1a6ku_299",DSe="_thinkingPreview_1a6ku_314",ZSe="_thinkingBody_1a6ku_324",GSe="_toolBlock_1a6ku_330",FSe="_toolBlockResult_1a6ku_337",HSe="_toolBlockError_1a6ku_341",KSe="_toolBlockHeader_1a6ku_345",JSe="_toolBlockBody_1a6ku_356",ebe="_toolName_1a6ku_361",tbe="_toolId_1a6ku_367",nbe="_errorLabel_1a6ku_374",rbe="_blockTag_1a6ku_384",ibe="_blockTagText_1a6ku_397",sbe="_blockTagThinking_1a6ku_403",obe="_blockTagResult_1a6ku_409",abe="_blockTagError_1a6ku_415",lbe="_jsonBlock_1a6ku_422",cbe="_jsonBlockLabel_1a6ku_429",ube="_blockSeparator_1a6ku_439",dbe="_markdownBody_1a6ku_446",At={root:hSe,sidebar:fSe,section:pSe,sectionHeader:mSe,arrow:gSe,sectionTitle:vSe,sectionCount:$Se,sectionBody:SSe,historyToggle:bSe,historyToggleLabel:ySe,item:_Se,itemActive:QSe,itemContent:xSe,itemLabel:wSe,itemSublabel:PSe,itemTime:CSe,content:TSe,contentEmpty:kSe,contentInner:RSe,emptyWrap:ESe,roleHeader:XSe,roleBadge:zSe,role_user:MSe,role_assistant:NSe,roleLabel:jSe,contentTime:ISe,turnDivider:LSe,textBlock:ASe,textBlockBar:WSe,textBlockBody:VSe,textBlockCompact:YSe,textBlockCompactFloat:BSe,thinkingBlock:qSe,thinkingHeader:USe,thinkingPreview:DSe,thinkingBody:ZSe,toolBlock:GSe,toolBlockResult:FSe,toolBlockError:HSe,toolBlockHeader:KSe,toolBlockBody:JSe,toolName:ebe,toolId:tbe,errorLabel:nbe,blockTag:rbe,blockTagText:ibe,blockTagThinking:sbe,blockTagResult:obe,blockTagError:abe,jsonBlock:lbe,jsonBlockLabel:cbe,blockSeparator:ube,markdownBody:dbe},{Text:Obe}=Za;function _P(t){if(t==null)return[];if(typeof t=="string"){const e=t.trim();return e?[{type:"markdown",text:e}]:[]}if(Array.isArray(t)){const e=[];for(const n of t)if(n)if(n.type==="text"){const r=(n.text||"").trim();r&&e.push({type:"markdown",text:r})}else if(n.type==="tool_use")e.push({type:"tool_use",name:n.name||"unknown",id:n.id||"",input:n.input??{}});else if(n.type==="tool_result"){const r=hbe(n.content);e.push({type:"tool_result",tool_use_id:n.tool_use_id||"",is_error:n.is_error,content:r})}else if(n.type==="thinking"){const r=n.thinking||"";r.trim()&&e.push({type:"thinking",text:r})}else n.type==="image"?e.push({type:"json",label:"image",data:n}):e.push({type:"json",label:n.type||"block",data:n});return e}return[{type:"json",label:"content",data:t}]}function hbe(t){if(t==null)return[];if(typeof t=="string"){const e=t.trim();return e?[{type:"markdown",text:e}]:[]}return Array.isArray(t)?t.flatMap(e=>{if(!e)return[];if(e.type==="text"){const n=(e.text||"").trim();return n?[{type:"markdown",text:n}]:[]}return[{type:"json",label:e.type||"block",data:e}]}):[{type:"json",label:"content",data:t}]}function fbe(t){if(!t)return null;if(typeof t=="string")return[{type:"markdown",text:t}];if(Array.isArray(t)){const e=[];return t.forEach((n,r)=>{r>0&&e.push({type:"separator"}),n&&(typeof n=="string"?e.push({type:"markdown",text:n}):n.type==="text"?e.push({type:"markdown",text:n.text||""}):e.push({type:"json",label:n.type||"item",data:n}))}),e}return[{type:"json",label:"system",data:t}]}function pbe(t){const e=[],n=(t==null?void 0:t.name)||"unknown",r=(t==null?void 0:t.description)||"";let i=`### ${n}
|
|
494
494
|
|
|
495
495
|
`;r&&(i+=`${r}
|
package/dist/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<title>Claude Code Viewer</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico?v=1">
|
|
8
8
|
<link rel="shortcut icon" href="/favicon.ico?v=1">
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-CrPveuit.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/index-BfZsj1Gi.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|