claude-code - 💡(How to fix) Fix [BUG] `claude --resume` crashes with "g9H is not a function" when session has existing messages [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#53118Fetched 2026-04-26 05:23:57
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
2
Author
Participants
Timeline (top)
labeled ×5cross-referenced ×1

claude --resume <session-id> crashes immediately when the target session has existing messages. The REPL throws an unhandled error:

ERROR  g9H is not a function. (In 'g9H(K)', 'g9H' is undefined)

Downgrading to 2.1.119 resolves the issue.

Error Message

ERROR g9H is not a function. (In 'g9H(K)', 'g9H' is undefined)

/$bunfs/root/src/entrypoints/cli.js:9251:5663

9248: ${K.join( 9249: 9250)}}var fL3,TkK=1000,JL3=300,ML3=5000;var Bb8=Z(()=>{P_();k_();Np();YI();OkK();__();HV();fL3=(LmH(),E8(ZmH))});var DkK={};J_(DkK,{useScheduledTasks:()=>XL3});function : XL3({isLoading:H,assistantMode:_,setMessages:q}){let K=QD6.useRef(H);K.current=H;let O=B4(),T=F8(),$=Xj();QD6.useEffect(()=>{if(!LR()||C8())return;let A=(w)=>yT({value:PL3.resolveLoopDefaultFire(w),mode:"prompt",priority:"later",isMeta:!0,workload:SEH}),z=void 0,Y=pb8({onFire:A,onFireTask:(w)=>{if(w.agentId){let j=nr(w.agentId,O.getState().tasks);if(j&&!HE(j.status)){OmH(j.id,w.prompt,$);return}y([ScheduledTasks] teammate ${w.agentId} gone, removing orphaned cron ${w.id}),i_H([w.id]);return}let D=hB7(w.kind==="loop"?Claude resuming /loop wakeup (${wkK(new Date)}):Running scheduled task (${wkK(new Date)}));q((j)=>[...j,D]),A(w.prompt)},isLoading:()=>K.current,assistantMode:_,getJitterConfig:s3H,isKilled:()=>!LR(),getExtraTasks:YkK&&z?()=>YkK.getRoutineCronTasks(G5(),z):void 0});return Y.start(),()=>{Y.stop()}},[_,q,O.getState,$])}function wkK(H){return H.toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).replace(/,? at |, /," ").replace(/ ([AP]M)/,(_,q)=>q.toLowerCase())}var QD6,PL3,YkK=null;var jkK=Z(()=>{EE();P_();h8();mZ();qE();DI();CK_();Bb8();YI();__();Uz();D8();q5H();QD6=u(MH(),1),PL3=(LmH(),E8(ZmH))});var XkK={};J_(XkK,{REPL:()=>Ub8});function fkK(H){let _=lD6.c(14),{showAllInTranscript:q,virtualScroll:K,searchBadge:O,suppressShowAll:T,status:$}=H,A=T===void 0?!1:T,z=M1("app:toggleTranscript","Global","ctrl+o"),Y=M1("transcript:toggleShowAll","Transcript","ctrl+e"),w;if(_[0]===Symbol.for("react.memo_cache_sentinel"))w=xQ7(),_[0]=w;else w=_[0];let D=w,j=D?open in ${D}:"open in editor",f;if(_[1]===Symbol.for("react.memo_cache_sentinel"))f=T6.createElement(T6.Fragment,null,"Showing detailed transcript"),_[1]=f;else f=_[1];let J;if(_[2]!==z)J=T6.createElement(T6.Fragment,null,z," to toggle"),_[2]=z,_[3]=J;else J=_[3];let M=O?"n/N to navigate":K?${O_.arrowUp}${O_.arrowDown} scroll \xB7 [ to print output \xB7 v to ${j}:A?v to ${j}:${Y} to ${q?"collapse":"show all"},P;if(_[4]!==J||_[5]!==M)P=T6.createElement(k,{dimColor:!0},T6.createElement(t_,null,f,J,M)),_[4]=J,_[5]=M,_[6]=P;else P=_[6];let X;if(_[7]===Symbol.for("react.memo_cache_sentinel"))X=T6.createElement(p,{flexGrow:1}),_[7]=X;else X=_[7];let R;if(_[8]!==O||_[9]!==$)R=T6.createElement(hL3,{status:$,searchBadge:O}),_[8]=O,_[9]=$,_[10]=R;else R=_[10];let W;if(_[11]!==P||_[12]!==R)W=T6.createElement(p,{noSelect:!0,alignItems:"center",alignSelf:" center",borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:"single",marginTop:1,paddingLeft:2,width:"100%"},P,X,R),_[11]=P,_[12]=R,_[13]=W;else W=_[13];return W}function hL3(H){let _=lD6.c(6),{status:q,searchBadge:K}=H;if(q){let T;if(_[0]!==q)T=T6.createElement(k,null,q," "),_[0]=q,_[1]=T;else T=_[1];return T}if(K){let T;if(_[2]!==K.count||_[3]!==K.current)T=T6.createElement(k,{dimColor:!0},K.current,"/",K.count," "),_[2]=K.count,_[3]=K.current,_[4]=T;else T=_[4];return T}let O;if(_[5]===Symbol.for("react.memo_cache_sentinel"))O=T6.createElement(k,{dimColor:!0},"verbose "),_[5]=O;else O=_[5];return O}function SL3({jumpRef:H,count:_,current:q,onClose:K,onCancel:O,setHighlight: T,initialQuery:$}){let{query:A,cursorOffset:z,handleKeyDown:Y,handlePaste:w}=AG({isActive:!0,initialQuery:$,onExit:()=>K(A),onCancel:O}),[D,j]=s_.useState("building");s_.useEffect(()=>{let P=!0,X=H.current?.warmSearchIndex;if(!X){j(null);return}return j("building"),X().then((R)=>{if(!P)return;if(R<20)j(null);else j({ms:R}),setTimeout(()=>P&&j(null),2000)}),()=>{P=!1}},[]);let f=D!=="building";s_.useEffect(()=>{if(!f)return;H.current?.setSearchQuery(A),T(A)},[A,f]);let J=z,M=J<A.length?A[J]:" ";return T6.createElement(p,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borde rRight:!1,borderStyle:"single",marginTop:1,paddingLeft:2,tabIndex:0,autoFocus:!0,onKeyDown:Y,onPaste:w,width:"100%",noSelect:!0},T6.createElement(k,null,"/"),T6.createElement(k,null,A.slice(0,J)),T6.crea teElement(k,{inverse:!0},M),J<A.length&&T6.createElement(k,null,A.slice(J+1)),T6.createElement(p,{flexGrow:1}),D==="building"?T6.createElement(k,{dimColor:!0},"indexing\u2026 "):D?T6.createElement(k,{dimColor:!0},"indexed in ",D.ms,"ms "):_===0&&A?T6.createElement(k,{color:"error"},"no matches "):_>0?T6.createElement(k,{dimColor:!0},q,"/",_," "):null)}function MkK(H){let _=lD6.c(6),{isAnimating:q,title:K,disabled:O,noPrefix:T}=H,$=IA(),[A,z]=s_.useState(0),Y,w;if(_[0]!==O||_[1]!==q||_[2]!==T||_[3]!==$)Y=()=>{if(O||T||!q||!$)return;let j=setInterval(CL3,EL3,z);return()=>clearInterval(j)},w=[O,T,q,$],_[0]=O,_[1]=q,_[2]=T,_[3]=$,_[4]=Y,_[5]=w;else Y=_[4],w=_[5];s_.useEffect(Y,w);let D=q?PkK[A]??JkK:JkK;return r5H(O?null:T?K:${D} ${K}),null}function CL3(H){return H(bL3)}function bL3(H){return(H+1)%PkK.length}function Ub8({commands:H,debug:_,initialTools:q,initialMessages:K,pendingHookMessages:O,initialFileHistorySnapshots:T,init ialContentReplacements:$,initialAgentName:A,initialAgentColor:z,mcpClients:Y,dynamicMcpConfig:w,autoConnectIdeFlag:D,strictMcpConfig:j=!1,systemPrompt:f,appendSystemPrompt:J,onBeforeQuery:M,onTurnComplet e:P,disabled:X=!1,mainThreadAgentDefinition:R,disableSlashCommands:W=!1,remoteSessionConfig:G,directConnectConfig:L,sshSession:v,thinkingConfig:N}){let h=!!G,C=s_.useMemo(()=>hH(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),S=s_.useMemo(()=>!1,[]),b=s_.useMemo(()=>hH(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]),B=!1;s_.useEffect(()=>{return y([REPL:mount] REPL mounted, disabled=${X}),()=>y("[REPL:unmount] REPL unmounting")},[X]);let[x,E]=s_.useState(R),F=j_((f_)=>f_.toolPermissionContext),g=j_((f_)=>f_.verbose),U=j_((f_)=>f_.mcp),d=j_((f_)=>f_.plugins),i=j_((f_)=>f_.agentDefinitions),n=j_((f_)=>f_.initialMessa ge),o=Es(),_H=j_((f_)=>f_.expandedView)==="tasks",r=j_((f_)=>f_.pendingWorkerRequest),HH=j_((f_)=>f_.pendingSandboxRequest),t=j_((f_)=>f_.teamContext),AH=j_((f_)=>f_.tasks),zH=j_((f_)=>f_.workerSandboxPe rmissions),JH=j_((f_)=>f_.elicitation),s=j_((f_)=>f_.ultraplanPendingChoice),a=j_((f_)=>f_.ultraplanLaunchPending),KH=j_((f_)=>f_.viewingAgentTaskId),e=F8(),$H=KH?AH[KH]:void 0,OH=xJ($H)&&$H.retain&&!$H.diskLoaded;s_.useEffect(()=>{if(!KH||!OH)return;let f_=KH;LTH(hT(f_)).then((r_)=>{e((O6)=>{let Hq=O6.tasks[f_];if(!xJ(Hq)||Hq.diskLoaded||!Hq.retain)return O6;let yq=Hq.messages??[],Y9=new Set(yq.map((l9)=>l9.uuid)),q9=r_?r_.messages.filter((l9)=>!Y9.has(l9.uuid)):[];return{...O6,tasks:{...O6.tasks,[f_]:{...Hq,messages:[...q9,...yq],diskLoaded:!0}}}})})},[KH,OH,e]);let DH=B4(),YH=s_.useMemo(()=>Ty(()=>DH.getState(),e),[DH,e]),PH=s_.useMemo(()=>rGH(()=>DH.getState(),e),[DH,e]),fH=Ni(),GH=Rj(),[kH,WH]=s_.useState(H);R0K(h?void 0:G5(),WH);let LH=j_((f_)=>f_.isBriefOnly),CH=s_.useMemo(()=>tR(F),[F,LH]);qJ7(),KJ7();let[BH,sH]=s_.useState(w),cH=s_.useCallback((f_)=>{sH(f_)},[sH]),[A_,Y_]=s_.useState("prompt"),[ZH,bH]=s_.useState(!1),[mH,xH]=s_.u seState(!1),[aH,rH]=s_.useState(""),nH=s_.useRef(0),QH=s_.useRef(void 0),tH=s_.useRef(!1),{addNotification:L_,removeNotification:B_}=T7(),H6=vL3,c_=M0K(Y,U.clients),[iH,u_]=s_.useState(void 0),[FH,T_]=s_ .useState(null),[vH,oH]=s_.useState(null),[w_,W_]=s_.useState(!1),[TH,jH]=s_.useState(()=>{return!1}),uH=j_((f_)=>f_.showRemoteCallout),[IH,eH]=s_.useState(()=>GGK());OLK(),$LK(),_LK({ideSelection:iH,mcp Clients:c_,ideInstallationStatus:vH}),iGK({mcpClients:c_}),oGK(),NZK(),hZK(),X36(),FZK(GH),XLK(),GLK(),dZK(GH),QZK(),tZK(),rZK(),LL3(),tRK(),YGK(),JGK(),tGK(),DLK();let{recommendation:EH,handleResponse:Z _}=jZK(),{recommendation:D_,handleResponse:Q_}=WZK(),{pending:F_,handleAction:l6,skipForSession:y6}=ZL3(),g8=s_.useMemo(()=>{return[...CH,...q]},[CH,q]);KD6({enabled:!h}),N0K({enabled:!h});let $8=CY7();s_.useEffect(()=>{if(h)return;IZK(e)},[e,h]),s_.useEffect(()=>{let f_=setTimeout(nLK,500);return()=>clearTimeout(f_)},[]),XGK(h?gb8:c_,F.mode),s_.useEffect(()=>{Xy8(F.mode)},[F.mode]),vWK(e,K,{enabled:!h});let wq=QT6(g8,U.tools,F),{tools:T9,allowedAgentTypes:g6}=s_.useMemo(()=>{if(!x)return{tools:wq,allowedAgentTypes:void 0};let f_=vc(x,wq,!1,!0);return{tools:f_.resolvedTools,allowedAgentTypes:f_.allowedAgentTypes}},[x,wq]),J8=s_.useRef(T9);J8.current=T9;let S9=s_.useMemo(()=>{if(!wJ())return T9;let f_=new Set(T9.map((O6)=>O6.name)),r_=n$H().filter((O6)=>!f_.has(O6.name));return r_.length>0?[...T9,...r_]:T9},[T9]),p9=nC8(kH,d.commands),CK=nC8(p9,U.commands),U8=s_.useMemo(()=>W?[]:CK,[W,CK]);vjK(h?gb8:U.cli ents),E0K(h?gb8:U.clients,u_);let[D4,j4]=s_.useState([]),[B1,l5]=s_.useState(null);s_.useEffect(()=>{if(B1&&!B1.isStreaming&&B1.streamingEndedAt){let r_=30000-(Date.now()-B1.streamingEndedAt);if(r_>0){let O6=setTimeout(l5,r_,null);return()=>clearTimeout(O6)}else l5(null)}},[B1]);let[AK,mO]=s_.useState(null),F1=s_.useRef(null);F1.current=AK;let SD=s_.useRef(null),xj=s_.useRef(()=>{}),O5=s_.useRef(()=>{}),vz=s_.useRef(null),eJ=s_.useRef(null),uj=s_.useRef(0),jO=s_.useRef(new ZS8).current,$$=s_.useSyncExternalStore(jO.subscribe,jO.getSnapshot),[T3,S5]=s_.useState(G?.hasInitialPrompt??!1),B7=$$||T3,[fO,q1]=s_.useState(void 0),N3=s_.useRef(0),K1=s_.useRef(!1),JO=s_.useRef(0),$3 =s_.useRef(0),aA=s_.useRef(null),dw=s_.useCallback(()=>{JO.current=Date.now(),$3.current=0,aA.current=null},[]),pf=s_.useRef(!1);if($$&&!pf.current)dw();pf.current=$$;let cY=s_.useCallback((f_)=>{if(S5(f_),f_)dw()},[dw]),sA=s_.useRef(null),ED=s_.useRef(void 0),$A=s_.useRef(void 0),HM=1500,[MO,wT]=s_.useState(!1);s_.useEffect(()=>{if(oq())vY9().then((f_)=>{if(f_)L_({key:"tmux-mouse-hint",text:f_,priority:"low"})});NY9().then((f_)=>{if(f_)L_({key:"tmux-focus-hint",text:f_,priorit y:"low"})})},[]);let[cw,Bf]=s_.useState(!1);s_.useEffect(()=>{},[]);let[X6,Jq]=s_.useState(null),W9=s_.useRef(null),o9=s_.useCallback((f_)=>{if(f_?.isLocalJSXCommand){let{clearLocalJSX:r_,...O6}=f_;W9.cu rrent={...O6,isLocalJSXCommand:!0},Jq(O6);return}if(W9.current){if(f_?.clearLocalJSX){W9.current=null,Jq(null);return}return}if(f_?.clearLocalJSX){Jq(null);return}Jq(f_)},[]),[a9,T5]=s_.useState(()=>new Map),s1=s_.useCallback((f_)=>{T5((r_)=>TRK(r_,f_))},[]),[VK,dq]=s_.useState([]),R9=s_.useMemo(()=>cDK(dq),[dq]),[I4,O4]=s_.useState(null),[Q9,pO]=s_.useState([]),[n4,NA]=s_.useState([]),mj=s_.useRef(new Map),Ff=j_((f_)=>f_.settings.terminalTitleFromRename)!==!1,i3=s_.useSyncExternalStore(My8,()=>Ff?fD(V_()):void 0);s_.useEffect(()=>{return fy8(()=>{let f_=VQH();if(!f_)return;e((r_)=>{if(r_.standaloneAgentContext?.name===f_)return r_;return{...r_,standaloneAgentContext:{...r_.standaloneAgentContext,name:f_}}})})},[e]);let[A7,gf]=s_.useState(),CD=s_.useRef((K?.length??0)>0),TW=x?.agentType,O1=i3??TW??A7??"Claude Code",r3=VK.length>0||n4.length>0||r||HH,V3=X6?.isLocalJSXCommand===!0&&X6?.jsx!=null,bD=s_.useMemo(()=>cK6(AH),[AH]),_M=r3||V3?"waiting":B7||bD?"busy":"idle",QY=s_.useMemo(()=>p$K(AH),[AH]),qM=_M==="idl e"&&QY?"busy":_M,PO=_M==="busy";s_.useEffect(()=>{if(_M==="busy")return yDK(),()=>hDK()},[_M]);let DT=_M!=="waiting"?void 0:VK.length>0?approve ${VK[0].tool.name}:r?"worker request":HH?"sandbox request":V3?"dialog open":"input needed";s_.useEffect(()=>{BC_({status:qM,waitingFor:DT})},[qM,DT]);let lY=yKK(AH),v9=ZQ_();s_.useEffect(()=>{vS7({tasks:lY.count,queued:v9,kinds:lY.kinds})},[lY.count,v9,lY.kinds.join(",")]);let Nz=S_("tengu_terminal_sidebar",!1)&&(h_().showStatusInTerminalTab??!1),Tu=j_((f_)=>f_.postTurnSummary?.status_detail);CU_(C||!Nz?null:_M,Tu),s_.useEffect(()=>{return DL9(R9),()=>jL9()},[R9]);let[E4,sy]=s_.useState(K??[]),A3=s_.useRef(E4),NG=s_.useRef(!1),F7=s_.useCallback((f_)=>{let r_=A3.current,O6=typeof f_==="function"?f_(A3.current):f_;if(A3.current=O6,O6.length<N3.current)N3.current=0,K1.current=!1,q1(void 0);else if(O6.length>r_.length&&K1.current){let Hq=O6.length-r_.length;if((r_.length===0||O6[0]===r_[0]?O6.slice(-Hq):O6.slice(0,Hq)).some(z5_))K1.current=!1;else N3.current=O6.length}sy(O6)},[]),BT=s_.useCallback((f_)=>F7((r_)=>ew6(r_,f_)),[F7]);AGK(s_.useCallback((f_)=>F7((r_)=>[...r_,q6({content:VO6(f_),isMeta:!0})]),[F7]));let y2=s_.useCallback((f_)=>{if(f_!==void 0)N3.current=A3.current.length,K1.current=!0;else K1.current=!1;q1(f_)},[]),{dividerIndex:h2,dividerYRef:$W,onScrollAway:IL,onRepin:AN,jumpToNew:Us,shiftDivider:Qw}= Ee7(E4.length);KGK(E4,F7,B7,uj,!h);let[VG,gH]=s_.useState(null),lH=s_.useRef(VG);lH.current=VG;let o_=s_.useRef(null),H_=s_.useMemo(()=>Ce7(E4,h2),[h2,E4.length]),g_=s_.useCallback((f_=!1,r_="?")=>{if(!f_&&!x3("autoScrollEnabled",!0).value)return;let O6=vz.current;if(O6&&!O6.isSticky())y(repinScroll(${r_}, force=${f_}): yanking from scrollTop=${O6.getScrollTop()} (max=${Math.max(0,O6.getScrollHeight()-O6.getViewportHeight())}));if(O6?.scrollToBottom(),AN(),lH.current!==null)gH(null)},[AN]),h6=E4.at(-1),G6=h6!=null&&z5_(h6);s_.useEffect(()=>{if(G6)g_(!1,"lastMsgI sHuman")},[G6,h6,g_]);let{maybeLoadOlder:I8}=VL3,s8=s_.useCallback((f_,r_)=>{if(uj.current=Date.now(),f_)AN();else IL(r_)},[AN,IL,I8]),v7=zWK(O,F7),[z3,g1]=s_.useState(null);s_.useState(()=>{return zq6(lr6()),null});let w7=s_.useRef(Aq6()),i4=oJ7(),n7=s_.useCallback(()=>wT(!1),[]),k4=hi(n7,HM),B$=s_.useRef(null),R5=s_.useCallback((f_)=>{if(H6(w7.current,f_))return;if(w7.current===""&&f_!==""&&Date. now()-uj.current>=yL3)g_(!1,"typedIntoEmpty");w7.current=f_,zq6(f_),j8H.recordUserActivity(),kwH(!0);let r_=f_.trim().length>0;if(wT(r_),r_)k4();else k4.cancel()},[wT,g_,H6,k4]),[A$,lw]=s_.useState("prompt"),[KM,ty]=s_.useState(),ID=s_.useCallback((f_)=>{let r_=new Set(f_.slash_commands);WH((O6)=>O6.filter((Hq)=>r_.has(Hq.name)||aV8.has(Hq))),e((O6)=>O6.mainLoopModel===f_.model?O6:{...O6,mainLoopModel:f_.model})},[WH,e]),[yG,zN]=s_.useState(new Set),PC=s_.useCallback((f_)=>{zN((r_)=>{switch(f_.action){case"add":{let O6=new Set(r_);for(let Hq of f_.ids)O6.add(Hq);return O6}case"remove":{let O6=new Set(r_);for(let Hq of f_.ids)O6.delete(Hq);return O6.size===r_.size?r_:O6}case"clear":return r_.size>0?new Set:r_}})},[]),S2=s_.useRef(!1),hG=s_.useRef(0),ey=s_.useRef([]),CF=s_.useRef(0),FQ=s_.useCallback((f_)=>{hG.current+=f_;let r_=ey.current;if(f_>0&&r_.length>0){let O6=r_.at(-1);if(O6.outputTokens==null)O6.lastTokenTime=Date.now(),O6.endResponseLength=hG.current}},[]),GLH=s_.useCallback(()=>{hG.current=0},[]),u9H=s_.useCallback((f_)=>{if(f_.type==="start"){let r_=Date.now(),O6=hG.current;ey.current.push({id:f_.id,ttftMs:f_.ttftMs,firstTokenTime:r_,lastTokenTime:r_,responseLengthBaseline:O6,endResponseLength:O6})}else{let r_=f_.id!=null?ey.current.find((O6)=>O6.id===f_.id):ey.current.findLast((O6)=>O6.id==null);if(r_){if(r_.outputTokens=f_.outputTokens,r_.lastTokenTime=Date.now(),f_.id==null)hG.current=Math.max(hG.current ,r_.responseLengthBaseline+f_.outputTokens*4)}}},[]),bF=hXK({config:G,setMessages:F7,setIsLoading:cY,onInit:ID,setToolUseConfirmQueue:R9,tools:g8,setStreamingToolUses:j4,setStreamMode:P$_,setInProgressTo olUseIDs:PC,recordApiMetricsEvent:u9H,permissionMode:F.mode}),ds=bXK({config:L,setMessages:F7,setIsLoading:cY,setToolUseConfirmQueue:R9,tools:g8,permissionMode:F.mode}),IF=uXK({session:v,setMessages:F7,s etIsLoading:cY,setToolUseConfirmQueue:R9,tools:g8,permissionMode:F.mode}),OM=s_.useMemo(()=>IF.isRemoteMode?A56("ssh",IF,!1):ds.isRemoteMode?A56("direct",ds,!1):bF.isRemoteMode?A56("ccr",bF,G?.viewerOnly ??!1,G?.sessionId):O08,[IF,ds,bF,G?.viewerOnly,G?.sessionId]);s_.useEffect(()=>{let f_=OM.isRemoteMode?OM:null,r_=OM.isRemoteMode&&OM.kind==="ccr"?"ccr-api":"local-jsonl",O6=xwH();if(O6.remote!==f_||O6.t ranscriptSource!==r_)zM6({...O6,remote:f_,transcriptSource:r_})},[OM]);let[BO,jP]=s_.useState({}),[XC,m9H]=s_.useState(0),[WC,xL]=s_.useState(null),gQ=!(j_((f_)=>f_.settings.prefersReducedMotion)??!1)&&! PJ9(),RC=s_.useCallback((f_)=>{if(!gQ)return;xL(f_)},[gQ]),k0=WC&&gQ?WC.substring(0,WC.lastIndexOf( 9251 )+1)||null:null,[uL,cs]=s_.useState(0),[Qs,$u]=s_.useState(!1),[QYH,ls]=s_.useState(void : 0),[ns,p9H]=s_.useState(!1),[lYH,YN]=s_.useState(uYH.randomUUID()),[xF,v0]=s_.useState(null),UQ=s_.useCallback((f_)=>{let r_=LDK(f_,GJ);if(r_)v0(r_)},[]),B9H=s_.useRef(uL);B9H.current=uL;let[is]=s_.useState(()=>({current:Yh9(K,$)})),[uF]=s_.useState(()=>({current:vc9(K??[])})),[dQ,TM]=s_.useState(h_().hasAcknowledgedCostThr eshold),[cQ,fP]=s_.useState(!1),[y_,i6]=s_.useState(!1),Pq=s_.useRef("INSERT");s_.useEffect(()=>{if(s&&cQ)fP(!1)},[s,cQ]);let f4=IA(),T4=s_.useRef(f4);T4.current=f4;let[T1]=j9(),fT=s_.useRef(!1),pj=s_.useCallback(()=>{if(fT.current)return;fT.current=!0;let f_=A3.current.slice(lQ.current);for(let r_ of s58(f_))d9H.current.add(r_);lQ.current=A3.current.length,kGK({theme:T1,readFileState:mF.current,bashTools:d9H.current}).then(async(r_)=>{if(r_){let O6=await r_.content({theme:T1});e((Hq)=>({...Hq,spinnerTip:O6})),vGK(r_)}else e((O6)=>{if(O6.spinnerTip===void 0)return O6;return{...O6,spinnerTip:void 0}})})},[e,T1]),XO=s_.useCallback(()=>{cY(!1),y2(void 0),hG.current=0,ey.current=[],CF.current++,xL(null),j4([]),lz8(),P$_("responding"),pj(),ar(),oo_()},[pj]),JP=s_.useMemo(()=>RXH(AH).some((f_)=>f_.status==="running"),[AH]);s_.useEffect(()=>{if(!JP&&sA.cu rrent!==null){let f_=Date.now()-sA.current,r_=ED.current;sA.current=null,ED.current=void 0,F7((O6)=>[...O6,UW8(f_,r_,q8(O6,H9H))])}},[JP,F7]);let AW=s_.useRef(!1);s_.useEffect(()=>{{if(F.mode!=="auto"){AW.current=!1;return}if(AW.current)return;if((h_().autoPermissionsNotificationCount??0)>=3)return;let O6=setTimeout((Hq,yq)=>{Hq.current=!0,a_((Y9)=>{let q9=Y9.autoPermissionsNotificationCount??0;if(q9>=3)return Y9;return{...Y9,autoPermissionsNotificationCount:q9+1}}),yq((Y9)=>[...Y9,OT(jw6,"warning")])},800,AW,F7);return()=>clearTimeout(O6)}},[F.mode,F7]);let BlH=s_.useRef(!1),nYH=s_.useRef(!1);s_.useEffect(()=>{if(nYH.current)return;let f_=HT();if(!f_?.creationDurationMs||f_.usedSparsePaths)return;if(f_.creationDurationMs<15000)return;nYH.current=!0;let r_=Math.round(f_.creationDurationMs/1000);F7((O6)=>[...O6,OT(Worktree creation took ${r_}s. For large repos, set `worktree.sparsePaths` in .claude/settings.json to check out only the directories you need \u2014 e.g. `{"worktree": {"sparsePaths": ["src", "packages/foo"]}}`.,"info")])},[F7]);let{onBeforeQuery:F9H,onTurnComplete:ZLH,onSessionRestored:g9H,render:aM_,ownsInput:LLH}=FXK({enabled:S,setM essages:F7,setInputValue:R5,setToolJSX:o9,resultDedupState:uF.current}),iYH=(!X6||X6.showSpinner===!0)&&VK.length===0&&n4.length===0&&(B7||fO||JP||ZQ_()>0)&&!r&&(!k0||LH),rs=VK.length>0||n4.length>0||Q9. length>0||JH.queue.length>0||zH.queue.length>0;xDK({sandboxHost:Q9[0]?.hostPattern.host,promptTitle:n4[0]?.title,elicitationServer:JH.queue[0]?.serverName,workerSandboxHost:zH.queue[0]?.host});let rYH=vRK({hasActivePrompt:rs,otherSurveyActive:!1}),U9H=yRK(E4,B7,rs,{enabled:!h}),SG=LRK(E4,B7,rs,{enabled:!h,otherSurveyActive:rYH.state!=="closed"||U9H.state!=="closed"}),kLH=MRK(E4,B7,XC,"session",rs, rYH.state!=="closed"||U9H.state!=="closed"||SG.state!=="closed"),mL=ILK(E4,XC),FlH=s_.useMemo(()=>({...kLH,handleSelect:(f_)=>{if(yLH.current=!1,kLH.handleSelect(f_),f_==="bad"&&vLK("feedback_survey_bad" ))c9H("feedback_survey_bad"),yLH.current=!0}}),[kLH]),sM_=GL3(E4,B7,rs,rYH.state!=="closed"||FlH.state!=="closed"||U9H.state!=="closed"||SG.state!=="closed");e0K({autoConnectIdeFlag:D,ideToInstallExtensi on:FH,setDynamicMcpConfig:sH,setShowIdeOnboarding:W_,setIDEInstallationState:oH}),FGK(T,(f_)=>e((r_)=>({...r_,fileHistory:f_})));let tM_=s_.useCallback(async(f_,r_,O6)=>{let Hq=performance.now();try{let yq=E$_(r_.messages),Y9=Fw_();await OGH("resume",{getAppState:()=>DH.getState(),setAppState:e,signal:AbortSignal.timeout(Y9)});let{agentDefinition:q9}=KLH(r_.agentSetting,R,i);E(q9),e((U1)=>({...U1,agent:q9?.agentType}));let l9=await II("resume",{sessionId:f_,agentType:q9?.agentType,model:GH});if(yq.push(...l9),O6==="fork")vF9(r_,WX(f_));else zr_(r_,WX(f_));if(r_.fileHistorySnapshots)K86(r_);if(e((U1)=>({...U1,standaloneAgentContext: YM_(r_.agentName,r_.agentColor)})),Rk(r_.agentName),HP_(yq,r_.projectPath??K8()),O6!=="fork")sYH.current.current=xz_(yq,g8);XO(),mO(null),YN(f_);let _q=fK8(f_);a1_(),SkH(),xG(WX(f_),r_.fullPath?nD6.dirname(r_.fullPath):null);let{renameRecordingForSession:z7}=await Promise.resolve().then(() => (AM_(),B0K));if(await z7(),await eB(),zM_(r_,e),Bw_(),Gs(r_),CD.current=!0,gf(void 0),O6!=="fork")g0K(r_.worktreeSession===void 0?r_.projectPath:r_.worktreeSession?.worktreePath),wM_(r_.worktreeSession,r_.projectPath),Rs(),hY8({abortController:new AbortController,taskRegistry:YH}),$l(MN().map((U1)=>U1.id)),tC8(yq);else{let U1=HT();if(U1)dE(U1)}if(_q)dnH(_q);if(is.current&&O6!=="fork")is.current=Fl_(yq,r_.contentReplacements??[]);if(F7(()=>yq),o9(null),R5(""),O6!=="fork")UQ(yq);c("tengu_session_resumed",{entrypoint:O6,succe ss:!0,resume_duration_ms:Math.round(performance.now()-Hq)})}catch(yq){throw c("tengu_session_resumed",{entrypoint:O6,success:!1,failure_reason:"processing_error",error_name:n6(yq).name}),yq}},[XO,e,YH,UQ]),[QQ]=s_.useState(()=>MI(Sp)),mF=s_.useRef(QQ),d9H=s_.useRef(new Set),lQ=s_.useRef(0),glH=s_.useRef(new Set),UlH=s_.useRef(new Map),vLH=s_.useRef(new Set),oYH=s_.useRef(new Map),NLH=s_.useRef(void 0),aYH=s_.useRef(OOH()),eM_=s_.useRef(f3_()),sYH=s_.useRef(tgH()),HP_=s_.useCallback((f_,r_)=>{let O6=ApH(f_,r_,Sp);mF.current=KxH(mF.current,O6);for(let Hq of s58(f_))d9H.current.add(Hq)},[e]);s_.useEffect(()=>{if(K&&K.length>0)HP_(K,K8()),hY8({abortController:new AbortController,taskRegistry:YH}),tC8(K),UQ(K),sYH.current.current=xz_(K,g8),g9H(K)},[]);let{stat us:_P_,reverify:VLH}=wWK(),[Au,c9H]=s_.useState(null),yLH=s_.useRef(!1),[dlH,clH]=s_.useState(null),[QlH,llH]=s_.useState(!1),nlH=!B7&&ns;function tYH(){if(QlH||dlH)return;if(Qs)return"message-selector";if(MO)return;if(Q9[0])return"sandbox-permission";let f_=!X6||X6.shouldContinueAnimation;if(f_&&VK[0])return"tool-permission";if(f_&&n4[0])return"prompt";if(f_&&zH.queue[0])return"worker-sandbox-permission";if(f_&&JH.queue[0])return"elicitation";if(f_&&nlH) return"cost";if(f_&&xF)return"resume-return";if(f_&&!B7&&s)return"ultraplan-choice";if(f_&&!B7&&a)return"ultraplan-launch";if(vK()){if(f_&&uH)return"remote-callout";return}if(f_&&w_)return"ide-onboarding ";if(f_&&uH)return"remote-callout";if(f_&&EH)return"lsp-recommendation";if(f_&&D_)return"plugin-hint";if(f_&&IH)return"desktop-upsell";return}let JT=tYH(),qP_=MO&&(Q9[0]||VK[0]||n4[0]||zH.queue[0]||JH.queue[0]||nlH);$A.current=JT,s_.useEffect(()=>{if(!B7)return;let f_=JT==="tool-permission",r_=Date.now();if(f_&&aA.current===null)aA.current=r_;else if(!f_&&aA.current!==null)$3.current+=r_-aA.current,aA.current=null},[JT,B7]);let ilH=s_.useRef(JT),FO=s_.useRef(null);s_.useLayoutEffect(()=>{let f_=ilH.current==="tool-permission",r_=JT==="tool-permission";if(ilH.current=JT,f_===r_)return;let O6=vz.current;if(r_)FO.current=O6&&!O6.isSticky()?O6.getScrollTop():null,g_(!0,"permissionDialogAppear");else if(FO.current!==null)O6?.scrollTo(FO.current),FO.current=null;else g_(!0,"permissionDialogDismiss")},[JT,g_]);let os=X6?.jsx!=null,KP_=s_.useRef(os);s_.useLayoutEffect(()=>{if(KP_.current!==os&&(vz.current?.isSticky()??!0))g_(!1,toolJsxDialog\u2192${os});KP_.current=os},[os,g_]);function hLH(){if(JT==="elicitation")return;if(y([onCancel] focusedInputDialog=${JT} streamMode=${Gc.getState().mode}),jO.forceEnd(),WC?.trim())F7((f_)=>[...f_,Pj({content:WC})]);if(XO(),JT==="tool-permission")VK[0]?.onAbort(),R9([]);else if(JT==="prompt"){for(let f_ of n4)f_.reject(Error("Prompt cancelled by user"));NA([]),AK?.abort("user-cancel")}else if(OM.isRemoteMode)OM.cancelRequest();else AK?.abort("user-cancel");mO(null),ZLH(A3.current,!0)}let OP_=s_.useCallback(()=>{let f_=kQ_(w7.current,0);if(!f_)return;if(R5(f_.text),lw("prompt"),f_.images.length>0)jP((r_)=>{let O6={...r_};for(let Hq of f_.images)O6[Hq.id]=Hq;return O6})},[R5,lw,jP]),TP_={setToolUseConfirmQueue:R9,onCancel:hLH,getConnectionSummary:()=>SD.current?.summary(),onAgentsKilled:()=>F7((f_)=>[...f_,EB7()]),isMessageSelectorVisible:Qs||!!cQ,screen:A_,abortSi gnal:AK?.signal,isExternalLoading:T3,popCommandFromQueue:OP_,isLocalJSXCommand:X6?.isLocalJSXCommand,isInputOverlayActive:y_,inputMode:A$,isInputEmpty:i4};s_.useEffect(()=>{if(h)return;if(XP()>=5&&!ns&&! dQ){if(c("tengu_cost_threshold_reached",{}),TM(!0),zE_())p9H(!0)}},[E4,ns,dQ]);let Ej6=s_.useCallback(async(f_)=>{let r_=DH.getState(),{mode:O6,isBypassPermissionsModeAvailable:Hq}=r_.toolPermissionContext;switch(Rk_(O6,Hq)){case"allow":return!0;case"deny":return!1;case"classify":return I86(f_.host,f_.port,A3.current,J8.current,r_.toolPermissionContext,new AbortController().signal);case"ask":break}if(V9()&&E5_()){let Y9=bd9(),q9=await Id9(f_.host,Y9);return new Promise((l9)=>{if(!q9){pO ((_q)=>[..._q,{hostPattern:f_,resolvePromise:l9}]);return}pd9({requestId:Y9,host:f_.host,resolve:l9}),e((_q)=>({..._q,pendingSandboxRequest:{requestId:Y9,host:f_.host}}))})}return new Promise((Y9)=>{let q9=!1;function l9(_q){if(q9)return;q9=!0,Y9(_q)}pO((_q)=>[..._q,{hostPattern:f_,resolvePromise:l9}]);{let _q=DH.getState().replBridgePermissionCallbacks;if(_q){let z7=uYH.randomUUID();_q.sendRequest(z7,hD6,{host:f_.host},uYH.randomUUID(),Allow network connection to ${f_.host}?);let U1=_q.onResponse(z7,(MT)=>{U1();let KY=MT.behavior==="allow";pO((Bj)=>{return Bj.filter((Fj)=>Fj.hostPattern.host===f_.host).forEach((Fj)=>Fj.resolvePromise(KY)),Bj.filter((Fj)=>Fj.hostPattern.host!==f_.host)});let V0=mj.current.get(f_.host);if(V0){for(let Bj of V0)Bj();mj.current.delete(f_.host)}}),nw=()=>{U1(),_q.cancelRequest(z7)},C4=mj.current.get(f_.host)??[];C4.push(nw),mj.current.set(f_.host,C4)}}})},[e,DH]);if(s_.useEffect(()=>{let f_=y8.getSandboxUnavailableReason();if(!f_)return;if(y8.isSandboxRequired()){process.stderr.write( 9252: Error: sandbox required but unavailable: ${f_} 9253: + sandbox.failIfUnavailable is set \u2014 refusing to start without a working sandbox. 9254:

  • <anonymous> (/$bunfs/root/src/entrypoints/cli.js:9251:5663)
  • WC (/$bunfs/root/src/entrypoints/cli.js:492:63749)
  • pj (/$bunfs/root/src/entrypoints/cli.js:492:76948)
  • fT (/$bunfs/root/src/entrypoints/cli.js:492:76827)
  • pj (/$bunfs/root/src/entrypoints/cli.js:492:77745)
  • fT (/$bunfs/root/src/entrypoints/cli.js:492:76827)
  • pj (/$bunfs/root/src/entrypoints/cli.js:492:76926)
  • fT (/$bunfs/root/src/entrypoints/cli.js:492:76827)
  • pj (/$bunfs/root/src/entrypoints/cli.js:492:77745)
  • fT (/$bunfs/root/src/entrypoints/cli.js:492:76827)
  • async <anonymous> (/$bunfs/root/src/entrypoints/cli.js:18815:2361)

Root Cause

Root Cause (analysis)

Fix Action

Workaround

Downgrade to 2.1.119:

npm install -g @anthropic-ai/[email protected]

Code Example

ERROR  g9H is not a function. (In 'g9H(K)', 'g9H' is undefined)

---

ERROR  g9H is not a function. (In 'g9H(K)', 'g9H' is undefined)

 /$bunfs/root/src/entrypoints/cli.js:9251:5663

 9248: ${K.join(`
 9249:
 9250 `)}`}var fL3,TkK=1000,JL3=300,ML3=5000;var Bb8=Z(()=>{P_();k_();Np();YI();OkK();__();HV();fL3=(LmH(),E8(ZmH))});var DkK={};J_(DkK,{useScheduledTasks:()=>XL3});function
 :   XL3({isLoading:H,assistantMode:_,setMessages:q}){let K=QD6.useRef(H);K.current=H;let O=B4(),T=F8(),$=Xj();QD6.useEffect(()=>{if(!LR()||C8())return;let
     A=(w)=>yT({value:PL3.resolveLoopDefaultFire(w),mode:"prompt",priority:"later",isMeta:!0,workload:SEH}),z=void 0,Y=pb8({onFire:A,onFireTask:(w)=>{if(w.agentId){let
     j=nr(w.agentId,O.getState().tasks);if(j&&!HE(j.status)){OmH(j.id,w.prompt,$);return}y(`[ScheduledTasks] teammate ${w.agentId} gone, removing orphaned cron ${w.id}`),i_H([w.id]);return}let
     D=hB7(w.kind==="loop"?`Claude resuming /loop wakeup (${wkK(new Date)})`:`Running scheduled task (${wkK(new
     Date)})`);q((j)=>[...j,D]),A(w.prompt)},isLoading:()=>K.current,assistantMode:_,getJitterConfig:s3H,isKilled:()=>!LR(),getExtraTasks:YkK&&z?()=>YkK.getRoutineCronTasks(G5(),z):void 0});return
     Y.start(),()=>{Y.stop()}},[_,q,O.getState,$])}function wkK(H){return H.toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).replace(/,? at |, /," ").replace(/
     ([AP]M)/,(_,q)=>q.toLowerCase())}var QD6,PL3,YkK=null;var jkK=Z(()=>{EE();P_();h8();mZ();qE();DI();CK_();Bb8();YI();__();Uz();D8();q5H();QD6=u(MH(),1),PL3=(LmH(),E8(ZmH))});var
     XkK={};J_(XkK,{REPL:()=>Ub8});function fkK(H){let _=lD6.c(14),{showAllInTranscript:q,virtualScroll:K,searchBadge:O,suppressShowAll:T,status:$}=H,A=T===void
     0?!1:T,z=M1("app:toggleTranscript","Global","ctrl+o"),Y=M1("transcript:toggleShowAll","Transcript","ctrl+e"),w;if(_[0]===Symbol.for("react.memo_cache_sentinel"))w=xQ7(),_[0]=w;else w=_[0];let
     D=w,j=D?`open in ${D}`:"open in editor",f;if(_[1]===Symbol.for("react.memo_cache_sentinel"))f=T6.createElement(T6.Fragment,null,"Showing detailed transcript"),_[1]=f;else f=_[1];let
     J;if(_[2]!==z)J=T6.createElement(T6.Fragment,null,z," to toggle"),_[2]=z,_[3]=J;else J=_[3];let M=O?"n/N to navigate":K?`${O_.arrowUp}${O_.arrowDown} scroll \xB7 [ to print output \xB7 v to ${j}`:A?`v to
      ${j}`:`${Y} to ${q?"collapse":"show all"}`,P;if(_[4]!==J||_[5]!==M)P=T6.createElement(k,{dimColor:!0},T6.createElement(t_,null,f,J,M)),_[4]=J,_[5]=M,_[6]=P;else P=_[6];let
     X;if(_[7]===Symbol.for("react.memo_cache_sentinel"))X=T6.createElement(p,{flexGrow:1}),_[7]=X;else X=_[7];let
     R;if(_[8]!==O||_[9]!==$)R=T6.createElement(hL3,{status:$,searchBadge:O}),_[8]=O,_[9]=$,_[10]=R;else R=_[10];let W;if(_[11]!==P||_[12]!==R)W=T6.createElement(p,{noSelect:!0,alignItems:"center",alignSelf:"
     center",borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:"single",marginTop:1,paddingLeft:2,width:"100%"},P,X,R),_[11]=P,_[12]=R,_[13]=W;else W=_[13];return W}function
     hL3(H){let _=lD6.c(6),{status:q,searchBadge:K}=H;if(q){let T;if(_[0]!==q)T=T6.createElement(k,null,q," "),_[0]=q,_[1]=T;else T=_[1];return T}if(K){let
     T;if(_[2]!==K.count||_[3]!==K.current)T=T6.createElement(k,{dimColor:!0},K.current,"/",K.count,"  "),_[2]=K.count,_[3]=K.current,_[4]=T;else T=_[4];return T}let
     O;if(_[5]===Symbol.for("react.memo_cache_sentinel"))O=T6.createElement(k,{dimColor:!0},"verbose "),_[5]=O;else O=_[5];return O}function SL3({jumpRef:H,count:_,current:q,onClose:K,onCancel:O,setHighlight:
     T,initialQuery:$}){let{query:A,cursorOffset:z,handleKeyDown:Y,handlePaste:w}=AG({isActive:!0,initialQuery:$,onExit:()=>K(A),onCancel:O}),[D,j]=s_.useState("building");s_.useEffect(()=>{let
     P=!0,X=H.current?.warmSearchIndex;if(!X){j(null);return}return j("building"),X().then((R)=>{if(!P)return;if(R<20)j(null);else j({ms:R}),setTimeout(()=>P&&j(null),2000)}),()=>{P=!1}},[]);let
     f=D!=="building";s_.useEffect(()=>{if(!f)return;H.current?.setSearchQuery(A),T(A)},[A,f]);let J=z,M=J<A.length?A[J]:" ";return T6.createElement(p,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borde
     rRight:!1,borderStyle:"single",marginTop:1,paddingLeft:2,tabIndex:0,autoFocus:!0,onKeyDown:Y,onPaste:w,width:"100%",noSelect:!0},T6.createElement(k,null,"/"),T6.createElement(k,null,A.slice(0,J)),T6.crea
     teElement(k,{inverse:!0},M),J<A.length&&T6.createElement(k,null,A.slice(J+1)),T6.createElement(p,{flexGrow:1}),D==="building"?T6.createElement(k,{dimColor:!0},"indexing\u2026
     "):D?T6.createElement(k,{dimColor:!0},"indexed in ",D.ms,"ms "):_===0&&A?T6.createElement(k,{color:"error"},"no matches "):_>0?T6.createElement(k,{dimColor:!0},q,"/",_,"  "):null)}function MkK(H){let
     _=lD6.c(6),{isAnimating:q,title:K,disabled:O,noPrefix:T}=H,$=IA(),[A,z]=s_.useState(0),Y,w;if(_[0]!==O||_[1]!==q||_[2]!==T||_[3]!==$)Y=()=>{if(O||T||!q||!$)return;let
     j=setInterval(CL3,EL3,z);return()=>clearInterval(j)},w=[O,T,q,$],_[0]=O,_[1]=q,_[2]=T,_[3]=$,_[4]=Y,_[5]=w;else Y=_[4],w=_[5];s_.useEffect(Y,w);let D=q?PkK[A]??JkK:JkK;return r5H(O?null:T?K:`${D}
     ${K}`),null}function CL3(H){return H(bL3)}function bL3(H){return(H+1)%PkK.length}function Ub8({commands:H,debug:_,initialTools:q,initialMessages:K,pendingHookMessages:O,initialFileHistorySnapshots:T,init
     ialContentReplacements:$,initialAgentName:A,initialAgentColor:z,mcpClients:Y,dynamicMcpConfig:w,autoConnectIdeFlag:D,strictMcpConfig:j=!1,systemPrompt:f,appendSystemPrompt:J,onBeforeQuery:M,onTurnComplet
     e:P,disabled:X=!1,mainThreadAgentDefinition:R,disableSlashCommands:W=!1,remoteSessionConfig:G,directConnectConfig:L,sshSession:v,thinkingConfig:N}){let
     h=!!G,C=s_.useMemo(()=>hH(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),S=s_.useMemo(()=>!1,[]),b=s_.useMemo(()=>hH(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]),B=!1;s_.useEffect(()=>{return
      y(`[REPL:mount] REPL mounted, disabled=${X}`),()=>y("[REPL:unmount] REPL
     unmounting")},[X]);let[x,E]=s_.useState(R),F=j_((f_)=>f_.toolPermissionContext),g=j_((f_)=>f_.verbose),U=j_((f_)=>f_.mcp),d=j_((f_)=>f_.plugins),i=j_((f_)=>f_.agentDefinitions),n=j_((f_)=>f_.initialMessa
     ge),o=Es(),_H=j_((f_)=>f_.expandedView)==="tasks",r=j_((f_)=>f_.pendingWorkerRequest),HH=j_((f_)=>f_.pendingSandboxRequest),t=j_((f_)=>f_.teamContext),AH=j_((f_)=>f_.tasks),zH=j_((f_)=>f_.workerSandboxPe
     rmissions),JH=j_((f_)=>f_.elicitation),s=j_((f_)=>f_.ultraplanPendingChoice),a=j_((f_)=>f_.ultraplanLaunchPending),KH=j_((f_)=>f_.viewingAgentTaskId),e=F8(),$H=KH?AH[KH]:void
     0,OH=xJ($H)&&$H.retain&&!$H.diskLoaded;s_.useEffect(()=>{if(!KH||!OH)return;let f_=KH;LTH(hT(f_)).then((r_)=>{e((O6)=>{let Hq=O6.tasks[f_];if(!xJ(Hq)||Hq.diskLoaded||!Hq.retain)return O6;let
     yq=Hq.messages??[],Y9=new
     Set(yq.map((l9)=>l9.uuid)),q9=r_?r_.messages.filter((l9)=>!Y9.has(l9.uuid)):[];return{...O6,tasks:{...O6.tasks,[f_]:{...Hq,messages:[...q9,...yq],diskLoaded:!0}}}})})},[KH,OH,e]);let
     DH=B4(),YH=s_.useMemo(()=>Ty(()=>DH.getState(),e),[DH,e]),PH=s_.useMemo(()=>rGH(()=>DH.getState(),e),[DH,e]),fH=Ni(),GH=Rj(),[kH,WH]=s_.useState(H);R0K(h?void 0:G5(),WH);let
     LH=j_((f_)=>f_.isBriefOnly),CH=s_.useMemo(()=>tR(F),[F,LH]);qJ7(),KJ7();let[BH,sH]=s_.useState(w),cH=s_.useCallback((f_)=>{sH(f_)},[sH]),[A_,Y_]=s_.useState("prompt"),[ZH,bH]=s_.useState(!1),[mH,xH]=s_.u
     seState(!1),[aH,rH]=s_.useState(""),nH=s_.useRef(0),QH=s_.useRef(void 0),tH=s_.useRef(!1),{addNotification:L_,removeNotification:B_}=T7(),H6=vL3,c_=M0K(Y,U.clients),[iH,u_]=s_.useState(void 0),[FH,T_]=s_
     .useState(null),[vH,oH]=s_.useState(null),[w_,W_]=s_.useState(!1),[TH,jH]=s_.useState(()=>{return!1}),uH=j_((f_)=>f_.showRemoteCallout),[IH,eH]=s_.useState(()=>GGK());OLK(),$LK(),_LK({ideSelection:iH,mcp
     Clients:c_,ideInstallationStatus:vH}),iGK({mcpClients:c_}),oGK(),NZK(),hZK(),X36(),FZK(GH),XLK(),GLK(),dZK(GH),QZK(),tZK(),rZK(),LL3(),tRK(),YGK(),JGK(),tGK(),DLK();let{recommendation:EH,handleResponse:Z
     _}=jZK(),{recommendation:D_,handleResponse:Q_}=WZK(),{pending:F_,handleAction:l6,skipForSession:y6}=ZL3(),g8=s_.useMemo(()=>{return[...CH,...q]},[CH,q]);KD6({enabled:!h}),N0K({enabled:!h});let
     $8=CY7();s_.useEffect(()=>{if(h)return;IZK(e)},[e,h]),s_.useEffect(()=>{let
     f_=setTimeout(nLK,500);return()=>clearTimeout(f_)},[]),XGK(h?gb8:c_,F.mode),s_.useEffect(()=>{Xy8(F.mode)},[F.mode]),vWK(e,K,{enabled:!h});let
     wq=QT6(g8,U.tools,F),{tools:T9,allowedAgentTypes:g6}=s_.useMemo(()=>{if(!x)return{tools:wq,allowedAgentTypes:void 0};let
     f_=vc(x,wq,!1,!0);return{tools:f_.resolvedTools,allowedAgentTypes:f_.allowedAgentTypes}},[x,wq]),J8=s_.useRef(T9);J8.current=T9;let S9=s_.useMemo(()=>{if(!wJ())return T9;let f_=new
     Set(T9.map((O6)=>O6.name)),r_=n$H().filter((O6)=>!f_.has(O6.name));return r_.length>0?[...T9,...r_]:T9},[T9]),p9=nC8(kH,d.commands),CK=nC8(p9,U.commands),U8=s_.useMemo(()=>W?[]:CK,[W,CK]);vjK(h?gb8:U.cli
     ents),E0K(h?gb8:U.clients,u_);let[D4,j4]=s_.useState([]),[B1,l5]=s_.useState(null);s_.useEffect(()=>{if(B1&&!B1.isStreaming&&B1.streamingEndedAt){let
     r_=30000-(Date.now()-B1.streamingEndedAt);if(r_>0){let O6=setTimeout(l5,r_,null);return()=>clearTimeout(O6)}else l5(null)}},[B1]);let[AK,mO]=s_.useState(null),F1=s_.useRef(null);F1.current=AK;let
     SD=s_.useRef(null),xj=s_.useRef(()=>{}),O5=s_.useRef(()=>{}),vz=s_.useRef(null),eJ=s_.useRef(null),uj=s_.useRef(0),jO=s_.useRef(new
     ZS8).current,$$=s_.useSyncExternalStore(jO.subscribe,jO.getSnapshot),[T3,S5]=s_.useState(G?.hasInitialPrompt??!1),B7=$$||T3,[fO,q1]=s_.useState(void 0),N3=s_.useRef(0),K1=s_.useRef(!1),JO=s_.useRef(0),$3
     =s_.useRef(0),aA=s_.useRef(null),dw=s_.useCallback(()=>{JO.current=Date.now(),$3.current=0,aA.current=null},[]),pf=s_.useRef(!1);if($$&&!pf.current)dw();pf.current=$$;let
     cY=s_.useCallback((f_)=>{if(S5(f_),f_)dw()},[dw]),sA=s_.useRef(null),ED=s_.useRef(void 0),$A=s_.useRef(void
     0),HM=1500,[MO,wT]=s_.useState(!1);s_.useEffect(()=>{if(oq())vY9().then((f_)=>{if(f_)L_({key:"tmux-mouse-hint",text:f_,priority:"low"})});NY9().then((f_)=>{if(f_)L_({key:"tmux-focus-hint",text:f_,priorit
     y:"low"})})},[]);let[cw,Bf]=s_.useState(!1);s_.useEffect(()=>{},[]);let[X6,Jq]=s_.useState(null),W9=s_.useRef(null),o9=s_.useCallback((f_)=>{if(f_?.isLocalJSXCommand){let{clearLocalJSX:r_,...O6}=f_;W9.cu
     rrent={...O6,isLocalJSXCommand:!0},Jq(O6);return}if(W9.current){if(f_?.clearLocalJSX){W9.current=null,Jq(null);return}return}if(f_?.clearLocalJSX){Jq(null);return}Jq(f_)},[]),[a9,T5]=s_.useState(()=>new
     Map),s1=s_.useCallback((f_)=>{T5((r_)=>TRK(r_,f_))},[]),[VK,dq]=s_.useState([]),R9=s_.useMemo(()=>cDK(dq),[dq]),[I4,O4]=s_.useState(null),[Q9,pO]=s_.useState([]),[n4,NA]=s_.useState([]),mj=s_.useRef(new
     Map),Ff=j_((f_)=>f_.settings.terminalTitleFromRename)!==!1,i3=s_.useSyncExternalStore(My8,()=>Ff?fD(V_()):void 0);s_.useEffect(()=>{return fy8(()=>{let
     f_=VQH();if(!f_)return;e((r_)=>{if(r_.standaloneAgentContext?.name===f_)return
     r_;return{...r_,standaloneAgentContext:{...r_.standaloneAgentContext,name:f_}}})})},[e]);let[A7,gf]=s_.useState(),CD=s_.useRef((K?.length??0)>0),TW=x?.agentType,O1=i3??TW??A7??"Claude
     Code",r3=VK.length>0||n4.length>0||r||HH,V3=X6?.isLocalJSXCommand===!0&&X6?.jsx!=null,bD=s_.useMemo(()=>cK6(AH),[AH]),_M=r3||V3?"waiting":B7||bD?"busy":"idle",QY=s_.useMemo(()=>p$K(AH),[AH]),qM=_M==="idl
     e"&&QY?"busy":_M,PO=_M==="busy";s_.useEffect(()=>{if(_M==="busy")return yDK(),()=>hDK()},[_M]);let DT=_M!=="waiting"?void 0:VK.length>0?`approve ${VK[0].tool.name}`:r?"worker request":HH?"sandbox
     request":V3?"dialog open":"input needed";s_.useEffect(()=>{BC_({status:qM,waitingFor:DT})},[qM,DT]);let
     lY=yKK(AH),v9=ZQ_();s_.useEffect(()=>{vS7({tasks:lY.count,queued:v9,kinds:lY.kinds})},[lY.count,v9,lY.kinds.join(",")]);let
     Nz=S_("tengu_terminal_sidebar",!1)&&(h_().showStatusInTerminalTab??!1),Tu=j_((f_)=>f_.postTurnSummary?.status_detail);CU_(C||!Nz?null:_M,Tu),s_.useEffect(()=>{return
     DL9(R9),()=>jL9()},[R9]);let[E4,sy]=s_.useState(K??[]),A3=s_.useRef(E4),NG=s_.useRef(!1),F7=s_.useCallback((f_)=>{let r_=A3.current,O6=typeof
     f_==="function"?f_(A3.current):f_;if(A3.current=O6,O6.length<N3.current)N3.current=0,K1.current=!1,q1(void 0);else if(O6.length>r_.length&&K1.current){let
     Hq=O6.length-r_.length;if((r_.length===0||O6[0]===r_[0]?O6.slice(-Hq):O6.slice(0,Hq)).some(z5_))K1.current=!1;else
     N3.current=O6.length}sy(O6)},[]),BT=s_.useCallback((f_)=>F7((r_)=>ew6(r_,f_)),[F7]);AGK(s_.useCallback((f_)=>F7((r_)=>[...r_,q6({content:VO6(f_),isMeta:!0})]),[F7]));let
     y2=s_.useCallback((f_)=>{if(f_!==void 0)N3.current=A3.current.length,K1.current=!0;else K1.current=!1;q1(f_)},[]),{dividerIndex:h2,dividerYRef:$W,onScrollAway:IL,onRepin:AN,jumpToNew:Us,shiftDivider:Qw}=
     Ee7(E4.length);KGK(E4,F7,B7,uj,!h);let[VG,gH]=s_.useState(null),lH=s_.useRef(VG);lH.current=VG;let
     o_=s_.useRef(null),H_=s_.useMemo(()=>Ce7(E4,h2),[h2,E4.length]),g_=s_.useCallback((f_=!1,r_="?")=>{if(!f_&&!x3("autoScrollEnabled",!0).value)return;let
     O6=vz.current;if(O6&&!O6.isSticky())y(`repinScroll(${r_}, force=${f_}): yanking from scrollTop=${O6.getScrollTop()}
     (max=${Math.max(0,O6.getScrollHeight()-O6.getViewportHeight())})`);if(O6?.scrollToBottom(),AN(),lH.current!==null)gH(null)},[AN]),h6=E4.at(-1),G6=h6!=null&&z5_(h6);s_.useEffect(()=>{if(G6)g_(!1,"lastMsgI
     sHuman")},[G6,h6,g_]);let{maybeLoadOlder:I8}=VL3,s8=s_.useCallback((f_,r_)=>{if(uj.current=Date.now(),f_)AN();else IL(r_)},[AN,IL,I8]),v7=zWK(O,F7),[z3,g1]=s_.useState(null);s_.useState(()=>{return
     zq6(lr6()),null});let w7=s_.useRef(Aq6()),i4=oJ7(),n7=s_.useCallback(()=>wT(!1),[]),k4=hi(n7,HM),B$=s_.useRef(null),R5=s_.useCallback((f_)=>{if(H6(w7.current,f_))return;if(w7.current===""&&f_!==""&&Date.
     now()-uj.current>=yL3)g_(!1,"typedIntoEmpty");w7.current=f_,zq6(f_),j8H.recordUserActivity(),kwH(!0);let r_=f_.trim().length>0;if(wT(r_),r_)k4();else
     k4.cancel()},[wT,g_,H6,k4]),[A$,lw]=s_.useState("prompt"),[KM,ty]=s_.useState(),ID=s_.useCallback((f_)=>{let r_=new
     Set(f_.slash_commands);WH((O6)=>O6.filter((Hq)=>r_.has(Hq.name)||aV8.has(Hq))),e((O6)=>O6.mainLoopModel===f_.model?O6:{...O6,mainLoopModel:f_.model})},[WH,e]),[yG,zN]=s_.useState(new
     Set),PC=s_.useCallback((f_)=>{zN((r_)=>{switch(f_.action){case"add":{let O6=new Set(r_);for(let Hq of f_.ids)O6.add(Hq);return O6}case"remove":{let O6=new Set(r_);for(let Hq of
     f_.ids)O6.delete(Hq);return O6.size===r_.size?r_:O6}case"clear":return r_.size>0?new
     Set:r_}})},[]),S2=s_.useRef(!1),hG=s_.useRef(0),ey=s_.useRef([]),CF=s_.useRef(0),FQ=s_.useCallback((f_)=>{hG.current+=f_;let r_=ey.current;if(f_>0&&r_.length>0){let
     O6=r_.at(-1);if(O6.outputTokens==null)O6.lastTokenTime=Date.now(),O6.endResponseLength=hG.current}},[]),GLH=s_.useCallback(()=>{hG.current=0},[]),u9H=s_.useCallback((f_)=>{if(f_.type==="start"){let
     r_=Date.now(),O6=hG.current;ey.current.push({id:f_.id,ttftMs:f_.ttftMs,firstTokenTime:r_,lastTokenTime:r_,responseLengthBaseline:O6,endResponseLength:O6})}else{let
     r_=f_.id!=null?ey.current.find((O6)=>O6.id===f_.id):ey.current.findLast((O6)=>O6.id==null);if(r_){if(r_.outputTokens=f_.outputTokens,r_.lastTokenTime=Date.now(),f_.id==null)hG.current=Math.max(hG.current
     ,r_.responseLengthBaseline+f_.outputTokens*4)}}},[]),bF=hXK({config:G,setMessages:F7,setIsLoading:cY,onInit:ID,setToolUseConfirmQueue:R9,tools:g8,setStreamingToolUses:j4,setStreamMode:P$_,setInProgressTo
     olUseIDs:PC,recordApiMetricsEvent:u9H,permissionMode:F.mode}),ds=bXK({config:L,setMessages:F7,setIsLoading:cY,setToolUseConfirmQueue:R9,tools:g8,permissionMode:F.mode}),IF=uXK({session:v,setMessages:F7,s
     etIsLoading:cY,setToolUseConfirmQueue:R9,tools:g8,permissionMode:F.mode}),OM=s_.useMemo(()=>IF.isRemoteMode?A56("ssh",IF,!1):ds.isRemoteMode?A56("direct",ds,!1):bF.isRemoteMode?A56("ccr",bF,G?.viewerOnly
     ??!1,G?.sessionId):O08,[IF,ds,bF,G?.viewerOnly,G?.sessionId]);s_.useEffect(()=>{let f_=OM.isRemoteMode?OM:null,r_=OM.isRemoteMode&&OM.kind==="ccr"?"ccr-api":"local-jsonl",O6=xwH();if(O6.remote!==f_||O6.t
     ranscriptSource!==r_)zM6({...O6,remote:f_,transcriptSource:r_})},[OM]);let[BO,jP]=s_.useState({}),[XC,m9H]=s_.useState(0),[WC,xL]=s_.useState(null),gQ=!(j_((f_)=>f_.settings.prefersReducedMotion)??!1)&&!
     PJ9(),RC=s_.useCallback((f_)=>{if(!gQ)return;xL(f_)},[gQ]),k0=WC&&gQ?WC.substring(0,WC.lastIndexOf(`
 9251 `)+1)||null:null,[uL,cs]=s_.useState(0),[Qs,$u]=s_.useState(!1),[QYH,ls]=s_.useState(void
 :   0),[ns,p9H]=s_.useState(!1),[lYH,YN]=s_.useState(uYH.randomUUID()),[xF,v0]=s_.useState(null),UQ=s_.useCallback((f_)=>{let
     r_=LDK(f_,GJ);if(r_)v0(r_)},[]),B9H=s_.useRef(uL);B9H.current=uL;let[is]=s_.useState(()=>({current:Yh9(K,$)})),[uF]=s_.useState(()=>({current:vc9(K??[])})),[dQ,TM]=s_.useState(h_().hasAcknowledgedCostThr
     eshold),[cQ,fP]=s_.useState(!1),[y_,i6]=s_.useState(!1),Pq=s_.useRef("INSERT");s_.useEffect(()=>{if(s&&cQ)fP(!1)},[s,cQ]);let
     f4=IA(),T4=s_.useRef(f4);T4.current=f4;let[T1]=j9(),fT=s_.useRef(!1),pj=s_.useCallback(()=>{if(fT.current)return;fT.current=!0;let f_=A3.current.slice(lQ.current);for(let r_ of
     s58(f_))d9H.current.add(r_);lQ.current=A3.current.length,kGK({theme:T1,readFileState:mF.current,bashTools:d9H.current}).then(async(r_)=>{if(r_){let O6=await
     r_.content({theme:T1});e((Hq)=>({...Hq,spinnerTip:O6})),vGK(r_)}else e((O6)=>{if(O6.spinnerTip===void 0)return O6;return{...O6,spinnerTip:void 0}})})},[e,T1]),XO=s_.useCallback(()=>{cY(!1),y2(void
     0),hG.current=0,ey.current=[],CF.current++,xL(null),j4([]),lz8(),P$_("responding"),pj(),ar(),oo_()},[pj]),JP=s_.useMemo(()=>RXH(AH).some((f_)=>f_.status==="running"),[AH]);s_.useEffect(()=>{if(!JP&&sA.cu
     rrent!==null){let f_=Date.now()-sA.current,r_=ED.current;sA.current=null,ED.current=void 0,F7((O6)=>[...O6,UW8(f_,r_,q8(O6,H9H))])}},[JP,F7]);let
     AW=s_.useRef(!1);s_.useEffect(()=>{{if(F.mode!=="auto"){AW.current=!1;return}if(AW.current)return;if((h_().autoPermissionsNotificationCount??0)>=3)return;let
     O6=setTimeout((Hq,yq)=>{Hq.current=!0,a_((Y9)=>{let q9=Y9.autoPermissionsNotificationCount??0;if(q9>=3)return
     Y9;return{...Y9,autoPermissionsNotificationCount:q9+1}}),yq((Y9)=>[...Y9,OT(jw6,"warning")])},800,AW,F7);return()=>clearTimeout(O6)}},[F.mode,F7]);let
     BlH=s_.useRef(!1),nYH=s_.useRef(!1);s_.useEffect(()=>{if(nYH.current)return;let f_=HT();if(!f_?.creationDurationMs||f_.usedSparsePaths)return;if(f_.creationDurationMs<15000)return;nYH.current=!0;let
     r_=Math.round(f_.creationDurationMs/1000);F7((O6)=>[...O6,OT(`Worktree creation took ${r_}s. For large repos, set \`worktree.sparsePaths\` in .claude/settings.json to check out only the directories you
     need \u2014 e.g. \`{"worktree": {"sparsePaths": ["src", "packages/foo"]}}\`.`,"info")])},[F7]);let{onBeforeQuery:F9H,onTurnComplete:ZLH,onSessionRestored:g9H,render:aM_,ownsInput:LLH}=FXK({enabled:S,setM
     essages:F7,setInputValue:R5,setToolJSX:o9,resultDedupState:uF.current}),iYH=(!X6||X6.showSpinner===!0)&&VK.length===0&&n4.length===0&&(B7||fO||JP||ZQ_()>0)&&!r&&(!k0||LH),rs=VK.length>0||n4.length>0||Q9.
     length>0||JH.queue.length>0||zH.queue.length>0;xDK({sandboxHost:Q9[0]?.hostPattern.host,promptTitle:n4[0]?.title,elicitationServer:JH.queue[0]?.serverName,workerSandboxHost:zH.queue[0]?.host});let
     rYH=vRK({hasActivePrompt:rs,otherSurveyActive:!1}),U9H=yRK(E4,B7,rs,{enabled:!h}),SG=LRK(E4,B7,rs,{enabled:!h,otherSurveyActive:rYH.state!=="closed"||U9H.state!=="closed"}),kLH=MRK(E4,B7,XC,"session",rs,
     rYH.state!=="closed"||U9H.state!=="closed"||SG.state!=="closed"),mL=ILK(E4,XC),FlH=s_.useMemo(()=>({...kLH,handleSelect:(f_)=>{if(yLH.current=!1,kLH.handleSelect(f_),f_==="bad"&&vLK("feedback_survey_bad"
     ))c9H("feedback_survey_bad"),yLH.current=!0}}),[kLH]),sM_=GL3(E4,B7,rs,rYH.state!=="closed"||FlH.state!=="closed"||U9H.state!=="closed"||SG.state!=="closed");e0K({autoConnectIdeFlag:D,ideToInstallExtensi
     on:FH,setDynamicMcpConfig:sH,setShowIdeOnboarding:W_,setIDEInstallationState:oH}),FGK(T,(f_)=>e((r_)=>({...r_,fileHistory:f_})));let tM_=s_.useCallback(async(f_,r_,O6)=>{let Hq=performance.now();try{let
     yq=E$_(r_.messages),Y9=Fw_();await
     OGH("resume",{getAppState:()=>DH.getState(),setAppState:e,signal:AbortSignal.timeout(Y9)});let{agentDefinition:q9}=KLH(r_.agentSetting,R,i);E(q9),e((U1)=>({...U1,agent:q9?.agentType}));let l9=await
     II("resume",{sessionId:f_,agentType:q9?.agentType,model:GH});if(yq.push(...l9),O6==="fork")vF9(r_,WX(f_));else zr_(r_,WX(f_));if(r_.fileHistorySnapshots)K86(r_);if(e((U1)=>({...U1,standaloneAgentContext:
     YM_(r_.agentName,r_.agentColor)})),Rk(r_.agentName),HP_(yq,r_.projectPath??K8()),O6!=="fork")sYH.current.current=xz_(yq,g8);XO(),mO(null),YN(f_);let
     _q=fK8(f_);a1_(),SkH(),xG(WX(f_),r_.fullPath?nD6.dirname(r_.fullPath):null);let{renameRecordingForSession:z7}=await Promise.resolve().then(() => (AM_(),B0K));if(await z7(),await
     eB(),zM_(r_,e),Bw_(),Gs(r_),CD.current=!0,gf(void 0),O6!=="fork")g0K(r_.worktreeSession===void
     0?r_.projectPath:r_.worktreeSession?.worktreePath),wM_(r_.worktreeSession,r_.projectPath),Rs(),hY8({abortController:new AbortController,taskRegistry:YH}),$l(MN().map((U1)=>U1.id)),tC8(yq);else{let
     U1=HT();if(U1)dE(U1)}if(_q)dnH(_q);if(is.current&&O6!=="fork")is.current=Fl_(yq,r_.contentReplacements??[]);if(F7(()=>yq),o9(null),R5(""),O6!=="fork")UQ(yq);c("tengu_session_resumed",{entrypoint:O6,succe
     ss:!0,resume_duration_ms:Math.round(performance.now()-Hq)})}catch(yq){throw
     c("tengu_session_resumed",{entrypoint:O6,success:!1,failure_reason:"processing_error",error_name:n6(yq).name}),yq}},[XO,e,YH,UQ]),[QQ]=s_.useState(()=>MI(Sp)),mF=s_.useRef(QQ),d9H=s_.useRef(new
     Set),lQ=s_.useRef(0),glH=s_.useRef(new Set),UlH=s_.useRef(new Map),vLH=s_.useRef(new Set),oYH=s_.useRef(new Map),NLH=s_.useRef(void
     0),aYH=s_.useRef(OOH()),eM_=s_.useRef(f3_()),sYH=s_.useRef(tgH()),HP_=s_.useCallback((f_,r_)=>{let O6=ApH(f_,r_,Sp);mF.current=KxH(mF.current,O6);for(let Hq of
     s58(f_))d9H.current.add(Hq)},[e]);s_.useEffect(()=>{if(K&&K.length>0)HP_(K,K8()),hY8({abortController:new AbortController,taskRegistry:YH}),tC8(K),UQ(K),sYH.current.current=xz_(K,g8),g9H(K)},[]);let{stat
     us:_P_,reverify:VLH}=wWK(),[Au,c9H]=s_.useState(null),yLH=s_.useRef(!1),[dlH,clH]=s_.useState(null),[QlH,llH]=s_.useState(!1),nlH=!B7&&ns;function
     tYH(){if(QlH||dlH)return;if(Qs)return"message-selector";if(MO)return;if(Q9[0])return"sandbox-permission";let
     f_=!X6||X6.shouldContinueAnimation;if(f_&&VK[0])return"tool-permission";if(f_&&n4[0])return"prompt";if(f_&&zH.queue[0])return"worker-sandbox-permission";if(f_&&JH.queue[0])return"elicitation";if(f_&&nlH)
     return"cost";if(f_&&xF)return"resume-return";if(f_&&!B7&&s)return"ultraplan-choice";if(f_&&!B7&&a)return"ultraplan-launch";if(vK()){if(f_&&uH)return"remote-callout";return}if(f_&&w_)return"ide-onboarding
     ";if(f_&&uH)return"remote-callout";if(f_&&EH)return"lsp-recommendation";if(f_&&D_)return"plugin-hint";if(f_&&IH)return"desktop-upsell";return}let
     JT=tYH(),qP_=MO&&(Q9[0]||VK[0]||n4[0]||zH.queue[0]||JH.queue[0]||nlH);$A.current=JT,s_.useEffect(()=>{if(!B7)return;let f_=JT==="tool-permission",r_=Date.now();if(f_&&aA.current===null)aA.current=r_;else
      if(!f_&&aA.current!==null)$3.current+=r_-aA.current,aA.current=null},[JT,B7]);let ilH=s_.useRef(JT),FO=s_.useRef(null);s_.useLayoutEffect(()=>{let
     f_=ilH.current==="tool-permission",r_=JT==="tool-permission";if(ilH.current=JT,f_===r_)return;let
     O6=vz.current;if(r_)FO.current=O6&&!O6.isSticky()?O6.getScrollTop():null,g_(!0,"permissionDialogAppear");else if(FO.current!==null)O6?.scrollTo(FO.current),FO.current=null;else
     g_(!0,"permissionDialogDismiss")},[JT,g_]);let
     os=X6?.jsx!=null,KP_=s_.useRef(os);s_.useLayoutEffect(()=>{if(KP_.current!==os&&(vz.current?.isSticky()??!0))g_(!1,`toolJsxDialog\u2192${os}`);KP_.current=os},[os,g_]);function
     hLH(){if(JT==="elicitation")return;if(y(`[onCancel] focusedInputDialog=${JT}
     streamMode=${Gc.getState().mode}`),jO.forceEnd(),WC?.trim())F7((f_)=>[...f_,Pj({content:WC})]);if(XO(),JT==="tool-permission")VK[0]?.onAbort(),R9([]);else if(JT==="prompt"){for(let f_ of
     n4)f_.reject(Error("Prompt cancelled by user"));NA([]),AK?.abort("user-cancel")}else if(OM.isRemoteMode)OM.cancelRequest();else AK?.abort("user-cancel");mO(null),ZLH(A3.current,!0)}let
     OP_=s_.useCallback(()=>{let f_=kQ_(w7.current,0);if(!f_)return;if(R5(f_.text),lw("prompt"),f_.images.length>0)jP((r_)=>{let O6={...r_};for(let Hq of f_.images)O6[Hq.id]=Hq;return
     O6})},[R5,lw,jP]),TP_={setToolUseConfirmQueue:R9,onCancel:hLH,getConnectionSummary:()=>SD.current?.summary(),onAgentsKilled:()=>F7((f_)=>[...f_,EB7()]),isMessageSelectorVisible:Qs||!!cQ,screen:A_,abortSi
     gnal:AK?.signal,isExternalLoading:T3,popCommandFromQueue:OP_,isLocalJSXCommand:X6?.isLocalJSXCommand,isInputOverlayActive:y_,inputMode:A$,isInputEmpty:i4};s_.useEffect(()=>{if(h)return;if(XP()>=5&&!ns&&!
     dQ){if(c("tengu_cost_threshold_reached",{}),TM(!0),zE_())p9H(!0)}},[E4,ns,dQ]);let Ej6=s_.useCallback(async(f_)=>{let
     r_=DH.getState(),{mode:O6,isBypassPermissionsModeAvailable:Hq}=r_.toolPermissionContext;switch(Rk_(O6,Hq)){case"allow":return!0;case"deny":return!1;case"classify":return
     I86(f_.host,f_.port,A3.current,J8.current,r_.toolPermissionContext,new AbortController().signal);case"ask":break}if(V9()&&E5_()){let Y9=bd9(),q9=await Id9(f_.host,Y9);return new Promise((l9)=>{if(!q9){pO
     ((_q)=>[..._q,{hostPattern:f_,resolvePromise:l9}]);return}pd9({requestId:Y9,host:f_.host,resolve:l9}),e((_q)=>({..._q,pendingSandboxRequest:{requestId:Y9,host:f_.host}}))})}return new Promise((Y9)=>{let
     q9=!1;function l9(_q){if(q9)return;q9=!0,Y9(_q)}pO((_q)=>[..._q,{hostPattern:f_,resolvePromise:l9}]);{let _q=DH.getState().replBridgePermissionCallbacks;if(_q){let
     z7=uYH.randomUUID();_q.sendRequest(z7,hD6,{host:f_.host},uYH.randomUUID(),`Allow network connection to ${f_.host}?`);let U1=_q.onResponse(z7,(MT)=>{U1();let KY=MT.behavior==="allow";pO((Bj)=>{return
     Bj.filter((Fj)=>Fj.hostPattern.host===f_.host).forEach((Fj)=>Fj.resolvePromise(KY)),Bj.filter((Fj)=>Fj.hostPattern.host!==f_.host)});let V0=mj.current.get(f_.host);if(V0){for(let Bj of
     V0)Bj();mj.current.delete(f_.host)}}),nw=()=>{U1(),_q.cancelRequest(z7)},C4=mj.current.get(f_.host)??[];C4.push(nw),mj.current.set(f_.host,C4)}}})},[e,DH]);if(s_.useEffect(()=>{let
     f_=y8.getSandboxUnavailableReason();if(!f_)return;if(y8.isSandboxRequired()){process.stderr.write(`
 9252: Error: sandbox required but unavailable: ${f_}
 9253: `+`  sandbox.failIfUnavailable is set \u2014 refusing to start without a working sandbox.
 9254:

 - <anonymous> (/$bunfs/root/src/entrypoints/cli.js:9251:5663)
 - WC (/$bunfs/root/src/entrypoints/cli.js:492:63749)
 - pj (/$bunfs/root/src/entrypoints/cli.js:492:76948)
 - fT (/$bunfs/root/src/entrypoints/cli.js:492:76827)
 - pj (/$bunfs/root/src/entrypoints/cli.js:492:77745)
 - fT (/$bunfs/root/src/entrypoints/cli.js:492:76827)
 - pj (/$bunfs/root/src/entrypoints/cli.js:492:76926)
 - fT (/$bunfs/root/src/entrypoints/cli.js:492:76827)
 - pj (/$bunfs/root/src/entrypoints/cli.js:492:77745)
 - fT (/$bunfs/root/src/entrypoints/cli.js:492:76827)
 - async <anonymous> (/$bunfs/root/src/entrypoints/cli.js:18815:2361)

---

claude -p "Hello" --session-id my-test-session

---

claude --resume my-test-session

---

ERROR  g9H is not a function. (In 'g9H(K)', 'g9H' is undefined)

---

claude -p "Hello" --session-id my-test-session

---

claude --resume my-test-session

---

// enabled is always false in normal interactive mode
const S = useMemo(() => false, []);

const { onSessionRestored: g9H } = FXK({ enabled: S, ... });

---

useEffect(() => {
  if (K && K.length > 0)
    HP_(K, K8()), hY8({...}), tC8(K), UQ(K),
    sYH.current.current = xz_(K, g8),
    g9H(K);   // ← crashes: g9H is undefined
}, []);

---

ERROR  g9H is not a function. (In 'g9H(K)', 'g9H' is undefined)

/$bunfs/root/src/entrypoints/cli.js:9251:5663

- <anonymous> (/$bunfs/root/src/entrypoints/cli.js:9251:5663)
- WC  (/$bunfs/root/src/entrypoints/cli.js:492:63749)
- ...

---

npm install -g @anthropic-ai/claude-code@2.1.119
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

claude --resume <session-id> crashes immediately when the target session has existing messages. The REPL throws an unhandled error:

ERROR  g9H is not a function. (In 'g9H(K)', 'g9H' is undefined)

What Should Happen?

claude --resume <session-id> opens the interactive REPL with the previous conversation loaded, as it did in 2.1.119.

Error Messages/Logs

ERROR  g9H is not a function. (In 'g9H(K)', 'g9H' is undefined)

 /$bunfs/root/src/entrypoints/cli.js:9251:5663

 9248: ${K.join(`
 9249:
 9250 `)}`}var fL3,TkK=1000,JL3=300,ML3=5000;var Bb8=Z(()=>{P_();k_();Np();YI();OkK();__();HV();fL3=(LmH(),E8(ZmH))});var DkK={};J_(DkK,{useScheduledTasks:()=>XL3});function
 :   XL3({isLoading:H,assistantMode:_,setMessages:q}){let K=QD6.useRef(H);K.current=H;let O=B4(),T=F8(),$=Xj();QD6.useEffect(()=>{if(!LR()||C8())return;let
     A=(w)=>yT({value:PL3.resolveLoopDefaultFire(w),mode:"prompt",priority:"later",isMeta:!0,workload:SEH}),z=void 0,Y=pb8({onFire:A,onFireTask:(w)=>{if(w.agentId){let
     j=nr(w.agentId,O.getState().tasks);if(j&&!HE(j.status)){OmH(j.id,w.prompt,$);return}y(`[ScheduledTasks] teammate ${w.agentId} gone, removing orphaned cron ${w.id}`),i_H([w.id]);return}let
     D=hB7(w.kind==="loop"?`Claude resuming /loop wakeup (${wkK(new Date)})`:`Running scheduled task (${wkK(new
     Date)})`);q((j)=>[...j,D]),A(w.prompt)},isLoading:()=>K.current,assistantMode:_,getJitterConfig:s3H,isKilled:()=>!LR(),getExtraTasks:YkK&&z?()=>YkK.getRoutineCronTasks(G5(),z):void 0});return
     Y.start(),()=>{Y.stop()}},[_,q,O.getState,$])}function wkK(H){return H.toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).replace(/,? at |, /," ").replace(/
     ([AP]M)/,(_,q)=>q.toLowerCase())}var QD6,PL3,YkK=null;var jkK=Z(()=>{EE();P_();h8();mZ();qE();DI();CK_();Bb8();YI();__();Uz();D8();q5H();QD6=u(MH(),1),PL3=(LmH(),E8(ZmH))});var
     XkK={};J_(XkK,{REPL:()=>Ub8});function fkK(H){let _=lD6.c(14),{showAllInTranscript:q,virtualScroll:K,searchBadge:O,suppressShowAll:T,status:$}=H,A=T===void
     0?!1:T,z=M1("app:toggleTranscript","Global","ctrl+o"),Y=M1("transcript:toggleShowAll","Transcript","ctrl+e"),w;if(_[0]===Symbol.for("react.memo_cache_sentinel"))w=xQ7(),_[0]=w;else w=_[0];let
     D=w,j=D?`open in ${D}`:"open in editor",f;if(_[1]===Symbol.for("react.memo_cache_sentinel"))f=T6.createElement(T6.Fragment,null,"Showing detailed transcript"),_[1]=f;else f=_[1];let
     J;if(_[2]!==z)J=T6.createElement(T6.Fragment,null,z," to toggle"),_[2]=z,_[3]=J;else J=_[3];let M=O?"n/N to navigate":K?`${O_.arrowUp}${O_.arrowDown} scroll \xB7 [ to print output \xB7 v to ${j}`:A?`v to
      ${j}`:`${Y} to ${q?"collapse":"show all"}`,P;if(_[4]!==J||_[5]!==M)P=T6.createElement(k,{dimColor:!0},T6.createElement(t_,null,f,J,M)),_[4]=J,_[5]=M,_[6]=P;else P=_[6];let
     X;if(_[7]===Symbol.for("react.memo_cache_sentinel"))X=T6.createElement(p,{flexGrow:1}),_[7]=X;else X=_[7];let
     R;if(_[8]!==O||_[9]!==$)R=T6.createElement(hL3,{status:$,searchBadge:O}),_[8]=O,_[9]=$,_[10]=R;else R=_[10];let W;if(_[11]!==P||_[12]!==R)W=T6.createElement(p,{noSelect:!0,alignItems:"center",alignSelf:"
     center",borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:"single",marginTop:1,paddingLeft:2,width:"100%"},P,X,R),_[11]=P,_[12]=R,_[13]=W;else W=_[13];return W}function
     hL3(H){let _=lD6.c(6),{status:q,searchBadge:K}=H;if(q){let T;if(_[0]!==q)T=T6.createElement(k,null,q," "),_[0]=q,_[1]=T;else T=_[1];return T}if(K){let
     T;if(_[2]!==K.count||_[3]!==K.current)T=T6.createElement(k,{dimColor:!0},K.current,"/",K.count,"  "),_[2]=K.count,_[3]=K.current,_[4]=T;else T=_[4];return T}let
     O;if(_[5]===Symbol.for("react.memo_cache_sentinel"))O=T6.createElement(k,{dimColor:!0},"verbose "),_[5]=O;else O=_[5];return O}function SL3({jumpRef:H,count:_,current:q,onClose:K,onCancel:O,setHighlight:
     T,initialQuery:$}){let{query:A,cursorOffset:z,handleKeyDown:Y,handlePaste:w}=AG({isActive:!0,initialQuery:$,onExit:()=>K(A),onCancel:O}),[D,j]=s_.useState("building");s_.useEffect(()=>{let
     P=!0,X=H.current?.warmSearchIndex;if(!X){j(null);return}return j("building"),X().then((R)=>{if(!P)return;if(R<20)j(null);else j({ms:R}),setTimeout(()=>P&&j(null),2000)}),()=>{P=!1}},[]);let
     f=D!=="building";s_.useEffect(()=>{if(!f)return;H.current?.setSearchQuery(A),T(A)},[A,f]);let J=z,M=J<A.length?A[J]:" ";return T6.createElement(p,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borde
     rRight:!1,borderStyle:"single",marginTop:1,paddingLeft:2,tabIndex:0,autoFocus:!0,onKeyDown:Y,onPaste:w,width:"100%",noSelect:!0},T6.createElement(k,null,"/"),T6.createElement(k,null,A.slice(0,J)),T6.crea
     teElement(k,{inverse:!0},M),J<A.length&&T6.createElement(k,null,A.slice(J+1)),T6.createElement(p,{flexGrow:1}),D==="building"?T6.createElement(k,{dimColor:!0},"indexing\u2026
     "):D?T6.createElement(k,{dimColor:!0},"indexed in ",D.ms,"ms "):_===0&&A?T6.createElement(k,{color:"error"},"no matches "):_>0?T6.createElement(k,{dimColor:!0},q,"/",_,"  "):null)}function MkK(H){let
     _=lD6.c(6),{isAnimating:q,title:K,disabled:O,noPrefix:T}=H,$=IA(),[A,z]=s_.useState(0),Y,w;if(_[0]!==O||_[1]!==q||_[2]!==T||_[3]!==$)Y=()=>{if(O||T||!q||!$)return;let
     j=setInterval(CL3,EL3,z);return()=>clearInterval(j)},w=[O,T,q,$],_[0]=O,_[1]=q,_[2]=T,_[3]=$,_[4]=Y,_[5]=w;else Y=_[4],w=_[5];s_.useEffect(Y,w);let D=q?PkK[A]??JkK:JkK;return r5H(O?null:T?K:`${D}
     ${K}`),null}function CL3(H){return H(bL3)}function bL3(H){return(H+1)%PkK.length}function Ub8({commands:H,debug:_,initialTools:q,initialMessages:K,pendingHookMessages:O,initialFileHistorySnapshots:T,init
     ialContentReplacements:$,initialAgentName:A,initialAgentColor:z,mcpClients:Y,dynamicMcpConfig:w,autoConnectIdeFlag:D,strictMcpConfig:j=!1,systemPrompt:f,appendSystemPrompt:J,onBeforeQuery:M,onTurnComplet
     e:P,disabled:X=!1,mainThreadAgentDefinition:R,disableSlashCommands:W=!1,remoteSessionConfig:G,directConnectConfig:L,sshSession:v,thinkingConfig:N}){let
     h=!!G,C=s_.useMemo(()=>hH(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),S=s_.useMemo(()=>!1,[]),b=s_.useMemo(()=>hH(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]),B=!1;s_.useEffect(()=>{return
      y(`[REPL:mount] REPL mounted, disabled=${X}`),()=>y("[REPL:unmount] REPL
     unmounting")},[X]);let[x,E]=s_.useState(R),F=j_((f_)=>f_.toolPermissionContext),g=j_((f_)=>f_.verbose),U=j_((f_)=>f_.mcp),d=j_((f_)=>f_.plugins),i=j_((f_)=>f_.agentDefinitions),n=j_((f_)=>f_.initialMessa
     ge),o=Es(),_H=j_((f_)=>f_.expandedView)==="tasks",r=j_((f_)=>f_.pendingWorkerRequest),HH=j_((f_)=>f_.pendingSandboxRequest),t=j_((f_)=>f_.teamContext),AH=j_((f_)=>f_.tasks),zH=j_((f_)=>f_.workerSandboxPe
     rmissions),JH=j_((f_)=>f_.elicitation),s=j_((f_)=>f_.ultraplanPendingChoice),a=j_((f_)=>f_.ultraplanLaunchPending),KH=j_((f_)=>f_.viewingAgentTaskId),e=F8(),$H=KH?AH[KH]:void
     0,OH=xJ($H)&&$H.retain&&!$H.diskLoaded;s_.useEffect(()=>{if(!KH||!OH)return;let f_=KH;LTH(hT(f_)).then((r_)=>{e((O6)=>{let Hq=O6.tasks[f_];if(!xJ(Hq)||Hq.diskLoaded||!Hq.retain)return O6;let
     yq=Hq.messages??[],Y9=new
     Set(yq.map((l9)=>l9.uuid)),q9=r_?r_.messages.filter((l9)=>!Y9.has(l9.uuid)):[];return{...O6,tasks:{...O6.tasks,[f_]:{...Hq,messages:[...q9,...yq],diskLoaded:!0}}}})})},[KH,OH,e]);let
     DH=B4(),YH=s_.useMemo(()=>Ty(()=>DH.getState(),e),[DH,e]),PH=s_.useMemo(()=>rGH(()=>DH.getState(),e),[DH,e]),fH=Ni(),GH=Rj(),[kH,WH]=s_.useState(H);R0K(h?void 0:G5(),WH);let
     LH=j_((f_)=>f_.isBriefOnly),CH=s_.useMemo(()=>tR(F),[F,LH]);qJ7(),KJ7();let[BH,sH]=s_.useState(w),cH=s_.useCallback((f_)=>{sH(f_)},[sH]),[A_,Y_]=s_.useState("prompt"),[ZH,bH]=s_.useState(!1),[mH,xH]=s_.u
     seState(!1),[aH,rH]=s_.useState(""),nH=s_.useRef(0),QH=s_.useRef(void 0),tH=s_.useRef(!1),{addNotification:L_,removeNotification:B_}=T7(),H6=vL3,c_=M0K(Y,U.clients),[iH,u_]=s_.useState(void 0),[FH,T_]=s_
     .useState(null),[vH,oH]=s_.useState(null),[w_,W_]=s_.useState(!1),[TH,jH]=s_.useState(()=>{return!1}),uH=j_((f_)=>f_.showRemoteCallout),[IH,eH]=s_.useState(()=>GGK());OLK(),$LK(),_LK({ideSelection:iH,mcp
     Clients:c_,ideInstallationStatus:vH}),iGK({mcpClients:c_}),oGK(),NZK(),hZK(),X36(),FZK(GH),XLK(),GLK(),dZK(GH),QZK(),tZK(),rZK(),LL3(),tRK(),YGK(),JGK(),tGK(),DLK();let{recommendation:EH,handleResponse:Z
     _}=jZK(),{recommendation:D_,handleResponse:Q_}=WZK(),{pending:F_,handleAction:l6,skipForSession:y6}=ZL3(),g8=s_.useMemo(()=>{return[...CH,...q]},[CH,q]);KD6({enabled:!h}),N0K({enabled:!h});let
     $8=CY7();s_.useEffect(()=>{if(h)return;IZK(e)},[e,h]),s_.useEffect(()=>{let
     f_=setTimeout(nLK,500);return()=>clearTimeout(f_)},[]),XGK(h?gb8:c_,F.mode),s_.useEffect(()=>{Xy8(F.mode)},[F.mode]),vWK(e,K,{enabled:!h});let
     wq=QT6(g8,U.tools,F),{tools:T9,allowedAgentTypes:g6}=s_.useMemo(()=>{if(!x)return{tools:wq,allowedAgentTypes:void 0};let
     f_=vc(x,wq,!1,!0);return{tools:f_.resolvedTools,allowedAgentTypes:f_.allowedAgentTypes}},[x,wq]),J8=s_.useRef(T9);J8.current=T9;let S9=s_.useMemo(()=>{if(!wJ())return T9;let f_=new
     Set(T9.map((O6)=>O6.name)),r_=n$H().filter((O6)=>!f_.has(O6.name));return r_.length>0?[...T9,...r_]:T9},[T9]),p9=nC8(kH,d.commands),CK=nC8(p9,U.commands),U8=s_.useMemo(()=>W?[]:CK,[W,CK]);vjK(h?gb8:U.cli
     ents),E0K(h?gb8:U.clients,u_);let[D4,j4]=s_.useState([]),[B1,l5]=s_.useState(null);s_.useEffect(()=>{if(B1&&!B1.isStreaming&&B1.streamingEndedAt){let
     r_=30000-(Date.now()-B1.streamingEndedAt);if(r_>0){let O6=setTimeout(l5,r_,null);return()=>clearTimeout(O6)}else l5(null)}},[B1]);let[AK,mO]=s_.useState(null),F1=s_.useRef(null);F1.current=AK;let
     SD=s_.useRef(null),xj=s_.useRef(()=>{}),O5=s_.useRef(()=>{}),vz=s_.useRef(null),eJ=s_.useRef(null),uj=s_.useRef(0),jO=s_.useRef(new
     ZS8).current,$$=s_.useSyncExternalStore(jO.subscribe,jO.getSnapshot),[T3,S5]=s_.useState(G?.hasInitialPrompt??!1),B7=$$||T3,[fO,q1]=s_.useState(void 0),N3=s_.useRef(0),K1=s_.useRef(!1),JO=s_.useRef(0),$3
     =s_.useRef(0),aA=s_.useRef(null),dw=s_.useCallback(()=>{JO.current=Date.now(),$3.current=0,aA.current=null},[]),pf=s_.useRef(!1);if($$&&!pf.current)dw();pf.current=$$;let
     cY=s_.useCallback((f_)=>{if(S5(f_),f_)dw()},[dw]),sA=s_.useRef(null),ED=s_.useRef(void 0),$A=s_.useRef(void
     0),HM=1500,[MO,wT]=s_.useState(!1);s_.useEffect(()=>{if(oq())vY9().then((f_)=>{if(f_)L_({key:"tmux-mouse-hint",text:f_,priority:"low"})});NY9().then((f_)=>{if(f_)L_({key:"tmux-focus-hint",text:f_,priorit
     y:"low"})})},[]);let[cw,Bf]=s_.useState(!1);s_.useEffect(()=>{},[]);let[X6,Jq]=s_.useState(null),W9=s_.useRef(null),o9=s_.useCallback((f_)=>{if(f_?.isLocalJSXCommand){let{clearLocalJSX:r_,...O6}=f_;W9.cu
     rrent={...O6,isLocalJSXCommand:!0},Jq(O6);return}if(W9.current){if(f_?.clearLocalJSX){W9.current=null,Jq(null);return}return}if(f_?.clearLocalJSX){Jq(null);return}Jq(f_)},[]),[a9,T5]=s_.useState(()=>new
     Map),s1=s_.useCallback((f_)=>{T5((r_)=>TRK(r_,f_))},[]),[VK,dq]=s_.useState([]),R9=s_.useMemo(()=>cDK(dq),[dq]),[I4,O4]=s_.useState(null),[Q9,pO]=s_.useState([]),[n4,NA]=s_.useState([]),mj=s_.useRef(new
     Map),Ff=j_((f_)=>f_.settings.terminalTitleFromRename)!==!1,i3=s_.useSyncExternalStore(My8,()=>Ff?fD(V_()):void 0);s_.useEffect(()=>{return fy8(()=>{let
     f_=VQH();if(!f_)return;e((r_)=>{if(r_.standaloneAgentContext?.name===f_)return
     r_;return{...r_,standaloneAgentContext:{...r_.standaloneAgentContext,name:f_}}})})},[e]);let[A7,gf]=s_.useState(),CD=s_.useRef((K?.length??0)>0),TW=x?.agentType,O1=i3??TW??A7??"Claude
     Code",r3=VK.length>0||n4.length>0||r||HH,V3=X6?.isLocalJSXCommand===!0&&X6?.jsx!=null,bD=s_.useMemo(()=>cK6(AH),[AH]),_M=r3||V3?"waiting":B7||bD?"busy":"idle",QY=s_.useMemo(()=>p$K(AH),[AH]),qM=_M==="idl
     e"&&QY?"busy":_M,PO=_M==="busy";s_.useEffect(()=>{if(_M==="busy")return yDK(),()=>hDK()},[_M]);let DT=_M!=="waiting"?void 0:VK.length>0?`approve ${VK[0].tool.name}`:r?"worker request":HH?"sandbox
     request":V3?"dialog open":"input needed";s_.useEffect(()=>{BC_({status:qM,waitingFor:DT})},[qM,DT]);let
     lY=yKK(AH),v9=ZQ_();s_.useEffect(()=>{vS7({tasks:lY.count,queued:v9,kinds:lY.kinds})},[lY.count,v9,lY.kinds.join(",")]);let
     Nz=S_("tengu_terminal_sidebar",!1)&&(h_().showStatusInTerminalTab??!1),Tu=j_((f_)=>f_.postTurnSummary?.status_detail);CU_(C||!Nz?null:_M,Tu),s_.useEffect(()=>{return
     DL9(R9),()=>jL9()},[R9]);let[E4,sy]=s_.useState(K??[]),A3=s_.useRef(E4),NG=s_.useRef(!1),F7=s_.useCallback((f_)=>{let r_=A3.current,O6=typeof
     f_==="function"?f_(A3.current):f_;if(A3.current=O6,O6.length<N3.current)N3.current=0,K1.current=!1,q1(void 0);else if(O6.length>r_.length&&K1.current){let
     Hq=O6.length-r_.length;if((r_.length===0||O6[0]===r_[0]?O6.slice(-Hq):O6.slice(0,Hq)).some(z5_))K1.current=!1;else
     N3.current=O6.length}sy(O6)},[]),BT=s_.useCallback((f_)=>F7((r_)=>ew6(r_,f_)),[F7]);AGK(s_.useCallback((f_)=>F7((r_)=>[...r_,q6({content:VO6(f_),isMeta:!0})]),[F7]));let
     y2=s_.useCallback((f_)=>{if(f_!==void 0)N3.current=A3.current.length,K1.current=!0;else K1.current=!1;q1(f_)},[]),{dividerIndex:h2,dividerYRef:$W,onScrollAway:IL,onRepin:AN,jumpToNew:Us,shiftDivider:Qw}=
     Ee7(E4.length);KGK(E4,F7,B7,uj,!h);let[VG,gH]=s_.useState(null),lH=s_.useRef(VG);lH.current=VG;let
     o_=s_.useRef(null),H_=s_.useMemo(()=>Ce7(E4,h2),[h2,E4.length]),g_=s_.useCallback((f_=!1,r_="?")=>{if(!f_&&!x3("autoScrollEnabled",!0).value)return;let
     O6=vz.current;if(O6&&!O6.isSticky())y(`repinScroll(${r_}, force=${f_}): yanking from scrollTop=${O6.getScrollTop()}
     (max=${Math.max(0,O6.getScrollHeight()-O6.getViewportHeight())})`);if(O6?.scrollToBottom(),AN(),lH.current!==null)gH(null)},[AN]),h6=E4.at(-1),G6=h6!=null&&z5_(h6);s_.useEffect(()=>{if(G6)g_(!1,"lastMsgI
     sHuman")},[G6,h6,g_]);let{maybeLoadOlder:I8}=VL3,s8=s_.useCallback((f_,r_)=>{if(uj.current=Date.now(),f_)AN();else IL(r_)},[AN,IL,I8]),v7=zWK(O,F7),[z3,g1]=s_.useState(null);s_.useState(()=>{return
     zq6(lr6()),null});let w7=s_.useRef(Aq6()),i4=oJ7(),n7=s_.useCallback(()=>wT(!1),[]),k4=hi(n7,HM),B$=s_.useRef(null),R5=s_.useCallback((f_)=>{if(H6(w7.current,f_))return;if(w7.current===""&&f_!==""&&Date.
     now()-uj.current>=yL3)g_(!1,"typedIntoEmpty");w7.current=f_,zq6(f_),j8H.recordUserActivity(),kwH(!0);let r_=f_.trim().length>0;if(wT(r_),r_)k4();else
     k4.cancel()},[wT,g_,H6,k4]),[A$,lw]=s_.useState("prompt"),[KM,ty]=s_.useState(),ID=s_.useCallback((f_)=>{let r_=new
     Set(f_.slash_commands);WH((O6)=>O6.filter((Hq)=>r_.has(Hq.name)||aV8.has(Hq))),e((O6)=>O6.mainLoopModel===f_.model?O6:{...O6,mainLoopModel:f_.model})},[WH,e]),[yG,zN]=s_.useState(new
     Set),PC=s_.useCallback((f_)=>{zN((r_)=>{switch(f_.action){case"add":{let O6=new Set(r_);for(let Hq of f_.ids)O6.add(Hq);return O6}case"remove":{let O6=new Set(r_);for(let Hq of
     f_.ids)O6.delete(Hq);return O6.size===r_.size?r_:O6}case"clear":return r_.size>0?new
     Set:r_}})},[]),S2=s_.useRef(!1),hG=s_.useRef(0),ey=s_.useRef([]),CF=s_.useRef(0),FQ=s_.useCallback((f_)=>{hG.current+=f_;let r_=ey.current;if(f_>0&&r_.length>0){let
     O6=r_.at(-1);if(O6.outputTokens==null)O6.lastTokenTime=Date.now(),O6.endResponseLength=hG.current}},[]),GLH=s_.useCallback(()=>{hG.current=0},[]),u9H=s_.useCallback((f_)=>{if(f_.type==="start"){let
     r_=Date.now(),O6=hG.current;ey.current.push({id:f_.id,ttftMs:f_.ttftMs,firstTokenTime:r_,lastTokenTime:r_,responseLengthBaseline:O6,endResponseLength:O6})}else{let
     r_=f_.id!=null?ey.current.find((O6)=>O6.id===f_.id):ey.current.findLast((O6)=>O6.id==null);if(r_){if(r_.outputTokens=f_.outputTokens,r_.lastTokenTime=Date.now(),f_.id==null)hG.current=Math.max(hG.current
     ,r_.responseLengthBaseline+f_.outputTokens*4)}}},[]),bF=hXK({config:G,setMessages:F7,setIsLoading:cY,onInit:ID,setToolUseConfirmQueue:R9,tools:g8,setStreamingToolUses:j4,setStreamMode:P$_,setInProgressTo
     olUseIDs:PC,recordApiMetricsEvent:u9H,permissionMode:F.mode}),ds=bXK({config:L,setMessages:F7,setIsLoading:cY,setToolUseConfirmQueue:R9,tools:g8,permissionMode:F.mode}),IF=uXK({session:v,setMessages:F7,s
     etIsLoading:cY,setToolUseConfirmQueue:R9,tools:g8,permissionMode:F.mode}),OM=s_.useMemo(()=>IF.isRemoteMode?A56("ssh",IF,!1):ds.isRemoteMode?A56("direct",ds,!1):bF.isRemoteMode?A56("ccr",bF,G?.viewerOnly
     ??!1,G?.sessionId):O08,[IF,ds,bF,G?.viewerOnly,G?.sessionId]);s_.useEffect(()=>{let f_=OM.isRemoteMode?OM:null,r_=OM.isRemoteMode&&OM.kind==="ccr"?"ccr-api":"local-jsonl",O6=xwH();if(O6.remote!==f_||O6.t
     ranscriptSource!==r_)zM6({...O6,remote:f_,transcriptSource:r_})},[OM]);let[BO,jP]=s_.useState({}),[XC,m9H]=s_.useState(0),[WC,xL]=s_.useState(null),gQ=!(j_((f_)=>f_.settings.prefersReducedMotion)??!1)&&!
     PJ9(),RC=s_.useCallback((f_)=>{if(!gQ)return;xL(f_)},[gQ]),k0=WC&&gQ?WC.substring(0,WC.lastIndexOf(`
 9251 `)+1)||null:null,[uL,cs]=s_.useState(0),[Qs,$u]=s_.useState(!1),[QYH,ls]=s_.useState(void
 :   0),[ns,p9H]=s_.useState(!1),[lYH,YN]=s_.useState(uYH.randomUUID()),[xF,v0]=s_.useState(null),UQ=s_.useCallback((f_)=>{let
     r_=LDK(f_,GJ);if(r_)v0(r_)},[]),B9H=s_.useRef(uL);B9H.current=uL;let[is]=s_.useState(()=>({current:Yh9(K,$)})),[uF]=s_.useState(()=>({current:vc9(K??[])})),[dQ,TM]=s_.useState(h_().hasAcknowledgedCostThr
     eshold),[cQ,fP]=s_.useState(!1),[y_,i6]=s_.useState(!1),Pq=s_.useRef("INSERT");s_.useEffect(()=>{if(s&&cQ)fP(!1)},[s,cQ]);let
     f4=IA(),T4=s_.useRef(f4);T4.current=f4;let[T1]=j9(),fT=s_.useRef(!1),pj=s_.useCallback(()=>{if(fT.current)return;fT.current=!0;let f_=A3.current.slice(lQ.current);for(let r_ of
     s58(f_))d9H.current.add(r_);lQ.current=A3.current.length,kGK({theme:T1,readFileState:mF.current,bashTools:d9H.current}).then(async(r_)=>{if(r_){let O6=await
     r_.content({theme:T1});e((Hq)=>({...Hq,spinnerTip:O6})),vGK(r_)}else e((O6)=>{if(O6.spinnerTip===void 0)return O6;return{...O6,spinnerTip:void 0}})})},[e,T1]),XO=s_.useCallback(()=>{cY(!1),y2(void
     0),hG.current=0,ey.current=[],CF.current++,xL(null),j4([]),lz8(),P$_("responding"),pj(),ar(),oo_()},[pj]),JP=s_.useMemo(()=>RXH(AH).some((f_)=>f_.status==="running"),[AH]);s_.useEffect(()=>{if(!JP&&sA.cu
     rrent!==null){let f_=Date.now()-sA.current,r_=ED.current;sA.current=null,ED.current=void 0,F7((O6)=>[...O6,UW8(f_,r_,q8(O6,H9H))])}},[JP,F7]);let
     AW=s_.useRef(!1);s_.useEffect(()=>{{if(F.mode!=="auto"){AW.current=!1;return}if(AW.current)return;if((h_().autoPermissionsNotificationCount??0)>=3)return;let
     O6=setTimeout((Hq,yq)=>{Hq.current=!0,a_((Y9)=>{let q9=Y9.autoPermissionsNotificationCount??0;if(q9>=3)return
     Y9;return{...Y9,autoPermissionsNotificationCount:q9+1}}),yq((Y9)=>[...Y9,OT(jw6,"warning")])},800,AW,F7);return()=>clearTimeout(O6)}},[F.mode,F7]);let
     BlH=s_.useRef(!1),nYH=s_.useRef(!1);s_.useEffect(()=>{if(nYH.current)return;let f_=HT();if(!f_?.creationDurationMs||f_.usedSparsePaths)return;if(f_.creationDurationMs<15000)return;nYH.current=!0;let
     r_=Math.round(f_.creationDurationMs/1000);F7((O6)=>[...O6,OT(`Worktree creation took ${r_}s. For large repos, set \`worktree.sparsePaths\` in .claude/settings.json to check out only the directories you
     need \u2014 e.g. \`{"worktree": {"sparsePaths": ["src", "packages/foo"]}}\`.`,"info")])},[F7]);let{onBeforeQuery:F9H,onTurnComplete:ZLH,onSessionRestored:g9H,render:aM_,ownsInput:LLH}=FXK({enabled:S,setM
     essages:F7,setInputValue:R5,setToolJSX:o9,resultDedupState:uF.current}),iYH=(!X6||X6.showSpinner===!0)&&VK.length===0&&n4.length===0&&(B7||fO||JP||ZQ_()>0)&&!r&&(!k0||LH),rs=VK.length>0||n4.length>0||Q9.
     length>0||JH.queue.length>0||zH.queue.length>0;xDK({sandboxHost:Q9[0]?.hostPattern.host,promptTitle:n4[0]?.title,elicitationServer:JH.queue[0]?.serverName,workerSandboxHost:zH.queue[0]?.host});let
     rYH=vRK({hasActivePrompt:rs,otherSurveyActive:!1}),U9H=yRK(E4,B7,rs,{enabled:!h}),SG=LRK(E4,B7,rs,{enabled:!h,otherSurveyActive:rYH.state!=="closed"||U9H.state!=="closed"}),kLH=MRK(E4,B7,XC,"session",rs,
     rYH.state!=="closed"||U9H.state!=="closed"||SG.state!=="closed"),mL=ILK(E4,XC),FlH=s_.useMemo(()=>({...kLH,handleSelect:(f_)=>{if(yLH.current=!1,kLH.handleSelect(f_),f_==="bad"&&vLK("feedback_survey_bad"
     ))c9H("feedback_survey_bad"),yLH.current=!0}}),[kLH]),sM_=GL3(E4,B7,rs,rYH.state!=="closed"||FlH.state!=="closed"||U9H.state!=="closed"||SG.state!=="closed");e0K({autoConnectIdeFlag:D,ideToInstallExtensi
     on:FH,setDynamicMcpConfig:sH,setShowIdeOnboarding:W_,setIDEInstallationState:oH}),FGK(T,(f_)=>e((r_)=>({...r_,fileHistory:f_})));let tM_=s_.useCallback(async(f_,r_,O6)=>{let Hq=performance.now();try{let
     yq=E$_(r_.messages),Y9=Fw_();await
     OGH("resume",{getAppState:()=>DH.getState(),setAppState:e,signal:AbortSignal.timeout(Y9)});let{agentDefinition:q9}=KLH(r_.agentSetting,R,i);E(q9),e((U1)=>({...U1,agent:q9?.agentType}));let l9=await
     II("resume",{sessionId:f_,agentType:q9?.agentType,model:GH});if(yq.push(...l9),O6==="fork")vF9(r_,WX(f_));else zr_(r_,WX(f_));if(r_.fileHistorySnapshots)K86(r_);if(e((U1)=>({...U1,standaloneAgentContext:
     YM_(r_.agentName,r_.agentColor)})),Rk(r_.agentName),HP_(yq,r_.projectPath??K8()),O6!=="fork")sYH.current.current=xz_(yq,g8);XO(),mO(null),YN(f_);let
     _q=fK8(f_);a1_(),SkH(),xG(WX(f_),r_.fullPath?nD6.dirname(r_.fullPath):null);let{renameRecordingForSession:z7}=await Promise.resolve().then(() => (AM_(),B0K));if(await z7(),await
     eB(),zM_(r_,e),Bw_(),Gs(r_),CD.current=!0,gf(void 0),O6!=="fork")g0K(r_.worktreeSession===void
     0?r_.projectPath:r_.worktreeSession?.worktreePath),wM_(r_.worktreeSession,r_.projectPath),Rs(),hY8({abortController:new AbortController,taskRegistry:YH}),$l(MN().map((U1)=>U1.id)),tC8(yq);else{let
     U1=HT();if(U1)dE(U1)}if(_q)dnH(_q);if(is.current&&O6!=="fork")is.current=Fl_(yq,r_.contentReplacements??[]);if(F7(()=>yq),o9(null),R5(""),O6!=="fork")UQ(yq);c("tengu_session_resumed",{entrypoint:O6,succe
     ss:!0,resume_duration_ms:Math.round(performance.now()-Hq)})}catch(yq){throw
     c("tengu_session_resumed",{entrypoint:O6,success:!1,failure_reason:"processing_error",error_name:n6(yq).name}),yq}},[XO,e,YH,UQ]),[QQ]=s_.useState(()=>MI(Sp)),mF=s_.useRef(QQ),d9H=s_.useRef(new
     Set),lQ=s_.useRef(0),glH=s_.useRef(new Set),UlH=s_.useRef(new Map),vLH=s_.useRef(new Set),oYH=s_.useRef(new Map),NLH=s_.useRef(void
     0),aYH=s_.useRef(OOH()),eM_=s_.useRef(f3_()),sYH=s_.useRef(tgH()),HP_=s_.useCallback((f_,r_)=>{let O6=ApH(f_,r_,Sp);mF.current=KxH(mF.current,O6);for(let Hq of
     s58(f_))d9H.current.add(Hq)},[e]);s_.useEffect(()=>{if(K&&K.length>0)HP_(K,K8()),hY8({abortController:new AbortController,taskRegistry:YH}),tC8(K),UQ(K),sYH.current.current=xz_(K,g8),g9H(K)},[]);let{stat
     us:_P_,reverify:VLH}=wWK(),[Au,c9H]=s_.useState(null),yLH=s_.useRef(!1),[dlH,clH]=s_.useState(null),[QlH,llH]=s_.useState(!1),nlH=!B7&&ns;function
     tYH(){if(QlH||dlH)return;if(Qs)return"message-selector";if(MO)return;if(Q9[0])return"sandbox-permission";let
     f_=!X6||X6.shouldContinueAnimation;if(f_&&VK[0])return"tool-permission";if(f_&&n4[0])return"prompt";if(f_&&zH.queue[0])return"worker-sandbox-permission";if(f_&&JH.queue[0])return"elicitation";if(f_&&nlH)
     return"cost";if(f_&&xF)return"resume-return";if(f_&&!B7&&s)return"ultraplan-choice";if(f_&&!B7&&a)return"ultraplan-launch";if(vK()){if(f_&&uH)return"remote-callout";return}if(f_&&w_)return"ide-onboarding
     ";if(f_&&uH)return"remote-callout";if(f_&&EH)return"lsp-recommendation";if(f_&&D_)return"plugin-hint";if(f_&&IH)return"desktop-upsell";return}let
     JT=tYH(),qP_=MO&&(Q9[0]||VK[0]||n4[0]||zH.queue[0]||JH.queue[0]||nlH);$A.current=JT,s_.useEffect(()=>{if(!B7)return;let f_=JT==="tool-permission",r_=Date.now();if(f_&&aA.current===null)aA.current=r_;else
      if(!f_&&aA.current!==null)$3.current+=r_-aA.current,aA.current=null},[JT,B7]);let ilH=s_.useRef(JT),FO=s_.useRef(null);s_.useLayoutEffect(()=>{let
     f_=ilH.current==="tool-permission",r_=JT==="tool-permission";if(ilH.current=JT,f_===r_)return;let
     O6=vz.current;if(r_)FO.current=O6&&!O6.isSticky()?O6.getScrollTop():null,g_(!0,"permissionDialogAppear");else if(FO.current!==null)O6?.scrollTo(FO.current),FO.current=null;else
     g_(!0,"permissionDialogDismiss")},[JT,g_]);let
     os=X6?.jsx!=null,KP_=s_.useRef(os);s_.useLayoutEffect(()=>{if(KP_.current!==os&&(vz.current?.isSticky()??!0))g_(!1,`toolJsxDialog\u2192${os}`);KP_.current=os},[os,g_]);function
     hLH(){if(JT==="elicitation")return;if(y(`[onCancel] focusedInputDialog=${JT}
     streamMode=${Gc.getState().mode}`),jO.forceEnd(),WC?.trim())F7((f_)=>[...f_,Pj({content:WC})]);if(XO(),JT==="tool-permission")VK[0]?.onAbort(),R9([]);else if(JT==="prompt"){for(let f_ of
     n4)f_.reject(Error("Prompt cancelled by user"));NA([]),AK?.abort("user-cancel")}else if(OM.isRemoteMode)OM.cancelRequest();else AK?.abort("user-cancel");mO(null),ZLH(A3.current,!0)}let
     OP_=s_.useCallback(()=>{let f_=kQ_(w7.current,0);if(!f_)return;if(R5(f_.text),lw("prompt"),f_.images.length>0)jP((r_)=>{let O6={...r_};for(let Hq of f_.images)O6[Hq.id]=Hq;return
     O6})},[R5,lw,jP]),TP_={setToolUseConfirmQueue:R9,onCancel:hLH,getConnectionSummary:()=>SD.current?.summary(),onAgentsKilled:()=>F7((f_)=>[...f_,EB7()]),isMessageSelectorVisible:Qs||!!cQ,screen:A_,abortSi
     gnal:AK?.signal,isExternalLoading:T3,popCommandFromQueue:OP_,isLocalJSXCommand:X6?.isLocalJSXCommand,isInputOverlayActive:y_,inputMode:A$,isInputEmpty:i4};s_.useEffect(()=>{if(h)return;if(XP()>=5&&!ns&&!
     dQ){if(c("tengu_cost_threshold_reached",{}),TM(!0),zE_())p9H(!0)}},[E4,ns,dQ]);let Ej6=s_.useCallback(async(f_)=>{let
     r_=DH.getState(),{mode:O6,isBypassPermissionsModeAvailable:Hq}=r_.toolPermissionContext;switch(Rk_(O6,Hq)){case"allow":return!0;case"deny":return!1;case"classify":return
     I86(f_.host,f_.port,A3.current,J8.current,r_.toolPermissionContext,new AbortController().signal);case"ask":break}if(V9()&&E5_()){let Y9=bd9(),q9=await Id9(f_.host,Y9);return new Promise((l9)=>{if(!q9){pO
     ((_q)=>[..._q,{hostPattern:f_,resolvePromise:l9}]);return}pd9({requestId:Y9,host:f_.host,resolve:l9}),e((_q)=>({..._q,pendingSandboxRequest:{requestId:Y9,host:f_.host}}))})}return new Promise((Y9)=>{let
     q9=!1;function l9(_q){if(q9)return;q9=!0,Y9(_q)}pO((_q)=>[..._q,{hostPattern:f_,resolvePromise:l9}]);{let _q=DH.getState().replBridgePermissionCallbacks;if(_q){let
     z7=uYH.randomUUID();_q.sendRequest(z7,hD6,{host:f_.host},uYH.randomUUID(),`Allow network connection to ${f_.host}?`);let U1=_q.onResponse(z7,(MT)=>{U1();let KY=MT.behavior==="allow";pO((Bj)=>{return
     Bj.filter((Fj)=>Fj.hostPattern.host===f_.host).forEach((Fj)=>Fj.resolvePromise(KY)),Bj.filter((Fj)=>Fj.hostPattern.host!==f_.host)});let V0=mj.current.get(f_.host);if(V0){for(let Bj of
     V0)Bj();mj.current.delete(f_.host)}}),nw=()=>{U1(),_q.cancelRequest(z7)},C4=mj.current.get(f_.host)??[];C4.push(nw),mj.current.set(f_.host,C4)}}})},[e,DH]);if(s_.useEffect(()=>{let
     f_=y8.getSandboxUnavailableReason();if(!f_)return;if(y8.isSandboxRequired()){process.stderr.write(`
 9252: Error: sandbox required but unavailable: ${f_}
 9253: `+`  sandbox.failIfUnavailable is set \u2014 refusing to start without a working sandbox.
 9254:

 - <anonymous> (/$bunfs/root/src/entrypoints/cli.js:9251:5663)
 - WC (/$bunfs/root/src/entrypoints/cli.js:492:63749)
 - pj (/$bunfs/root/src/entrypoints/cli.js:492:76948)
 - fT (/$bunfs/root/src/entrypoints/cli.js:492:76827)
 - pj (/$bunfs/root/src/entrypoints/cli.js:492:77745)
 - fT (/$bunfs/root/src/entrypoints/cli.js:492:76827)
 - pj (/$bunfs/root/src/entrypoints/cli.js:492:76926)
 - fT (/$bunfs/root/src/entrypoints/cli.js:492:76827)
 - pj (/$bunfs/root/src/entrypoints/cli.js:492:77745)
 - fT (/$bunfs/root/src/entrypoints/cli.js:492:76827)
 - async <anonymous> (/$bunfs/root/src/entrypoints/cli.js:18815:2361)

Steps to Reproduce

  1. Start a session that runs to completion (so the JSONL file has at least one message entry):
    claude -p "Hello" --session-id my-test-session
  2. Resume it interactively:
    claude --resume my-test-session
  3. The REPL crashes immediately with the error above.

Any session that has existing messages in ~/.claude/projects/<encoded-path>/<session-id>.jsonl triggers the crash.

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.119

Claude Code Version

2.1.120

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

claude --resume crashes with "g9H is not a function" when session has existing messages

Version

2.1.120 (introduced in this version; 2.1.119 is unaffected)

Description

claude --resume <session-id> crashes immediately when the target session has existing messages. The REPL throws an unhandled error:

ERROR  g9H is not a function. (In 'g9H(K)', 'g9H' is undefined)

Downgrading to 2.1.119 resolves the issue.

Steps to Reproduce

  1. Start a session that runs to completion (so the JSONL file has at least one message entry):
    claude -p "Hello" --session-id my-test-session
  2. Resume it interactively:
    claude --resume my-test-session
  3. The REPL crashes immediately with the error above.

Any session that has existing messages in ~/.claude/projects/<encoded-path>/<session-id>.jsonl triggers the crash.

Root Cause (analysis)

In the REPL component (/$bunfs/root/src/entrypoints/cli.js), onSessionRestored is destructured from a hook call with enabled: false:

// enabled is always false in normal interactive mode
const S = useMemo(() => false, []);

const { onSessionRestored: g9H } = FXK({ enabled: S, ... });

A useEffect that runs on mount then calls g9H(initialMessages) when the resumed session has messages:

useEffect(() => {
  if (K && K.length > 0)
    HP_(K, K8()), hY8({...}), tC8(K), UQ(K),
    sYH.current.current = xz_(K, g8),
    g9H(K);   // ← crashes: g9H is undefined
}, []);

In 2.1.119 this did not crash — either FXK returned a no-op onSessionRestored, or the call site used optional chaining (g9H?.(K)). That guard was removed in 2.1.120.

Expected Behavior

claude --resume <session-id> opens the interactive REPL with the previous conversation loaded, as it did in 2.1.119.

Actual Behavior

The REPL crashes immediately with:

ERROR  g9H is not a function. (In 'g9H(K)', 'g9H' is undefined)

/$bunfs/root/src/entrypoints/cli.js:9251:5663

- <anonymous> (/$bunfs/root/src/entrypoints/cli.js:9251:5663)
- WC  (/$bunfs/root/src/entrypoints/cli.js:492:63749)
- ...

Workaround

Downgrade to 2.1.119:

npm install -g @anthropic-ai/[email protected]

Environment

  • OS: macOS Darwin 24.6.0 (arm64)
  • Node: via Homebrew
  • Shell: zsh

extent analysis

TL;DR

The issue can be fixed by adding a null check for g9H before calling it in the useEffect hook.

Guidance

  1. Identify the problematic code: The crash occurs in the useEffect hook where g9H is called without a null check.
  2. Add a null check: Modify the code to check if g9H is defined before calling it: if (g9H) g9H(K);.
  3. Verify the fix: Test the modified code to ensure the crash no longer occurs when resuming a session with existing messages.

Example

useEffect(() => {
  if (K && K.length > 0)
    HP_(K, K8()), hY8({...}), tC8(K), UQ(K),
    sYH.current.current = xz_(K, g8);
  if (g9H) g9H(K); // Add null check
}, []);

Notes

This fix assumes that g9H being undefined is not a critical issue and the code can continue executing without it. If g9H is essential, further investigation is needed to determine why it's undefined and how to properly define it.

Recommendation

Apply the workaround by adding a null check for g9H to prevent the crash. If the issue persists or g9H is critical, consider downgrading to version 2.1.119 until a more comprehensive fix is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] `claude --resume` crashes with "g9H is not a function" when session has existing messages [1 participants]