commandmate 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +5 -5
  3. package/.next/app-path-routes-manifest.json +1 -1
  4. package/.next/build-manifest.json +2 -2
  5. package/.next/cache/.tsbuildinfo +1 -1
  6. package/.next/cache/config.json +3 -3
  7. package/.next/cache/webpack/client-production/0.pack +0 -0
  8. package/.next/cache/webpack/client-production/1.pack +0 -0
  9. package/.next/cache/webpack/client-production/2.pack +0 -0
  10. package/.next/cache/webpack/client-production/index.pack +0 -0
  11. package/.next/cache/webpack/client-production/index.pack.old +0 -0
  12. package/.next/cache/webpack/edge-server-production/0.pack +0 -0
  13. package/.next/cache/webpack/edge-server-production/index.pack +0 -0
  14. package/.next/cache/webpack/server-production/0.pack +0 -0
  15. package/.next/cache/webpack/server-production/index.pack +0 -0
  16. package/.next/next-server.js.nft.json +1 -1
  17. package/.next/prerender-manifest.json +1 -1
  18. package/.next/required-server-files.json +1 -1
  19. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  20. package/.next/server/app/api/app/update-check/route.js +1 -1
  21. package/.next/server/app/api/worktrees/[id]/route.js +1 -1
  22. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  23. package/.next/server/app/page_client-reference-manifest.js +1 -1
  24. package/.next/server/app/proxy/[...path]/route.js +1 -1
  25. package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
  26. package/.next/server/app/worktrees/[id]/page.js +4 -4
  27. package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
  28. package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
  29. package/.next/server/app-paths-manifest.json +8 -8
  30. package/.next/server/chunks/2314.js +1 -1
  31. package/.next/server/chunks/539.js +1 -1
  32. package/.next/server/chunks/6228.js +1 -1
  33. package/.next/server/chunks/7425.js +41 -35
  34. package/.next/server/chunks/9446.js +1 -1
  35. package/.next/server/middleware-manifest.json +5 -5
  36. package/.next/server/pages/500.html +1 -1
  37. package/.next/server/pages-manifest.json +1 -1
  38. package/.next/server/server-reference-manifest.json +1 -1
  39. package/.next/static/chunks/{8091-274bc0716106e7fc.js → 8091-c0e955616dd86f82.js} +1 -1
  40. package/.next/static/chunks/app/worktrees/[id]/page-9c0c64488c17db3c.js +1 -0
  41. package/.next/static/css/fa3df0e6f437f2ba.css +3 -0
  42. package/.next/trace +5 -5
  43. package/dist/server/src/lib/cli-tools/types.js +35 -1
  44. package/dist/server/src/lib/cli-tools/vibe-local.js +12 -3
  45. package/dist/server/src/lib/db-migrations.js +17 -1
  46. package/dist/server/src/lib/db.js +21 -2
  47. package/dist/server/src/lib/prompt-detector.js +23 -4
  48. package/dist/server/src/lib/response-poller.js +28 -12
  49. package/package.json +4 -4
  50. package/.next/static/chunks/app/worktrees/[id]/page-78580947c201d698.js +0 -1
  51. package/.next/static/css/e85de230ef5ddc40.css +0 -3
  52. /package/.next/static/{O7EDFfAYQNe_HRbORxQAC → BiyH3zkbySg7ZWTeZuXqj}/_buildManifest.js +0 -0
  53. /package/.next/static/{O7EDFfAYQNe_HRbORxQAC → BiyH3zkbySg7ZWTeZuXqj}/_ssgManifest.js +0 -0
  54. /package/.next/static/chunks/app/{page-060057e02b841125.js → page-9e523a8f415bc707.js} +0 -0
@@ -1 +1 @@
1
- "use strict";exports.id=9446,exports.ids=[9446],exports.modules={89194:(e,t,s)=>{s.d(t,{Lg:()=>r,NA:()=>a});var i=s(10927),n=s(23816);let o=(0,s(43895).h)("cli-session");async function r(e,t){let s=n.g.getInstance().getTool(t).getSessionName(e);return await (0,i.Hk)(s)}async function a(e,t,s=1e3){let r=o.withContext({worktreeId:e,cliToolId:t});r.debug("captureSessionOutput:start",{requestedLines:s});let a=n.g.getInstance().getTool(t),l=a.getSessionName(e);if(!await (0,i.Hk)(l))throw r.debug("captureSessionOutput:sessionNotFound",{sessionName:l}),Error(`${a.name} session ${l} does not exist`);try{let e=await (0,i.xq)(l,{startLine:-s}),t=e.split("\n").length;return r.debug("captureSessionOutput:success",{actualLines:t,lastFewLines:e.split("\n").slice(-3).join(" | ")}),e}catch(t){let e=t instanceof Error?t.message:String(t);throw r.error("captureSessionOutput:failed",{error:e}),Error(`Failed to capture ${a.name} output: ${e}`)}}},23816:(e,t,s)=>{s.d(t,{g:()=>T});var i=s(61282),n=s(21764);let o=/^[a-zA-Z0-9_-]+$/;var r=s(10927);let a=(0,n.promisify)(i.exec);class l{async isInstalled(){try{return await a(`which ${this.command}`,{timeout:5e3}),!0}catch{return!1}}getSessionName(e){let t=`mcbd-${this.id}-${e}`;return function(e){if(!o.test(e))throw Error(`Invalid session name format: ${e}`)}(t),t}async interrupt(e){let t=this.getSessionName(e);await (0,r.ZV)(t,"Escape")}}var c=s(62648);class u extends l{async isInstalled(){return await (0,c.Uv)()}async isRunning(e){return await (0,c.YI)(e)}async startSession(e,t){await (0,c.ym)({worktreeId:e,worktreePath:t})}async sendMessage(e,t){await (0,c.xd)(e,t)}async killSession(e){await (0,c._f)(e)}constructor(...e){super(...e),this.id="claude",this.name="Claude Code",this.command="claude"}}var m=s(92900);let d=(0,n.promisify)(i.exec);function p(e){return e instanceof Error?e.message:String(e)}class f extends l{async isRunning(e){let t=this.getSessionName(e);return await (0,r.Hk)(t)}async startSession(e,t){if(!await this.isInstalled())throw Error("Codex CLI is not installed or not in PATH");let s=this.getSessionName(e);if(await (0,r.Hk)(s)){console.log(`Codex session ${s} already exists`);return}try{await (0,r.ed)({sessionName:s,workingDirectory:t,historyLimit:5e4}),await new Promise(e=>setTimeout(e,100)),await (0,r.Is)(s,"codex",!0),await new Promise(e=>setTimeout(e,3e3)),await (0,r.Is)(s,"2",!0),await new Promise(e=>setTimeout(e,200)),await d(`tmux send-keys -t "${s}" Down`),await new Promise(e=>setTimeout(e,200)),await d(`tmux send-keys -t "${s}" Enter`),await new Promise(e=>setTimeout(e,200)),console.log(`✓ Started Codex session: ${s}`)}catch(t){let e=p(t);throw Error(`Failed to start Codex session: ${e}`)}}async sendMessage(e,t){let s=this.getSessionName(e);if(!await (0,r.Hk)(s))throw Error(`Codex session ${s} does not exist. Start the session first.`);try{await (0,r.Is)(s,t,!1),await new Promise(e=>setTimeout(e,100)),await d(`tmux send-keys -t "${s}" C-m`),await new Promise(e=>setTimeout(e,200)),t.includes("\n")&&await (0,m.N)(s),console.log(`✓ Sent message to Codex session: ${s}`)}catch(t){let e=p(t);throw Error(`Failed to send message to Codex: ${e}`)}}async killSession(e){let t=this.getSessionName(e);try{await (0,r.Hk)(t)&&(await d(`tmux send-keys -t "${t}" C-d`),await new Promise(e=>setTimeout(e,500))),await (0,r.AJ)(t)&&console.log(`✓ Stopped Codex session: ${t}`)}catch(t){let e=p(t);throw console.error(`Error stopping Codex session: ${e}`),t}}constructor(...e){super(...e),this.id="codex",this.name="Codex CLI",this.command="codex"}}function h(e){return e instanceof Error?e.message:String(e)}class g extends l{async isRunning(e){let t=this.getSessionName(e);return await (0,r.Hk)(t)}async startSession(e,t){if(!await this.isInstalled())throw Error("Gemini CLI is not installed or not in PATH");let s=this.getSessionName(e);if(await (0,r.Hk)(s)){console.log(`Gemini session ${s} already exists`);return}try{await (0,r.ed)({sessionName:s,workingDirectory:t,historyLimit:5e4}),await new Promise(e=>setTimeout(e,100)),await (0,r.Is)(s,"gemini",!0),await new Promise(e=>setTimeout(e,6e3)),await this.handleTrustDialog(s),console.log(`✓ Started Gemini session: ${s}`)}catch(t){let e=h(t);throw Error(`Failed to start Gemini session: ${e}`)}}async handleTrustDialog(e){for(let t=0;t<10;t++){try{let t=await (0,r.xq)(e,50);if(t.includes("Do you trust this folder?")){await (0,r.ZV)(e,"Enter"),await new Promise(e=>setTimeout(e,2e3)),console.log("✓ Auto-trusted folder for Gemini session");return}if(t.match(/^[>❯]\s*$/m)){console.log("✓ Gemini prompt detected - no trust dialog needed");return}}catch{}await new Promise(e=>setTimeout(e,1e3))}console.log("⚠ Trust dialog detection timed out - proceeding anyway")}async sendMessage(e,t){let s=this.getSessionName(e);if(!await (0,r.Hk)(s))throw Error(`Gemini session ${s} does not exist. Start the session first.`);try{await (0,r.Is)(s,t,!1),await new Promise(e=>setTimeout(e,100)),await (0,r.ZV)(s,"C-m"),await new Promise(e=>setTimeout(e,200)),t.includes("\n")&&await (0,m.N)(s),console.log(`✓ Sent message to Gemini session: ${s}`)}catch(t){let e=h(t);throw Error(`Failed to send message to Gemini: ${e}`)}}async killSession(e){let t=this.getSessionName(e);try{await (0,r.Hk)(t)&&(await (0,r.ZV)(t,"C-c"),await new Promise(e=>setTimeout(e,300)),await (0,r.Is)(t,"/quit",!0),await new Promise(e=>setTimeout(e,500))),await (0,r.AJ)(t)&&console.log(`✓ Stopped Gemini session: ${t}`)}catch(t){let e=h(t);throw console.error(`Error stopping Gemini session: ${e}`),t}}constructor(...e){super(...e),this.id="gemini",this.name="Gemini CLI",this.command="gemini"}}var w=s(83513),y=s(97425),$=s(75748);function x(e){return e instanceof Error?e.message:String(e)}class C extends l{async isRunning(e){let t=this.getSessionName(e);return await (0,r.Hk)(t)}async startSession(e,t){if(!await this.isInstalled())throw Error("vibe-local is not installed or not in PATH");let s=this.getSessionName(e);if(await (0,r.Hk)(s)){console.log(`Vibe Local session ${s} already exists`);return}try{await (0,r.ed)({sessionName:s,workingDirectory:t,historyLimit:5e4}),await new Promise(e=>setTimeout(e,100));let i="vibe-local -y";try{let t=(0,y.getDbInstance)(),s=(0,$.gU)(t,e);s?.vibeLocalModel&&w.Y1.test(s.vibeLocalModel)&&(i=`vibe-local -y -m ${s.vibeLocalModel}`)}catch{}await (0,r.Is)(s,i,!0),await new Promise(e=>setTimeout(e,5e3)),console.log(`✓ Started Vibe Local session: ${s}`)}catch(t){let e=x(t);throw Error(`Failed to start Vibe Local session: ${e}`)}}async sendMessage(e,t){let s=this.getSessionName(e);if(!await (0,r.Hk)(s))throw Error(`Vibe Local session ${s} does not exist. Start the session first.`);try{await (0,r.Is)(s,t,!1),await new Promise(e=>setTimeout(e,100)),await (0,r.ZV)(s,"C-m"),await new Promise(e=>setTimeout(e,200)),await (0,r.ZV)(s,"C-m"),await new Promise(e=>setTimeout(e,200)),t.includes("\n")&&await (0,m.N)(s),console.log(`✓ Sent message to Vibe Local session: ${s}`)}catch(t){let e=x(t);throw Error(`Failed to send message to Vibe Local: ${e}`)}}async killSession(e){let t=this.getSessionName(e);try{await (0,r.Hk)(t)&&(await (0,r.ZV)(t,"C-c"),await new Promise(e=>setTimeout(e,300)),await (0,r.ZV)(t,"C-c"),await new Promise(e=>setTimeout(e,500))),await (0,r.AJ)(t)&&console.log(`✓ Stopped Vibe Local session: ${t}`)}catch(t){let e=x(t);throw console.error(`Error stopping Vibe Local session: ${e}`),t}}constructor(...e){super(...e),this.id="vibe-local",this.name="Vibe Local",this.command="vibe-local"}}var S=s(59991);class T{constructor(){this.tools=new Map,this.tools.set("claude",new u),this.tools.set("codex",new f),this.tools.set("gemini",new g),this.tools.set("vibe-local",new C)}static getInstance(){return T.instance||(T.instance=new T),T.instance}getTool(e){let t=this.tools.get(e);if(!t)throw Error(`CLI tool '${e}' not found`);return t}getAllTools(){return Array.from(this.tools.values())}async getToolInfo(e){let t=this.getTool(e),s=await t.isInstalled();return{id:t.id,name:t.name,command:t.command,installed:s}}async getAllToolsInfo(){return Promise.all(this.getAllTools().map(async e=>{let t=await e.isInstalled();return{id:e.id,name:e.name,command:e.command,installed:t}}))}async getInstalledTools(){return(await this.getAllToolsInfo()).filter(e=>e.installed)}stopPollers(e,t){(0,S.FN)(e,t)}}},63661:(e,t,s)=>{s.d(t,{F:()=>r,J:()=>f});let i=(0,s(43895).h)("prompt-detector"),n=[{regex:/^(.+)\s+\(y\/n\)\s*$/m},{regex:/^(.+)\s+\[y\/N\]\s*$/m,defaultOption:"no"},{regex:/^(.+)\s+\[Y\/n\]\s*$/m,defaultOption:"yes"},{regex:/^(.+)\s+\(yes\/no\)\s*$/m}];function o(e,t,s,i){return{isPrompt:!0,promptData:{type:"yes_no",question:e,options:["yes","no"],status:"pending",...void 0!==i&&{defaultOption:i},instructionText:s},cleanContent:t,rawContent:s}}function r(e,t){i.debug("detectPrompt:start",{outputLength:e.length});let s=e.split("\n").slice(-20).join("\n"),r=function(e,t){let s=t?.requireDefaultIndicator??!0,i=e.split("\n"),n=i.length;for(;n>0&&""===i[n-1].trim();)n--;let o=Math.max(0,n-50);if(s){let t=!1;for(let e=o;e<n;e++){let s=i[e].trim();if(l.test(s)){t=!0;break}}if(!t)return m(e)}let r=[],d=-1;for(let t=n-1;t>=o;t--){let s=i[t].trim(),n=s.match(l);if(n){let e=parseInt(n[1],10),t=n[2].trim();r.unshift({number:e,label:t,isDefault:!0});continue}let o=s.match(c);if(o){let e=parseInt(o[1],10),t=o[2].trim();r.unshift({number:e,label:t,isDefault:!1});continue}if(0===r.length&&(s.startsWith("❯")||s.startsWith("●")))return m(e);if(r.length>0&&s&&!u.test(s)){if(p(s)){d=t;break}if(function(e,t){let s=t.endsWith("?")||t.endsWith("?");return!!(!s&&/^\s{2,}[^\d]/.test(e)&&!/^\s*\d+\./.test(e)||t.length<5&&!s||/^[\/~]/.test(t)||t.length>=2&&/^[a-zA-Z0-9_-]+$/.test(t))}(i[t],s))continue;d=t;break}}if(!function(e){if(0===e.length||1!==e[0])return!1;for(let t=1;t<e.length;t++)if(e[t]!==e[t-1]+1)return!1;return!0}(r.map(e=>e.number)))return m(e);let f=r.some(e=>e.isDefault);if(r.length<2||s&&!f||!s&&(-1===d||!p(i[d]?.trim()??"")&&!function(e,t,s,i){let n=Math.max(i,t-3);for(let s=t-1;s>=n;s--){let t=e[s]?.trim()??"";if(!(!t||u.test(t))&&p(t))return!0}return!1}(i,d,0,o)))return m(e);let h=function(e,t){if(t<0)return"Please select an option:";let s=[];for(let i=Math.max(0,t-5);i<=t;i++){let t=e[i].trim();t&&!u.test(t)&&s.push(t)}return s.join(" ")}(i,d),g=function(e,t,s){if(t<0)return;let i=e.slice(Math.max(0,t-19),s).map(e=>e.trimEnd()).join("\n").trim();return i.length>0?i:void 0}(i,d,n);return{isPrompt:!0,promptData:{type:"multiple_choice",question:h.trim(),options:r.map(e=>{let t=a.some(t=>t.test(e.label));return{number:e.number,label:e.label,isDefault:e.isDefault,requiresTextInput:t}}),status:"pending",instructionText:g},cleanContent:h.trim(),rawContent:function(e){let t=e.split("\n"),s=(t.length>200?t.slice(-200):t).join("\n");return s.length>5e3&&(s=s.slice(-5e3)),s}(e.trim())}}(e,t);if(r.isPrompt)return i.info("detectPrompt:multipleChoice",{isPrompt:!0,question:r.promptData?.question,optionsCount:r.promptData?.options?.length}),r;let d=s.trim();for(let e of n){let t=s.match(e.regex);if(t){let s=t[1].trim();return o(s,s,d,e.defaultOption)}}let f=s.match(/^(.*?)Approve\?\s*$/m);if(f){let e=f[1].trim();return o(e?`${e} Approve?`:"Approve?",e||"Approve?",d)}return i.debug("detectPrompt:complete",{isPrompt:!1}),{isPrompt:!1,cleanContent:e.trim()}}let a=[/type\s+here/i,/tell\s+(me|claude)/i,/enter\s+/i,/custom/i,/differently/i],l=/^\s*[\u276F\u25CF]\s*(\d+)\.\s*(.+)$/,c=/^\s*(\d+)\.\s*(.+)$/,u=/^[-─]+$/;function m(e){return{isPrompt:!1,cleanContent:e.trim()}}let d=/(?:select|choose|pick|which|what|how|where|enter|type|specify|confirm|approve|accept|reject|decide|preference|option)/i;function p(e){return 0!==e.length&&!!(e.includes("?")||e.includes("?")||d.test(e))}function f(e,t="yes_no"){let s=e.toLowerCase().trim();if("multiple_choice"===t){if(/^\d+$/.test(s))return s;throw Error("Invalid answer for multiple choice prompt. Expected a number.")}if("yes"===s||"y"===s)return"y";if("no"===s||"n"===s)return"n";throw Error("Invalid answer for yes/no prompt. Expected 'yes', 'no', 'y', or 'n'.")}},59991:(e,t,s)=>{s.d(t,{FN:()=>T,RJ:()=>$,ci:()=>y,cn:()=>S});var i=s(89194),n=s(97425),o=s(75748),r=s(68507),a=s(63661),l=s(76966),c=s(89287),u=s(19377);let m=["Waiting for auth","⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function d(e){return{response:"",isComplete:!1,lineCount:e}}function p(e,t,s,i,n,o){let r=x(t,s,i,n,o),a=e.slice(r);return{response:(0,u.vp)(a.join("\n")),isComplete:!0,lineCount:s}}let f=new Map,h=new Map;function g(e,t){return`${e}:${t}`}function w(e,t){let s=(0,u.Sg)(t);return(0,a.F)((0,u.BN)((0,u.vp)(e)),s)}function y(e){let t=(0,u.vp)(e).split("\n"),s=-1;for(let e=t.length-1;e>=0;e--)if(/^❯\s+\S/.test(t[e])){s=e;break}let i=s>=0?s+1:0,n=t.slice(i),o=[/CLAUDE_HOOKS_/,/\/bin\/claude/,/^claude\s*$/,/@.*\s+%\s*$/,/^[^⏺]*curl.*POST/,/^[^⏺]*Content-Type/,/^[^⏺]*export\s+CLAUDE_/,/^\s*$/,/^[╭╮╰╯│─\s]+$/,/^[│╭╮╰╯].*[│╭╮╰╯]$/,/Claude Code v[\d.]+/,/^Tips for getting started/,/^Welcome back/,/Run \/init to create/,/^Recent activity/,/^No recent activity/,/▐▛███▜▌|▝▜█████▛▘|▘▘ ▝▝/,/^\s*Opus \d+\.\d+\s*·\s*Claude Max/,/\.com's Organization/,/\?\s*for shortcuts\s*$/,/^─{10,}$/,/^❯\s*$/,u.d8],r=[];for(let e of n)!o.some(t=>t.test(e))&&e.trim()&&r.push(e);return r.join("\n").trim()}function $(e){let t=e.split("\n"),s=[],i=[/^maenokota@.*%/,/^zsh:/,/^feature-issue-\d+/,/^\s*$/],n=!1,o=[];for(let e of t){if(e.includes("✦")){n=!0;let t=e.indexOf("✦"),s=e.substring(t+1).trim();s&&o.push(s);continue}if(n){if(i.some(t=>t.test(e)))continue;o.push(e)}}if(o.length>0)return o.join("\n").trim();for(let e of t)i.some(t=>t.test(e))||s.push(e);return s.join("\n").trim()}function x(e,t,s,i,n){if((e=Math.max(0,e))>=t||s){let e=n(40);return e>=0?e+1:0}if("codex"===i)return Math.max(0,e);if(e>=t-5){let e=n(50);return e>=0?e+1:Math.max(0,t-40)}return Math.max(0,e)}async function C(e,t){let s=(0,n.getDbInstance)();try{if(!(0,o.gU)(s,e))return console.error(`Worktree ${e} not found, stopping poller`),T(e,t),!1;if(!await (0,i.Lg)(e,t))return T(e,t),!1;let n=(0,o.zl)(s,e,t),a=n?.lastCapturedLine||0,f=await (0,i.NA)(e,t,1e4),h=function(e,t,s){let i=e.split("\n"),n=i.length;for(;n>0&&""===i[n-1].trim();)n--;let o=i.slice(0,n),r=o.length,a=r>0&&t>25&&r+25<t,l=r>0&&t>50&&r<50,c=a||l;if(!c&&r<t-5)return null;let f=Math.max(0,r-20),h=o.slice(f).join("\n"),{promptPattern:g,separatorPattern:y,thinkingPattern:$,skipPatterns:C}=(0,u.bs)(s),S=(e=60)=>{let t="codex"===s?/^›\s+(?!Implement|Find and fix|Type|Summarize)/:/^[>❯]\s+\S/;for(let s=r-1;s>=Math.max(0,r-e);s--){let e=(0,u.vp)(o[s]);if(t.test(e))return s}return -1};if("claude"===s&&w(o.join("\n"),s).isPrompt)return p(o,t,r,c,s,S);let T=(0,u.vp)(h),P=g.test(T),v=y.test(T),b=$.test(T),I=("codex"===s||"gemini"===s||"vibe-local"===s)&&P&&!b,k="claude"===s&&P&&v&&!b;if(I||k){let e=[],i=x(t,r,c,s,S),n=r;for(let t=i;t<r;t++){let i=o[t],r=(0,u.vp)(i);if("codex"===s&&/^›\s+/.test(r)||"gemini"===s&&/^(%|\$|.*@.*[%$#])\s*$/.test(r)){n=t;break}C.some(e=>e.test(r))||e.push(i)}let a=e.join("\n").trim(),l=a.split("\n").slice(-5).join("\n");if($.test(l))return d(r);if("claude"===s){let e=(0,u.vp)(a),t=/[╭╮╰╯│]/.test(e)||/░{3,}/.test(e)||/▓{3,}/.test(e),s=/Claude Code|claude\/|v\d+\.\d+/.test(e),i=/Tip:|for shortcuts|\?\s*for help/.test(e),n=/^\s*\/Users\/.*$/m.test(e)&&e.split("\n").length<30,o=e.match(/^[>❯]\s+(\S.*)$/m);if(o){let t=e.indexOf(o[0]);if(0===e.substring(t+o[0].length).trim().split("\n").filter(e=>{let t=e.trim();return t&&!C.some(e=>e.test(t))&&!/^─+$/.test(t)}).length)return d(r)}else if((t||s||i||n)&&a.length<2e3)return d(r)}return"gemini"===s&&((a.match(/[░███]/g)||[]).length>.3*a.length||m.some(e=>a.includes(e))||!a.includes("✦")&&a.length<10)?d(r):{response:a,isComplete:!0,lineCount:n}}if(w(o.join("\n"),s).isPrompt)return p(o,t,r,c,s,S);let E=[],L=c||t>=r-5,N=L?S(80):-1,M=L?N>=0?N+1:Math.max(0,r-80):Math.max(0,t);for(let e=M;e<r;e++){let t=o[e],s=(0,u.vp)(t);C.some(e=>e.test(s))||E.push(t)}let D=E.join("\n").trim();return D?{response:D,isComplete:!1,lineCount:r}:d(r)}(f,a,t);if(!h||!h.isComplete){let{thinkingPattern:i}=(0,u.bs)(t),n=(0,u.vp)(f).split("\n").slice(-5).join("\n");if(i.test(n)){let i=(0,o.GP)(s,e,t);i>0&&console.log(`Marked ${i} pending prompt(s) as answered (thinking detected) for ${e}`)}return!1}if(h.lineCount===a&&!n?.inProgressMessageId)return!1;if(h.lineCount<=a)return console.log(`[checkForResponse] Already saved up to line ${a}, skipping (result: ${h.lineCount})`),!1;let g=w(h.response,t);if(g.isPrompt){(0,o.Mf)(s,e,t);let i=(0,o.tn)(s,{worktreeId:e,role:"assistant",content:g.rawContent||g.cleanContent,messageType:"prompt",promptData:g.promptData,timestamp:new Date,cliToolId:t});return(0,o.IH)(s,e,t,h.lineCount),(0,r.ps)("message",{worktreeId:e,message:i}),T(e,t),!0}if(!h.response||""===h.response.trim())return(0,o.IH)(s,e,t,h.lineCount),!1;let C="claude"===t?(0,c.Z)(h.response):void 0,S=h.response;if("gemini"===t?S=$(h.response):"claude"===t&&(S=y(h.response)),!S||""===S.trim()||"[No content]"===S)return(0,o.IH)(s,e,t,h.lineCount),(0,o.Mf)(s,e,t),!1;S&&await (0,l.o)(s,e,S,t);let P=(0,o.GP)(s,e,t);P>0&&console.log(`Marked ${P} pending prompt(s) as answered for ${e}`);let v=(0,o.zl)(s,e,t);if(v&&h.lineCount<=v.lastCapturedLine)return console.log(`[checkForResponse] Race condition detected, skipping save (result: ${h.lineCount}, current: ${v.lastCapturedLine})`),!1;let b=(0,o.tn)(s,{worktreeId:e,role:"assistant",content:S,messageType:"normal",timestamp:new Date,cliToolId:t,summary:C?.summary,logFileName:C?.logFileName,requestId:C?.requestId});return(0,r.ps)("message",{worktreeId:e,message:b}),(0,o.IH)(s,e,t,h.lineCount),!0}catch(t){return console.error(`Error checking for response (${e}):`,t instanceof Error?t.message:String(t)),!1}}function S(e,t){let s=g(e,t);T(e,t),h.set(s,Date.now()),function e(t,s){let i=g(t,s),n=setTimeout(async()=>{let n=h.get(i);if(n&&Date.now()-n>18e5){T(t,s);return}try{await C(t,s)}catch(e){console.error("[Poller] Error:",e)}f.has(i)&&e(t,s)},2e3);f.set(i,n)}(e,t)}function T(e,t){let s=g(e,t),i=f.get(s);i&&(clearTimeout(i),f.delete(s),h.delete(s))}}};
1
+ "use strict";exports.id=9446,exports.ids=[9446],exports.modules={89194:(e,t,s)=>{s.d(t,{Lg:()=>r,NA:()=>a});var i=s(10927),n=s(23816);let o=(0,s(43895).h)("cli-session");async function r(e,t){let s=n.g.getInstance().getTool(t).getSessionName(e);return await (0,i.Hk)(s)}async function a(e,t,s=1e3){let r=o.withContext({worktreeId:e,cliToolId:t});r.debug("captureSessionOutput:start",{requestedLines:s});let a=n.g.getInstance().getTool(t),l=a.getSessionName(e);if(!await (0,i.Hk)(l))throw r.debug("captureSessionOutput:sessionNotFound",{sessionName:l}),Error(`${a.name} session ${l} does not exist`);try{let e=await (0,i.xq)(l,{startLine:-s}),t=e.split("\n").length;return r.debug("captureSessionOutput:success",{actualLines:t,lastFewLines:e.split("\n").slice(-3).join(" | ")}),e}catch(t){let e=t instanceof Error?t.message:String(t);throw r.error("captureSessionOutput:failed",{error:e}),Error(`Failed to capture ${a.name} output: ${e}`)}}},23816:(e,t,s)=>{s.d(t,{g:()=>T});var i=s(61282),n=s(21764);let o=/^[a-zA-Z0-9_-]+$/;var r=s(10927);let a=(0,n.promisify)(i.exec);class l{async isInstalled(){try{return await a(`which ${this.command}`,{timeout:5e3}),!0}catch{return!1}}getSessionName(e){let t=`mcbd-${this.id}-${e}`;return function(e){if(!o.test(e))throw Error(`Invalid session name format: ${e}`)}(t),t}async interrupt(e){let t=this.getSessionName(e);await (0,r.ZV)(t,"Escape")}}var c=s(62648);class u extends l{async isInstalled(){return await (0,c.Uv)()}async isRunning(e){return await (0,c.YI)(e)}async startSession(e,t){await (0,c.ym)({worktreeId:e,worktreePath:t})}async sendMessage(e,t){await (0,c.xd)(e,t)}async killSession(e){await (0,c._f)(e)}constructor(...e){super(...e),this.id="claude",this.name="Claude Code",this.command="claude"}}var m=s(92900);let d=(0,n.promisify)(i.exec);function p(e){return e instanceof Error?e.message:String(e)}class f extends l{async isRunning(e){let t=this.getSessionName(e);return await (0,r.Hk)(t)}async startSession(e,t){if(!await this.isInstalled())throw Error("Codex CLI is not installed or not in PATH");let s=this.getSessionName(e);if(await (0,r.Hk)(s)){console.log(`Codex session ${s} already exists`);return}try{await (0,r.ed)({sessionName:s,workingDirectory:t,historyLimit:5e4}),await new Promise(e=>setTimeout(e,100)),await (0,r.Is)(s,"codex",!0),await new Promise(e=>setTimeout(e,3e3)),await (0,r.Is)(s,"2",!0),await new Promise(e=>setTimeout(e,200)),await d(`tmux send-keys -t "${s}" Down`),await new Promise(e=>setTimeout(e,200)),await d(`tmux send-keys -t "${s}" Enter`),await new Promise(e=>setTimeout(e,200)),console.log(`✓ Started Codex session: ${s}`)}catch(t){let e=p(t);throw Error(`Failed to start Codex session: ${e}`)}}async sendMessage(e,t){let s=this.getSessionName(e);if(!await (0,r.Hk)(s))throw Error(`Codex session ${s} does not exist. Start the session first.`);try{await (0,r.Is)(s,t,!1),await new Promise(e=>setTimeout(e,100)),await d(`tmux send-keys -t "${s}" C-m`),await new Promise(e=>setTimeout(e,200)),t.includes("\n")&&await (0,m.N)(s),console.log(`✓ Sent message to Codex session: ${s}`)}catch(t){let e=p(t);throw Error(`Failed to send message to Codex: ${e}`)}}async killSession(e){let t=this.getSessionName(e);try{await (0,r.Hk)(t)&&(await d(`tmux send-keys -t "${t}" C-d`),await new Promise(e=>setTimeout(e,500))),await (0,r.AJ)(t)&&console.log(`✓ Stopped Codex session: ${t}`)}catch(t){let e=p(t);throw console.error(`Error stopping Codex session: ${e}`),t}}constructor(...e){super(...e),this.id="codex",this.name="Codex CLI",this.command="codex"}}function h(e){return e instanceof Error?e.message:String(e)}class g extends l{async isRunning(e){let t=this.getSessionName(e);return await (0,r.Hk)(t)}async startSession(e,t){if(!await this.isInstalled())throw Error("Gemini CLI is not installed or not in PATH");let s=this.getSessionName(e);if(await (0,r.Hk)(s)){console.log(`Gemini session ${s} already exists`);return}try{await (0,r.ed)({sessionName:s,workingDirectory:t,historyLimit:5e4}),await new Promise(e=>setTimeout(e,100)),await (0,r.Is)(s,"gemini",!0),await new Promise(e=>setTimeout(e,6e3)),await this.handleTrustDialog(s),console.log(`✓ Started Gemini session: ${s}`)}catch(t){let e=h(t);throw Error(`Failed to start Gemini session: ${e}`)}}async handleTrustDialog(e){for(let t=0;t<10;t++){try{let t=await (0,r.xq)(e,50);if(t.includes("Do you trust this folder?")){await (0,r.ZV)(e,"Enter"),await new Promise(e=>setTimeout(e,2e3)),console.log("✓ Auto-trusted folder for Gemini session");return}if(t.match(/^[>❯]\s*$/m)){console.log("✓ Gemini prompt detected - no trust dialog needed");return}}catch{}await new Promise(e=>setTimeout(e,1e3))}console.log("⚠ Trust dialog detection timed out - proceeding anyway")}async sendMessage(e,t){let s=this.getSessionName(e);if(!await (0,r.Hk)(s))throw Error(`Gemini session ${s} does not exist. Start the session first.`);try{await (0,r.Is)(s,t,!1),await new Promise(e=>setTimeout(e,100)),await (0,r.ZV)(s,"C-m"),await new Promise(e=>setTimeout(e,200)),t.includes("\n")&&await (0,m.N)(s),console.log(`✓ Sent message to Gemini session: ${s}`)}catch(t){let e=h(t);throw Error(`Failed to send message to Gemini: ${e}`)}}async killSession(e){let t=this.getSessionName(e);try{await (0,r.Hk)(t)&&(await (0,r.ZV)(t,"C-c"),await new Promise(e=>setTimeout(e,300)),await (0,r.Is)(t,"/quit",!0),await new Promise(e=>setTimeout(e,500))),await (0,r.AJ)(t)&&console.log(`✓ Stopped Gemini session: ${t}`)}catch(t){let e=h(t);throw console.error(`Error stopping Gemini session: ${e}`),t}}constructor(...e){super(...e),this.id="gemini",this.name="Gemini CLI",this.command="gemini"}}var w=s(83513),y=s(97425),$=s(75748);function x(e){return e instanceof Error?e.message:String(e)}class C extends l{async isRunning(e){let t=this.getSessionName(e);return await (0,r.Hk)(t)}async startSession(e,t){if(!await this.isInstalled())throw Error("vibe-local is not installed or not in PATH");let s=this.getSessionName(e);if(await (0,r.Hk)(s)){console.log(`Vibe Local session ${s} already exists`);return}try{await (0,r.ed)({sessionName:s,workingDirectory:t,historyLimit:5e4}),await new Promise(e=>setTimeout(e,100));let i="vibe-local -y";try{let t=(0,y.getDbInstance)(),s=(0,$.gU)(t,e);s?.vibeLocalModel&&w.Y1.test(s.vibeLocalModel)&&(i+=` -m ${s.vibeLocalModel}`);let n=s?.vibeLocalContextWindow;(0,w.ZP)(n)&&(i+=` --context-window ${Number(n)}`)}catch{}await (0,r.Is)(s,i,!0),await new Promise(e=>setTimeout(e,5e3)),console.log(`✓ Started Vibe Local session: ${s}`)}catch(t){let e=x(t);throw Error(`Failed to start Vibe Local session: ${e}`)}}async sendMessage(e,t){let s=this.getSessionName(e);if(!await (0,r.Hk)(s))throw Error(`Vibe Local session ${s} does not exist. Start the session first.`);try{await (0,r.Is)(s,t,!1),await new Promise(e=>setTimeout(e,100)),await (0,r.ZV)(s,"C-m"),await new Promise(e=>setTimeout(e,200)),await (0,r.ZV)(s,"C-m"),await new Promise(e=>setTimeout(e,200)),t.includes("\n")&&await (0,m.N)(s),console.log(`✓ Sent message to Vibe Local session: ${s}`)}catch(t){let e=x(t);throw Error(`Failed to send message to Vibe Local: ${e}`)}}async killSession(e){let t=this.getSessionName(e);try{await (0,r.Hk)(t)&&(await (0,r.ZV)(t,"C-c"),await new Promise(e=>setTimeout(e,300)),await (0,r.ZV)(t,"C-c"),await new Promise(e=>setTimeout(e,500))),await (0,r.AJ)(t)&&console.log(`✓ Stopped Vibe Local session: ${t}`)}catch(t){let e=x(t);throw console.error(`Error stopping Vibe Local session: ${e}`),t}}constructor(...e){super(...e),this.id="vibe-local",this.name="Vibe Local",this.command="vibe-local"}}var S=s(59991);class T{constructor(){this.tools=new Map,this.tools.set("claude",new u),this.tools.set("codex",new f),this.tools.set("gemini",new g),this.tools.set("vibe-local",new C)}static getInstance(){return T.instance||(T.instance=new T),T.instance}getTool(e){let t=this.tools.get(e);if(!t)throw Error(`CLI tool '${e}' not found`);return t}getAllTools(){return Array.from(this.tools.values())}async getToolInfo(e){let t=this.getTool(e),s=await t.isInstalled();return{id:t.id,name:t.name,command:t.command,installed:s}}async getAllToolsInfo(){return Promise.all(this.getAllTools().map(async e=>{let t=await e.isInstalled();return{id:e.id,name:e.name,command:e.command,installed:t}}))}async getInstalledTools(){return(await this.getAllToolsInfo()).filter(e=>e.installed)}stopPollers(e,t){(0,S.FN)(e,t)}}},63661:(e,t,s)=>{s.d(t,{F:()=>r,J:()=>f});let i=(0,s(43895).h)("prompt-detector"),n=[{regex:/^(.+)\s+\(y\/n\)\s*$/m},{regex:/^(.+)\s+\[y\/N\]\s*$/m,defaultOption:"no"},{regex:/^(.+)\s+\[Y\/n\]\s*$/m,defaultOption:"yes"},{regex:/^(.+)\s+\(yes\/no\)\s*$/m}];function o(e,t,s,i){return{isPrompt:!0,promptData:{type:"yes_no",question:e,options:["yes","no"],status:"pending",...void 0!==i&&{defaultOption:i},instructionText:s},cleanContent:t,rawContent:s}}function r(e,t){i.debug("detectPrompt:start",{outputLength:e.length});let s=e.split("\n").slice(-20).join("\n"),r=function(e,t){let s=t?.requireDefaultIndicator??!0,i=e.split("\n"),n=i.length;for(;n>0&&""===i[n-1].trim();)n--;let o=Math.max(0,n-50);if(s){let t=!1;for(let e=o;e<n;e++){let s=i[e].trim();if(l.test(s)){t=!0;break}}if(!t)return m(e)}let r=[],d=-1,f=0;for(let t=n-1;t>=o;t--){let s=i[t].trim(),n=s.match(l);if(n){let e=parseInt(n[1],10),t=n[2].trim();r.unshift({number:e,label:t,isDefault:!0}),f=0;continue}let o=s.match(c);if(o){let e=parseInt(o[1],10),t=o[2].trim();r.unshift({number:e,label:t,isDefault:!1}),f=0;continue}if(0===r.length&&(s.startsWith("❯")||s.startsWith("●")||s.startsWith("›")))return m(e);if(r.length>0&&s&&!u.test(s)){if(p(s)){d=t;break}if(function(e,t){let s=t.endsWith("?")||t.endsWith("?");return!!(!s&&/^\s{2,}[^\d]/.test(e)&&!/^\s*\d+\./.test(e)||t.length<5&&!s||/^[\/~]/.test(t)||t.length>=2&&/^[a-zA-Z0-9_-]+$/.test(t))}(i[t],s)){if(++f>5){d=t;break}continue}d=t;break}}if(!function(e){if(0===e.length||1!==e[0])return!1;for(let t=1;t<e.length;t++)if(e[t]!==e[t-1]+1)return!1;return!0}(r.map(e=>e.number)))return m(e);let h=r.some(e=>e.isDefault);if(r.length<2||s&&!h||!s&&(-1===d||!p(i[d]?.trim()??"")&&!function(e,t,s,i){let n=Math.max(i,t-3);for(let s=t-1;s>=n;s--){let t=e[s]?.trim()??"";if(!(!t||u.test(t))&&p(t))return!0}return!1}(i,d,0,o)))return m(e);let g=function(e,t){if(t<0)return"Please select an option:";let s=[];for(let i=Math.max(0,t-5);i<=t;i++){let t=e[i].trim();t&&!u.test(t)&&s.push(t)}return s.join(" ")}(i,d),w=function(e,t,s){if(t<0)return;let i=e.slice(Math.max(0,t-19),s).map(e=>e.trimEnd()).join("\n").trim();return i.length>0?i:void 0}(i,d,n);return{isPrompt:!0,promptData:{type:"multiple_choice",question:g.trim(),options:r.map(e=>{let t=a.some(t=>t.test(e.label));return{number:e.number,label:e.label,isDefault:e.isDefault,requiresTextInput:t}}),status:"pending",instructionText:w},cleanContent:g.trim(),rawContent:function(e){let t=e.split("\n"),s=(t.length>200?t.slice(-200):t).join("\n");return s.length>5e3&&(s=s.slice(-5e3)),s}(e.trim())}}(e,t);if(r.isPrompt)return i.info("detectPrompt:multipleChoice",{isPrompt:!0,question:r.promptData?.question,optionsCount:r.promptData?.options?.length}),r;let d=s.trim();for(let e of n){let t=s.match(e.regex);if(t){let s=t[1].trim();return o(s,s,d,e.defaultOption)}}let f=s.match(/^(.*?)Approve\?\s*$/m);if(f){let e=f[1].trim();return o(e?`${e} Approve?`:"Approve?",e||"Approve?",d)}return i.debug("detectPrompt:complete",{isPrompt:!1}),{isPrompt:!1,cleanContent:e.trim()}}let a=[/type\s+here/i,/tell\s+(me|claude)/i,/enter\s+/i,/custom/i,/differently/i],l=/^\s*[\u276F\u25CF\u203A]\s*(\d+)\.\s*(.+)$/,c=/^\s*(\d+)\.\s*(.+)$/,u=/^[-─]+$/;function m(e){return{isPrompt:!1,cleanContent:e.trim()}}let d=/(?:select|choose|pick|which|what|how|where|enter|type|specify|confirm|approve|accept|reject|decide|preference|option)/i;function p(e){return 0!==e.length&&!!(e.includes("?")||e.includes("?")||d.test(e))}function f(e,t="yes_no"){let s=e.toLowerCase().trim();if("multiple_choice"===t){if(/^\d+$/.test(s))return s;throw Error("Invalid answer for multiple choice prompt. Expected a number.")}if("yes"===s||"y"===s)return"y";if("no"===s||"n"===s)return"n";throw Error("Invalid answer for yes/no prompt. Expected 'yes', 'no', 'y', or 'n'.")}},59991:(e,t,s)=>{s.d(t,{FN:()=>T,RJ:()=>$,ci:()=>y,cn:()=>S});var i=s(89194),n=s(97425),o=s(75748),r=s(68507),a=s(63661),l=s(76966),c=s(89287),u=s(19377);let m=["Waiting for auth","⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function d(e){return{response:"",isComplete:!1,lineCount:e}}function p(e,t,s,i,n,o,r){let a=x(t,s,i,n,o),l=e.slice(a);return{response:(0,u.vp)(l.join("\n")),isComplete:!0,lineCount:s,promptDetection:r,bufferReset:i}}let f=new Map,h=new Map;function g(e,t){return`${e}:${t}`}function w(e,t){let s=(0,u.Sg)(t);return(0,a.F)((0,u.BN)((0,u.vp)(e)),s)}function y(e){let t=(0,u.vp)(e).split("\n"),s=-1;for(let e=t.length-1;e>=0;e--)if(/^❯\s+\S/.test(t[e])){s=e;break}let i=s>=0?s+1:0,n=t.slice(i),o=[/CLAUDE_HOOKS_/,/\/bin\/claude/,/^claude\s*$/,/@.*\s+%\s*$/,/^[^⏺]*curl.*POST/,/^[^⏺]*Content-Type/,/^[^⏺]*export\s+CLAUDE_/,/^\s*$/,/^[╭╮╰╯│─\s]+$/,/^[│╭╮╰╯].*[│╭╮╰╯]$/,/Claude Code v[\d.]+/,/^Tips for getting started/,/^Welcome back/,/Run \/init to create/,/^Recent activity/,/^No recent activity/,/▐▛███▜▌|▝▜█████▛▘|▘▘ ▝▝/,/^\s*Opus \d+\.\d+\s*·\s*Claude Max/,/\.com's Organization/,/\?\s*for shortcuts\s*$/,/^─{10,}$/,/^❯\s*$/,u.d8],r=[];for(let e of n)!o.some(t=>t.test(e))&&e.trim()&&r.push(e);return r.join("\n").trim()}function $(e){let t=e.split("\n"),s=[],i=[/^maenokota@.*%/,/^zsh:/,/^feature-issue-\d+/,/^\s*$/],n=!1,o=[];for(let e of t){if(e.includes("✦")){n=!0;let t=e.indexOf("✦"),s=e.substring(t+1).trim();s&&o.push(s);continue}if(n){if(i.some(t=>t.test(e)))continue;o.push(e)}}if(o.length>0)return o.join("\n").trim();for(let e of t)i.some(t=>t.test(e))||s.push(e);return s.join("\n").trim()}function x(e,t,s,i,n){if((e=Math.max(0,e))>=t||s){let e=n(40);return e>=0?e+1:0}if("codex"===i)return Math.max(0,e);if(e>=t-5){let e=n(50);return e>=0?e+1:Math.max(0,t-40)}return Math.max(0,e)}async function C(e,t){let s=(0,n.getDbInstance)();try{if(!(0,o.gU)(s,e))return console.error(`Worktree ${e} not found, stopping poller`),T(e,t),!1;if(!await (0,i.Lg)(e,t))return console.log(`[checkForResponse] Session not running for ${e} (${t}), stopping poller`),T(e,t),!1;let n=(0,o.zl)(s,e,t),a=n?.lastCapturedLine||0,f=await (0,i.NA)(e,t,1e4),h=function(e,t,s){let i=e.split("\n"),n=i.length;for(;n>0&&""===i[n-1].trim();)n--;let o=i.slice(0,n),r=o.length,a=r>0&&t>25&&r+25<t,l=r>0&&t>50&&r<50,c=a||l;if(!c&&r<t-5)return null;let f=Math.max(0,r-20),h=o.slice(f).join("\n"),{promptPattern:g,separatorPattern:y,thinkingPattern:$,skipPatterns:C}=(0,u.bs)(s),S=(e=60)=>{let t="codex"===s?/^›\s+(?!Implement|Find and fix|Type|Summarize)/:/^[>❯]\s+\S/;for(let s=r-1;s>=Math.max(0,r-e);s--){let e=(0,u.vp)(o[s]);if(t.test(e))return s}return -1};if("claude"===s||"codex"===s){let e=w(o.join("\n"),s);if(e.isPrompt)return p(o,t,r,c,s,S,e)}let T=(0,u.vp)(h),b=g.test(T),P=y.test(T),v=$.test(T),k=("codex"===s||"gemini"===s||"vibe-local"===s)&&b&&!v,I="claude"===s&&b&&P&&!v;if(k||I){let e=[],i=x(t,r,c,s,S),n=r;for(let t=i;t<r;t++){let i=o[t],r=(0,u.vp)(i);if("codex"===s&&/^›\s+/.test(r)||"gemini"===s&&/^(%|\$|.*@.*[%$#])\s*$/.test(r)){n=t;break}C.some(e=>e.test(r))||e.push(i)}let a=e.join("\n").trim(),l=a.split("\n").slice(-5).join("\n");if($.test(l))return d(r);if("claude"===s){let e=(0,u.vp)(a),t=/[╭╮╰╯│]/.test(e)||/░{3,}/.test(e)||/▓{3,}/.test(e),s=/Claude Code|claude\/|v\d+\.\d+/.test(e),i=/Tip:|for shortcuts|\?\s*for help/.test(e),n=/^\s*\/Users\/.*$/m.test(e)&&e.split("\n").length<30,o=e.match(/^[>❯]\s+(\S.*)$/m);if(o){let t=e.indexOf(o[0]);if(0===e.substring(t+o[0].length).trim().split("\n").filter(e=>{let t=e.trim();return t&&!C.some(e=>e.test(t))&&!/^─+$/.test(t)}).length)return d(r)}else if((t||s||i||n)&&a.length<2e3)return d(r)}return"gemini"===s&&((a.match(/[░███]/g)||[]).length>.3*a.length||m.some(e=>a.includes(e))||!a.includes("✦")&&a.length<10)?d(r):{response:a,isComplete:!0,lineCount:n,bufferReset:c}}let E=w(o.join("\n"),s);if(E.isPrompt)return p(o,t,r,c,s,S,E);let L=[],N=c||t>=r-5,D=N?S(80):-1,M=N?D>=0?D+1:Math.max(0,r-80):Math.max(0,t);for(let e=M;e<r;e++){let t=o[e],s=(0,u.vp)(t);C.some(e=>e.test(s))||L.push(t)}let A=L.join("\n").trim();return A?{response:A,isComplete:!1,lineCount:r}:d(r)}(f,a,t);if(!h||!h.isComplete){let{thinkingPattern:i}=(0,u.bs)(t),n=(0,u.vp)(f).split("\n").slice(-5).join("\n");if(i.test(n)){let i=(0,o.GP)(s,e,t);i>0&&console.log(`Marked ${i} pending prompt(s) as answered (thinking detected) for ${e}`)}return!1}if(!h.bufferReset&&h.lineCount===a&&!n?.inProgressMessageId)return!1;if(!h.bufferReset&&h.lineCount<=a)return console.log(`[checkForResponse] Already saved up to line ${a}, skipping (result: ${h.lineCount})`),!1;let g=h.promptDetection??w(h.response,t);if(g.isPrompt){(0,o.Mf)(s,e,t);let i=(0,o.tn)(s,{worktreeId:e,role:"assistant",content:g.rawContent||g.cleanContent,messageType:"prompt",promptData:g.promptData,timestamp:new Date,cliToolId:t});return(0,o.IH)(s,e,t,h.lineCount),(0,r.ps)("message",{worktreeId:e,message:i}),T(e,t),!0}if(!h.response||""===h.response.trim())return(0,o.IH)(s,e,t,h.lineCount),!1;let C="claude"===t?(0,c.Z)(h.response):void 0,S=h.response;if("gemini"===t?S=$(h.response):"claude"===t&&(S=y(h.response)),!S||""===S.trim()||"[No content]"===S)return(0,o.IH)(s,e,t,h.lineCount),(0,o.Mf)(s,e,t),!1;S&&await (0,l.o)(s,e,S,t);let b=(0,o.GP)(s,e,t);b>0&&console.log(`Marked ${b} pending prompt(s) as answered for ${e}`);let P=(0,o.zl)(s,e,t);if(P&&h.lineCount<=P.lastCapturedLine)return console.log(`[checkForResponse] Race condition detected, skipping save (result: ${h.lineCount}, current: ${P.lastCapturedLine})`),!1;let v=(0,o.tn)(s,{worktreeId:e,role:"assistant",content:S,messageType:"normal",timestamp:new Date,cliToolId:t,summary:C?.summary,logFileName:C?.logFileName,requestId:C?.requestId});return(0,r.ps)("message",{worktreeId:e,message:v}),(0,o.IH)(s,e,t,h.lineCount),!0}catch(t){return console.error(`Error checking for response (${e}):`,t instanceof Error?t.message:String(t)),!1}}function S(e,t){let s=g(e,t);T(e,t),h.set(s,Date.now()),function e(t,s){let i=g(t,s),n=setTimeout(async()=>{let n=h.get(i);if(n&&Date.now()-n>18e5){T(t,s);return}try{await C(t,s)}catch(e){console.error("[Poller] Error:",e)}f.has(i)&&e(t,s)},2e3);f.set(i,n)}(e,t)}function T(e,t){let s=g(e,t),i=f.get(s);i&&(clearTimeout(i),f.delete(s),h.delete(s))}}};
@@ -17,11 +17,11 @@
17
17
  "wasm": [],
18
18
  "assets": [],
19
19
  "env": {
20
- "__NEXT_BUILD_ID": "O7EDFfAYQNe_HRbORxQAC",
21
- "NEXT_SERVER_ACTIONS_ENCRYPTION_KEY": "HjSeyEJW5j6LL0pq2ZuLliSH/ggh6YmlyPQQNyNBmNk=",
22
- "__NEXT_PREVIEW_MODE_ID": "fe0ec2124f3e88ac56779cad7b3ac26c",
23
- "__NEXT_PREVIEW_MODE_ENCRYPTION_KEY": "bcfbcbd97f8158a49c09548d52de66c70c9d33ff7cead9db6435b126b03bd5e1",
24
- "__NEXT_PREVIEW_MODE_SIGNING_KEY": "659fef5fb681ce1f3d1032ccab75ec2429d33df6949f0afacb3f4f2ef5a8038a"
20
+ "__NEXT_BUILD_ID": "BiyH3zkbySg7ZWTeZuXqj",
21
+ "NEXT_SERVER_ACTIONS_ENCRYPTION_KEY": "PVPAPo2Yb8QPY8s/PRbFoOJqyalgbV37ienkbsfxtxM=",
22
+ "__NEXT_PREVIEW_MODE_ID": "627a86862bb21611d90b4c05f9d87e9e",
23
+ "__NEXT_PREVIEW_MODE_ENCRYPTION_KEY": "467f4ce8ef71d51f1d704542c0dd61a1f48718fad0aeb68f8f8de8f57a797a8f",
24
+ "__NEXT_PREVIEW_MODE_SIGNING_KEY": "f06e7285c75cd644e0d77695764455c232d81bb4241907f0d6e9039855daa0c5"
25
25
  }
26
26
  }
27
27
  },
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>500: Internal Server Error</title><meta name="next-head-count" content="3"/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-3c0ee3ce5b546818.js" defer=""></script><script src="/_next/static/chunks/framework-8e0e0f4a6b83a956.js" defer=""></script><script src="/_next/static/chunks/main-2feda12a4d321111.js" defer=""></script><script src="/_next/static/chunks/pages/_app-3c9ca398d360b709.js" defer=""></script><script src="/_next/static/chunks/pages/_error-cf5ca766ac8f493f.js" defer=""></script><script src="/_next/static/O7EDFfAYQNe_HRbORxQAC/_buildManifest.js" defer=""></script><script src="/_next/static/O7EDFfAYQNe_HRbORxQAC/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":500}},"page":"/_error","query":{},"buildId":"O7EDFfAYQNe_HRbORxQAC","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>500: Internal Server Error</title><meta name="next-head-count" content="3"/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-3c0ee3ce5b546818.js" defer=""></script><script src="/_next/static/chunks/framework-8e0e0f4a6b83a956.js" defer=""></script><script src="/_next/static/chunks/main-2feda12a4d321111.js" defer=""></script><script src="/_next/static/chunks/pages/_app-3c9ca398d360b709.js" defer=""></script><script src="/_next/static/chunks/pages/_error-cf5ca766ac8f493f.js" defer=""></script><script src="/_next/static/BiyH3zkbySg7ZWTeZuXqj/_buildManifest.js" defer=""></script><script src="/_next/static/BiyH3zkbySg7ZWTeZuXqj/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":500}},"page":"/_error","query":{},"buildId":"BiyH3zkbySg7ZWTeZuXqj","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
@@ -1 +1 @@
1
- {"/_app":"pages/_app.js","/_error":"pages/_error.js","/_document":"pages/_document.js"}
1
+ {"/_error":"pages/_error.js","/_app":"pages/_app.js","/_document":"pages/_document.js"}
@@ -1 +1 @@
1
- {"node":{},"edge":{},"encryptionKey":"HjSeyEJW5j6LL0pq2ZuLliSH/ggh6YmlyPQQNyNBmNk="}
1
+ {"node":{},"edge":{},"encryptionKey":"PVPAPo2Yb8QPY8s/PRbFoOJqyalgbV37ienkbsfxtxM="}
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8091],{20318:function(e,t,n){n.d(t,{Ix:function(){return x},pm:function(){return m}});var r=n(57437),a=n(2265),s=n(41671),l=n(99388),o=n(33245),i=n(32489),c=n(3468);function d(e){let{type:t,iconColor:n}=e,a="h-5 w-5 ".concat(n);switch(t){case"success":return(0,r.jsx)(s.Z,{className:a,"data-testid":"toast-icon-success"});case"error":return(0,r.jsx)(l.Z,{className:a,"data-testid":"toast-icon-error"});default:return(0,r.jsx)(o.Z,{className:a,"data-testid":"toast-icon-info"})}}function u(e){let{id:t,message:n,type:s,onClose:l,duration:o=3e3}=e,c=(0,a.useRef)(null),u=function(e){switch(e){case"success":return{bgColor:"bg-green-50",borderColor:"border-green-200",textColor:"text-green-800",iconColor:"text-green-500"};case"error":return{bgColor:"bg-red-50",borderColor:"border-red-200",textColor:"text-red-800",iconColor:"text-red-500"};default:return{bgColor:"bg-blue-50",borderColor:"border-blue-200",textColor:"text-blue-800",iconColor:"text-blue-500"}}}(s);(0,a.useEffect)(()=>(o>0&&(c.current=setTimeout(()=>{l(t)},o)),()=>{c.current&&clearTimeout(c.current)}),[t,o,l]);let x=(0,a.useCallback)(()=>{c.current&&clearTimeout(c.current),l(t)},[t,l]);return(0,r.jsxs)("div",{"data-testid":"toast-".concat(t),role:"alert",className:"\n ".concat(u.bgColor,"\n ").concat(u.borderColor,"\n ").concat(u.textColor,"\n border rounded-lg shadow-lg p-4 min-w-[300px] max-w-[400px]\n flex items-start gap-3\n animate-slide-in\n "),children:[(0,r.jsx)(d,{type:s,iconColor:u.iconColor}),(0,r.jsx)("p",{className:"flex-1 text-sm font-medium",children:n}),(0,r.jsx)("button",{"data-testid":"toast-close-button",onClick:x,"aria-label":"Close notification",className:"\n ".concat(u.textColor,"\n hover:opacity-70\n focus:outline-none focus:ring-2 focus:ring-offset-2\n transition-opacity\n "),children:(0,r.jsx)(i.Z,{className:"h-4 w-4"})})]})}function x(e){let{toasts:t,onClose:n}=e;return(0,r.jsx)("div",{"data-testid":"toast-container","aria-live":"polite",className:"fixed bottom-4 right-4 flex flex-col gap-2",style:{zIndex:c.k.TOAST},children:t.map(e=>(0,r.jsx)(u,{id:e.id,message:e.message,type:e.type,onClose:n,duration:e.duration},e.id))})}function m(){let[e,t]=(0,a.useState)([]),n=(0,a.useRef)(0);return{toasts:e,showToast:(0,a.useCallback)(function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e3,s="toast-".concat(++n.current,"-").concat(Date.now()),l={id:s,message:e,type:r,duration:a};return t(e=>[...e,l]),s},[]),removeToast:(0,a.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[]),clearToasts:(0,a.useCallback)(()=>{t([])},[])}}},8820:function(e,t,n){n.d(t,{Vw:function(){return M}});var r=n(57437),a=n(2265);n(27648);var s=n(43241),l=n(58819),o=n(99376),i=n(34021),c=n(8672),d=n(74707);function u(e){let{status:t,label:n}=e,a=c.F4[t],s="".concat(n,": ").concat(a.label);return"spinner"===a.type?(0,r.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ".concat(a.className),title:s,"aria-label":s}):(0,r.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ".concat(a.className),title:s,"aria-label":s})}let x=(0,a.memo)(function(e){let{branch:t,isSelected:n,onClick:a}=e;return(0,r.jsxs)("button",{"data-testid":"branch-list-item",onClick:a,"aria-current":n?"true":void 0,className:"\n w-full px-4 py-3 flex flex-col gap-1\n hover:bg-gray-800 transition-colors\n focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blue-500\n ".concat(n?"bg-gray-700 border-l-2 border-blue-500":"border-l-2 border-transparent","\n "),children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 w-full",children:[t.cliStatus&&Object.keys(t.cliStatus).length>0&&(0,r.jsx)("div",{className:"flex items-center gap-1 flex-shrink-0","aria-label":"CLI tool status",children:Object.entries(t.cliStatus).map(e=>{let[t,n]=e;return(0,r.jsx)(u,{status:null!=n?n:"idle",label:(0,d.Ds)(t)},t)})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 text-left",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white truncate",children:t.name}),(0,r.jsx)("p",{className:"text-xs text-gray-400 truncate",children:t.repositoryName})]}),t.hasUnread&&(0,r.jsx)("span",{"data-testid":"unread-indicator",className:"w-2 h-2 rounded-full bg-blue-500 flex-shrink-0","aria-label":"Has unread messages"})]}),t.description&&(0,r.jsx)("div",{"data-testid":"branch-description",className:"pl-6 pr-2 mt-1 text-left",children:(0,r.jsx)("p",{className:"text-xs text-gray-400 line-clamp-2",children:t.description})})]})}),m=[{key:"updatedAt",label:"Updated"},{key:"repositoryName",label:"Repository"},{key:"branchName",label:"Branch"},{key:"status",label:"Status"}],h=(0,a.memo)(function(){var e;let{sortKey:t,sortDirection:n,setSortKey:l,setSortDirection:o}=(0,s.Sz)(),[i,c]=(0,a.useState)(!1),d=(0,a.useRef)(null);(0,a.useEffect)(()=>{function e(e){d.current&&!d.current.contains(e.target)&&c(!1)}if(i)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]),(0,a.useEffect)(()=>{function e(e){"Escape"===e.key&&c(!1)}if(i)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[i]);let u=(0,a.useCallback)(()=>{c(e=>!e)},[]),x=(0,a.useCallback)(e=>{e===t?o("asc"===n?"desc":"asc"):(l(e),o("updatedAt"===e?"desc":"asc")),c(!1)},[t,n,l,o]),h=(0,a.useCallback)(()=>{o("asc"===n?"desc":"asc")},[n,o]),b=(null===(e=m.find(e=>e.key===t))||void 0===e?void 0:e.label)||"Sort";return(0,r.jsxs)("div",{ref:d,className:"relative","data-testid":"sort-selector",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsxs)("button",{type:"button",onClick:u,"aria-expanded":i,"aria-haspopup":"listbox","aria-label":"Sort by ".concat(b),className:" flex items-center gap-1 px-2 py-1 rounded text-xs text-gray-300 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors ",children:[(0,r.jsx)(f,{className:"w-3 h-3"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:b})]}),(0,r.jsx)("button",{type:"button",onClick:h,"aria-label":"asc"===n?"Sort ascending":"Sort descending",className:" p-1 rounded text-gray-300 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors ",children:"asc"===n?(0,r.jsx)(g,{className:"w-3 h-3"}):(0,r.jsx)(p,{className:"w-3 h-3"})})]}),i&&(0,r.jsx)("div",{role:"listbox","aria-label":"Sort options",className:" absolute right-0 top-full mt-1 z-50 min-w-[140px] py-1 rounded-md shadow-lg bg-gray-800 border border-gray-600 ",children:m.map(e=>(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":t===e.key,onClick:()=>x(e.key),className:"\n w-full px-3 py-2 text-left text-sm\n flex items-center justify-between\n hover:bg-gray-700 transition-colors\n ".concat(t===e.key?"text-blue-400":"text-gray-300","\n "),children:[(0,r.jsx)("span",{children:e.label}),t===e.key&&(0,r.jsx)("span",{className:"text-xs",children:"asc"===n?"ASC":"DESC"})]},e.key))})]})});function f(e){let{className:t}=e;return(0,r.jsx)("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"})})}function g(e){let{className:t}=e;return(0,r.jsx)("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 15l7-7 7 7"})})}function p(e){let{className:t}=e;return(0,r.jsx)("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}var b=n(69234);let y=["en","ja"],v={en:"English",ja:"日本語"};function w(){let{currentLocale:e,switchLocale:t}={currentLocale:(0,b.bU)(),switchLocale:e=>{y.includes(e)&&(!function(e){let t="https:"===window.location.protocol;document.cookie="".concat("locale","=").concat(e,";path=/;max-age=").concat(31536e3,";SameSite=Lax").concat(t?";Secure":"")}(e),localStorage.setItem("locale",e),window.location.reload())}};return(0,r.jsx)("select",{value:e,onChange:e=>t(e.target.value),"aria-label":"Language",className:" w-full px-3 py-2 rounded-md bg-gray-800 text-white border border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm ",children:y.map(e=>(0,r.jsx)("option",{value:e,children:v[e]},e))})}var j=n(38706),N=n(14362);function k(){let e=(0,j.T)("auth"),t=(0,N.m)(),[n,s]=(0,a.useState)(!1);if(!t)return null;async function l(){s(!0);try{await fetch("/api/auth/logout",{method:"POST"}),window.location.href="/login"}catch(e){window.location.href="/login"}}return(0,r.jsx)("button",{type:"button",onClick:l,disabled:n,"data-testid":"logout-button",className:" w-full px-3 py-2 text-sm text-left rounded-md text-gray-300 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 transition-colors ",children:n?"...":e("logout.button")})}var C=n(47712);let S={waiting:0,ready:1,running:2,generating:3,idle:4},L=(0,a.memo)(function(){let e=(0,o.useRouter)(),{worktrees:t,selectedWorktreeId:n,selectWorktree:l}=(0,i.Mu)(),{closeMobileDrawer:c,sortKey:d,sortDirection:u}=(0,s.Sz)(),[m,f]=(0,a.useState)(""),g=(0,a.useMemo)(()=>{let e=t.map(C.I_),n=e;if(m.trim()){let t=m.toLowerCase();n=e.filter(e=>e.name.toLowerCase().includes(t)||e.repositoryName.toLowerCase().includes(t))}return function(e,t,n){let r=[...e];return r.sort((e,r)=>{let a=0;switch(t){case"updatedAt":{let t=e=>e?e instanceof Date?e.getTime():new Date(e).getTime():0,n=t(e.lastActivity);a=t(r.lastActivity)-n;break}case"repositoryName":{let t=e.repositoryName.toLowerCase(),n=r.repositoryName.toLowerCase();a=t.localeCompare(n);break}case"branchName":{let t=e.name.toLowerCase(),n=r.name.toLowerCase();a=t.localeCompare(n);break}case"status":a=S[e.status]-S[r.status]}return("updatedAt"===t?"desc"===n:"asc"===n)?a:-a}),r}(n,d,u)},[t,m,d,u]),p=t=>{l(t),e.push("/worktrees/".concat(t)),c()};return(0,r.jsxs)("nav",{"data-testid":"sidebar","aria-label":"Branch navigation",className:"h-full flex flex-col bg-gray-900 text-white",role:"navigation",children:[(0,r.jsx)("div",{"data-testid":"sidebar-header",className:"flex-shrink-0 px-4 py-4 border-b border-gray-700",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-white",children:"Branches"}),(0,r.jsx)(h,{})]})}),(0,r.jsx)("div",{className:"flex-shrink-0 px-4 py-3 border-b border-gray-700",children:(0,r.jsx)("input",{type:"text",placeholder:"Search branches...",value:m,onChange:e=>f(e.target.value),className:" w-full px-3 py-2 rounded-md bg-gray-800 text-white placeholder-gray-400 border border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent "})}),(0,r.jsx)("div",{"data-testid":"branch-list",className:"flex-1 overflow-y-auto",children:0===g.length?(0,r.jsx)("div",{className:"px-4 py-8 text-center text-gray-400",children:m?"No branches found":"No branches available"}):g.map(e=>(0,r.jsx)(x,{branch:e,isSelected:e.id===n,onClick:()=>p(e.id)},e.id))}),(0,r.jsxs)("div",{className:"flex-shrink-0 px-4 py-3 border-t border-gray-700 space-y-2",children:[(0,r.jsx)(w,{}),(0,r.jsx)(k,{})]})]})});var E=n(3468);let z="transform transition-transform duration-300 ease-out",M=(0,a.memo)(function(e){let{children:t}=e,{isOpen:n,isMobileDrawerOpen:a,closeMobileDrawer:o}=(0,s.Sz)();return(0,l.d)()?(0,r.jsxs)("div",{"data-testid":"app-shell",className:"h-screen flex flex-col",children:[a&&(0,r.jsx)("div",{"data-testid":"drawer-overlay",className:"fixed inset-0 bg-black/50 z-40",onClick:o,"aria-hidden":"true"}),(0,r.jsx)("aside",{"data-testid":"sidebar-container",className:"\n fixed left-0 top-0 h-full w-72 z-50\n ".concat(z,"\n ").concat(a?"translate-x-0":"-translate-x-full","\n "),role:"complementary",children:(0,r.jsx)(L,{})}),(0,r.jsx)("main",{className:"flex-1 min-h-0 overflow-hidden",role:"main",children:t})]}):(0,r.jsxs)("div",{"data-testid":"app-shell",className:"h-screen flex",children:[(0,r.jsx)("aside",{"data-testid":"sidebar-container",className:"\n fixed left-0 top-0 h-full w-72\n ".concat(z,"\n ").concat(n?"translate-x-0":"-translate-x-full","\n "),style:{zIndex:E.k.SIDEBAR},role:"complementary","aria-hidden":!n,children:(0,r.jsx)(L,{})}),(0,r.jsx)("main",{className:"\n flex-1 min-w-0 h-full overflow-hidden\n transition-[padding] duration-300 ease-out\n ".concat(n?"md:pl-72":"md:pl-0","\n "),role:"main",children:t})]})})},98702:function(e,t,n){n.d(t,{u:function(){return o}});var r=n(57437),a=n(2265),s=n(54887),l=n(3468);function o(e){let{isOpen:t,onClose:n,title:o,children:i,size:c="lg",showCloseButton:d=!0,disableClose:u=!1}=e,x=(0,a.useRef)(null);return((0,a.useEffect)(()=>{if(u)return;let e=e=>{"Escape"===e.key&&t&&n()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,n,u]),(0,a.useEffect)(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[t]),t)?(0,s.createPortal)((0,r.jsxs)("div",{className:"fixed inset-0 overflow-y-auto",style:{zIndex:l.k.MODAL},children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 transition-opacity",onClick:u?void 0:n}),(0,r.jsx)("div",{className:"relative flex min-h-full items-center justify-center p-2 sm:p-4",children:(0,r.jsxs)("div",{ref:x,className:"relative w-full ".concat({sm:"max-w-[calc(100vw-2rem)] sm:max-w-md",md:"max-w-[calc(100vw-2rem)] sm:max-w-2xl",lg:"max-w-[calc(100vw-2rem)] sm:max-w-4xl",xl:"max-w-[calc(100vw-2rem)] sm:max-w-6xl",full:"max-w-[calc(100vw-2rem)] sm:max-w-[95vw]"}[c]," max-h-[calc(100vh-1rem)] sm:max-h-[calc(100vh-2rem)] flex flex-col bg-white rounded-lg shadow-xl transform transition-all"),children:[(o||d)&&(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 sm:px-6 py-3 sm:py-4 border-b border-gray-200 flex-shrink-0",children:[(0,r.jsx)("h3",{className:"text-base sm:text-lg font-semibold text-gray-900 truncate pr-2",children:o}),d&&(0,r.jsx)("button",{onClick:n,className:"text-gray-400 hover:text-gray-600 transition-colors flex-shrink-0",children:(0,r.jsx)("svg",{className:"w-5 h-5 sm:w-6 sm:h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"px-4 sm:px-6 py-3 sm:py-4 overflow-y-auto flex-1 min-h-0",children:i})]})})]}),document.body):null}},10789:function(e,t,n){n.d(t,{Ct:function(){return c},zx:function(){return a},Zb:function(){return s},aY:function(){return i},Ol:function(){return l},ll:function(){return o},u_:function(){return d.u}});var r=n(57437);function a(e){let{variant:t="primary",size:n="md",fullWidth:a=!1,loading:s=!1,disabled:l,className:o="",children:i,...c}=e,d=["btn",{primary:"btn-primary",secondary:"btn-secondary",danger:"btn-danger",ghost:"bg-transparent text-gray-700 hover:bg-gray-100 focus:ring-gray-500"}[t],{sm:"btn-sm",md:"",lg:"btn-lg"}[n],a?"w-full":"",l||s?"opacity-50 cursor-not-allowed":"",o].filter(Boolean).join(" ");return(0,r.jsxs)("button",{className:d,disabled:l||s,...c,children:[s&&(0,r.jsxs)("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),i]})}function s(e){let{hover:t=!1,padding:n="md",className:a="",children:s,...l}=e,o=["card",t?"card-hover":"",{none:"",sm:"p-3",md:"p-4",lg:"p-6"}[n],a].filter(Boolean).join(" ");return(0,r.jsx)("div",{className:o,...l,children:s})}function l(e){let{className:t="",children:n,...a}=e;return(0,r.jsx)("div",{className:"mb-3 ".concat(t),...a,children:n})}function o(e){let{className:t="",children:n,...a}=e;return(0,r.jsx)("h3",{className:"text-lg font-semibold text-gray-900 ".concat(t),...a,children:n})}function i(e){let{className:t="",children:n,...a}=e;return(0,r.jsx)("div",{className:t,...a,children:n})}function c(e){let{variant:t="gray",dot:n=!1,className:a="",children:s,...l}=e,o=["badge",{success:"badge-success",warning:"badge-warning",error:"badge-error",info:"badge-info",gray:"badge-gray"}[t],a].filter(Boolean).join(" ");return(0,r.jsxs)("span",{className:o,...l,children:[n&&(0,r.jsx)("span",{className:"mr-1.5 inline-block h-2 w-2 rounded-full ".concat({success:"bg-green-600",warning:"bg-yellow-600",error:"bg-red-600",info:"bg-blue-600",gray:"bg-gray-600"}[t]),"aria-hidden":"true"}),s]})}n(2265);var d=n(98702)},43616:function(e,t,n){n.d(t,{n:function(){return d}});var r=n(57437),a=n(2265),s=n(10789),l=n(20318),o=n(3227),i=n(32636),c=n(93448);function d(e){let{worktreeId:t}=e,[n,d]=(0,a.useState)([]),[u,x]=(0,a.useState)(null),[m,h]=(0,a.useState)(null),[f,g]=(0,a.useState)(!0),[p,b]=(0,a.useState)(null),[y,v]=(0,a.useState)(""),[w,j]=(0,a.useState)(0),[N,k]=(0,a.useState)("all"),[C,S]=(0,a.useState)(!1),{toasts:L,showToast:E,removeToast:z}=(0,l.pm)();(0,a.useEffect)(()=>{(async()=>{try{g(!0),b(null);let e=await o.Iv.getLogs(t);d(e)}catch(e){b((0,o.zG)(e))}finally{g(!1)}})()},[t]);let M=(0,a.useMemo)(()=>"all"===N?n:n.filter(e=>e.toLowerCase().includes(N)),[n,N]),T=async e=>{try{g(!0),b(null);let n=await o.Iv.getLogFile(t,e);h(n.content),x(e),v(""),j(0)}catch(e){b((0,o.zG)(e))}finally{g(!1)}},A=(0,a.useCallback)(async()=>{if(u)try{S(!0);let e=await o.Iv.getLogFile(t,u,{sanitize:!0});await (0,i.v)(e.content),E("Log copied to clipboard (sanitized)","success")}catch(e){E("Failed to export log: ".concat((0,o.zG)(e)),"error")}finally{S(!1)}},[t,u,E]),I=(0,a.useMemo)(()=>{let e;if(!y||!m)return[];let t=RegExp((0,c.hr)(y),"gi"),n=[];for(;null!==(e=t.exec(m));)n.push({index:e.index,length:e[0].length});return n},[y,m]);(0,a.useEffect)(()=>{j(0)},[y]);let D=()=>{I.length>0&&j(e=>(e+1)%I.length)},R=()=>{I.length>0&&j(e=>(e-1+I.length)%I.length)},B=(0,a.useMemo)(()=>{if(!m||!y||0===I.length)return m;let e="",t=0;return I.forEach((n,r)=>{e+=(0,c.Xv)(m.substring(t,n.index));let a=m.substring(n.index,n.index+n.length),s=r===w;e+='<mark class="'.concat(s?"bg-yellow-400 text-black":"bg-yellow-200 text-black",'" data-match-index="').concat(r,'">').concat((0,c.Xv)(a),"</mark>"),t=n.index+n.length}),e+=(0,c.Xv)(m.substring(t))},[m,y,I,w]);return(0,a.useEffect)(()=>{I.length>0&&w>=0&&setTimeout(()=>{let e=document.querySelector('mark[data-match-index="'.concat(w,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"})},100)},[w,I.length]),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(s.Zb,{padding:"md",children:[(0,r.jsx)(s.Ol,{children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(s.ll,{children:"Log Files"}),(0,r.jsx)(s.Ct,{variant:"gray",children:M.length})]}),(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,r.jsxs)(s.zx,{variant:"all"===N?"primary":"ghost",size:"sm",onClick:()=>k("all"),children:["All (",n.length,")"]}),(0,r.jsxs)(s.zx,{variant:"claude"===N?"primary":"ghost",size:"sm",onClick:()=>k("claude"),children:["Claude (",n.filter(e=>e.toLowerCase().includes("claude")).length,")"]}),(0,r.jsxs)(s.zx,{variant:"codex"===N?"primary":"ghost",size:"sm",onClick:()=>k("codex"),children:["Codex (",n.filter(e=>e.toLowerCase().includes("codex")).length,")"]}),(0,r.jsxs)(s.zx,{variant:"gemini"===N?"primary":"ghost",size:"sm",onClick:()=>k("gemini"),children:["Gemini (",n.filter(e=>e.toLowerCase().includes("gemini")).length,")"]})]})]})}),(0,r.jsxs)(s.aY,{children:[f&&0===n.length&&(0,r.jsx)("div",{className:"text-center py-4",children:(0,r.jsx)("div",{className:"inline-block animate-spin rounded-full h-6 w-6 border-4 border-gray-300 border-t-blue-600"})}),p&&(0,r.jsx)("div",{className:"p-3 bg-red-50 border border-red-200 rounded text-sm text-red-800",children:p}),!f&&0===M.length&&!p&&(0,r.jsx)("p",{className:"text-sm text-gray-600 text-center py-4",children:"all"===N?"No log files found":"No ".concat(N," log files found")}),M.length>0&&(0,r.jsx)("div",{className:"space-y-2",children:M.map(e=>(0,r.jsx)("button",{onClick:()=>T(e),className:"w-full text-left px-3 py-2 rounded text-sm font-mono transition-colors ".concat(u===e?"bg-blue-50 text-blue-700 border border-blue-200":"hover:bg-gray-50 border border-transparent"),children:e},e))})]})]}),u&&(0,r.jsxs)(s.Zb,{padding:"md",children:[(0,r.jsx)(s.Ol,{children:(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(s.ll,{className:"font-mono text-base",children:u}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(s.zx,{variant:"ghost",size:"sm",onClick:A,disabled:!u||C,title:"Copy sanitized log to clipboard",children:C?"Exporting...":"Export"}),(0,r.jsx)(s.zx,{variant:"ghost",size:"sm",onClick:()=>{x(null),h(null),v(""),j(0)},children:"Close"})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)("input",{type:"text",value:y,onChange:e=>v(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?R():D())},placeholder:"Search in log file...",className:"input w-full pr-20"}),I.length>0&&(0,r.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:[w+1," / ",I.length]})]}),I.length>0&&(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)(s.zx,{variant:"ghost",size:"sm",onClick:R,disabled:0===I.length,title:"Previous match (Shift+Enter)",children:"↑"}),(0,r.jsx)(s.zx,{variant:"ghost",size:"sm",onClick:D,disabled:0===I.length,title:"Next match (Enter)",children:"↓"})]})]})]})}),(0,r.jsxs)(s.aY,{children:[f&&(0,r.jsx)("div",{className:"text-center py-8",children:(0,r.jsx)("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"})}),!f&&m&&(0,r.jsx)("div",{className:"bg-gray-900 text-gray-100 rounded p-4 overflow-x-auto max-h-[500px] scrollbar-thin",children:y&&I.length>0?(0,r.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",dangerouslySetInnerHTML:{__html:B||""}}):(0,r.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",children:m})}),!f&&y&&0===I.length&&m&&(0,r.jsxs)("div",{className:"text-center py-4 text-sm text-gray-500",children:['No matches found for "',y,'"']})]})]}),(0,r.jsx)(l.Ix,{toasts:L,onClose:z})]})}},6940:function(e,t,n){n.d(t,{R:function(){return x}});var r=n(57437),a=n(2265),s=n(3227);function l(e,t){if(!t.trim())return e;let n=t.toLowerCase();return e.map(e=>({...e,commands:e.commands.filter(e=>{let t=e.name.toLowerCase().includes(n),r=e.description.toLowerCase().includes(n);return t||r})})).filter(e=>e.commands.length>0)}function o(e){let{groups:t,onSelect:n,highlightedIndex:a=-1,className:s=""}=e,l=0;return 0===t.length?(0,r.jsx)("div",{className:"text-sm text-gray-500 p-4 text-center ".concat(s),children:"No commands available"}):(0,r.jsx)("div",{className:"overflow-y-auto ".concat(s),children:t.map(e=>(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs font-semibold text-gray-500 uppercase tracking-wider bg-gray-50",children:e.label}),(0,r.jsx)("div",{children:e.commands.map(e=>{let t=l;l++;let s=t===a;return(0,r.jsxs)("button",{type:"button","data-command-item":!0,"data-highlighted":s,onClick:()=>n(e),className:"w-full px-3 py-2 text-left flex items-start gap-2 hover:bg-blue-50 transition-colors ".concat(s?"bg-blue-100":""),children:[(0,r.jsxs)("span",{className:"text-blue-600 font-mono text-sm flex-shrink-0",children:["/",e.name]}),(0,r.jsx)("span",{className:"text-gray-600 text-sm truncate",children:e.description})]},e.name)})})]},e.category))})}function i(e){let{isOpen:t,groups:n,onSelect:s,onClose:i,isMobile:c=!1,position:d,onFreeInput:u}=e,[x,m]=(0,a.useState)(""),[h,f]=(0,a.useState)(0),g=(0,a.useRef)(null),p=(0,a.useMemo)(()=>l(n,x),[n,x]),b=(0,a.useMemo)(()=>p.flatMap(e=>e.commands),[p]);(0,a.useEffect)(()=>{t&&(m(""),f(0),setTimeout(()=>{var e;null===(e=g.current)||void 0===e||e.focus()},50))},[t]);let y=(0,a.useCallback)(e=>{s(e),i()},[s,i]),v=(0,a.useCallback)(e=>{if(t)switch(e.key){case"Escape":e.preventDefault(),i();break;case"ArrowDown":e.preventDefault(),f(e=>Math.min(e+1,b.length-1));break;case"ArrowUp":e.preventDefault(),f(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),b[h]&&y(b[h])}},[t,b,h,i,y]);return((0,a.useEffect)(()=>{if(t)return document.addEventListener("keydown",v),()=>{document.removeEventListener("keydown",v)}},[t,v]),t)?c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 z-40",onClick:i,"aria-hidden":"true"}),(0,r.jsxs)("div",{"data-testid":"slash-command-bottom-sheet",className:"fixed bottom-0 left-0 right-0 bg-white rounded-t-xl z-50 max-h-[70vh] flex flex-col shadow-xl",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Commands"}),(0,r.jsx)("button",{type:"button",onClick:i,"aria-label":"Close",className:"p-2 rounded-full hover:bg-gray-100",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"px-4 py-2 border-b border-gray-100",children:(0,r.jsx)("input",{ref:g,type:"text",value:x,onChange:e=>m(e.target.value),placeholder:"Search commands...",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})}),u&&(0,r.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:()=>u(x),className:"w-full px-4 py-3 text-left border-b border-gray-100 flex items-center gap-2 hover:bg-blue-50 transition-colors",children:[(0,r.jsx)("span",{className:"text-blue-600",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,r.jsx)("span",{className:"text-gray-600",children:"Enter custom command..."})]}),(0,r.jsx)(o,{groups:p,onSelect:y,highlightedIndex:h,className:"flex-1 overflow-y-auto pb-20"})]})]}):(0,r.jsxs)("div",{role:"listbox",className:"absolute bg-white border border-gray-200 rounded-lg shadow-lg z-50 w-80 max-h-96 flex flex-col",style:d?{top:d.top,left:d.left}:{bottom:"100%",left:0,marginBottom:"4px"},children:[(0,r.jsx)("div",{className:"px-3 py-2 border-b border-gray-100",children:(0,r.jsx)("input",{ref:g,type:"text",value:x,onChange:e=>m(e.target.value),placeholder:"Search commands...",className:"w-full px-3 py-1.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"})}),u&&(0,r.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:()=>u(x),className:"w-full px-3 py-2 text-left border-b border-gray-100 flex items-center gap-2 hover:bg-blue-50 transition-colors text-sm",children:[(0,r.jsx)("span",{className:"text-blue-600",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,r.jsx)("span",{className:"text-gray-600",children:"Enter custom command..."})]}),(0,r.jsx)(o,{groups:p,onSelect:y,highlightedIndex:h,className:"flex-1 overflow-y-auto"}),(0,r.jsxs)("div",{className:"px-3 py-1.5 border-t border-gray-100 text-xs text-gray-400 flex gap-3",children:[(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-gray-100 rounded",children:"Enter"})," select"]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-gray-100 rounded",children:"Esc"})," close"]})]})]}):null}function c(e){let{worktreeId:t,cliToolId:n,disabled:s=!1,onInterrupt:l}=e,[o,i]=(0,a.useState)(!1),c=(0,a.useRef)(0),u=(0,a.useCallback)(async()=>{let e=Date.now();if(!(e-c.current<1e3)){c.current=e,i(!0);try{let e=await fetch("/api/worktrees/".concat(t,"/interrupt"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliToolId:n})});if(e.ok)null==l||l();else{let t=await e.json().catch(()=>({}));console.error("[InterruptButton] Failed to send interrupt:",t.error||e.statusText)}}catch(e){console.error("[InterruptButton] Error sending interrupt:",e)}finally{i(!1)}}},[t,n,l]);return(0,r.jsx)("button",{type:"button",onClick:u,disabled:s||o,className:"flex-shrink-0 p-2 text-orange-600 hover:bg-orange-50 rounded-full transition-colors disabled:text-gray-300 disabled:hover:bg-transparent","aria-label":"Stop processing","data-testid":"interrupt-button",children:o?(0,r.jsxs)("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):(0,r.jsx)(d,{})})}function d(){return(0,r.jsx)("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}var u=n(58819);function x(e){let{worktreeId:t,onMessageSent:n,cliToolId:o,isSessionRunning:d=!1}=e,[x,m]=(0,a.useState)(""),[h,f]=(0,a.useState)(!1),[g,p]=(0,a.useState)(null),[b,y]=(0,a.useState)(!1),[v,w]=(0,a.useState)(!1),[j,N]=(0,a.useState)(!1),k=(0,a.useRef)(null),C=(0,a.useRef)(null),S=(0,a.useRef)(!1),L=(0,a.useRef)(null),E=(0,u.d)(),{groups:z}=function(e,t){let[n,r]=(0,a.useState)([]),[o,i]=(0,a.useState)(!0),[c,d]=(0,a.useState)(null),[u,x]=(0,a.useState)(""),[m,h]=(0,a.useState)(t||"claude"),f=(0,a.useCallback)(async()=>{try{i(!0),d(null);let n=e?"/api/worktrees/".concat(e,"/slash-commands"):"/api/slash-commands";t&&(n+="?cliTool=".concat(t));let a=await fetch(n);if(!a.ok)throw Error("HTTP error ".concat(a.status));let s=await a.json();r(s.groups),h(s.cliTool||t||"claude")}catch(e){d((0,s.zG)(e)),r([])}finally{i(!1)}},[e,t]);(0,a.useEffect)(()=>{f()},[f]);let g=(0,a.useMemo)(()=>n.flatMap(e=>e.commands),[n]),p=(0,a.useMemo)(()=>l(n,u),[n,u]);return{groups:n,filteredGroups:p,allCommands:g,loading:o,error:c,filter:u,setFilter:x,refresh:(0,a.useCallback)(()=>{f()},[f]),cliTool:m}}(t,o);(0,a.useEffect)(()=>{let e=k.current;e&&(x?(e.style.height="auto",e.style.height="".concat(Math.min(e.scrollHeight,160),"px")):e.style.height="24px")},[x]);let M=async()=>{if(!b&&x.trim()&&!h)try{f(!0),p(null);let e=o||"claude";await s.Iv.sendMessage(t,x.trim(),e),m(""),N(!1),null==n||n(e)}catch(e){p((0,s.zG)(e))}finally{f(!1)}},T=async e=>{e.preventDefault(),await M()},A=()=>{var e;w(!1),N(!1),null===(e=k.current)||void 0===e||e.focus()};return(0,r.jsxs)("div",{ref:L,className:"space-y-2 relative",children:[g&&(0,r.jsx)("div",{className:"p-2 bg-red-50 border border-red-200 rounded text-sm text-red-800",children:g}),(0,r.jsxs)("form",{onSubmit:T,className:"flex items-end gap-2 bg-white border border-gray-300 rounded-lg px-4 py-2 focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-500",children:[E&&(0,r.jsx)("button",{type:"button",onClick:()=>{j&&N(!1),w(!0)},className:"flex-shrink-0 p-2 text-gray-500 hover:text-blue-600 hover:bg-blue-50 rounded-full transition-colors","aria-label":"Show slash commands","data-testid":"mobile-command-button",children:(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"})})}),(0,r.jsx)("textarea",{ref:k,value:x,onChange:e=>{let t=e.target.value;if(m(t),""===t){N(!1),w(!1);return}j||("/"===t||t.startsWith("/")&&!t.includes(" ")?w(!0):w(!1))},onKeyDown:e=>{let{keyCode:t}=e.nativeEvent;if(229!==t){if("Escape"===e.key&&v){e.preventDefault(),A();return}if(S.current&&"Enter"===e.key){S.current=!1;return}if("Enter"===e.key&&!b&&(!v||j)){if(E)return;e.shiftKey||(e.preventDefault(),M())}}},onCompositionStart:()=>{y(!0),S.current=!1,C.current&&clearTimeout(C.current)},onCompositionEnd:()=>{y(!1),S.current=!0,C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{S.current=!1},300)},placeholder:E?"Type your message...":"Type your message... (/ for commands, Shift+Enter for line break)",disabled:h,rows:1,className:"flex-1 outline-none bg-transparent resize-none py-1 overflow-y-auto scrollbar-thin",style:{minHeight:"24px",maxHeight:"160px"}}),(0,r.jsx)(c,{worktreeId:t,cliToolId:o||"claude",disabled:!d}),(0,r.jsx)("button",{type:"submit",disabled:!x.trim()||h,className:"flex-shrink-0 p-2 text-blue-600 hover:bg-blue-50 rounded-full transition-colors disabled:text-gray-300 disabled:hover:bg-transparent","aria-label":"Send message",children:h?(0,r.jsxs)("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]}),(0,r.jsx)(i,{isOpen:v,groups:z,onSelect:e=>{var t;m("/".concat(e.name," ")),w(!1),null===(t=k.current)||void 0===t||t.focus()},onClose:A,isMobile:E,onFreeInput:e=>{w(!1),N(!0),m(e?"/".concat(e):"/"),setTimeout(()=>{var e;null===(e=k.current)||void 0===e||e.focus()},50)}})]})}},8672:function(e,t,n){n.d(t,{F4:function(){return i},Ie:function(){return d},xh:function(){return c}});let r="bg-gray-500",a="bg-green-500",s="border-blue-500",l="bg-yellow-500",o="bg-red-500",i={idle:{className:r,label:"Idle",type:"dot"},ready:{className:a,label:"Ready",type:"dot"},running:{className:s,label:"Running",type:"spinner"},waiting:{className:l,label:"Waiting for response",type:"dot"},generating:{className:s,label:"Generating",type:"spinner"}},c={idle:{className:r,label:"Idle",type:"dot"},ready:{className:a,label:"Ready",type:"dot"},running:{className:s,label:"Running",type:"spinner"},waiting:{className:l,label:"Waiting for response",type:"dot"},error:{className:o,label:"Error",type:"dot"}},d={idle:{className:r,label:"Idle - No active session",type:"dot"},ready:{className:a,label:"Ready - Waiting for input",type:"dot"},running:{className:s,label:"Running - Processing",type:"spinner"},waiting:{className:l,label:"Waiting - User input required",type:"dot"},error:{className:o,label:"Error",type:"dot"}}},3468:function(e,t,n){n.d(t,{k:function(){return r}});let r={DROPDOWN:10,SIDEBAR:30,MODAL:50,MAXIMIZED_EDITOR:55,TOAST:60,CONTEXT_MENU:70}},58819:function(e,t,n){n.d(t,{G:function(){return a},d:function(){return s}});var r=n(2265);let a=768;function s(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{breakpoint:t=a}=e,[n,s]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let e=()=>window.innerWidth<t;s(e());let n=()=>{s(e())};return window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n)}},[t]),n}},74707:function(e,t,n){n.d(t,{Ds:function(){return s},tK:function(){return r},ts:function(){return l}});let r=["claude","codex","gemini","vibe-local"],a={claude:"Claude",codex:"Codex",gemini:"Gemini","vibe-local":"Vibe Local"};function s(e){var t;return null!==(t=a[e])&&void 0!==t?t:e}function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Assistant";return e&&r.includes(e)?s(e):t}},32636:function(e,t,n){n.d(t,{v:function(){return a}});let r=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07]*\x07|\[[0-9;]*m/g;async function a(e){if(!e||0===e.trim().length)return;let t=e.replace(r,"");await navigator.clipboard.writeText(t)}},98408:function(e,t,n){n.d(t,{G:function(){return l}});var r=n(69073),a=n(8854);let s={en:a._,ja:r.ja};function l(e){var t;return null!==(t=s[e])&&void 0!==t?t:a._}},87348:function(e,t,n){n.d(t,{Fq:function(){return r}}),n(74707);let r=["claude","codex"]},93448:function(e,t,n){function r(e,t){let n=null;return function(){for(var r=arguments.length,a=Array(r),s=0;s<r;s++)a[s]=arguments[s];n&&clearTimeout(n),n=setTimeout(()=>{e(...a),n=null},t)}}function a(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function s(e){let t=new Set;for(let n of e){t.add(n);let e=n.split("/"),r="";for(let n=0;n<e.length-1;n++)r=r?"".concat(r,"/").concat(e[n]):e[n],t.add(r)}return t}function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30;return e.length<=t?e:"".concat(e.substring(0,t-3),"...")}function o(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}n.d(t,{Ds:function(){return r},Ps:function(){return s},Xv:function(){return o},aS:function(){return l},hr:function(){return a}})},47712:function(e,t,n){n.d(t,{He:function(){return a},I_:function(){return s}});var r=n(87348);function a(e){return e?e.isWaitingForResponse?"waiting":e.isProcessing?"running":e.isRunning?"ready":"idle":"idle"}function s(e){var t,n;let s=!!e.lastAssistantMessageAt&&(!e.lastViewedAt||new Date(e.lastAssistantMessageAt)>new Date(e.lastViewedAt)),l=null!==(t=e.selectedAgents)&&void 0!==t?t:r.Fq,o={};for(let t of l)o[t]=a(null===(n=e.sessionStatusByCli)||void 0===n?void 0:n[t]);return{id:e.id,name:e.name,repositoryName:e.repositoryName,status:"idle",hasUnread:s,lastActivity:e.updatedAt,description:e.description,cliStatus:o}}}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8091],{20318:function(e,t,n){n.d(t,{Ix:function(){return x},pm:function(){return m}});var r=n(57437),a=n(2265),s=n(41671),l=n(99388),o=n(33245),i=n(32489),c=n(3468);function d(e){let{type:t,iconColor:n}=e,a="h-5 w-5 ".concat(n);switch(t){case"success":return(0,r.jsx)(s.Z,{className:a,"data-testid":"toast-icon-success"});case"error":return(0,r.jsx)(l.Z,{className:a,"data-testid":"toast-icon-error"});default:return(0,r.jsx)(o.Z,{className:a,"data-testid":"toast-icon-info"})}}function u(e){let{id:t,message:n,type:s,onClose:l,duration:o=3e3}=e,c=(0,a.useRef)(null),u=function(e){switch(e){case"success":return{bgColor:"bg-green-50",borderColor:"border-green-200",textColor:"text-green-800",iconColor:"text-green-500"};case"error":return{bgColor:"bg-red-50",borderColor:"border-red-200",textColor:"text-red-800",iconColor:"text-red-500"};default:return{bgColor:"bg-blue-50",borderColor:"border-blue-200",textColor:"text-blue-800",iconColor:"text-blue-500"}}}(s);(0,a.useEffect)(()=>(o>0&&(c.current=setTimeout(()=>{l(t)},o)),()=>{c.current&&clearTimeout(c.current)}),[t,o,l]);let x=(0,a.useCallback)(()=>{c.current&&clearTimeout(c.current),l(t)},[t,l]);return(0,r.jsxs)("div",{"data-testid":"toast-".concat(t),role:"alert",className:"\n ".concat(u.bgColor,"\n ").concat(u.borderColor,"\n ").concat(u.textColor,"\n border rounded-lg shadow-lg p-4 min-w-[300px] max-w-[400px]\n flex items-start gap-3\n animate-slide-in\n "),children:[(0,r.jsx)(d,{type:s,iconColor:u.iconColor}),(0,r.jsx)("p",{className:"flex-1 text-sm font-medium",children:n}),(0,r.jsx)("button",{"data-testid":"toast-close-button",onClick:x,"aria-label":"Close notification",className:"\n ".concat(u.textColor,"\n hover:opacity-70\n focus:outline-none focus:ring-2 focus:ring-offset-2\n transition-opacity\n "),children:(0,r.jsx)(i.Z,{className:"h-4 w-4"})})]})}function x(e){let{toasts:t,onClose:n}=e;return(0,r.jsx)("div",{"data-testid":"toast-container","aria-live":"polite",className:"fixed bottom-4 right-4 flex flex-col gap-2",style:{zIndex:c.k.TOAST},children:t.map(e=>(0,r.jsx)(u,{id:e.id,message:e.message,type:e.type,onClose:n,duration:e.duration},e.id))})}function m(){let[e,t]=(0,a.useState)([]),n=(0,a.useRef)(0);return{toasts:e,showToast:(0,a.useCallback)(function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e3,s="toast-".concat(++n.current,"-").concat(Date.now()),l={id:s,message:e,type:r,duration:a};return t(e=>[...e,l]),s},[]),removeToast:(0,a.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[]),clearToasts:(0,a.useCallback)(()=>{t([])},[])}}},8820:function(e,t,n){n.d(t,{Vw:function(){return M}});var r=n(57437),a=n(2265);n(27648);var s=n(43241),l=n(58819),o=n(99376),i=n(34021),c=n(8672),d=n(74707);function u(e){let{status:t,label:n}=e,a=c.F4[t],s="".concat(n,": ").concat(a.label);return"spinner"===a.type?(0,r.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ".concat(a.className),title:s,"aria-label":s}):(0,r.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ".concat(a.className),title:s,"aria-label":s})}let x=(0,a.memo)(function(e){let{branch:t,isSelected:n,onClick:a}=e;return(0,r.jsxs)("button",{"data-testid":"branch-list-item",onClick:a,"aria-current":n?"true":void 0,className:"\n w-full px-4 py-3 flex flex-col gap-1\n hover:bg-gray-800 transition-colors\n focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blue-500\n ".concat(n?"bg-gray-700 border-l-2 border-blue-500":"border-l-2 border-transparent","\n "),children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 w-full",children:[t.cliStatus&&Object.keys(t.cliStatus).length>0&&(0,r.jsx)("div",{className:"flex items-center gap-1 flex-shrink-0","aria-label":"CLI tool status",children:Object.entries(t.cliStatus).map(e=>{let[t,n]=e;return(0,r.jsx)(u,{status:null!=n?n:"idle",label:(0,d.Ds)(t)},t)})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 text-left",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white truncate",children:t.name}),(0,r.jsx)("p",{className:"text-xs text-gray-400 truncate",children:t.repositoryName})]}),t.hasUnread&&(0,r.jsx)("span",{"data-testid":"unread-indicator",className:"w-2 h-2 rounded-full bg-blue-500 flex-shrink-0","aria-label":"Has unread messages"})]}),t.description&&(0,r.jsx)("div",{"data-testid":"branch-description",className:"pl-6 pr-2 mt-1 text-left",children:(0,r.jsx)("p",{className:"text-xs text-gray-400 line-clamp-2",children:t.description})})]})}),m=[{key:"updatedAt",label:"Updated"},{key:"repositoryName",label:"Repository"},{key:"branchName",label:"Branch"},{key:"status",label:"Status"}],h=(0,a.memo)(function(){var e;let{sortKey:t,sortDirection:n,setSortKey:l,setSortDirection:o}=(0,s.Sz)(),[i,c]=(0,a.useState)(!1),d=(0,a.useRef)(null);(0,a.useEffect)(()=>{function e(e){d.current&&!d.current.contains(e.target)&&c(!1)}if(i)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]),(0,a.useEffect)(()=>{function e(e){"Escape"===e.key&&c(!1)}if(i)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[i]);let u=(0,a.useCallback)(()=>{c(e=>!e)},[]),x=(0,a.useCallback)(e=>{e===t?o("asc"===n?"desc":"asc"):(l(e),o("updatedAt"===e?"desc":"asc")),c(!1)},[t,n,l,o]),h=(0,a.useCallback)(()=>{o("asc"===n?"desc":"asc")},[n,o]),b=(null===(e=m.find(e=>e.key===t))||void 0===e?void 0:e.label)||"Sort";return(0,r.jsxs)("div",{ref:d,className:"relative","data-testid":"sort-selector",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsxs)("button",{type:"button",onClick:u,"aria-expanded":i,"aria-haspopup":"listbox","aria-label":"Sort by ".concat(b),className:" flex items-center gap-1 px-2 py-1 rounded text-xs text-gray-300 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors ",children:[(0,r.jsx)(f,{className:"w-3 h-3"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:b})]}),(0,r.jsx)("button",{type:"button",onClick:h,"aria-label":"asc"===n?"Sort ascending":"Sort descending",className:" p-1 rounded text-gray-300 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors ",children:"asc"===n?(0,r.jsx)(g,{className:"w-3 h-3"}):(0,r.jsx)(p,{className:"w-3 h-3"})})]}),i&&(0,r.jsx)("div",{role:"listbox","aria-label":"Sort options",className:" absolute right-0 top-full mt-1 z-50 min-w-[140px] py-1 rounded-md shadow-lg bg-gray-800 border border-gray-600 ",children:m.map(e=>(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":t===e.key,onClick:()=>x(e.key),className:"\n w-full px-3 py-2 text-left text-sm\n flex items-center justify-between\n hover:bg-gray-700 transition-colors\n ".concat(t===e.key?"text-blue-400":"text-gray-300","\n "),children:[(0,r.jsx)("span",{children:e.label}),t===e.key&&(0,r.jsx)("span",{className:"text-xs",children:"asc"===n?"ASC":"DESC"})]},e.key))})]})});function f(e){let{className:t}=e;return(0,r.jsx)("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"})})}function g(e){let{className:t}=e;return(0,r.jsx)("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 15l7-7 7 7"})})}function p(e){let{className:t}=e;return(0,r.jsx)("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}var b=n(69234);let y=["en","ja"],v={en:"English",ja:"日本語"};function w(){let{currentLocale:e,switchLocale:t}={currentLocale:(0,b.bU)(),switchLocale:e=>{y.includes(e)&&(!function(e){let t="https:"===window.location.protocol;document.cookie="".concat("locale","=").concat(e,";path=/;max-age=").concat(31536e3,";SameSite=Lax").concat(t?";Secure":"")}(e),localStorage.setItem("locale",e),window.location.reload())}};return(0,r.jsx)("select",{value:e,onChange:e=>t(e.target.value),"aria-label":"Language",className:" w-full px-3 py-2 rounded-md bg-gray-800 text-white border border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm ",children:y.map(e=>(0,r.jsx)("option",{value:e,children:v[e]},e))})}var j=n(38706),N=n(14362);function k(){let e=(0,j.T)("auth"),t=(0,N.m)(),[n,s]=(0,a.useState)(!1);if(!t)return null;async function l(){s(!0);try{await fetch("/api/auth/logout",{method:"POST"}),window.location.href="/login"}catch(e){window.location.href="/login"}}return(0,r.jsx)("button",{type:"button",onClick:l,disabled:n,"data-testid":"logout-button",className:" w-full px-3 py-2 text-sm text-left rounded-md text-gray-300 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 transition-colors ",children:n?"...":e("logout.button")})}var C=n(47712);let S={waiting:0,ready:1,running:2,generating:3,idle:4},L=(0,a.memo)(function(){let e=(0,o.useRouter)(),{worktrees:t,selectedWorktreeId:n,selectWorktree:l}=(0,i.Mu)(),{closeMobileDrawer:c,sortKey:d,sortDirection:u}=(0,s.Sz)(),[m,f]=(0,a.useState)(""),g=(0,a.useMemo)(()=>{let e=t.map(C.I_),n=e;if(m.trim()){let t=m.toLowerCase();n=e.filter(e=>e.name.toLowerCase().includes(t)||e.repositoryName.toLowerCase().includes(t))}return function(e,t,n){let r=[...e];return r.sort((e,r)=>{let a=0;switch(t){case"updatedAt":{let t=e=>e?e instanceof Date?e.getTime():new Date(e).getTime():0,n=t(e.lastActivity);a=t(r.lastActivity)-n;break}case"repositoryName":{let t=e.repositoryName.toLowerCase(),n=r.repositoryName.toLowerCase();a=t.localeCompare(n);break}case"branchName":{let t=e.name.toLowerCase(),n=r.name.toLowerCase();a=t.localeCompare(n);break}case"status":a=S[e.status]-S[r.status]}return("updatedAt"===t?"desc"===n:"asc"===n)?a:-a}),r}(n,d,u)},[t,m,d,u]),p=t=>{l(t),e.push("/worktrees/".concat(t)),c()};return(0,r.jsxs)("nav",{"data-testid":"sidebar","aria-label":"Branch navigation",className:"h-full flex flex-col bg-gray-900 text-white",role:"navigation",children:[(0,r.jsx)("div",{"data-testid":"sidebar-header",className:"flex-shrink-0 px-4 py-4 border-b border-gray-700",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-white",children:"Branches"}),(0,r.jsx)(h,{})]})}),(0,r.jsx)("div",{className:"flex-shrink-0 px-4 py-3 border-b border-gray-700",children:(0,r.jsx)("input",{type:"text",placeholder:"Search branches...",value:m,onChange:e=>f(e.target.value),className:" w-full px-3 py-2 rounded-md bg-gray-800 text-white placeholder-gray-400 border border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent "})}),(0,r.jsx)("div",{"data-testid":"branch-list",className:"flex-1 overflow-y-auto",children:0===g.length?(0,r.jsx)("div",{className:"px-4 py-8 text-center text-gray-400",children:m?"No branches found":"No branches available"}):g.map(e=>(0,r.jsx)(x,{branch:e,isSelected:e.id===n,onClick:()=>p(e.id)},e.id))}),(0,r.jsxs)("div",{className:"flex-shrink-0 px-4 py-3 border-t border-gray-700 space-y-2",children:[(0,r.jsx)(w,{}),(0,r.jsx)(k,{})]})]})});var E=n(3468);let z="transform transition-transform duration-300 ease-out",M=(0,a.memo)(function(e){let{children:t}=e,{isOpen:n,isMobileDrawerOpen:a,closeMobileDrawer:o}=(0,s.Sz)();return(0,l.d)()?(0,r.jsxs)("div",{"data-testid":"app-shell",className:"h-screen flex flex-col",children:[a&&(0,r.jsx)("div",{"data-testid":"drawer-overlay",className:"fixed inset-0 bg-black/50 z-40",onClick:o,"aria-hidden":"true"}),(0,r.jsx)("aside",{"data-testid":"sidebar-container",className:"\n fixed left-0 top-0 h-full w-72 z-50\n ".concat(z,"\n ").concat(a?"translate-x-0":"-translate-x-full","\n "),role:"complementary",children:(0,r.jsx)(L,{})}),(0,r.jsx)("main",{className:"flex-1 min-h-0 overflow-hidden",role:"main",children:t})]}):(0,r.jsxs)("div",{"data-testid":"app-shell",className:"h-screen flex",children:[(0,r.jsx)("aside",{"data-testid":"sidebar-container",className:"\n fixed left-0 top-0 h-full w-72\n ".concat(z,"\n ").concat(n?"translate-x-0":"-translate-x-full","\n "),style:{zIndex:E.k.SIDEBAR},role:"complementary","aria-hidden":!n,children:(0,r.jsx)(L,{})}),(0,r.jsx)("main",{className:"\n flex-1 min-w-0 h-full overflow-hidden\n transition-[padding] duration-300 ease-out\n ".concat(n?"md:pl-72":"md:pl-0","\n "),role:"main",children:t})]})})},98702:function(e,t,n){n.d(t,{u:function(){return o}});var r=n(57437),a=n(2265),s=n(54887),l=n(3468);function o(e){let{isOpen:t,onClose:n,title:o,children:i,size:c="lg",showCloseButton:d=!0,disableClose:u=!1}=e,x=(0,a.useRef)(null);return((0,a.useEffect)(()=>{if(u)return;let e=e=>{"Escape"===e.key&&t&&n()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,n,u]),(0,a.useEffect)(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[t]),t)?(0,s.createPortal)((0,r.jsxs)("div",{className:"fixed inset-0 overflow-y-auto",style:{zIndex:l.k.MODAL},children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 transition-opacity",onClick:u?void 0:n}),(0,r.jsx)("div",{className:"relative flex min-h-full items-center justify-center p-2 sm:p-4",children:(0,r.jsxs)("div",{ref:x,className:"relative w-full ".concat({sm:"max-w-[calc(100vw-2rem)] sm:max-w-md",md:"max-w-[calc(100vw-2rem)] sm:max-w-2xl",lg:"max-w-[calc(100vw-2rem)] sm:max-w-4xl",xl:"max-w-[calc(100vw-2rem)] sm:max-w-6xl",full:"max-w-[calc(100vw-2rem)] sm:max-w-[95vw]"}[c]," max-h-[calc(100vh-1rem)] sm:max-h-[calc(100vh-2rem)] flex flex-col bg-white rounded-lg shadow-xl transform transition-all"),children:[(o||d)&&(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 sm:px-6 py-3 sm:py-4 border-b border-gray-200 flex-shrink-0",children:[(0,r.jsx)("h3",{className:"text-base sm:text-lg font-semibold text-gray-900 truncate pr-2",children:o}),d&&(0,r.jsx)("button",{onClick:n,className:"text-gray-400 hover:text-gray-600 transition-colors flex-shrink-0",children:(0,r.jsx)("svg",{className:"w-5 h-5 sm:w-6 sm:h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"px-4 sm:px-6 py-3 sm:py-4 overflow-y-auto flex-1 min-h-0",children:i})]})})]}),document.body):null}},10789:function(e,t,n){n.d(t,{Ct:function(){return c},zx:function(){return a},Zb:function(){return s},aY:function(){return i},Ol:function(){return l},ll:function(){return o},u_:function(){return d.u}});var r=n(57437);function a(e){let{variant:t="primary",size:n="md",fullWidth:a=!1,loading:s=!1,disabled:l,className:o="",children:i,...c}=e,d=["btn",{primary:"btn-primary",secondary:"btn-secondary",danger:"btn-danger",ghost:"bg-transparent text-gray-700 hover:bg-gray-100 focus:ring-gray-500"}[t],{sm:"btn-sm",md:"",lg:"btn-lg"}[n],a?"w-full":"",l||s?"opacity-50 cursor-not-allowed":"",o].filter(Boolean).join(" ");return(0,r.jsxs)("button",{className:d,disabled:l||s,...c,children:[s&&(0,r.jsxs)("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),i]})}function s(e){let{hover:t=!1,padding:n="md",className:a="",children:s,...l}=e,o=["card",t?"card-hover":"",{none:"",sm:"p-3",md:"p-4",lg:"p-6"}[n],a].filter(Boolean).join(" ");return(0,r.jsx)("div",{className:o,...l,children:s})}function l(e){let{className:t="",children:n,...a}=e;return(0,r.jsx)("div",{className:"mb-3 ".concat(t),...a,children:n})}function o(e){let{className:t="",children:n,...a}=e;return(0,r.jsx)("h3",{className:"text-lg font-semibold text-gray-900 ".concat(t),...a,children:n})}function i(e){let{className:t="",children:n,...a}=e;return(0,r.jsx)("div",{className:t,...a,children:n})}function c(e){let{variant:t="gray",dot:n=!1,className:a="",children:s,...l}=e,o=["badge",{success:"badge-success",warning:"badge-warning",error:"badge-error",info:"badge-info",gray:"badge-gray"}[t],a].filter(Boolean).join(" ");return(0,r.jsxs)("span",{className:o,...l,children:[n&&(0,r.jsx)("span",{className:"mr-1.5 inline-block h-2 w-2 rounded-full ".concat({success:"bg-green-600",warning:"bg-yellow-600",error:"bg-red-600",info:"bg-blue-600",gray:"bg-gray-600"}[t]),"aria-hidden":"true"}),s]})}n(2265);var d=n(98702)},43616:function(e,t,n){n.d(t,{n:function(){return d}});var r=n(57437),a=n(2265),s=n(10789),l=n(20318),o=n(3227),i=n(32636),c=n(93448);function d(e){let{worktreeId:t}=e,[n,d]=(0,a.useState)([]),[u,x]=(0,a.useState)(null),[m,h]=(0,a.useState)(null),[f,g]=(0,a.useState)(!0),[p,b]=(0,a.useState)(null),[y,v]=(0,a.useState)(""),[w,j]=(0,a.useState)(0),[N,k]=(0,a.useState)("all"),[C,S]=(0,a.useState)(!1),{toasts:L,showToast:E,removeToast:z}=(0,l.pm)();(0,a.useEffect)(()=>{(async()=>{try{g(!0),b(null);let e=await o.Iv.getLogs(t);d(e)}catch(e){b((0,o.zG)(e))}finally{g(!1)}})()},[t]);let M=(0,a.useMemo)(()=>"all"===N?n:n.filter(e=>e.toLowerCase().includes(N)),[n,N]),T=async e=>{try{g(!0),b(null);let n=await o.Iv.getLogFile(t,e);h(n.content),x(e),v(""),j(0)}catch(e){b((0,o.zG)(e))}finally{g(!1)}},A=(0,a.useCallback)(async()=>{if(u)try{S(!0);let e=await o.Iv.getLogFile(t,u,{sanitize:!0});await (0,i.v)(e.content),E("Log copied to clipboard (sanitized)","success")}catch(e){E("Failed to export log: ".concat((0,o.zG)(e)),"error")}finally{S(!1)}},[t,u,E]),I=(0,a.useMemo)(()=>{let e;if(!y||!m)return[];let t=RegExp((0,c.hr)(y),"gi"),n=[];for(;null!==(e=t.exec(m));)n.push({index:e.index,length:e[0].length});return n},[y,m]);(0,a.useEffect)(()=>{j(0)},[y]);let D=()=>{I.length>0&&j(e=>(e+1)%I.length)},R=()=>{I.length>0&&j(e=>(e-1+I.length)%I.length)},B=(0,a.useMemo)(()=>{if(!m||!y||0===I.length)return m;let e="",t=0;return I.forEach((n,r)=>{e+=(0,c.Xv)(m.substring(t,n.index));let a=m.substring(n.index,n.index+n.length),s=r===w;e+='<mark class="'.concat(s?"bg-yellow-400 text-black":"bg-yellow-200 text-black",'" data-match-index="').concat(r,'">').concat((0,c.Xv)(a),"</mark>"),t=n.index+n.length}),e+=(0,c.Xv)(m.substring(t))},[m,y,I,w]);return(0,a.useEffect)(()=>{I.length>0&&w>=0&&setTimeout(()=>{let e=document.querySelector('mark[data-match-index="'.concat(w,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"})},100)},[w,I.length]),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(s.Zb,{padding:"md",children:[(0,r.jsx)(s.Ol,{children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(s.ll,{children:"Log Files"}),(0,r.jsx)(s.Ct,{variant:"gray",children:M.length})]}),(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,r.jsxs)(s.zx,{variant:"all"===N?"primary":"ghost",size:"sm",onClick:()=>k("all"),children:["All (",n.length,")"]}),(0,r.jsxs)(s.zx,{variant:"claude"===N?"primary":"ghost",size:"sm",onClick:()=>k("claude"),children:["Claude (",n.filter(e=>e.toLowerCase().includes("claude")).length,")"]}),(0,r.jsxs)(s.zx,{variant:"codex"===N?"primary":"ghost",size:"sm",onClick:()=>k("codex"),children:["Codex (",n.filter(e=>e.toLowerCase().includes("codex")).length,")"]}),(0,r.jsxs)(s.zx,{variant:"gemini"===N?"primary":"ghost",size:"sm",onClick:()=>k("gemini"),children:["Gemini (",n.filter(e=>e.toLowerCase().includes("gemini")).length,")"]})]})]})}),(0,r.jsxs)(s.aY,{children:[f&&0===n.length&&(0,r.jsx)("div",{className:"text-center py-4",children:(0,r.jsx)("div",{className:"inline-block animate-spin rounded-full h-6 w-6 border-4 border-gray-300 border-t-blue-600"})}),p&&(0,r.jsx)("div",{className:"p-3 bg-red-50 border border-red-200 rounded text-sm text-red-800",children:p}),!f&&0===M.length&&!p&&(0,r.jsx)("p",{className:"text-sm text-gray-600 text-center py-4",children:"all"===N?"No log files found":"No ".concat(N," log files found")}),M.length>0&&(0,r.jsx)("div",{className:"space-y-2",children:M.map(e=>(0,r.jsx)("button",{onClick:()=>T(e),className:"w-full text-left px-3 py-2 rounded text-sm font-mono transition-colors ".concat(u===e?"bg-blue-50 text-blue-700 border border-blue-200":"hover:bg-gray-50 border border-transparent"),children:e},e))})]})]}),u&&(0,r.jsxs)(s.Zb,{padding:"md",children:[(0,r.jsx)(s.Ol,{children:(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(s.ll,{className:"font-mono text-base",children:u}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(s.zx,{variant:"ghost",size:"sm",onClick:A,disabled:!u||C,title:"Copy sanitized log to clipboard",children:C?"Exporting...":"Export"}),(0,r.jsx)(s.zx,{variant:"ghost",size:"sm",onClick:()=>{x(null),h(null),v(""),j(0)},children:"Close"})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)("input",{type:"text",value:y,onChange:e=>v(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?R():D())},placeholder:"Search in log file...",className:"input w-full pr-20"}),I.length>0&&(0,r.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:[w+1," / ",I.length]})]}),I.length>0&&(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)(s.zx,{variant:"ghost",size:"sm",onClick:R,disabled:0===I.length,title:"Previous match (Shift+Enter)",children:"↑"}),(0,r.jsx)(s.zx,{variant:"ghost",size:"sm",onClick:D,disabled:0===I.length,title:"Next match (Enter)",children:"↓"})]})]})]})}),(0,r.jsxs)(s.aY,{children:[f&&(0,r.jsx)("div",{className:"text-center py-8",children:(0,r.jsx)("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"})}),!f&&m&&(0,r.jsx)("div",{className:"bg-gray-900 text-gray-100 rounded p-4 overflow-x-auto max-h-[500px] scrollbar-thin",children:y&&I.length>0?(0,r.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",dangerouslySetInnerHTML:{__html:B||""}}):(0,r.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",children:m})}),!f&&y&&0===I.length&&m&&(0,r.jsxs)("div",{className:"text-center py-4 text-sm text-gray-500",children:['No matches found for "',y,'"']})]})]}),(0,r.jsx)(l.Ix,{toasts:L,onClose:z})]})}},6940:function(e,t,n){n.d(t,{R:function(){return x}});var r=n(57437),a=n(2265),s=n(3227);function l(e,t){if(!t.trim())return e;let n=t.toLowerCase();return e.map(e=>({...e,commands:e.commands.filter(e=>{let t=e.name.toLowerCase().includes(n),r=e.description.toLowerCase().includes(n);return t||r})})).filter(e=>e.commands.length>0)}function o(e){let{groups:t,onSelect:n,highlightedIndex:a=-1,className:s=""}=e,l=0;return 0===t.length?(0,r.jsx)("div",{className:"text-sm text-gray-500 p-4 text-center ".concat(s),children:"No commands available"}):(0,r.jsx)("div",{className:"overflow-y-auto ".concat(s),children:t.map(e=>(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs font-semibold text-gray-500 uppercase tracking-wider bg-gray-50",children:e.label}),(0,r.jsx)("div",{children:e.commands.map(e=>{let t=l;l++;let s=t===a;return(0,r.jsxs)("button",{type:"button","data-command-item":!0,"data-highlighted":s,onClick:()=>n(e),className:"w-full px-3 py-2 text-left flex items-start gap-2 hover:bg-blue-50 transition-colors ".concat(s?"bg-blue-100":""),children:[(0,r.jsxs)("span",{className:"text-blue-600 font-mono text-sm flex-shrink-0",children:["/",e.name]}),(0,r.jsx)("span",{className:"text-gray-600 text-sm truncate",children:e.description})]},e.name)})})]},e.category))})}function i(e){let{isOpen:t,groups:n,onSelect:s,onClose:i,isMobile:c=!1,position:d,onFreeInput:u}=e,[x,m]=(0,a.useState)(""),[h,f]=(0,a.useState)(0),g=(0,a.useRef)(null),p=(0,a.useMemo)(()=>l(n,x),[n,x]),b=(0,a.useMemo)(()=>p.flatMap(e=>e.commands),[p]);(0,a.useEffect)(()=>{t&&(m(""),f(0),setTimeout(()=>{var e;null===(e=g.current)||void 0===e||e.focus()},50))},[t]);let y=(0,a.useCallback)(e=>{s(e),i()},[s,i]),v=(0,a.useCallback)(e=>{if(t)switch(e.key){case"Escape":e.preventDefault(),i();break;case"ArrowDown":e.preventDefault(),f(e=>Math.min(e+1,b.length-1));break;case"ArrowUp":e.preventDefault(),f(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),b[h]&&y(b[h])}},[t,b,h,i,y]);return((0,a.useEffect)(()=>{if(t)return document.addEventListener("keydown",v),()=>{document.removeEventListener("keydown",v)}},[t,v]),t)?c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 z-40",onClick:i,"aria-hidden":"true"}),(0,r.jsxs)("div",{"data-testid":"slash-command-bottom-sheet",className:"fixed bottom-0 left-0 right-0 bg-white rounded-t-xl z-50 max-h-[70vh] flex flex-col shadow-xl",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Commands"}),(0,r.jsx)("button",{type:"button",onClick:i,"aria-label":"Close",className:"p-2 rounded-full hover:bg-gray-100",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"px-4 py-2 border-b border-gray-100",children:(0,r.jsx)("input",{ref:g,type:"text",value:x,onChange:e=>m(e.target.value),placeholder:"Search commands...",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})}),u&&(0,r.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:()=>u(x),className:"w-full px-4 py-3 text-left border-b border-gray-100 flex items-center gap-2 hover:bg-blue-50 transition-colors",children:[(0,r.jsx)("span",{className:"text-blue-600",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,r.jsx)("span",{className:"text-gray-600",children:"Enter custom command..."})]}),(0,r.jsx)(o,{groups:p,onSelect:y,highlightedIndex:h,className:"flex-1 overflow-y-auto pb-20"})]})]}):(0,r.jsxs)("div",{role:"listbox",className:"absolute bg-white border border-gray-200 rounded-lg shadow-lg z-50 w-80 max-h-96 flex flex-col",style:d?{top:d.top,left:d.left}:{bottom:"100%",left:0,marginBottom:"4px"},children:[(0,r.jsx)("div",{className:"px-3 py-2 border-b border-gray-100",children:(0,r.jsx)("input",{ref:g,type:"text",value:x,onChange:e=>m(e.target.value),placeholder:"Search commands...",className:"w-full px-3 py-1.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"})}),u&&(0,r.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:()=>u(x),className:"w-full px-3 py-2 text-left border-b border-gray-100 flex items-center gap-2 hover:bg-blue-50 transition-colors text-sm",children:[(0,r.jsx)("span",{className:"text-blue-600",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,r.jsx)("span",{className:"text-gray-600",children:"Enter custom command..."})]}),(0,r.jsx)(o,{groups:p,onSelect:y,highlightedIndex:h,className:"flex-1 overflow-y-auto"}),(0,r.jsxs)("div",{className:"px-3 py-1.5 border-t border-gray-100 text-xs text-gray-400 flex gap-3",children:[(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-gray-100 rounded",children:"Enter"})," select"]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-gray-100 rounded",children:"Esc"})," close"]})]})]}):null}function c(e){let{worktreeId:t,cliToolId:n,disabled:s=!1,onInterrupt:l}=e,[o,i]=(0,a.useState)(!1),c=(0,a.useRef)(0),u=(0,a.useCallback)(async()=>{let e=Date.now();if(!(e-c.current<1e3)){c.current=e,i(!0);try{let e=await fetch("/api/worktrees/".concat(t,"/interrupt"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliToolId:n})});if(e.ok)null==l||l();else{let t=await e.json().catch(()=>({}));console.error("[InterruptButton] Failed to send interrupt:",t.error||e.statusText)}}catch(e){console.error("[InterruptButton] Error sending interrupt:",e)}finally{i(!1)}}},[t,n,l]);return(0,r.jsx)("button",{type:"button",onClick:u,disabled:s||o,className:"flex-shrink-0 p-2 text-orange-600 hover:bg-orange-50 rounded-full transition-colors disabled:text-gray-300 disabled:hover:bg-transparent","aria-label":"Stop processing","data-testid":"interrupt-button",children:o?(0,r.jsxs)("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):(0,r.jsx)(d,{})})}function d(){return(0,r.jsx)("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}var u=n(58819);function x(e){let{worktreeId:t,onMessageSent:n,cliToolId:o,isSessionRunning:d=!1}=e,[x,m]=(0,a.useState)(""),[h,f]=(0,a.useState)(!1),[g,p]=(0,a.useState)(null),[b,y]=(0,a.useState)(!1),[v,w]=(0,a.useState)(!1),[j,N]=(0,a.useState)(!1),k=(0,a.useRef)(null),C=(0,a.useRef)(null),S=(0,a.useRef)(!1),L=(0,a.useRef)(null),E=(0,u.d)(),{groups:z}=function(e,t){let[n,r]=(0,a.useState)([]),[o,i]=(0,a.useState)(!0),[c,d]=(0,a.useState)(null),[u,x]=(0,a.useState)(""),[m,h]=(0,a.useState)(t||"claude"),f=(0,a.useCallback)(async()=>{try{i(!0),d(null);let n=e?"/api/worktrees/".concat(e,"/slash-commands"):"/api/slash-commands";t&&(n+="?cliTool=".concat(t));let a=await fetch(n);if(!a.ok)throw Error("HTTP error ".concat(a.status));let s=await a.json();r(s.groups),h(s.cliTool||t||"claude")}catch(e){d((0,s.zG)(e)),r([])}finally{i(!1)}},[e,t]);(0,a.useEffect)(()=>{f()},[f]);let g=(0,a.useMemo)(()=>n.flatMap(e=>e.commands),[n]),p=(0,a.useMemo)(()=>l(n,u),[n,u]);return{groups:n,filteredGroups:p,allCommands:g,loading:o,error:c,filter:u,setFilter:x,refresh:(0,a.useCallback)(()=>{f()},[f]),cliTool:m}}(t,o);(0,a.useEffect)(()=>{let e=k.current;e&&(x?(e.style.height="auto",e.style.height="".concat(Math.min(e.scrollHeight,160),"px")):e.style.height="24px")},[x]);let M=async()=>{if(!b&&x.trim()&&!h)try{f(!0),p(null);let e=o||"claude";await s.Iv.sendMessage(t,x.trim(),e),m(""),N(!1),null==n||n(e)}catch(e){p((0,s.zG)(e))}finally{f(!1)}},T=async e=>{e.preventDefault(),await M()},A=()=>{var e;w(!1),N(!1),null===(e=k.current)||void 0===e||e.focus()};return(0,r.jsxs)("div",{ref:L,className:"space-y-2 relative",children:[g&&(0,r.jsx)("div",{className:"p-2 bg-red-50 border border-red-200 rounded text-sm text-red-800",children:g}),(0,r.jsxs)("form",{onSubmit:T,className:"flex items-end gap-2 bg-white border border-gray-300 rounded-lg px-4 py-2 focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-500",children:[E&&(0,r.jsx)("button",{type:"button",onClick:()=>{j&&N(!1),w(!0)},className:"flex-shrink-0 p-2 text-gray-500 hover:text-blue-600 hover:bg-blue-50 rounded-full transition-colors","aria-label":"Show slash commands","data-testid":"mobile-command-button",children:(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"})})}),(0,r.jsx)("textarea",{ref:k,value:x,onChange:e=>{let t=e.target.value;if(m(t),""===t){N(!1),w(!1);return}j||("/"===t||t.startsWith("/")&&!t.includes(" ")?w(!0):w(!1))},onKeyDown:e=>{let{keyCode:t}=e.nativeEvent;if(229!==t){if("Escape"===e.key&&v){e.preventDefault(),A();return}if(S.current&&"Enter"===e.key){S.current=!1;return}if("Enter"===e.key&&!b&&(!v||j)){if(E)return;e.shiftKey||(e.preventDefault(),M())}}},onCompositionStart:()=>{y(!0),S.current=!1,C.current&&clearTimeout(C.current)},onCompositionEnd:()=>{y(!1),S.current=!0,C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{S.current=!1},300)},placeholder:E?"Type your message...":"Type your message... (/ for commands, Shift+Enter for line break)",disabled:h,rows:1,className:"flex-1 outline-none bg-transparent resize-none py-1 overflow-y-auto scrollbar-thin",style:{minHeight:"24px",maxHeight:"160px"}}),(0,r.jsx)(c,{worktreeId:t,cliToolId:o||"claude",disabled:!d}),(0,r.jsx)("button",{type:"submit",disabled:!x.trim()||h,className:"flex-shrink-0 p-2 text-blue-600 hover:bg-blue-50 rounded-full transition-colors disabled:text-gray-300 disabled:hover:bg-transparent","aria-label":"Send message",children:h?(0,r.jsxs)("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]}),(0,r.jsx)(i,{isOpen:v,groups:z,onSelect:e=>{var t;m("/".concat(e.name," ")),w(!1),null===(t=k.current)||void 0===t||t.focus()},onClose:A,isMobile:E,onFreeInput:e=>{w(!1),N(!0),m(e?"/".concat(e):"/"),setTimeout(()=>{var e;null===(e=k.current)||void 0===e||e.focus()},50)}})]})}},8672:function(e,t,n){n.d(t,{F4:function(){return i},Ie:function(){return d},xh:function(){return c}});let r="bg-gray-500",a="bg-green-500",s="border-blue-500",l="bg-yellow-500",o="bg-red-500",i={idle:{className:r,label:"Idle",type:"dot"},ready:{className:a,label:"Ready",type:"dot"},running:{className:s,label:"Running",type:"spinner"},waiting:{className:l,label:"Waiting for response",type:"dot"},generating:{className:s,label:"Generating",type:"spinner"}},c={idle:{className:r,label:"Idle",type:"dot"},ready:{className:a,label:"Ready",type:"dot"},running:{className:s,label:"Running",type:"spinner"},waiting:{className:l,label:"Waiting for response",type:"dot"},error:{className:o,label:"Error",type:"dot"}},d={idle:{className:r,label:"Idle - No active session",type:"dot"},ready:{className:a,label:"Ready - Waiting for input",type:"dot"},running:{className:s,label:"Running - Processing",type:"spinner"},waiting:{className:l,label:"Waiting - User input required",type:"dot"},error:{className:o,label:"Error",type:"dot"}}},3468:function(e,t,n){n.d(t,{k:function(){return r}});let r={DROPDOWN:10,SIDEBAR:30,MODAL:50,MAXIMIZED_EDITOR:55,TOAST:60,CONTEXT_MENU:70}},58819:function(e,t,n){n.d(t,{G:function(){return a},d:function(){return s}});var r=n(2265);let a=768;function s(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{breakpoint:t=a}=e,[n,s]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let e=()=>window.innerWidth<t;s(e());let n=()=>{s(e())};return window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n)}},[t]),n}},74707:function(e,t,n){n.d(t,{Ds:function(){return s},Ho:function(){return o},Ns:function(){return i},tK:function(){return r},ts:function(){return l}});let r=["claude","codex","gemini","vibe-local"],a={claude:"Claude",codex:"Codex",gemini:"Gemini","vibe-local":"Vibe Local"};function s(e){var t;return null!==(t=a[e])&&void 0!==t?t:e}function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Assistant";return e&&r.includes(e)?s(e):t}let o=128,i=2097152},32636:function(e,t,n){n.d(t,{v:function(){return a}});let r=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07]*\x07|\[[0-9;]*m/g;async function a(e){if(!e||0===e.trim().length)return;let t=e.replace(r,"");await navigator.clipboard.writeText(t)}},98408:function(e,t,n){n.d(t,{G:function(){return l}});var r=n(69073),a=n(8854);let s={en:a._,ja:r.ja};function l(e){var t;return null!==(t=s[e])&&void 0!==t?t:a._}},87348:function(e,t,n){n.d(t,{Fq:function(){return r}}),n(74707);let r=["claude","codex"]},93448:function(e,t,n){function r(e,t){let n=null;return function(){for(var r=arguments.length,a=Array(r),s=0;s<r;s++)a[s]=arguments[s];n&&clearTimeout(n),n=setTimeout(()=>{e(...a),n=null},t)}}function a(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function s(e){let t=new Set;for(let n of e){t.add(n);let e=n.split("/"),r="";for(let n=0;n<e.length-1;n++)r=r?"".concat(r,"/").concat(e[n]):e[n],t.add(r)}return t}function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30;return e.length<=t?e:"".concat(e.substring(0,t-3),"...")}function o(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}n.d(t,{Ds:function(){return r},Ps:function(){return s},Xv:function(){return o},aS:function(){return l},hr:function(){return a}})},47712:function(e,t,n){n.d(t,{He:function(){return a},I_:function(){return s}});var r=n(87348);function a(e){return e?e.isWaitingForResponse?"waiting":e.isProcessing?"running":e.isRunning?"ready":"idle":"idle"}function s(e){var t,n;let s=!!e.lastAssistantMessageAt&&(!e.lastViewedAt||new Date(e.lastAssistantMessageAt)>new Date(e.lastViewedAt)),l=null!==(t=e.selectedAgents)&&void 0!==t?t:r.Fq,o={};for(let t of l)o[t]=a(null===(n=e.sessionStatusByCli)||void 0===n?void 0:n[t]);return{id:e.id,name:e.name,repositoryName:e.repositoryName,status:"idle",hasUnread:s,lastActivity:e.updatedAt,description:e.description,cliStatus:o}}}}]);