codeharden 2026.1122.2133 → 2026.1122.2302

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 (108) hide show
  1. package/README.md +48 -3
  2. package/dist/{args-B0i5tyjE.js → args-BJ0ric8X.js} +5 -5
  3. package/dist/args-BJ0ric8X.js.map +1 -0
  4. package/dist/cli.js +2 -2
  5. package/dist/{commands-CvAvyECH.js → commands-BPobEsBP.js} +33 -14
  6. package/dist/commands-BPobEsBP.js.map +1 -0
  7. package/dist/{env-wDgRchH9.js → env-CMkse2o0.js} +2 -2
  8. package/dist/{env-wDgRchH9.js.map → env-CMkse2o0.js.map} +1 -1
  9. package/dist/{harden-channel-2IT0Y7p3.js → harden-channel-D7h06kQ_.js} +41 -3
  10. package/dist/harden-channel-D7h06kQ_.js.map +1 -0
  11. package/dist/{launcher-D17oQovS.js → launcher-CvQZcEIC.js} +3 -3
  12. package/dist/launcher-CvQZcEIC.js.map +1 -0
  13. package/dist/{lock-DxXcNd2w.js → lock-iovTSSb0.js} +2 -2
  14. package/dist/{lock-DxXcNd2w.js.map → lock-iovTSSb0.js.map} +1 -1
  15. package/dist/{main-BRHfJHGf.js → main-BFo94KOF.js} +6 -6
  16. package/dist/{main-BRHfJHGf.js.map → main-BFo94KOF.js.map} +1 -1
  17. package/dist/{main-CJdbWeA_.js → main-B_ui4G93.js} +3 -3
  18. package/dist/{main-CJdbWeA_.js.map → main-B_ui4G93.js.map} +1 -1
  19. package/dist/{mediaType-e66mt7Cb.js → mediaType-DHbUOwRj.js} +2 -2
  20. package/dist/{mediaType-e66mt7Cb.js.map → mediaType-DHbUOwRj.js.map} +1 -1
  21. package/dist/{runner-CKo8zFVx.js → runner-agAgr2qn.js} +5 -5
  22. package/dist/{runner-CKo8zFVx.js.map → runner-agAgr2qn.js.map} +1 -1
  23. package/dist/{runner-link-CGefyJ5U.js → runner-link-B7SsTYaz.js} +3 -3
  24. package/dist/{runner-link-CGefyJ5U.js.map → runner-link-B7SsTYaz.js.map} +1 -1
  25. package/dist/runner.js +1 -1
  26. package/dist/{server-test-aa-ENBUk.js → server-test-Cad_bM68.js} +4 -4
  27. package/dist/{server-test-aa-ENBUk.js.map → server-test-Cad_bM68.js.map} +1 -1
  28. package/dist/{src-CwV8i4Mj.js → src-BPcdaWEw.js} +4 -6
  29. package/dist/{src-CwV8i4Mj.js.map → src-BPcdaWEw.js.map} +1 -1
  30. package/dist/web/assets/{add-project-dialog-VBi3WXnh.js → add-project-dialog-BHbgORVh.js} +1 -1
  31. package/dist/web/assets/{agent-tabs-BNgrQWDq.js → agent-tabs-B6uUKAXD.js} +1 -1
  32. package/dist/web/assets/{agents-Ir1aHz-I.js → agents-NbcZbVrc.js} +1 -1
  33. package/dist/web/assets/{api-jkvqht5P.js → api-B9OffDXw.js} +1 -1
  34. package/dist/web/assets/{api-B620HpC2.js → api-yvn34iKU.js} +27 -27
  35. package/dist/web/assets/{archived-sessions-D4fJHB37.js → archived-sessions-C1-stU7x.js} +1 -1
  36. package/dist/web/assets/{automation-B91XTDIM.js → automation-Co7V1tcW.js} +1 -1
  37. package/dist/web/assets/{automation-new-CN7YhryW.js → automation-new-hCV8HoK1.js} +1 -1
  38. package/dist/web/assets/{automations-CLzVG-zc.js → automations-7GJxGbPp.js} +1 -1
  39. package/dist/web/assets/{composer-Dd8joSgj.js → composer-B1tdNGSi.js} +1 -1
  40. package/dist/web/assets/{conflict-card-BN9kNMVL.js → conflict-card-Bx8tT_d5.js} +1 -1
  41. package/dist/web/assets/{dialog-Dyw3b_Tu.js → dialog-Cvj_lHPY.js} +1 -1
  42. package/dist/web/assets/{diff-panel-CQ2XZMk2.js → diff-panel-BHhM9z93.js} +1 -1
  43. package/dist/web/assets/{draft-BmnE6-7J.js → draft-JkaN3nCS.js} +1 -1
  44. package/dist/web/assets/{dropdown-menu-C4XI7F63.js → dropdown-menu-Bflkx6wY.js} +1 -1
  45. package/dist/web/assets/{engines-Chq2ih3x.js → engines-pLQJYIu_.js} +1 -1
  46. package/dist/web/assets/{factory-BBYEYI9i.js → factory-DVCs5zxg.js} +1 -1
  47. package/dist/web/assets/{factory-columns-CtJOpFim.js → factory-columns-DExb6gW2.js} +1 -1
  48. package/dist/web/assets/{factory-item-BjydL6AH.js → factory-item-efMFkxnv.js} +1 -1
  49. package/dist/web/assets/{factory-view-BU2AKcD8.js → factory-view-Cot7flHA.js} +1 -1
  50. package/dist/web/assets/{files-panel-B6_6pSo9.js → files-panel-BIkR_seN.js} +1 -1
  51. package/dist/web/assets/{floor-scene-DCpEq0j7.js → floor-scene-DGy8i_5R.js} +1 -1
  52. package/dist/web/assets/{form-bits-BSfnSmQ7.js → form-bits-5XojWhBG.js} +1 -1
  53. package/dist/web/assets/{format-D1ma_o2D.js → format-D3kairnQ.js} +1 -1
  54. package/dist/web/assets/{home-_m_Aihwv.js → home-BtFPGjza.js} +1 -1
  55. package/dist/web/assets/{inbox-FDD5FMWW.js → inbox-CUPkJ4WC.js} +1 -1
  56. package/dist/web/assets/{index-BkpVvQrC.js → index-C0C9GyeX.js} +4 -4
  57. package/dist/web/assets/{item-parts-BhDFWsT1.js → item-parts-DZ3TQad4.js} +1 -1
  58. package/dist/web/assets/{kill-switch-Dvqaozhz.js → kill-switch-BDAFCjui.js} +1 -1
  59. package/dist/web/assets/{label-DcWfyglU.js → label-Bm_8Eqe2.js} +1 -1
  60. package/dist/web/assets/{local-whisper-test-DPTOEA1M.js → local-whisper-test-CqGlAOvK.js} +1 -1
  61. package/dist/web/assets/{markdown-ad2jia51.js → markdown-DGHfubu-.js} +1 -1
  62. package/dist/web/assets/{mobile-nav-D8FZcJzG.js → mobile-nav-CrjrDJZ5.js} +1 -1
  63. package/dist/web/assets/{model-picker-4yoJPkRY.js → model-picker-DnKv2cbc.js} +1 -1
  64. package/dist/web/assets/{new-session-ddLbjOoZ.js → new-session-Bc93-xJK.js} +1 -1
  65. package/dist/web/assets/{new-session-GpxXZWbB.js → new-session-CUpOffXI.js} +1 -1
  66. package/dist/web/assets/{new-session-CwbgcYzY.js → new-session-DVYesr8z.js} +1 -1
  67. package/dist/web/assets/{now-next-D-6j1g_S.js → now-next-x8fwFm7p.js} +1 -1
  68. package/dist/web/assets/{on-demand-Cvu5D9uT.js → on-demand-Cvi90jRi.js} +2 -2
  69. package/dist/web/assets/{open-pr-controls--EtUvzD2.js → open-pr-controls-CYypJCKQ.js} +1 -1
  70. package/dist/web/assets/{orchestration-pknfiYFr.js → orchestration-BZj0HlxR.js} +1 -1
  71. package/dist/web/assets/{page-header-BqPf-jRo.js → page-header-t9HzSrxd.js} +1 -1
  72. package/dist/web/assets/{pm-fMuSJMPP.js → pm-DJfHcB90.js} +1 -1
  73. package/dist/web/assets/{popover-OrzLEhHL.js → popover-BqwWmyWQ.js} +1 -1
  74. package/dist/web/assets/{pr-details-BBVM9Kll.js → pr-details-1hhbiFWa.js} +1 -1
  75. package/dist/web/assets/{project-ws85aDq4.js → project-dy2_DT0H.js} +1 -1
  76. package/dist/web/assets/{question-card-4aNx5IRX.js → question-card-ldxLXNS_.js} +1 -1
  77. package/dist/web/assets/{remote-check-BAPXUznK.js → remote-check-CQktPgyp.js} +2 -2
  78. package/dist/web/assets/{reports-BZj5_wsp.js → reports-D0GAsXFv.js} +1 -1
  79. package/dist/web/assets/{role-chat-CeJXMsYB.js → role-chat-nIyzM-vQ.js} +1 -1
  80. package/dist/web/assets/{run-conflict-CPr9OWa3.js → run-conflict-BlgKVpOG.js} +1 -1
  81. package/dist/web/assets/{runs-table-DpBJ4ZeQ.js → runs-table-DMPF5_D6.js} +1 -1
  82. package/dist/web/assets/{search-BFTvT67N.js → search-gwjIEGis.js} +1 -1
  83. package/dist/web/assets/{search-Da3B5-lr.js → search-hK5b8Xwb.js} +1 -1
  84. package/dist/web/assets/{select-B4LGxZQI.js → select-B1ES0hhy.js} +1 -1
  85. package/dist/web/assets/{session-_62x2rSZ.js → session-CPUTlq1O.js} +1 -1
  86. package/dist/web/assets/{settings-CUYuBL-5.js → settings-DRd0b0Kz.js} +1 -1
  87. package/dist/web/assets/{settings-ui-Ux8rPFol.js → settings-ui-Bc6ymtc_.js} +1 -1
  88. package/dist/web/assets/{setup-BKOOV6vX.js → setup-Bn2CFYAt.js} +1 -1
  89. package/dist/web/assets/{shallow-CbfSRfYC.js → shallow-BUNpybIA.js} +1 -1
  90. package/dist/web/assets/{spec-approval-9S-jPMrI.js → spec-approval-CmC6QBSh.js} +1 -1
  91. package/dist/web/assets/{spot-check-actions-5CmYjt8A.js → spot-check-actions-DzMUED1O.js} +1 -1
  92. package/dist/web/assets/{spot-checks-BadmkHuG.js → spot-checks-CDZxwwu0.js} +1 -1
  93. package/dist/web/assets/{storeys-OlWmOmqA.js → storeys-BEgFUsix.js} +1 -1
  94. package/dist/web/assets/{switch-DuBpF2_h.js → switch-BHplnCdo.js} +1 -1
  95. package/dist/web/assets/{terminal-view-ChO1pNp0.js → terminal-view-WNT8FI6K.js} +1 -1
  96. package/dist/web/assets/{theme-DsW-i9mD.js → theme-3eeE0sp4.js} +1 -1
  97. package/dist/web/assets/{thread-view-CPlJsMhl.js → thread-view-AQKzJlKb.js} +1 -1
  98. package/dist/web/assets/{update-banner-CNYd8gAf.js → update-banner-CZGRgiG8.js} +1 -1
  99. package/dist/web/assets/{updates-CQZDqpFF.js → updates-4l7pwDq1.js} +1 -1
  100. package/dist/web/assets/{use-retry-item-CWwb3JGo.js → use-retry-item-3n4BD_3J.js} +1 -1
  101. package/dist/web/assets/{vision-7gkgZ-Ap.js → vision-Z1sLHr_c.js} +1 -1
  102. package/dist/web/assets/{wip-chip-D5-cZcfN.js → wip-chip-DXwuAo3A.js} +1 -1
  103. package/dist/web/index.html +34 -34
  104. package/package.json +1 -1
  105. package/dist/args-B0i5tyjE.js.map +0 -1
  106. package/dist/commands-CvAvyECH.js.map +0 -1
  107. package/dist/harden-channel-2IT0Y7p3.js.map +0 -1
  108. package/dist/launcher-D17oQovS.js.map +0 -1
@@ -1 +1 @@
1
- import{G as e}from"./api-B620HpC2.js";var t=`/assets/pcm-capture.worklet--b-0A3gc.js`;function n(){return typeof window>`u`?null:window.AudioContext??window.webkitAudioContext??null}function r(){return typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia&&n()!==null}async function i(e,n,r){if(e.audioWorklet&&typeof AudioWorkletNode<`u`)try{await e.audioWorklet.addModule(t);let i=new AudioWorkletNode(e,`codeden-pcm-capture`);return i.port.onmessage=e=>r(e.data),n.connect(i),i.connect(e.destination),i}catch{}let i=e.createScriptProcessor(2048,1,1);return i.onaudioprocess=e=>r(e.inputBuffer.getChannelData(0).slice()),n.connect(i),i.connect(e.destination),i}var a=async e=>{let t=n();if(!t||!navigator.mediaDevices?.getUserMedia)throw Error(`This browser can't capture the microphone for dictation.`);let r=new t,a;try{a=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})}catch{throw r.close().catch(()=>{}),Error(`Microphone access was blocked.`)}let o=()=>{for(let e of a.getTracks())e.stop();r.close().catch(()=>{})};try{r.state===`suspended`&&r.resume().catch(()=>{});let t=r.createMediaStreamSource(a),n=await i(r,t,t=>e(t,r.sampleRate)),s=!1;return{stop(){s||(s=!0,t.disconnect(),n.disconnect(),o())}}}catch(e){throw o(),e instanceof Error?e:Error(String(e))}},o=`\\p{scx=Han}\\p{scx=Hiragana}\\p{scx=Katakana}\\p{scx=Thai}\\p{scx=Lao}\\p{scx=Khmer}\\p{scx=Myanmar}\\u3000-\\u303f\\uff01-\\uff60`,s=RegExp(`[${o}]$`,`u`),c=RegExp(`^[${o}]`,`u`);function l(e,t){return s.test(e)&&c.test(t)?``:` `}function u(e){let t=``;for(let n of e){let e=n.trim();e&&(t=t?t+l(t,e)+e:e)}return t}var d=e=>e instanceof Error?e.message:String(e);function f(e){let t=[],n=[],r=0,i=!1,a={final:``,draft:``},o=()=>{let n=0;for(;n<t.length&&t[n]!==void 0;)n++;let r=(e,n)=>t.slice(e,n).filter(e=>typeof e==`string`),i={final:u(r(0,n)),draft:u(r(n,t.length))};(i.final!==a.final||i.draft!==a.draft)&&(a=i,e.onText(i))};return{get text(){return u(t.filter(e=>typeof e==`string`))},get failed(){return i},add(a){if(i)return;let s=t.length;t.push(void 0),r++,e.onPending?.(r);let c=Promise.resolve().then(()=>e.transcribe(a)).then(e=>{t[s]=e},n=>{t[s]=null,i||(i=!0,e.onError(d(n)))}).finally(()=>{r--,e.onPending?.(r),o()});n.push(c)},async drain(){let e=-1;for(;e!==n.length;)e=n.length,await Promise.all(n)}}}var p={frameMs:20,pauseMs:600,minSpeechMs:250,leadInMs:200,tailMs:300,maxSegmentMs:25e3,minThreshold:.01},m=2.5,h=1e4,g=2e3,_=200,v=.1,y=.02,b=2e3,x=1e-4,S=2e3;function C(e){if(e.length===0)return 0;let t=0;for(let n of e)t+=n*n;return Math.sqrt(t/e.length)}function w(e){let t=new Float32Array(e.reduce((e,t)=>e+t.samples.length,0)),n=0;for(let r of e)t.set(r.samples,n),n+=r.samples.length;return t}function T(e){let t=0;for(;t<e.length&&!e[e.length-1-t]?.speech;)t++;return t}function E(e){let t={...p,...e},n=Math.max(1,Math.round(t.sampleRate*t.frameMs/1e3)),r=e=>Math.max(1,Math.round(e/t.frameMs)),i=r(t.pauseMs),a=r(t.minSpeechMs),o=r(t.leadInMs),s=r(t.tailMs),c=Math.max(r(t.maxSegmentMs),i+1),l=Math.min(r(g),c-1),u=Math.min(1,t.frameMs/h),d=r(_),f=r(b),E=new Float32Array(n),D=0,O=0,k=0,A=[],j=[],M=r(S),N=[],P=[],F=()=>{let e=T(P),t=P.length-e+Math.min(e,s),n=P.slice(0,t),r=n.filter(e=>e.speech).length;return N=P.slice(t).slice(-o),P=[],r>=a?w(n):null},I=()=>{let e=P.length-1;for(let t=P.length-1;t>=P.length-l;t--)(P[t]?.rms??1/0)<(P[e]?.rms??1/0)&&(e=t);let t=P.slice(0,e+1);return P=P.slice(e+1),t.filter(e=>e.speech).length>=a?w(t):null},L=()=>Math.max(t.minThreshold,O*m),R=(e,t,n)=>{let r=t>L();n&&(O=t<O?O+(t-O)*.5:O+(t-O)*u);let a={samples:e,speech:r,rms:t};if(j?.push(a),P.length===0){if(!r)return N.push(a),N.length>o&&N.shift(),null;P=N,N=[]}P.push(a);let s=T(P)>=i?F():P.length>=c?I():null;return s&&(j=null),s},z=e=>{if(!j)return;if(--M<0){j=null;return}let t=L();if(!j.some(e=>!e.speech&&e.rms>t))return;let n=j;j=[],N=[],P=[];for(let t of n){let n=R(t.samples,t.rms,!1);n&&e.push(n)}},B=()=>(A??[]).map(e=>e.rms).sort((e,t)=>e-t),V=(e,t)=>e[Math.floor(e.length*t)]??0,H=()=>{let e=B();if(e.length<d)return!1;let t=V(e,.5);return t<=y||V(e,v)*m<=t||e.length>=f},U=e=>{O=V(B(),v);let t=A??[];A=null;for(let n of t){let t=R(n.samples,n.rms,!1);t&&e.push(t)}},W=(e,t)=>{let n=C(e);if(k=Math.min(1,n),A&&(A.length>0||n>x)){A.push({samples:e,rms:n}),M--,H()&&U(t);return}let r=R(e,n,!0);r&&t.push(r),A||z(t)};return{get level(){return k},push(e){let t=[],r=0;for(;r<e.length;){let i=Math.min(n-D,e.length-r);E.set(e.subarray(r,r+i),D),D+=i,r+=i,D===n&&(W(E,t),E=new Float32Array(n),D=0)}return t},flush(){let e=[];if(A&&U(e),D>0&&P.length>0&&W(E.slice(0,D),e),E=new Float32Array(n),D=0,P.length>0){let t=F();t&&e.push(t)}return N=[],j=null,e}}}function D(e){let[t]=e;if(!t)return new Float32Array;if(e.length===1)return t.slice();let n=new Float32Array(t.length);for(let t of e)for(let e=0;e<n.length;e++)n[e]=(n[e]??0)+(t[e]??0);for(let t=0;t<n.length;t++)n[t]=(n[t]??0)/e.length;return n}function O(e,t,n){if(t===n)return e.slice();let r=t/n,i=Math.floor(e.length/r),a=new Float32Array(i);if(r>1)for(let t=0;t<i;t++){let n=Math.floor(t*r),i=Math.min(e.length,Math.max(n+1,Math.floor((t+1)*r))),o=0;for(let t=n;t<i;t++)o+=e[t]??0;a[t]=o/(i-n)}else for(let t=0;t<i;t++){let n=t*r,i=Math.floor(n),o=Math.min(e.length-1,i+1),s=n-i;a[t]=(e[i]??0)*(1-s)+(e[o]??0)*s}return a}function k(e,t){let n=new ArrayBuffer(44+e.length*2),r=new DataView(n),i=(e,t)=>{for(let n=0;n<t.length;n++)r.setUint8(e+n,t.charCodeAt(n))};i(0,`RIFF`),r.setUint32(4,36+e.length*2,!0),i(8,`WAVE`),i(12,`fmt `),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),i(36,`data`),r.setUint32(40,e.length*2,!0);for(let t=0;t<e.length;t++){let n=Math.max(-1,Math.min(1,e[t]??0));r.setInt16(44+t*2,n<0?n*32768:n*32767,!0)}return n}function A(t,n){let r=O(t,n,e).subarray(0,120*e);return new Blob([k(r,e)],{type:`audio/wav`})}function j(e){return A(D(Array.from({length:e.numberOfChannels},(t,n)=>e.getChannelData(n))),e.sampleRate)}async function M(e){let t=window.AudioContext??window.webkitAudioContext;if(!t)throw Error(`This browser can't decode audio for local Whisper.`);let n=new t;try{return j(await n.decodeAudioData(await e.arrayBuffer()))}finally{n.close()}}var N=e=>e instanceof Error?e.message:String(e);function P(e){let t=null;return{supported:e.supported,live:`segments`,finishesAfterStop:!0,start(n){t?.stop();let r=!0,i=!1,a=null,o=0,s=null,c=()=>{i||(i=!0,n.onEnd())},l=f({transcribe:t=>e.transcribe(t,n.language),onText:n.onText,onPending:n.onPending,onError:e=>{n.onError(e),d(!1)}}),u=e=>l.add(A(e,o)),d=e=>{if(r){if(r=!1,s?.stop(),s=null,e&&a)for(let e of a.flush())u(e);l.drain().then(()=>{n.onText({final:l.text,draft:``}),c()})}};e.capture((t,i)=>{if(r){a||=(o=i,E({...e.segmenter,sampleRate:i}));for(let e of a.push(t))u(e);n.onLevel?.(a.level)}}).then(e=>{r?s=e:e.stop()},e=>{r&&(r=!1,n.onError(N(e)),c())}),t={stop:()=>d(!0)}},stop(){t?.stop(),t=null}}}function F(e){let t=e?.split(`-`)[0]?.toLowerCase();return t&&t.length>=2?t:void 0}async function I(e,t,n,r){let i=n===`local`?await M(t):t;return e.voice.stt(i,{engine:n,language:F(r)})}function L(e,t){return P({supported:r(),capture:a,transcribe:async(n,r)=>(await e.voice.stt(n,{engine:t,language:F(r)})).text})}function R(){if(typeof window>`u`)return null;let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}var z=`codeden.voice.browserSttUnavailable`,B=new Set([`network`,`service-not-allowed`]);function V(){if(!R())return`unsupported`;try{if(window.localStorage.getItem(z)===`1`)return`failed`}catch{}return`available`}function H(){try{window.localStorage.removeItem(z)}catch{}}function U(){try{window.localStorage.setItem(z,`1`)}catch{}}var W=`Browser speech recognition isn't available here. Choose Local (Whisper) in Settings > Voice.`;function G(){let e=R(),t=null;return{get supported(){return V()===`available`},live:`interim`,finishesAfterStop:!1,start({language:n,onText:r,onEnd:i,onError:a}){if(!e){a(W);return}t=new e,t.lang=n??navigator.language,t.continuous=!0,t.interimResults=!0;let o=``,s=``;t.onresult=e=>{s=``;for(let t=e.resultIndex;t<e.results.length;t++){let n=e.results[t];n&&(n.isFinal?o+=n[0].transcript:s+=n[0].transcript)}r({final:o.trim(),draft:s.trim()})},t.onerror=e=>{B.has(e.error)?(U(),a(W)):a(e.error===`not-allowed`?`Microphone access was blocked.`:e.error)},t.onend=()=>{t=null,s.trim()&&r({final:(o+s).trim(),draft:``}),s=``,i()},t.start()},stop(){t?.stop()}}}function K(){let e=typeof window<`u`?window.speechSynthesis:void 0;return{supported:!!e,speak(t,n){if(!e||!t){n?.onEnd?.();return}e.cancel();let r=new SpeechSynthesisUtterance(t),i=!1;r.onend=r.onerror=()=>{i||(i=!0,n?.onEnd?.())};let a=e.getVoices().find(e=>e.voiceURI===n?.voice);a&&(r.voice=a),r.rate=n?.rate??1.05,e.speak(r)},cancel(){e?.cancel()},voices(){return(e?.getVoices()??[]).map(e=>({id:e.voiceURI,label:e.name,lang:e.lang}))}}}var q=G(),J=K();export{L as a,J as i,H as n,I as o,q as r,l as s,V as t};
1
+ import{G as e}from"./api-yvn34iKU.js";var t=`/assets/pcm-capture.worklet--b-0A3gc.js`;function n(){return typeof window>`u`?null:window.AudioContext??window.webkitAudioContext??null}function r(){return typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia&&n()!==null}async function i(e,n,r){if(e.audioWorklet&&typeof AudioWorkletNode<`u`)try{await e.audioWorklet.addModule(t);let i=new AudioWorkletNode(e,`codeden-pcm-capture`);return i.port.onmessage=e=>r(e.data),n.connect(i),i.connect(e.destination),i}catch{}let i=e.createScriptProcessor(2048,1,1);return i.onaudioprocess=e=>r(e.inputBuffer.getChannelData(0).slice()),n.connect(i),i.connect(e.destination),i}var a=async e=>{let t=n();if(!t||!navigator.mediaDevices?.getUserMedia)throw Error(`This browser can't capture the microphone for dictation.`);let r=new t,a;try{a=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})}catch{throw r.close().catch(()=>{}),Error(`Microphone access was blocked.`)}let o=()=>{for(let e of a.getTracks())e.stop();r.close().catch(()=>{})};try{r.state===`suspended`&&r.resume().catch(()=>{});let t=r.createMediaStreamSource(a),n=await i(r,t,t=>e(t,r.sampleRate)),s=!1;return{stop(){s||(s=!0,t.disconnect(),n.disconnect(),o())}}}catch(e){throw o(),e instanceof Error?e:Error(String(e))}},o=`\\p{scx=Han}\\p{scx=Hiragana}\\p{scx=Katakana}\\p{scx=Thai}\\p{scx=Lao}\\p{scx=Khmer}\\p{scx=Myanmar}\\u3000-\\u303f\\uff01-\\uff60`,s=RegExp(`[${o}]$`,`u`),c=RegExp(`^[${o}]`,`u`);function l(e,t){return s.test(e)&&c.test(t)?``:` `}function u(e){let t=``;for(let n of e){let e=n.trim();e&&(t=t?t+l(t,e)+e:e)}return t}var d=e=>e instanceof Error?e.message:String(e);function f(e){let t=[],n=[],r=0,i=!1,a={final:``,draft:``},o=()=>{let n=0;for(;n<t.length&&t[n]!==void 0;)n++;let r=(e,n)=>t.slice(e,n).filter(e=>typeof e==`string`),i={final:u(r(0,n)),draft:u(r(n,t.length))};(i.final!==a.final||i.draft!==a.draft)&&(a=i,e.onText(i))};return{get text(){return u(t.filter(e=>typeof e==`string`))},get failed(){return i},add(a){if(i)return;let s=t.length;t.push(void 0),r++,e.onPending?.(r);let c=Promise.resolve().then(()=>e.transcribe(a)).then(e=>{t[s]=e},n=>{t[s]=null,i||(i=!0,e.onError(d(n)))}).finally(()=>{r--,e.onPending?.(r),o()});n.push(c)},async drain(){let e=-1;for(;e!==n.length;)e=n.length,await Promise.all(n)}}}var p={frameMs:20,pauseMs:600,minSpeechMs:250,leadInMs:200,tailMs:300,maxSegmentMs:25e3,minThreshold:.01},m=2.5,h=1e4,g=2e3,_=200,v=.1,y=.02,b=2e3,x=1e-4,S=2e3;function C(e){if(e.length===0)return 0;let t=0;for(let n of e)t+=n*n;return Math.sqrt(t/e.length)}function w(e){let t=new Float32Array(e.reduce((e,t)=>e+t.samples.length,0)),n=0;for(let r of e)t.set(r.samples,n),n+=r.samples.length;return t}function T(e){let t=0;for(;t<e.length&&!e[e.length-1-t]?.speech;)t++;return t}function E(e){let t={...p,...e},n=Math.max(1,Math.round(t.sampleRate*t.frameMs/1e3)),r=e=>Math.max(1,Math.round(e/t.frameMs)),i=r(t.pauseMs),a=r(t.minSpeechMs),o=r(t.leadInMs),s=r(t.tailMs),c=Math.max(r(t.maxSegmentMs),i+1),l=Math.min(r(g),c-1),u=Math.min(1,t.frameMs/h),d=r(_),f=r(b),E=new Float32Array(n),D=0,O=0,k=0,A=[],j=[],M=r(S),N=[],P=[],F=()=>{let e=T(P),t=P.length-e+Math.min(e,s),n=P.slice(0,t),r=n.filter(e=>e.speech).length;return N=P.slice(t).slice(-o),P=[],r>=a?w(n):null},I=()=>{let e=P.length-1;for(let t=P.length-1;t>=P.length-l;t--)(P[t]?.rms??1/0)<(P[e]?.rms??1/0)&&(e=t);let t=P.slice(0,e+1);return P=P.slice(e+1),t.filter(e=>e.speech).length>=a?w(t):null},L=()=>Math.max(t.minThreshold,O*m),R=(e,t,n)=>{let r=t>L();n&&(O=t<O?O+(t-O)*.5:O+(t-O)*u);let a={samples:e,speech:r,rms:t};if(j?.push(a),P.length===0){if(!r)return N.push(a),N.length>o&&N.shift(),null;P=N,N=[]}P.push(a);let s=T(P)>=i?F():P.length>=c?I():null;return s&&(j=null),s},z=e=>{if(!j)return;if(--M<0){j=null;return}let t=L();if(!j.some(e=>!e.speech&&e.rms>t))return;let n=j;j=[],N=[],P=[];for(let t of n){let n=R(t.samples,t.rms,!1);n&&e.push(n)}},B=()=>(A??[]).map(e=>e.rms).sort((e,t)=>e-t),V=(e,t)=>e[Math.floor(e.length*t)]??0,H=()=>{let e=B();if(e.length<d)return!1;let t=V(e,.5);return t<=y||V(e,v)*m<=t||e.length>=f},U=e=>{O=V(B(),v);let t=A??[];A=null;for(let n of t){let t=R(n.samples,n.rms,!1);t&&e.push(t)}},W=(e,t)=>{let n=C(e);if(k=Math.min(1,n),A&&(A.length>0||n>x)){A.push({samples:e,rms:n}),M--,H()&&U(t);return}let r=R(e,n,!0);r&&t.push(r),A||z(t)};return{get level(){return k},push(e){let t=[],r=0;for(;r<e.length;){let i=Math.min(n-D,e.length-r);E.set(e.subarray(r,r+i),D),D+=i,r+=i,D===n&&(W(E,t),E=new Float32Array(n),D=0)}return t},flush(){let e=[];if(A&&U(e),D>0&&P.length>0&&W(E.slice(0,D),e),E=new Float32Array(n),D=0,P.length>0){let t=F();t&&e.push(t)}return N=[],j=null,e}}}function D(e){let[t]=e;if(!t)return new Float32Array;if(e.length===1)return t.slice();let n=new Float32Array(t.length);for(let t of e)for(let e=0;e<n.length;e++)n[e]=(n[e]??0)+(t[e]??0);for(let t=0;t<n.length;t++)n[t]=(n[t]??0)/e.length;return n}function O(e,t,n){if(t===n)return e.slice();let r=t/n,i=Math.floor(e.length/r),a=new Float32Array(i);if(r>1)for(let t=0;t<i;t++){let n=Math.floor(t*r),i=Math.min(e.length,Math.max(n+1,Math.floor((t+1)*r))),o=0;for(let t=n;t<i;t++)o+=e[t]??0;a[t]=o/(i-n)}else for(let t=0;t<i;t++){let n=t*r,i=Math.floor(n),o=Math.min(e.length-1,i+1),s=n-i;a[t]=(e[i]??0)*(1-s)+(e[o]??0)*s}return a}function k(e,t){let n=new ArrayBuffer(44+e.length*2),r=new DataView(n),i=(e,t)=>{for(let n=0;n<t.length;n++)r.setUint8(e+n,t.charCodeAt(n))};i(0,`RIFF`),r.setUint32(4,36+e.length*2,!0),i(8,`WAVE`),i(12,`fmt `),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),i(36,`data`),r.setUint32(40,e.length*2,!0);for(let t=0;t<e.length;t++){let n=Math.max(-1,Math.min(1,e[t]??0));r.setInt16(44+t*2,n<0?n*32768:n*32767,!0)}return n}function A(t,n){let r=O(t,n,e).subarray(0,120*e);return new Blob([k(r,e)],{type:`audio/wav`})}function j(e){return A(D(Array.from({length:e.numberOfChannels},(t,n)=>e.getChannelData(n))),e.sampleRate)}async function M(e){let t=window.AudioContext??window.webkitAudioContext;if(!t)throw Error(`This browser can't decode audio for local Whisper.`);let n=new t;try{return j(await n.decodeAudioData(await e.arrayBuffer()))}finally{n.close()}}var N=e=>e instanceof Error?e.message:String(e);function P(e){let t=null;return{supported:e.supported,live:`segments`,finishesAfterStop:!0,start(n){t?.stop();let r=!0,i=!1,a=null,o=0,s=null,c=()=>{i||(i=!0,n.onEnd())},l=f({transcribe:t=>e.transcribe(t,n.language),onText:n.onText,onPending:n.onPending,onError:e=>{n.onError(e),d(!1)}}),u=e=>l.add(A(e,o)),d=e=>{if(r){if(r=!1,s?.stop(),s=null,e&&a)for(let e of a.flush())u(e);l.drain().then(()=>{n.onText({final:l.text,draft:``}),c()})}};e.capture((t,i)=>{if(r){a||=(o=i,E({...e.segmenter,sampleRate:i}));for(let e of a.push(t))u(e);n.onLevel?.(a.level)}}).then(e=>{r?s=e:e.stop()},e=>{r&&(r=!1,n.onError(N(e)),c())}),t={stop:()=>d(!0)}},stop(){t?.stop(),t=null}}}function F(e){let t=e?.split(`-`)[0]?.toLowerCase();return t&&t.length>=2?t:void 0}async function I(e,t,n,r){let i=n===`local`?await M(t):t;return e.voice.stt(i,{engine:n,language:F(r)})}function L(e,t){return P({supported:r(),capture:a,transcribe:async(n,r)=>(await e.voice.stt(n,{engine:t,language:F(r)})).text})}function R(){if(typeof window>`u`)return null;let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}var z=`codeden.voice.browserSttUnavailable`,B=new Set([`network`,`service-not-allowed`]);function V(){if(!R())return`unsupported`;try{if(window.localStorage.getItem(z)===`1`)return`failed`}catch{}return`available`}function H(){try{window.localStorage.removeItem(z)}catch{}}function U(){try{window.localStorage.setItem(z,`1`)}catch{}}var W=`Browser speech recognition isn't available here. Choose Local (Whisper) in Settings > Voice.`;function G(){let e=R(),t=null;return{get supported(){return V()===`available`},live:`interim`,finishesAfterStop:!1,start({language:n,onText:r,onEnd:i,onError:a}){if(!e){a(W);return}t=new e,t.lang=n??navigator.language,t.continuous=!0,t.interimResults=!0;let o=``,s=``;t.onresult=e=>{s=``;for(let t=e.resultIndex;t<e.results.length;t++){let n=e.results[t];n&&(n.isFinal?o+=n[0].transcript:s+=n[0].transcript)}r({final:o.trim(),draft:s.trim()})},t.onerror=e=>{B.has(e.error)?(U(),a(W)):a(e.error===`not-allowed`?`Microphone access was blocked.`:e.error)},t.onend=()=>{t=null,s.trim()&&r({final:(o+s).trim(),draft:``}),s=``,i()},t.start()},stop(){t?.stop()}}}function K(){let e=typeof window<`u`?window.speechSynthesis:void 0;return{supported:!!e,speak(t,n){if(!e||!t){n?.onEnd?.();return}e.cancel();let r=new SpeechSynthesisUtterance(t),i=!1;r.onend=r.onerror=()=>{i||(i=!0,n?.onEnd?.())};let a=e.getVoices().find(e=>e.voiceURI===n?.voice);a&&(r.voice=a),r.rate=n?.rate??1.05,e.speak(r)},cancel(){e?.cancel()},voices(){return(e?.getVoices()??[]).map(e=>({id:e.voiceURI,label:e.name,lang:e.lang}))}}}var q=G(),J=K();export{L as a,J as i,H as n,I as o,q as r,l as s,V as t};
@@ -1 +1 @@
1
- import{t as e}from"./useQuery-VSotSwry.js";import{i as t,v as n}from"./api-B620HpC2.js";var r={all:[`factory`],status:e=>[`factory`,`status`,e],item:(e,t)=>[`factory`,`item`,e,t],vision:e=>[`factory`,`vision`,e],scorecard:(e,t)=>[`factory`,`scorecard`,e,t]},i=new Set([`factory.loop.updated`,`factory.item.updated`,`factory.digest.created`,`factory.lesson.updated`,`project.updated`,`settings.updated`]);function a(e,t){i.has(t.type)&&(e.invalidateQueries({queryKey:[`factory`,`status`]}),e.invalidateQueries({queryKey:[`factory`,`item`]}),c(e))}var o=15e3,s=new WeakMap;function c(e){if(e.invalidateQueries({queryKey:[`factory`,`scorecard`],refetchType:`none`}),s.has(e))return;let t=setTimeout(()=>{s.delete(e),e.invalidateQueries({queryKey:[`factory`,`scorecard`]})},o);s.set(e,t)}var l=3e4,u=3e5;function d(e){return!e||e.activeSessions>0||e.inProgress.length>0||e.loopState===`discovering`?l:u}function f(n,i=!0){let a=t();return e({queryKey:r.status(n),queryFn:()=>a.factory.status(n),enabled:i,refetchInterval:e=>d(e.state.data)})}var p=new Set([`backlog`,`building`,`verifying`]);function m(n,i){let a=t();return e({queryKey:r.item(n,i),queryFn:()=>a.factory.item(n,i),refetchInterval:e=>{let t=e.state.data?.item.stage;return t&&p.has(t)?l:!1}})}function h(n,i,a=!0){let o=t();return e({queryKey:r.scorecard(n,i),queryFn:()=>o.factory.scorecard(n,i),enabled:a})}function g(n){let i=t();return e({queryKey:r.vision(n),queryFn:()=>i.factory.vision(n)})}var _={not_a_github_project:`The software and dark factory need a GitHub project.`,vision_required:`Write and save the vision file first.`,limits_required:`Set the factory limits first.`,budget_required:`Set a daily budget (dollars or tokens).`};function v(e){return e instanceof n?_[e.code]??e.message:e.message}export{h as a,m as i,a as n,f as o,v as r,g as s,r as t};
1
+ import{t as e}from"./useQuery-VSotSwry.js";import{i as t,v as n}from"./api-yvn34iKU.js";var r={all:[`factory`],status:e=>[`factory`,`status`,e],item:(e,t)=>[`factory`,`item`,e,t],vision:e=>[`factory`,`vision`,e],scorecard:(e,t)=>[`factory`,`scorecard`,e,t]},i=new Set([`factory.loop.updated`,`factory.item.updated`,`factory.digest.created`,`factory.lesson.updated`,`project.updated`,`settings.updated`]);function a(e,t){i.has(t.type)&&(e.invalidateQueries({queryKey:[`factory`,`status`]}),e.invalidateQueries({queryKey:[`factory`,`item`]}),c(e))}var o=15e3,s=new WeakMap;function c(e){if(e.invalidateQueries({queryKey:[`factory`,`scorecard`],refetchType:`none`}),s.has(e))return;let t=setTimeout(()=>{s.delete(e),e.invalidateQueries({queryKey:[`factory`,`scorecard`]})},o);s.set(e,t)}var l=3e4,u=3e5;function d(e){return!e||e.activeSessions>0||e.inProgress.length>0||e.loopState===`discovering`?l:u}function f(n,i=!0){let a=t();return e({queryKey:r.status(n),queryFn:()=>a.factory.status(n),enabled:i,refetchInterval:e=>d(e.state.data)})}var p=new Set([`backlog`,`building`,`verifying`]);function m(n,i){let a=t();return e({queryKey:r.item(n,i),queryFn:()=>a.factory.item(n,i),refetchInterval:e=>{let t=e.state.data?.item.stage;return t&&p.has(t)?l:!1}})}function h(n,i,a=!0){let o=t();return e({queryKey:r.scorecard(n,i),queryFn:()=>o.factory.scorecard(n,i),enabled:a})}function g(n){let i=t();return e({queryKey:r.vision(n),queryFn:()=>i.factory.vision(n)})}var _={not_a_github_project:`The software and dark factory need a GitHub project.`,vision_required:`Write and save the vision file first.`,limits_required:`Set the factory limits first.`,budget_required:`Set a daily budget (dollars or tokens).`};function v(e){return e instanceof n?_[e.code]??e.message:e.message}export{h as a,m as i,a as n,f as o,v as r,g as s,r as t};
@@ -1 +1 @@
1
- import{M as e,i as t}from"./api-B620HpC2.js";import{t as n}from"./jsx-runtime-C3cWAN_r.js";import{F as r}from"./useQuery-VSotSwry.js";import{j as i,m as a,n as o,yt as s}from"./format-D1ma_o2D.js";import{L as c}from"./dropdown-menu-C4XI7F63.js";import{o as l}from"./switch-DuBpF2_h.js";import{t as u}from"./dist-wxbqfqV1.js";import{t as d}from"./factory-BBYEYI9i.js";import{Xn as f,an as p,ar as m,bt as h,d as g,kn as _,m as v,n as y,p as b,pr as x,q as S,un as C}from"./icons-COCLuOtb.js";import{o as w}from"./bits-B2GRjm37.js";import{_ as T,i as E,r as D,t as O}from"./use-retry-item-CWwb3JGo.js";var k=n(),A={duplicate:`duplicate`,expired:`expired`,capped:`dropped`,dismissed:`dismissed`},j={high:`border-status-failed/40 text-status-failed`,medium:`border-status-waiting/40 text-status-waiting`,low:`border-border text-muted-foreground`};function M({f:e}){return!e.severity&&!e.area?null:(0,k.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[e.severity&&(0,k.jsx)(`span`,{className:u(`rounded-full border px-1.5 text-3xs`,j[e.severity]),children:e.severity}),e.area&&(0,k.jsx)(`span`,{className:`rounded-full border border-border px-1.5 font-mono text-3xs text-muted-foreground`,children:e.area})]})}function N({item:e,projectId:n,mode:o}){let c=t(),u=r(),f=s({mutationFn:t=>c.factory.fileFollowUp(n,e.id,t),onSuccess:(e,t)=>{let n=e.followUps[t]?.issue;i.success(n?`Filed as #${n.number}`:`Filed`),u.invalidateQueries({queryKey:d.all})},onError:e=>i.error(`Couldn't file the issue`,{description:e.message})}),p=e.followUps.length>0,h=p?e.followUps:e.review?.followUps??[];return h.length===0?null:(0,k.jsxs)(`section`,{"data-testid":`follow-ups`,children:[(0,k.jsx)(w,{className:`mb-2`,children:`Follow-ups · not blocking`}),(0,k.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card`,children:h.map((e,t)=>{let n=e.issue??null;return(0,k.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border px-3.5 py-2.5 text-[13px] last:border-0`,children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.title}),(0,k.jsx)(M,{f:e}),p&&!n&&(e.dropped||e.heldAt)&&(0,k.jsx)(`span`,{className:`shrink-0 text-3xs text-muted-foreground`,title:e.dropped?`Left the scout's held list without an issue`:`Held for the scout's next round`,children:e.dropped?A[e.dropped.reason]:`held for the scout`}),p&&(n?(0,k.jsxs)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1 text-2xs text-primary hover:underline`,onClick:()=>l.openExternal(n.url),children:[(0,k.jsx)(m,{className:`size-3`}),`#`,n.number]}):(0,k.jsxs)(a,{size:`xs`,variant:`outline`,disabled:f.isPending,onClick:()=>f.mutate(t),children:[(0,k.jsx)(_,{}),` File issue`]}))]},e.title)})}),(0,k.jsx)(`p`,{className:`mt-1.5 text-3xs text-muted-foreground`,children:p?o===`dark_factory`?`Held ones wait for the scout, which weighs them against its other findings; the rest are filed as issues.`:`File the ones worth doing as issues; the factory picks them up from there.`:o===`dark_factory`?`They don't hold up the merge; once it merges, high-severity and security ones are filed as issues and the rest wait for the scout's rounds.`:`They don't hold up the merge; once it merges you can file them as issues here.`})]})}function P({projectId:t,item:n,mode:r,size:i=`xs`,variant:o=`ghost`,className:s}){let c=O(t,n.id,r),l=e(n);if(!l)return null;let u=l.pr,d=(r??l.mode)===`rebuild`||!u?`Run it again from the first step${u?`, replacing #${u.number}`:``}`:`Send #${u.number} back to a fresh review of its latest commits (no new build)`;return(0,k.jsxs)(a,{size:i,variant:o,className:s,title:d,disabled:c.isPending,"data-testid":r===`rebuild`?`factory-rebuild`:`factory-retry`,onClick:e=>{e.preventDefault(),e.stopPropagation(),c.mutate()},children:[r===`rebuild`?(0,k.jsx)(p,{}):(0,k.jsx)(S,{}),r===`rebuild`?`Rebuild`:`Retry`]})}function F({title:e,count:t,children:n}){return(0,k.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-surface`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-1.5 text-2xs font-medium text-muted-foreground`,children:[e,` `,(0,k.jsx)(`span`,{className:`ml-auto tabular-nums`,children:t})]}),(0,k.jsx)(`div`,{className:`space-y-0.5 p-1.5`,children:t===0?(0,k.jsx)(`p`,{className:`px-2 py-3 text-center text-3xs text-muted-foreground/70`,children:`Nothing yet`}):n})]})}var I=`flex items-center gap-2 rounded-md px-2 py-1.5 text-[12.5px] transition-colors hover:bg-accent/60`;function L({projectId:e,item:t,children:n}){return(0,k.jsx)(c,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:e,itemId:t.id},className:I,"data-testid":`factory-item-link`,children:n})}function R({projectId:e,ignored:n}){let o=t(),l=r(),f=s({mutationFn:t=>o.factory.admit(e,{itemId:t}),onSuccess:e=>{i.success(`Let in`,{description:`${e.title} runs through its pipeline; you merge the result.`}),l.invalidateQueries({queryKey:d.all})},onError:e=>i.error(`Couldn't let it in`,{description:e.message})});return(0,k.jsx)(F,{title:`Ignored · untrusted authors`,count:n.length,children:n.map(t=>(0,k.jsxs)(`div`,{className:u(I,`pr-1`),"data-testid":`ignored-issue`,children:[(0,k.jsxs)(c,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:e,itemId:t.id},className:`flex min-w-0 flex-1 items-center gap-2`,children:[t.issue&&(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-3xs text-muted-foreground`,children:[`#`,t.issue.number]}),(0,k.jsx)(`span`,{className:`truncate text-muted-foreground`,title:t.title,children:t.title}),(0,k.jsxs)(`span`,{className:`ml-auto shrink-0 text-3xs text-muted-foreground/80`,children:[`@`,t.author??`unknown`]})]}),(0,k.jsxs)(a,{size:`xs`,variant:`ghost`,className:`shrink-0`,title:`Let the factory take this on. A person merges the result.`,disabled:f.isPending,onClick:()=>f.mutate(t.id),children:[(0,k.jsx)(g,{}),` Let in`]})]},t.id))})}var z={pass:{icon:x,cls:`border-status-done/30 bg-status-done/10 text-status-done`},fail:{icon:y,cls:`border-status-failed/30 bg-status-failed/10 text-status-failed`},pending:{icon:f,cls:`border-border text-muted-foreground`},skipped:{icon:h,cls:`border-border text-muted-foreground/60`}};function B({check:e}){let t=z[e.state];return(0,k.jsxs)(`span`,{title:e.detail??D[e.name],className:u(`inline-flex h-5 items-center gap-1 rounded-full border px-1.5 text-3xs`,t.cls,e.escalate&&`border-status-waiting/40 bg-status-waiting/10 text-status-waiting`),"data-check":e.name,"data-state":e.state,children:[e.escalate?(0,k.jsx)(v,{className:`size-2.5`}):(0,k.jsx)(t.icon,{className:`size-2.5`}),E[e.name]]})}function V({projectId:e,checks:t}){return(0,k.jsx)(F,{title:`Merge checks`,count:t.length,children:t.map(t=>(0,k.jsxs)(c,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:e,itemId:t.itemId},className:`block rounded-md px-2 py-1.5 hover:bg-accent/60`,children:[(0,k.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-[12.5px]`,children:[(0,k.jsxs)(`span`,{className:`font-mono text-3xs text-muted-foreground`,children:[`#`,t.prNumber]}),(0,k.jsx)(`span`,{className:`truncate`,children:t.title})]}),(0,k.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.checks.map(e=>(0,k.jsx)(B,{check:e},e.name))}),t.reviewerProvider&&(0,k.jsxs)(`p`,{className:`mt-1 text-3xs text-muted-foreground/80`,children:[`Reviewer: `,t.reviewerProvider,t.verdict&&` · ${t.verdict.replace(`_`,` `)}`,t.reviewerNote&&` · ${t.reviewerNote}`]})]},t.itemId))})}var H={merged:{icon:C,cls:`text-chart-4`},reverted:{icon:b,cls:`text-status-failed`},failed:{icon:y,cls:`text-status-failed`},rejected:{icon:y,cls:`text-muted-foreground`},escalated:{icon:v,cls:`text-status-waiting`}};function U({projectId:t,recent:n}){return(0,k.jsx)(F,{title:`Recent merges & reverts`,count:n.length,children:n.map(n=>{let r=H[n.stage]??H.merged,i=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(r.icon,{className:u(`size-3.5 shrink-0`,r.cls)}),(0,k.jsx)(`span`,{className:u(`truncate`,n.stage===`rejected`&&`text-muted-foreground`),title:[n.reason,n.note].filter(Boolean).join(` · `)||void 0,children:n.title}),(0,k.jsxs)(`span`,{className:u(`ml-auto shrink-0 text-3xs`,r.cls),children:[T[n.stage].label.toLowerCase(),` · `,o(n.updatedAt)]})]});return e(n)?(0,k.jsxs)(`div`,{className:u(I,`pr-1`),"data-testid":`factory-stopped-item`,children:[(0,k.jsx)(c,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:t,itemId:n.id},className:`flex min-w-0 flex-1 items-center gap-2`,"data-testid":`factory-item-link`,children:i}),(0,k.jsx)(P,{projectId:t,item:n})]},n.id):(0,k.jsx)(L,{projectId:t,item:n,children:i},n.id)})})}export{P as a,U as i,V as n,N as o,R as r,j as s,B as t};
1
+ import{A as e,i as t}from"./api-yvn34iKU.js";import{t as n}from"./jsx-runtime-C3cWAN_r.js";import{F as r}from"./useQuery-VSotSwry.js";import{j as i,m as a,n as o,yt as s}from"./format-D3kairnQ.js";import{L as c}from"./dropdown-menu-Bflkx6wY.js";import{o as l}from"./switch-BHplnCdo.js";import{t as u}from"./dist-wxbqfqV1.js";import{t as d}from"./factory-DVCs5zxg.js";import{Xn as f,an as p,ar as m,bt as h,d as g,kn as _,m as v,n as y,p as b,pr as x,q as S,un as C}from"./icons-COCLuOtb.js";import{o as w}from"./bits-B2GRjm37.js";import{_ as T,i as E,r as D,t as O}from"./use-retry-item-3n4BD_3J.js";var k=n(),A={duplicate:`duplicate`,expired:`expired`,capped:`dropped`,dismissed:`dismissed`},j={high:`border-status-failed/40 text-status-failed`,medium:`border-status-waiting/40 text-status-waiting`,low:`border-border text-muted-foreground`};function M({f:e}){return!e.severity&&!e.area?null:(0,k.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[e.severity&&(0,k.jsx)(`span`,{className:u(`rounded-full border px-1.5 text-3xs`,j[e.severity]),children:e.severity}),e.area&&(0,k.jsx)(`span`,{className:`rounded-full border border-border px-1.5 font-mono text-3xs text-muted-foreground`,children:e.area})]})}function N({item:e,projectId:n,mode:o}){let c=t(),u=r(),f=s({mutationFn:t=>c.factory.fileFollowUp(n,e.id,t),onSuccess:(e,t)=>{let n=e.followUps[t]?.issue;i.success(n?`Filed as #${n.number}`:`Filed`),u.invalidateQueries({queryKey:d.all})},onError:e=>i.error(`Couldn't file the issue`,{description:e.message})}),p=e.followUps.length>0,h=p?e.followUps:e.review?.followUps??[];return h.length===0?null:(0,k.jsxs)(`section`,{"data-testid":`follow-ups`,children:[(0,k.jsx)(w,{className:`mb-2`,children:`Follow-ups · not blocking`}),(0,k.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card`,children:h.map((e,t)=>{let n=e.issue??null;return(0,k.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border px-3.5 py-2.5 text-[13px] last:border-0`,children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.title}),(0,k.jsx)(M,{f:e}),p&&!n&&(e.dropped||e.heldAt)&&(0,k.jsx)(`span`,{className:`shrink-0 text-3xs text-muted-foreground`,title:e.dropped?`Left the scout's held list without an issue`:`Held for the scout's next round`,children:e.dropped?A[e.dropped.reason]:`held for the scout`}),p&&(n?(0,k.jsxs)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1 text-2xs text-primary hover:underline`,onClick:()=>l.openExternal(n.url),children:[(0,k.jsx)(m,{className:`size-3`}),`#`,n.number]}):(0,k.jsxs)(a,{size:`xs`,variant:`outline`,disabled:f.isPending,onClick:()=>f.mutate(t),children:[(0,k.jsx)(_,{}),` File issue`]}))]},e.title)})}),(0,k.jsx)(`p`,{className:`mt-1.5 text-3xs text-muted-foreground`,children:p?o===`dark_factory`?`Held ones wait for the scout, which weighs them against its other findings; the rest are filed as issues.`:`File the ones worth doing as issues; the factory picks them up from there.`:o===`dark_factory`?`They don't hold up the merge; once it merges, high-severity and security ones are filed as issues and the rest wait for the scout's rounds.`:`They don't hold up the merge; once it merges you can file them as issues here.`})]})}function P({projectId:t,item:n,mode:r,size:i=`xs`,variant:o=`ghost`,className:s}){let c=O(t,n.id,r),l=e(n);if(!l)return null;let u=l.pr,d=(r??l.mode)===`rebuild`||!u?`Run it again from the first step${u?`, replacing #${u.number}`:``}`:`Send #${u.number} back to a fresh review of its latest commits (no new build)`;return(0,k.jsxs)(a,{size:i,variant:o,className:s,title:d,disabled:c.isPending,"data-testid":r===`rebuild`?`factory-rebuild`:`factory-retry`,onClick:e=>{e.preventDefault(),e.stopPropagation(),c.mutate()},children:[r===`rebuild`?(0,k.jsx)(p,{}):(0,k.jsx)(S,{}),r===`rebuild`?`Rebuild`:`Retry`]})}function F({title:e,count:t,children:n}){return(0,k.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-surface`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-1.5 text-2xs font-medium text-muted-foreground`,children:[e,` `,(0,k.jsx)(`span`,{className:`ml-auto tabular-nums`,children:t})]}),(0,k.jsx)(`div`,{className:`space-y-0.5 p-1.5`,children:t===0?(0,k.jsx)(`p`,{className:`px-2 py-3 text-center text-3xs text-muted-foreground/70`,children:`Nothing yet`}):n})]})}var I=`flex items-center gap-2 rounded-md px-2 py-1.5 text-[12.5px] transition-colors hover:bg-accent/60`;function L({projectId:e,item:t,children:n}){return(0,k.jsx)(c,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:e,itemId:t.id},className:I,"data-testid":`factory-item-link`,children:n})}function R({projectId:e,ignored:n}){let o=t(),l=r(),f=s({mutationFn:t=>o.factory.admit(e,{itemId:t}),onSuccess:e=>{i.success(`Let in`,{description:`${e.title} runs through its pipeline; you merge the result.`}),l.invalidateQueries({queryKey:d.all})},onError:e=>i.error(`Couldn't let it in`,{description:e.message})});return(0,k.jsx)(F,{title:`Ignored · untrusted authors`,count:n.length,children:n.map(t=>(0,k.jsxs)(`div`,{className:u(I,`pr-1`),"data-testid":`ignored-issue`,children:[(0,k.jsxs)(c,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:e,itemId:t.id},className:`flex min-w-0 flex-1 items-center gap-2`,children:[t.issue&&(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-3xs text-muted-foreground`,children:[`#`,t.issue.number]}),(0,k.jsx)(`span`,{className:`truncate text-muted-foreground`,title:t.title,children:t.title}),(0,k.jsxs)(`span`,{className:`ml-auto shrink-0 text-3xs text-muted-foreground/80`,children:[`@`,t.author??`unknown`]})]}),(0,k.jsxs)(a,{size:`xs`,variant:`ghost`,className:`shrink-0`,title:`Let the factory take this on. A person merges the result.`,disabled:f.isPending,onClick:()=>f.mutate(t.id),children:[(0,k.jsx)(g,{}),` Let in`]})]},t.id))})}var z={pass:{icon:x,cls:`border-status-done/30 bg-status-done/10 text-status-done`},fail:{icon:y,cls:`border-status-failed/30 bg-status-failed/10 text-status-failed`},pending:{icon:f,cls:`border-border text-muted-foreground`},skipped:{icon:h,cls:`border-border text-muted-foreground/60`}};function B({check:e}){let t=z[e.state];return(0,k.jsxs)(`span`,{title:e.detail??D[e.name],className:u(`inline-flex h-5 items-center gap-1 rounded-full border px-1.5 text-3xs`,t.cls,e.escalate&&`border-status-waiting/40 bg-status-waiting/10 text-status-waiting`),"data-check":e.name,"data-state":e.state,children:[e.escalate?(0,k.jsx)(v,{className:`size-2.5`}):(0,k.jsx)(t.icon,{className:`size-2.5`}),E[e.name]]})}function V({projectId:e,checks:t}){return(0,k.jsx)(F,{title:`Merge checks`,count:t.length,children:t.map(t=>(0,k.jsxs)(c,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:e,itemId:t.itemId},className:`block rounded-md px-2 py-1.5 hover:bg-accent/60`,children:[(0,k.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-[12.5px]`,children:[(0,k.jsxs)(`span`,{className:`font-mono text-3xs text-muted-foreground`,children:[`#`,t.prNumber]}),(0,k.jsx)(`span`,{className:`truncate`,children:t.title})]}),(0,k.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.checks.map(e=>(0,k.jsx)(B,{check:e},e.name))}),t.reviewerProvider&&(0,k.jsxs)(`p`,{className:`mt-1 text-3xs text-muted-foreground/80`,children:[`Reviewer: `,t.reviewerProvider,t.verdict&&` · ${t.verdict.replace(`_`,` `)}`,t.reviewerNote&&` · ${t.reviewerNote}`]})]},t.itemId))})}var H={merged:{icon:C,cls:`text-chart-4`},reverted:{icon:b,cls:`text-status-failed`},failed:{icon:y,cls:`text-status-failed`},rejected:{icon:y,cls:`text-muted-foreground`},escalated:{icon:v,cls:`text-status-waiting`}};function U({projectId:t,recent:n}){return(0,k.jsx)(F,{title:`Recent merges & reverts`,count:n.length,children:n.map(n=>{let r=H[n.stage]??H.merged,i=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(r.icon,{className:u(`size-3.5 shrink-0`,r.cls)}),(0,k.jsx)(`span`,{className:u(`truncate`,n.stage===`rejected`&&`text-muted-foreground`),title:[n.reason,n.note].filter(Boolean).join(` · `)||void 0,children:n.title}),(0,k.jsxs)(`span`,{className:u(`ml-auto shrink-0 text-3xs`,r.cls),children:[T[n.stage].label.toLowerCase(),` · `,o(n.updatedAt)]})]});return e(n)?(0,k.jsxs)(`div`,{className:u(I,`pr-1`),"data-testid":`factory-stopped-item`,children:[(0,k.jsx)(c,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:t,itemId:n.id},className:`flex min-w-0 flex-1 items-center gap-2`,"data-testid":`factory-item-link`,children:i}),(0,k.jsx)(P,{projectId:t,item:n})]},n.id):(0,k.jsx)(L,{projectId:t,item:n,children:i},n.id)})})}export{P as a,U as i,V as n,N as o,R as r,j as s,B as t};
@@ -1 +1 @@
1
- import{rt as e}from"./api-B620HpC2.js";import{L as t}from"./dropdown-menu-C4XI7F63.js";import{P as n,Rn as r,Wt as i,ar as a,cn as o,dr as s,m as c,n as l,pr as u,zn as d}from"./icons-COCLuOtb.js";import{o as f}from"./bits-B2GRjm37.js";import{O as p}from"./mobile-nav-D8FZcJzG.js";import{o as m}from"./factory-columns-CtJOpFim.js";import{a as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./item-parts-BhDFWsT1.js";import{C as S,_ as C,g as w,i as T,v as E}from"./use-retry-item-CWwb3JGo.js";import{t as D}from"./spec-approval-9S-jPMrI.js";import{n as O,y as k}from"./format-D1ma_o2D.js";import{o as A}from"./switch-DuBpF2_h.js";import{n as j,r as M,t as N}from"./spot-check-actions-5CmYjt8A.js";import{n as P}from"./spot-checks-BadmkHuG.js";import{t as F}from"./jsx-runtime-C3cWAN_r.js";import{t as I}from"./skeleton-D8Sbd2jT.js";import{i as L}from"./factory-BBYEYI9i.js";import{t as R}from"./dist-wxbqfqV1.js";import{t as z}from"./page-header-BqPf-jRo.js";var B=F();function V({item:e,projectId:t}){let n=e.spotCheck;if(!n)return null;let r=P[n.reason];return(0,B.jsxs)(`section`,{"data-testid":`spot-check`,children:[(0,B.jsx)(f,{className:`mb-2`,children:`Spot-check`}),(0,B.jsx)(`div`,{className:`space-y-2 rounded-xl border border-border bg-card p-4 text-[13px]`,children:n.state===`pending`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(d,{className:`mt-0.5 size-3.5 shrink-0 text-status-waiting`}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`font-medium`,children:`Set aside for a quick look`}),(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`(`,r.label.toLowerCase(),`, merged `,O(n.sampledAt),`). Read the change, then record what you found. Nothing waits on it.`]})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[e.pr&&(0,B.jsx)(j,{projectId:t,pr:e.pr,itemId:e.id,title:e.title}),(0,B.jsx)(M,{projectId:t,itemId:e.id,title:e.title})]})]}):(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n.state===`problem`?(0,B.jsx)(c,{className:`mt-0.5 size-3.5 shrink-0 text-status-failed`}):(0,B.jsx)(u,{className:`mt-0.5 size-3.5 shrink-0 text-status-done`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,B.jsxs)(`p`,{children:[n.state===`problem`?`A person found a problem`:`Looks good to a person`,(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[n.checkedAt&&` · ${O(n.checkedAt)}`,` · `,r.label.toLowerCase()]})]}),n.note&&(0,B.jsx)(`p`,{className:`text-2xs whitespace-pre-wrap text-muted-foreground`,children:n.note}),n.state===`problem`&&(n.issue?(0,B.jsxs)(`button`,{type:`button`,className:`text-2xs text-muted-foreground hover:text-foreground hover:underline`,onClick:()=>n.issue&&A.openExternal(n.issue.url),children:[`Follow-up issue #`,n.issue.number]}):(0,B.jsx)(N,{projectId:t,itemId:e.id}))]})]})})]})}function H({label:e,children:t}){return(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,B.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e}),(0,B.jsx)(`span`,{className:`min-w-0 truncate text-right`,children:t})]})}function U({review:e,item:t}){let n=e.verdict===`approve`?`text-status-done`:e.verdict===`reject`?`text-status-failed`:`text-status-waiting`,r=e=>e?(0,B.jsx)(u,{className:`size-3.5 text-status-done`}):(0,B.jsx)(l,{className:`size-3.5 text-status-failed`});return(0,B.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4`,"data-testid":`review-verdict`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,B.jsx)(`span`,{className:R(`font-medium capitalize`,n),children:e.verdict.replace(`_`,` `)}),(0,B.jsxs)(`span`,{className:`text-2xs text-muted-foreground`,children:[`by the reviewer on `,t.reviewerProvider??`another provider`,t.reviewerNote&&` · ${t.reviewerNote}`]})]}),(0,B.jsx)(`p`,{className:`mt-2 text-[13px] leading-relaxed`,children:e.summary}),(0,B.jsxs)(`div`,{className:`mt-3 grid gap-1.5 text-2xs sm:grid-cols-3`,children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[r(e.vision.aligned),` Fits the vision`]}),(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[r(e.tests.adequate),` `,e.tests.notNeeded?`No tests needed`:`Tests adequate`]}),(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[r(e.security.concerns.length===0),` `,e.security.concerns.length?`${e.security.concerns.length} security concerns`:`No security concerns`]})]}),e.security.concerns.length>0&&(0,B.jsx)(`ul`,{className:`mt-2 list-disc pl-5 text-2xs text-status-failed`,children:e.security.concerns.map(e=>(0,B.jsx)(`li`,{children:e},e))}),e.lessons.length>0&&(0,B.jsxs)(`div`,{className:`mt-3 text-2xs`,"data-testid":`review-lessons`,children:[(0,B.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground`,children:[(0,B.jsx)(i,{className:`size-3.5`,"aria-hidden":!0}),` `,t.lessonsNote?`Lessons not kept`:`Lessons recorded`]}),t.lessonsNote&&(0,B.jsx)(`p`,{className:`mt-0.5 text-status-waiting`,"data-testid":`review-lessons-note`,children:t.lessonsNote}),(0,B.jsx)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-5 text-foreground/85`,children:e.lessons.map(e=>(0,B.jsx)(`li`,{children:e},e))})]})]})}function W({projectId:i,itemId:c}){let d=k(i),{data:j,error:M}=L(i,c);if(M)return(0,B.jsx)(`div`,{className:`p-8 text-sm text-muted-foreground`,children:M.message});if(!j||!d)return(0,B.jsx)(I,{className:`m-6 h-64 rounded-xl`});let{item:N,cost:P}=j,F=b(P),R=C[N.stage],W=e(N),G=new Map(N.review?.criteria.map(e=>[e.criterion,e])??[]);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(z,{icon:(0,B.jsx)(r,{}),title:(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,B.jsxs)(t,{to:`/projects/$projectId`,params:{projectId:i},className:`flex items-center text-muted-foreground hover:text-foreground`,children:[(0,B.jsx)(s,{className:`size-4`}),` `,d.name]}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,N.title]}),meta:(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5`,"data-testid":`factory-item-stage`,children:[(0,B.jsx)(p,{tone:R.tone}),` `,R.label,N.type&&(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,E[N.type],` pipeline · `,S(W,N.type)]})]})}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:(0,B.jsxs)(`div`,{className:`mx-auto grid w-full max-w-6xl gap-6 px-6 py-6 lg:grid-cols-[minmax(0,1fr)_300px]`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(N.reason||N.note)&&N.trust!==`untrusted`&&(0,B.jsx)(`div`,{className:`rounded-lg border border-status-waiting/30 bg-status-waiting/[0.06] px-3 py-2 text-2xs`,children:N.reason??N.note}),N.trust!==`trusted`&&(0,B.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-status-waiting/30 bg-status-waiting/[0.06] px-3 py-2 text-2xs`,children:[(0,B.jsx)(n,{className:`mt-px size-3.5 shrink-0 text-status-waiting`}),(0,B.jsx)(`span`,{children:N.trust===`untrusted`?`@${N.author??`unknown`} is not a trusted author, so the factory ignores this issue. Let it in only if you want it done; a person then merges the result.`:`Let in by ${N.admittedBy===`pm`?`the PM`:`you`} from an untrusted author: it is never merged automatically.`})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(f,{className:`mb-2`,children:`The issue`}),(0,B.jsx)(`p`,{className:`text-[13px] leading-relaxed whitespace-pre-wrap`,children:N.summary||N.title})]}),(0,B.jsx)(g,{item:N}),N.acceptanceCriteria.length>0&&(0,B.jsxs)(`section`,{children:[(0,B.jsx)(f,{className:`mb-2`,children:`Acceptance criteria`}),(0,B.jsx)(`ul`,{className:`space-y-1.5`,children:N.acceptanceCriteria.map(e=>{let t=G.get(e);return(0,B.jsxs)(`li`,{className:`flex items-start gap-2 text-[13px]`,children:[t?t.met?(0,B.jsx)(u,{className:`mt-0.5 size-3.5 shrink-0 text-status-done`}):(0,B.jsx)(l,{className:`mt-0.5 size-3.5 shrink-0 text-status-failed`}):(0,B.jsx)(`span`,{className:`mt-1.5 size-1.5 shrink-0 rounded-full bg-muted-foreground/50`}),(0,B.jsxs)(`span`,{children:[e,t?.note&&(0,B.jsx)(`span`,{className:`block text-2xs text-muted-foreground`,children:t.note})]})]},e)})})]}),(0,B.jsx)(D,{item:N,projectId:i}),N.stage!==`ignored`&&(0,B.jsxs)(`section`,{children:[(0,B.jsxs)(f,{className:`mb-2`,children:[`Merge checks · `,N.checks.filter(e=>e.state===`pass`).length,` passed`,N.checks.some(e=>e.state===`skipped`)&&`, ${N.checks.filter(e=>e.state===`skipped`).length} skipped`,N.checks.some(e=>e.state===`fail`)&&`, ${N.checks.filter(e=>e.state===`fail`).length} failed`]}),N.checks.length===0?(0,B.jsxs)(`p`,{className:`text-2xs text-muted-foreground`,children:[`Checks run once the builder opens a pull request:`,` `,Object.values(T).join(`, `),`.`]}):(0,B.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card`,"data-testid":`item-checks`,children:N.checks.map(e=>(0,B.jsx)(x,{check:e},e.name))})]}),N.review&&(0,B.jsxs)(`section`,{children:[(0,B.jsx)(f,{className:`mb-2`,children:`Independent review`}),(0,B.jsx)(U,{review:N.review,item:N})]}),(0,B.jsx)(V,{item:N,projectId:i}),(0,B.jsx)(m,{item:N,projectId:i,mode:d.autonomyMode})]}),(0,B.jsxs)(`aside`,{className:`space-y-3 rounded-xl border border-border bg-card p-4 self-start`,children:[(0,B.jsx)(h,{item:N,projectId:i}),(0,B.jsxs)(H,{label:`Source`,children:[w[N.source],N.area&&` · ${N.area.replace(`_`,` `)}`]}),(0,B.jsxs)(H,{label:`Pipeline`,children:[N.type?E[N.type]:`Not classified yet`,N.classification&&(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · by `,N.classification.by]})]}),(0,B.jsxs)(H,{label:`Author`,children:[N.author?`@${N.author}`:`—`,(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,N.trust]})]}),N.score!==null&&(0,B.jsx)(H,{label:`Priority`,children:N.score.toFixed(2)}),(0,B.jsx)(H,{label:`Work key`,children:(0,B.jsx)(`code`,{className:`font-mono text-2xs`,children:N.workKey})}),(0,B.jsx)(H,{label:`Issue`,children:N.issue?(0,B.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-primary hover:underline`,onClick:()=>N.issue&&A.openExternal(N.issue.url),children:[(0,B.jsx)(a,{className:`size-3`}),`#`,N.issue.number]}):`—`}),(0,B.jsx)(H,{label:`Pull request`,children:N.pr?(0,B.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-primary hover:underline`,onClick:()=>N.pr&&A.openExternal(N.pr.url),children:[(0,B.jsx)(o,{className:`size-3`}),`#`,N.pr.number,` · `,N.pr.state]}):`—`}),(0,B.jsx)(H,{label:`Builder`,children:(0,B.jsx)(v,{id:N.builderSessionId,label:N.builderProvider??`session`})}),(0,B.jsx)(H,{label:`Reviewer`,children:(0,B.jsx)(v,{id:N.reviewerSessionId,label:N.reviewerProvider??`session`})}),(0,B.jsx)(y,{item:N}),(0,B.jsx)(H,{label:`Revise rounds`,children:N.attempts}),(0,B.jsx)(H,{label:`Cost`,children:(0,B.jsx)(_,{cost:P})}),F&&(0,B.jsx)(H,{label:`Spend cap`,children:F}),N.mergeSha&&(0,B.jsx)(H,{label:`Merge commit`,children:(0,B.jsx)(`code`,{className:`font-mono text-2xs`,children:N.mergeSha.slice(0,10)})}),N.revertOf&&(0,B.jsx)(H,{label:`Reverts`,children:(0,B.jsx)(t,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:i,itemId:N.revertOf},className:`text-primary hover:underline`,children:`the original item`})}),(0,B.jsxs)(`div`,{className:`space-y-1 border-t border-border pt-3 text-3xs text-muted-foreground`,children:[(0,B.jsxs)(`p`,{children:[`Found `,O(N.createdAt)]}),N.mergedAt&&(0,B.jsxs)(`p`,{children:[`Merged `,O(N.mergedAt)]}),N.finishedAt&&(0,B.jsxs)(`p`,{children:[`Finished `,O(N.finishedAt)]})]})]})]})})]})}export{W as FactoryItemPage};
1
+ import{rt as e}from"./api-yvn34iKU.js";import{L as t}from"./dropdown-menu-Bflkx6wY.js";import{P as n,Rn as r,Wt as i,ar as a,cn as o,dr as s,m as c,n as l,pr as u,zn as d}from"./icons-COCLuOtb.js";import{o as f}from"./bits-B2GRjm37.js";import{O as p}from"./mobile-nav-CrjrDJZ5.js";import{o as m}from"./factory-columns-DExb6gW2.js";import{a as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./item-parts-DZ3TQad4.js";import{C as S,_ as C,g as w,i as T,v as E}from"./use-retry-item-3n4BD_3J.js";import{t as D}from"./spec-approval-CmC6QBSh.js";import{n as O,y as k}from"./format-D3kairnQ.js";import{o as A}from"./switch-BHplnCdo.js";import{n as j,r as M,t as N}from"./spot-check-actions-DzMUED1O.js";import{n as P}from"./spot-checks-CDZxwwu0.js";import{t as F}from"./jsx-runtime-C3cWAN_r.js";import{t as I}from"./skeleton-D8Sbd2jT.js";import{i as L}from"./factory-DVCs5zxg.js";import{t as R}from"./dist-wxbqfqV1.js";import{t as z}from"./page-header-t9HzSrxd.js";var B=F();function V({item:e,projectId:t}){let n=e.spotCheck;if(!n)return null;let r=P[n.reason];return(0,B.jsxs)(`section`,{"data-testid":`spot-check`,children:[(0,B.jsx)(f,{className:`mb-2`,children:`Spot-check`}),(0,B.jsx)(`div`,{className:`space-y-2 rounded-xl border border-border bg-card p-4 text-[13px]`,children:n.state===`pending`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(d,{className:`mt-0.5 size-3.5 shrink-0 text-status-waiting`}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`font-medium`,children:`Set aside for a quick look`}),(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`(`,r.label.toLowerCase(),`, merged `,O(n.sampledAt),`). Read the change, then record what you found. Nothing waits on it.`]})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[e.pr&&(0,B.jsx)(j,{projectId:t,pr:e.pr,itemId:e.id,title:e.title}),(0,B.jsx)(M,{projectId:t,itemId:e.id,title:e.title})]})]}):(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n.state===`problem`?(0,B.jsx)(c,{className:`mt-0.5 size-3.5 shrink-0 text-status-failed`}):(0,B.jsx)(u,{className:`mt-0.5 size-3.5 shrink-0 text-status-done`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,B.jsxs)(`p`,{children:[n.state===`problem`?`A person found a problem`:`Looks good to a person`,(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[n.checkedAt&&` · ${O(n.checkedAt)}`,` · `,r.label.toLowerCase()]})]}),n.note&&(0,B.jsx)(`p`,{className:`text-2xs whitespace-pre-wrap text-muted-foreground`,children:n.note}),n.state===`problem`&&(n.issue?(0,B.jsxs)(`button`,{type:`button`,className:`text-2xs text-muted-foreground hover:text-foreground hover:underline`,onClick:()=>n.issue&&A.openExternal(n.issue.url),children:[`Follow-up issue #`,n.issue.number]}):(0,B.jsx)(N,{projectId:t,itemId:e.id}))]})]})})]})}function H({label:e,children:t}){return(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,B.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e}),(0,B.jsx)(`span`,{className:`min-w-0 truncate text-right`,children:t})]})}function U({review:e,item:t}){let n=e.verdict===`approve`?`text-status-done`:e.verdict===`reject`?`text-status-failed`:`text-status-waiting`,r=e=>e?(0,B.jsx)(u,{className:`size-3.5 text-status-done`}):(0,B.jsx)(l,{className:`size-3.5 text-status-failed`});return(0,B.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4`,"data-testid":`review-verdict`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,B.jsx)(`span`,{className:R(`font-medium capitalize`,n),children:e.verdict.replace(`_`,` `)}),(0,B.jsxs)(`span`,{className:`text-2xs text-muted-foreground`,children:[`by the reviewer on `,t.reviewerProvider??`another provider`,t.reviewerNote&&` · ${t.reviewerNote}`]})]}),(0,B.jsx)(`p`,{className:`mt-2 text-[13px] leading-relaxed`,children:e.summary}),(0,B.jsxs)(`div`,{className:`mt-3 grid gap-1.5 text-2xs sm:grid-cols-3`,children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[r(e.vision.aligned),` Fits the vision`]}),(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[r(e.tests.adequate),` `,e.tests.notNeeded?`No tests needed`:`Tests adequate`]}),(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[r(e.security.concerns.length===0),` `,e.security.concerns.length?`${e.security.concerns.length} security concerns`:`No security concerns`]})]}),e.security.concerns.length>0&&(0,B.jsx)(`ul`,{className:`mt-2 list-disc pl-5 text-2xs text-status-failed`,children:e.security.concerns.map(e=>(0,B.jsx)(`li`,{children:e},e))}),e.lessons.length>0&&(0,B.jsxs)(`div`,{className:`mt-3 text-2xs`,"data-testid":`review-lessons`,children:[(0,B.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground`,children:[(0,B.jsx)(i,{className:`size-3.5`,"aria-hidden":!0}),` `,t.lessonsNote?`Lessons not kept`:`Lessons recorded`]}),t.lessonsNote&&(0,B.jsx)(`p`,{className:`mt-0.5 text-status-waiting`,"data-testid":`review-lessons-note`,children:t.lessonsNote}),(0,B.jsx)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-5 text-foreground/85`,children:e.lessons.map(e=>(0,B.jsx)(`li`,{children:e},e))})]})]})}function W({projectId:i,itemId:c}){let d=k(i),{data:j,error:M}=L(i,c);if(M)return(0,B.jsx)(`div`,{className:`p-8 text-sm text-muted-foreground`,children:M.message});if(!j||!d)return(0,B.jsx)(I,{className:`m-6 h-64 rounded-xl`});let{item:N,cost:P}=j,F=b(P),R=C[N.stage],W=e(N),G=new Map(N.review?.criteria.map(e=>[e.criterion,e])??[]);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(z,{icon:(0,B.jsx)(r,{}),title:(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,B.jsxs)(t,{to:`/projects/$projectId`,params:{projectId:i},className:`flex items-center text-muted-foreground hover:text-foreground`,children:[(0,B.jsx)(s,{className:`size-4`}),` `,d.name]}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,N.title]}),meta:(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5`,"data-testid":`factory-item-stage`,children:[(0,B.jsx)(p,{tone:R.tone}),` `,R.label,N.type&&(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,E[N.type],` pipeline · `,S(W,N.type)]})]})}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:(0,B.jsxs)(`div`,{className:`mx-auto grid w-full max-w-6xl gap-6 px-6 py-6 lg:grid-cols-[minmax(0,1fr)_300px]`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(N.reason||N.note)&&N.trust!==`untrusted`&&(0,B.jsx)(`div`,{className:`rounded-lg border border-status-waiting/30 bg-status-waiting/[0.06] px-3 py-2 text-2xs`,children:N.reason??N.note}),N.trust!==`trusted`&&(0,B.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-status-waiting/30 bg-status-waiting/[0.06] px-3 py-2 text-2xs`,children:[(0,B.jsx)(n,{className:`mt-px size-3.5 shrink-0 text-status-waiting`}),(0,B.jsx)(`span`,{children:N.trust===`untrusted`?`@${N.author??`unknown`} is not a trusted author, so the factory ignores this issue. Let it in only if you want it done; a person then merges the result.`:`Let in by ${N.admittedBy===`pm`?`the PM`:`you`} from an untrusted author: it is never merged automatically.`})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(f,{className:`mb-2`,children:`The issue`}),(0,B.jsx)(`p`,{className:`text-[13px] leading-relaxed whitespace-pre-wrap`,children:N.summary||N.title})]}),(0,B.jsx)(g,{item:N}),N.acceptanceCriteria.length>0&&(0,B.jsxs)(`section`,{children:[(0,B.jsx)(f,{className:`mb-2`,children:`Acceptance criteria`}),(0,B.jsx)(`ul`,{className:`space-y-1.5`,children:N.acceptanceCriteria.map(e=>{let t=G.get(e);return(0,B.jsxs)(`li`,{className:`flex items-start gap-2 text-[13px]`,children:[t?t.met?(0,B.jsx)(u,{className:`mt-0.5 size-3.5 shrink-0 text-status-done`}):(0,B.jsx)(l,{className:`mt-0.5 size-3.5 shrink-0 text-status-failed`}):(0,B.jsx)(`span`,{className:`mt-1.5 size-1.5 shrink-0 rounded-full bg-muted-foreground/50`}),(0,B.jsxs)(`span`,{children:[e,t?.note&&(0,B.jsx)(`span`,{className:`block text-2xs text-muted-foreground`,children:t.note})]})]},e)})})]}),(0,B.jsx)(D,{item:N,projectId:i}),N.stage!==`ignored`&&(0,B.jsxs)(`section`,{children:[(0,B.jsxs)(f,{className:`mb-2`,children:[`Merge checks · `,N.checks.filter(e=>e.state===`pass`).length,` passed`,N.checks.some(e=>e.state===`skipped`)&&`, ${N.checks.filter(e=>e.state===`skipped`).length} skipped`,N.checks.some(e=>e.state===`fail`)&&`, ${N.checks.filter(e=>e.state===`fail`).length} failed`]}),N.checks.length===0?(0,B.jsxs)(`p`,{className:`text-2xs text-muted-foreground`,children:[`Checks run once the builder opens a pull request:`,` `,Object.values(T).join(`, `),`.`]}):(0,B.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card`,"data-testid":`item-checks`,children:N.checks.map(e=>(0,B.jsx)(x,{check:e},e.name))})]}),N.review&&(0,B.jsxs)(`section`,{children:[(0,B.jsx)(f,{className:`mb-2`,children:`Independent review`}),(0,B.jsx)(U,{review:N.review,item:N})]}),(0,B.jsx)(V,{item:N,projectId:i}),(0,B.jsx)(m,{item:N,projectId:i,mode:d.autonomyMode})]}),(0,B.jsxs)(`aside`,{className:`space-y-3 rounded-xl border border-border bg-card p-4 self-start`,children:[(0,B.jsx)(h,{item:N,projectId:i}),(0,B.jsxs)(H,{label:`Source`,children:[w[N.source],N.area&&` · ${N.area.replace(`_`,` `)}`]}),(0,B.jsxs)(H,{label:`Pipeline`,children:[N.type?E[N.type]:`Not classified yet`,N.classification&&(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · by `,N.classification.by]})]}),(0,B.jsxs)(H,{label:`Author`,children:[N.author?`@${N.author}`:`—`,(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,N.trust]})]}),N.score!==null&&(0,B.jsx)(H,{label:`Priority`,children:N.score.toFixed(2)}),(0,B.jsx)(H,{label:`Work key`,children:(0,B.jsx)(`code`,{className:`font-mono text-2xs`,children:N.workKey})}),(0,B.jsx)(H,{label:`Issue`,children:N.issue?(0,B.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-primary hover:underline`,onClick:()=>N.issue&&A.openExternal(N.issue.url),children:[(0,B.jsx)(a,{className:`size-3`}),`#`,N.issue.number]}):`—`}),(0,B.jsx)(H,{label:`Pull request`,children:N.pr?(0,B.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-primary hover:underline`,onClick:()=>N.pr&&A.openExternal(N.pr.url),children:[(0,B.jsx)(o,{className:`size-3`}),`#`,N.pr.number,` · `,N.pr.state]}):`—`}),(0,B.jsx)(H,{label:`Builder`,children:(0,B.jsx)(v,{id:N.builderSessionId,label:N.builderProvider??`session`})}),(0,B.jsx)(H,{label:`Reviewer`,children:(0,B.jsx)(v,{id:N.reviewerSessionId,label:N.reviewerProvider??`session`})}),(0,B.jsx)(y,{item:N}),(0,B.jsx)(H,{label:`Revise rounds`,children:N.attempts}),(0,B.jsx)(H,{label:`Cost`,children:(0,B.jsx)(_,{cost:P})}),F&&(0,B.jsx)(H,{label:`Spend cap`,children:F}),N.mergeSha&&(0,B.jsx)(H,{label:`Merge commit`,children:(0,B.jsx)(`code`,{className:`font-mono text-2xs`,children:N.mergeSha.slice(0,10)})}),N.revertOf&&(0,B.jsx)(H,{label:`Reverts`,children:(0,B.jsx)(t,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:i,itemId:N.revertOf},className:`text-primary hover:underline`,children:`the original item`})}),(0,B.jsxs)(`div`,{className:`space-y-1 border-t border-border pt-3 text-3xs text-muted-foreground`,children:[(0,B.jsxs)(`p`,{children:[`Found `,O(N.createdAt)]}),N.mergedAt&&(0,B.jsxs)(`p`,{children:[`Merged `,O(N.mergedAt)]}),N.finishedAt&&(0,B.jsxs)(`p`,{children:[`Finished `,O(N.finishedAt)]})]})]})]})})]})}export{W as FactoryItemPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Z as t,i as n}from"./api-B620HpC2.js";import{L as r}from"./dropdown-menu-C4XI7F63.js";import{Cr as i,Gt as a,Ht as o,In as s,Jn as c,P as l,Rn as u,Sr as d,Tt as f,Vn as p,Z as m,ar as h,cn as g,fr as _,jt as v,kt as ee,m as y,n as b,pr as x,q as S,rt as C,u as w,ur as T,xt as te}from"./icons-COCLuOtb.js";import{n as E,t as D}from"./jsx-runtime-C3cWAN_r.js";import{o as O,t as k}from"./bits-B2GRjm37.js";import{_ as ne,a as re,c as A,d as j,f as M,g as ie,h as ae,i as oe,l as N,m as se,n as ce,o as le,p as P,s as ue,u as F,v as de}from"./storeys-OlWmOmqA.js";import{c as I,d as L,l as fe,n as pe,o as R,s as z,t as me,u as he}from"./item-parts-BhDFWsT1.js";import{C as ge,_ as _e,c as ve,d as B,n as ye,o as be,t as xe,v as Se}from"./use-retry-item-CWwb3JGo.js";import{A as Ce,M as we,N as Te,P as Ee,j as De}from"./mobile-nav-D8FZcJzG.js";import{t as V}from"./skeleton-D8Sbd2jT.js";import{i as Oe,o as ke,t as Ae}from"./factory-BBYEYI9i.js";import{D as je,E as Me,f as Ne,j as H,m as U,n as Pe,t as Fe,w as Ie,y as Le,yt as W}from"./format-D1ma_o2D.js";import{o as Re}from"./switch-DuBpF2_h.js";import{t as G}from"./dist-wxbqfqV1.js";import{F as ze}from"./useQuery-VSotSwry.js";import{i as Be}from"./form-bits-BSfnSmQ7.js";import{i as K,o as q,r as Ve}from"./remote-check-BAPXUznK.js";import{i as He,l as Ue,n as We,s as Ge,t as Ke,u as qe}from"./wip-chip-D5-cZcfN.js";import{t as Je}from"./kill-switch-Dvqaozhz.js";import{i as Ye}from"./on-demand-Cvu5D9uT.js";import{r as Xe}from"./role-chat-CeJXMsYB.js";var J=e(E(),1),Y=D(),Ze=Object.fromEntries(Object.entries(B).map(([e,t])=>[e,t.label])),Qe={bug:`bg-status-failed/10 text-status-failed`,feature:`bg-primary/10 text-primary`,docs:`bg-muted text-muted-foreground`};function $e({type:e,fit:t=!1}){if(!e)return null;let n=e===`docs`?`Docs`:Se[e];return(0,Y.jsx)(`span`,{className:G(`min-w-0 truncate rounded px-1 text-[10px] leading-4 font-medium`,Qe[e]),title:Se[e],children:e===`feature`&&t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`@[9.5rem]:hidden`,children:`Feat`}),(0,Y.jsx)(`span`,{className:`hidden @[9.5rem]:inline`,children:n})]}):n})}function et({state:e,className:t}){return e===`person`?(0,Y.jsx)(w,{className:G(`size-3 shrink-0 text-status-waiting`,t),"aria-hidden":!0}):e===`failed`?(0,Y.jsx)(y,{className:G(`size-3 shrink-0 text-status-failed`,t),"aria-hidden":!0}):(0,Y.jsx)(`span`,{"aria-hidden":!0,className:G(`inline-block size-2 shrink-0 rounded-full`,e===`running`?`bg-status-running motion-safe:animate-pulse`:`bg-status-idle/70 ring-2 ring-status-idle/20`,t)})}function X({tone:e,title:t,testId:n,children:r}){return(0,Y.jsx)(`span`,{title:t,"data-testid":n,className:G(`inline-flex shrink-0 items-center gap-0.5 rounded-full border px-1.5 text-[10px] leading-4`,e===`person`&&`border-status-waiting/40 text-status-waiting`,e===`failed`&&`border-status-failed/40 text-status-failed`,!e&&`border-border text-muted-foreground`),children:r})}function tt({card:e,now:t,onOpen:n,className:r}){let i=e.item,a=N(i),s=P(e.pr,Ze),u=e.place===`reviewing`||e.place===`merge`?i.checks:null,d=he(i.cost)?i.cost:null,f=Fe(e.since,t);return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(e),"aria-label":`${a} ${i.title}, ${F(e)}${d?`, cost ${I(d)}`:``}`,"data-testid":`factory-view-card`,"data-state":e.state,className:G(`group @container w-full animate-rise rounded-lg border bg-card px-2.5 py-2 text-left shadow-xs transition-colors hover:border-primary/50 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,e.state===`person`&&`border-status-waiting/50 bg-status-waiting/[0.05]`,e.state===`failed`&&`border-status-failed/50 bg-status-failed/[0.05]`,e.state!==`person`&&e.state!==`failed`&&`border-border`,r),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 overflow-hidden`,children:[(0,Y.jsx)(et,{state:e.state}),(0,Y.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:a}),(0,Y.jsx)($e,{type:i.type,fit:!0}),i.trust===`admitted`&&(0,Y.jsx)(l,{className:`size-3 shrink-0 text-status-waiting`,"aria-label":`Let in from an untrusted author`}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-muted-foreground tabular-nums`,title:`In this step since ${new Date(e.since).toLocaleString()}`,children:f===`now`?`just now`:f})]}),(0,Y.jsx)(`div`,{className:`mt-1 line-clamp-2 text-[12.5px] leading-snug font-medium`,children:i.title}),(i.attempts>0||s||u||d)&&(0,Y.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:[i.attempts>0&&(0,Y.jsxs)(X,{tone:`person`,title:`Revise round ${i.attempts}`,children:[(0,Y.jsx)(S,{className:`size-2.5`,"aria-hidden":!0}),` `,i.attempts]}),s&&(0,Y.jsx)(X,{tone:e.pr?.state===`stuck`||e.pr?.state===`waiting_for_you`?`person`:void 0,children:s}),u&&(0,Y.jsxs)(X,{tone:u.failed>0?`failed`:void 0,title:`${u.passed} of ${u.total} merge checks passed${u.failed?`, ${u.failed} failed`:``}`,children:[(0,Y.jsx)(o,{className:`size-2.5`,"aria-hidden":!0}),` `,u.passed,`/`,u.total]}),d&&(0,Y.jsxs)(X,{tone:L(d)?`person`:void 0,title:[fe(d),z(d)&&`Spend cap: ${z(d)}`].filter(Boolean).join(` · `),testId:`factory-view-card-cost`,children:[(0,Y.jsx)(c,{className:`size-2.5`,"aria-hidden":!0}),` `,I(d)]})]}),(0,Y.jsx)(`div`,{className:`mt-0.5 truncate text-2xs text-muted-foreground`,children:e.activity})]})}function nt({card:e,projectId:t,className:i}){let a=n(),o=ze(),c=e.need,l=N(e.item),u=()=>void o.invalidateQueries({queryKey:Ae.all}),d=xe(t,e.item.id),f=W({mutationFn:()=>a.factory.dismiss(t,e.item.id),onSuccess:()=>{H.success(`${l} dismissed`),u()},onError:e=>H.error(`Couldn't dismiss`,{description:e.message})});if(!c)return null;let m=d.isPending||f.isPending,h=e.pr?.pr.url??e.item.ownedPr?.url??e.item.pr?.url??null;return(0,Y.jsxs)(`div`,{className:G(`flex flex-wrap items-center gap-1`,i),"data-testid":`factory-view-need`,"data-need":c.kind,children:[(0,Y.jsx)(`span`,{className:`mr-auto min-w-0 text-2xs font-medium text-status-waiting`,children:c.label}),c.kind===`merge`&&h&&(0,Y.jsxs)(U,{size:`xs`,variant:`outline`,onClick:()=>Re.openExternal(h),children:[(0,Y.jsx)(p,{}),` Open PR`]}),(c.kind===`retry`||c.kind===`retry_or_dismiss`)&&(0,Y.jsxs)(U,{size:`xs`,variant:`outline`,onClick:()=>d.mutate(),disabled:m,"aria-label":`Retry ${l}`,children:[(0,Y.jsx)(S,{}),` Retry`]}),c.kind===`retry_or_dismiss`&&(0,Y.jsxs)(U,{size:`xs`,variant:`ghost`,onClick:()=>f.mutate(),disabled:m,"aria-label":`Dismiss ${l}`,children:[(0,Y.jsx)(b,{}),` Dismiss`]}),c.kind===`answer`&&e.sessionId&&(0,Y.jsx)(U,{size:`xs`,variant:`outline`,asChild:!0,children:(0,Y.jsxs)(r,{to:`/sessions/$sessionId`,params:{sessionId:e.sessionId},children:[(0,Y.jsx)(ee,{}),` Answer`]})}),c.kind===`approve_spec`&&(0,Y.jsx)(U,{size:`xs`,variant:`outline`,asChild:!0,children:(0,Y.jsxs)(r,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:t,itemId:e.item.id},"aria-label":`Review the spec of ${l}`,children:[(0,Y.jsx)(s,{}),` Review spec`]})})]})}function rt({card:e,now:t,onOpen:n,projectId:r}){return(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsx)(tt,{card:e,now:t,onOpen:n,className:`rounded-b-none border-b-0 shadow-none`}),(0,Y.jsx)(nt,{card:e,projectId:r,className:G(`rounded-b-lg border px-2.5 py-1.5`,e.state===`failed`?`border-status-failed/50 bg-status-failed/[0.05]`:`border-status-waiting/50 bg-status-waiting/[0.05]`)})]})}var it={bug:[`intake`,`reproduce`,`implement`,`review`,`merge`],feature:[`intake`,`analyze`,`implement`,`review`,`merge`],docs:[`intake`,`implement`,`review`,`merge`]};function at(e){let t=it[e.type??`feature`],n,r=null;return e.stage===`merged`||e.step===`done`?n=t.length:e.stage===`watching`?(n=t.indexOf(`merge`),r=`Merged; watching CI on the default branch`):e.step===`queued`?(n=1,r=`Waiting for a free agent`):n=e.step===`stopped`||e.step===`ignored`?-1:t.indexOf(e.step),t.map((e,t)=>{let i=n===-1?`next`:t<n?`done`:t===n?`current`:`next`;return{step:e,mark:i,note:i===`current`?r:null}})}function ot({item:e,card:t}){let n=at({type:e.type,step:t.item.step,stage:t.item.stage});return(0,Y.jsx)(`ol`,{className:`flex flex-col gap-1`,"aria-label":`Pipeline steps`,children:n.map(({step:t,mark:n,note:r})=>(0,Y.jsxs)(`li`,{className:G(`flex items-center gap-2 rounded-md px-2 py-1 text-[12.5px]`,n===`current`&&`bg-primary/10 font-medium text-foreground`,n===`next`&&`text-muted-foreground`),"aria-current":n===`current`?`step`:void 0,children:[n===`done`?(0,Y.jsx)(x,{className:`size-3.5 text-status-done`,"aria-hidden":!0}):(0,Y.jsx)(`span`,{"aria-hidden":!0,className:G(`mx-[3px] size-2 rounded-full`,n===`current`?`bg-primary`:`border border-muted-foreground/50`)}),(0,Y.jsxs)(`span`,{children:[ge(t,e.type),r&&(0,Y.jsx)(`span`,{className:`block text-2xs font-normal text-muted-foreground`,children:r})]}),n===`current`&&(0,Y.jsx)(`span`,{className:`sr-only`,children:`(current step)`})]},t))})}function Z({label:e,children:t}){return(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-right`,children:t})]})}function st({url:e,children:t}){return(0,Y.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-primary hover:underline`,onClick:()=>Re.openExternal(e),children:t})}function ct({projectId:e,card:t}){let{data:n,error:i}=Oe(e,t.item.id);if(i)return(0,Y.jsx)(`p`,{className:`px-4 text-2xs text-muted-foreground`,children:i.message});if(!n)return(0,Y.jsx)(V,{className:`mx-4 h-48 rounded-xl`});let{item:a}=n,o=n.cost??t.item.cost,s=z(o),c=a.checks.filter(e=>e.state===`pass`).length,l=a.pr??t.pr?.pr??t.item.ownedPr;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5 px-4 pb-6`,children:[(a.reason||t.activity)&&(0,Y.jsx)(`p`,{className:G(`rounded-lg border px-3 py-2 text-2xs`,t.state===`failed`?`border-status-failed/30 bg-status-failed/[0.06]`:t.state===`person`?`border-status-waiting/30 bg-status-waiting/[0.06]`:`border-border bg-surface`),children:t.activity}),t.need&&(0,Y.jsx)(nt,{card:t,projectId:e,className:`rounded-lg border border-status-waiting/30 bg-status-waiting/[0.06] px-3 py-2`}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(O,{className:`mb-1.5`,children:`Steps`}),(0,Y.jsx)(ot,{item:a,card:t})]}),(0,Y.jsxs)(`section`,{className:`space-y-2 rounded-xl border border-border bg-card p-3`,children:[(0,Y.jsx)(Z,{label:`Issue`,children:a.issue?(0,Y.jsxs)(st,{url:a.issue.url,children:[(0,Y.jsx)(h,{className:`size-3`}),`#`,a.issue.number]}):`—`}),(0,Y.jsx)(Z,{label:!a.pr&&l?`Pull request (rebuilt)`:`Pull request`,children:l?(0,Y.jsxs)(st,{url:l.url,children:[(0,Y.jsx)(g,{className:`size-3`}),`#`,l.number,t.pr?.pr.number===l.number?` · ${B[t.pr.state].label}`:` · ${l.state}`]}):`—`}),(0,Y.jsx)(Z,{label:`Builder`,children:(0,Y.jsx)(R,{id:a.builderSessionId,label:a.builderProvider??`session`})}),(0,Y.jsx)(Z,{label:`Reviewer`,children:(0,Y.jsx)(R,{id:a.reviewerSessionId,label:a.reviewerProvider??`session`})}),(0,Y.jsx)(Z,{label:`Stage`,children:_e[a.stage].label}),a.attempts>0&&(0,Y.jsx)(Z,{label:`Revise rounds`,children:a.attempts}),(0,Y.jsx)(Z,{label:`Cost`,children:(0,Y.jsx)(pe,{cost:o})}),s&&(0,Y.jsx)(Z,{label:`Spend cap`,children:s}),(0,Y.jsx)(Z,{label:`In this step`,children:Pe(t.since)})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(O,{className:`mb-1.5`,children:[`Merge checks`,a.checks.length>0&&` · ${c} of ${a.checks.length} passed`]}),a.checks.length===0?(0,Y.jsx)(`p`,{className:`text-2xs text-muted-foreground`,children:a.pr?`No merge checks recorded yet.`:`Checks run once the builder opens a pull request.`}):(0,Y.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card`,children:a.checks.map(e=>(0,Y.jsx)(me,{check:e},e.name))})]}),a.review&&(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(O,{className:`mb-1.5`,children:`Review`}),(0,Y.jsxs)(`p`,{className:`text-2xs leading-relaxed`,children:[(0,Y.jsx)(`span`,{className:`font-medium capitalize`,children:a.review.verdict.replace(`_`,` `)}),` · `,a.review.summary.length>400?`${a.review.summary.slice(0,400)}…`:a.review.summary]})]}),(0,Y.jsxs)(r,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:e,itemId:a.id},className:`inline-flex items-center gap-1 text-2xs text-primary hover:underline`,children:[(0,Y.jsx)(p,{className:`size-3`}),` Open the full item page`]})]})}function lt({projectId:e,card:t,onClose:n}){return(0,Y.jsx)(Ce,{open:t!==null,onOpenChange:e=>!e&&n(),children:(0,Y.jsx)(De,{side:`right`,className:`gap-0 overflow-y-auto scroll-thin data-[side=right]:w-full data-[side=right]:sm:max-w-md`,"data-testid":`factory-view-sheet`,children:t&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Te,{className:`pb-3`,children:[(0,Y.jsxs)(Ee,{className:`flex items-start gap-2 pr-6 text-[15px] leading-snug`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 font-mono whitespace-nowrap text-muted-foreground`,children:N(t.item)}),(0,Y.jsx)(`span`,{children:t.item.title})]}),(0,Y.jsxs)(we,{className:`flex items-center gap-1.5 text-2xs`,children:[(0,Y.jsx)(et,{state:t.state}),F(t),(0,Y.jsx)($e,{type:t.item.type})]})]}),(0,Y.jsx)(ct,{projectId:e,card:t})]})})})}var ut={idle:`Idle`,planning:`Planning the round`,reviewing:`Area reviewers at work`,filing:`Filing issues`};function dt({scout:e,projectId:t}){let n=e.phase!==`idle`;return(0,Y.jsxs)(`div`,{className:G(`rounded-lg border border-dashed px-2.5 py-2 text-2xs`,n?`border-primary/40 bg-primary/[0.04]`:`border-border`),"data-testid":`factory-view-scout`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(m,{className:G(`size-3.5`,n?`text-primary`:`text-muted-foreground`)}),e.sessionId?(0,Y.jsx)(r,{to:`/sessions/$sessionId`,params:{sessionId:e.sessionId},className:`text-[12px] font-medium hover:underline`,children:`Scout`}):(0,Y.jsx)(`span`,{className:`text-[12px] font-medium`,children:`Scout`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:n?`round ${e.rounds}`:`${e.rounds} rounds`})]}),(0,Y.jsxs)(`div`,{className:`mt-0.5 text-muted-foreground`,children:[ut[e.phase],n&&` · ${e.findings} found · ${e.filed} filed`,!n&&e.nextRoundAt&&` · next ${Ne(e.nextRoundAt)}`]}),e.lenses.length>0&&(0,Y.jsx)(`ul`,{className:`mt-1.5 flex flex-wrap gap-1`,"aria-label":`Area reviewers`,children:e.lenses.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(r,{to:`/sessions/$sessionId`,params:{sessionId:e.sessionId},className:`flex items-center gap-1 rounded-full border border-border bg-surface px-1.5 text-[10px] leading-4 hover:border-primary/50`,title:e.reported?`Reported its findings`:e.active?`Reviewing now`:`Waiting to start`,children:[e.reported?(0,Y.jsx)(x,{className:`size-2.5 text-status-done`}):(0,Y.jsx)(`span`,{className:G(`size-1.5 rounded-full`,e.active?`bg-status-running motion-safe:animate-pulse`:`bg-status-idle`)}),ye[e.area]]})},e.area))}),(0,Y.jsx)(qe,{projectId:t,held:e.heldFollowUps,className:`mt-1 block`})]})}function ft(e){let t=(0,J.useRef)(null),[n,r]=(0,J.useState)(``);return(0,J.useEffect)(()=>{let n=t.current;if(t.current=M(e),!n)return;let i=j(n,e);i.length!==0&&r(i.length>4?`${i.slice(0,4).join(` `)} And ${i.length-4} more.`:i.join(` `))},[e]),n}function pt({cards:e,now:t,onOpen:n,empty:r}){return e.length===0?r?(0,Y.jsxs)(`p`,{className:`px-1 py-2 text-2xs text-muted-foreground/70`,children:[r.text,` ·`,` `,(0,Y.jsx)(K,{section:r.guide,className:`text-muted-foreground`,children:`how it works`})]}):null:(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(tt,{card:e,now:t,onOpen:n})},e.item.id))})}function mt({label:e,hint:t,count:n,wide:r,last:i,children:a}){let o=(0,J.useId)(),[s,c]=(0,J.useState)(n>0),l=(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{id:o,className:`text-[12px] leading-tight font-medium`,children:e}),(0,Y.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-[10px] leading-4 text-muted-foreground tabular-nums`,children:n})]});return r?(0,Y.jsxs)(`section`,{"aria-labelledby":o,className:`relative flex min-h-0 min-w-0 flex-col rounded-xl border border-border bg-surface/60`,"data-testid":`factory-view-stage`,"data-stage":e,children:[!i&&(0,Y.jsx)(T,{className:`absolute top-2.5 -right-[11px] z-10 size-3.5 rounded-full bg-background text-muted-foreground/70`,"aria-hidden":!0}),(0,Y.jsxs)(`header`,{className:`flex min-h-10 shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5`,children:[l,(0,Y.jsx)(Be,{label:e,className:`ml-auto shrink-0`,children:t})]}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto p-2 scroll-thin`,children:a})]}):(0,Y.jsxs)(`section`,{"aria-labelledby":o,className:`rounded-xl border border-border bg-surface/60`,"data-testid":`factory-view-stage`,"data-stage":e,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 px-3 py-2.5 text-left`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[(0,Y.jsx)(_,{className:G(`size-3.5 text-muted-foreground transition-transform`,!s&&`-rotate-90`),"aria-hidden":!0}),l]}),s&&(0,Y.jsx)(`div`,{className:`px-2 pb-2`,children:a})]})}function ht({cards:e,now:t,onOpen:n,wide:r,projectId:i}){let a=(0,J.useId)();return e.length===0?(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 px-1 text-2xs text-muted-foreground`,children:[(0,Y.jsx)(w,{className:`size-3`,"aria-hidden":!0}),` Nothing waits on you.`,(0,Y.jsx)(K,{section:q.needsYou,className:`text-muted-foreground`,children:`What lands here?`})]}):(0,Y.jsxs)(`section`,{"aria-labelledby":a,className:G(`flex flex-col rounded-xl border border-status-waiting/40 bg-status-waiting/[0.04] p-2`,r&&`max-h-[min(34vh,20rem)] shrink-0`),"data-testid":`factory-view-needs-you`,children:[(0,Y.jsxs)(`h2`,{id:a,className:`mb-1.5 flex items-center gap-1.5 px-1 text-[12px] font-medium text-status-waiting`,children:[(0,Y.jsx)(w,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:ue}),(0,Y.jsx)(`span`,{className:`rounded-full bg-status-waiting/12 px-1.5 text-[10px] leading-4 tabular-nums`,children:e.length}),(0,Y.jsx)(`span`,{className:`hidden truncate font-normal text-muted-foreground sm:inline`,children:`Work only a person can move on: merge, retry or dismiss, answer, or approve a spec`}),(0,Y.jsx)(K,{section:q.needsYou,className:`ml-auto shrink-0 font-normal whitespace-nowrap`,children:`Why is this here?`})]}),(0,Y.jsx)(`ul`,{className:G(`grid gap-1.5`,r?`min-h-0 grid-cols-4 overflow-y-auto scroll-thin`:`grid-cols-1 sm:grid-cols-2`),"data-testid":`factory-view-needs-you-list`,children:e.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(rt,{card:e,now:t,onOpen:n,projectId:i})},e.item.id))})]})}function gt({f:e,pipeline:t,now:n,onOpen:r}){let i=de(),a=ft(t),o=e.mode===`dark_factory`?e.scout:null,s=e.ignored.length,c=e=>e===`intake`?+!!o:0;return(0,Y.jsxs)(`div`,{className:G(`flex min-h-0 flex-col gap-3`,i&&`flex-1`),children:[(0,Y.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,"data-testid":`factory-view-live`,children:a}),(0,Y.jsx)(ht,{cards:t.needsYou,now:n,onOpen:r,wide:i,projectId:e.projectId}),(0,Y.jsx)(`div`,{className:G(i?`grid min-h-[20rem] flex-1 grid-cols-[repeat(6,minmax(9rem,1fr))] gap-2 overflow-x-auto scroll-thin`:`flex flex-col gap-2`),"data-testid":`factory-view-pipeline`,children:A.map((a,l)=>{let u=t.stages[a.id];return(0,Y.jsx)(mt,{label:a.label,hint:a.hint,count:u.length+c(a.id),wide:i,last:l===A.length-1,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a.id===`intake`&&o&&(0,Y.jsx)(dt,{scout:o,projectId:e.projectId}),(0,Y.jsx)(pt,{cards:u,now:n,onOpen:r,empty:a.id===`intake`&&o?void 0:{text:`Nothing here`,guide:q[a.id]}}),a.id===`intake`&&s>0&&(0,Y.jsxs)(`p`,{className:`px-1 text-[10px] text-status-waiting`,title:`Issues from authors who aren't trusted. Let them in from the factory panel.`,children:[s,` ignored (untrusted authors)`]})]})},a.id)})})]})}function _t({bar:e}){let t=e.max>0?Math.min(100,e.value/e.max*100):0,n=e.warn?t>85?`bg-status-failed`:t>60?`bg-status-waiting`:`bg-primary`:`bg-status-running`;return(0,Y.jsx)(`span`,{className:`mt-1 block h-1 w-full overflow-hidden rounded-full bg-muted`,"aria-hidden":!0,children:(0,Y.jsx)(`span`,{className:G(`block h-full rounded-full`,n),style:{width:`${t}%`}})})}function vt({f:e}){let t=Ue(e);return(0,Y.jsx)(`dl`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 xl:grid-cols-6`,"aria-label":`Factory figures`,"data-testid":`factory-view-stats`,children:t.map(e=>(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3 py-2`,"data-stat":e.id,children:[(0,Y.jsx)(`dt`,{className:`truncate text-3xs tracking-wider text-muted-foreground uppercase`,children:e.label}),(0,Y.jsxs)(`dd`,{className:`mt-0.5 flex items-baseline gap-1.5`,children:[(0,Y.jsx)(`span`,{className:G(`shrink-0 text-[17px] leading-6 font-semibold whitespace-nowrap tabular-nums`,e.alert&&`text-status-failed`),children:e.value}),e.detail&&(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-2xs text-muted-foreground`,title:e.detail,children:e.detail})]}),e.note&&(0,Y.jsx)(`p`,{className:`truncate text-3xs text-muted-foreground`,title:e.note,children:e.note}),e.bar&&(0,Y.jsx)(_t,{bar:e.bar})]},e.id))})}function yt({tabs:e,focus:t,onFocus:n}){if(e.length===0)return null;let r=(e,t)=>{n(e),t?.querySelector(`[data-storey="${e}"]`)?.focus()};return(0,Y.jsx)(`div`,{role:`radiogroup`,"aria-label":`Storey`,className:`inline-flex items-center rounded-md border border-border bg-muted/40 p-0.5`,onKeyDown:n=>{let i=n.key===`ArrowRight`||n.key===`ArrowDown`?1:n.key===`ArrowLeft`||n.key===`ArrowUp`?-1:0;if(!i)return;n.preventDefault();let a=e[(e.findIndex(e=>e.id===t)+i+e.length)%e.length];r(a.id,n.currentTarget)},"data-testid":`factory-view-storeys`,children:e.map(e=>{let r=e.id===t;return(0,Y.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,"aria-label":`${e.label}: ${e.count} ${e.count===1?`agent`:`agents`}${e.waiting?`, someone waits on you`:``}`,tabIndex:r?0:-1,onClick:()=>n(e.id),"data-storey":e.id,"data-testid":`factory-view-storey-${e.id}`,className:G(`inline-flex h-7 items-center gap-1.5 rounded-[5px] px-2 text-xs font-medium text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,r&&`bg-background text-foreground shadow-sm`),children:[e.label,(0,Y.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-2xs tabular-nums`,children:e.count}),e.waiting&&(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-status-waiting`,"data-testid":`factory-view-storey-waiting`})]},e.id)})})}var Q=[{id:`board`,label:`Board`,title:`The pipeline as stages and cards`,icon:a},{id:`floor`,label:`Floor`,title:`Factory floor: a 3D workshop with every agent at its station`,icon:d}];function bt({view:e}){let t=(t,n)=>{e.set(t),n?.querySelector(`[data-mode="${t}"]`)?.focus()};return(0,Y.jsx)(`div`,{role:`radiogroup`,"aria-label":`Factory view mode`,className:`inline-flex items-center rounded-md border border-border bg-muted/40 p-0.5`,onKeyDown:n=>{let r=n.key===`ArrowRight`||n.key===`ArrowDown`?1:n.key===`ArrowLeft`||n.key===`ArrowUp`?-1:0;if(!r)return;n.preventDefault();let i=Q[(Q.findIndex(t=>t.id===e.mode)+r+Q.length)%Q.length];t(i.id,n.currentTarget)},"data-testid":`factory-view-mode`,children:Q.map(t=>{let n=t.id===e.mode,r=t.icon;return(0,Y.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n,tabIndex:n?0:-1,title:t.title,onClick:()=>e.set(t.id),"data-mode":t.id,"data-testid":`factory-view-mode-${t.id}`,className:G(`inline-flex h-7 items-center gap-1.5 rounded-[5px] px-2 text-xs font-medium text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5`,n&&`bg-background text-foreground shadow-sm`),children:[(0,Y.jsx)(r,{"aria-hidden":!0}),t.label]},t.id)})})}function xt(){let e=typeof document<`u`&&document.fullscreenEnabled===!0,[t,n]=(0,J.useState)(()=>!!document.fullscreenElement);return(0,J.useEffect)(()=>{let e=()=>n(!!document.fullscreenElement);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]),{supported:e,on:t,toggle:()=>{(document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen())?.catch(()=>H.error(`Full screen isn't available here`))}}}function St({f:e}){let t=e.killSwitch||e.globalKillSwitch||e.loopState===`stopped`,n=be[t?`stopped`:e.loopState],r=e.globalKillSwitch?`global kill switch`:e.killSwitch?`kill switch`:e.loopState===`paused`?e.pausedReason:null;return e.drain&&!t?(0,Y.jsx)(He,{f:e}):(0,Y.jsxs)(`span`,{className:G(`inline-flex max-w-full min-w-0 items-center gap-1 rounded-full px-2 py-0.5 text-2xs font-medium`,n.tone===`failed`&&`bg-status-failed/12 text-status-failed`,n.tone===`waiting`&&`bg-status-waiting/12 text-status-waiting`,n.tone===`running`&&`bg-status-running/12 text-status-running`,n.tone===`idle`&&`bg-muted text-muted-foreground`),"data-testid":`factory-view-loop`,title:r??void 0,children:[(0,Y.jsxs)(`span`,{className:`shrink-0`,children:[`Loop `,n.label.toLowerCase()]}),r&&(0,Y.jsxs)(`span`,{className:`truncate font-normal`,children:[`· `,r]})]})}function Ct({n:e,label:t,tone:n,icon:r}){return(0,Y.jsxs)(`span`,{className:G(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-2xs tabular-nums`,e===0&&`border-border text-muted-foreground`,e>0&&n===`waiting`&&`border-status-waiting/40 bg-status-waiting/10 text-status-waiting`,e>0&&n===`failed`&&`border-status-failed/40 bg-status-failed/10 text-status-failed`),"data-testid":`factory-view-count-${n}`,children:[r,(0,Y.jsx)(`span`,{className:`font-semibold`,children:e}),` `,t]})}function wt({project:e,f:t,needsPerson:i,failed:a,view:o,storeys:s}){let c=n(),l=ze(),d=xt(),f=t.killSwitch||t.globalKillSwitch||t.loopState===`stopped`,p=W({mutationFn:()=>c.factory.resume(t.projectId),onSuccess:()=>{H.success(`Loop resumed`),l.invalidateQueries({queryKey:Ae.all})},onError:e=>H.error(`Couldn't resume`,{description:e.message})});return(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-4 py-2.5`,"data-testid":`factory-view-header`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary/12 text-primary`,children:(0,Y.jsx)(u,{className:`size-4`,"aria-hidden":!0})}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h1`,{className:`truncate text-[15px] leading-tight font-semibold`,children:e.name}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-2xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:ve[t.mode]}),t.experimental&&(0,Y.jsx)(Ge,{})]})]})]}),(0,Y.jsx)(St,{f:t}),(0,Y.jsx)(Ke,{f:t}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Ct,{n:i,label:`need you`,tone:`waiting`,icon:(0,Y.jsx)(w,{className:`size-3`,"aria-hidden":!0})}),(0,Y.jsx)(Ct,{n:a,label:`failed`,tone:`failed`,icon:(0,Y.jsx)(y,{className:`size-3`,"aria-hidden":!0})})]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-1`,children:[t.loopState===`paused`&&!f&&!t.drain&&(0,Y.jsxs)(U,{size:`sm`,onClick:()=>p.mutate(),disabled:p.isPending,children:[(0,Y.jsx)(C,{}),` Resume`]}),(0,Y.jsx)(We,{f:t,stopped:f}),(0,Y.jsx)(Je,{scope:{projectId:t.projectId},on:t.killSwitch,drain:t.drain,paused:t.loopState===`paused`}),(0,Y.jsx)(Ve,{}),s,o.available&&(0,Y.jsx)(bt,{view:o}),d.supported&&(0,Y.jsxs)(U,{size:`sm`,variant:`ghost`,onClick:d.toggle,"aria-label":d.on?`Exit full screen`:`Full screen`,"data-testid":`factory-view-fullscreen`,children:[d.on?(0,Y.jsx)(te,{}):(0,Y.jsx)(v,{}),(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:d.on?`Exit full screen`:`Full screen`})]}),(0,Y.jsx)(U,{size:`sm`,variant:`ghost`,asChild:!0,children:(0,Y.jsxs)(r,{to:`/projects/$projectId`,params:{projectId:t.projectId},onClick:()=>d.on&&void document.exitFullscreen().catch(()=>{}),"data-testid":`factory-view-exit`,children:[(0,Y.jsx)(b,{}),` `,(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:`Exit`}),(0,Y.jsx)(`span`,{className:`sr-only sm:hidden`,children:`Exit the factory view`})]})})]})]})}var Tt=`codeden.factoryView.mode`;function Et(e){return e===`floor`||e===`pixel`?`floor`:`board`}function Dt(){let[e,t]=(0,J.useState)(()=>Et(localStorage.getItem(Tt)));return{available:!0,mode:e,set:e=>{localStorage.setItem(Tt,e),t(e)}}}var Ot=`codeden.factoryView.chat`,kt=[],At=[];function jt(e){let t=new Set;for(let n of[...e.backlog,...e.inProgress,...e.viewRecent,...e.recent])for(let e of[n.activeSessionId,n.sessionId,n.reviewerSessionId])e&&t.add(e);let n=e.mode===`dark_factory`?e.scout:null;n?.sessionId&&t.add(n.sessionId);for(let e of n?.lenses??[])t.add(e.sessionId);return[...t]}function Mt(){let[e,t]=(0,J.useState)(()=>localStorage.getItem(Ot)!==`closed`);return[e,e=>{localStorage.setItem(Ot,e?`open`:`closed`),t(e)}]}function $({children:e}){return(0,Y.jsx)(`div`,{className:`flex h-dvh flex-col overflow-hidden bg-background text-foreground`,children:e})}function Nt({projectId:e}){let{data:n}=Me(),a=Le(e),o=a?t(a.autonomyMode):!1,{data:s}=ke(e,o),c=je(e=>e.sessions,kt),l=Ie((0,J.useMemo)(()=>s?jt(s):[],[s])),d=je(e=>e.runner.providers,At),p=(0,J.useMemo)(()=>{let e=new Map(d.map(e=>[e.id,e.displayName]));return new Map([...c,...l.values()].map(t=>[t.id,{status:t.status,progress:t.progress?.text??null,progressAt:t.progress?.at??null,provider:e.get(t.provider)??t.provider,providerId:t.provider,model:t.model,workKey:t.workKey}]))},[c,l,d]),m=ie(),h=(0,J.useMemo)(()=>s?se(s,p,m):null,[s,p,m]),g=Xe(`pm`,e)?.id??null,_=s?.mode===`dark_factory`&&!!s.scout,v=!ne(),[ee,y]=(0,J.useState)(null),b=(0,J.useMemo)(()=>s&&h&&_?oe(le({f:s,pipeline:h,sessions:p,pmSessionId:g}),_,v):[],[s,h,p,g,_,v]),x=ce(ee,_,v),S=de(),C=ae(),[w,T]=Mt(),[te,E]=(0,J.useState)(!1),D=Dt(),[O,A]=(0,J.useState)(!1),j=D.mode===`floor`&&!O,M=j,[N,P]=(0,J.useState)(!1),ue=C?{docked:!0,open:w,setOpen:T}:{docked:!1,open:N,setOpen:P},[F,I]=(0,J.useState)(null),L=(0,J.useMemo)(()=>!F||!h?F:[...Object.values(h.stages).flat(),...h.needsYou].find(e=>e.item.id===F.item.id)??F,[F,h]);return n?a?o?!s||!h?(0,Y.jsxs)($,{children:[(0,Y.jsx)(`div`,{className:`h-14 border-b border-border`}),(0,Y.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,Y.jsx)(V,{className:`h-16 w-full rounded-xl`}),(0,Y.jsx)(V,{className:`h-96 w-full rounded-xl`})]})]}):(0,Y.jsx)($,{children:(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`factory-view`,children:[(0,Y.jsx)(wt,{project:a,f:s,needsPerson:h.needsPerson,failed:h.failed,view:D,storeys:j?(0,Y.jsx)(yt,{tabs:b,focus:x,onFocus:y}):void 0}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[M?(0,Y.jsx)(`main`,{className:S?`flex min-h-0 min-w-0 flex-1 flex-col p-3`:`flex min-h-0 min-w-0 flex-1 flex-col p-3 pb-16`,children:(0,Y.jsx)(Ye,{f:s,pipeline:h,sessions:p,projectId:e,now:m,onOpen:I,chat:ue,focus:x,onUnsupported:()=>A(!0)})}):(0,Y.jsxs)(`main`,{className:S?`flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-y-auto p-3 scroll-thin`:`flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-y-auto p-3 pb-20`,children:[D.mode===`floor`&&O&&(0,Y.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,"data-testid":`factory-view-floor-unsupported`,children:`Factory floor needs WebGL; showing the board.`}),(0,Y.jsx)(vt,{f:s}),(0,Y.jsx)(gt,{f:s,pipeline:h,now:m,onOpen:I})]}),C&&w&&!M&&(0,Y.jsx)(`aside`,{className:`flex w-[340px] shrink-0 flex-col border-l border-border bg-surface/40 2xl:w-[400px]`,"aria-label":`Project manager chat`,children:(0,Y.jsx)(re,{projectId:e,onCollapse:()=>T(!1)})}),S&&!(C&&(w||M))&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>M?P(!0):C?T(!0):E(!0),className:`flex w-10 shrink-0 flex-col items-center gap-2 border-l border-border py-3 text-2xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,"aria-label":`Show the PM chat`,"data-testid":`factory-view-chat-show`,children:[(0,Y.jsx)(i,{className:`size-4 text-primary`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`[writing-mode:vertical-rl]`,children:`PM chat`})]})]}),!S&&(0,Y.jsxs)(U,{className:`fixed right-4 bottom-4 z-10 rounded-full shadow-lg`,onClick:()=>M?P(!0):E(!0),"data-testid":`factory-view-chat-open`,children:[(0,Y.jsx)(f,{}),` PM chat`]}),!C&&!M&&(0,Y.jsx)(Ce,{open:te,onOpenChange:E,children:(0,Y.jsxs)(De,{side:S?`right`:`bottom`,showCloseButton:!1,className:`gap-0 p-0 data-[side=bottom]:h-[85dvh] data-[side=bottom]:rounded-t-2xl data-[side=right]:w-[min(26rem,90vw)] data-[side=right]:sm:max-w-none`,children:[(0,Y.jsx)(Ee,{className:`sr-only`,children:`Project manager chat`}),(0,Y.jsx)(we,{className:`sr-only`,children:`The latest messages with this project's PM`}),(0,Y.jsx)(re,{projectId:e,onCollapse:()=>E(!1)})]})}),(0,Y.jsx)(lt,{projectId:e,card:L,onClose:()=>I(null)})]})}):(0,Y.jsx)($,{children:(0,Y.jsxs)(k,{icon:(0,Y.jsx)(u,{}),title:`Not a factory project`,className:`flex-1`,action:(0,Y.jsx)(U,{size:`sm`,variant:`outline`,asChild:!0,children:(0,Y.jsx)(r,{to:`/projects/$projectId`,params:{projectId:e},children:`Back to the project`})}),children:[a.name,` isn't in software factory or dark factory mode, so there's no factory to show.`]})}):(0,Y.jsx)($,{children:(0,Y.jsx)(k,{icon:(0,Y.jsx)(u,{}),title:`Project not found`,className:`flex-1`,children:(0,Y.jsx)(r,{to:`/`,className:`text-primary hover:underline`,children:`Back to CodeDen`})})}):(0,Y.jsx)($,{children:(0,Y.jsx)(V,{className:`m-6 h-72 rounded-xl`})})}export{Nt as FactoryViewPage};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Z as t,i as n}from"./api-yvn34iKU.js";import{L as r}from"./dropdown-menu-Bflkx6wY.js";import{Cr as i,Gt as a,Ht as o,In as s,Jn as c,P as l,Rn as u,Sr as d,Tt as f,Vn as p,Z as m,ar as h,cn as g,fr as _,jt as v,kt as ee,m as y,n as b,pr as x,q as S,rt as C,u as w,ur as T,xt as te}from"./icons-COCLuOtb.js";import{n as E,t as D}from"./jsx-runtime-C3cWAN_r.js";import{o as O,t as k}from"./bits-B2GRjm37.js";import{_ as ne,a as re,c as A,d as j,f as M,g as ie,h as ae,i as oe,l as N,m as se,n as ce,o as le,p as P,s as ue,u as F,v as de}from"./storeys-BEgFUsix.js";import{c as I,d as L,l as fe,n as pe,o as R,s as z,t as me,u as he}from"./item-parts-DZ3TQad4.js";import{C as ge,_ as _e,c as ve,d as B,n as ye,o as be,t as xe,v as Se}from"./use-retry-item-3n4BD_3J.js";import{A as Ce,M as we,N as Te,P as Ee,j as De}from"./mobile-nav-CrjrDJZ5.js";import{t as V}from"./skeleton-D8Sbd2jT.js";import{i as Oe,o as ke,t as Ae}from"./factory-DVCs5zxg.js";import{D as je,E as Me,f as Ne,j as H,m as U,n as Pe,t as Fe,w as Ie,y as Le,yt as W}from"./format-D3kairnQ.js";import{o as Re}from"./switch-BHplnCdo.js";import{t as G}from"./dist-wxbqfqV1.js";import{F as ze}from"./useQuery-VSotSwry.js";import{i as Be}from"./form-bits-5XojWhBG.js";import{i as K,o as q,r as Ve}from"./remote-check-CQktPgyp.js";import{i as He,l as Ue,n as We,s as Ge,t as Ke,u as qe}from"./wip-chip-DXwuAo3A.js";import{t as Je}from"./kill-switch-BDAFCjui.js";import{i as Ye}from"./on-demand-Cvi90jRi.js";import{r as Xe}from"./role-chat-nIyzM-vQ.js";var J=e(E(),1),Y=D(),Ze=Object.fromEntries(Object.entries(B).map(([e,t])=>[e,t.label])),Qe={bug:`bg-status-failed/10 text-status-failed`,feature:`bg-primary/10 text-primary`,docs:`bg-muted text-muted-foreground`};function $e({type:e,fit:t=!1}){if(!e)return null;let n=e===`docs`?`Docs`:Se[e];return(0,Y.jsx)(`span`,{className:G(`min-w-0 truncate rounded px-1 text-[10px] leading-4 font-medium`,Qe[e]),title:Se[e],children:e===`feature`&&t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`@[9.5rem]:hidden`,children:`Feat`}),(0,Y.jsx)(`span`,{className:`hidden @[9.5rem]:inline`,children:n})]}):n})}function et({state:e,className:t}){return e===`person`?(0,Y.jsx)(w,{className:G(`size-3 shrink-0 text-status-waiting`,t),"aria-hidden":!0}):e===`failed`?(0,Y.jsx)(y,{className:G(`size-3 shrink-0 text-status-failed`,t),"aria-hidden":!0}):(0,Y.jsx)(`span`,{"aria-hidden":!0,className:G(`inline-block size-2 shrink-0 rounded-full`,e===`running`?`bg-status-running motion-safe:animate-pulse`:`bg-status-idle/70 ring-2 ring-status-idle/20`,t)})}function X({tone:e,title:t,testId:n,children:r}){return(0,Y.jsx)(`span`,{title:t,"data-testid":n,className:G(`inline-flex shrink-0 items-center gap-0.5 rounded-full border px-1.5 text-[10px] leading-4`,e===`person`&&`border-status-waiting/40 text-status-waiting`,e===`failed`&&`border-status-failed/40 text-status-failed`,!e&&`border-border text-muted-foreground`),children:r})}function tt({card:e,now:t,onOpen:n,className:r}){let i=e.item,a=N(i),s=P(e.pr,Ze),u=e.place===`reviewing`||e.place===`merge`?i.checks:null,d=he(i.cost)?i.cost:null,f=Fe(e.since,t);return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(e),"aria-label":`${a} ${i.title}, ${F(e)}${d?`, cost ${I(d)}`:``}`,"data-testid":`factory-view-card`,"data-state":e.state,className:G(`group @container w-full animate-rise rounded-lg border bg-card px-2.5 py-2 text-left shadow-xs transition-colors hover:border-primary/50 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,e.state===`person`&&`border-status-waiting/50 bg-status-waiting/[0.05]`,e.state===`failed`&&`border-status-failed/50 bg-status-failed/[0.05]`,e.state!==`person`&&e.state!==`failed`&&`border-border`,r),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 overflow-hidden`,children:[(0,Y.jsx)(et,{state:e.state}),(0,Y.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:a}),(0,Y.jsx)($e,{type:i.type,fit:!0}),i.trust===`admitted`&&(0,Y.jsx)(l,{className:`size-3 shrink-0 text-status-waiting`,"aria-label":`Let in from an untrusted author`}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-muted-foreground tabular-nums`,title:`In this step since ${new Date(e.since).toLocaleString()}`,children:f===`now`?`just now`:f})]}),(0,Y.jsx)(`div`,{className:`mt-1 line-clamp-2 text-[12.5px] leading-snug font-medium`,children:i.title}),(i.attempts>0||s||u||d)&&(0,Y.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:[i.attempts>0&&(0,Y.jsxs)(X,{tone:`person`,title:`Revise round ${i.attempts}`,children:[(0,Y.jsx)(S,{className:`size-2.5`,"aria-hidden":!0}),` `,i.attempts]}),s&&(0,Y.jsx)(X,{tone:e.pr?.state===`stuck`||e.pr?.state===`waiting_for_you`?`person`:void 0,children:s}),u&&(0,Y.jsxs)(X,{tone:u.failed>0?`failed`:void 0,title:`${u.passed} of ${u.total} merge checks passed${u.failed?`, ${u.failed} failed`:``}`,children:[(0,Y.jsx)(o,{className:`size-2.5`,"aria-hidden":!0}),` `,u.passed,`/`,u.total]}),d&&(0,Y.jsxs)(X,{tone:L(d)?`person`:void 0,title:[fe(d),z(d)&&`Spend cap: ${z(d)}`].filter(Boolean).join(` · `),testId:`factory-view-card-cost`,children:[(0,Y.jsx)(c,{className:`size-2.5`,"aria-hidden":!0}),` `,I(d)]})]}),(0,Y.jsx)(`div`,{className:`mt-0.5 truncate text-2xs text-muted-foreground`,children:e.activity})]})}function nt({card:e,projectId:t,className:i}){let a=n(),o=ze(),c=e.need,l=N(e.item),u=()=>void o.invalidateQueries({queryKey:Ae.all}),d=xe(t,e.item.id),f=W({mutationFn:()=>a.factory.dismiss(t,e.item.id),onSuccess:()=>{H.success(`${l} dismissed`),u()},onError:e=>H.error(`Couldn't dismiss`,{description:e.message})});if(!c)return null;let m=d.isPending||f.isPending,h=e.pr?.pr.url??e.item.ownedPr?.url??e.item.pr?.url??null;return(0,Y.jsxs)(`div`,{className:G(`flex flex-wrap items-center gap-1`,i),"data-testid":`factory-view-need`,"data-need":c.kind,children:[(0,Y.jsx)(`span`,{className:`mr-auto min-w-0 text-2xs font-medium text-status-waiting`,children:c.label}),c.kind===`merge`&&h&&(0,Y.jsxs)(U,{size:`xs`,variant:`outline`,onClick:()=>Re.openExternal(h),children:[(0,Y.jsx)(p,{}),` Open PR`]}),(c.kind===`retry`||c.kind===`retry_or_dismiss`)&&(0,Y.jsxs)(U,{size:`xs`,variant:`outline`,onClick:()=>d.mutate(),disabled:m,"aria-label":`Retry ${l}`,children:[(0,Y.jsx)(S,{}),` Retry`]}),c.kind===`retry_or_dismiss`&&(0,Y.jsxs)(U,{size:`xs`,variant:`ghost`,onClick:()=>f.mutate(),disabled:m,"aria-label":`Dismiss ${l}`,children:[(0,Y.jsx)(b,{}),` Dismiss`]}),c.kind===`answer`&&e.sessionId&&(0,Y.jsx)(U,{size:`xs`,variant:`outline`,asChild:!0,children:(0,Y.jsxs)(r,{to:`/sessions/$sessionId`,params:{sessionId:e.sessionId},children:[(0,Y.jsx)(ee,{}),` Answer`]})}),c.kind===`approve_spec`&&(0,Y.jsx)(U,{size:`xs`,variant:`outline`,asChild:!0,children:(0,Y.jsxs)(r,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:t,itemId:e.item.id},"aria-label":`Review the spec of ${l}`,children:[(0,Y.jsx)(s,{}),` Review spec`]})})]})}function rt({card:e,now:t,onOpen:n,projectId:r}){return(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsx)(tt,{card:e,now:t,onOpen:n,className:`rounded-b-none border-b-0 shadow-none`}),(0,Y.jsx)(nt,{card:e,projectId:r,className:G(`rounded-b-lg border px-2.5 py-1.5`,e.state===`failed`?`border-status-failed/50 bg-status-failed/[0.05]`:`border-status-waiting/50 bg-status-waiting/[0.05]`)})]})}var it={bug:[`intake`,`reproduce`,`implement`,`review`,`merge`],feature:[`intake`,`analyze`,`implement`,`review`,`merge`],docs:[`intake`,`implement`,`review`,`merge`]};function at(e){let t=it[e.type??`feature`],n,r=null;return e.stage===`merged`||e.step===`done`?n=t.length:e.stage===`watching`?(n=t.indexOf(`merge`),r=`Merged; watching CI on the default branch`):e.step===`queued`?(n=1,r=`Waiting for a free agent`):n=e.step===`stopped`||e.step===`ignored`?-1:t.indexOf(e.step),t.map((e,t)=>{let i=n===-1?`next`:t<n?`done`:t===n?`current`:`next`;return{step:e,mark:i,note:i===`current`?r:null}})}function ot({item:e,card:t}){let n=at({type:e.type,step:t.item.step,stage:t.item.stage});return(0,Y.jsx)(`ol`,{className:`flex flex-col gap-1`,"aria-label":`Pipeline steps`,children:n.map(({step:t,mark:n,note:r})=>(0,Y.jsxs)(`li`,{className:G(`flex items-center gap-2 rounded-md px-2 py-1 text-[12.5px]`,n===`current`&&`bg-primary/10 font-medium text-foreground`,n===`next`&&`text-muted-foreground`),"aria-current":n===`current`?`step`:void 0,children:[n===`done`?(0,Y.jsx)(x,{className:`size-3.5 text-status-done`,"aria-hidden":!0}):(0,Y.jsx)(`span`,{"aria-hidden":!0,className:G(`mx-[3px] size-2 rounded-full`,n===`current`?`bg-primary`:`border border-muted-foreground/50`)}),(0,Y.jsxs)(`span`,{children:[ge(t,e.type),r&&(0,Y.jsx)(`span`,{className:`block text-2xs font-normal text-muted-foreground`,children:r})]}),n===`current`&&(0,Y.jsx)(`span`,{className:`sr-only`,children:`(current step)`})]},t))})}function Z({label:e,children:t}){return(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-right`,children:t})]})}function st({url:e,children:t}){return(0,Y.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-primary hover:underline`,onClick:()=>Re.openExternal(e),children:t})}function ct({projectId:e,card:t}){let{data:n,error:i}=Oe(e,t.item.id);if(i)return(0,Y.jsx)(`p`,{className:`px-4 text-2xs text-muted-foreground`,children:i.message});if(!n)return(0,Y.jsx)(V,{className:`mx-4 h-48 rounded-xl`});let{item:a}=n,o=n.cost??t.item.cost,s=z(o),c=a.checks.filter(e=>e.state===`pass`).length,l=a.pr??t.pr?.pr??t.item.ownedPr;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5 px-4 pb-6`,children:[(a.reason||t.activity)&&(0,Y.jsx)(`p`,{className:G(`rounded-lg border px-3 py-2 text-2xs`,t.state===`failed`?`border-status-failed/30 bg-status-failed/[0.06]`:t.state===`person`?`border-status-waiting/30 bg-status-waiting/[0.06]`:`border-border bg-surface`),children:t.activity}),t.need&&(0,Y.jsx)(nt,{card:t,projectId:e,className:`rounded-lg border border-status-waiting/30 bg-status-waiting/[0.06] px-3 py-2`}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(O,{className:`mb-1.5`,children:`Steps`}),(0,Y.jsx)(ot,{item:a,card:t})]}),(0,Y.jsxs)(`section`,{className:`space-y-2 rounded-xl border border-border bg-card p-3`,children:[(0,Y.jsx)(Z,{label:`Issue`,children:a.issue?(0,Y.jsxs)(st,{url:a.issue.url,children:[(0,Y.jsx)(h,{className:`size-3`}),`#`,a.issue.number]}):`—`}),(0,Y.jsx)(Z,{label:!a.pr&&l?`Pull request (rebuilt)`:`Pull request`,children:l?(0,Y.jsxs)(st,{url:l.url,children:[(0,Y.jsx)(g,{className:`size-3`}),`#`,l.number,t.pr?.pr.number===l.number?` · ${B[t.pr.state].label}`:` · ${l.state}`]}):`—`}),(0,Y.jsx)(Z,{label:`Builder`,children:(0,Y.jsx)(R,{id:a.builderSessionId,label:a.builderProvider??`session`})}),(0,Y.jsx)(Z,{label:`Reviewer`,children:(0,Y.jsx)(R,{id:a.reviewerSessionId,label:a.reviewerProvider??`session`})}),(0,Y.jsx)(Z,{label:`Stage`,children:_e[a.stage].label}),a.attempts>0&&(0,Y.jsx)(Z,{label:`Revise rounds`,children:a.attempts}),(0,Y.jsx)(Z,{label:`Cost`,children:(0,Y.jsx)(pe,{cost:o})}),s&&(0,Y.jsx)(Z,{label:`Spend cap`,children:s}),(0,Y.jsx)(Z,{label:`In this step`,children:Pe(t.since)})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(O,{className:`mb-1.5`,children:[`Merge checks`,a.checks.length>0&&` · ${c} of ${a.checks.length} passed`]}),a.checks.length===0?(0,Y.jsx)(`p`,{className:`text-2xs text-muted-foreground`,children:a.pr?`No merge checks recorded yet.`:`Checks run once the builder opens a pull request.`}):(0,Y.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card`,children:a.checks.map(e=>(0,Y.jsx)(me,{check:e},e.name))})]}),a.review&&(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(O,{className:`mb-1.5`,children:`Review`}),(0,Y.jsxs)(`p`,{className:`text-2xs leading-relaxed`,children:[(0,Y.jsx)(`span`,{className:`font-medium capitalize`,children:a.review.verdict.replace(`_`,` `)}),` · `,a.review.summary.length>400?`${a.review.summary.slice(0,400)}…`:a.review.summary]})]}),(0,Y.jsxs)(r,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:e,itemId:a.id},className:`inline-flex items-center gap-1 text-2xs text-primary hover:underline`,children:[(0,Y.jsx)(p,{className:`size-3`}),` Open the full item page`]})]})}function lt({projectId:e,card:t,onClose:n}){return(0,Y.jsx)(Ce,{open:t!==null,onOpenChange:e=>!e&&n(),children:(0,Y.jsx)(De,{side:`right`,className:`gap-0 overflow-y-auto scroll-thin data-[side=right]:w-full data-[side=right]:sm:max-w-md`,"data-testid":`factory-view-sheet`,children:t&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Te,{className:`pb-3`,children:[(0,Y.jsxs)(Ee,{className:`flex items-start gap-2 pr-6 text-[15px] leading-snug`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 font-mono whitespace-nowrap text-muted-foreground`,children:N(t.item)}),(0,Y.jsx)(`span`,{children:t.item.title})]}),(0,Y.jsxs)(we,{className:`flex items-center gap-1.5 text-2xs`,children:[(0,Y.jsx)(et,{state:t.state}),F(t),(0,Y.jsx)($e,{type:t.item.type})]})]}),(0,Y.jsx)(ct,{projectId:e,card:t})]})})})}var ut={idle:`Idle`,planning:`Planning the round`,reviewing:`Area reviewers at work`,filing:`Filing issues`};function dt({scout:e,projectId:t}){let n=e.phase!==`idle`;return(0,Y.jsxs)(`div`,{className:G(`rounded-lg border border-dashed px-2.5 py-2 text-2xs`,n?`border-primary/40 bg-primary/[0.04]`:`border-border`),"data-testid":`factory-view-scout`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(m,{className:G(`size-3.5`,n?`text-primary`:`text-muted-foreground`)}),e.sessionId?(0,Y.jsx)(r,{to:`/sessions/$sessionId`,params:{sessionId:e.sessionId},className:`text-[12px] font-medium hover:underline`,children:`Scout`}):(0,Y.jsx)(`span`,{className:`text-[12px] font-medium`,children:`Scout`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:n?`round ${e.rounds}`:`${e.rounds} rounds`})]}),(0,Y.jsxs)(`div`,{className:`mt-0.5 text-muted-foreground`,children:[ut[e.phase],n&&` · ${e.findings} found · ${e.filed} filed`,!n&&e.nextRoundAt&&` · next ${Ne(e.nextRoundAt)}`]}),e.lenses.length>0&&(0,Y.jsx)(`ul`,{className:`mt-1.5 flex flex-wrap gap-1`,"aria-label":`Area reviewers`,children:e.lenses.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(r,{to:`/sessions/$sessionId`,params:{sessionId:e.sessionId},className:`flex items-center gap-1 rounded-full border border-border bg-surface px-1.5 text-[10px] leading-4 hover:border-primary/50`,title:e.reported?`Reported its findings`:e.active?`Reviewing now`:`Waiting to start`,children:[e.reported?(0,Y.jsx)(x,{className:`size-2.5 text-status-done`}):(0,Y.jsx)(`span`,{className:G(`size-1.5 rounded-full`,e.active?`bg-status-running motion-safe:animate-pulse`:`bg-status-idle`)}),ye[e.area]]})},e.area))}),(0,Y.jsx)(qe,{projectId:t,held:e.heldFollowUps,className:`mt-1 block`})]})}function ft(e){let t=(0,J.useRef)(null),[n,r]=(0,J.useState)(``);return(0,J.useEffect)(()=>{let n=t.current;if(t.current=M(e),!n)return;let i=j(n,e);i.length!==0&&r(i.length>4?`${i.slice(0,4).join(` `)} And ${i.length-4} more.`:i.join(` `))},[e]),n}function pt({cards:e,now:t,onOpen:n,empty:r}){return e.length===0?r?(0,Y.jsxs)(`p`,{className:`px-1 py-2 text-2xs text-muted-foreground/70`,children:[r.text,` ·`,` `,(0,Y.jsx)(K,{section:r.guide,className:`text-muted-foreground`,children:`how it works`})]}):null:(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(tt,{card:e,now:t,onOpen:n})},e.item.id))})}function mt({label:e,hint:t,count:n,wide:r,last:i,children:a}){let o=(0,J.useId)(),[s,c]=(0,J.useState)(n>0),l=(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{id:o,className:`text-[12px] leading-tight font-medium`,children:e}),(0,Y.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-[10px] leading-4 text-muted-foreground tabular-nums`,children:n})]});return r?(0,Y.jsxs)(`section`,{"aria-labelledby":o,className:`relative flex min-h-0 min-w-0 flex-col rounded-xl border border-border bg-surface/60`,"data-testid":`factory-view-stage`,"data-stage":e,children:[!i&&(0,Y.jsx)(T,{className:`absolute top-2.5 -right-[11px] z-10 size-3.5 rounded-full bg-background text-muted-foreground/70`,"aria-hidden":!0}),(0,Y.jsxs)(`header`,{className:`flex min-h-10 shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5`,children:[l,(0,Y.jsx)(Be,{label:e,className:`ml-auto shrink-0`,children:t})]}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto p-2 scroll-thin`,children:a})]}):(0,Y.jsxs)(`section`,{"aria-labelledby":o,className:`rounded-xl border border-border bg-surface/60`,"data-testid":`factory-view-stage`,"data-stage":e,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 px-3 py-2.5 text-left`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[(0,Y.jsx)(_,{className:G(`size-3.5 text-muted-foreground transition-transform`,!s&&`-rotate-90`),"aria-hidden":!0}),l]}),s&&(0,Y.jsx)(`div`,{className:`px-2 pb-2`,children:a})]})}function ht({cards:e,now:t,onOpen:n,wide:r,projectId:i}){let a=(0,J.useId)();return e.length===0?(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 px-1 text-2xs text-muted-foreground`,children:[(0,Y.jsx)(w,{className:`size-3`,"aria-hidden":!0}),` Nothing waits on you.`,(0,Y.jsx)(K,{section:q.needsYou,className:`text-muted-foreground`,children:`What lands here?`})]}):(0,Y.jsxs)(`section`,{"aria-labelledby":a,className:G(`flex flex-col rounded-xl border border-status-waiting/40 bg-status-waiting/[0.04] p-2`,r&&`max-h-[min(34vh,20rem)] shrink-0`),"data-testid":`factory-view-needs-you`,children:[(0,Y.jsxs)(`h2`,{id:a,className:`mb-1.5 flex items-center gap-1.5 px-1 text-[12px] font-medium text-status-waiting`,children:[(0,Y.jsx)(w,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:ue}),(0,Y.jsx)(`span`,{className:`rounded-full bg-status-waiting/12 px-1.5 text-[10px] leading-4 tabular-nums`,children:e.length}),(0,Y.jsx)(`span`,{className:`hidden truncate font-normal text-muted-foreground sm:inline`,children:`Work only a person can move on: merge, retry or dismiss, answer, or approve a spec`}),(0,Y.jsx)(K,{section:q.needsYou,className:`ml-auto shrink-0 font-normal whitespace-nowrap`,children:`Why is this here?`})]}),(0,Y.jsx)(`ul`,{className:G(`grid gap-1.5`,r?`min-h-0 grid-cols-4 overflow-y-auto scroll-thin`:`grid-cols-1 sm:grid-cols-2`),"data-testid":`factory-view-needs-you-list`,children:e.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(rt,{card:e,now:t,onOpen:n,projectId:i})},e.item.id))})]})}function gt({f:e,pipeline:t,now:n,onOpen:r}){let i=de(),a=ft(t),o=e.mode===`dark_factory`?e.scout:null,s=e.ignored.length,c=e=>e===`intake`?+!!o:0;return(0,Y.jsxs)(`div`,{className:G(`flex min-h-0 flex-col gap-3`,i&&`flex-1`),children:[(0,Y.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,"data-testid":`factory-view-live`,children:a}),(0,Y.jsx)(ht,{cards:t.needsYou,now:n,onOpen:r,wide:i,projectId:e.projectId}),(0,Y.jsx)(`div`,{className:G(i?`grid min-h-[20rem] flex-1 grid-cols-[repeat(6,minmax(9rem,1fr))] gap-2 overflow-x-auto scroll-thin`:`flex flex-col gap-2`),"data-testid":`factory-view-pipeline`,children:A.map((a,l)=>{let u=t.stages[a.id];return(0,Y.jsx)(mt,{label:a.label,hint:a.hint,count:u.length+c(a.id),wide:i,last:l===A.length-1,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a.id===`intake`&&o&&(0,Y.jsx)(dt,{scout:o,projectId:e.projectId}),(0,Y.jsx)(pt,{cards:u,now:n,onOpen:r,empty:a.id===`intake`&&o?void 0:{text:`Nothing here`,guide:q[a.id]}}),a.id===`intake`&&s>0&&(0,Y.jsxs)(`p`,{className:`px-1 text-[10px] text-status-waiting`,title:`Issues from authors who aren't trusted. Let them in from the factory panel.`,children:[s,` ignored (untrusted authors)`]})]})},a.id)})})]})}function _t({bar:e}){let t=e.max>0?Math.min(100,e.value/e.max*100):0,n=e.warn?t>85?`bg-status-failed`:t>60?`bg-status-waiting`:`bg-primary`:`bg-status-running`;return(0,Y.jsx)(`span`,{className:`mt-1 block h-1 w-full overflow-hidden rounded-full bg-muted`,"aria-hidden":!0,children:(0,Y.jsx)(`span`,{className:G(`block h-full rounded-full`,n),style:{width:`${t}%`}})})}function vt({f:e}){let t=Ue(e);return(0,Y.jsx)(`dl`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 xl:grid-cols-6`,"aria-label":`Factory figures`,"data-testid":`factory-view-stats`,children:t.map(e=>(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3 py-2`,"data-stat":e.id,children:[(0,Y.jsx)(`dt`,{className:`truncate text-3xs tracking-wider text-muted-foreground uppercase`,children:e.label}),(0,Y.jsxs)(`dd`,{className:`mt-0.5 flex items-baseline gap-1.5`,children:[(0,Y.jsx)(`span`,{className:G(`shrink-0 text-[17px] leading-6 font-semibold whitespace-nowrap tabular-nums`,e.alert&&`text-status-failed`),children:e.value}),e.detail&&(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-2xs text-muted-foreground`,title:e.detail,children:e.detail})]}),e.note&&(0,Y.jsx)(`p`,{className:`truncate text-3xs text-muted-foreground`,title:e.note,children:e.note}),e.bar&&(0,Y.jsx)(_t,{bar:e.bar})]},e.id))})}function yt({tabs:e,focus:t,onFocus:n}){if(e.length===0)return null;let r=(e,t)=>{n(e),t?.querySelector(`[data-storey="${e}"]`)?.focus()};return(0,Y.jsx)(`div`,{role:`radiogroup`,"aria-label":`Storey`,className:`inline-flex items-center rounded-md border border-border bg-muted/40 p-0.5`,onKeyDown:n=>{let i=n.key===`ArrowRight`||n.key===`ArrowDown`?1:n.key===`ArrowLeft`||n.key===`ArrowUp`?-1:0;if(!i)return;n.preventDefault();let a=e[(e.findIndex(e=>e.id===t)+i+e.length)%e.length];r(a.id,n.currentTarget)},"data-testid":`factory-view-storeys`,children:e.map(e=>{let r=e.id===t;return(0,Y.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,"aria-label":`${e.label}: ${e.count} ${e.count===1?`agent`:`agents`}${e.waiting?`, someone waits on you`:``}`,tabIndex:r?0:-1,onClick:()=>n(e.id),"data-storey":e.id,"data-testid":`factory-view-storey-${e.id}`,className:G(`inline-flex h-7 items-center gap-1.5 rounded-[5px] px-2 text-xs font-medium text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,r&&`bg-background text-foreground shadow-sm`),children:[e.label,(0,Y.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-2xs tabular-nums`,children:e.count}),e.waiting&&(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-status-waiting`,"data-testid":`factory-view-storey-waiting`})]},e.id)})})}var Q=[{id:`board`,label:`Board`,title:`The pipeline as stages and cards`,icon:a},{id:`floor`,label:`Floor`,title:`Factory floor: a 3D workshop with every agent at its station`,icon:d}];function bt({view:e}){let t=(t,n)=>{e.set(t),n?.querySelector(`[data-mode="${t}"]`)?.focus()};return(0,Y.jsx)(`div`,{role:`radiogroup`,"aria-label":`Factory view mode`,className:`inline-flex items-center rounded-md border border-border bg-muted/40 p-0.5`,onKeyDown:n=>{let r=n.key===`ArrowRight`||n.key===`ArrowDown`?1:n.key===`ArrowLeft`||n.key===`ArrowUp`?-1:0;if(!r)return;n.preventDefault();let i=Q[(Q.findIndex(t=>t.id===e.mode)+r+Q.length)%Q.length];t(i.id,n.currentTarget)},"data-testid":`factory-view-mode`,children:Q.map(t=>{let n=t.id===e.mode,r=t.icon;return(0,Y.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n,tabIndex:n?0:-1,title:t.title,onClick:()=>e.set(t.id),"data-mode":t.id,"data-testid":`factory-view-mode-${t.id}`,className:G(`inline-flex h-7 items-center gap-1.5 rounded-[5px] px-2 text-xs font-medium text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5`,n&&`bg-background text-foreground shadow-sm`),children:[(0,Y.jsx)(r,{"aria-hidden":!0}),t.label]},t.id)})})}function xt(){let e=typeof document<`u`&&document.fullscreenEnabled===!0,[t,n]=(0,J.useState)(()=>!!document.fullscreenElement);return(0,J.useEffect)(()=>{let e=()=>n(!!document.fullscreenElement);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]),{supported:e,on:t,toggle:()=>{(document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen())?.catch(()=>H.error(`Full screen isn't available here`))}}}function St({f:e}){let t=e.killSwitch||e.globalKillSwitch||e.loopState===`stopped`,n=be[t?`stopped`:e.loopState],r=e.globalKillSwitch?`global kill switch`:e.killSwitch?`kill switch`:e.loopState===`paused`?e.pausedReason:null;return e.drain&&!t?(0,Y.jsx)(He,{f:e}):(0,Y.jsxs)(`span`,{className:G(`inline-flex max-w-full min-w-0 items-center gap-1 rounded-full px-2 py-0.5 text-2xs font-medium`,n.tone===`failed`&&`bg-status-failed/12 text-status-failed`,n.tone===`waiting`&&`bg-status-waiting/12 text-status-waiting`,n.tone===`running`&&`bg-status-running/12 text-status-running`,n.tone===`idle`&&`bg-muted text-muted-foreground`),"data-testid":`factory-view-loop`,title:r??void 0,children:[(0,Y.jsxs)(`span`,{className:`shrink-0`,children:[`Loop `,n.label.toLowerCase()]}),r&&(0,Y.jsxs)(`span`,{className:`truncate font-normal`,children:[`· `,r]})]})}function Ct({n:e,label:t,tone:n,icon:r}){return(0,Y.jsxs)(`span`,{className:G(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-2xs tabular-nums`,e===0&&`border-border text-muted-foreground`,e>0&&n===`waiting`&&`border-status-waiting/40 bg-status-waiting/10 text-status-waiting`,e>0&&n===`failed`&&`border-status-failed/40 bg-status-failed/10 text-status-failed`),"data-testid":`factory-view-count-${n}`,children:[r,(0,Y.jsx)(`span`,{className:`font-semibold`,children:e}),` `,t]})}function wt({project:e,f:t,needsPerson:i,failed:a,view:o,storeys:s}){let c=n(),l=ze(),d=xt(),f=t.killSwitch||t.globalKillSwitch||t.loopState===`stopped`,p=W({mutationFn:()=>c.factory.resume(t.projectId),onSuccess:()=>{H.success(`Loop resumed`),l.invalidateQueries({queryKey:Ae.all})},onError:e=>H.error(`Couldn't resume`,{description:e.message})});return(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-4 py-2.5`,"data-testid":`factory-view-header`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary/12 text-primary`,children:(0,Y.jsx)(u,{className:`size-4`,"aria-hidden":!0})}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h1`,{className:`truncate text-[15px] leading-tight font-semibold`,children:e.name}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-2xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:ve[t.mode]}),t.experimental&&(0,Y.jsx)(Ge,{})]})]})]}),(0,Y.jsx)(St,{f:t}),(0,Y.jsx)(Ke,{f:t}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Ct,{n:i,label:`need you`,tone:`waiting`,icon:(0,Y.jsx)(w,{className:`size-3`,"aria-hidden":!0})}),(0,Y.jsx)(Ct,{n:a,label:`failed`,tone:`failed`,icon:(0,Y.jsx)(y,{className:`size-3`,"aria-hidden":!0})})]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-1`,children:[t.loopState===`paused`&&!f&&!t.drain&&(0,Y.jsxs)(U,{size:`sm`,onClick:()=>p.mutate(),disabled:p.isPending,children:[(0,Y.jsx)(C,{}),` Resume`]}),(0,Y.jsx)(We,{f:t,stopped:f}),(0,Y.jsx)(Je,{scope:{projectId:t.projectId},on:t.killSwitch,drain:t.drain,paused:t.loopState===`paused`}),(0,Y.jsx)(Ve,{}),s,o.available&&(0,Y.jsx)(bt,{view:o}),d.supported&&(0,Y.jsxs)(U,{size:`sm`,variant:`ghost`,onClick:d.toggle,"aria-label":d.on?`Exit full screen`:`Full screen`,"data-testid":`factory-view-fullscreen`,children:[d.on?(0,Y.jsx)(te,{}):(0,Y.jsx)(v,{}),(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:d.on?`Exit full screen`:`Full screen`})]}),(0,Y.jsx)(U,{size:`sm`,variant:`ghost`,asChild:!0,children:(0,Y.jsxs)(r,{to:`/projects/$projectId`,params:{projectId:t.projectId},onClick:()=>d.on&&void document.exitFullscreen().catch(()=>{}),"data-testid":`factory-view-exit`,children:[(0,Y.jsx)(b,{}),` `,(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:`Exit`}),(0,Y.jsx)(`span`,{className:`sr-only sm:hidden`,children:`Exit the factory view`})]})})]})]})}var Tt=`codeden.factoryView.mode`;function Et(e){return e===`floor`||e===`pixel`?`floor`:`board`}function Dt(){let[e,t]=(0,J.useState)(()=>Et(localStorage.getItem(Tt)));return{available:!0,mode:e,set:e=>{localStorage.setItem(Tt,e),t(e)}}}var Ot=`codeden.factoryView.chat`,kt=[],At=[];function jt(e){let t=new Set;for(let n of[...e.backlog,...e.inProgress,...e.viewRecent,...e.recent])for(let e of[n.activeSessionId,n.sessionId,n.reviewerSessionId])e&&t.add(e);let n=e.mode===`dark_factory`?e.scout:null;n?.sessionId&&t.add(n.sessionId);for(let e of n?.lenses??[])t.add(e.sessionId);return[...t]}function Mt(){let[e,t]=(0,J.useState)(()=>localStorage.getItem(Ot)!==`closed`);return[e,e=>{localStorage.setItem(Ot,e?`open`:`closed`),t(e)}]}function $({children:e}){return(0,Y.jsx)(`div`,{className:`flex h-dvh flex-col overflow-hidden bg-background text-foreground`,children:e})}function Nt({projectId:e}){let{data:n}=Me(),a=Le(e),o=a?t(a.autonomyMode):!1,{data:s}=ke(e,o),c=je(e=>e.sessions,kt),l=Ie((0,J.useMemo)(()=>s?jt(s):[],[s])),d=je(e=>e.runner.providers,At),p=(0,J.useMemo)(()=>{let e=new Map(d.map(e=>[e.id,e.displayName]));return new Map([...c,...l.values()].map(t=>[t.id,{status:t.status,progress:t.progress?.text??null,progressAt:t.progress?.at??null,provider:e.get(t.provider)??t.provider,providerId:t.provider,model:t.model,workKey:t.workKey}]))},[c,l,d]),m=ie(),h=(0,J.useMemo)(()=>s?se(s,p,m):null,[s,p,m]),g=Xe(`pm`,e)?.id??null,_=s?.mode===`dark_factory`&&!!s.scout,v=!ne(),[ee,y]=(0,J.useState)(null),b=(0,J.useMemo)(()=>s&&h&&_?oe(le({f:s,pipeline:h,sessions:p,pmSessionId:g}),_,v):[],[s,h,p,g,_,v]),x=ce(ee,_,v),S=de(),C=ae(),[w,T]=Mt(),[te,E]=(0,J.useState)(!1),D=Dt(),[O,A]=(0,J.useState)(!1),j=D.mode===`floor`&&!O,M=j,[N,P]=(0,J.useState)(!1),ue=C?{docked:!0,open:w,setOpen:T}:{docked:!1,open:N,setOpen:P},[F,I]=(0,J.useState)(null),L=(0,J.useMemo)(()=>!F||!h?F:[...Object.values(h.stages).flat(),...h.needsYou].find(e=>e.item.id===F.item.id)??F,[F,h]);return n?a?o?!s||!h?(0,Y.jsxs)($,{children:[(0,Y.jsx)(`div`,{className:`h-14 border-b border-border`}),(0,Y.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,Y.jsx)(V,{className:`h-16 w-full rounded-xl`}),(0,Y.jsx)(V,{className:`h-96 w-full rounded-xl`})]})]}):(0,Y.jsx)($,{children:(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`factory-view`,children:[(0,Y.jsx)(wt,{project:a,f:s,needsPerson:h.needsPerson,failed:h.failed,view:D,storeys:j?(0,Y.jsx)(yt,{tabs:b,focus:x,onFocus:y}):void 0}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[M?(0,Y.jsx)(`main`,{className:S?`flex min-h-0 min-w-0 flex-1 flex-col p-3`:`flex min-h-0 min-w-0 flex-1 flex-col p-3 pb-16`,children:(0,Y.jsx)(Ye,{f:s,pipeline:h,sessions:p,projectId:e,now:m,onOpen:I,chat:ue,focus:x,onUnsupported:()=>A(!0)})}):(0,Y.jsxs)(`main`,{className:S?`flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-y-auto p-3 scroll-thin`:`flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-y-auto p-3 pb-20`,children:[D.mode===`floor`&&O&&(0,Y.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,"data-testid":`factory-view-floor-unsupported`,children:`Factory floor needs WebGL; showing the board.`}),(0,Y.jsx)(vt,{f:s}),(0,Y.jsx)(gt,{f:s,pipeline:h,now:m,onOpen:I})]}),C&&w&&!M&&(0,Y.jsx)(`aside`,{className:`flex w-[340px] shrink-0 flex-col border-l border-border bg-surface/40 2xl:w-[400px]`,"aria-label":`Project manager chat`,children:(0,Y.jsx)(re,{projectId:e,onCollapse:()=>T(!1)})}),S&&!(C&&(w||M))&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>M?P(!0):C?T(!0):E(!0),className:`flex w-10 shrink-0 flex-col items-center gap-2 border-l border-border py-3 text-2xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,"aria-label":`Show the PM chat`,"data-testid":`factory-view-chat-show`,children:[(0,Y.jsx)(i,{className:`size-4 text-primary`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`[writing-mode:vertical-rl]`,children:`PM chat`})]})]}),!S&&(0,Y.jsxs)(U,{className:`fixed right-4 bottom-4 z-10 rounded-full shadow-lg`,onClick:()=>M?P(!0):E(!0),"data-testid":`factory-view-chat-open`,children:[(0,Y.jsx)(f,{}),` PM chat`]}),!C&&!M&&(0,Y.jsx)(Ce,{open:te,onOpenChange:E,children:(0,Y.jsxs)(De,{side:S?`right`:`bottom`,showCloseButton:!1,className:`gap-0 p-0 data-[side=bottom]:h-[85dvh] data-[side=bottom]:rounded-t-2xl data-[side=right]:w-[min(26rem,90vw)] data-[side=right]:sm:max-w-none`,children:[(0,Y.jsx)(Ee,{className:`sr-only`,children:`Project manager chat`}),(0,Y.jsx)(we,{className:`sr-only`,children:`The latest messages with this project's PM`}),(0,Y.jsx)(re,{projectId:e,onCollapse:()=>E(!1)})]})}),(0,Y.jsx)(lt,{projectId:e,card:L,onClose:()=>I(null)})]})}):(0,Y.jsx)($,{children:(0,Y.jsxs)(k,{icon:(0,Y.jsx)(u,{}),title:`Not a factory project`,className:`flex-1`,action:(0,Y.jsx)(U,{size:`sm`,variant:`outline`,asChild:!0,children:(0,Y.jsx)(r,{to:`/projects/$projectId`,params:{projectId:e},children:`Back to the project`})}),children:[a.name,` isn't in software factory or dark factory mode, so there's no factory to show.`]})}):(0,Y.jsx)($,{children:(0,Y.jsx)(k,{icon:(0,Y.jsx)(u,{}),title:`Project not found`,className:`flex-1`,children:(0,Y.jsx)(r,{to:`/`,className:`text-primary hover:underline`,children:`Back to CodeDen`})})}):(0,Y.jsx)($,{children:(0,Y.jsx)(V,{className:`m-6 h-72 rounded-xl`})})}export{Nt as FactoryViewPage};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$ as t,A as n,B as r,C as i,D as a,E as o,F as s,G as c,H as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,T as b,U as x,V as S,W as C,X as w,Y as T,Z as E,_ as D,_t as O,a as k,at as A,b as j,bt as ee,c as M,ct as N,d as P,dt as F,et as I,f as te,ft as ne,g as re,gt as ie,h as ae,ht as oe,i as se,it as ce,j as le,k as ue,l as de,lt as fe,m as pe,mt as me,nt as he,o as ge,ot as _e,p as ve,pt as ye,q as be,r as xe,rt as L,s as Se,st as R,tt as Ce,u as we,ut as z,v as Te,vt as Ee,w as De,x as Oe,xt as B,y as ke,yt as Ae,z as je}from"./react-BETlQaef.js";import{n as Me,t as Ne}from"./jsx-runtime-C3cWAN_r.js";import{a as Pe,i as Fe,n as Ie,o as Le,p as V,s as Re,t as H,u as ze}from"./hastToHtml-BM7hjk4v.js";import{t as U}from"./useQuery-VSotSwry.js";import{En as Be,Tn as W,_n as Ve,ur as He,xn as Ue}from"./icons-COCLuOtb.js";import{t as We}from"./bits-B2GRjm37.js";import{t as Ge}from"./skeleton-D8Sbd2jT.js";import{i as Ke}from"./api-B620HpC2.js";import{t as G}from"./dist-wxbqfqV1.js";import{r as qe}from"./theme-DsW-i9mD.js";var K=Ne();function Je({file:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,lineAnnotations:o,renderGutterUtility:s,getHoveredLine:c,getAnnotationSlotName:l=R}){let u=t?.(e),d=n?.(e),f=r?.(e),p=i?.(e);return(0,K.jsxs)(K.Fragment,{children:[u==null?(0,K.jsxs)(K.Fragment,{children:[d!=null&&(0,K.jsx)(`div`,{slot:`header-prefix`,children:d}),f!=null&&(0,K.jsx)(`div`,{slot:`header-filename-suffix`,children:f}),p!=null&&(0,K.jsx)(`div`,{slot:`header-metadata`,children:p})]}):(0,K.jsx)(`div`,{slot:N,children:u}),a!=null&&o?.map((t,n)=>(0,K.jsx)(`div`,{slot:l(t),children:a(t,e)},n)),s!=null&&(0,K.jsx)(`div`,{slot:`gutter-utility-slot`,style:Ee,children:s(c)})]})}function q(e,t){return he(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}function J(e){return(e.lang??I(e.name))===`text`}var Ye=10,Xe=13,Ze=4,Qe=40;function $e(e){let t=[0],n=e.indexOf(`\r`),r=e.indexOf(`
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$ as t,A as n,B as r,C as i,D as a,E as o,F as s,G as c,H as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,T as b,U as x,V as S,W as C,X as w,Y as T,Z as E,_ as D,_t as O,a as k,at as A,b as j,bt as ee,c as M,ct as N,d as P,dt as F,et as I,f as te,ft as ne,g as re,gt as ie,h as ae,ht as oe,i as se,it as ce,j as le,k as ue,l as de,lt as fe,m as pe,mt as me,nt as he,o as ge,ot as _e,p as ve,pt as ye,q as be,r as xe,rt as L,s as Se,st as R,tt as Ce,u as we,ut as z,v as Te,vt as Ee,w as De,x as Oe,xt as B,y as ke,yt as Ae,z as je}from"./react-BETlQaef.js";import{n as Me,t as Ne}from"./jsx-runtime-C3cWAN_r.js";import{a as Pe,i as Fe,n as Ie,o as Le,p as V,s as Re,t as H,u as ze}from"./hastToHtml-BM7hjk4v.js";import{t as U}from"./useQuery-VSotSwry.js";import{En as Be,Tn as W,_n as Ve,ur as He,xn as Ue}from"./icons-COCLuOtb.js";import{t as We}from"./bits-B2GRjm37.js";import{t as Ge}from"./skeleton-D8Sbd2jT.js";import{i as Ke}from"./api-yvn34iKU.js";import{t as G}from"./dist-wxbqfqV1.js";import{r as qe}from"./theme-3eeE0sp4.js";var K=Ne();function Je({file:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,lineAnnotations:o,renderGutterUtility:s,getHoveredLine:c,getAnnotationSlotName:l=R}){let u=t?.(e),d=n?.(e),f=r?.(e),p=i?.(e);return(0,K.jsxs)(K.Fragment,{children:[u==null?(0,K.jsxs)(K.Fragment,{children:[d!=null&&(0,K.jsx)(`div`,{slot:`header-prefix`,children:d}),f!=null&&(0,K.jsx)(`div`,{slot:`header-filename-suffix`,children:f}),p!=null&&(0,K.jsx)(`div`,{slot:`header-metadata`,children:p})]}):(0,K.jsx)(`div`,{slot:N,children:u}),a!=null&&o?.map((t,n)=>(0,K.jsx)(`div`,{slot:l(t),children:a(t,e)},n)),s!=null&&(0,K.jsx)(`div`,{slot:`gutter-utility-slot`,style:Ee,children:s(c)})]})}function q(e,t){return he(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}function J(e){return(e.lang??I(e.name))===`text`}var Ye=10,Xe=13,Ze=4,Qe=40;function $e(e){let t=[0],n=e.indexOf(`\r`),r=e.indexOf(`
2
2
  `),i=0,a=0;for(;n!==-1||r!==-1;){let o;if(n!==-1&&(r===-1||n<r)?r===n+1?(o=r+1,n=e.indexOf(`\r`,o),r=e.indexOf(`
3
3
  `,o)):(o=n+1,n=e.indexOf(`\r`,o)):(o=r+1,r=e.indexOf(`
4
4
  `,o)),t.push(o),++a===Ze){if(o-i<=Qe){for(let n=o;n<e.length;n++){let r=e.charCodeAt(n);(r===Ye||r===Xe)&&(r===Xe&&n+1<e.length&&e.charCodeAt(n+1)===Ye&&n++,t.push(n+1))}return t}i=o,a=0}}return t}function Y(e){let t=$e(e);return Array.from({length:t.length},(n,r)=>{let i=t[r],a=t[r+1]??e.length;return e.slice(i,a)})}var et={forcePlainText:!1};function tt(e,n,{theme:r,tokenizeMaxLineLength:i,useTokenTransformer:a},{forcePlainText:o,lazyLineAST:s=!1,startingLine:c,totalLines:l,lines:u}=et){o?(c??=0,l??=1/0):(c=0,l=1/0);let d=c>0||l<1/0,f={lineInfo:[]},p=o?`text`:e.lang??I(e.name),m=typeof r==`string`?n.getTheme(r).type:void 0,h=t({theme:r,highlighter:n});f.lineInfo=e=>({type:`context`,lineIndex:e-1+c,lineNumber:e+c});let g=Ie(n.codeToTokens(nt(d?rt(u??Y(e.contents),c,l):e.contents),_(p,r,i)).tokens,{state:f,useTokenTransformer:a,lazyLineAST:s&&!o&&!a,cacheHtmlStyles:n.name===`highlights`}),v=d?Array(c):g;return d&&ze(v,g),{code:v,themeStyles:h,baseThemeType:m}}function nt(e){return e.replace(/\r(?!\n)/g,`