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.
- package/README.md +48 -3
- package/dist/{args-B0i5tyjE.js → args-BJ0ric8X.js} +5 -5
- package/dist/args-BJ0ric8X.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/{commands-CvAvyECH.js → commands-BPobEsBP.js} +33 -14
- package/dist/commands-BPobEsBP.js.map +1 -0
- package/dist/{env-wDgRchH9.js → env-CMkse2o0.js} +2 -2
- package/dist/{env-wDgRchH9.js.map → env-CMkse2o0.js.map} +1 -1
- package/dist/{harden-channel-2IT0Y7p3.js → harden-channel-D7h06kQ_.js} +41 -3
- package/dist/harden-channel-D7h06kQ_.js.map +1 -0
- package/dist/{launcher-D17oQovS.js → launcher-CvQZcEIC.js} +3 -3
- package/dist/launcher-CvQZcEIC.js.map +1 -0
- package/dist/{lock-DxXcNd2w.js → lock-iovTSSb0.js} +2 -2
- package/dist/{lock-DxXcNd2w.js.map → lock-iovTSSb0.js.map} +1 -1
- package/dist/{main-BRHfJHGf.js → main-BFo94KOF.js} +6 -6
- package/dist/{main-BRHfJHGf.js.map → main-BFo94KOF.js.map} +1 -1
- package/dist/{main-CJdbWeA_.js → main-B_ui4G93.js} +3 -3
- package/dist/{main-CJdbWeA_.js.map → main-B_ui4G93.js.map} +1 -1
- package/dist/{mediaType-e66mt7Cb.js → mediaType-DHbUOwRj.js} +2 -2
- package/dist/{mediaType-e66mt7Cb.js.map → mediaType-DHbUOwRj.js.map} +1 -1
- package/dist/{runner-CKo8zFVx.js → runner-agAgr2qn.js} +5 -5
- package/dist/{runner-CKo8zFVx.js.map → runner-agAgr2qn.js.map} +1 -1
- package/dist/{runner-link-CGefyJ5U.js → runner-link-B7SsTYaz.js} +3 -3
- package/dist/{runner-link-CGefyJ5U.js.map → runner-link-B7SsTYaz.js.map} +1 -1
- package/dist/runner.js +1 -1
- package/dist/{server-test-aa-ENBUk.js → server-test-Cad_bM68.js} +4 -4
- package/dist/{server-test-aa-ENBUk.js.map → server-test-Cad_bM68.js.map} +1 -1
- package/dist/{src-CwV8i4Mj.js → src-BPcdaWEw.js} +4 -6
- package/dist/{src-CwV8i4Mj.js.map → src-BPcdaWEw.js.map} +1 -1
- package/dist/web/assets/{add-project-dialog-VBi3WXnh.js → add-project-dialog-BHbgORVh.js} +1 -1
- package/dist/web/assets/{agent-tabs-BNgrQWDq.js → agent-tabs-B6uUKAXD.js} +1 -1
- package/dist/web/assets/{agents-Ir1aHz-I.js → agents-NbcZbVrc.js} +1 -1
- package/dist/web/assets/{api-jkvqht5P.js → api-B9OffDXw.js} +1 -1
- package/dist/web/assets/{api-B620HpC2.js → api-yvn34iKU.js} +27 -27
- package/dist/web/assets/{archived-sessions-D4fJHB37.js → archived-sessions-C1-stU7x.js} +1 -1
- package/dist/web/assets/{automation-B91XTDIM.js → automation-Co7V1tcW.js} +1 -1
- package/dist/web/assets/{automation-new-CN7YhryW.js → automation-new-hCV8HoK1.js} +1 -1
- package/dist/web/assets/{automations-CLzVG-zc.js → automations-7GJxGbPp.js} +1 -1
- package/dist/web/assets/{composer-Dd8joSgj.js → composer-B1tdNGSi.js} +1 -1
- package/dist/web/assets/{conflict-card-BN9kNMVL.js → conflict-card-Bx8tT_d5.js} +1 -1
- package/dist/web/assets/{dialog-Dyw3b_Tu.js → dialog-Cvj_lHPY.js} +1 -1
- package/dist/web/assets/{diff-panel-CQ2XZMk2.js → diff-panel-BHhM9z93.js} +1 -1
- package/dist/web/assets/{draft-BmnE6-7J.js → draft-JkaN3nCS.js} +1 -1
- package/dist/web/assets/{dropdown-menu-C4XI7F63.js → dropdown-menu-Bflkx6wY.js} +1 -1
- package/dist/web/assets/{engines-Chq2ih3x.js → engines-pLQJYIu_.js} +1 -1
- package/dist/web/assets/{factory-BBYEYI9i.js → factory-DVCs5zxg.js} +1 -1
- package/dist/web/assets/{factory-columns-CtJOpFim.js → factory-columns-DExb6gW2.js} +1 -1
- package/dist/web/assets/{factory-item-BjydL6AH.js → factory-item-efMFkxnv.js} +1 -1
- package/dist/web/assets/{factory-view-BU2AKcD8.js → factory-view-Cot7flHA.js} +1 -1
- package/dist/web/assets/{files-panel-B6_6pSo9.js → files-panel-BIkR_seN.js} +1 -1
- package/dist/web/assets/{floor-scene-DCpEq0j7.js → floor-scene-DGy8i_5R.js} +1 -1
- package/dist/web/assets/{form-bits-BSfnSmQ7.js → form-bits-5XojWhBG.js} +1 -1
- package/dist/web/assets/{format-D1ma_o2D.js → format-D3kairnQ.js} +1 -1
- package/dist/web/assets/{home-_m_Aihwv.js → home-BtFPGjza.js} +1 -1
- package/dist/web/assets/{inbox-FDD5FMWW.js → inbox-CUPkJ4WC.js} +1 -1
- package/dist/web/assets/{index-BkpVvQrC.js → index-C0C9GyeX.js} +4 -4
- package/dist/web/assets/{item-parts-BhDFWsT1.js → item-parts-DZ3TQad4.js} +1 -1
- package/dist/web/assets/{kill-switch-Dvqaozhz.js → kill-switch-BDAFCjui.js} +1 -1
- package/dist/web/assets/{label-DcWfyglU.js → label-Bm_8Eqe2.js} +1 -1
- package/dist/web/assets/{local-whisper-test-DPTOEA1M.js → local-whisper-test-CqGlAOvK.js} +1 -1
- package/dist/web/assets/{markdown-ad2jia51.js → markdown-DGHfubu-.js} +1 -1
- package/dist/web/assets/{mobile-nav-D8FZcJzG.js → mobile-nav-CrjrDJZ5.js} +1 -1
- package/dist/web/assets/{model-picker-4yoJPkRY.js → model-picker-DnKv2cbc.js} +1 -1
- package/dist/web/assets/{new-session-ddLbjOoZ.js → new-session-Bc93-xJK.js} +1 -1
- package/dist/web/assets/{new-session-GpxXZWbB.js → new-session-CUpOffXI.js} +1 -1
- package/dist/web/assets/{new-session-CwbgcYzY.js → new-session-DVYesr8z.js} +1 -1
- package/dist/web/assets/{now-next-D-6j1g_S.js → now-next-x8fwFm7p.js} +1 -1
- package/dist/web/assets/{on-demand-Cvu5D9uT.js → on-demand-Cvi90jRi.js} +2 -2
- package/dist/web/assets/{open-pr-controls--EtUvzD2.js → open-pr-controls-CYypJCKQ.js} +1 -1
- package/dist/web/assets/{orchestration-pknfiYFr.js → orchestration-BZj0HlxR.js} +1 -1
- package/dist/web/assets/{page-header-BqPf-jRo.js → page-header-t9HzSrxd.js} +1 -1
- package/dist/web/assets/{pm-fMuSJMPP.js → pm-DJfHcB90.js} +1 -1
- package/dist/web/assets/{popover-OrzLEhHL.js → popover-BqwWmyWQ.js} +1 -1
- package/dist/web/assets/{pr-details-BBVM9Kll.js → pr-details-1hhbiFWa.js} +1 -1
- package/dist/web/assets/{project-ws85aDq4.js → project-dy2_DT0H.js} +1 -1
- package/dist/web/assets/{question-card-4aNx5IRX.js → question-card-ldxLXNS_.js} +1 -1
- package/dist/web/assets/{remote-check-BAPXUznK.js → remote-check-CQktPgyp.js} +2 -2
- package/dist/web/assets/{reports-BZj5_wsp.js → reports-D0GAsXFv.js} +1 -1
- package/dist/web/assets/{role-chat-CeJXMsYB.js → role-chat-nIyzM-vQ.js} +1 -1
- package/dist/web/assets/{run-conflict-CPr9OWa3.js → run-conflict-BlgKVpOG.js} +1 -1
- package/dist/web/assets/{runs-table-DpBJ4ZeQ.js → runs-table-DMPF5_D6.js} +1 -1
- package/dist/web/assets/{search-BFTvT67N.js → search-gwjIEGis.js} +1 -1
- package/dist/web/assets/{search-Da3B5-lr.js → search-hK5b8Xwb.js} +1 -1
- package/dist/web/assets/{select-B4LGxZQI.js → select-B1ES0hhy.js} +1 -1
- package/dist/web/assets/{session-_62x2rSZ.js → session-CPUTlq1O.js} +1 -1
- package/dist/web/assets/{settings-CUYuBL-5.js → settings-DRd0b0Kz.js} +1 -1
- package/dist/web/assets/{settings-ui-Ux8rPFol.js → settings-ui-Bc6ymtc_.js} +1 -1
- package/dist/web/assets/{setup-BKOOV6vX.js → setup-Bn2CFYAt.js} +1 -1
- package/dist/web/assets/{shallow-CbfSRfYC.js → shallow-BUNpybIA.js} +1 -1
- package/dist/web/assets/{spec-approval-9S-jPMrI.js → spec-approval-CmC6QBSh.js} +1 -1
- package/dist/web/assets/{spot-check-actions-5CmYjt8A.js → spot-check-actions-DzMUED1O.js} +1 -1
- package/dist/web/assets/{spot-checks-BadmkHuG.js → spot-checks-CDZxwwu0.js} +1 -1
- package/dist/web/assets/{storeys-OlWmOmqA.js → storeys-BEgFUsix.js} +1 -1
- package/dist/web/assets/{switch-DuBpF2_h.js → switch-BHplnCdo.js} +1 -1
- package/dist/web/assets/{terminal-view-ChO1pNp0.js → terminal-view-WNT8FI6K.js} +1 -1
- package/dist/web/assets/{theme-DsW-i9mD.js → theme-3eeE0sp4.js} +1 -1
- package/dist/web/assets/{thread-view-CPlJsMhl.js → thread-view-AQKzJlKb.js} +1 -1
- package/dist/web/assets/{update-banner-CNYd8gAf.js → update-banner-CZGRgiG8.js} +1 -1
- package/dist/web/assets/{updates-CQZDqpFF.js → updates-4l7pwDq1.js} +1 -1
- package/dist/web/assets/{use-retry-item-CWwb3JGo.js → use-retry-item-3n4BD_3J.js} +1 -1
- package/dist/web/assets/{vision-7gkgZ-Ap.js → vision-Z1sLHr_c.js} +1 -1
- package/dist/web/assets/{wip-chip-D5-cZcfN.js → wip-chip-DXwuAo3A.js} +1 -1
- package/dist/web/index.html +34 -34
- package/package.json +1 -1
- package/dist/args-B0i5tyjE.js.map +0 -1
- package/dist/commands-CvAvyECH.js.map +0 -1
- package/dist/harden-channel-2IT0Y7p3.js.map +0 -1
- package/dist/launcher-D17oQovS.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,jt as n,yt as r}from"./api-B620HpC2.js";import{n as i,t as a}from"./jsx-runtime-C3cWAN_r.js";import{F as o,t as s}from"./useQuery-VSotSwry.js";import{D as c,_ as l,j as u,m as d,yt as f}from"./format-D1ma_o2D.js";import{a as p,c as m,i as h,l as g,n as _,o as v,r as y,s as b,t as x}from"./dropdown-menu-C4XI7F63.js";import{F as S,I as C,R as w,h as T,m as E}from"./mobile-nav-D8FZcJzG.js";import{d as D,r as O}from"./switch-DuBpF2_h.js";import{t as k}from"./dist-wxbqfqV1.js";import{g as A}from"./logic-BTt00I9b.js";import{Bt as j,Ct as ee,D as te,Dr as ne,En as re,Ht as ie,Lt as M,O as ae,On as oe,St as se,T as ce,Zn as N,_n as le,lt as ue,n as de,pr as fe,t as P}from"./icons-COCLuOtb.js";import{a as pe}from"./theme-DsW-i9mD.js";import{r as F,t as I}from"./composer-Dd8joSgj.js";import{i as L}from"./settings-ui-Ux8rPFol.js";import{d as me,f as he,h as ge,l as R,m as z,p as _e,t as ve}from"./model-picker-4yoJPkRY.js";import{a as ye,r as be,s as xe}from"./engines-Chq2ih3x.js";import{t as Se}from"./send-to-session-CdnAb3k6.js";import{i as Ce,n as we,t as B}from"./autonomy-Bx33JDEO.js";import{t as Te}from"./footer-BFGvnowz.js";import{t as Ee}from"./tap-tooltip-Pz23Abjm.js";import{a as De}from"./new-session-ddLbjOoZ.js";var V=e(i(),1),H=a(),Oe=0,U=()=>`att-${Date.now().toString(36)}-${Oe++}`;function W(e){return e.map(e=>e.type===`image`?{type:`image`,mediaType:e.mediaType,name:e.name,source:{type:`base64`,data:e.data}}:{type:`file`,path:e.path,name:e.name})}async function ke(e){let t=[];for(let n of e){let e=r.safeParse(n.type);if(e.success){let r=await new Promise((e,t)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>t(r.error),r.readAsDataURL(n)});t.push({id:U(),type:`image`,name:n.name||`pasted-image.png`,mediaType:e.data,data:r.slice(r.indexOf(`,`)+1),previewUrl:r})}else t.push({id:U(),type:`file`,name:n.name,path:n.name})}return t}function Ae({items:e,onRemove:t}){return e.length===0?null:(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,children:e.map(e=>(0,H.jsxs)(`div`,{className:`group relative animate-rise`,children:[e.type===`image`?(0,H.jsx)(`img`,{src:e.previewUrl,alt:e.name,className:`size-14 rounded-lg border border-border object-cover`}):(0,H.jsxs)(`div`,{className:`flex h-14 max-w-44 items-center gap-2 rounded-lg border border-border bg-muted/40 px-2.5`,children:[(0,H.jsx)(oe,{className:`size-4 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`truncate font-mono text-2xs`,children:e.name})]}),(0,H.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,onClick:()=>t(e.id),className:`absolute -top-1.5 -right-1.5 flex size-5 items-center justify-center rounded-full border border-border bg-popover text-muted-foreground opacity-0 shadow-sm transition-opacity group-hover:opacity-100 hover:text-foreground touch:opacity-100`,children:(0,H.jsx)(de,{className:`size-3`})})]},e.id))})}var G=356,K=24,je=16,Me=8;function Ne(e,t){if(!e)return{};let n=Math.max(0,e.viewportHeight-e.top)+Me,r=t===`right`?e.viewportWidth-K-G:K,i=e.right<=r||e.left>=r+G;return{mobileOffset:{bottom:Math.max(je,n)},...i?{}:{offset:{bottom:Math.max(K,n)}}}}function Pe(e){let t=e.getBoundingClientRect();return t.width===0||t.height===0?null:{top:Math.round(t.top),left:Math.round(t.left),right:Math.round(t.right),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}function Fe(e){(0,V.useEffect)(()=>{let t=e.current;if(!t)return;let{setComposerBounds:n}=O.getState(),r=()=>n(Pe(t));r();let i=new ResizeObserver(r);for(let e=t;e;e=e.parentElement)i.observe(e);return window.addEventListener(`resize`,r),()=>{i.disconnect(),window.removeEventListener(`resize`,r),n(null)}},[e])}function Ie(e){let t=20*Math.log10(Math.max(e,1e-6));return Math.min(1,Math.max(0,(t+55)/45))}var Le=[.55,.85,1,.8,.6];function Re({store:e}){let t=(0,V.useSyncExternalStore)(e.subscribe,e.get);if(t===null)return(0,H.jsxs)(`span`,{"aria-hidden":!0,className:`relative mt-[7px] flex size-2 shrink-0`,children:[(0,H.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-full bg-status-failed/50`}),(0,H.jsx)(`span`,{className:`relative size-2 rounded-full bg-status-failed`})]});let n=Ie(t);return(0,H.jsx)(`span`,{"aria-hidden":!0,"data-testid":`dictation-level`,className:`mt-[3px] flex h-4 shrink-0 items-center gap-[2px]`,children:Le.map(e=>(0,H.jsx)(`span`,{className:`w-[3px] rounded-full bg-status-failed/80 transition-[height] duration-75`,style:{height:`${20+80*n*e}%`}},e))})}function ze({dictation:e}){let{phase:t,draft:n,pending:r,heard:i,engine:a,level:o}=e;if(t===`idle`)return null;let s=n?null:t===`finishing`||r>0?`Transcribing…`:`Listening…`;return(0,H.jsxs)(`div`,{"data-testid":`dictation-strip`,className:`flex items-start gap-2 px-4 pb-1.5 text-[13px] leading-relaxed text-muted-foreground`,children:[t===`listening`?(0,H.jsx)(Re,{store:o}):(0,H.jsx)(M,{"aria-hidden":!0,className:`mt-[3px] size-3.5 shrink-0 animate-spin`}),n&&(0,H.jsx)(`span`,{"data-testid":`dictation-draft`,className:`min-w-0 italic text-muted-foreground/75`,children:n}),s&&(0,H.jsxs)(`span`,{role:`status`,children:[s,s===`Listening…`&&!i&&a.live===`segments`&&(0,H.jsx)(`span`,{className:`text-muted-foreground/60`,children:` Text appears after each pause.`})]})]})}function Be(){let e=null,t=new Set;return{get:()=>e,set(n){if(n!==e){e=n;for(let e of t)e()}},subscribe(e){return t.add(e),()=>t.delete(e)}}}function Ve(e){let n=t(),{settings:r}=L(),i=r.voice.dictation.engine;return(0,V.useMemo)(()=>e||(i===`browser`?be:ye(n,i)),[e,i,n])}function He({baseText:e,onText:t,language:n,engine:r}){let i=Ve(r),{settings:a}=L(),o=a.voice.dictation.pushToTalkShortcut??null,s=ge(`dictate`).combo,[c,l]=(0,V.useState)(`idle`),[d,f]=(0,V.useState)(``),[p,m]=(0,V.useState)(0),[h,g]=(0,V.useState)(!1),[_]=(0,V.useState)(Be),v=(0,V.useRef)(`idle`),y=(0,V.useRef)(!1),b=e=>{v.current=e,l(e)},x=()=>{if(!i.supported||v.current!==`idle`)return;y.current=!1;let r=e.trimEnd(),a=e=>t(r?r+xe(r,e)+e:e);b(`listening`),f(``),m(0),g(!1),_.set(null),i.start({language:n,onText:e=>{f(e.draft),(e.final||e.draft)&&g(!0),e.final&&a(e.final)},onLevel:e=>_.set(e),onPending:m,onEnd:()=>{b(`idle`),f(``),m(0),_.set(null)},onError:e=>{v.current!==`idle`&&b(i.finishesAfterStop?`finishing`:`idle`),u.error(`Dictation stopped`,{description:e})}})},S=()=>{v.current===`listening`&&(b(i.finishesAfterStop?`finishing`:`idle`),i.stop())},C=()=>v.current===`listening`?S():x(),w=(0,V.useRef)({toggle:C,start:x,stop:S});return w.current={toggle:C,start:x,stop:S},(0,V.useEffect)(()=>{let e=e=>o!==null&&!_e(o)&&he(e.target),t=t=>{i.supported&&(o&&z(t,o)&&!e(t)?(t.preventDefault(),!t.repeat&&v.current===`idle`&&(w.current.start(),y.current=!0)):z(t,s)&&(t.preventDefault(),w.current.toggle()))},n=e=>{if(!o||!y.current)return;let t=o.split(`+`).at(-1)?.toLowerCase();t&&(e.key.toLowerCase()===t||e.code.toLowerCase()===t)&&w.current.stop()};return window.addEventListener(`keydown`,t),window.addEventListener(`keyup`,n),()=>{window.removeEventListener(`keydown`,t),window.removeEventListener(`keyup`,n)}},[s,o,i.supported]),(0,V.useEffect)(()=>()=>{v.current===`listening`&&i.stop()},[i]),{engine:i,phase:c,draft:d,pending:p,heard:h,level:_,combo:s,pushToTalk:o,start:x,stop:S,toggle:C}}function Ue({dictation:e}){let{engine:t,phase:n,combo:r,pushToTalk:i,toggle:a}=e,o=n===`listening`,s=n===`finishing`,c=t.supported?s?`Transcribing…`:o?`Stop dictation`:`Dictate · ${me(r)}${i?` · hold ${me(i)}`:``}`:`Dictation isn't available in this browser. Choose Local (Whisper) in Settings > Voice.`;return(0,H.jsxs)(S,{children:[(0,H.jsx)(w,{asChild:!0,children:(0,H.jsx)(`span`,{children:(0,H.jsxs)(d,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:!t.supported||s,onClick:a,"aria-label":c,"aria-pressed":o,className:k(`relative text-muted-foreground`,o&&`bg-status-failed/12 text-status-failed hover:bg-status-failed/20 hover:text-status-failed`),children:[s?(0,H.jsx)(M,{className:`animate-spin`}):t.supported?(0,H.jsx)(se,{}):(0,H.jsx)(ee,{}),o&&(0,H.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-[inherit] border border-status-failed/40 [animation-duration:1.6s]`})]})})}),(0,H.jsx)(C,{children:c})]})}var q={orchestrator:`Ask the orchestrator to start a project, triage issues or check on work…`,pm:`Message the project manager…`,agent:`Message the agent — @ to mention files, / for commands and skills`},J=e=>e.text.trim().length>0||e.attachments.length>0,Y=e=>({text:e.text.trim(),attachments:W(e.attachments)}),X=e=>e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing;function Z({draftKey:e,placeholder:t,onKeyDown:n,onCaret:r,textareaRef:i,combobox:a,menu:o,options:s,actions:l,children:u,dictationEngine:f}){let p=F(t=>I(t,e)),m=F(e=>e.focusToken),{setText:h,addAttachments:g,removeAttachment:_}=F.getState(),v=c(e=>e.settings.voice.dictation.language,null),y=He({baseText:p.text,onText:t=>h(e,t),language:v,engine:f}),b=(0,V.useRef)(null),x=i??b,T=(0,V.useRef)(null),E=(0,V.useRef)(null),[D,O]=(0,V.useState)(!1);Fe(E),(0,V.useEffect)(()=>{if(m>0){x.current?.focus();let e=x.current?.value.length??0;x.current?.setSelectionRange(e,e)}},[m,x]);let A=async t=>{t.length>0&&g(e,await ke(t))};return(0,H.jsx)(`div`,{className:`mx-auto w-full max-w-[46rem] px-3 pb-3 sm:px-6 sm:pb-5`,children:(0,H.jsxs)(`div`,{className:`relative`,children:[o,(0,H.jsxs)(`div`,{ref:E,onDragOver:e=>{e.preventDefault(),O(!0)},onDragLeave:()=>O(!1),onDrop:e=>{e.preventDefault(),O(!1),A(Array.from(e.dataTransfer.files))},className:k(`rounded-2xl border border-border bg-card shadow-[0_10px_30px_-18px] shadow-black/40 transition-[border-color,box-shadow] focus-within:border-primary/35 focus-within:shadow-[0_0_0_4px] focus-within:shadow-primary/[0.07]`,D&&`border-dashed border-primary/60 bg-primary/[0.03]`),children:[(0,H.jsx)(Ae,{items:p.attachments,onRemove:t=>_(e,t)}),(0,H.jsx)(`textarea`,{ref:x,value:p.text,rows:1,onChange:t=>{h(e,t.target.value),r?.(t.target.selectionStart)},onSelect:e=>r?.(e.currentTarget.selectionStart),onKeyDown:n,onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length!==0&&(e.preventDefault(),A(t))},placeholder:t,"aria-label":`Message`,role:a?`combobox`:void 0,"aria-autocomplete":a?`list`:void 0,"aria-expanded":a?a.open:void 0,"aria-controls":a?.open?a.listId:void 0,"aria-activedescendant":a?.open?a.activeId:void 0,className:`block max-h-64 min-h-[56px] w-full resize-none bg-transparent px-4 pt-3.5 pb-1 text-[14px] leading-relaxed outline-none [field-sizing:content] placeholder:text-muted-foreground/70`}),(0,H.jsx)(ze,{dictation:y}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-0.5 gap-y-1 px-2 pb-2`,children:[(0,H.jsx)(`input`,{ref:T,type:`file`,multiple:!0,hidden:!0,onChange:e=>void A(Array.from(e.target.files??[]))}),(0,H.jsxs)(S,{children:[(0,H.jsx)(w,{asChild:!0,children:(0,H.jsx)(d,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,onClick:()=>T.current?.click(),"aria-label":`Attach files`,children:(0,H.jsx)(ue,{})})}),(0,H.jsx)(C,{children:`Attach files or paste an image`})]}),s,(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[l,(0,H.jsx)(Ue,{dictation:y}),u]})]})]})]})})}var We=[1,2,3,5,10];function Q({checks:e,value:t,onChange:n,disabled:r}){let i=t.untilPass;return(0,H.jsxs)(x,{children:[(0,H.jsx)(g,{asChild:!0,children:(0,H.jsxs)(d,{variant:`ghost`,size:`sm`,className:k(R,i&&`bg-primary/10 text-primary hover:text-primary`),"aria-label":`Keep going until checks pass`,"aria-pressed":i,disabled:r,children:[(0,H.jsx)(ie,{className:`size-3.5`}),`Checks`,i&&(0,H.jsxs)(`span`,{className:`tabular-nums opacity-80`,children:[`×`,t.maxRounds]})]})}),(0,H.jsxs)(y,{align:`start`,className:`w-80`,"data-testid":`checks-menu`,children:[(0,H.jsx)(_,{checked:i,onCheckedChange:e=>n({...t,untilPass:e===!0}),onSelect:e=>e.preventDefault(),className:`items-start py-1.5`,children:(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block text-[13px]`,children:`Keep going until checks pass`}),(0,H.jsx)(`span`,{className:`block text-2xs text-muted-foreground`,children:`After each turn CodeDen runs the checks and sends failures back to the agent.`})]})}),(0,H.jsx)(m,{}),(0,H.jsx)(p,{className:`text-2xs`,children:`At most this many rounds`}),(0,H.jsx)(v,{value:String(t.maxRounds),onValueChange:e=>n({...t,maxRounds:Number(e)}),children:We.map(e=>(0,H.jsxs)(b,{value:String(e),onSelect:e=>e.preventDefault(),className:`text-[13px]`,children:[e,` `,e===1?`round`:`rounds`,e===3&&(0,H.jsx)(`span`,{className:`ml-auto text-2xs text-muted-foreground`,children:`default`})]},e))}),(0,H.jsx)(m,{}),(0,H.jsx)(p,{className:`text-2xs`,children:`The project's checks`}),(0,H.jsx)(`ul`,{className:`space-y-0.5 px-2 pb-1.5`,children:e.map(e=>(0,H.jsx)(`li`,{className:`truncate font-mono text-[11.5px] text-muted-foreground`,children:e.command},e.command))})]})]})}function Ge({provider:e,wasOn:t,canSwitch:n}){let r=`${e} can't plan first.`;return t?n?`Plan mode is off: ${r} It turns back on when you pick a provider that can plan.`:`Plan mode is off: ${r}`:n?`${r} Pick a provider that can plan to use it.`:r}function Ke({value:e,onChange:t,disabled:n,unavailable:r}){return r?(0,H.jsx)(qe,{...r}):(0,H.jsxs)(S,{children:[(0,H.jsx)(w,{asChild:!0,children:(0,H.jsxs)(d,{variant:`ghost`,size:`sm`,className:k(R,e&&`bg-primary/10 text-primary hover:text-primary`),"aria-label":`Plan mode`,"aria-pressed":e,disabled:n,onClick:()=>t(!e),children:[(0,H.jsx)(N,{className:`size-3.5`}),`Plan`]})}),(0,H.jsx)(C,{className:`max-w-64`,children:e?`Plan mode is on: the agent plans without editing, and starts once you approve the plan.`:`Plan first: the agent explores and proposes a plan before it changes anything.`})]})}function qe(e){let t=Ee(),n=(0,V.useId)(),r=Ge(e);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(S,{...t.root,children:[(0,H.jsx)(w,{asChild:!0,children:(0,H.jsxs)(d,{variant:`ghost`,size:`sm`,className:k(R,`cursor-not-allowed opacity-50 hover:text-muted-foreground`),"aria-label":`Plan mode`,"aria-pressed":!1,"aria-disabled":!0,"aria-describedby":n,...t.trigger,children:[(0,H.jsx)(N,{className:`size-3.5`}),(0,H.jsx)(`span`,{className:k(e.wasOn&&`line-through`),children:`Plan`})]})}),(0,H.jsx)(C,{className:`max-w-64`,children:r})]}),(0,H.jsx)(`span`,{id:n,className:`sr-only`,children:r})]})}function Je({value:e,onChange:t,readOnlySupported:n=!0,heading:r=`Permissions for this session`,disabled:i}){let a=B[e];return(0,H.jsxs)(x,{children:[(0,H.jsx)(g,{asChild:!0,children:(0,H.jsxs)(d,{variant:`ghost`,size:`sm`,className:R,"aria-label":`Permissions`,disabled:i,children:[(0,H.jsx)(a.icon,{className:k(`size-3.5`,a.tone)}),a.short]})}),(0,H.jsxs)(y,{align:`start`,className:`w-80`,"data-testid":`permissions-menu`,children:[(0,H.jsx)(p,{className:`text-2xs`,children:r}),we.map(r=>{let i=B[r],a=r===`read_only`&&!n;return(0,H.jsxs)(h,{disabled:a,onSelect:()=>t(r),className:`items-start py-1.5`,children:[(0,H.jsx)(i.icon,{className:k(`mt-0.5 size-4`,i.tone)}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block text-[13px]`,children:i.label}),(0,H.jsx)(`span`,{className:`block text-2xs text-muted-foreground`,children:a?`This provider can't enforce read-only.`:i.description})]}),r===e&&(0,H.jsx)(fe,{className:`mt-0.5 size-3.5`})]},r)})]})]})}function Ye(e){return e.planMode===void 0?e.untilChecksPass===!1?`Keep going until checks pass: off`:e.untilChecksPass!==void 0||e.checkRounds!==void 0?`Keep going until checks pass${e.checkRounds?`, up to ${e.checkRounds} ${e.checkRounds===1?`round`:`rounds`}`:``}`:e.autonomy===void 0?e.model!==void 0&&e.effort!==void 0?`Model and effort changed`:e.model===void 0?`Effort changed`:`Model changed`:`Permissions: ${B[e.autonomy].label}`:e.planMode?`Plan mode on`:`Plan mode off`}function Xe(e,t,n){if(t)return e.untilChecksPass!==void 0||e.checkRounds!==void 0?`Applies when this turn ends.`:(e.autonomy!==void 0||e.planMode!==void 0)&&n?`Applies from the next tool call.`:`Applies from the next turn.`}function Ze({session:e,running:n}){let r=t(),i=o(),a=D(),s=c(e=>e.runner.providers,[]),d=s.find(t=>t.id===e.provider),p=d?.capabilities.liveAutonomy??!1,m=O(e=>e.setHandoff),h=T(e),g=f({mutationFn:t=>r.updateSession(e.id,t),onSuccess:(t,r)=>{i.setQueryData(l,e=>e&&{...e,sessions:e.sessions.map(e=>e.id===t.id?t:e)}),u.success(Ye(r),{id:`session-options-${e.id}`,description:Xe(r,n,p)})},onError:e=>u.error(`Couldn't change the session`,{description:e.message})}),_=(0,V.useRef)(Promise.resolve()),v=e=>{_.current=_.current.then(()=>g.mutateAsync(e)).catch(()=>{})};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ve,{providers:s,lockedProvider:e.provider,handoff:e.role===`agent`?{blocked:h,lasting:h===E,onHandoff:t=>m({sessionId:e.id,provider:t})}:void 0,switchHint:e.role===`agent`?void 0:A(e.role),footer:e.role===`agent`||s.length<2?void 0:t=>(0,H.jsx)(Te,{note:`${e.role===`orchestrator`?`The orchestrator`:`Project managers`} can run on another provider.`,action:`Change provider`,onClick:()=>{t(),a({to:`/settings/$section`,params:{section:`providers`}})}}),value:{provider:e.provider,model:e.model,effort:e.effort},shortcut:!0,onChange:t=>{let n={};t.model!==e.model&&(n.model=t.model),t.effort!==e.effort&&(n.effort=t.effort),(n.model!==void 0||n.effort!==void 0)&&v(n)}}),e.role===`agent`&&(0,H.jsx)(Je,{value:e.autonomy,readOnlySupported:Ce(d),onChange:t=>{t!==e.autonomy&&v({autonomy:t})}}),e.role===`agent`&&d&&(0,H.jsx)(Ke,{value:e.planMode??!1,unavailable:d.capabilities.planMode?void 0:{provider:d.displayName,wasOn:e.planMode??!1},onChange:e=>v({planMode:e})}),e.role===`agent`&&e.checks&&e.checks.commands.length>0&&e.autonomy!==`read_only`&&(0,H.jsx)(Q,{checks:e.checks.commands,value:e.checks,onChange:e=>v({untilChecksPass:e.untilPass,checkRounds:e.maxRounds})})]})}var Qe={file:re,dir:le,command:te,skill:ae},$e={file:`file`,dir:`folder`,command:`command`,skill:`skill`},et=(e,t)=>`${e}-${t.icon}-${encodeURIComponent(t.id)}`;function tt(e,t,n,r){if(!e||t)return``;let i=n===0?`No matches`:n===1?`1 result`:`${n} results`;return r?.query?`${i} for ${r.kind===`command`?`/`:`@`}${r.query}`:i}function nt({id:e,title:t,items:n,active:r,onHover:i,onPick:a}){let o=(0,V.useRef)(null);return(0,V.useEffect)(()=>{o.current?.querySelector(`[data-index="${r}"]`)?.scrollIntoView({block:`nearest`})},[r]),(0,H.jsxs)(`div`,{className:`absolute inset-x-0 bottom-full z-30 mb-2 overflow-hidden rounded-xl border border-border bg-popover shadow-xl animate-rise`,children:[(0,H.jsx)(`div`,{id:`${e}-title`,className:`border-b border-border px-3 py-1.5 text-3xs font-medium tracking-wider text-muted-foreground uppercase`,children:t}),(0,H.jsxs)(`div`,{ref:o,id:e,role:`listbox`,"aria-labelledby":`${e}-title`,className:`max-h-64 overflow-y-auto p-1 scroll-thin`,children:[n.length===0&&(0,H.jsx)(`div`,{className:`px-2.5 py-2 text-xs text-muted-foreground`,children:`No matches`}),n.map((t,n)=>{let o=Qe[t.icon],s=et(e,t);return(0,H.jsxs)(`div`,{id:s,role:`option`,tabIndex:-1,"aria-selected":n===r,"aria-label":`${t.label}, ${$e[t.icon]}`,"aria-describedby":t.description?`${s}-description`:void 0,"data-index":n,onMouseEnter:()=>i(n),onMouseDown:e=>{e.preventDefault(),a(t)},className:k(`flex cursor-pointer items-center gap-2.5 rounded-md px-2.5 py-1.5 text-[13px]`,n===r&&`bg-accent`),children:[(0,H.jsx)(o,{className:k(`size-3.5 shrink-0`,t.icon===`skill`?`text-primary`:`text-muted-foreground`)}),(0,H.jsx)(`span`,{className:k(`max-w-[70%] shrink-0 truncate`,(t.icon===`file`||t.icon===`dir`)&&`font-mono text-[12px]`),children:t.label}),t.description&&(0,H.jsx)(`span`,{id:`${s}-description`,title:t.description,className:`ml-auto min-w-0 truncate pl-3 text-2xs text-muted-foreground`,children:t.description})]},t.id)})]})]})}function rt(e,t){let n=e.slice(0,t),r=/(^|\s)@([\w./\\-]*)$/.exec(n);if(r){let e=r[2]??``;return{kind:`mention`,query:e,start:t-e.length-1}}let i=/^\/([\w:.-]*)$/.exec(n);return i?{kind:`command`,query:i[1]??``,start:0}:null}function it(e,t){let n=t.toLowerCase(),r=e.filter(e=>e.name.toLowerCase().includes(n)),i=e=>e.name.toLowerCase().startsWith(n);return[...r.filter(i),...r.filter(e=>!i(e))]}function at(e,t,n,r){return{text:`${e.slice(0,n.start)}${r} ${e.slice(t)}`,caret:n.start+r.length+1}}function ot(e,n,r){let i=t(),a=(0,V.useMemo)(()=>rt(n,r),[n,r]),[o,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(0),d=e.kind===`session`?[e.sessionId]:[`project`,e.projectId,e.provider],f=s({queryKey:[`mentions`,...d,a?.kind===`mention`?a.query:null],queryFn:()=>{let t=a?.query??``;return e.kind===`session`?i.searchMentions(e.sessionId,t):i.searchProjectMentions(e.projectId,t)},enabled:a?.kind===`mention`,staleTime:3e4}),p=s({queryKey:[`commands`,...d],queryFn:()=>e.kind===`session`?i.listSlashCommands(e.sessionId):e.provider?i.listProjectSlashCommands(e.projectId,e.provider):Promise.resolve([]),enabled:a?.kind===`command`,staleTime:6e4}),m=(0,V.useMemo)(()=>a?a.kind===`mention`?(f.data??[]).map(e=>({id:e.path,label:e.path,icon:e.kind,insert:`@${e.path}`})):it(p.data??[],a.query).map(e=>({id:e.name,label:`/${e.name}`,description:e.description,icon:e.kind===`skill`?`skill`:`command`,insert:`/${e.name}`})):[],[a,f.data,p.data]);(0,V.useEffect)(()=>u(0),[a?.kind,a?.query]);let h=!!a&&o!==a?.start,g=a?.kind===`mention`?f:p;return{trigger:a,items:m,open:h,loading:!!a&&g.isPending,active:l,setActive:u,dismiss:()=>c(a?.start??null),title:a?.kind===`mention`?`Files`:`Commands & skills`}}function st({draftKey:e,source:t,placeholder:n,options:r,running:i=!1,stoppable:a=!1,canSteer:o=!1,sending:s,onSend:c,onStop:l}){let u=F(t=>I(t,e)),{setText:f}=F.getState(),p=(0,V.useRef)(null),[m,h]=(0,V.useState)(0),[g,_]=(0,V.useState)(`queue`),v=ot(t,u.text,m),y=(0,V.useId)(),b=v.items[v.active],x=J(u),S=e=>{x&&c(Y(u),e??(i?o?g:`queue`:`send`))},C=t=>{if(!v.trigger)return;let n=at(u.text,m,v.trigger,t);f(e,n.text),requestAnimationFrame(()=>{p.current?.setSelectionRange(n.caret,n.caret),h(n.caret)})};return(0,H.jsx)(Z,{draftKey:e,placeholder:n,onKeyDown:e=>{if(v.open&&v.items.length>0){let t=v.items.length;if(e.key===`ArrowDown`){e.preventDefault(),v.setActive((v.active+1)%t);return}if(e.key===`ArrowUp`){e.preventDefault(),v.setActive((v.active-1+t)%t);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=v.items[v.active];t&&C(t.insert);return}if(e.key===`Escape`){e.preventDefault(),v.dismiss();return}}z(e.nativeEvent,ge(`stop`).combo)&&(i||a)&&l?(e.preventDefault(),l()):X(e)&&(e.preventDefault(),S(i&&o&&(e.ctrlKey||e.metaKey)?`steer`:void 0))},onCaret:h,textareaRef:p,combobox:{listId:y,open:v.open,activeId:b&&et(y,b)},menu:(0,H.jsxs)(H.Fragment,{children:[v.open&&(0,H.jsx)(nt,{id:y,title:v.title,items:v.items,active:v.active,onHover:v.setActive,onPick:e=>C(e.insert)}),(0,H.jsx)(`span`,{role:`status`,className:`sr-only`,children:tt(v.open,v.loading,v.items.length,v.trigger)})]}),options:r,actions:i&&o&&(0,H.jsx)(`div`,{className:`mr-1 flex h-7 items-center rounded-lg border border-border p-0.5 text-2xs pointer-coarse:h-10`,title:`While a turn runs`,children:[`queue`,`steer`].map(e=>(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":g===e,onClick:()=>_(e),className:k(`flex h-full items-center gap-1 rounded-md px-2 capitalize text-muted-foreground transition-colors`,g===e&&`bg-accent text-foreground`),children:[e===`queue`?(0,H.jsx)(j,{className:`size-3`}):(0,H.jsx)(P,{className:`size-3`}),e]},e))}),children:(i||a)&&!x&&l?(0,H.jsx)(d,{size:`icon-sm`,variant:`secondary`,className:`rounded-full`,onClick:l,"aria-label":`Stop`,children:(0,H.jsx)(ce,{className:`size-3 fill-current`})}):(0,H.jsx)(d,{size:`icon-sm`,className:`rounded-full transition-transform hover:scale-105`,onClick:()=>S(),disabled:!x||s,"aria-label":i?o?`${g} message`:`Queue message`:`Send`,children:i?g===`steer`&&o?(0,H.jsx)(P,{}):(0,H.jsx)(j,{}):(0,H.jsx)(ne,{})})})}function ct({session:e,running:n,checking:r=!1}){let i=t(),a=c(e=>e.runner.providers,[]),{setText:o,clear:s}=F.getState(),l=a.find(t=>t.id===e.provider),d=f({mutationFn:({sendMode:t,input:n})=>Se(i,e,n,t),onMutate:()=>s(e.id),onSuccess:(e,{sendMode:t})=>{t===`steer`&&u(`Sent to the running turn`)},onError:(t,{input:n})=>{o(e.id,n.text),u.error(`Message not sent`,{description:t.message})}}),p=f({mutationFn:()=>i.interrupt(e.id)});return(0,H.jsx)(st,{draftKey:e.id,source:{kind:`session`,sessionId:e.id},placeholder:n?`Queue a follow-up, or steer the running turn…`:q[e.role],options:(0,H.jsx)(Ze,{session:e,running:n}),running:n,stoppable:r,canSteer:l?.capabilities.steer??!1,sending:d.isPending,onSend:(e,t)=>d.mutate({sendMode:t,input:e}),onStop:()=>p.mutate()})}var lt={choice:De,workKey:``};function $(e,t){return e.drafts[t]??lt}var ut=n()(pe(e=>({drafts:{},firstMessages:{},setChoice:(t,n)=>e(e=>{let r=$(e,t);return{drafts:{...e.drafts,[t]:{...r,choice:{...r.choice,...n}}}}}),setWorkKey:(t,n)=>e(e=>({drafts:{...e.drafts,[t]:{...$(e,t),workKey:n}}})),reset:t=>e(e=>{let{[t]:n,...r}=e.drafts;return{drafts:r}}),setFirstMessage:(t,n)=>e(e=>({firstMessages:{...e.firstMessages,[t]:n}}))}),{name:`codeden.new-session`,partialize:({drafts:e})=>({drafts:e})}));export{Je as a,Z as c,Y as d,X as f,ct as i,J as l,W as m,ut as n,Ke as o,Ne as p,st as r,Q as s,$ as t,q as u};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,jt as n,yt as r}from"./api-yvn34iKU.js";import{n as i,t as a}from"./jsx-runtime-C3cWAN_r.js";import{F as o,t as s}from"./useQuery-VSotSwry.js";import{D as c,_ as l,j as u,m as d,yt as f}from"./format-D3kairnQ.js";import{a as p,c as m,i as h,l as g,n as _,o as v,r as y,s as b,t as x}from"./dropdown-menu-Bflkx6wY.js";import{F as S,I as C,R as w,h as T,m as E}from"./mobile-nav-CrjrDJZ5.js";import{d as D,r as O}from"./switch-BHplnCdo.js";import{t as k}from"./dist-wxbqfqV1.js";import{g as A}from"./logic-BTt00I9b.js";import{Bt as j,Ct as ee,D as te,Dr as ne,En as re,Ht as ie,Lt as M,O as ae,On as oe,St as se,T as ce,Zn as N,_n as le,lt as ue,n as de,pr as fe,t as P}from"./icons-COCLuOtb.js";import{a as pe}from"./theme-3eeE0sp4.js";import{r as F,t as I}from"./composer-B1tdNGSi.js";import{i as L}from"./settings-ui-Bc6ymtc_.js";import{d as me,f as he,h as ge,l as R,m as z,p as _e,t as ve}from"./model-picker-DnKv2cbc.js";import{a as ye,r as be,s as xe}from"./engines-pLQJYIu_.js";import{t as Se}from"./send-to-session-CdnAb3k6.js";import{i as Ce,n as we,t as B}from"./autonomy-Bx33JDEO.js";import{t as Te}from"./footer-BFGvnowz.js";import{t as Ee}from"./tap-tooltip-Pz23Abjm.js";import{a as De}from"./new-session-Bc93-xJK.js";var V=e(i(),1),H=a(),Oe=0,U=()=>`att-${Date.now().toString(36)}-${Oe++}`;function W(e){return e.map(e=>e.type===`image`?{type:`image`,mediaType:e.mediaType,name:e.name,source:{type:`base64`,data:e.data}}:{type:`file`,path:e.path,name:e.name})}async function ke(e){let t=[];for(let n of e){let e=r.safeParse(n.type);if(e.success){let r=await new Promise((e,t)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>t(r.error),r.readAsDataURL(n)});t.push({id:U(),type:`image`,name:n.name||`pasted-image.png`,mediaType:e.data,data:r.slice(r.indexOf(`,`)+1),previewUrl:r})}else t.push({id:U(),type:`file`,name:n.name,path:n.name})}return t}function Ae({items:e,onRemove:t}){return e.length===0?null:(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,children:e.map(e=>(0,H.jsxs)(`div`,{className:`group relative animate-rise`,children:[e.type===`image`?(0,H.jsx)(`img`,{src:e.previewUrl,alt:e.name,className:`size-14 rounded-lg border border-border object-cover`}):(0,H.jsxs)(`div`,{className:`flex h-14 max-w-44 items-center gap-2 rounded-lg border border-border bg-muted/40 px-2.5`,children:[(0,H.jsx)(oe,{className:`size-4 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`truncate font-mono text-2xs`,children:e.name})]}),(0,H.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,onClick:()=>t(e.id),className:`absolute -top-1.5 -right-1.5 flex size-5 items-center justify-center rounded-full border border-border bg-popover text-muted-foreground opacity-0 shadow-sm transition-opacity group-hover:opacity-100 hover:text-foreground touch:opacity-100`,children:(0,H.jsx)(de,{className:`size-3`})})]},e.id))})}var G=356,K=24,je=16,Me=8;function Ne(e,t){if(!e)return{};let n=Math.max(0,e.viewportHeight-e.top)+Me,r=t===`right`?e.viewportWidth-K-G:K,i=e.right<=r||e.left>=r+G;return{mobileOffset:{bottom:Math.max(je,n)},...i?{}:{offset:{bottom:Math.max(K,n)}}}}function Pe(e){let t=e.getBoundingClientRect();return t.width===0||t.height===0?null:{top:Math.round(t.top),left:Math.round(t.left),right:Math.round(t.right),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}function Fe(e){(0,V.useEffect)(()=>{let t=e.current;if(!t)return;let{setComposerBounds:n}=O.getState(),r=()=>n(Pe(t));r();let i=new ResizeObserver(r);for(let e=t;e;e=e.parentElement)i.observe(e);return window.addEventListener(`resize`,r),()=>{i.disconnect(),window.removeEventListener(`resize`,r),n(null)}},[e])}function Ie(e){let t=20*Math.log10(Math.max(e,1e-6));return Math.min(1,Math.max(0,(t+55)/45))}var Le=[.55,.85,1,.8,.6];function Re({store:e}){let t=(0,V.useSyncExternalStore)(e.subscribe,e.get);if(t===null)return(0,H.jsxs)(`span`,{"aria-hidden":!0,className:`relative mt-[7px] flex size-2 shrink-0`,children:[(0,H.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-full bg-status-failed/50`}),(0,H.jsx)(`span`,{className:`relative size-2 rounded-full bg-status-failed`})]});let n=Ie(t);return(0,H.jsx)(`span`,{"aria-hidden":!0,"data-testid":`dictation-level`,className:`mt-[3px] flex h-4 shrink-0 items-center gap-[2px]`,children:Le.map(e=>(0,H.jsx)(`span`,{className:`w-[3px] rounded-full bg-status-failed/80 transition-[height] duration-75`,style:{height:`${20+80*n*e}%`}},e))})}function ze({dictation:e}){let{phase:t,draft:n,pending:r,heard:i,engine:a,level:o}=e;if(t===`idle`)return null;let s=n?null:t===`finishing`||r>0?`Transcribing…`:`Listening…`;return(0,H.jsxs)(`div`,{"data-testid":`dictation-strip`,className:`flex items-start gap-2 px-4 pb-1.5 text-[13px] leading-relaxed text-muted-foreground`,children:[t===`listening`?(0,H.jsx)(Re,{store:o}):(0,H.jsx)(M,{"aria-hidden":!0,className:`mt-[3px] size-3.5 shrink-0 animate-spin`}),n&&(0,H.jsx)(`span`,{"data-testid":`dictation-draft`,className:`min-w-0 italic text-muted-foreground/75`,children:n}),s&&(0,H.jsxs)(`span`,{role:`status`,children:[s,s===`Listening…`&&!i&&a.live===`segments`&&(0,H.jsx)(`span`,{className:`text-muted-foreground/60`,children:` Text appears after each pause.`})]})]})}function Be(){let e=null,t=new Set;return{get:()=>e,set(n){if(n!==e){e=n;for(let e of t)e()}},subscribe(e){return t.add(e),()=>t.delete(e)}}}function Ve(e){let n=t(),{settings:r}=L(),i=r.voice.dictation.engine;return(0,V.useMemo)(()=>e||(i===`browser`?be:ye(n,i)),[e,i,n])}function He({baseText:e,onText:t,language:n,engine:r}){let i=Ve(r),{settings:a}=L(),o=a.voice.dictation.pushToTalkShortcut??null,s=ge(`dictate`).combo,[c,l]=(0,V.useState)(`idle`),[d,f]=(0,V.useState)(``),[p,m]=(0,V.useState)(0),[h,g]=(0,V.useState)(!1),[_]=(0,V.useState)(Be),v=(0,V.useRef)(`idle`),y=(0,V.useRef)(!1),b=e=>{v.current=e,l(e)},x=()=>{if(!i.supported||v.current!==`idle`)return;y.current=!1;let r=e.trimEnd(),a=e=>t(r?r+xe(r,e)+e:e);b(`listening`),f(``),m(0),g(!1),_.set(null),i.start({language:n,onText:e=>{f(e.draft),(e.final||e.draft)&&g(!0),e.final&&a(e.final)},onLevel:e=>_.set(e),onPending:m,onEnd:()=>{b(`idle`),f(``),m(0),_.set(null)},onError:e=>{v.current!==`idle`&&b(i.finishesAfterStop?`finishing`:`idle`),u.error(`Dictation stopped`,{description:e})}})},S=()=>{v.current===`listening`&&(b(i.finishesAfterStop?`finishing`:`idle`),i.stop())},C=()=>v.current===`listening`?S():x(),w=(0,V.useRef)({toggle:C,start:x,stop:S});return w.current={toggle:C,start:x,stop:S},(0,V.useEffect)(()=>{let e=e=>o!==null&&!_e(o)&&he(e.target),t=t=>{i.supported&&(o&&z(t,o)&&!e(t)?(t.preventDefault(),!t.repeat&&v.current===`idle`&&(w.current.start(),y.current=!0)):z(t,s)&&(t.preventDefault(),w.current.toggle()))},n=e=>{if(!o||!y.current)return;let t=o.split(`+`).at(-1)?.toLowerCase();t&&(e.key.toLowerCase()===t||e.code.toLowerCase()===t)&&w.current.stop()};return window.addEventListener(`keydown`,t),window.addEventListener(`keyup`,n),()=>{window.removeEventListener(`keydown`,t),window.removeEventListener(`keyup`,n)}},[s,o,i.supported]),(0,V.useEffect)(()=>()=>{v.current===`listening`&&i.stop()},[i]),{engine:i,phase:c,draft:d,pending:p,heard:h,level:_,combo:s,pushToTalk:o,start:x,stop:S,toggle:C}}function Ue({dictation:e}){let{engine:t,phase:n,combo:r,pushToTalk:i,toggle:a}=e,o=n===`listening`,s=n===`finishing`,c=t.supported?s?`Transcribing…`:o?`Stop dictation`:`Dictate · ${me(r)}${i?` · hold ${me(i)}`:``}`:`Dictation isn't available in this browser. Choose Local (Whisper) in Settings > Voice.`;return(0,H.jsxs)(S,{children:[(0,H.jsx)(w,{asChild:!0,children:(0,H.jsx)(`span`,{children:(0,H.jsxs)(d,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:!t.supported||s,onClick:a,"aria-label":c,"aria-pressed":o,className:k(`relative text-muted-foreground`,o&&`bg-status-failed/12 text-status-failed hover:bg-status-failed/20 hover:text-status-failed`),children:[s?(0,H.jsx)(M,{className:`animate-spin`}):t.supported?(0,H.jsx)(se,{}):(0,H.jsx)(ee,{}),o&&(0,H.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-[inherit] border border-status-failed/40 [animation-duration:1.6s]`})]})})}),(0,H.jsx)(C,{children:c})]})}var q={orchestrator:`Ask the orchestrator to start a project, triage issues or check on work…`,pm:`Message the project manager…`,agent:`Message the agent — @ to mention files, / for commands and skills`},J=e=>e.text.trim().length>0||e.attachments.length>0,Y=e=>({text:e.text.trim(),attachments:W(e.attachments)}),X=e=>e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing;function Z({draftKey:e,placeholder:t,onKeyDown:n,onCaret:r,textareaRef:i,combobox:a,menu:o,options:s,actions:l,children:u,dictationEngine:f}){let p=F(t=>I(t,e)),m=F(e=>e.focusToken),{setText:h,addAttachments:g,removeAttachment:_}=F.getState(),v=c(e=>e.settings.voice.dictation.language,null),y=He({baseText:p.text,onText:t=>h(e,t),language:v,engine:f}),b=(0,V.useRef)(null),x=i??b,T=(0,V.useRef)(null),E=(0,V.useRef)(null),[D,O]=(0,V.useState)(!1);Fe(E),(0,V.useEffect)(()=>{if(m>0){x.current?.focus();let e=x.current?.value.length??0;x.current?.setSelectionRange(e,e)}},[m,x]);let A=async t=>{t.length>0&&g(e,await ke(t))};return(0,H.jsx)(`div`,{className:`mx-auto w-full max-w-[46rem] px-3 pb-3 sm:px-6 sm:pb-5`,children:(0,H.jsxs)(`div`,{className:`relative`,children:[o,(0,H.jsxs)(`div`,{ref:E,onDragOver:e=>{e.preventDefault(),O(!0)},onDragLeave:()=>O(!1),onDrop:e=>{e.preventDefault(),O(!1),A(Array.from(e.dataTransfer.files))},className:k(`rounded-2xl border border-border bg-card shadow-[0_10px_30px_-18px] shadow-black/40 transition-[border-color,box-shadow] focus-within:border-primary/35 focus-within:shadow-[0_0_0_4px] focus-within:shadow-primary/[0.07]`,D&&`border-dashed border-primary/60 bg-primary/[0.03]`),children:[(0,H.jsx)(Ae,{items:p.attachments,onRemove:t=>_(e,t)}),(0,H.jsx)(`textarea`,{ref:x,value:p.text,rows:1,onChange:t=>{h(e,t.target.value),r?.(t.target.selectionStart)},onSelect:e=>r?.(e.currentTarget.selectionStart),onKeyDown:n,onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length!==0&&(e.preventDefault(),A(t))},placeholder:t,"aria-label":`Message`,role:a?`combobox`:void 0,"aria-autocomplete":a?`list`:void 0,"aria-expanded":a?a.open:void 0,"aria-controls":a?.open?a.listId:void 0,"aria-activedescendant":a?.open?a.activeId:void 0,className:`block max-h-64 min-h-[56px] w-full resize-none bg-transparent px-4 pt-3.5 pb-1 text-[14px] leading-relaxed outline-none [field-sizing:content] placeholder:text-muted-foreground/70`}),(0,H.jsx)(ze,{dictation:y}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-0.5 gap-y-1 px-2 pb-2`,children:[(0,H.jsx)(`input`,{ref:T,type:`file`,multiple:!0,hidden:!0,onChange:e=>void A(Array.from(e.target.files??[]))}),(0,H.jsxs)(S,{children:[(0,H.jsx)(w,{asChild:!0,children:(0,H.jsx)(d,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,onClick:()=>T.current?.click(),"aria-label":`Attach files`,children:(0,H.jsx)(ue,{})})}),(0,H.jsx)(C,{children:`Attach files or paste an image`})]}),s,(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[l,(0,H.jsx)(Ue,{dictation:y}),u]})]})]})]})})}var We=[1,2,3,5,10];function Q({checks:e,value:t,onChange:n,disabled:r}){let i=t.untilPass;return(0,H.jsxs)(x,{children:[(0,H.jsx)(g,{asChild:!0,children:(0,H.jsxs)(d,{variant:`ghost`,size:`sm`,className:k(R,i&&`bg-primary/10 text-primary hover:text-primary`),"aria-label":`Keep going until checks pass`,"aria-pressed":i,disabled:r,children:[(0,H.jsx)(ie,{className:`size-3.5`}),`Checks`,i&&(0,H.jsxs)(`span`,{className:`tabular-nums opacity-80`,children:[`×`,t.maxRounds]})]})}),(0,H.jsxs)(y,{align:`start`,className:`w-80`,"data-testid":`checks-menu`,children:[(0,H.jsx)(_,{checked:i,onCheckedChange:e=>n({...t,untilPass:e===!0}),onSelect:e=>e.preventDefault(),className:`items-start py-1.5`,children:(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block text-[13px]`,children:`Keep going until checks pass`}),(0,H.jsx)(`span`,{className:`block text-2xs text-muted-foreground`,children:`After each turn CodeDen runs the checks and sends failures back to the agent.`})]})}),(0,H.jsx)(m,{}),(0,H.jsx)(p,{className:`text-2xs`,children:`At most this many rounds`}),(0,H.jsx)(v,{value:String(t.maxRounds),onValueChange:e=>n({...t,maxRounds:Number(e)}),children:We.map(e=>(0,H.jsxs)(b,{value:String(e),onSelect:e=>e.preventDefault(),className:`text-[13px]`,children:[e,` `,e===1?`round`:`rounds`,e===3&&(0,H.jsx)(`span`,{className:`ml-auto text-2xs text-muted-foreground`,children:`default`})]},e))}),(0,H.jsx)(m,{}),(0,H.jsx)(p,{className:`text-2xs`,children:`The project's checks`}),(0,H.jsx)(`ul`,{className:`space-y-0.5 px-2 pb-1.5`,children:e.map(e=>(0,H.jsx)(`li`,{className:`truncate font-mono text-[11.5px] text-muted-foreground`,children:e.command},e.command))})]})]})}function Ge({provider:e,wasOn:t,canSwitch:n}){let r=`${e} can't plan first.`;return t?n?`Plan mode is off: ${r} It turns back on when you pick a provider that can plan.`:`Plan mode is off: ${r}`:n?`${r} Pick a provider that can plan to use it.`:r}function Ke({value:e,onChange:t,disabled:n,unavailable:r}){return r?(0,H.jsx)(qe,{...r}):(0,H.jsxs)(S,{children:[(0,H.jsx)(w,{asChild:!0,children:(0,H.jsxs)(d,{variant:`ghost`,size:`sm`,className:k(R,e&&`bg-primary/10 text-primary hover:text-primary`),"aria-label":`Plan mode`,"aria-pressed":e,disabled:n,onClick:()=>t(!e),children:[(0,H.jsx)(N,{className:`size-3.5`}),`Plan`]})}),(0,H.jsx)(C,{className:`max-w-64`,children:e?`Plan mode is on: the agent plans without editing, and starts once you approve the plan.`:`Plan first: the agent explores and proposes a plan before it changes anything.`})]})}function qe(e){let t=Ee(),n=(0,V.useId)(),r=Ge(e);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(S,{...t.root,children:[(0,H.jsx)(w,{asChild:!0,children:(0,H.jsxs)(d,{variant:`ghost`,size:`sm`,className:k(R,`cursor-not-allowed opacity-50 hover:text-muted-foreground`),"aria-label":`Plan mode`,"aria-pressed":!1,"aria-disabled":!0,"aria-describedby":n,...t.trigger,children:[(0,H.jsx)(N,{className:`size-3.5`}),(0,H.jsx)(`span`,{className:k(e.wasOn&&`line-through`),children:`Plan`})]})}),(0,H.jsx)(C,{className:`max-w-64`,children:r})]}),(0,H.jsx)(`span`,{id:n,className:`sr-only`,children:r})]})}function Je({value:e,onChange:t,readOnlySupported:n=!0,heading:r=`Permissions for this session`,disabled:i}){let a=B[e];return(0,H.jsxs)(x,{children:[(0,H.jsx)(g,{asChild:!0,children:(0,H.jsxs)(d,{variant:`ghost`,size:`sm`,className:R,"aria-label":`Permissions`,disabled:i,children:[(0,H.jsx)(a.icon,{className:k(`size-3.5`,a.tone)}),a.short]})}),(0,H.jsxs)(y,{align:`start`,className:`w-80`,"data-testid":`permissions-menu`,children:[(0,H.jsx)(p,{className:`text-2xs`,children:r}),we.map(r=>{let i=B[r],a=r===`read_only`&&!n;return(0,H.jsxs)(h,{disabled:a,onSelect:()=>t(r),className:`items-start py-1.5`,children:[(0,H.jsx)(i.icon,{className:k(`mt-0.5 size-4`,i.tone)}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block text-[13px]`,children:i.label}),(0,H.jsx)(`span`,{className:`block text-2xs text-muted-foreground`,children:a?`This provider can't enforce read-only.`:i.description})]}),r===e&&(0,H.jsx)(fe,{className:`mt-0.5 size-3.5`})]},r)})]})]})}function Ye(e){return e.planMode===void 0?e.untilChecksPass===!1?`Keep going until checks pass: off`:e.untilChecksPass!==void 0||e.checkRounds!==void 0?`Keep going until checks pass${e.checkRounds?`, up to ${e.checkRounds} ${e.checkRounds===1?`round`:`rounds`}`:``}`:e.autonomy===void 0?e.model!==void 0&&e.effort!==void 0?`Model and effort changed`:e.model===void 0?`Effort changed`:`Model changed`:`Permissions: ${B[e.autonomy].label}`:e.planMode?`Plan mode on`:`Plan mode off`}function Xe(e,t,n){if(t)return e.untilChecksPass!==void 0||e.checkRounds!==void 0?`Applies when this turn ends.`:(e.autonomy!==void 0||e.planMode!==void 0)&&n?`Applies from the next tool call.`:`Applies from the next turn.`}function Ze({session:e,running:n}){let r=t(),i=o(),a=D(),s=c(e=>e.runner.providers,[]),d=s.find(t=>t.id===e.provider),p=d?.capabilities.liveAutonomy??!1,m=O(e=>e.setHandoff),h=T(e),g=f({mutationFn:t=>r.updateSession(e.id,t),onSuccess:(t,r)=>{i.setQueryData(l,e=>e&&{...e,sessions:e.sessions.map(e=>e.id===t.id?t:e)}),u.success(Ye(r),{id:`session-options-${e.id}`,description:Xe(r,n,p)})},onError:e=>u.error(`Couldn't change the session`,{description:e.message})}),_=(0,V.useRef)(Promise.resolve()),v=e=>{_.current=_.current.then(()=>g.mutateAsync(e)).catch(()=>{})};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ve,{providers:s,lockedProvider:e.provider,handoff:e.role===`agent`?{blocked:h,lasting:h===E,onHandoff:t=>m({sessionId:e.id,provider:t})}:void 0,switchHint:e.role===`agent`?void 0:A(e.role),footer:e.role===`agent`||s.length<2?void 0:t=>(0,H.jsx)(Te,{note:`${e.role===`orchestrator`?`The orchestrator`:`Project managers`} can run on another provider.`,action:`Change provider`,onClick:()=>{t(),a({to:`/settings/$section`,params:{section:`providers`}})}}),value:{provider:e.provider,model:e.model,effort:e.effort},shortcut:!0,onChange:t=>{let n={};t.model!==e.model&&(n.model=t.model),t.effort!==e.effort&&(n.effort=t.effort),(n.model!==void 0||n.effort!==void 0)&&v(n)}}),e.role===`agent`&&(0,H.jsx)(Je,{value:e.autonomy,readOnlySupported:Ce(d),onChange:t=>{t!==e.autonomy&&v({autonomy:t})}}),e.role===`agent`&&d&&(0,H.jsx)(Ke,{value:e.planMode??!1,unavailable:d.capabilities.planMode?void 0:{provider:d.displayName,wasOn:e.planMode??!1},onChange:e=>v({planMode:e})}),e.role===`agent`&&e.checks&&e.checks.commands.length>0&&e.autonomy!==`read_only`&&(0,H.jsx)(Q,{checks:e.checks.commands,value:e.checks,onChange:e=>v({untilChecksPass:e.untilPass,checkRounds:e.maxRounds})})]})}var Qe={file:re,dir:le,command:te,skill:ae},$e={file:`file`,dir:`folder`,command:`command`,skill:`skill`},et=(e,t)=>`${e}-${t.icon}-${encodeURIComponent(t.id)}`;function tt(e,t,n,r){if(!e||t)return``;let i=n===0?`No matches`:n===1?`1 result`:`${n} results`;return r?.query?`${i} for ${r.kind===`command`?`/`:`@`}${r.query}`:i}function nt({id:e,title:t,items:n,active:r,onHover:i,onPick:a}){let o=(0,V.useRef)(null);return(0,V.useEffect)(()=>{o.current?.querySelector(`[data-index="${r}"]`)?.scrollIntoView({block:`nearest`})},[r]),(0,H.jsxs)(`div`,{className:`absolute inset-x-0 bottom-full z-30 mb-2 overflow-hidden rounded-xl border border-border bg-popover shadow-xl animate-rise`,children:[(0,H.jsx)(`div`,{id:`${e}-title`,className:`border-b border-border px-3 py-1.5 text-3xs font-medium tracking-wider text-muted-foreground uppercase`,children:t}),(0,H.jsxs)(`div`,{ref:o,id:e,role:`listbox`,"aria-labelledby":`${e}-title`,className:`max-h-64 overflow-y-auto p-1 scroll-thin`,children:[n.length===0&&(0,H.jsx)(`div`,{className:`px-2.5 py-2 text-xs text-muted-foreground`,children:`No matches`}),n.map((t,n)=>{let o=Qe[t.icon],s=et(e,t);return(0,H.jsxs)(`div`,{id:s,role:`option`,tabIndex:-1,"aria-selected":n===r,"aria-label":`${t.label}, ${$e[t.icon]}`,"aria-describedby":t.description?`${s}-description`:void 0,"data-index":n,onMouseEnter:()=>i(n),onMouseDown:e=>{e.preventDefault(),a(t)},className:k(`flex cursor-pointer items-center gap-2.5 rounded-md px-2.5 py-1.5 text-[13px]`,n===r&&`bg-accent`),children:[(0,H.jsx)(o,{className:k(`size-3.5 shrink-0`,t.icon===`skill`?`text-primary`:`text-muted-foreground`)}),(0,H.jsx)(`span`,{className:k(`max-w-[70%] shrink-0 truncate`,(t.icon===`file`||t.icon===`dir`)&&`font-mono text-[12px]`),children:t.label}),t.description&&(0,H.jsx)(`span`,{id:`${s}-description`,title:t.description,className:`ml-auto min-w-0 truncate pl-3 text-2xs text-muted-foreground`,children:t.description})]},t.id)})]})]})}function rt(e,t){let n=e.slice(0,t),r=/(^|\s)@([\w./\\-]*)$/.exec(n);if(r){let e=r[2]??``;return{kind:`mention`,query:e,start:t-e.length-1}}let i=/^\/([\w:.-]*)$/.exec(n);return i?{kind:`command`,query:i[1]??``,start:0}:null}function it(e,t){let n=t.toLowerCase(),r=e.filter(e=>e.name.toLowerCase().includes(n)),i=e=>e.name.toLowerCase().startsWith(n);return[...r.filter(i),...r.filter(e=>!i(e))]}function at(e,t,n,r){return{text:`${e.slice(0,n.start)}${r} ${e.slice(t)}`,caret:n.start+r.length+1}}function ot(e,n,r){let i=t(),a=(0,V.useMemo)(()=>rt(n,r),[n,r]),[o,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(0),d=e.kind===`session`?[e.sessionId]:[`project`,e.projectId,e.provider],f=s({queryKey:[`mentions`,...d,a?.kind===`mention`?a.query:null],queryFn:()=>{let t=a?.query??``;return e.kind===`session`?i.searchMentions(e.sessionId,t):i.searchProjectMentions(e.projectId,t)},enabled:a?.kind===`mention`,staleTime:3e4}),p=s({queryKey:[`commands`,...d],queryFn:()=>e.kind===`session`?i.listSlashCommands(e.sessionId):e.provider?i.listProjectSlashCommands(e.projectId,e.provider):Promise.resolve([]),enabled:a?.kind===`command`,staleTime:6e4}),m=(0,V.useMemo)(()=>a?a.kind===`mention`?(f.data??[]).map(e=>({id:e.path,label:e.path,icon:e.kind,insert:`@${e.path}`})):it(p.data??[],a.query).map(e=>({id:e.name,label:`/${e.name}`,description:e.description,icon:e.kind===`skill`?`skill`:`command`,insert:`/${e.name}`})):[],[a,f.data,p.data]);(0,V.useEffect)(()=>u(0),[a?.kind,a?.query]);let h=!!a&&o!==a?.start,g=a?.kind===`mention`?f:p;return{trigger:a,items:m,open:h,loading:!!a&&g.isPending,active:l,setActive:u,dismiss:()=>c(a?.start??null),title:a?.kind===`mention`?`Files`:`Commands & skills`}}function st({draftKey:e,source:t,placeholder:n,options:r,running:i=!1,stoppable:a=!1,canSteer:o=!1,sending:s,onSend:c,onStop:l}){let u=F(t=>I(t,e)),{setText:f}=F.getState(),p=(0,V.useRef)(null),[m,h]=(0,V.useState)(0),[g,_]=(0,V.useState)(`queue`),v=ot(t,u.text,m),y=(0,V.useId)(),b=v.items[v.active],x=J(u),S=e=>{x&&c(Y(u),e??(i?o?g:`queue`:`send`))},C=t=>{if(!v.trigger)return;let n=at(u.text,m,v.trigger,t);f(e,n.text),requestAnimationFrame(()=>{p.current?.setSelectionRange(n.caret,n.caret),h(n.caret)})};return(0,H.jsx)(Z,{draftKey:e,placeholder:n,onKeyDown:e=>{if(v.open&&v.items.length>0){let t=v.items.length;if(e.key===`ArrowDown`){e.preventDefault(),v.setActive((v.active+1)%t);return}if(e.key===`ArrowUp`){e.preventDefault(),v.setActive((v.active-1+t)%t);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=v.items[v.active];t&&C(t.insert);return}if(e.key===`Escape`){e.preventDefault(),v.dismiss();return}}z(e.nativeEvent,ge(`stop`).combo)&&(i||a)&&l?(e.preventDefault(),l()):X(e)&&(e.preventDefault(),S(i&&o&&(e.ctrlKey||e.metaKey)?`steer`:void 0))},onCaret:h,textareaRef:p,combobox:{listId:y,open:v.open,activeId:b&&et(y,b)},menu:(0,H.jsxs)(H.Fragment,{children:[v.open&&(0,H.jsx)(nt,{id:y,title:v.title,items:v.items,active:v.active,onHover:v.setActive,onPick:e=>C(e.insert)}),(0,H.jsx)(`span`,{role:`status`,className:`sr-only`,children:tt(v.open,v.loading,v.items.length,v.trigger)})]}),options:r,actions:i&&o&&(0,H.jsx)(`div`,{className:`mr-1 flex h-7 items-center rounded-lg border border-border p-0.5 text-2xs pointer-coarse:h-10`,title:`While a turn runs`,children:[`queue`,`steer`].map(e=>(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":g===e,onClick:()=>_(e),className:k(`flex h-full items-center gap-1 rounded-md px-2 capitalize text-muted-foreground transition-colors`,g===e&&`bg-accent text-foreground`),children:[e===`queue`?(0,H.jsx)(j,{className:`size-3`}):(0,H.jsx)(P,{className:`size-3`}),e]},e))}),children:(i||a)&&!x&&l?(0,H.jsx)(d,{size:`icon-sm`,variant:`secondary`,className:`rounded-full`,onClick:l,"aria-label":`Stop`,children:(0,H.jsx)(ce,{className:`size-3 fill-current`})}):(0,H.jsx)(d,{size:`icon-sm`,className:`rounded-full transition-transform hover:scale-105`,onClick:()=>S(),disabled:!x||s,"aria-label":i?o?`${g} message`:`Queue message`:`Send`,children:i?g===`steer`&&o?(0,H.jsx)(P,{}):(0,H.jsx)(j,{}):(0,H.jsx)(ne,{})})})}function ct({session:e,running:n,checking:r=!1}){let i=t(),a=c(e=>e.runner.providers,[]),{setText:o,clear:s}=F.getState(),l=a.find(t=>t.id===e.provider),d=f({mutationFn:({sendMode:t,input:n})=>Se(i,e,n,t),onMutate:()=>s(e.id),onSuccess:(e,{sendMode:t})=>{t===`steer`&&u(`Sent to the running turn`)},onError:(t,{input:n})=>{o(e.id,n.text),u.error(`Message not sent`,{description:t.message})}}),p=f({mutationFn:()=>i.interrupt(e.id)});return(0,H.jsx)(st,{draftKey:e.id,source:{kind:`session`,sessionId:e.id},placeholder:n?`Queue a follow-up, or steer the running turn…`:q[e.role],options:(0,H.jsx)(Ze,{session:e,running:n}),running:n,stoppable:r,canSteer:l?.capabilities.steer??!1,sending:d.isPending,onSend:(e,t)=>d.mutate({sendMode:t,input:e}),onStop:()=>p.mutate()})}var lt={choice:De,workKey:``};function $(e,t){return e.drafts[t]??lt}var ut=n()(pe(e=>({drafts:{},firstMessages:{},setChoice:(t,n)=>e(e=>{let r=$(e,t);return{drafts:{...e.drafts,[t]:{...r,choice:{...r.choice,...n}}}}}),setWorkKey:(t,n)=>e(e=>({drafts:{...e.drafts,[t]:{...$(e,t),workKey:n}}})),reset:t=>e(e=>{let{[t]:n,...r}=e.drafts;return{drafts:r}}),setFirstMessage:(t,n)=>e(e=>({firstMessages:{...e.firstMessages,[t]:n}}))}),{name:`codeden.new-session`,partialize:({drafts:e})=>({drafts:e})}));export{Je as a,Z as c,Y as d,X as f,ct as i,J as l,W as m,ut as n,Ke as o,Ne as p,st as r,Q as s,$ as t,q as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Jt as t,Ot as n,Un as r,mn as i,n as a,pr as o,vn as s,xn as c}from"./icons-COCLuOtb.js";import{n as l,t as u}from"./jsx-runtime-C3cWAN_r.js";import{t as d}from"./bits-B2GRjm37.js";import{a as f,d as p,l as m,n as h,o as g,r as _,s as v,t as y}from"./new-session-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Jt as t,Ot as n,Un as r,mn as i,n as a,pr as o,vn as s,xn as c}from"./icons-COCLuOtb.js";import{n as l,t as u}from"./jsx-runtime-C3cWAN_r.js";import{t as d}from"./bits-B2GRjm37.js";import{a as f,d as p,l as m,n as h,o as g,r as _,s as v,t as y}from"./new-session-CUpOffXI.js";import{i as b}from"./autonomy-Bx33JDEO.js";import{c as x,i as ee,n as S,o as te,r as C,s as w,t as ne}from"./new-session-Bc93-xJK.js";import{l as re,t as ie}from"./model-picker-DnKv2cbc.js";import{D as T,E,_ as D,b as ae,j as O,m as k,y as oe,yt as se}from"./format-D3kairnQ.js";import{L as A,a as j,i as M,l as N,r as P,t as F}from"./dropdown-menu-Bflkx6wY.js";import{t as I}from"./conflict-card-Bx8tT_d5.js";import{a as L,t as R}from"./mobile-nav-CrjrDJZ5.js";import{t as z}from"./input-CPpbtC2H.js";import{t as B}from"./label-Bm_8Eqe2.js";import{n as V,r as H,t as U}from"./popover-BqwWmyWQ.js";import{F as W}from"./useQuery-VSotSwry.js";import{d as G}from"./switch-BHplnCdo.js";import{i as ce}from"./api-yvn34iKU.js";import{n as K,r as q,t as J}from"./composer-B1tdNGSi.js";var Y=e(l(),1),X=u();function Z({path:e}){return(0,X.jsxs)(F,{children:[(0,X.jsx)(N,{asChild:!0,children:(0,X.jsxs)(k,{variant:`ghost`,size:`sm`,className:re,"aria-label":`Workspace`,children:[(0,X.jsx)(c,{className:`size-3.5`}),`Project folder`]})}),(0,X.jsxs)(P,{align:`start`,className:`w-80`,"data-testid":`workspace-menu`,children:[(0,X.jsx)(j,{className:`text-2xs`,children:`Where the new session runs`}),(0,X.jsxs)(M,{disabled:!0,className:`items-start py-1.5`,children:[(0,X.jsx)(i,{className:`mt-0.5 size-4`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block text-[13px]`,children:`New worktree`}),(0,X.jsx)(`span`,{className:`block text-2xs text-muted-foreground`,children:S})]})]}),(0,X.jsxs)(M,{className:`items-start py-1.5`,children:[(0,X.jsx)(c,{className:`mt-0.5 size-4`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block text-[13px]`,children:`Project folder`}),(0,X.jsx)(`span`,{className:`block break-all text-2xs text-muted-foreground`,children:e})]}),(0,X.jsx)(o,{className:`mt-0.5 size-3.5`})]})]})]})}function le({providers:e,choice:t,resolved:n,checks:r,projectPath:i,onChange:a}){let{provider:o}=n,s=n.workspace===`repo_root`&&(0,X.jsx)(Z,{path:i});return o?(0,X.jsxs)(X.Fragment,{children:[s,(0,X.jsx)(ie,{providers:e,value:{provider:o.id,model:n.model,effort:n.effort},shortcut:!0,onChange:e=>a(w(t,e))}),(0,X.jsx)(f,{value:n.autonomy,heading:`Permissions for the new session`,readOnlySupported:b(o),onChange:e=>a({...t,autonomy:e})}),(0,X.jsx)(g,{value:n.planMode,unavailable:o.capabilities.planMode?void 0:{provider:o.displayName,wasOn:t.planMode,canSwitch:!0},onChange:e=>a({...t,planMode:e})}),r.length>0&&n.autonomy!==`read_only`&&(0,X.jsx)(v,{checks:r,value:{untilPass:n.untilChecksPass,maxRounds:n.checkRounds},onChange:e=>a({...t,untilChecksPass:e.untilPass,checkRounds:e.maxRounds})})]}):(0,X.jsxs)(X.Fragment,{children:[s,(0,X.jsx)(`span`,{className:`px-2 text-xs text-muted-foreground`,children:`No agent provider ready`})]})}function ue({project:e,workKey:n,onWorkKey:i}){let o=n.trim();return(0,X.jsxs)(`header`,{className:`@container flex h-12 shrink-0 items-center gap-2.5 border-b border-border px-4`,children:[(0,X.jsx)(R,{}),(0,X.jsx)(L,{project:e}),(0,X.jsxs)(`div`,{className:`flex min-w-0 shrink items-baseline gap-2 overflow-hidden`,children:[(0,X.jsxs)(A,{to:`/projects/$projectId`,params:{projectId:e.id},className:`hidden shrink-0 text-[13px] text-muted-foreground hover:text-foreground @[36rem]:inline`,children:[e.name,` `,(0,X.jsx)(`span`,{className:`text-muted-foreground/50`,children:`/`})]}),(0,X.jsx)(`h1`,{className:`min-w-0 truncate text-[14px] font-medium`,children:`New session`}),(0,X.jsx)(`span`,{className:`shrink-0 text-2xs text-muted-foreground`,children:`Not started`})]}),o&&(0,X.jsxs)(`span`,{title:`Work key: sessions with the same key are flagged as duplicates`,className:`ml-1 inline-flex h-6 max-w-44 items-center gap-1.5 rounded-md border border-border/80 px-2 text-2xs text-muted-foreground [&_svg]:size-3`,"data-testid":`work-key-chip`,children:[(0,X.jsx)(t,{}),(0,X.jsx)(`span`,{className:`truncate font-mono`,children:o})]}),(0,X.jsx)(`div`,{className:`ml-auto flex shrink-0 items-center`,children:(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(k,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Session options`,children:(0,X.jsx)(r,{})})}),(0,X.jsxs)(V,{align:`end`,className:`w-80 space-y-2`,children:[(0,X.jsxs)(B,{htmlFor:`new-session-work-key`,className:`text-[13px]`,children:[`Work key `,(0,X.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional)`})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(z,{id:`new-session-work-key`,value:n,onChange:e=>i(e.target.value),placeholder:`issue:151`,className:`font-mono text-[13px]`}),n&&(0,X.jsx)(k,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,onClick:()=>i(``),"aria-label":`Clear the work key`,children:(0,X.jsx)(a,{})})]}),(0,X.jsx)(`p`,{className:`text-2xs text-muted-foreground`,children:`Sessions with the same key are flagged as duplicates before anything starts. Without one, CodeDen derives it from the task.`})]})]})})]})}async function Q(e,t,n){let r=e=>!!e?.sessions.some(e=>e.id===n);if(!r(t.getQueryData(D)))try{let{session:i}=await e.getSessionDetail(n);t.setQueryData(D,e=>e&&!r(e)?{...e,sessions:[...e.sessions,i]}:e)}catch{}}var $=e=>!e.id.startsWith(ne);function de(e,t,n){let r=ce(),i=W(),a=G(),o=K(e),s=q(e=>J(e,o)),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(void 0),d=(t,n,r)=>{n&&h.getState().setFirstMessage(t,n),q.getState().clear(o),h.getState().reset(e),l(null),a({to:`/sessions/$sessionId`,params:{sessionId:t},replace:r})},f=()=>void a({to:`/projects/$projectId`,params:{projectId:e}}),g=()=>{let r=J(q.getState(),o);if(!m(r))throw Error(`Write the task in the composer first`);return C(e,p(r),t,n)},_=se({mutationFn:async a=>{let o=c&&$(c.record)?c.record.id:void 0,s=C(e,a,t,n),l=await r.startSession(o?{...s,replacesConflict:o}:s);return l.status===`conflict`?{request:s,result:l,record:(l.conflictId?(await r.listConflicts({projectId:e})).find(e=>e.id===l.conflictId):void 0)??te(s,l)}:((l.status===`started`||l.status===`queued`)&&await Q(r,i,l.sessionId),{request:s,result:l,record:null})},onSuccess:({request:e,result:t,record:n})=>{switch(i.invalidateQueries({queryKey:[`conflicts`]}),t.status){case`conflict`:l(n?{record:n,request:e}:null);return;case`skipped`:f();return;case`queued`:O(`Queued behind running work`),d(t.sessionId,e.input,!0);return;case`started`:d(t.sessionId,e.input,!0);return;case`joined`:d(t.sessionId,void 0,!0);return}},onError:e=>O.error(`Couldn't start the session`,{description:e.message})}),v=!!c&&(c?.request.workKey??``)!==n.trim(),y=async e=>{if(!c)throw Error(`No conflict to resolve`);let{record:t}=c,n=e.resolution===`skip`;if(!n&&v)throw Error(`The work key changed: send the draft again`);let i=n?c.request:{...g(),workKey:t.request.workKey};if(u.current=i.input,!$(t))return r.startSession({...i,conflict:e});let a=e.resolution===`skip`?{}:{start:i};return(await r.resolveConflict(t.id,{...e,...a})).result},b=t=>{let n=u.current;if(t.sessionId&&[`started`,`queued`,`joined`].includes(t.status)){let a=t.status!==`joined`;a&&Q(r,i,t.sessionId),a&&n&&h.getState().setFirstMessage(t.sessionId,n),q.getState().clear(o),h.getState().reset(e),l(null)}else l(null),f()},x=m(s),S=c&&{...c.record,request:{...c.record.request,purpose:x?ee(s.text)??`New session`:c.record.request.purpose}};return{send:e=>{_.isPending||_.mutate(e)},sending:_.isPending,conflict:S,startBlocked:x?v?`The work key changed: send the draft again to check it`:null:`The composer is empty: write the task to start it, or skip`,decide:y,onConflictResolved:b}}function fe({projectId:e}){let t=E().data!==void 0,r=oe(e),i=T(e=>e.runner.providers,[]),a=T(e=>e.settings.autonomy.default,`auto`),o=T(e=>e.settings.providers.agent,null),c=h(t=>y(t,e)),{setChoice:l,setWorkKey:u}=h.getState(),f=(0,Y.useMemo)(()=>x(c.choice,{providers:i,project:r,agent:o,defaultAutonomy:a}),[c.choice,i,r,o,a]),p=de(e,f,c.workKey),m=ae(e);return(0,Y.useEffect)(()=>q.getState().focus(),[]),t?r?(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`new-session`,children:[(0,X.jsx)(ue,{project:r,workKey:c.workKey,onWorkKey:t=>u(e,t)}),(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:(0,X.jsxs)(d,{icon:(0,X.jsx)(n,{}),title:`New session`,className:`flex-1`,children:[f.workspace===`repo_root`?`Describe the task. The agent works in the project folder itself: it isn't a git repository, so there is no worktree.`:`Describe the task. The agent works in its own worktree and branch.`,` `,`Nothing is created until you send.`]})}),p.conflict&&(0,X.jsx)(`div`,{className:`mx-auto w-full max-w-[46rem] px-3 pb-2 sm:px-6`,children:(0,X.jsx)(I,{conflict:p.conflict,decideWith:p.decide,onResolved:p.onConflictResolved,startBlocked:p.startBlocked,replace:!0})}),(0,X.jsx)(_,{draftKey:K(e),source:{kind:`project`,projectId:e,provider:f.provider?.id??null},placeholder:`Describe the task — @ to mention files, / for commands and skills`,options:(0,X.jsx)(le,{providers:i,choice:c.choice,resolved:f,checks:m,projectPath:r.path,onChange:t=>l(e,t)}),sending:p.sending,onSend:e=>p.send(e)})]}):(0,X.jsx)(d,{icon:(0,X.jsx)(s,{}),title:`Project not found`,className:`flex-1`,children:`It may have been archived.`}):null}export{fe as NewSessionPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./api-B620HpC2.js";import{t}from"./jsx-runtime-C3cWAN_r.js";import{F as n}from"./useQuery-VSotSwry.js";import{D as r,f as i,j as a,m as o,n as s,t as c,yt as l}from"./format-D1ma_o2D.js";import{C as u,D as d,L as f,O as p,S as m,k as h,y as g}from"./dropdown-menu-C4XI7F63.js";import{O as _,p as v}from"./mobile-nav-D8FZcJzG.js";import{t as y}from"./switch-DuBpF2_h.js";import{t as b}from"./dist-wxbqfqV1.js";import{Cr as x,O as S,X as C,Xn as w,ct as T,i as E,in as D,j as O,l as k,m as A,rt as j,t as M,tt as N,vr as P}from"./icons-COCLuOtb.js";import{o as F,t as I}from"./bits-B2GRjm37.js";import{a as L,l as R,o as z,p as B}from"./meta-CSV1Er3C.js";import{r as V,t as H}from"./run-conflict-CPr9OWa3.js";var U=t(),W={cron:w,event:M,manual:D};function G({item:e,projectId:t,actions:n,compact:r=!1}){let a=e.automation,c=m(e,t),l=u(e,t),d=W[a.trigger.type],p=e.lastRun,h=l&&c&&!c.enabled;return(0,U.jsxs)(`div`,{className:`group flex items-center gap-3 border-b border-border px-3.5 py-2.5 last:border-0 hover:bg-accent/30`,"data-testid":`automation-row`,"data-automation":a.id,children:[(0,U.jsx)(`span`,{className:b(`flex size-7 shrink-0 items-center justify-center rounded-lg border border-border bg-surface text-muted-foreground`,c?.enabled&&`border-primary/25 bg-primary/8 text-primary`),children:(0,U.jsx)(d,{className:`size-3.5`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(f,{to:`/projects/$projectId/automations/$automationId`,params:{projectId:t,automationId:a.id},className:`truncate text-[13px] font-medium hover:underline`,children:a.name}),(0,U.jsx)(V,{item:e}),c?.paused&&(0,U.jsx)(`span`,{className:`rounded bg-status-waiting/12 px-1.5 py-px text-3xs text-status-waiting`,children:`Paused`}),c?.enabledOverride!=null&&(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px text-3xs text-muted-foreground`,children:`Project override`})]}),!r&&a.description&&(0,U.jsx)(`p`,{className:`truncate text-2xs text-muted-foreground`,children:a.description}),(0,U.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-3xs text-muted-foreground/90`,children:[(0,U.jsx)(`span`,{children:R(a.trigger)}),c?.nextRunAt&&(0,U.jsxs)(`span`,{className:`text-foreground/70`,children:[`· next `,i(c.nextRunAt),c.skipNextAt===c.nextRunAt&&` (skipped)`]}),h&&(0,U.jsx)(`span`,{className:`text-status-waiting`,children:`· off for this project`}),p&&(0,U.jsxs)(`span`,{className:`flex items-center gap-1`,title:p.purpose,children:[`· `,(0,U.jsx)(_,{tone:L[p.status].tone,className:`size-1.5`}),L[p.status].label,p.skipReason&&` (${z[p.skipReason].toLowerCase()})`,` `,s(p.startedAt)]})]})]}),!r&&c?.enabled&&a.trigger.type!==`manual`&&(0,U.jsx)(o,{size:`icon-xs`,variant:`ghost`,className:`text-muted-foreground opacity-0 group-hover:opacity-100 focus-visible:opacity-100 touch:opacity-100`,"aria-label":c.paused?`Resume ${a.name}`:`Pause ${a.name}`,onClick:()=>n.pause.mutate({id:a.id,paused:!c.paused}),children:c.paused?(0,U.jsx)(j,{}):(0,U.jsx)(T,{})}),(0,U.jsxs)(o,{size:`xs`,variant:`ghost`,className:`text-muted-foreground`,disabled:n.run.isPending||a.action.type===`triage`,title:a.action.type===`triage`?`Triage runs when an issue opens`:`Run now`,onClick:()=>n.run.mutate({id:a.id,name:a.name}),children:[(0,U.jsx)(j,{}),` Run`]}),(0,U.jsx)(y,{checked:l,onCheckedChange:t=>n.toggle.mutate({item:e,enabled:t}),"aria-label":`Enable ${a.name}`})]})}function K({projectId:t}){let i=e(),s=n(),c=r(e=>e.settings.automations.enabled,!1),u=p(t),d=()=>void s.invalidateQueries({queryKey:g.all}),f=l({mutationFn:e=>i.updateSettings({automations:{enabled:e}}),onSuccess:(e,t)=>a.success(t?`Automations on`:`All automations paused`)}),m=l({mutationFn:e=>i.automations.setProjectEnabled(t,e),onSuccess:d}),h=l({mutationFn:()=>i.automations.reload(),onSuccess:e=>{a.success(`Automation files re-read`,{description:e.errors.length?`${e.errors.length} file(s) have errors`:void 0}),d()}});return(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 gap-y-2 text-xs`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(y,{checked:c,onCheckedChange:e=>f.mutate(e),"aria-label":`Automations on globally`}),(0,U.jsx)(`span`,{children:`All projects`})]}),(0,U.jsxs)(`div`,{className:b(`flex items-center gap-2`,!c&&`opacity-60`),children:[(0,U.jsx)(y,{checked:u.data?.enabled??!0,onCheckedChange:e=>m.mutate(e),"aria-label":`Automations on for this project`}),(0,U.jsx)(`span`,{children:`This project`})]}),(0,U.jsxs)(o,{size:`xs`,variant:`ghost`,className:`ml-auto text-muted-foreground`,onClick:()=>h.mutate(),disabled:h.isPending,children:[(0,U.jsx)(C,{className:b(h.isPending&&`animate-spin`)}),` Reload files`]})]})}function q({projectId:t,compact:r=!1}){let i=e(),a=n(),{data:s,isLoading:c}=d(t),u=v(t),p=l({mutationFn:()=>i.automations.starterSet(t,!1),onSuccess:()=>void a.invalidateQueries({queryKey:g.all})}),m=s?.automations??[],h=[...m].sort((e,t)=>Number(t.states[0]?.enabled??!1)-Number(e.states[0]?.enabled??!1)||e.automation.name.localeCompare(t.automation.name));return(0,U.jsxs)(`div`,{className:`space-y-3`,children:[!r&&(0,U.jsx)(K,{projectId:t}),s?.errors.map(e=>(0,U.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-status-failed/30 bg-status-failed/5 px-3 py-2 text-2xs`,children:[(0,U.jsx)(A,{className:`mt-px size-3.5 shrink-0 text-status-failed`}),(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsx)(`code`,{className:`font-mono`,children:e.path}),(0,U.jsx)(`span`,{className:`block text-muted-foreground`,children:e.message})]})]},e.path)),u.conflict&&(0,U.jsx)(H,{conflict:u.conflict,projectId:t,onClose:()=>u.setConflict(null)}),!c&&m.length===0?(0,U.jsx)(`div`,{className:`rounded-xl border border-dashed border-border`,children:(0,U.jsx)(I,{icon:(0,U.jsx)(E,{}),title:`No automations yet`,action:(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[(0,U.jsx)(o,{size:`sm`,asChild:!0,children:(0,U.jsxs)(f,{to:`/projects/$projectId/automations/new`,params:{projectId:t},children:[(0,U.jsx)(N,{}),` New automation`]})}),(0,U.jsxs)(o,{size:`sm`,variant:`outline`,onClick:()=>p.mutate(),disabled:p.isPending,children:[(0,U.jsx)(S,{}),` Add the starter set`]}),(0,U.jsx)(o,{size:`sm`,variant:`outline`,asChild:!0,children:(0,U.jsx)(f,{to:`/projects/$projectId/automations`,params:{projectId:t},search:{tab:`templates`},children:`Browse templates`})})]}),children:`Scheduled audits, dependency updates, triage and more. Everything starts off.`})}):(0,U.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card`,"data-testid":`automations-list`,children:h.map(e=>(0,U.jsx)(G,{item:e,projectId:t,actions:u,compact:r},e.automation.id))})]})}var J={user:k,orchestrator:x,pm:x,automation:E},Y={user:`you`,orchestrator:`orchestrator`,pm:`PM`,automation:`automation`};function X(e){return e===`queued`?`Queued behind running work`:e===`waiting`?`Waiting for your answer in the inbox`:e===`starting`||e===`created`?`Starting…`:`Working…`}function Z({work:e,title:t}){let n=J[e.startedBy.kind],r=e.status===`waiting`,i=e.status===`queued`,a=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(_,{tone:r?`waiting`:i?`idle`:`running`}),(0,U.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:t??e.purpose})]}),(0,U.jsx)(`p`,{className:`line-clamp-2 min-h-8 text-2xs leading-4 text-muted-foreground`,children:e.progress?.text??X(e.status)}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 text-3xs text-muted-foreground/80`,children:[(0,U.jsx)(n,{className:`size-3`,"aria-label":`Started by ${Y[e.startedBy.kind]}`}),(0,U.jsx)(`code`,{className:`truncate font-mono`,title:`Work key`,children:e.workKey}),(0,U.jsx)(`span`,{className:b(`ml-auto shrink-0`,r&&`font-medium text-status-waiting`),title:`Started ${new Date(e.startedAt).toLocaleString()}`,children:r?`Waiting on you`:i?`Queued`:c(e.startedAt)})]})]}),o=`group flex w-64 shrink-0 flex-col gap-1.5 rounded-xl border border-border bg-card px-3 py-2.5 transition-colors hover:border-primary/30`;return e.sessionId?(0,U.jsx)(f,{to:`/sessions/$sessionId`,params:{sessionId:e.sessionId},className:o,"data-testid":`now-card`,children:a}):(0,U.jsx)(`div`,{className:o,"data-testid":`now-card`,children:a})}function Q({run:t}){let r=e(),o=n(),s=l({mutationFn:()=>r.automations.skipNext(t.automationId,t.projectId??``),onSuccess:e=>{a.success(e?`Skipped the ${B(t.at)} run`:`Nothing left to skip`),o.invalidateQueries({queryKey:g.all})},onError:e=>a.error(`Couldn't skip the run`,{description:e.message})});return(0,U.jsxs)(`div`,{className:b(`group flex items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px]`,t.skipped&&`opacity-60`),"data-testid":`next-run`,"data-skipped":t.skipped||void 0,title:`${t.workKey} · ${B(t.at)}`,children:[(0,U.jsx)(P,{className:`size-3.5 shrink-0 text-muted-foreground`}),t.projectId?(0,U.jsx)(f,{to:`/projects/$projectId/automations/$automationId`,params:{projectId:t.projectId,automationId:t.automationId},className:b(`truncate hover:underline`,t.skipped&&`line-through`),children:t.name}):(0,U.jsx)(`span`,{className:b(`truncate`,t.skipped&&`line-through`),children:t.name}),(0,U.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs text-muted-foreground tabular-nums`,children:i(t.at)}),t.skipped?(0,U.jsx)(`span`,{className:`shrink-0 px-1.5 text-3xs text-status-waiting`,children:`Skipped`}):(0,U.jsxs)(`button`,{type:`button`,onClick:()=>s.mutate(),disabled:s.isPending||!t.projectId,"aria-label":`Skip the next ${t.name} run`,className:`flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-3xs text-muted-foreground hover:bg-accent hover:text-foreground pointer-coarse:min-h-10 pointer-coarse:px-2.5`,children:[(0,U.jsx)(O,{className:`size-3`}),` Skip`]})]})}function $({projectId:e,limit:t=6}){let{data:n,isLoading:r}=h(e),i=n??[];return(0,U.jsx)(`div`,{className:`rounded-xl border border-border bg-card p-1`,"data-testid":`next-runs`,children:i.length===0?(0,U.jsx)(`p`,{className:`px-3 py-5 text-center text-xs text-muted-foreground`,children:r?`Loading the schedule…`:`No scheduled runs. Enabled scheduled automations show their next runs here.`}):i.slice(0,t).map(e=>(0,U.jsx)(Q,{run:e},`${e.automationId}-${e.at}`))})}function ee({work:e,projectId:t,titleOf:n}){let r=e.filter(e=>e.status!==`queued`).length;return(0,U.jsxs)(`section`,{className:`grid grid-cols-[minmax(0,1fr)] gap-4 lg:grid-cols-[minmax(0,1fr)_300px]`,"data-testid":`now-next`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(F,{className:`mb-2 flex items-center gap-2`,children:[`Now`,` `,(0,U.jsx)(`span`,{className:`rounded-full bg-status-running/15 px-1.5 text-status-running tabular-nums`,children:r}),e.length>r&&(0,U.jsxs)(`span`,{className:`font-normal normal-case tracking-normal`,children:[`· `,e.length-r,` queued`]})]}),e.length===0?(0,U.jsx)(`div`,{className:`rounded-xl border border-dashed border-border px-4 py-6 text-center text-xs text-muted-foreground`,children:`Nothing running right now.`}):(0,U.jsx)(`div`,{className:`flex gap-2 overflow-x-auto pb-1 scroll-thin`,children:e.map(e=>(0,U.jsx)(Z,{work:e,title:n?.(e.sessionId)},e.id))})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(F,{className:`mb-2`,children:`Next`}),(0,U.jsx)($,{projectId:t,limit:5})]})]})}export{W as i,ee as n,q as r,$ as t};
|
|
1
|
+
import{i as e}from"./api-yvn34iKU.js";import{t}from"./jsx-runtime-C3cWAN_r.js";import{F as n}from"./useQuery-VSotSwry.js";import{D as r,f as i,j as a,m as o,n as s,t as c,yt as l}from"./format-D3kairnQ.js";import{C as u,D as d,L as f,O as p,S as m,k as h,y as g}from"./dropdown-menu-Bflkx6wY.js";import{O as _,p as v}from"./mobile-nav-CrjrDJZ5.js";import{t as y}from"./switch-BHplnCdo.js";import{t as b}from"./dist-wxbqfqV1.js";import{Cr as x,O as S,X as C,Xn as w,ct as T,i as E,in as D,j as O,l as k,m as A,rt as j,t as M,tt as N,vr as P}from"./icons-COCLuOtb.js";import{o as F,t as I}from"./bits-B2GRjm37.js";import{a as L,l as R,o as z,p as B}from"./meta-CSV1Er3C.js";import{r as V,t as H}from"./run-conflict-BlgKVpOG.js";var U=t(),W={cron:w,event:M,manual:D};function G({item:e,projectId:t,actions:n,compact:r=!1}){let a=e.automation,c=m(e,t),l=u(e,t),d=W[a.trigger.type],p=e.lastRun,h=l&&c&&!c.enabled;return(0,U.jsxs)(`div`,{className:`group flex items-center gap-3 border-b border-border px-3.5 py-2.5 last:border-0 hover:bg-accent/30`,"data-testid":`automation-row`,"data-automation":a.id,children:[(0,U.jsx)(`span`,{className:b(`flex size-7 shrink-0 items-center justify-center rounded-lg border border-border bg-surface text-muted-foreground`,c?.enabled&&`border-primary/25 bg-primary/8 text-primary`),children:(0,U.jsx)(d,{className:`size-3.5`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(f,{to:`/projects/$projectId/automations/$automationId`,params:{projectId:t,automationId:a.id},className:`truncate text-[13px] font-medium hover:underline`,children:a.name}),(0,U.jsx)(V,{item:e}),c?.paused&&(0,U.jsx)(`span`,{className:`rounded bg-status-waiting/12 px-1.5 py-px text-3xs text-status-waiting`,children:`Paused`}),c?.enabledOverride!=null&&(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px text-3xs text-muted-foreground`,children:`Project override`})]}),!r&&a.description&&(0,U.jsx)(`p`,{className:`truncate text-2xs text-muted-foreground`,children:a.description}),(0,U.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-3xs text-muted-foreground/90`,children:[(0,U.jsx)(`span`,{children:R(a.trigger)}),c?.nextRunAt&&(0,U.jsxs)(`span`,{className:`text-foreground/70`,children:[`· next `,i(c.nextRunAt),c.skipNextAt===c.nextRunAt&&` (skipped)`]}),h&&(0,U.jsx)(`span`,{className:`text-status-waiting`,children:`· off for this project`}),p&&(0,U.jsxs)(`span`,{className:`flex items-center gap-1`,title:p.purpose,children:[`· `,(0,U.jsx)(_,{tone:L[p.status].tone,className:`size-1.5`}),L[p.status].label,p.skipReason&&` (${z[p.skipReason].toLowerCase()})`,` `,s(p.startedAt)]})]})]}),!r&&c?.enabled&&a.trigger.type!==`manual`&&(0,U.jsx)(o,{size:`icon-xs`,variant:`ghost`,className:`text-muted-foreground opacity-0 group-hover:opacity-100 focus-visible:opacity-100 touch:opacity-100`,"aria-label":c.paused?`Resume ${a.name}`:`Pause ${a.name}`,onClick:()=>n.pause.mutate({id:a.id,paused:!c.paused}),children:c.paused?(0,U.jsx)(j,{}):(0,U.jsx)(T,{})}),(0,U.jsxs)(o,{size:`xs`,variant:`ghost`,className:`text-muted-foreground`,disabled:n.run.isPending||a.action.type===`triage`,title:a.action.type===`triage`?`Triage runs when an issue opens`:`Run now`,onClick:()=>n.run.mutate({id:a.id,name:a.name}),children:[(0,U.jsx)(j,{}),` Run`]}),(0,U.jsx)(y,{checked:l,onCheckedChange:t=>n.toggle.mutate({item:e,enabled:t}),"aria-label":`Enable ${a.name}`})]})}function K({projectId:t}){let i=e(),s=n(),c=r(e=>e.settings.automations.enabled,!1),u=p(t),d=()=>void s.invalidateQueries({queryKey:g.all}),f=l({mutationFn:e=>i.updateSettings({automations:{enabled:e}}),onSuccess:(e,t)=>a.success(t?`Automations on`:`All automations paused`)}),m=l({mutationFn:e=>i.automations.setProjectEnabled(t,e),onSuccess:d}),h=l({mutationFn:()=>i.automations.reload(),onSuccess:e=>{a.success(`Automation files re-read`,{description:e.errors.length?`${e.errors.length} file(s) have errors`:void 0}),d()}});return(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 gap-y-2 text-xs`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(y,{checked:c,onCheckedChange:e=>f.mutate(e),"aria-label":`Automations on globally`}),(0,U.jsx)(`span`,{children:`All projects`})]}),(0,U.jsxs)(`div`,{className:b(`flex items-center gap-2`,!c&&`opacity-60`),children:[(0,U.jsx)(y,{checked:u.data?.enabled??!0,onCheckedChange:e=>m.mutate(e),"aria-label":`Automations on for this project`}),(0,U.jsx)(`span`,{children:`This project`})]}),(0,U.jsxs)(o,{size:`xs`,variant:`ghost`,className:`ml-auto text-muted-foreground`,onClick:()=>h.mutate(),disabled:h.isPending,children:[(0,U.jsx)(C,{className:b(h.isPending&&`animate-spin`)}),` Reload files`]})]})}function q({projectId:t,compact:r=!1}){let i=e(),a=n(),{data:s,isLoading:c}=d(t),u=v(t),p=l({mutationFn:()=>i.automations.starterSet(t,!1),onSuccess:()=>void a.invalidateQueries({queryKey:g.all})}),m=s?.automations??[],h=[...m].sort((e,t)=>Number(t.states[0]?.enabled??!1)-Number(e.states[0]?.enabled??!1)||e.automation.name.localeCompare(t.automation.name));return(0,U.jsxs)(`div`,{className:`space-y-3`,children:[!r&&(0,U.jsx)(K,{projectId:t}),s?.errors.map(e=>(0,U.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-status-failed/30 bg-status-failed/5 px-3 py-2 text-2xs`,children:[(0,U.jsx)(A,{className:`mt-px size-3.5 shrink-0 text-status-failed`}),(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsx)(`code`,{className:`font-mono`,children:e.path}),(0,U.jsx)(`span`,{className:`block text-muted-foreground`,children:e.message})]})]},e.path)),u.conflict&&(0,U.jsx)(H,{conflict:u.conflict,projectId:t,onClose:()=>u.setConflict(null)}),!c&&m.length===0?(0,U.jsx)(`div`,{className:`rounded-xl border border-dashed border-border`,children:(0,U.jsx)(I,{icon:(0,U.jsx)(E,{}),title:`No automations yet`,action:(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[(0,U.jsx)(o,{size:`sm`,asChild:!0,children:(0,U.jsxs)(f,{to:`/projects/$projectId/automations/new`,params:{projectId:t},children:[(0,U.jsx)(N,{}),` New automation`]})}),(0,U.jsxs)(o,{size:`sm`,variant:`outline`,onClick:()=>p.mutate(),disabled:p.isPending,children:[(0,U.jsx)(S,{}),` Add the starter set`]}),(0,U.jsx)(o,{size:`sm`,variant:`outline`,asChild:!0,children:(0,U.jsx)(f,{to:`/projects/$projectId/automations`,params:{projectId:t},search:{tab:`templates`},children:`Browse templates`})})]}),children:`Scheduled audits, dependency updates, triage and more. Everything starts off.`})}):(0,U.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card`,"data-testid":`automations-list`,children:h.map(e=>(0,U.jsx)(G,{item:e,projectId:t,actions:u,compact:r},e.automation.id))})]})}var J={user:k,orchestrator:x,pm:x,automation:E},Y={user:`you`,orchestrator:`orchestrator`,pm:`PM`,automation:`automation`};function X(e){return e===`queued`?`Queued behind running work`:e===`waiting`?`Waiting for your answer in the inbox`:e===`starting`||e===`created`?`Starting…`:`Working…`}function Z({work:e,title:t}){let n=J[e.startedBy.kind],r=e.status===`waiting`,i=e.status===`queued`,a=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(_,{tone:r?`waiting`:i?`idle`:`running`}),(0,U.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:t??e.purpose})]}),(0,U.jsx)(`p`,{className:`line-clamp-2 min-h-8 text-2xs leading-4 text-muted-foreground`,children:e.progress?.text??X(e.status)}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 text-3xs text-muted-foreground/80`,children:[(0,U.jsx)(n,{className:`size-3`,"aria-label":`Started by ${Y[e.startedBy.kind]}`}),(0,U.jsx)(`code`,{className:`truncate font-mono`,title:`Work key`,children:e.workKey}),(0,U.jsx)(`span`,{className:b(`ml-auto shrink-0`,r&&`font-medium text-status-waiting`),title:`Started ${new Date(e.startedAt).toLocaleString()}`,children:r?`Waiting on you`:i?`Queued`:c(e.startedAt)})]})]}),o=`group flex w-64 shrink-0 flex-col gap-1.5 rounded-xl border border-border bg-card px-3 py-2.5 transition-colors hover:border-primary/30`;return e.sessionId?(0,U.jsx)(f,{to:`/sessions/$sessionId`,params:{sessionId:e.sessionId},className:o,"data-testid":`now-card`,children:a}):(0,U.jsx)(`div`,{className:o,"data-testid":`now-card`,children:a})}function Q({run:t}){let r=e(),o=n(),s=l({mutationFn:()=>r.automations.skipNext(t.automationId,t.projectId??``),onSuccess:e=>{a.success(e?`Skipped the ${B(t.at)} run`:`Nothing left to skip`),o.invalidateQueries({queryKey:g.all})},onError:e=>a.error(`Couldn't skip the run`,{description:e.message})});return(0,U.jsxs)(`div`,{className:b(`group flex items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px]`,t.skipped&&`opacity-60`),"data-testid":`next-run`,"data-skipped":t.skipped||void 0,title:`${t.workKey} · ${B(t.at)}`,children:[(0,U.jsx)(P,{className:`size-3.5 shrink-0 text-muted-foreground`}),t.projectId?(0,U.jsx)(f,{to:`/projects/$projectId/automations/$automationId`,params:{projectId:t.projectId,automationId:t.automationId},className:b(`truncate hover:underline`,t.skipped&&`line-through`),children:t.name}):(0,U.jsx)(`span`,{className:b(`truncate`,t.skipped&&`line-through`),children:t.name}),(0,U.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs text-muted-foreground tabular-nums`,children:i(t.at)}),t.skipped?(0,U.jsx)(`span`,{className:`shrink-0 px-1.5 text-3xs text-status-waiting`,children:`Skipped`}):(0,U.jsxs)(`button`,{type:`button`,onClick:()=>s.mutate(),disabled:s.isPending||!t.projectId,"aria-label":`Skip the next ${t.name} run`,className:`flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-3xs text-muted-foreground hover:bg-accent hover:text-foreground pointer-coarse:min-h-10 pointer-coarse:px-2.5`,children:[(0,U.jsx)(O,{className:`size-3`}),` Skip`]})]})}function $({projectId:e,limit:t=6}){let{data:n,isLoading:r}=h(e),i=n??[];return(0,U.jsx)(`div`,{className:`rounded-xl border border-border bg-card p-1`,"data-testid":`next-runs`,children:i.length===0?(0,U.jsx)(`p`,{className:`px-3 py-5 text-center text-xs text-muted-foreground`,children:r?`Loading the schedule…`:`No scheduled runs. Enabled scheduled automations show their next runs here.`}):i.slice(0,t).map(e=>(0,U.jsx)(Q,{run:e},`${e.automationId}-${e.at}`))})}function ee({work:e,projectId:t,titleOf:n}){let r=e.filter(e=>e.status!==`queued`).length;return(0,U.jsxs)(`section`,{className:`grid grid-cols-[minmax(0,1fr)] gap-4 lg:grid-cols-[minmax(0,1fr)_300px]`,"data-testid":`now-next`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(F,{className:`mb-2 flex items-center gap-2`,children:[`Now`,` `,(0,U.jsx)(`span`,{className:`rounded-full bg-status-running/15 px-1.5 text-status-running tabular-nums`,children:r}),e.length>r&&(0,U.jsxs)(`span`,{className:`font-normal normal-case tracking-normal`,children:[`· `,e.length-r,` queued`]})]}),e.length===0?(0,U.jsx)(`div`,{className:`rounded-xl border border-dashed border-border px-4 py-6 text-center text-xs text-muted-foreground`,children:`Nothing running right now.`}):(0,U.jsx)(`div`,{className:`flex gap-2 overflow-x-auto pb-1 scroll-thin`,children:e.map(e=>(0,U.jsx)(Z,{work:e,title:n?.(e.sessionId)},e.id))})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(F,{className:`mb-2`,children:`Next`}),(0,U.jsx)($,{projectId:t,limit:5})]})]})}export{W as i,ee as n,q as r,$ as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-view-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Lt as t,X as n}from"./icons-COCLuOtb.js";import{n as r,t as i}from"./jsx-runtime-C3cWAN_r.js";import{m as a}from"./format-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-view-WNT8FI6K.js","assets/rolldown-runtime-XKyaHtl9.js","assets/jsx-runtime-C3cWAN_r.js","assets/api-yvn34iKU.js","assets/dist-wxbqfqV1.js","assets/theme-3eeE0sp4.js","assets/terminal-view-BrP-ENHg.css","assets/diff-panel-BHhM9z93.js","assets/react-BETlQaef.js","assets/hastToHtml-BM7hjk4v.js","assets/preload-helper-7y9sWmk5.js","assets/lib-DMtK1EFU.js","assets/lib-m_q9jTTN.js","assets/unwrapDefault-ByDmBtHB.js","assets/constants-CmGPilXJ.js","assets/formatCSSVariablePrefix-KRh9vnZf.js","assets/format-D3kairnQ.js","assets/useQuery-VSotSwry.js","assets/clsx-BxLRjTE8.js","assets/icons-COCLuOtb.js","assets/bits-B2GRjm37.js","assets/dropdown-menu-Bflkx6wY.js","assets/skeleton-D8Sbd2jT.js","assets/shallow-BUNpybIA.js","assets/archived-sessions-C1-stU7x.js","assets/useInfiniteQuery-CoCb1Ya8.js","assets/factory-DVCs5zxg.js","assets/updates-4l7pwDq1.js","assets/composer-B1tdNGSi.js","assets/popover-BqwWmyWQ.js","assets/textarea-gD4G5Znx.js","assets/send-to-session-CdnAb3k6.js","assets/dialog-Cvj_lHPY.js","assets/open-pr-controls-CYypJCKQ.js","assets/files-panel-BIkR_seN.js","assets/code-editor-Uk3tKKsE.js","assets/floor-scene-DGy8i_5R.js","assets/switch-BHplnCdo.js","assets/role-chat-nIyzM-vQ.js","assets/new-session-CUpOffXI.js","assets/mobile-nav-CrjrDJZ5.js","assets/logic-BTt00I9b.js","assets/settings-ui-Bc6ymtc_.js","assets/model-picker-DnKv2cbc.js","assets/engines-pLQJYIu_.js","assets/autonomy-Bx33JDEO.js","assets/footer-BFGvnowz.js","assets/tap-tooltip-Pz23Abjm.js","assets/new-session-Bc93-xJK.js","assets/thread-view-AQKzJlKb.js","assets/orchestration-BZj0HlxR.js","assets/markdown-DGHfubu-.js","assets/langs-bundle-full-CSdmXkDy-Dw8EfGyl.js","assets/dist-Cc5XWWBt.js","assets/dist-5JF3pQvh.js","assets/engine-javascript-DG4nFvXa.js","assets/chunk-7TTQLYRW-BeGKB8s3.js","assets/api-B9OffDXw.js","assets/format-CPIs7kVL.js","assets/github-bits-BLf93Pkz.js","assets/question-card-ldxLXNS_.js","assets/input-CPpbtC2H.js","assets/storeys-BEgFUsix.js","assets/use-retry-item-3n4BD_3J.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Lt as t,X as n}from"./icons-COCLuOtb.js";import{n as r,t as i}from"./jsx-runtime-C3cWAN_r.js";import{m as a}from"./format-D3kairnQ.js";import{t as o}from"./skeleton-D8Sbd2jT.js";import{t as s}from"./preload-helper-7y9sWmk5.js";var c=e(r(),1),l=[`Failed to fetch dynamically imported module`,`error loading dynamically imported module`,`Importing a module script failed`,`Unable to preload CSS`];function u(e){let t=e instanceof Error?e.message:``;return l.some(e=>t.startsWith(e))}var d=i();function f(e,t=(0,d.jsx)(p,{})){let n=(0,c.lazy)(async()=>({default:await e()}));return function(e){return(0,d.jsx)(m,{children:(0,d.jsx)(c.Suspense,{fallback:t,children:(0,d.jsx)(n,{...e})})})}}function p(){return(0,d.jsx)(`div`,{role:`status`,"aria-label":`Loading`,className:`flex h-full min-h-0 items-center justify-center text-muted-foreground`,children:(0,d.jsx)(t,{className:`size-4 animate-spin`})})}var m=class extends c.Component{state={failed:!1,error:void 0};static getDerivedStateFromError(e){return{failed:!0,error:e}}render(){if(!this.state.failed)return this.props.children;if(!u(this.state.error))throw this.state.error;return(0,d.jsx)(h,{})}};function h(){return(0,d.jsxs)(`div`,{role:`alert`,className:`flex h-full min-h-0 flex-col items-center justify-center gap-2 p-4 text-center text-xs text-muted-foreground`,children:[(0,d.jsx)(`p`,{children:`This part of CodeDen didn't load. CodeDen may have been updated since you opened it.`}),(0,d.jsxs)(a,{variant:`outline`,size:`sm`,onClick:()=>window.location.reload(),children:[(0,d.jsx)(n,{}),` Reload`]})]})}var g=f(()=>s(()=>import(`./terminal-view-WNT8FI6K.js`).then(e=>e.TerminalView),__vite__mapDeps([0,1,2,3,4,5,6]))),_=f(()=>s(()=>import(`./diff-panel-BHhM9z93.js`).then(e=>e.DiffPanel),__vite__mapDeps([7,1,8,2,9,10,11,12,13,14,15,16,3,17,18,4,19,20,21,5,22,23,24,25,26,27,28,29,30,31,32,33]))),v=f(()=>s(()=>import(`./files-panel-BIkR_seN.js`).then(e=>e.FilesPanel),__vite__mapDeps([34,1,8,2,9,10,11,12,13,14,15,17,19,20,4,22,3,5]))),y=f(()=>s(()=>import(`./code-editor-Uk3tKKsE.js`).then(e=>e.CodeEditor),__vite__mapDeps([35,1,2,4]))),b=f(()=>s(()=>import(`./floor-scene-DGy8i_5R.js`).then(e=>e.FloorScene),__vite__mapDeps([36,1,37,3,2,16,17,18,4,19,38,39,21,5,40,20,41,28,42,43,29,44,31,45,46,47,48,49,22,32,50,51,52,10,53,54,11,12,55,56,30,23,24,25,26,27,57,58,59,60,61,62,63]))),x=f(()=>s(()=>import(`./react-BETlQaef.js`).then(e=>e.t).then(e=>e.PatchDiff),__vite__mapDeps([8,1,2,9,10,11,12,13,14,15])),(0,d.jsx)(o,{className:`m-2 h-16`})),S=f(()=>s(()=>import(`./react-BETlQaef.js`).then(e=>e.t).then(e=>e.MultiFileDiff),__vite__mapDeps([8,1,2,9,10,11,12,13,14,15])),(0,d.jsx)(o,{className:`m-2 h-16`}));export{S as a,p as c,b as i,h as l,_ as n,x as o,v as r,g as s,y as t,u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cn as e}from"./icons-COCLuOtb.js";import{S as t,j as n,k as r,m as i,y as a,yt as o}from"./format-
|
|
1
|
+
import{cn as e}from"./icons-COCLuOtb.js";import{S as t,j as n,k as r,m as i,y as a,yt as o}from"./format-D3kairnQ.js";import{c as s,d as c,f as l,i as u,l as d,m as f,p,t as m,u as h}from"./shallow-BUNpybIA.js";import{v as g}from"./dropdown-menu-Bflkx6wY.js";import{F as _,t as v}from"./useQuery-VSotSwry.js";import{i as y}from"./api-yvn34iKU.js";import{t as b}from"./jsx-runtime-C3cWAN_r.js";function x(e){let n=y(),i=t(e),o=a(i?.projectId),{data:s}=v({queryKey:[`github`,`session`,e],queryFn:()=>n.github.session(e),enabled:o?.kind===`github`&&i?.role===`agent`,refetchInterval:3e4}),c=s?.pr?{number:s.pr.number,url:s.pr.url,state:s.pr.state,title:s.pr.title}:i?.pr??null,p=s?.connection.connected!==!1,{data:g}=v({queryKey:u(e),queryFn:()=>n.queue.list(e),enabled:p&&d(i,o,c)}),_=r(m(t=>h(t.byId[e]))),b=f(t=>t.asked[e]);return l({session:i,project:o,pr:c,connected:p,queue:g,latest:_,asked:b})}function S(e){let t=y(),i=_(),a=o({mutationFn:()=>t.sendMessage(e,{text:s},`queue`),onSuccess:()=>n.success(`Asked the agent to open a pull request`),onError:t=>{f.getState().forget(e),n.error(`Couldn't ask for a pull request`,{description:t.message})}});return()=>{let t=h(r.getState().byId[e]);p({queue:i.getQueryData(u(e)),latest:t,asked:f.getState().asked[e]})||(f.getState().ask(e,{after:t?.id??null}),a.mutate())}}var C=b();function w({requested:t,size:n,variant:r}){return(0,C.jsx)(`span`,{title:c(t),className:`inline-flex`,children:(0,C.jsxs)(i,{size:n,variant:r,disabled:!0,children:[(0,C.jsx)(e,{}),` PR requested`]})})}function T({sessionId:e}){let t=x(e),n=S(e),r=g(e=>e.openRightTab);return t.pr?(0,C.jsxs)(`button`,{type:`button`,"data-button":!0,"data-action":!0,onClick:()=>r(`github`),children:[`View PR #`,t.pr.number]}):t.requested?(0,C.jsx)(`span`,{title:c(t.requested),className:`inline-flex`,children:(0,C.jsx)(`button`,{type:`button`,"data-button":!0,"data-action":!0,disabled:!0,className:`opacity-60`,style:{cursor:`default`},children:`PR requested`})}):t.canAsk?(0,C.jsx)(`button`,{type:`button`,"data-button":!0,"data-action":!0,onClick:n,children:`Open PR`}):null}export{x as i,T as n,S as r,w as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./useQuery-VSotSwry.js";import{i as t}from"./api-
|
|
1
|
+
import{t as e}from"./useQuery-VSotSwry.js";import{i as t}from"./api-yvn34iKU.js";import{D as n,o as r}from"./format-D3kairnQ.js";var i=e=>[`project-status`,e];function a(e){return{kind:`session`,id:e.id,sessionId:e.id,projectId:e.projectId,startedBy:e.startedBy,purpose:e.purpose,workKey:e.workKey,scope:e.scope,progress:e.progress,status:e.status,startedAt:e.createdAt}}function o(e,t){return e.sessions.filter(e=>e.projectId===t&&e.role===`agent`&&r(e.status)).map(a)}function s(r){let a=t(),s=n(e=>o(e,r),[]),{data:c}=e({queryKey:i(r),queryFn:()=>a.orchestration.projectStatus(r),refetchInterval:15e3});if(!c)return{work:s,status:void 0};let l=new Map(s.map(e=>[e.id,e])),u=[...c.running,...c.queued].map(e=>l.get(e.id)??e);for(let e of s)u.some(t=>t.id===e.id)||u.push(e);return{work:u,status:c}}var c=/^\s*<codeden_status\b[^>]*>[\s\S]*?<\/codeden_status>\s*/,l=/^<codeden_updates\b[^>]*>([\s\S]*?)<\/codeden_updates>\s*/,u=`Updates since your last turn:`,d=`Automatic wake-up for the updates above.`;function f(e){let t=e,n=null,r=c.exec(t);r&&(n=r[0].trim(),t=t.slice(r[0].length));let i=null,a=l.exec(t);if(a)i=(a[1]??``).trim(),t=t.slice(a[0].length);else if(t.startsWith(u)){let e=p(t);i=t.slice(0,e).trim(),t=t.slice(e)}let o=t.trim();return{status:n,updates:i,text:o,wake:o.startsWith(d)}}function p(e){let t=e.indexOf(`
|
|
2
2
|
|
|
3
3
|
`);if(t===-1)return e.length;let n=0,r=0;for(let i=t;i!==-1;i=e.indexOf(`
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./mobile-nav-
|
|
1
|
+
import{t as e}from"./mobile-nav-CrjrDJZ5.js";import{t}from"./jsx-runtime-C3cWAN_r.js";var n=t();function r({icon:t,title:r,meta:i,actions:a}){return(0,n.jsxs)(`header`,{className:`flex min-h-12 shrink-0 flex-wrap items-center gap-x-2.5 gap-y-1 border-b border-border px-4 py-1.5 sm:h-12 sm:flex-nowrap sm:px-5 sm:py-0`,children:[(0,n.jsx)(e,{}),t&&(0,n.jsx)(`span`,{className:`text-muted-foreground [&_svg]:size-4`,children:t}),(0,n.jsx)(`h1`,{className:`min-w-[5rem] flex-1 truncate text-[14px] font-medium sm:flex-none`,children:r}),i&&(0,n.jsx)(`div`,{className:`hidden truncate text-2xs text-muted-foreground sm:block`,children:i}),a&&(0,n.jsx)(`div`,{className:`ml-auto flex max-w-full shrink-0 items-center gap-1.5 overflow-x-auto`,children:a})]})}export{r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Cr as e,ar as t,cn as n,i as r,zt as i}from"./icons-COCLuOtb.js";import{t as a}from"./role-chat-
|
|
1
|
+
import{Cr as e,ar as t,cn as n,i as r,zt as i}from"./icons-COCLuOtb.js";import{t as a}from"./role-chat-nIyzM-vQ.js";import{y as o}from"./format-D3kairnQ.js";import{SuggestionGrid as s}from"./home-BtFPGjza.js";import{t as c}from"./jsx-runtime-C3cWAN_r.js";var l=c(),u=[{icon:i,text:`What's running in this project right now?`},{icon:t,text:`Triage the open issues and tell me which are ready`},{icon:n,text:`Which pull requests need attention?`},{icon:r,text:`Plan the next piece of work and start an agent on it`}];function d({projectId:t}){let n=o(t);return n?(0,l.jsx)(a,{kind:`pm`,projectId:t,empty:t=>(0,l.jsxs)(`div`,{className:`relative flex flex-1 flex-col items-center justify-center px-6 py-10`,children:[(0,l.jsx)(`div`,{className:`mb-5 flex size-12 items-center justify-center rounded-2xl border border-border bg-card shadow-sm`,children:(0,l.jsx)(e,{className:`size-6 text-primary`})}),(0,l.jsxs)(`h2`,{className:`text-2xl font-semibold tracking-tight`,children:[n.name,` PM`]}),(0,l.jsxs)(`p`,{className:`mt-2 max-w-md text-center text-sm text-muted-foreground`,children:[`The project manager sees everything running in `,n.name,`, triages issues and starts agent sessions. It works read-only; agents make the changes.`]}),(0,l.jsx)(s,{draftKey:t,items:u})]})}):null}export{d as PmPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./dist-wxbqfqV1.js";import{n,t as r}from"./jsx-runtime-C3cWAN_r.js";import{$ as i,F as a,I as o,J as s,M as c,N as l,Q as u,X as d,Y as f,Z as p,at as m,dt as h,et as g,gt as _,it as v,ot as y,pt as b,q as x,st as S,tt as C,ut as w}from"./format-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./dist-wxbqfqV1.js";import{n,t as r}from"./jsx-runtime-C3cWAN_r.js";import{$ as i,F as a,I as o,J as s,M as c,N as l,Q as u,X as d,Y as f,Z as p,at as m,dt as h,et as g,gt as _,it as v,ot as y,pt as b,q as x,st as S,tt as C,ut as w}from"./format-D3kairnQ.js";var T=e(n(),1),E=r(),D=Object.defineProperty,O=(e,t)=>D(e,`name`,{value:t,configurable:!0}),k=`Popover`,[A,j]=w(k,[o]),M=o(),[N,P]=A(k),F=O(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=M(t),l=T.useRef(null),[u,d]=T.useState(!1),[f,p]=T.useState(0),[m,h]=T.useState(0),[g,_]=y({prop:r,defaultProp:i??!1,onChange:a,caller:k});return(0,E.jsx)(c,{...s,children:(0,E.jsx)(N,{scope:t,contentId:v(),titleId:v(),descriptionId:v(),titlePresent:f>0,descriptionPresent:m>0,setTitleCount:p,setDescriptionCount:h,triggerRef:l,open:g,onOpenChange:_,onOpenToggle:T.useCallback(()=>_(e=>!e),[_]),hasCustomAnchor:u,onCustomAnchorAdd:T.useCallback(()=>d(!0),[]),onCustomAnchorRemove:T.useCallback(()=>d(!1),[]),modal:o,children:n})})},`Popover`),I=`PopoverTrigger`,L=T.forwardRef(O(function(e,t){let{__scopePopover:n,...r}=e,i=P(I,n),a=M(n),o=_(t,i.triggerRef),s=(0,E.jsx)(h.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":J(i.open),...r,ref:o,onClick:S(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,E.jsx)(l,{asChild:!0,...a,children:s})},`PopoverTrigger`)),R=`PopoverPortal`,[z,B]=A(R,{forceMount:void 0}),V=O(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=P(R,t);return(0,E.jsx)(z,{scope:t,forceMount:n,children:(0,E.jsx)(m,{present:n||a.open,children:(0,E.jsx)(d,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),H=`PopoverContent`,U=T.forwardRef(O(function(e,t){let n=B(H,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=P(H,e.__scopePopover);return(0,E.jsx)(m,{present:r||a.open,children:a.modal?(0,E.jsx)(G,{...i,ref:t}):(0,E.jsx)(K,{...i,ref:t})})},`PopoverContent`)),W=b(`PopoverContent.RemoveScroll`),G=T.forwardRef(O(function(e,t){let n=P(H,e.__scopePopover),r=T.useRef(null),i=_(t,r),a=T.useRef(!1),{nodes:o,registry:c}=g();return T.useEffect(()=>{let e=r.current;if(e)return x(e)},[]),(0,E.jsx)(s,{as:W,allowPinchZoom:!0,shards:T.useMemo(()=>[r,...o.map(e=>({current:e}))],[r,o]),children:(0,E.jsx)(q,{...e,ref:i,branchNodes:o,branchRegistry:c,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:S(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:S(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:S(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),K=T.forwardRef(O(function(e,t){let n=P(H,e.__scopePopover),r=T.useRef(!1),i=T.useRef(!1);return(0,E.jsx)(q,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),q=T.forwardRef(O(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:m,onInteractOutside:h,"aria-describedby":g,branchNodes:v,branchRegistry:y,...b}=e,x=P(H,n),S=M(n),[w,D]=T.useState(null),O=_(t,D);return i(w),f(),(0,E.jsx)(u,{registry:y,children:(0,E.jsx)(p,{asChild:!0,loop:!0,trapped:r,branches:v,onMountAutoFocus:o,onUnmountAutoFocus:s,children:(0,E.jsx)(C,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:h,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:m,onDismiss:()=>x.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,E.jsx)(a,{"data-state":J(x.open),role:`dialog`,id:x.contentId,"aria-labelledby":x.titlePresent?x.titleId:void 0,"aria-describedby":x.descriptionPresent?Y(g,x.descriptionId):g,...S,...b,ref:O,style:{...b.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})})},`PopoverContentImpl`));function J(e){return e?`open`:`closed`}O(J,`getState`);function Y(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}O(Y,`concatAriaDescribedby`);function X({...e}){return(0,E.jsx)(F,{"data-slot":`popover`,...e})}function Z({...e}){return(0,E.jsx)(L,{"data-slot":`popover-trigger`,...e})}function Q({className:e,align:n=`center`,sideOffset:r=4,...i}){return(0,E.jsx)(V,{children:(0,E.jsx)(U,{"data-slot":`popover-content`,align:n,sideOffset:r,className:t(`z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...i})})}export{Q as n,Z as r,X as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{S as t,j as n,m as r,n as i,yt as a}from"./format-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{S as t,j as n,m as r,n as i,yt as a}from"./format-D3kairnQ.js";import{F as o,t as s}from"./useQuery-VSotSwry.js";import{L as c}from"./dropdown-menu-Bflkx6wY.js";import{Fn as l,Or as u,Tt as d,Vn as f,un as p,ur as m}from"./icons-COCLuOtb.js";import{t as h}from"./markdown-DGHfubu-.js";import{t as g}from"./skeleton-D8Sbd2jT.js";import{i as _}from"./api-yvn34iKU.js";import{o as v}from"./switch-BHplnCdo.js";import{t as y}from"./dist-wxbqfqV1.js";import{n as b,o as x,r as S,s as C,t as w}from"./github-bits-BLf93Pkz.js";import{n as T,t as E}from"./jsx-runtime-C3cWAN_r.js";import{o as D}from"./on-demand-Cvi90jRi.js";import{r as O}from"./theme-3eeE0sp4.js";var k=e(T(),1),A=class extends k.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?this.props.fallback:this.props.children}},j=E(),M=100;function N(e){return`${e.url}/files`}function P({pr:e,label:t=`Open on GitHub`}){return(0,j.jsxs)(r,{variant:`link`,size:`xs`,className:`h-auto px-0 text-2xs`,onClick:()=>v.openExternal(N(e)),children:[t,` `,(0,j.jsx)(f,{className:`size-3`})]})}function F({pr:e,open:t,onChange:n}){if(e.files.length===0||e.files.length>M)return null;let i=t.size===e.files.length;return(0,j.jsx)(r,{variant:`ghost`,size:`xs`,className:`h-5 px-1.5 text-2xs font-normal tracking-normal normal-case`,onClick:()=>n(i?new Set:new Set(e.files.map(e=>e.path))),children:i?`Collapse all`:`Expand all`})}function I({pr:e,open:t,onToggle:n}){let r=_(),i=s({queryKey:[`github`,`pr-diff`,e.id,e.headSha],queryFn:()=>r.github.prDiff(e.id),enabled:t.size>0,staleTime:1/0}),a=(0,k.useMemo)(()=>new Map((i.data?.files??[]).map(e=>[e.path,e])),[i.data]),o=e.changedFiles>e.files.length;return(0,j.jsxs)(`div`,{className:`space-y-2`,children:[(0,j.jsxs)(`div`,{className:`divide-y divide-border overflow-clip rounded-lg border border-border`,children:[e.files.map(r=>{let o=t.has(r.path);return(0,j.jsxs)(`div`,{"data-file":r.path,children:[(0,j.jsx)(L,{file:r,open:o,onToggle:()=>n(r.path)}),o&&(0,j.jsx)(`div`,{className:`border-t border-border`,children:i.isLoading?(0,j.jsx)(g,{className:`m-2 h-16`}):i.error?(0,j.jsx)(`p`,{className:`px-3 py-2 text-xs text-status-failed`,children:i.error.message}):(0,j.jsx)(R,{pr:e,file:r,diff:a.get(r.path)})})]},r.path)}),e.files.length===0&&(0,j.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:`No files changed.`})]}),o&&(0,j.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-2xs text-muted-foreground`,children:[`GitHub lists the first `,e.files.length,` of `,e.changedFiles,` files.`,(0,j.jsx)(P,{pr:e,label:`See the rest on GitHub`})]})]})}function L({file:e,open:t,onToggle:n}){let r=e.previousPath?`${e.previousPath} → ${e.path}`:e.path;return(0,j.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:n,className:y(`flex w-full items-center gap-2 bg-background px-3 py-1.5 text-left text-[12px] hover:bg-accent/40`,t&&`sticky top-0 z-10`),children:[(0,j.jsx)(m,{className:y(`size-3.5 shrink-0 text-muted-foreground transition-transform`,t&&`rotate-90`)}),(0,j.jsx)(l,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,j.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,title:r,children:r}),(0,j.jsx)(`span`,{className:`text-3xs text-muted-foreground`,children:e.status}),(0,j.jsxs)(`span`,{className:`text-3xs text-diff-add tabular-nums`,children:[`+`,e.additions]}),(0,j.jsxs)(`span`,{className:`text-3xs text-diff-del tabular-nums`,children:[`−`,e.deletions]})]})}function R({pr:e,file:t,diff:n}){let r=O();if(n?.patch)return(0,j.jsx)(A,{fallback:(0,j.jsxs)(z,{children:[`Couldn't render this file's diff.`,(0,j.jsx)(P,{pr:e})]}),children:(0,j.jsx)(D,{patch:n.patch,options:{theme:{dark:`pierre-dark`,light:`pierre-light`},themeType:r,diffStyle:`unified`,overflow:`wrap`,disableFileHeader:!0}})},n.patch);let i=n?t.status===`renamed`&&t.additions+t.deletions===0?`Renamed without content changes.`:`GitHub shows no diff for this file (binary, empty or too large).`:`This file is no longer in the pull request's latest diff.`;return(0,j.jsxs)(z,{children:[i,n&&(0,j.jsx)(P,{pr:e})]})}function z({children:e}){return(0,j.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-2 px-3 py-2 text-xs text-muted-foreground`,children:e})}function B(){let[e,t]=(0,k.useState)(new Set);return{open:e,setOpen:t,toggle:e=>t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}}function V({title:e,action:t,children:n}){return(0,j.jsxs)(`section`,{className:`space-y-2`,children:[(0,j.jsxs)(`div`,{className:`flex min-h-5 items-center gap-2`,children:[(0,j.jsx)(`h3`,{className:`flex-1 text-2xs font-medium tracking-wider text-muted-foreground uppercase`,children:e}),t]}),n]})}function H({pr:e}){let t=_(),i=o(),s=a({mutationFn:()=>t.github.merge(e.id,{method:`squash`,sha:e.headSha??void 0}),onSuccess:t=>{t.merged?n.success(`Merged #${e.number}`):n.error(`GitHub did not merge the pull request`),i.invalidateQueries({queryKey:[`github`]})},onError:e=>n.error(`Couldn't merge`,{description:e.message})});if(e.state!==`open`)return null;let c=e.mergeable===`conflicting`||e.checks.state===`failure`||e.checks.state===`pending`,l=e.mergeable===`conflicting`?`Has merge conflicts`:e.checks.state===`failure`?`Checks failed`:e.checks.state===`pending`?`Checks are still running`:`Squash and merge`;return(0,j.jsxs)(r,{size:`sm`,onClick:()=>s.mutate(),disabled:c||s.isPending,title:l,children:[(0,j.jsx)(p,{}),` `,s.isPending?`Merging…`:`Squash and merge`]})}function U({sessionId:e}){let n=t(e);return(0,j.jsxs)(c,{to:`/sessions/$sessionId`,params:{sessionId:e},className:`inline-flex items-center gap-1 text-2xs text-primary hover:underline`,children:[`Session: `,n?.title??n?.purpose??e.slice(0,8),(0,j.jsx)(u,{className:`size-3`})]})}function W({prId:e,showSession:t=!0}){let n=_(),r=B(),{data:a,error:o,isLoading:c}=s({queryKey:[`github`,`pr`,e],queryFn:()=>n.github.pr(e),refetchInterval:3e4});return c?(0,j.jsxs)(`div`,{className:`space-y-2`,children:[(0,j.jsx)(g,{className:`h-5 w-2/3`}),(0,j.jsx)(g,{className:`h-24`})]}):o||!a?(0,j.jsx)(`p`,{className:`text-xs text-status-failed`,children:o?.message??`PR not found`}):(0,j.jsxs)(`div`,{className:`space-y-5`,"data-testid":`pr-details`,children:[(0,j.jsxs)(`div`,{className:`space-y-2`,children:[(0,j.jsxs)(`button`,{type:`button`,onClick:()=>v.openExternal(a.url),className:`group flex w-full items-start gap-2 text-left`,children:[(0,j.jsxs)(`span`,{className:`flex-1 text-[14px] font-medium group-hover:underline`,children:[a.title,` `,(0,j.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`#`,a.number]})]}),(0,j.jsx)(f,{className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`})]}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-2xs text-muted-foreground`,children:[(0,j.jsx)(x,{state:a.state}),(0,j.jsx)(S,{checks:a.checks}),(0,j.jsx)(C,{decision:a.reviewDecision}),(0,j.jsxs)(`span`,{className:`text-diff-add`,children:[`+`,a.additions]}),(0,j.jsxs)(`span`,{className:`text-diff-del`,children:[`−`,a.deletions]}),(0,j.jsxs)(`code`,{className:`truncate font-mono text-3xs`,children:[a.headBranch,` → `,a.baseBranch]})]}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,j.jsx)(H,{pr:a}),a.mergeable===`conflicting`&&(0,j.jsx)(`span`,{className:`text-2xs text-status-failed`,children:`Merge conflicts`}),t&&a.sessionId&&(0,j.jsx)(U,{sessionId:a.sessionId}),a.linkedIssues.length>0&&(0,j.jsxs)(`span`,{className:`text-2xs text-muted-foreground`,children:[`Closes `,a.linkedIssues.map(e=>`#${e}`).join(`, `)]})]})]}),(0,j.jsx)(V,{title:`Checks · ${a.checks.total}`,children:a.checks.total===0?(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No checks on the head commit.`}):(0,j.jsx)(`div`,{className:`divide-y divide-border rounded-lg border border-border`,children:a.checks.checks.map(e=>(0,j.jsxs)(`button`,{type:`button`,disabled:!e.url,onClick:()=>e.url&&v.openExternal(e.url),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[13px] enabled:hover:bg-accent/40`,children:[(0,j.jsx)(w,{status:e.status,conclusion:e.conclusion}),(0,j.jsx)(`span`,{className:`flex-1 truncate font-mono text-[12px]`,children:e.name}),(0,j.jsx)(b,{status:e.status,conclusion:e.conclusion})]},e.name))})}),(0,j.jsx)(V,{title:`Reviews · ${a.reviews.length}`,children:a.reviews.length===0?(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No reviews yet.`}):(0,j.jsx)(`div`,{className:`space-y-2`,children:a.reviews.map(e=>(0,j.jsxs)(`div`,{className:`rounded-lg border border-border px-3 py-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 text-2xs`,children:[(0,j.jsx)(d,{className:`size-3 text-muted-foreground`}),(0,j.jsx)(`span`,{className:`font-medium`,children:e.author??`someone`}),(0,j.jsx)(`span`,{className:y(`text-muted-foreground`,e.state===`approved`&&`text-status-done`,e.state===`changes_requested`&&`text-status-failed`),children:e.state.replace(`_`,` `)}),e.submittedAt&&(0,j.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:i(e.submittedAt)})]}),e.body&&(0,j.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.body})]},e.id))})}),(0,j.jsx)(V,{title:`Files changed · ${a.changedFiles}`,action:(0,j.jsx)(F,{pr:a,open:r.open,onChange:r.setOpen}),children:(0,j.jsx)(I,{pr:a,open:r.open,onToggle:r.toggle})}),a.body.trim()&&(0,j.jsx)(V,{title:`Description`,children:(0,j.jsx)(h,{className:`text-[13px]`,children:a.body})})]})}export{W as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Z as t,i as n,it as r}from"./api-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Z as t,i as n,it as r}from"./api-yvn34iKU.js";import{L as i}from"./dropdown-menu-Bflkx6wY.js";import{d as a,o}from"./switch-BHplnCdo.js";import{A as s,Cr as c,Et as l,Fr as u,Jn as d,Lt as f,On as p,Or as m,P as h,Rn as g,Sn as _,Tt as v,Wt as y,X as b,ar as ee,cn as te,hr as ne,ht as re,kr as ie,m as x,mn as ae,n as oe,pr as se,q as ce,rt as le,zn as ue}from"./icons-COCLuOtb.js";import{n as de,t as fe}from"./jsx-runtime-C3cWAN_r.js";import{n as pe,r as me}from"./now-next-x8fwFm7p.js";import{a as he,i as ge,o as S,r as _e}from"./bits-B2GRjm37.js";import{a as ve,c as ye,i as be,n as xe,o as Se,r as Ce,s as C,t as we,u as Te}from"./wip-chip-DXwuAo3A.js";import{D as w,E as Ee,_t as De,c as Oe,f as ke,j as T,l as Ae,m as E,n as D,p as je,r as O,t as Me,yt as k}from"./format-D3kairnQ.js";import{F as A,t as j}from"./useQuery-VSotSwry.js";import{E as Ne,H as Pe,O as M,V as Fe,a as Ie,u as Le}from"./mobile-nav-CrjrDJZ5.js";import{t as N}from"./skeleton-D8Sbd2jT.js";import{a as Re,o as ze,t as Be}from"./factory-DVCs5zxg.js";import{t as P}from"./dist-wxbqfqV1.js";import{i as Ve,n as He,r as Ue}from"./factory-columns-DExb6gW2.js";import{n as We,r as Ge,t as Ke}from"./remote-check-CQktPgyp.js";import{t as qe}from"./kill-switch-BDAFCjui.js";import{C as F,S as I,a as Je,c as Ye,d as Xe,h as Ze,m as Qe,n as L,o as $e,p as et,v as tt,x as nt}from"./use-retry-item-3n4BD_3J.js";import{i as R,r as rt}from"./form-bits-5XojWhBG.js";import{a as it,i as at,n as ot,o as st,r as ct,t as lt}from"./table-ByDILCrJ.js";import{a as ut,c as z,i as dt,o as B,r as ft,s as pt,t as mt}from"./format-CPIs7kVL.js";import{a as ht,i as gt,n as _t,r as vt,t as yt}from"./spot-checks-CDZxwwu0.js";import{n as bt,r as xt,t as St}from"./spot-check-actions-DzMUED1O.js";import{a as Ct,c as wt,n as Tt,t as Et}from"./dialog-Cvj_lHPY.js";import{a as Dt,i as Ot,r as kt,s as At}from"./github-bits-BLf93Pkz.js";import{t as jt}from"./pr-details-1hhbiFWa.js";import{n as Mt}from"./archived-sessions-C1-stU7x.js";import{n as Nt,r as V,t as Pt}from"./settings-ui-Bc6ymtc_.js";import{n as Ft}from"./footer-BFGvnowz.js";import{t as It}from"./model-picker-DnKv2cbc.js";import{n as Lt,t as H}from"./autonomy-Bx33JDEO.js";import{r as Rt}from"./api-B9OffDXw.js";import{n as zt}from"./orchestration-BZj0HlxR.js";import{t as Bt}from"./page-header-t9HzSrxd.js";function Vt(e){let t=De();return Pe(t.stores.location,Fe(e,t))}var U=e(de(),1),W=fe();function Ht({projectId:e,lessons:t,learning:n}){return(0,W.jsxs)(`details`,{className:`group rounded-lg border border-border bg-surface text-2xs`,"data-testid":`factory-lessons`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer items-center gap-2 px-3 py-1.5 font-medium text-muted-foreground`,children:[(0,W.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),`Lessons`,(0,W.jsxs)(`span`,{className:`font-normal text-muted-foreground/80`,children:[`·`,` `,n?`what reviews taught the factory; new builders and reviewers get them in their briefs`:`learning from reviews is off: briefs carry none`]}),(0,W.jsx)(`span`,{className:`ml-auto tabular-nums`,children:t.length})]}),t.length===0?(0,W.jsx)(`p`,{className:`border-t border-border px-2 py-3 text-center text-3xs text-muted-foreground/70`,children:`None yet: reviewers add lessons as they review.`}):(0,W.jsx)(`ul`,{className:`space-y-0.5 border-t border-border p-1.5`,children:t.map(t=>(0,W.jsx)(Ut,{projectId:e,lesson:t},t.id))})]})}function Ut({projectId:e,lesson:t}){let n=Wt(e),a=r(t),o=a.getTime()>Date.now();return(0,W.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 rounded-md px-2 py-1.5 hover:bg-accent/40`,"data-testid":`factory-lesson`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block text-[12.5px] leading-snug text-foreground/90`,children:t.text}),(0,W.jsxs)(`span`,{className:`block text-3xs text-muted-foreground/80`,children:[t.prNumber===null?`from a review`:(0,W.jsxs)(i,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:e,itemId:t.itemId},className:`hover:text-foreground hover:underline`,children:[`from #`,t.prNumber]}),t.times>1&&` · recorded ${t.times}×`,` · `,D(t.lastSeenAt),o&&(0,W.jsxs)(`span`,{className:`text-status-waiting`,"data-testid":`factory-lesson-waiting`,children:[` `,`· new: in briefs `,ke(a.toISOString())]})]})]}),(0,W.jsx)(E,{variant:`ghost`,size:`icon-xs`,className:`shrink-0 text-muted-foreground`,"aria-label":`Forget lesson: ${t.text}`,title:`Forget: later builders and reviewers no longer get it, and it isn't learned again`,disabled:n.isPending,onClick:()=>n.mutate(t.id),children:(0,W.jsx)(oe,{className:`size-3.5`})})]})}function Wt(e){let t=n(),r=A();return k({mutationFn:n=>t.factory.forgetLesson(e,n),onSuccess:()=>{T.success(`Lesson forgotten`,{description:`New builders and reviewers no longer get it.`}),r.invalidateQueries({queryKey:Be.status(e)})},onError:e=>T.error(`Couldn't forget the lesson`,{description:e.message})})}var G={human:`Human`,humanOrScout:`Human or scout`,llm:`LLM call`,agent:`Agent`,workspace:`Workspace agent`,auto:`Auto-merge`,scout:`Scout`,checks:`CI checks`};function Gt({kind:e,hint:t}){return(0,W.jsx)(`span`,{className:P(`absolute -top-2 left-1/2 -translate-x-1/2 rounded-full border bg-card px-1.5 font-mono text-[9.5px] leading-4 whitespace-nowrap`,e===`human`||e===`scout`||e===`humanOrScout`?`border-foreground/40 text-foreground`:e===`auto`?`border-primary/50 text-primary`:`border-border text-muted-foreground`),children:t?(0,W.jsx)(R,{label:G[e],term:G[e],children:t}):G[e]})}function Kt({projectId:e,scout:t,scheduled:n=!0}){let r=a(),i=t.phase===`idle`?n?t.nextRoundAt?`Resting`:`Waiting for a round`:`On demand`:t.phase===`planning`?`Planning`:t.phase===`reviewing`?`Reviewing areas`:`Filing issues`,o=(0,W.jsx)(R,{label:`rounds`,children:Qe});return(0,W.jsxs)(`div`,{className:`relative flex min-h-[64px] w-[132px] shrink-0 flex-col items-center gap-1 rounded-lg border border-foreground/30 bg-card px-2 pt-3.5 pb-2 text-center`,"data-testid":`pipeline-scout`,children:[(0,W.jsx)(Gt,{kind:`scout`,hint:Ze}),(0,W.jsx)(`button`,{type:`button`,disabled:!t.sessionId,onClick:()=>t.sessionId&&void r({to:`/sessions/$sessionId`,params:{sessionId:t.sessionId}}),className:`text-[12px] leading-tight font-medium hover:text-primary disabled:hover:text-foreground`,title:t.sessionId?`Open the scout's session`:void 0,children:`Find improvements`}),(0,W.jsxs)(`span`,{className:`text-[10px] leading-tight text-muted-foreground`,children:[i,t.rounds>0?(0,W.jsxs)(`span`,{className:`flex items-center justify-center gap-1`,children:[`Round `,t.rounds,o]}):(0,W.jsx)(`span`,{className:`ml-1`,children:o})]}),t.lenses.length>0&&(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-1`,"data-testid":`scout-areas`,children:[t.lenses.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>void r({to:`/sessions/$sessionId`,params:{sessionId:e.sessionId}}),className:`flex items-center gap-1 rounded-md border border-border px-1 text-[10px] hover:border-primary/60`,title:`${L[e.area]} review: ${e.reported?`reported`:`reviewing`}`,"aria-label":`${L[e.area]} review: ${e.reported?`reported`:`reviewing`}. Open its session`,children:[(0,W.jsx)(M,{tone:e.active?`running`:e.reported?`done`:`idle`,className:`size-1.5 [&>span]:size-1.5`}),L[e.area]]},e.area)),(0,W.jsx)(R,{label:`review areas`,children:`How many focused reviewer agents the scout may use in a round, each looking at one area of the app: security, UI & UX, performance, docs and so on. Each costs tokens; 0 means the scout reviews by itself.`})]}),t.phase===`filing`||t.filed>0?(0,W.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[t.filed,` filed this round`]}):null,(0,W.jsx)(Te,{projectId:e,held:t.heldFollowUps})]})}var K=4;function qt(e){let t=e.type??(e.step===`intake`?null:`feature`);return e.step===`queued`?t===`bug`?{lane:t,node:`reproduce`}:t===`feature`?{lane:t,node:`analyze`}:{lane:t,node:`implement`}:{lane:t,node:e.step}}function Jt({w:e,projectId:t,tone:n,queued:r}){let i=a(),o=e.issue?`#${e.issue.number}`:e.pr?`PR #${e.pr.number}`:e.title.slice(0,18),s=r?null:e.activeSessionId,c=()=>s?void i({to:`/sessions/$sessionId`,params:{sessionId:s}}):void i({to:`/projects/$projectId/factory/$itemId`,params:{projectId:t,itemId:e.id}}),l=[e.title,r?`Waiting for a free agent`:null,e.trust===`admitted`?`Let in by hand: a person merges it`:null,e.attempts>0?`Revise round ${e.attempts}`:null,e.note,s?`Click to open the agent's session`:`Click to open the item`].filter(Boolean).join(`
|
|
2
2
|
`);return(0,W.jsxs)(`button`,{type:`button`,onClick:c,title:l,"data-testid":`pipeline-chip`,"data-step":e.step,className:P(`flex max-w-full items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] leading-4 transition-colors hover:border-primary/60 hover:bg-primary/[0.06]`,r?`border-dashed border-border text-muted-foreground`:`border-border bg-surface text-foreground`,e.stage===`escalated`&&`border-status-waiting/50 text-status-waiting`),children:[e.stage===`escalated`?(0,W.jsx)(x,{className:`size-2.5 shrink-0`}):(0,W.jsx)(M,{tone:r?`idle`:n,className:`size-1.5 [&>span]:size-1.5`}),(0,W.jsx)(`span`,{className:`truncate font-mono`,children:o}),e.trust===`admitted`&&(0,W.jsx)(h,{className:`size-2.5 shrink-0 text-status-waiting`}),e.attempts>0&&!r&&(0,W.jsx)(ce,{className:`size-2.5 shrink-0 text-muted-foreground`})]})}function q({kind:e,title:t,hint:n,items:r,queued:i=[],projectId:a,toneOf:o,className:s,footer:c}){let l=[...r,...i],u=l.length-K,d=r.length>0;return(0,W.jsxs)(`div`,{className:P(`relative flex min-h-[64px] min-w-0 flex-col items-center gap-1.5 rounded-lg border bg-card px-2 pt-3.5 pb-2 text-center`,d?`border-primary/50 shadow-[0_0_0_3px] shadow-primary/10`:`border-border`,s),"data-testid":`pipeline-node`,"data-node":t,children:[(0,W.jsx)(Gt,{kind:e}),(0,W.jsx)(`span`,{className:`text-[12px] leading-tight font-medium`,children:(0,W.jsx)(R,{label:t,term:t,children:n})}),l.length>0&&(0,W.jsxs)(`div`,{className:`flex w-full flex-wrap justify-center gap-1`,children:[r.slice(0,K).map(e=>(0,W.jsx)(Jt,{w:e,projectId:a,tone:o(e)},e.id)),i.slice(0,Math.max(0,K-r.length)).map(e=>(0,W.jsx)(Jt,{w:e,projectId:a,tone:`idle`,queued:!0},e.id)),u>0&&(0,W.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`+`,u]})]}),c]})}function J({dashed:e}){return(0,W.jsxs)(`span`,{className:`flex items-center text-muted-foreground/70`,"aria-hidden":!0,children:[(0,W.jsx)(`span`,{className:P(`h-px w-3`,e?`border-t border-dashed border-muted-foreground/60`:`bg-muted-foreground/60`)}),(0,W.jsx)(ie,{className:`-ml-1 size-3`})]})}function Yt({side:e}){return(0,W.jsxs)(`div`,{className:`relative grid w-6 shrink-0 grid-rows-3 self-stretch`,"aria-hidden":!0,children:[(0,W.jsx)(`span`,{className:`absolute top-[16.6%] bottom-[16.6%] left-1/2 border-l border-muted-foreground/50`}),(0,W.jsx)(`span`,{className:P(`absolute top-1/2 h-px w-1/2 bg-muted-foreground/50`,e===`out`?`left-0`:`right-0`)}),[0,1,2].map(t=>(0,W.jsx)(`span`,{className:`relative`,children:(0,W.jsx)(`span`,{className:P(`absolute top-1/2 h-px w-1/2 bg-muted-foreground/50`,e===`out`?`right-0`:`left-0`)})},t))]})}function Y({type:e,children:t}){let n=tt[e];return(0,W.jsxs)(`div`,{className:`relative flex items-center gap-1 rounded-lg border border-border bg-[repeating-linear-gradient(135deg,transparent,transparent_6px,var(--color-muted)_6px,var(--color-muted)_7px)] px-2 pt-5 pb-2`,"data-testid":`pipeline-lane`,"data-lane":e,children:[(0,W.jsxs)(`span`,{className:`absolute top-1 left-2 flex items-center gap-1 font-mono text-[9.5px] tracking-widest text-muted-foreground uppercase`,children:[n,(0,W.jsx)(R,{label:`the ${n} lane`,side:`right`,children:Je[e]})]}),t]})}function Xt({count:e}){return(0,W.jsxs)(`span`,{className:P(`absolute -bottom-2 left-1/2 flex -translate-x-1/2 items-center gap-1 rounded-full border border-dashed bg-card px-1.5 text-[9.5px] leading-4`,e>0?`border-status-waiting/60 text-status-waiting`:`border-border text-muted-foreground`),children:[(0,W.jsx)(ce,{className:`size-2.5`}),` Revise`,e>0&&` · ${e}`,(0,W.jsx)(R,{label:`Revise`,className:`size-3 text-current [&_svg]:size-2.5`,children:et})]})}function Zt({f:e}){let{data:t}=Ee(),n=e.projectId,r=new Map(t?.sessions.map(e=>[e.id,e.status])??[]),i=e=>{let t=e.activeSessionId?r.get(e.activeSessionId):void 0;return e.step===`merge`?e.stage===`watching`?`running`:`waiting`:t?Ae[t]:`idle`},a=[...e.backlog,...e.inProgress,...e.recent.filter(e=>e.stage===`escalated`)],o=(e,t)=>a.filter(n=>{let r=qt(n);return r.lane===e&&r.node===t&&n.step!==`queued`}),s=(e,t)=>a.filter(n=>{let r=qt(n);return n.step===`queued`&&r.lane===e&&r.node===t}),c=e=>a.filter(t=>t.type===e&&t.step===`implement`&&t.attempts>0).length,l=a.filter(e=>e.step===`merge`),u=(t,r,a,c)=>(0,W.jsx)(q,{kind:a,title:F(r,t),hint:I(r,t,e.limits.autoMerge),items:o(t,r),queued:s(t,r),projectId:n,toneOf:i,className:P(`flex-1`,c)}),d=e.mode===`dark_factory`&&e.scout,f=e.ignored.length;return(0,W.jsx)(`div`,{className:`overflow-x-auto scroll-thin`,"data-testid":`pipeline-diagram`,children:(0,W.jsxs)(`div`,{className:`flex min-w-[880px] items-stretch gap-1 py-2`,children:[d&&e.scout&&(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(Kt,{projectId:n,scout:e.scout,scheduled:e.tuning.minBacklog>0}),(0,W.jsx)(J,{dashed:!0})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(q,{kind:d?`humanOrScout`:`human`,title:`Issue`,hint:nt(!!d),items:[],projectId:n,toneOf:i,className:`w-[96px] shrink-0`,footer:(0,W.jsx)(`span`,{className:P(`text-[10px]`,f>0?`text-status-waiting`:`text-muted-foreground`),title:`Issues from authors who aren't trusted are ignored until you let them in`,children:f>0?`${f} ignored`:`trusted authors`})}),(0,W.jsx)(J,{dashed:!0}),(0,W.jsx)(q,{kind:`llm`,title:F(`intake`,null),hint:I(`intake`,null,e.limits.autoMerge),items:o(null,`intake`),projectId:n,toneOf:i,className:`w-[112px] shrink-0`})]}),(0,W.jsx)(Yt,{side:`out`}),(0,W.jsxs)(`div`,{className:`grid min-w-0 flex-1 grid-rows-3 gap-2.5`,children:[(0,W.jsxs)(Y,{type:`bug`,children:[u(`bug`,`reproduce`,`workspace`),(0,W.jsx)(J,{}),u(`bug`,`implement`,`workspace`),(0,W.jsx)(J,{}),(0,W.jsxs)(`div`,{className:`relative flex flex-1`,children:[u(`bug`,`review`,`workspace`),(0,W.jsx)(Xt,{count:c(`bug`)})]})]}),(0,W.jsxs)(Y,{type:`feature`,children:[u(`feature`,`analyze`,`agent`),(0,W.jsx)(J,{}),u(`feature`,`implement`,`workspace`),(0,W.jsx)(J,{}),(0,W.jsxs)(`div`,{className:`relative flex flex-1`,children:[u(`feature`,`review`,`workspace`),(0,W.jsx)(Xt,{count:c(`feature`)})]})]}),(0,W.jsxs)(Y,{type:`docs`,children:[u(`docs`,`implement`,`workspace`,`flex-[2]`),(0,W.jsx)(J,{dashed:!0}),u(`docs`,`review`,`checks`,`flex-1`)]})]}),(0,W.jsx)(Yt,{side:`in`}),(0,W.jsx)(`div`,{className:`flex items-center`,children:(0,W.jsx)(q,{kind:e.limits.autoMerge?`auto`:`human`,title:F(`merge`,null),hint:I(`merge`,null,e.limits.autoMerge),items:l,projectId:n,toneOf:i,className:`w-[120px] shrink-0`,footer:(0,W.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.limits.autoMerge?`when every check passes`:`ready for you on GitHub`})})})]})})}function Qt({projectId:e,pullRequests:t}){let n=t.filter(e=>e.queuePosition!==null).length;return(0,W.jsxs)(`section`,{className:`min-w-0 rounded-lg border border-border bg-surface`,"data-testid":`factory-pull-requests`,children:[(0,W.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:[(0,W.jsx)(te,{className:`size-3.5`}),`Pull requests`,(0,W.jsxs)(`span`,{className:`font-normal text-muted-foreground/80`,title:`With auto-merge on, the factory merges every pull request that passed its checks, oldest approved first. One that is behind the default branch merges on its own CI unless it has to be re-tested first.`,children:[`· merge queue `,n>0?`${n} waiting`:`empty`]}),(0,W.jsx)(`span`,{className:`ml-auto tabular-nums`,children:t.length})]}),t.length===0?(0,W.jsx)(`p`,{className:`px-2 py-3 text-center text-3xs text-muted-foreground/70`,children:`No open factory pull requests`}):(0,W.jsx)(`ol`,{className:`space-y-0.5 p-1.5`,children:t.map(t=>(0,W.jsx)($t,{projectId:e,entry:t},`${t.itemId}:${t.pr.number}`))})]})}function $t({projectId:e,entry:t}){let n=Xe[t.state];return(0,W.jsx)(`li`,{"data-testid":`factory-pr`,"data-state":t.state,children:(0,W.jsxs)(i,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:e,itemId:t.itemId},className:`flex min-w-0 items-start gap-2 rounded-md px-2 py-1.5 text-[12.5px] transition-colors hover:bg-accent/60`,children:[(0,W.jsx)(`span`,{className:P(`mt-px inline-flex h-5 w-6 shrink-0 items-center justify-center rounded-md text-3xs tabular-nums`,t.queuePosition===null?`text-muted-foreground/60`:`bg-status-waiting/15 font-medium text-status-waiting`),title:t.queuePosition===null?`Not in the merge queue`:`Number ${t.queuePosition} in the merge queue`,"data-testid":`factory-pr-position`,children:t.queuePosition??`·`}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,W.jsxs)(`span`,{className:`shrink-0 font-mono text-3xs text-muted-foreground`,children:[`#`,t.pr.number]}),(0,W.jsx)(`span`,{className:`truncate`,title:t.title,children:t.title})]}),t.note&&(0,W.jsx)(`span`,{className:`block truncate text-3xs text-muted-foreground/80`,title:t.note,children:t.note})]}),(0,W.jsxs)(`span`,{className:`mt-0.5 inline-flex shrink-0 items-center gap-1.5 text-3xs text-muted-foreground`,title:n.help,children:[(0,W.jsx)(M,{tone:n.tone,className:`size-1.5 [&>span]:size-1.5`}),n.label]})]})})}function en(e,t){return e?`${t(e.provider)} · ${e.model??`default model`}`:`No review`}function tn(e){return pt(e.finished>0?e.merged/e.finished:null)}function nn(e){return pt(e.merged>0?e.firstPass/e.merged:null)}function rn(e){return e.finished>0?(e.reviseRounds/e.finished).toFixed(1):`—`}function an(e){return e.medianMergeMs===null?`—`:ye(e.medianMergeMs)}function on(e){if(e.spotChecked===0)return`—`;let t=e.spotProblems===1?`1 problem`:`${e.spotProblems} problems`;return`${e.spotChecked} · ${t}`}function sn(e){return`${`${e.spotChecked} merge${e.spotChecked===1?``:`s`} spot-checked by a person`}, ${e.spotProblems} with a problem`}function cn(e){return e.costPerMergeUsd===null?`—`:e.costUsd===0&&e.unpricedTurns>0?`Not priced`:B(e.costPerMergeUsd,e.estimatedUsd>0)}function ln(e){return[`${e.apiEquivalent?`API-equivalent cost per merge`:`Cost per merge`}, failures included${e.estimatedUsd>0?` (estimated from list prices)`:``}: ${B(e.costUsd,e.estimatedUsd>0)} over ${e.finished} item${e.finished===1?``:`s`}`,e.unpricedTurns>0?`${e.unpricedTurns} turns not priced`:null].filter(Boolean).join(` · `)}var un=[{id:`builders`,label:`Builder`},{id:`reviewers`,label:`Reviewer`},{id:`pairs`,label:`Pair`}],dn=[{id:`7`,label:`7 days`},{id:`30`,label:`30 days`},{id:`90`,label:`90 days`}],fn=[{label:`Finished`,title:`Work that merged or failed (from its own work) in the window`},{label:`Merged`,title:`Merges in the window, and the share of the finished work`},{label:`First pass`,title:`Merges that needed no revise round (no failed review or check, no revert)`},{label:`Revise rounds`,title:`Revise rounds per finished item`},{label:`Reverted`,title:`Merges reverted because CI on the default branch failed after them`},{label:`Spot-checks`,title:`Merges a person spot-checked, and the problems they found`},{label:`Cost / merge`,title:`What the finished work cost, failures included, per merge`},{label:`To merge`,title:`Median time from intake to merge`}];function pn({projectId:e}){let[t,n]=(0,U.useState)(!1),[r,i]=(0,U.useState)(`builders`),[a,o]=(0,U.useState)(30),{data:s,error:c}=Re(e,a,t),l=w(e=>e.runner.providers,[]),u=e=>l.find(t=>t.id===e)?.displayName??mt[e]??e,d=s?.[r]??[];return(0,W.jsxs)(`details`,{className:`group rounded-lg border border-border bg-surface text-2xs`,"data-testid":`factory-scorecard`,onToggle:e=>n(e.currentTarget.open),children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer items-center gap-2 px-3 py-1.5 font-medium text-muted-foreground`,children:[(0,W.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),`Scorecard`,(0,W.jsx)(`span`,{className:`min-w-0 truncate font-normal text-muted-foreground/80`,children:`· first-pass merges, revise rounds, reverts and cost by builder and reviewer`})]}),t&&(0,W.jsxs)(`div`,{className:`space-y-2 border-t border-border p-2`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(rt,{label:`Group by`,value:r,options:un,onChange:i}),(0,W.jsx)(rt,{label:`Window`,value:`${a}`,options:dn,onChange:e=>o(Number(e))})]}),c?(0,W.jsxs)(`p`,{className:`py-4 text-center text-3xs text-status-failed`,children:[`Couldn't load the scorecard: `,c.message]}):!s||s.days!==a?(0,W.jsx)(N,{className:`h-24 w-full rounded-md`}):d.length===0?(0,W.jsxs)(`p`,{className:`py-4 text-center text-3xs text-muted-foreground/70`,children:[`No finished factory work in the last `,a,` days.`]}):(0,W.jsx)(mn,{rows:d,view:r,names:u}),(0,W.jsx)(`p`,{className:`px-1 text-3xs text-muted-foreground/80`,children:`Each item counts for the builder and reviewer of its last attempt. Infrastructure failures, rejected and escalated work and the factory's own reverts don't count.`})]})]})}function mn(e){let{rows:t,view:n,names:r}=e,i=un.find(e=>e.id===n)?.label??``;return(0,W.jsxs)(lt,{className:`text-xs`,"data-testid":`factory-scorecard-table`,children:[(0,W.jsx)(it,{children:(0,W.jsxs)(st,{className:`hover:bg-transparent`,children:[(0,W.jsx)(at,{className:`h-8 text-2xs`,children:n===`pairs`?`Builder → reviewer`:i}),fn.map(e=>(0,W.jsx)(at,{className:`h-8 text-right text-2xs`,title:e.title,children:e.label},e.label))]})}),(0,W.jsx)(ot,{children:t.map(e=>(0,W.jsxs)(st,{"data-testid":`factory-scorecard-row`,children:[(0,W.jsx)(ct,{className:`max-w-80 py-1.5`,children:(0,W.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5`,children:[n!==`reviewers`&&(0,W.jsx)(hn,{agent:e.builder,names:r}),n===`pairs`&&(0,W.jsx)(`span`,{className:`text-muted-foreground/60`,children:`→`}),n!==`builders`&&(0,W.jsx)(hn,{agent:e.reviewer,names:r})]})}),(0,W.jsx)(X,{children:e.finished}),(0,W.jsxs)(X,{children:[e.merged,` `,(0,W.jsx)(gn,{children:tn(e)})]}),(0,W.jsx)(X,{title:`${e.firstPass} of ${e.merged} merges`,children:nn(e)}),(0,W.jsx)(X,{title:`${e.reviseRounds} rounds over ${e.finished} items`,children:rn(e)}),(0,W.jsx)(X,{className:P(e.reverted>0&&`text-status-failed`),children:e.reverted}),(0,W.jsx)(X,{className:P(e.spotProblems>0&&`text-status-failed`),title:sn(e),children:on(e)}),(0,W.jsx)(X,{className:`font-mono`,title:ln(e),children:cn(e)}),(0,W.jsx)(X,{children:an(e)})]},e.key))})]})}function hn({agent:e,names:t}){return e?(0,W.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,title:en(e,t),children:[(0,W.jsx)(he,{provider:e.provider,className:`size-3.5 text-[8px]`}),(0,W.jsx)(`span`,{className:`font-medium`,children:t(e.provider)}),(0,W.jsx)(`span`,{className:`truncate font-mono text-2xs text-muted-foreground`,children:e.model??`default model`})]}):(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`No review`})}function X(e){return(0,W.jsx)(ct,{className:P(`py-1.5 text-right whitespace-nowrap tabular-nums`,e.className),title:e.title,children:e.children})}function gn({children:e}){return(0,W.jsx)(`span`,{className:`text-2xs text-muted-foreground`,children:e})}function _n({projectId:e,spotChecks:t,focus:n=!1}){let[r,i]=(0,U.useState)(n||t.outstanding>0),a=(0,U.useRef)(null);if((0,U.useEffect)(()=>{if(!n)return;i(!0);let e=requestAnimationFrame(()=>a.current?.scrollIntoView?.({block:`start`,behavior:`auto`}));return()=>cancelAnimationFrame(e)},[n]),!vt(t))return null;let{pending:o,recent:s,outstanding:c}=t;return(0,W.jsxs)(`details`,{ref:a,id:yt,className:`group scroll-mt-3 rounded-lg border border-border bg-surface text-2xs`,"data-testid":`factory-spot-checks`,open:r,onToggle:e=>i(e.currentTarget.open),children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer items-center gap-2 px-3 py-1.5 font-medium text-muted-foreground`,children:[(0,W.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),`Spot-checks`,(0,W.jsxs)(`span`,{className:`min-w-0 truncate font-normal text-muted-foreground/80`,children:[`· `,ht(t.percent)]}),(0,W.jsxs)(`span`,{className:P(`ml-auto shrink-0 rounded-full px-1.5 tabular-nums`,c>0&&`bg-status-waiting/12 text-status-waiting`),title:`Merges waiting for a look`,children:[c,` to check`]})]}),(0,W.jsxs)(`div`,{className:`space-y-2 border-t border-border p-2`,children:[(0,W.jsxs)(`p`,{className:`px-1 text-3xs text-muted-foreground`,"data-testid":`spot-check-share`,children:[gt(t),`. Read the change in the PR view, then record what you found; nothing in the factory waits on it.`]}),o.length===0?(0,W.jsx)(`p`,{className:`py-2 text-center text-3xs text-muted-foreground/70`,children:`Nothing to spot-check right now.`}):(0,W.jsxs)(`ul`,{className:`space-y-1`,children:[o.map(t=>(0,W.jsx)(yn,{projectId:e,entry:t},t.itemId)),c>o.length&&(0,W.jsxs)(`li`,{className:`px-2 text-3xs text-muted-foreground`,children:[`and `,c-o.length,` older merge`,c-o.length===1?``:`s`]})]}),s.length>0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`px-1 pt-1 pb-0.5 text-3xs font-medium text-muted-foreground`,children:`Checked lately`}),(0,W.jsx)(`ul`,{className:`space-y-0.5`,children:s.map(t=>(0,W.jsx)(bn,{projectId:e,entry:t},t.itemId))})]})]})]})}function vn({projectId:e,entry:t}){return(0,W.jsx)(i,{to:`/projects/$projectId/factory/$itemId`,params:{projectId:e,itemId:t.itemId},className:`truncate text-[12.5px] font-medium text-foreground/90 hover:underline`,children:t.title})}function yn({projectId:e,entry:t}){let n=_t[t.check.reason];return(0,W.jsxs)(`li`,{className:`space-y-1 rounded-md border border-border/60 bg-card px-2 py-1.5`,"data-testid":`spot-check-pending`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(vn,{projectId:e,entry:t}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-muted px-1.5 text-3xs text-muted-foreground`,title:n.title,children:n.label}),(0,W.jsxs)(`span`,{className:`ml-auto shrink-0 text-3xs text-muted-foreground`,children:[t.pr&&`#${t.pr.number} · `,`merged`,` `,D(t.mergedAt??t.check.sampledAt)]})]}),(0,W.jsx)(`p`,{className:`line-clamp-2 text-3xs text-muted-foreground`,title:t.verdict?.summary,children:t.verdict?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{className:`font-medium text-foreground/80`,children:[`Reviewer: `,t.verdict.verdict.replace(`_`,` `)]}),` `,`· `,t.verdict.summary]}):`No agent review (a docs-only change)`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[t.pr&&(0,W.jsx)(bt,{projectId:e,pr:t.pr,itemId:t.itemId,title:t.title}),(0,W.jsx)(xt,{projectId:e,itemId:t.itemId,title:t.title})]})]})}function bn({projectId:e,entry:t}){let{check:n}=t,r=n.state===`problem`;return(0,W.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 rounded-md px-2 py-1 hover:bg-accent/40`,"data-testid":`spot-check-recent`,children:[r?(0,W.jsx)(x,{className:`mt-0.5 size-3.5 shrink-0 text-status-failed`,"aria-hidden":!0}):(0,W.jsx)(se,{className:`mt-0.5 size-3.5 shrink-0 text-status-done`,"aria-hidden":!0}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(vn,{projectId:e,entry:t}),(0,W.jsxs)(`span`,{className:`shrink-0 text-3xs text-muted-foreground`,children:[r?`found a problem`:`looks good`,n.checkedAt&&` · ${D(n.checkedAt)}`]})]}),n.note&&(0,W.jsx)(`span`,{className:`block truncate text-3xs text-muted-foreground`,title:n.note,children:n.note})]}),r&&(n.issue?(0,W.jsxs)(`button`,{type:`button`,className:`shrink-0 text-3xs text-muted-foreground hover:text-foreground hover:underline`,onClick:()=>n.issue&&o.openExternal(n.issue.url),children:[`#`,n.issue.number]}):(0,W.jsx)(St,{projectId:e,itemId:t.itemId}))]})}function Z(e){let{label:t,value:n,max:r,display:i,warn:a=!0}=e,o=r>0?Math.min(100,n/r*100):0;return(0,W.jsxs)(`div`,{className:`min-w-[9rem] flex-1 rounded-lg border border-border bg-surface px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-3xs tracking-wider text-muted-foreground uppercase`,children:t}),(0,W.jsx)(`span`,{className:`text-[13px] font-medium whitespace-nowrap tabular-nums`,children:i})]}),(0,W.jsx)(`div`,{className:`mt-1.5 h-1 overflow-hidden rounded-full bg-muted`,children:(0,W.jsx)(`div`,{className:P(`h-full rounded-full`,a?o>85?`bg-status-failed`:o>60?`bg-status-waiting`:`bg-primary`:`bg-status-running`),style:{width:`${o}%`}})})]})}function xn({state:e,stopped:t}){let n=$e[t?`stopped`:e];return(0,W.jsxs)(`span`,{className:P(`shrink-0 rounded-full px-2 py-0.5 text-3xs 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-loop-state`,children:[`Loop `,n.label.toLowerCase()]})}function Sn({project:e}){let t=e.id,r=n(),a=A(),{data:o}=ze(t),c=Vt({select:e=>e.hash}),[l,u]=(0,U.useState)(!1),d=()=>void a.invalidateQueries({queryKey:Be.all}),f=e=>t=>T.error(e,{description:t.message}),m=k({mutationFn:()=>r.factory.resume(t),onSuccess:()=>{T.success(`Loop resumed`),d()},onError:f(`Couldn't resume`)}),h=k({mutationFn:()=>r.factory.digest(t),onSuccess:e=>{T.success(`Digest ready in your inbox`,{description:`${e.shipped.length} shipped, ${e.rejected.length} rejected, ${e.waiting.length} waiting`}),d()},onError:f(`Couldn't build the digest`)});if(!o)return(0,W.jsx)(N,{className:`h-72 w-full rounded-xl`});let _=o.killSwitch||o.globalKillSwitch||o.loopState===`stopped`,v=o.inProgress.filter(e=>e.step===`merge`&&e.stage===`verifying`).length,y=o.limits.dailyBudget.usd,b=o.limits.dailyBudget.tokens;return(0,W.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-border bg-card`,"data-testid":`factory-panel`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b border-border px-4 py-3`,children:[(0,W.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-lg bg-primary/12 text-primary`,children:(0,W.jsx)(g,{className:`size-4`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px] font-medium`,children:[Ye[o.mode],o.experimental&&(0,W.jsx)(C,{})]}),(0,W.jsxs)(`div`,{className:`text-2xs text-muted-foreground`,children:[o.mode===`dark_factory`?`The scout and trusted issues feed the pipelines; `:`Trusted GitHub issues feed the pipelines; `,o.limits.autoMerge?`CodeDen merges when every check passes.`:`you merge the pull requests.`]})]}),(0,W.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-1`,children:[(0,W.jsx)(Ce,{projectId:t,variant:`outline`}),o.loopState===`paused`&&!o.drain&&(0,W.jsxs)(E,{size:`sm`,onClick:()=>m.mutate(),disabled:m.isPending,children:[(0,W.jsx)(le,{}),` Resume`]}),(0,W.jsx)(xe,{f:o,stopped:_}),(0,W.jsxs)(E,{size:`sm`,variant:`ghost`,onClick:()=>h.mutate(),disabled:h.isPending,children:[(0,W.jsx)(re,{}),` Digest`]}),(0,W.jsxs)(E,{size:`sm`,variant:`ghost`,onClick:()=>u(!0),children:[(0,W.jsx)(s,{}),` Settings`]}),(0,W.jsx)(E,{size:`sm`,variant:`ghost`,asChild:!0,children:(0,W.jsxs)(i,{to:`/projects/$projectId/vision`,params:{projectId:t},children:[(0,W.jsx)(p,{}),` Vision`]})}),(0,W.jsx)(Ge,{}),(0,W.jsx)(qe,{scope:{projectId:t},on:o.killSwitch,drain:o.drain,paused:o.loopState===`paused`})]})]}),(0,W.jsxs)(`div`,{className:`space-y-4 px-4 py-4`,children:[(o.globalKillSwitch||o.pausedReason||!o.visionExists)&&(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-lg border border-status-waiting/30 bg-status-waiting/[0.06] px-3 py-2 text-2xs`,children:[(0,W.jsx)(x,{className:`size-3.5 text-status-waiting`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1`,children:o.globalKillSwitch?`The global kill switch is on: no project's factory runs.`:o.visionExists?`Paused: ${o.pausedReason}`:`The vision file is missing; the loop will not start work without it.`}),o.globalKillSwitch&&(0,W.jsx)(qe,{scope:`global`,on:!0,size:`xs`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-2xs font-medium text-muted-foreground`,children:`Pipelines`}),(0,W.jsx)(`span`,{className:`text-3xs text-muted-foreground/80`,children:`Click an issue to open the agent working on it`}),(0,W.jsxs)(`span`,{className:`ml-auto flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(we,{f:o}),o.drain&&!_?(0,W.jsx)(be,{f:o}):(0,W.jsx)(xn,{state:o.loopState,stopped:_})]})]}),(0,W.jsx)(Zt,{f:o})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(Z,{label:`Spend today`,value:y?o.spendToday.usd:o.spendToday.tokens,max:y??b??0,display:y?`${je(o.spendToday.usd)} / ${je(y)}`:`${O(o.spendToday.tokens)} / ${O(b??0)}`}),(0,W.jsx)(Z,{label:`Agents working`,value:o.activeSessions,max:o.limits.maxConcurrentSessions,display:`${o.activeSessions} / ${o.limits.maxConcurrentSessions}`,warn:!1}),(0,W.jsx)(Z,{label:`PRs in progress`,value:o.wip.openPrs,max:o.wip.limit,display:`${o.wip.openPrs} / ${o.wip.limit}`,warn:!1}),o.limits.autoMerge?(0,W.jsx)(Z,{label:`Merges today`,value:o.mergesToday,max:o.limits.maxMergesPerDay,display:`${o.mergesToday} / ${o.limits.maxMergesPerDay}`,warn:!1}):(0,W.jsx)(Z,{label:`Ready for you`,value:v,max:Math.max(v,1),display:`${v} PR${v===1?``:`s`}`,warn:!1}),(0,W.jsx)(Z,{label:`Failures in a row`,value:o.consecutiveFailures,max:o.limits.pauseAfterConsecutiveFailures,display:`${o.consecutiveFailures} / ${o.limits.pauseAfterConsecutiveFailures}`})]}),(0,W.jsx)(Qt,{projectId:t,pullRequests:o.pullRequests}),(0,W.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-3 lg:grid-cols-3`,children:[(0,W.jsx)(He,{projectId:t,checks:o.mergeChecks}),(0,W.jsx)(Ve,{projectId:t,recent:o.recent}),(0,W.jsx)(Ue,{projectId:t,ignored:o.ignored})]}),(0,W.jsx)(_n,{projectId:t,spotChecks:o.spotChecks,focus:c===yt}),(0,W.jsx)(Ht,{projectId:t,lessons:o.lessons,learning:o.tuning.learnFromReviews}),(0,W.jsx)(pn,{projectId:t}),o.lastDigest&&(0,W.jsxs)(`details`,{className:`rounded-lg border border-border bg-surface px-3 py-2 text-2xs`,children:[(0,W.jsxs)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:[`Digest `,o.lastDigest.day,`: `,o.lastDigest.shipped.length,` shipped,`,` `,o.lastDigest.rejected.length,` rejected, `,o.lastDigest.waiting.length,` waiting on you`]}),(0,W.jsx)(`pre`,{className:`mt-2 font-sans text-2xs leading-relaxed whitespace-pre-wrap text-foreground/85`,children:o.lastDigest.text})]}),(0,W.jsxs)(`p`,{className:`text-3xs text-muted-foreground/80`,children:[O(o.spendToday.tokens),` tokens today · trusted:`,` `,[o.githubLogin,...o.limits.trustedAuthors].filter(Boolean).map(e=>`@${e}`).join(`, `)||`the GitHub account`,` `,`· auto-merge `,o.limits.autoMerge?`on`:`off`,` · protected:`,` `,o.limits.protectedPaths.join(`, `)||`from the vision`,` · deploys`,` `,o.limits.allowDeploys?`allowed`:`off`,` · CI`,` `,o.tuning.requireCi?`required`:`optional`,` ·`,` `,o.tuning.maxChangedLines===null?`no size limit`:`up to ${o.tuning.maxChangedLines.toLocaleString()} changed lines`,o.lastTickAt&&` · last check ${D(o.lastTickAt)}`]})]}),(0,W.jsx)(ve,{project:e,open:l,onOpenChange:u})]})}var Cn=[`open`,`closed`,`all`];function wn({pr:e,onOpen:t}){return(0,W.jsxs)(`button`,{type:`button`,onClick:t,className:`flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-accent/40`,"data-testid":`github-pr-row`,children:[(0,W.jsx)(ge,{pr:e}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block truncate text-[13px] font-medium`,children:e.title}),(0,W.jsxs)(`span`,{className:`block truncate text-3xs text-muted-foreground`,children:[e.author??`unknown`,` · `,e.headBranch,` · updated `,D(e.updatedAt)]})]}),(0,W.jsx)(At,{decision:e.reviewDecision}),(0,W.jsx)(kt,{checks:e.checks}),e.sessionId&&(0,W.jsx)(`span`,{className:`rounded-full border border-primary/30 px-1.5 py-px text-3xs text-primary`,children:`session`})]})}function Tn({issue:e}){return(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2`,"data-testid":`github-issue-row`,children:[(0,W.jsx)(ee,{className:P(`size-3.5 shrink-0`,e.state===`open`?`text-status-done`:`text-chart-4`)}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>o.openExternal(e.url),className:`min-w-0 flex-1 text-left`,children:[(0,W.jsxs)(`span`,{className:`block truncate text-[13px] hover:underline`,children:[e.title,` `,(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[`#`,e.number]})]}),(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 text-3xs text-muted-foreground`,children:[e.author??`unknown`,` · updated `,D(e.updatedAt),e.comments>0&&(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[`· `,(0,W.jsx)(v,{className:`size-2.5`}),` `,e.comments]})]})]}),(0,W.jsx)(`span`,{className:`hidden max-w-56 flex-wrap justify-end gap-1 sm:flex`,children:e.labels.slice(0,4).map(e=>(0,W.jsx)(Dt,{name:e},e))}),e.sessionIds[0]&&(0,W.jsxs)(i,{to:`/sessions/$sessionId`,params:{sessionId:e.sessionIds[0]},className:`inline-flex items-center gap-0.5 text-3xs text-primary hover:underline`,children:[`Session `,(0,W.jsx)(m,{className:`size-3`})]})]})}function En({children:e,empty:t}){return(0,W.jsx)(`div`,{className:`divide-y divide-border overflow-hidden rounded-xl border border-border bg-card`,children:e.length>0?e:(0,W.jsx)(`p`,{className:`px-3 py-6 text-center text-xs text-muted-foreground`,children:t})})}function Dn({project:e}){let t=n(),r=A(),[i,a]=(0,U.useState)(`open`),[o,s]=(0,U.useState)(null),c=e.kind===`github`,l=j({queryKey:[`github`,`prs`,e.id,i],queryFn:()=>t.github.prs(e.id,i),enabled:c}),u=j({queryKey:[`github`,`issues`,e.id,i],queryFn:()=>t.github.issues(e.id,i),enabled:c}),d=k({mutationFn:()=>t.github.sync(e.id),onSuccess:()=>void r.invalidateQueries({queryKey:[`github`]}),onError:e=>T.error(`Sync failed`,{description:e.message})});if(!c)return(0,W.jsx)(Ot,{localOnly:!0,action:(0,W.jsx)(Ke,{projectId:e.id})});let f=l.data?.connection??u.data?.connection;if(f&&!f.connected)return(0,W.jsx)(Ot,{connection:f});let p=l.data?.sync;return(0,W.jsxs)(`div`,{className:`space-y-6`,"data-testid":`project-github`,children:[(0,W.jsx)(We,{project:e}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg border border-border bg-card/50 p-0.5 text-xs`,children:Cn.map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>a(e),className:P(`h-7 rounded-md px-2.5 capitalize text-muted-foreground hover:text-foreground`,i===e&&`bg-accent text-foreground`),children:e},e))}),(0,W.jsx)(`span`,{className:`ml-auto text-3xs text-muted-foreground`,children:p?.lastError?`Sync error: ${p.lastError}`:p?.lastSyncAt?`Synced ${D(p.lastSyncAt)}`:`Not synced yet`}),(0,W.jsxs)(E,{size:`xs`,variant:`outline`,onClick:()=>d.mutate(),disabled:d.isPending,children:[(0,W.jsx)(b,{className:P(d.isPending&&`animate-spin`)}),` Sync`]})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(S,{className:`mb-2`,children:[`Pull requests · `,l.data?.prs.length??0]}),l.isLoading?(0,W.jsx)(N,{className:`h-24 rounded-xl`}):(0,W.jsx)(En,{empty:`No pull requests.`,children:(l.data?.prs??[]).map(e=>(0,W.jsx)(wn,{pr:e,onOpen:()=>s(e)},e.id))})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(S,{className:`mb-2`,children:[`Issues · `,u.data?.issues.length??0]}),u.isLoading?(0,W.jsx)(N,{className:`h-24 rounded-xl`}):(0,W.jsx)(En,{empty:`No issues.`,children:(u.data?.issues??[]).map(e=>(0,W.jsx)(Tn,{issue:e},e.number))})]}),(0,W.jsx)(Et,{open:!!o,onOpenChange:e=>!e&&s(null),children:(0,W.jsxs)(Tt,{className:`max-h-[85vh] overflow-y-auto sm:max-w-4xl`,children:[(0,W.jsx)(Ct,{children:(0,W.jsxs)(wt,{children:[`Pull request #`,o?.number]})}),o&&(0,W.jsx)(jt,{prId:o.id})]})})]})}var On={user:`You`,orchestrator:`Orchestrator`,pm:`PM`,automation:`Automation`};function kn({session:e}){let t=Le(e);return(0,W.jsxs)(E,{size:`xs`,variant:`outline`,className:`relative z-10`,onClick:t.unarchive,"aria-label":`Unarchive ${e.title??e.purpose}`,children:[(0,W.jsx)(u,{}),` Unarchive`]})}var An=`rounded-xl border border-dashed border-border px-4 py-6 text-center text-xs text-muted-foreground`;function jn({projectId:e}){let{data:t,error:n,isPending:r,hasNextPage:i,isFetchingNextPage:a,fetchNextPage:o}=Mt(e),s=t?.pages.flatMap(e=>e.sessions)??[];return r?(0,W.jsx)(N,{className:`h-24 rounded-xl`}):n&&s.length===0?(0,W.jsxs)(`p`,{className:An,children:[`Couldn't load the archived sessions: `,n.message]}):s.length===0?(0,W.jsx)(`p`,{className:An,children:`No archived sessions. Archive one from its menu to tidy the sidebar.`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Mn,{sessions:s}),i&&(0,W.jsx)(`div`,{className:`flex justify-center pt-3`,children:(0,W.jsxs)(E,{variant:`outline`,size:`sm`,onClick:()=>void o(),disabled:a,children:[a&&(0,W.jsx)(f,{className:`animate-spin`}),`Load more`]})})]})}function Mn({sessions:e}){return(0,W.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card`,children:e.map(e=>(0,W.jsxs)(`div`,{"data-session-id":e.id,className:`relative grid grid-cols-[16px_minmax(0,1fr)_96px_110px_auto] items-center gap-3 border-b border-border px-3.5 py-2 text-[13px] transition-colors last:border-0 hover:bg-accent/40`,children:[(0,W.jsx)(M,{status:e.status}),(0,W.jsxs)(`span`,{className:`min-w-0`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(i,{to:`/sessions/$sessionId`,params:{sessionId:e.id},className:`truncate font-medium outline-none after:absolute after:inset-0 focus-visible:after:rounded-md focus-visible:after:ring-2 focus-visible:after:ring-ring`,children:e.title??e.purpose}),e.issue&&(0,W.jsx)(_e,{issue:e.issue}),e.pr&&(0,W.jsx)(ge,{pr:e.pr})]}),(0,W.jsxs)(`span`,{className:`block truncate font-mono text-3xs text-muted-foreground`,children:[e.workKey,` · `,e.branch]})]}),(0,W.jsx)(`span`,{className:`text-2xs text-muted-foreground`,children:Oe[e.status]}),(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 text-2xs text-muted-foreground`,children:[(0,W.jsx)(he,{provider:e.provider}),` `,On[e.startedBy.kind]]}),e.archivedAt?(0,W.jsx)(kn,{session:e}):(0,W.jsx)(`span`,{className:`w-11 text-right text-2xs text-muted-foreground tabular-nums`,children:Me(e.updatedAt)})]},e.id))})}function Nn({project:e}){let t=n(),{setExecutionBackend:r}=Ne(),i=j({queryKey:[`execution`,`backends`,e.id,e.kind],queryFn:()=>t.executionBackends({projectId:e.id}),retry:!1,staleTime:3e4}),a=i.data?.backends.find(e=>e.backend===`docker`),o=e.execution?.backend??`local`,s=!a?.available,c=a?[a.reason,a.fix].filter(Boolean).join(`. `):i.isPending?`Checking Docker…`:`Docker couldn't be checked`;return(0,W.jsx)(V,{title:`Where sessions run`,description:`Where new agent sessions in this project run. Sessions that already started stay where they are.`,children:(0,W.jsxs)(`div`,{className:`space-y-3 px-4 py-3.5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-[13.5px] font-medium`,children:[`Agent sessions`,o===`docker`&&(0,W.jsx)(C,{})]}),(0,W.jsx)(`div`,{className:`mt-0.5 text-2xs leading-relaxed text-muted-foreground`,children:o===`docker`?(0,W.jsx)(W.Fragment,{children:`Each new agent session gets a Docker container of its own, which clones the repository from GitHub. Archiving the session removes the container. For now only providers that need no sign-in run there.`}):(0,W.jsx)(W.Fragment,{children:`Each new agent session works in a worktree on this machine.`})})]}),(0,W.jsx)(Pt,{value:o,onChange:t=>{t!==o&&r(e,t)},options:[{value:`local`,label:`This machine`},{value:`docker`,label:`Docker (experimental)`,disabled:s&&o!==`docker`,title:s?c:void 0}]}),s&&(0,W.jsx)(`p`,{className:`text-2xs text-muted-foreground`,"data-testid":`docker-unavailable`,children:c})]})})}var Pn=[`completed`,`failed`,`stopped`];function Fn(e,t,n){return e.filter(e=>e.projectId===t&&e.role===`agent`&&!e.archivedAt&&!Pn.includes(e.status)&&e.autonomy!==n)}var Q=`default`,$=3;function In({project:e}){let t=w(e=>e.runner.providers,[]),n=w(e=>e.settings.autonomy.default,`auto`),{setSessionDefaults:r}=Ne(),a=e.autonomy??n,o=w(t=>Fn(t.sessions,e.id,a),[]),s=e.defaultProvider===null,c=(0,W.jsx)(i,{to:`/settings/$section`,params:{section:`providers`},className:`underline underline-offset-2 hover:text-foreground`,children:`Settings → Providers → Agent sessions`});return(0,W.jsxs)(V,{title:`New sessions`,description:`What sessions you start in this project begin with. You can still pick something else in each new session.`,children:[(0,W.jsx)(Nt,{label:`Default agent`,help:s?(0,W.jsxs)(W.Fragment,{children:[`Not set: new sessions use `,c,`.`]}):(0,W.jsxs)(W.Fragment,{children:[`Used instead of `,c,` for this project.`]}),children:(0,W.jsx)(`div`,{className:`rounded-lg border border-border px-1 py-0.5`,"data-testid":`project-agent`,children:(0,W.jsx)(It,{providers:t,align:`end`,placeholder:`Settings default`,value:s?null:{provider:e.defaultProvider,model:e.defaultModel,effort:e.defaultEffort},onChange:t=>void r(e,{defaultProvider:t.provider,defaultModel:t.model,defaultEffort:t.effort}),footer:t=>(0,W.jsx)(Ft,{active:s,onClick:()=>{r(e,{defaultProvider:null,defaultModel:null,defaultEffort:null}),t()},children:`Settings default: Agent sessions in Settings`})})})}),(0,W.jsxs)(Nt,{label:`Permissions`,help:`What new sessions start with. Default: ${H[n].short}, from Settings → Autonomy.`,stacked:!0,children:[(0,W.jsx)(Pt,{value:e.autonomy??Q,onChange:t=>void r(e,{autonomy:t===Q?null:t}),options:[{value:Q,label:`Default`},...Lt.map(e=>({value:e,label:H[e].short}))]}),o.length>0&&(0,W.jsxs)(`p`,{className:`mt-2 text-2xs leading-relaxed text-muted-foreground`,"data-testid":`sessions-keeping-level`,children:[o.length===1?`1 open session is on another level and keeps it: `:`${o.length} open sessions are on another level and keep it: `,o.slice(0,$).map((e,t)=>(0,W.jsxs)(`span`,{children:[t>0&&`, `,(0,W.jsx)(i,{to:`/sessions/$sessionId`,params:{sessionId:e.id},className:`underline underline-offset-2 hover:text-foreground`,children:e.title??e.purpose??`Untitled session`}),` `,`(`,H[e.autonomy].short,`)`]},e.id)),o.length>$&&` and ${o.length-$} more`,`. To change a session's, open it and use the Permissions picker under its message box: it applies while the session runs.`]})]})]})}function Ln({projectId:e}){let{data:t}=Rt(e);if(!t)return null;let n=Math.max(...t.dailyUsd,.01),r=z(dt(),-13),a=[{label:`Today`,value:t.todayUsd},{label:`7 days`,value:t.last7Usd},{label:`This month`,value:t.monthUsd}];return(0,W.jsxs)(`section`,{className:`rounded-xl border border-border bg-card px-4 py-3`,"data-testid":`project-spend`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(d,{className:`size-4 text-muted-foreground`}),(0,W.jsx)(`h2`,{className:`text-sm font-medium`,children:ft(t.billing)?`API-equivalent spend`:`Spend`}),t.topModel&&(0,W.jsxs)(`span`,{className:`text-2xs text-muted-foreground`,children:[`mostly `,(0,W.jsx)(`span`,{className:`font-mono`,children:t.topModel})]}),(0,W.jsxs)(i,{to:`/reports`,search:{project:e},className:`ml-auto inline-flex items-center gap-1 text-2xs text-muted-foreground hover:text-foreground`,children:[`Full report `,(0,W.jsx)(ie,{className:`size-3`})]})]}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-x-8 gap-y-3`,children:[a.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-2xs text-muted-foreground`,children:e.label}),(0,W.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:B(e.value,t.estimated)})]},e.label)),(0,W.jsx)(`div`,{className:`ml-auto flex h-10 min-w-40 flex-1 items-end gap-0.5 sm:max-w-72`,role:`img`,"aria-label":`Daily spend over the last 14 days`,children:t.dailyUsd.map((e,t)=>{let i=z(r,t);return(0,W.jsx)(`div`,{title:`${ut(i)}: ${B(e)}`,className:P(`flex-1 rounded-t-[3px] bg-primary/70 hover:bg-primary`,e===0&&`bg-muted`),style:{height:`${e===0?6:Math.max(10,e/n*100)}%`}},i)})})]}),t.budgets.length>0&&(0,W.jsx)(`div`,{className:`mt-3 space-y-1 border-t border-border pt-2 text-2xs text-muted-foreground`,children:t.budgets.map(e=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2 tabular-nums`,children:[(0,W.jsxs)(`span`,{children:[e.budget.period===`daily`?`Daily`:`Monthly`,` budget`]}),(0,W.jsx)(`span`,{className:`h-1 flex-1 overflow-hidden rounded-full bg-muted`,children:(0,W.jsx)(`span`,{className:P(`block h-full rounded-full`,e.state===`exceeded`?`bg-status-failed`:e.state===`warning`?`bg-status-waiting`:`bg-status-done`),style:{width:`${Math.min(100,e.percent)}%`}})}),(0,W.jsxs)(`span`,{children:[B(e.spentUsd),` / `,B(e.budget.limitUsd)]})]},e.budget.id))})]})}function Rn(e,t){return e.filter(e=>e.projectId===t&&e.role===`agent`&&!e.archivedAt).sort((e,t)=>Date.parse(t.updatedAt)-Date.parse(e.updatedAt))}function zn(e,t){return{active:Rn(e.sessions,t).length,archived:e.archivedSessionCounts[t]??0}}var Bn={overview:`Overview`,github:`GitHub`,settings:`Settings`};function Vn({projectId:e,tab:n,sessionView:r=`active`}){let{data:o}=Ee(),s=a(),{work:u}=zt(e),d=(0,U.useRef)(null),f=r===`archived`;(0,U.useEffect)(()=>{f&&d.current?.scrollIntoView({block:`start`})},[f]);let m=o?.projects.find(t=>t.id===e);if(!o||!m)return null;let h=zn(o,e),g=Rn(o.sessions,e),v=t(m.autonomyMode),y=e=>o.sessions.find(t=>t.id===e)?.title??null,b=t=>void s({to:`/projects/$projectId`,params:{projectId:e},search:t,replace:!0}),ee={...n===`overview`?{}:{tab:n},...f?{archived:!0}:{}};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Bt,{icon:(0,W.jsx)(Ie,{project:m,className:`size-5 text-2xs`}),title:m.name,meta:(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[m.kind===`github`?(0,W.jsxs)(`span`,{className:`flex items-center gap-1`,"data-testid":`project-github-repo`,children:[(0,W.jsx)(ae,{className:`size-3`}),` `,m.github.owner,`/`,m.github.repo,m.remoteWarning&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>b({tab:`github`}),title:`The folder no longer has this GitHub remote on origin`,"aria-label":`GitHub remote missing`,className:`text-status-waiting`,children:(0,W.jsx)(x,{className:`size-3`})})]}):(0,W.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(_,{className:`size-3`}),` Local folder`]}),(0,W.jsx)(Se,{project:m})]}),actions:(0,W.jsxs)(W.Fragment,{children:[v&&(0,W.jsx)(Ce,{projectId:e}),(0,W.jsx)(E,{size:`sm`,variant:`ghost`,asChild:!0,children:(0,W.jsxs)(i,{to:`/projects/$projectId/vision`,params:{projectId:e},children:[(0,W.jsx)(p,{}),` Vision`]})}),(0,W.jsx)(E,{size:`sm`,variant:`outline`,asChild:!0,children:(0,W.jsxs)(i,{to:`/projects/$projectId/pm`,params:{projectId:e},children:[(0,W.jsx)(c,{}),` Talk to the PM`]})}),(0,W.jsx)(E,{size:`sm`,asChild:!0,children:(0,W.jsxs)(i,{to:`/projects/$projectId/new`,params:{projectId:e},children:[(0,W.jsx)(l,{}),` New session`]})})]})}),(0,W.jsx)(`div`,{className:`flex h-10 shrink-0 items-end gap-4 border-b border-border px-6`,role:`tablist`,children:[`overview`,`github`,`settings`].map(e=>(0,W.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":n===e,onClick:()=>b(e===`overview`?{}:{tab:e}),className:P(`-mb-px border-b-2 border-transparent pb-2 text-[13px] text-muted-foreground hover:text-foreground`,n===e&&`border-primary text-foreground`),children:Bn[e]},e))}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:(0,W.jsx)(`div`,{className:`mx-auto w-full max-w-6xl space-y-8 px-6 py-6`,children:n===`github`?(0,W.jsx)(Dn,{project:m}):n===`settings`?(0,W.jsxs)(`div`,{className:`max-w-3xl`,children:[(0,W.jsx)(In,{project:m}),(0,W.jsx)(Nn,{project:m})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(pe,{work:u,projectId:e,titleOf:y}),v&&(0,W.jsx)(Sn,{project:m}),(0,W.jsx)(Ln,{projectId:e}),(0,W.jsxs)(`section`,{ref:d,className:`scroll-mt-6`,"aria-label":`Sessions`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center gap-3`,children:[(0,W.jsx)(S,{children:`Sessions`}),(0,W.jsx)(`div`,{className:`flex items-center gap-1`,role:`tablist`,"aria-label":`Show`,children:[`active`,`archived`].map(e=>(0,W.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":r===e,onClick:()=>{let{archived:t,...n}=ee;b(e===`archived`?{...n,archived:!0}:n)},className:P(`rounded-md px-2 py-0.5 text-2xs text-muted-foreground transition-colors hover:text-foreground`,r===e&&`bg-accent text-foreground`),children:[e===`active`?`Active`:`Archived`,` · `,h[e]]},e))})]}),f?(0,W.jsx)(jn,{projectId:e}):g.length>0?(0,W.jsx)(Mn,{sessions:g}):(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-3 rounded-xl border border-dashed border-border px-4 py-6 text-center text-xs text-muted-foreground`,"data-testid":`sessions-empty`,children:[(0,W.jsx)(`p`,{children:`No active sessions. A session is one agent working on one task, in its own worktree and branch.`}),(0,W.jsx)(E,{size:`sm`,asChild:!0,children:(0,W.jsxs)(i,{to:`/projects/$projectId/new`,params:{projectId:e},children:[(0,W.jsx)(l,{}),` Start a session`]})})]})]}),(0,W.jsxs)(`section`,{id:`automations`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,W.jsx)(S,{children:`Automations`}),(0,W.jsx)(i,{to:`/projects/$projectId/automations`,params:{projectId:e},className:`ml-auto text-2xs text-muted-foreground hover:text-foreground`,children:`Manage, runs and templates →`})]}),(0,W.jsx)(me,{projectId:e,compact:!0})]})]})})})]})}export{Vn as ProjectPage};
|