cezarion 0.18.0-dev.8321 → 0.18.0-dev.8329
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/package.json +3 -3
- package/web/dist/assets/{accounts-section-W7E0lJ_T.js → accounts-section-qnA3YX9G.js} +1 -1
- package/web/dist/assets/{activity-motion-CKC91fdO.js → activity-motion-wGHBuD_L.js} +1 -1
- package/web/dist/assets/{activity-route-BMKRcZZz.js → activity-route-BhT-npje.js} +1 -1
- package/web/dist/assets/agent-config-section-BIkW506A.js +4 -0
- package/web/dist/assets/agent-defaults-section-D9oxRh7t.js +1 -0
- package/web/dist/assets/{appearance-DgNRb9F9.js → appearance-CipbKN5k.js} +1 -1
- package/web/dist/assets/{automations-route-Bgp_2Y8z.js → automations-route-DKKwkBjL.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-DEXRRtL1.js → commit-diff-panel-OqVigspU.js} +1 -1
- package/web/dist/assets/{diff-TSXSey_i.js → diff-CpkjO5Q-.js} +2 -2
- package/web/dist/assets/{diff-view-COAB2s1Z.js → diff-view-D6QC4z_i.js} +1 -1
- package/web/dist/assets/{file-preview-BgnwLTzh.js → file-preview-C-oYrG0r.js} +1 -1
- package/web/dist/assets/{git-toolbar-DKexH2FX.js → git-toolbar-BiWUXSvy.js} +1 -1
- package/web/dist/assets/{github-CdzkHkDn.js → github-DSZtAYK0.js} +1 -1
- package/web/dist/assets/{global-activity-route-Cfb8uAU1.js → global-activity-route-ylV7sfQb.js} +1 -1
- package/web/dist/assets/{index-DgdiXHgV.js → index-CS5yyNbo.js} +5 -5
- package/web/dist/assets/{markdown-Dj9PnU5f.js → markdown-Drj1MCd_.js} +1 -1
- package/web/dist/assets/{notifications-section-DCf8tYi9.js → notifications-section-BNncS89W.js} +1 -1
- package/web/dist/assets/preview-pane-connected-C9bYs_nr.js +3 -0
- package/web/dist/assets/{projects-section-C-ji_9Jb.js → projects-section-DAyPYxaB.js} +1 -1
- package/web/dist/assets/prompt-templates-section-BUTjHN-R.js +1 -0
- package/web/dist/assets/{remote-settings-notice-D12kO_fx.js → remote-settings-notice-BTtluTx2.js} +1 -1
- package/web/dist/assets/{repo-git-BnR84_ZF.js → repo-git-CahuM1Bi.js} +1 -1
- package/web/dist/assets/{report-reader-DFeUVrVf.js → report-reader-BMw7TyID.js} +1 -1
- package/web/dist/assets/{reports-DeGJ_TQv.js → reports-BqhgWSM-.js} +1 -1
- package/web/dist/assets/resources-section-CPdErsDL.js +1 -0
- package/web/dist/assets/run-header-BpdSJ6lc.js +2 -0
- package/web/dist/assets/saved-draft-BwzBc-_Y.js +1 -0
- package/web/dist/assets/{settings-agent-picker-2lOzGfbc.js → settings-agent-picker-By-EZVYH.js} +1 -1
- package/web/dist/assets/settings-shell-Cg1j_HUU.js +1 -0
- package/web/dist/assets/sidebar-section-C7mKySo9.js +1 -0
- package/web/dist/assets/{skills-C1g3oBTx.js → skills-DL6gTurZ.js} +1 -1
- package/web/dist/assets/{task-changes-AWps2X1w.js → task-changes-BYdPYqmr.js} +1 -1
- package/web/dist/assets/{task-commits-DjUZYIvx.js → task-commits-CZs64PxA.js} +1 -1
- package/web/dist/assets/{task-files-xW_ZlA4N.js → task-files-CHDvZdch.js} +1 -1
- package/web/dist/assets/{task-github-item-QsIE8qBm.js → task-github-item-BaAS8tc7.js} +1 -1
- package/web/dist/assets/{task-thread-19WlI5jh.js → task-thread-DKTYTRYk.js} +6 -6
- package/web/dist/assets/{thread-state-Bno0d7IG.js → thread-state-Cnu6irf1.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-DGPBUUma.js → use-hand-to-agent-state-C0HmC08K.js} +1 -1
- package/web/dist/assets/{workflows-LoZzQln6.js → workflows-BxrHkrIx.js} +3 -3
- package/web/dist/assets/{workspace-tools-885o7YQC.js → workspace-tools-DK0GgizV.js} +1 -1
- package/web/dist/assets/worktrees-section-CBWXq2mc.js +4 -0
- package/web/dist/index.html +1 -1
- package/web/dist/assets/agent-config-section-L-WUv_Sg.js +0 -4
- package/web/dist/assets/agent-defaults-section-BNy5LuYr.js +0 -1
- package/web/dist/assets/preview-pane-connected-BuS799XB.js +0 -3
- package/web/dist/assets/prompt-templates-section-pKPXaO18.js +0 -1
- package/web/dist/assets/resources-section-CKfUOEMU.js +0 -1
- package/web/dist/assets/run-header-sYd-snDr.js +0 -2
- package/web/dist/assets/settings-shell-Cd_zkHHS.js +0 -1
- package/web/dist/assets/sidebar-section-CrCVthxb.js +0 -1
- package/web/dist/assets/worktrees-section-ORq1CrNd.js +0 -4
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{An as i,ci as a}from"./project-scope-context-d3J3hWPR.js";import{Kt as o,Lt as s,Wt as c,Xt as l,g as u,h as d,ht as f,x as p}from"./queries-dnpdX9VT.js";import{n as m}from"./toaster-Bo5vCbz-.js";import{t as h}from"./button-BQ2y4XRB.js";import{t as g}from"./badge-D9JrXe0o.js";import{t as _}from"./centered-state-V15AR_qo.js";import{A as v,Qn as y}from"./index-DgdiXHgV.js";import{i as b,n as x,r as S}from"./highlighter-DvLzHjjY.js";import{n as C,r as w,t as T}from"./remote-settings-notice-D12kO_fx.js";var E=e(t(),1),D=n(),O=1500;function k(e,t){let n=(0,E.useMemo)(()=>e.split(`
|
|
2
|
-
`).map(e=>[{content:e}]),[e]),r=(0,E.useMemo)(()=>x(t),[t]),i=n.length>O,[a,o]=(0,E.useState)(null);return(0,E.useEffect)(()=>{if(r===null||i)return;let t=!1;return S(e,r).then(n=>{t||o({key:e,tokens:n.tokens})}),()=>{t=!0}},[e,r,i]),r===null||i?n:a?.key===e?a.tokens:b(e,r)?.tokens??n}var A=`code-editor-surface m-0 min-h-full w-full whitespace-pre font-mono text-xs leading-[1.7] px-3 py-2 [tab-size:2]`;function j({value:e,onChange:t,language:n,readOnly:i,className:a,...o}){let s=k(e,n),c=(0,E.useRef)(null),l=(0,E.useRef)(null),u=()=>{let e=l.current,t=c.current;!e||!t||(t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft)};return(0,E.useLayoutEffect)(u,[e]),(0,D.jsxs)(`div`,{"data-slot":`code-editor`,className:r(`relative overflow-hidden rounded-md border border-input bg-card`,a),children:[(0,D.jsx)(`pre`,{ref:c,"aria-hidden":`true`,className:r(A,`pointer-events-none absolute inset-0 overflow-auto text-soft-foreground`),children:s.map((e,t)=>(0,D.jsx)(`span`,{className:`block`,children:e.length===0?`
|
|
3
|
-
`:(0,D.jsxs)(D.Fragment,{children:[e.map((e,t)=>(0,D.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t)),`
|
|
4
|
-
`]})},t))}),(0,D.jsx)(`textarea`,{ref:l,"data-slot":`code-editor-input`,value:e,readOnly:i,onChange:e=>t?.(e.target.value),onScroll:u,spellCheck:!1,autoCorrect:`off`,autoCapitalize:`off`,autoComplete:`off`,wrap:`off`,className:r(A,`relative block resize-none overflow-auto bg-transparent text-transparent caret-foreground outline-hidden`,`selection:bg-accent-strong/30 focus-visible:ring-0`,i&&`cursor-default`),...o})]})}function M(e){return t=>t.runners.includes(e)}function N(e,t){let n=M(e);return t===`mcp`?e=>n(e)&&(e.holdsMcp===!0||e.kind===`mcp`):e=>n(e)&&e.kind===t}function P(e){let{label:t,note:n,groups:r}=e.agentConfig;return{id:e.id,label:t,note:n,groups:r.map(({id:t,label:n,note:r,empty:i,showsUserMcp:a})=>({id:t,label:n,note:r,...i?{empty:i}:{},...a?{showsUserMcp:a}:{},files:N(e.id,t)}))}}function F(e){return c(e).map(P)}function I(e){return e.seeded?`Copied into each run’s worktree — takes effect on your next run.`:e.tracked===`tracked`?`Runs read the committed copy — this edit applies after you commit it.`:e.tracked===`outside-repo`?`Applies to every session on this machine.`:`Personal, git-ignored.`}function L(){let e=d();w();let t=f(),n=l(),r=n.data,i=(0,E.useMemo)(()=>F(r),[r]),a=(0,E.useMemo)(()=>t.data?v(t.data.checks,r):o(r),[t.data,r]);return n.isError?(0,D.jsx)(_,{icon:(0,D.jsx)(y,{}),tone:`danger`,title:`Runners did not load`,subtitle:n.error.message,heading:`h2`}):e.isError?(0,D.jsx)(_,{icon:(0,D.jsx)(y,{}),tone:`danger`,title:`Agent config did not load`,subtitle:e.error.message,heading:`h2`}):e.isPending||r===void 0?(0,D.jsx)(`p`,{"data-slot":`agent-config-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent config…`}):(0,D.jsx)(R,{listing:e.data,descriptors:i,installed:a})}function R({listing:e,descriptors:t,installed:n}){let[i,a]=(0,E.useState)(`claude`),[o,s]=(0,E.useState)(null),c=t.find(e=>e.id===i)??t[0];if(c===void 0)return null;let l=e.files.find(e=>e.id===o)??null,u=e=>{a(e),s(null)};return(0,D.jsxs)(`div`,{"data-slot":`agent-config`,className:`flex flex-col gap-5 p-4 md:p-6`,children:[(0,D.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Edit agent instructions and MCP configuration for this project.`}),!e.editable&&(0,D.jsxs)(`div`,{"data-slot":`agent-config-readonly`,className:`rounded-md border border-border bg-muted/40 px-3 py-2 text-[13px] text-soft-foreground`,children:[`Read-only: this remote cockpit cannot edit agent config. You can still see every file and which one wins. To edit here, the host operator runs `,(0,D.jsx)(`code`,{children:T}),`.`]}),(0,D.jsx)(C,{risk:`Agent config can define hooks and MCP servers that run commands on the machine running Squawk`}),(0,D.jsx)(`div`,{"data-slot":`agent-config-agents`,role:`tablist`,className:`flex flex-wrap gap-1`,children:t.map(e=>(0,D.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===c.id,"data-slot":`agent-config-agent`,"data-agent":e.id,"data-selected":e.id===c.id,onClick:()=>u(e.id),className:r(`flex min-w-11 items-center justify-center gap-2 rounded-md px-3 py-1.5 text-[13px] transition-colors`,e.id===c.id?`bg-background font-semibold shadow-sm`:`hover:bg-muted/60`),children:[e.label,!n.includes(e.id)&&(0,D.jsx)(g,{variant:`outline`,className:`text-[12px] text-soft-foreground`,children:`not installed`})]},e.id))}),c.note&&(0,D.jsx)(`p`,{"data-slot":`agent-config-agent-note`,className:`text-[12px] text-soft-foreground`,children:c.note}),(0,D.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[minmax(0,20rem)_minmax(0,1fr)]`,children:[(0,D.jsx)(`nav`,{"data-slot":`agent-config-nav`,className:`flex min-w-0 flex-col gap-5`,children:(0,D.jsx)(z,{agent:c,listing:e,selectedId:o,onSelect:s})}),(0,D.jsx)(`div`,{"data-slot":`agent-config-editor-pane`,className:`min-w-0`,children:l?(0,D.jsx)(V,{file:l},l.id):(0,D.jsx)(`div`,{className:`flex h-full min-h-40 items-center justify-center rounded-md border border-dashed border-border text-[13px] text-soft-foreground`,children:`Select a config file to view or edit it.`})})]})]})}function z({agent:e,listing:t,selectedId:n,onSelect:i}){return(0,D.jsx)(D.Fragment,{children:e.groups.map(a=>{let o=t.files.filter(a.files),s=a.showsUserMcp?t.userMcp:void 0;return o.length===0&&!s&&!a.empty?null:(0,D.jsxs)(`section`,{"data-slot":`agent-config-group`,"data-group":a.id,"data-agent":e.id,children:[(0,D.jsx)(`p`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wide text-soft-foreground`,children:a.label}),a.note&&(0,D.jsx)(`p`,{className:`mb-2 text-[12px] text-soft-foreground`,children:a.note}),o.length===0&&a.empty&&(0,D.jsx)(`p`,{"data-slot":`agent-config-group-empty`,className:`rounded-md border border-dashed border-border px-3 py-2 text-[12px] text-soft-foreground`,children:a.empty}),(0,D.jsx)(`ul`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,D.jsx)(`li`,{children:(0,D.jsxs)(`button`,{type:`button`,"data-slot":`agent-config-file`,"data-selected":e.id===n,onClick:()=>i(e.id),className:r(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] transition-colors`,e.id===n?`bg-accent-strong/15 text-foreground`:`hover:bg-muted/60`),children:[(0,D.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12px]`,children:e.label}),e.seeded&&(0,D.jsx)(g,{variant:`outline`,className:`shrink-0 text-[12px]`,children:`seeded`}),!e.exists&&(0,D.jsx)(`span`,{className:`shrink-0 text-[11px] text-soft-foreground`,children:`absent`})]})},e.id))}),s&&(0,D.jsx)(B,{userMcp:s})]},a.id)})})}function B({userMcp:e}){return(0,D.jsxs)(`div`,{"data-slot":`agent-config-user-mcp`,className:`mt-3`,children:[(0,D.jsx)(`h4`,{className:`mb-1 text-[12px] font-semibold`,children:`User & local scopes`}),(0,D.jsxs)(`p`,{className:`mb-2 text-[12px] text-soft-foreground`,children:[`Managed by `,(0,D.jsx)(`code`,{className:`font-mono`,children:`claude mcp add`}),` in `,e.path,` — Squawk does not edit Claude’s state file.`]}),e.readable?e.servers.length>0?(0,D.jsx)(`ul`,{className:`flex flex-wrap gap-1`,children:e.servers.map(e=>(0,D.jsx)(`li`,{children:(0,D.jsx)(g,{variant:`outline`,className:`font-mono text-[11px]`,children:e})},e))}):(0,D.jsx)(`p`,{className:`text-[12px] text-soft-foreground`,children:`No user-scoped MCP servers.`}):(0,D.jsx)(`p`,{className:`text-[12px] text-soft-foreground`,children:`Could not read the file.`})]})}function V({file:e}){let t=u(e.id),[n,r]=(0,E.useState)(null),[i,a]=(0,E.useState)(!1),[o,s]=(0,E.useState)(null),c=t.data?.version??null,l=n??t.data?.content??``,d=t.data?l!==t.data.content:!1,f=e.writable,{save:p,isSaving:m}=W({file:e,content:l,loadedVersion:c,setDraft:r,setConflict:a,setFormatError:s});return(0,E.useEffect)(()=>{t.data&&(r(t.data.content),a(!1),s(null))},[t.data?.version,t.data]),(0,D.jsxs)(`div`,{"data-slot":`settings-config-editor`,className:`flex flex-col gap-3`,children:[(0,D.jsx)(`h3`,{className:`text-sm`,children:`Configuration file`}),(0,D.jsxs)(`p`,{"data-slot":`agent-config-scope`,title:e.path,className:`text-[12px] text-muted-foreground break-words`,children:[e.scope.charAt(0).toUpperCase()+e.scope.slice(1),` scope · `,e.path]}),(0,D.jsxs)(`div`,{className:`settings-readout flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.label}),(0,D.jsx)(g,{variant:`outline`,className:`text-[12px] uppercase`,children:e.format}),(0,D.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-[12px] text-soft-foreground underline hover:text-foreground`,children:`docs`})]}),(0,D.jsxs)(`div`,{className:`settings-config-content-heading`,children:[(0,D.jsx)(`h3`,{children:e.kind===`mcp`||e.holdsMcp?`MCP configuration`:`File contents`}),(e.kind===`mcp`||e.holdsMcp)&&(0,D.jsx)(`p`,{children:`Review server commands before saving. MCP servers execute locally.`})]}),t.isPending?(0,D.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading file…`}):t.isError?(0,D.jsx)(`p`,{className:`text-[13px] text-destructive`,children:t.error.message}):(0,D.jsx)(j,{value:l,language:e.format,readOnly:!f,onChange:r,"aria-label":`${e.label} contents`,className:`h-[210px]`}),(0,D.jsx)(H,{formatError:o,conflict:i,onReload:()=>void t.refetch()}),f&&(0,D.jsxs)(`div`,{className:`settings-form-actions`,children:[(0,D.jsx)(h,{size:`sm`,onClick:p,disabled:!d||m,children:e.exists?`Save file`:`Create file`}),(0,D.jsx)(h,{size:`sm`,variant:`outline`,onClick:()=>r(null),disabled:!d||m,children:`Reset`}),d&&(0,D.jsx)(`span`,{className:`text-[12px] text-soft-foreground`,children:`Unsaved changes`})]}),(0,D.jsxs)(`div`,{className:`settings-config-save-help`,children:[(0,D.jsx)(`p`,{"data-slot":`agent-config-precedence`,className:`text-[12px] text-soft-foreground`,children:e.precedence}),(0,D.jsxs)(`p`,{"data-slot":`agent-config-effect`,className:`text-[12px] text-foreground/80`,children:[I(e),e.hotReload?` ${e.hotReload}`:``]}),(0,D.jsx)(U,{reason:e.readOnlyReason})]})]})}function H({formatError:e,conflict:t,onReload:n}){return(0,D.jsxs)(D.Fragment,{children:[e&&(0,D.jsx)(`p`,{"data-slot":`agent-config-format-error`,className:`text-[12px] text-destructive`,children:e}),t&&(0,D.jsxs)(`div`,{"data-slot":`agent-config-conflict`,className:`flex items-center justify-between gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px]`,children:[(0,D.jsx)(`span`,{children:`The file changed on disk since you opened it.`}),(0,D.jsx)(h,{size:`sm`,variant:`outline`,onClick:n,children:`Reload from disk`})]})]})}function U({reason:e}){return e&&(0,D.jsx)(`p`,{children:e})}function W({file:e,content:t,loadedVersion:n,setDraft:r,setConflict:o,setFormatError:c}){let l=p(e.id),u=a(),d=w();return{save:()=>{c(null),o(!1),l.mutate({content:t,version:n},{onSuccess:()=>{r(null),m(`${e.exists?`Saved`:`Created`} ${e.label}`)},onError:e=>{e instanceof i&&e.status===409?d().then(()=>{u.getQueryData(s.health)?.capabilities.settingsAdmin===!1?m(e.message,{tone:`danger`}):o(!0)}):e instanceof i&&e.status===400?c(e.message):m(e.message,{tone:`danger`})}})},isSaving:l.isPending}}export{L as AgentConfigSection};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,An as i,Ut as a,br as o,ci as s,r as c,un as l}from"./project-scope-context-d3J3hWPR.js";import{$t as u,Dt as d,Et as f,Kt as p,Lt as m,Qt as h,Rt as g,S as _,Ut as v,Wt as y,Xt as b,_ as x,in as S,st as C,vt as w,xt as T,yt as E}from"./queries-dnpdX9VT.js";import{n as D}from"./toaster-Bo5vCbz-.js";import{s as O}from"./design-icons-CzEoMH9c.js";import{t as k}from"./button-BQ2y4XRB.js";import{t as A}from"./switch-Bv2Zf1uU.js";import{t as j}from"./status-dot-DtAOFiIi.js";import{t as M}from"./centered-state-V15AR_qo.js";import{N,j as P}from"./index-DgdiXHgV.js";import{t as F}from"./textarea-vJt9undk.js";import{a as I,i as L,n as R,r as z,t as B}from"./settings-agent-picker-2lOzGfbc.js";var V=e(t(),1),H=n(),U={connected:{label:`Credentials found`,tone:`success`},disconnected:{label:`Not connected`,tone:`pending`},"not-installed":{label:`Not installed`,tone:`neutral`},unknown:{label:`Could not verify`,tone:`danger`}};function W(e,t,n){return{providers:e.providers.map(e=>e.provider===t?{...e,enabled:n}:e)}}function G(e,t){return e?U[e]:t?{label:`Checking…`,tone:`neutral`}:U.unknown}function K(e,t){return e===`unknown`||t&&!e}function q({provider:e,state:t,current:n,statusIsError:r}){return t===`not-installed`?(0,H.jsxs)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:[`Install `,e.displayName,`, then run `,(0,H.jsx)(`code`,{children:e.loginCommand}),`.`]}):K(t,r)?(0,H.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:`Verification failed. Check again when the provider is available.`}):n?.hint?(0,H.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:n.hint}):null}function J({provider:e,state:t,current:n,isConnecting:r,incidentId:i,refresh:a,connect:o,retry:s,queueToggle:c}){let l=t===`disconnected`||t===`unknown`;return(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t===`not-installed`?null:(0,H.jsx)(A,{checked:n?.enabled??!0,"aria-label":`Use ${e.displayName}`,onCheckedChange:t=>c(e.id,t)}),l?(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:a.isPending,onClick:()=>a.mutate(void 0,{onError:e=>D(e.message,{tone:`danger`})}),children:`Check again`}):null,t===`disconnected`&&e.browserLogin?(0,H.jsx)(R,{provider:e.id,label:e.displayName}):null,t===`disconnected`&&e.terminalLogin!==!1?(0,H.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(e.id),children:r?`Opening…`:`Connect`}):null,i===void 0?null:(0,H.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,disabled:s.isPending,onClick:()=>s.mutate({provider:e.id,authFailureId:i},{onSuccess:()=>D(`${e.displayName} can be tried again.`),onError:e=>D(e.message,{tone:`danger`})}),children:`Try again`})]})}function Y({manual:e,provider:t,connected:n,onCopy:r}){return e===null||e.provider!==t||n?null:(0,H.jsxs)(`div`,{role:`region`,"aria-label":`${e.label} manual sign-in`,className:`rounded-md border border-pending/40 bg-pending/5 px-3.5 py-3`,children:[(0,H.jsx)(`p`,{className:`text-[13px] text-foreground`,children:e.message}),(0,H.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`code`,{className:`min-w-0 flex-1 overflow-x-auto rounded-sm bg-muted px-2 py-1.5 text-xs`,children:e.command}),(0,H.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void r(e.command),children:`Copy command`})]})]})}function X(){let e=b(),t=E(),n=T(),r=f(),c=s(),[u,d]=(0,V.useState)(null),p=(0,V.useRef)(Promise.resolve()),m=(0,V.useRef)({}),_=(0,V.useRef)({}),x=(0,V.useRef)(t.data);(0,V.useEffect)(()=>{u&&o(t.data,u.provider)?.status===`connected`&&d(null)},[u,t.data]),(0,V.useEffect)(()=>{if(t.data){if(Object.values(_.current).every(e=>e===0)||!x.current){x.current=t.data;return}x.current={providers:t.data.providers.map(e=>({...e,enabled:(_.current[e.provider]??0)>0?o(x.current,e.provider)?.enabled??e.enabled:e.enabled}))}}},[t.data]);let C=(0,V.useCallback)((e,t)=>{let n=g.providerStatus,r=c.getQueryData(n);if(!r)return;x.current||=r;let i=W(r,e,t);_.current[e]=(_.current[e]??0)+1,c.setQueryData(n,i);let a=(m.current[e]??0)+1;m.current[e]=a,p.current=p.current.then(async()=>{try{let r=await l(e,t),i=o(r,e)?.enabled;if(i===void 0)return;if(x.current=W(x.current??r,e,i),a===m.current[e]){let t=c.getQueryData(n);c.setQueryData(n,t?W(t,e,i):r)}}catch(t){if(a===m.current[e]){let r=o(x.current,e)?.enabled,i=c.getQueryData(n);i&&r!==void 0?c.setQueryData(n,W(i,e,r)):x.current?c.setQueryData(n,x.current):c.removeQueries({queryKey:n,exact:!0}),D(t instanceof Error?t.message:String(t),{tone:`danger`})}}finally{_.current[e]=(_.current[e]??0)-1}})},[c]),w=S({mutationFn:e=>a(e),onSuccess:async(e,t)=>{d(null),D(e.opened?`Finish signing in in the terminal, then check again.`:`Provider is already connected.`),await c.invalidateQueries({queryKey:g.providerStatus}),await h(c,t,`none`)},onError:(t,n)=>{if(t instanceof i&&t.command){let r=v(e.data,n);d({provider:n,label:r,message:t.message,command:t.command});return}D(t.message,{tone:`danger`})}}),O=async e=>{try{await navigator.clipboard.writeText(e),D(`Command copied`)}catch{D(`Could not copy the command`,{tone:`danger`})}};return(0,H.jsxs)(`section`,{id:`providers`,"data-slot":`provider-settings`,className:`scroll-mt-20`,children:[(0,H.jsxs)(`div`,{className:`mb-2`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Providers`}),(0,H.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Connect the coding agents available on this computer.`})]}),t.isError?(0,H.jsxs)(`div`,{role:`alert`,className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border border-danger/30 bg-danger/5 px-3 py-2.5`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:`Provider status could not be loaded`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.error.message})]}),(0,H.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,disabled:t.isFetching,onClick:()=>void t.refetch(),children:`Retry`})]}):null,(0,H.jsx)(`div`,{className:`flex flex-col gap-2`,children:y(e.data).map(e=>{let i=o(t.data,e.id),a=i?.status,s=G(a,t.isPending),c=w.isPending&&w.variables===e.id,l=i?.authFailureId;return(0,H.jsxs)(V.Fragment,{children:[(0,H.jsxs)(`div`,{"data-slot":`provider-card`,"data-provider":e.id,className:`rounded-md border border-border bg-card px-3.5 py-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:e.displayName}),(0,H.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,H.jsx)(j,{tone:s.tone,pulse:t.isPending}),(0,H.jsx)(`span`,{children:s.label}),i?.enabled===!1?(0,H.jsx)(`span`,{children:`Disabled`}):null]}),(0,H.jsx)(q,{provider:e,state:a,current:i,statusIsError:t.isError})]}),(0,H.jsx)(J,{provider:e,state:a,current:i,isConnecting:c,incidentId:l,refresh:n,connect:w,retry:r,queueToggle:C})]}),l===void 0?null:(0,H.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Use this after completing the provider sign-in flow. Squawk cannot validate the credential without a task/model request; it will verify it on the next task.`})]}),(0,H.jsx)(Y,{manual:u,provider:e.id,connected:a===`connected`,onCopy:O})]},e.id)})})]})}var Z=2e4;function ee(){let e=x(),t=b(),n=u(p(t.data)),r=E();return e.isPending?(0,H.jsx)(`p`,{"data-slot":`agents-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent settings…`}):e.isError?(0,H.jsx)(M,{icon:(0,H.jsx)(O,{}),tone:`danger`,title:`Agent settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,H.jsx)(te,{config:e.data,catalogs:n,providerStatus:r,runners:t.data})}function te({config:e,catalogs:t,providerStatus:n,runners:i}){let a=_(),o=s(),c=S({mutationFn:e=>r(e),onSuccess:e=>{o.setQueryData(m.config,e),o.invalidateQueries({queryKey:m.health}),o.invalidateQueries({queryKey:m.repo})},onError:e=>D(e.message,{tone:`danger`})}),[l,u]=(0,V.useState)(e.systemPrompt??``),d=l.trim(),f=d===(e.systemPrompt??``),p=d.length>Z;return(0,H.jsxs)(`div`,{"data-slot":`agent-defaults-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,H.jsx)(ne,{defaultRunner:e.defaultRunner,providerStatus:n,saving:c.isPending,onPick:e=>c.mutate({defaultRunner:e})}),(0,H.jsx)(Q,{title:`Default model`,hint:e.modelsLocked?`Models are locked to the defaults configured in the native coding-agent settings.`:`The model preselected in the composer for each runner. Auto lets the runner decide per task.`,children:(0,H.jsx)(`div`,{className:`flex flex-col gap-4`,children:y(i).map(r=>{let{providerConnected:a,providerReason:o}=I(n,r.id),s=t[r.id],l=P(r.id,i,s),u=N(r.id,i,s?.data,[e.defaultModels[r.id]]),d=e.defaultModels[r.id]??``,f=u.find(e=>e.id===d)?.label??d??`auto (default)`;return(0,H.jsxs)(`label`,{className:`settings-option-row`,children:[(0,H.jsx)(`div`,{children:(0,H.jsx)(`h3`,{children:r.pickerLabel})}),e.modelsLocked?(0,H.jsx)(`output`,{"aria-label":`Default model for ${r.pickerLabel}`,"data-slot":`agents-model`,"data-runner":r.id,title:`Model selection is locked to native coding-agent settings.`,className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs`,children:f}):(0,H.jsxs)(`select`,{"aria-label":`Default model for ${r.pickerLabel}`,"data-slot":`agents-model`,"data-runner":r.id,value:d,title:o??r.pickerDescription,disabled:c.isPending||!a,onChange:e=>c.mutate({defaultModels:{[r.id]:e.target.value||null}}),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[u.map(e=>(0,H.jsx)(`option`,{value:e.id,children:e.id===``?`Native agent default`:e.label},e.id)),l?(0,H.jsx)(`option`,{disabled:!0,children:l}):null]})]},r.id)})})}),(0,H.jsxs)(Q,{title:`System prompt`,hint:`Extra instructions for every run in this project.`,children:[(0,H.jsx)(F,{"aria-label":`System prompt`,"data-slot":`agents-system-prompt`,value:l,onChange:e=>u(e.target.value),placeholder:`Extra rules for every agent run — conventions, tone, review requirements…`,className:`min-h-48 w-full`}),(0,H.jsxs)(`div`,{className:`settings-form-actions`,children:[(0,H.jsx)(k,{type:`button`,variant:`primary`,size:`sm`,"data-action":`agents-save-prompt`,disabled:f||p||c.isPending,onClick:()=>c.mutate({systemPrompt:d===``?null:d},{onSuccess:()=>D(d===``?`System prompt cleared`:`System prompt saved`)}),children:`Save prompt`}),p?(0,H.jsxs)(`p`,{"data-slot":`agents-prompt-limit`,className:`text-[11px] text-danger`,children:[d.length.toLocaleString(),` characters — the limit is`,` `,Z.toLocaleString(),`.`]}):(0,H.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Leave empty and save to clear. Applied to new runs only.`})]})]}),(0,H.jsxs)(`section`,{"data-slot":`agents-task-runs`,className:`settings-field flex flex-col gap-5`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Task runs`}),(0,H.jsx)($,{title:`Live title updates`,hint:`Refresh a task's short title through the namer model as the run progresses. A manual rename always wins and stops updates for that task.`,children:(0,H.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,H.jsx)(A,{"aria-label":`Live title updates`,"data-slot":`agents-live-title-updates`,checked:e.liveTitleUpdates??!0,disabled:c.isPending,onCheckedChange:e=>c.mutate({liveTitleUpdates:e},{onSuccess:()=>D(e?`Live title updates on`:`Live title updates off`)})}),(0,H.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.liveTitleUpdates??!0?`On`:`Off`,e.liveTitleUpdates===null&&` (default)`]})]})}),(0,H.jsx)($,{title:`Review changes before finishing`,hint:`When on, a task with changes pauses so you can Accept, Send back, or open a Draft PR. Autonomous tasks always skip this and finish on their own. Default: off — tasks finish without asking.`,children:(0,H.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,H.jsx)(A,{"aria-label":`Review changes before finishing`,"data-slot":`agents-review-gate`,checked:e.reviewGate??!1,disabled:c.isPending,onCheckedChange:e=>c.mutate({reviewGate:e},{onSuccess:()=>D(e?`Review gate on`:`Review gate off`)})}),(0,H.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.reviewGate??!1?`On`:`Off`,e.reviewGate===null&&` (default)`]})]})}),(0,H.jsx)($,{title:`Base branch`,hint:`New task worktrees branch from this and draft PRs target it. Also settable from the Git view.`,children:a.data?.info?(0,H.jsxs)(`select`,{"aria-label":`Base branch`,"data-slot":`agents-base-branch`,value:e.baseBranch??``,disabled:c.isPending,onChange:e=>c.mutate({baseBranch:e.target.value||null}),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,H.jsx)(`option`,{value:``,children:`follow checked-out branch (default)`}),a.data.branches.map(e=>(0,H.jsx)(`option`,{value:e,children:e},e))]}):(0,H.jsx)(`p`,{"data-slot":`agents-base-branch-unavailable`,className:`text-[13px] text-soft-foreground`,children:a.isPending?`Loading branches…`:`Not a git repository — tasks run in place, no branching.`})})]}),(0,H.jsxs)(`details`,{className:`settings-disclosure`,children:[(0,H.jsx)(`summary`,{children:`Provider connections`}),(0,H.jsx)(X,{})]})]})}function ne({defaultRunner:e,providerStatus:t,saving:n,onPick:r}){let i=C(),a=w(),s=c(),l=_(),u=d(),f=s.projectId??`default`,p=l.data?.info?.root,m=p?i.data?.selections[p]:void 0,h=b().data,g=z(i.data?.profiles??[],h),v=L(g,h);return(0,H.jsxs)(Q,{title:`Default runner`,hint:`Project defaults. A task can override these choices.`,children:[(0,H.jsx)(B,{rows:g,runner:e,accountFor:e=>m?.[e]??null,providerStatus:t,disabled:n,accountDisabled:u.isPending||a.data===void 0,onPick:(t,n,i)=>{t!==e&&r(t),i&&u.mutate({projectId:f,provider:t,profileId:n},{onError:e=>D(e.message,{tone:`danger`})})}}),!t.isPending&&!t.isError&&o(t.data,e)?.enabled===!1?(0,H.jsx)(`p`,{"data-slot":`agents-runner-disabled`,className:`text-[13px] text-muted-foreground`,children:`This provider is disabled. Enable it above or choose another provider.`}):null,v?(0,H.jsx)(`p`,{className:`max-w-md text-[13px] text-muted-foreground`,children:`The account is personal and never committed. Tasks already started under another account can’t be resumed here — their sessions live in that account’s folder.`}):null]})}function Q({title:e,hint:t,children:n}){return(0,H.jsxs)(`section`,{className:`settings-field flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,H.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}function $({title:e,hint:t,children:n}){return(0,H.jsxs)(`section`,{className:`settings-option-row`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{children:e}),(0,H.jsx)(`p`,{children:t})]}),n]})}export{ee as AgentDefaultsSection};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{Gr as i,Kr as a,Wr as o,lr as s}from"./project-scope-context-d3J3hWPR.js";import{n as c}from"./toaster-Bo5vCbz-.js";import{t as l}from"./createLucideIcon-BHp8sXmF.js";import{t as u}from"./arrow-right-Dh_Lx3um.js";import{r as d}from"./dist-C28wFbz0.js";import{t as f}from"./chevron-down-CHGyCDBH.js";import{n as p,r as m,t as h}from"./hourglass-B0lPAJvT.js";import{n as g,t as _}from"./smartphone-Lr8Ug2z_.js";import{t as v}from"./info-DA1x_4bz.js";import{a as y}from"./format-BNCkW110.js";import{n as b,t as x}from"./moon-CRE9nU5R.js";import{t as S}from"./play-CmVAj_fu.js";import{d as C,l as w,n as ee,u as T}from"./thread-state-Bno0d7IG.js";import{t as E}from"./square-terminal-B6RYYieR.js";import{t as D}from"./button-BQ2y4XRB.js";import{a as O,c as te,i as k,l as A,p as j,r as M,s as ne,t as N}from"./dropdown-menu-4e2iKSMT.js";import{s as re}from"./project-router-C6zhlnwO.js";import{t as P}from"./status-dot-DtAOFiIi.js";import{$n as ie,Dn as ae,En as oe,Gn as se,Jn as ce,On as F,_ as le,c as ue,d as de,er as I,f as L,g as fe,kn as pe,l as me,p as he,tr as ge,u as _e,v as ve}from"./index-DgdiXHgV.js";var ye=l(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),be=l(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),xe=l(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),R=l(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),z=l(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),B=l(`folder-x`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),V=l(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Se=l(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Ce=l(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),H=l(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),U=l(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),W=l(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),G=l(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),K=l(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),q=l(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),we=l(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),Te=l(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ee=l(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),De=l(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),J=e(t(),1),Oe=1e3,ke=[500,1e3,2e3,4e3,8e3],Ae=1;function je(e,t){let n=`/api/v1/p/${encodeURIComponent(e.projectId)}/runs/${encodeURIComponent(e.runId)}/preview/ws`,r=()=>`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${n}`,a=null,c,l=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||o(),m=()=>{if(l||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,a=n,n.addEventListener(`open`,()=>{n===a&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==a)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=s.safeParse(e);n.success&&t.onMessage(n.data);return}r instanceof Blob&&(f=0,t.onFrame(r))}),n.addEventListener(`error`,()=>void 0),n.addEventListener(`close`,()=>{if(n!==a||l)return;if(a=null,!u){if(d+=1,d>=2){l=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),c=setTimeout(m,Oe);return}if(f>=5){l=!0,t.onTransport(`closed`);return}let e=ke[Math.min(f,ke.length-1)];f+=1,t.onTransport(`reconnecting`,f),c=setTimeout(m,e)})},h=i(e=>{if(!l)if(e)a||m();else{clearTimeout(c),c=void 0;let e=a;a=null,e?.close()}});return t.onTransport(`connecting`),m(),{send(e){a?.readyState===Ae&&a.send(JSON.stringify(e))},close(){l=!0,h(),clearTimeout(c),c=void 0;let e=a;a=null,e?.close()}}}var Y=n();function Me({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,Y.jsx)(F,{children:(0,Y.jsxs)(oe,{children:[(0,Y.jsx)(pe,{asChild:!0,children:(0,Y.jsxs)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex h-7 min-w-7 shrink-0 items-center justify-center gap-0 rounded-full bg-muted px-0 text-xs font-semibold text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none @min-[640px]:gap-1.5 @min-[640px]:px-2.5`,n),children:[(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline`,children:`Experimental`})]})}),(0,Y.jsx)(ae,{children:`Experimental`})]})}):e?(0,Y.jsx)(F,{children:(0,Y.jsxs)(oe,{children:[(0,Y.jsx)(pe,{asChild:!0,children:(0,Y.jsx)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(ae,{children:`Experimental`})]})}):(0,Y.jsxs)(`span`,{"data-slot":`preview-experimental`,className:r(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-muted px-2.5 text-xs font-semibold text-muted-foreground`,n),children:[(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function Ne({text:e,source:t,onCopy:n,className:i}){let a=e.replace(/\s+$/,``).split(`
|
|
2
|
-
`);return(0,Y.jsxs)(`div`,{"data-slot":`preview-log-tail`,className:r(`min-w-0 rounded-lg bg-muted px-3.5 py-3 font-mono text-xs`,i),children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,Y.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${a.length} ${a.length===1?`line`:`lines`} · ${t}`]}),(0,Y.jsxs)(`button`,{type:`button`,className:`-m-2 inline-flex min-h-11 items-center gap-1.5 rounded-sm p-2 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:min-h-0 md:p-0`,onClick:()=>n(e),children:[(0,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,Y.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Pe=/^([a-z][a-z0-9+.-]*):/i;function Fe(e,t){let n=e.trim();if(n===``)return{kind:`error`,message:`Type a URL or a port.`};if(/^\d{1,5}$/.test(n)){let e=Number(n);return e<1||e>65535?{kind:`error`,message:`A port is a number from 1 to 65535.`}:t.some(t=>t.port===e)?{kind:`server`,port:e}:{kind:`url`,url:`http://localhost:${e}`}}let r=Pe.exec(n)?.[1]?.toLowerCase();return r&&!/^[a-z0-9.-]+:\d/i.test(n)?r!==`http`&&r!==`https`?{kind:`error`,message:`Only http and https addresses open here.`}:Ie(n):Ie(`http://${n}`)}function Ie(e){let t={kind:`error`,message:`That is not a valid address.`};if(/\s/.test(e))return t;try{new URL(e)}catch{return t}return{kind:`url`,url:e}}function Le(e){return e.replace(/^https?:\/\//i,``)}var Re=`https://github.com/hearsay-tools/squawk#environment-variables`;function ze({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,Y.jsx)(Ue,{state:e,actions:t});case`downloading`:return(0,Y.jsx)(Ge,{state:e,actions:t});case`download-failed`:return(0,Y.jsx)(Ke,{state:e,actions:t});case`sandbox-failed`:return(0,Y.jsx)(qe,{state:e,actions:t});case`browser-exited`:return(0,Y.jsx)(Je,{state:e,actions:t});case`needs-approval`:return(0,Y.jsx)(Ze,{state:e,actions:t});case`port-held`:return(0,Y.jsx)(Qe,{state:e,actions:t});case`server-starting`:return(0,Y.jsx)($e,{state:e,actions:t});case`server-stalled`:return(0,Y.jsx)(et,{state:e,actions:t});case`server-exited`:return(0,Y.jsx)(tt,{state:e,actions:t});case`server-stopped`:return(0,Y.jsx)(nt,{state:e,actions:t});case`loading`:return(0,Y.jsx)(it,{step:e.step,url:n});case`worktree-removed`:return(0,Y.jsx)(at,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,Y.jsx)(ot,{actions:t});case`taken-over`:return(0,Y.jsx)(ct,{state:e,actions:t})}}function X({icon:e,title:t,children:n,state:r}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":r,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:e}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Z=({children:e})=>(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),Q=({children:e})=>(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function Be({server:e}){return(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(E,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Runs ${L(e.command)} in this task's worktree, on the host.`})]})}function Ve({copy:e,command:t,label:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-3 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:[(0,Y.jsx)(`span`,{children:n}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,className:`-m-2 inline-flex size-11 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:size-6`,onClick:()=>e(t),children:(0,Y.jsx)(I,{className:`size-4`,"aria-hidden":`true`})})]}),(0,Y.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function He({server:e,status:t}){return(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,Y.jsx)(P,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,Y.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,Y.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,Y.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,Y.jsx)(`span`,{children:`cwd`}),(0,Y.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,Y.jsx)(`div`,{className:`mt-2.5`,children:(0,Y.jsx)(Be,{server:e})})]})}function Ue({state:e,actions:t}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(R,{}),title:`This host has no browser yet`,children:[(0,Y.jsx)(Z,{children:e.canDownload?`Preview runs Chromium on the machine Squawk runs on. Squawk can download it into ~/.cache/cez/ (about 150 MB). Nothing else on the host changes.`:`Preview runs Chromium on the machine Squawk runs on. Squawk has no download for this platform, so install it with the system package manager.`}),e.canDownload?(0,Y.jsx)(Q,{children:(0,Y.jsxs)(D,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(R,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,Y.jsx)(Ve,{command:e.installCommand,copy:t.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function We(e){return Math.round(e/1e6)}function Ge({state:e,actions:t}){let n=(0,J.useRef)(null);n.current??={at:Date.now(),received:e.received};let r=e.total>0?Math.min(100,Math.floor(e.received/e.total*100)):0,i=(Date.now()-n.current.at)/1e3,a=i>=1?(e.received-n.current.received)/i:0,o=a>0?Math.ceil((e.total-e.received)/a):void 0;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(R,{}),title:`Downloading Chromium`,children:[(0,Y.jsx)(Z,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Chromium download`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${r}%`}})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:`${We(e.received)} of ${We(e.total)} MB · ${r}%`}),o===void 0?null:(0,Y.jsx)(`span`,{children:`about ${o} s left`})]})]}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(D,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function Ke({state:e,actions:t}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(Te,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,Y.jsx)(Z,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,Y.jsx)(Ve,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(D,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Retry download`]}),(0,Y.jsxs)(D,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,Y.jsx)(I,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function qe({state:e,actions:t}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(q,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,Y.jsx)(Z,{children:`The host blocks the sandbox Chromium needs. This usually means Squawk runs as root, or inside a container without user namespaces.`}),(0,Y.jsx)(Ne,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(D,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(D,{variant:`outline`,onClick:()=>t.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,Y.jsx)(I,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,Y.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Re,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function Je({state:e,actions:t}){let n=e.reason===`timeout`,r=e.signal?` (${e.signal})`:e.exitCode===void 0?``:` (code ${e.exitCode})`,i=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,a=n?`Chromium did not start in time`:`Chromium exited${r}`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(p,{className:`text-danger`}),title:n?`The browser did not start`:`The browser stopped`,children:[(0,Y.jsx)(Z,{children:n?`Chromium did not open its DevTools port in time. ${i}`:`Chromium exited unexpectedly${r}. ${i}`}),(0,Y.jsx)(Ne,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(D,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(D,{variant:`outline`,onClick:()=>t.copy(`${a}\n${e.stderrTail}`),children:[(0,Y.jsx)(I,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Ye=2;function Xe(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Ze({state:e,actions:t}){let{server:n,wasRunning:r}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:r?(0,Y.jsx)(Ee,{className:`text-pending-strong`}):(0,Y.jsx)(S,{}),title:r?`Nothing answers on :${n.port} anymore`:`${n.label} isn't running yet`,children:[(0,Y.jsx)(Z,{children:r?`${n.label} was running when the agent registered it, likely inside the agent's own session, which has ended. Squawk can start it with the registered command.`:`The agent registered this server. Nothing runs until you approve it here.`}),(0,Y.jsx)(He,{server:n,status:r?`was running when registered · silent now`:`registered · not started`}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(D,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(S,{"aria-hidden":`true`}),`Run and open`]})})]})}function Qe({state:e,actions:t}){let{server:n,ownerTitle:r}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(Te,{className:`text-pending-strong`}),title:`${n.label} :${n.port} is in use by another task`,children:[(0,Y.jsx)(Z,{children:`Task "${r}" is running its own server on :${n.port}. Register a different port for this task, or stop that task's server.`}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(D,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function $e({state:e,actions:t}){let{server:n}=e,r=Xe(1e3),i=Math.max(0,Math.floor((r-Date.parse(e.startedAt))/1e3)),[a,o]=(0,J.useState)(()=>Date.now());(0,J.useEffect)(()=>o(Date.now()),[e.attempt]);let s=Math.max(0,Math.ceil(Ye-(r-a)/1e3));return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(S,{}),title:`Starting ${n.label}`,children:[(0,Y.jsx)(Z,{children:`Squawk ran ${L(n.command)} in the worktree. The page opens as soon as :${n.port} answers.`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,Y.jsx)(y,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),s>0?`Attempt ${e.attempt} · next try in ${s} s`:`Attempt ${e.attempt}`]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${i} s ago`})]}),e.logTail.length>0?(0,Y.jsx)(Ne,{text:e.logTail.join(`
|
|
3
|
-
`),source:L(n.command),onCopy:t.copy}):null,(0,Y.jsx)(Q,{children:(0,Y.jsx)(D,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})})]})}function et({state:e,actions:t}){let{server:n}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(h,{className:`text-pending-strong`}),title:`${n.label} is running, but :${n.port} is silent`,children:[(0,Y.jsx)(Z,{children:`The process has run for 2 min without opening the port. It may be waiting on another service, or listening somewhere else.`}),(0,Y.jsx)(Ne,{text:e.logTail,source:L(n.command),onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(D,{variant:`contrast`,onClick:()=>t.keepWaiting(n.port),children:`Keep waiting`}),(0,Y.jsx)(D,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})]})]})}function tt({state:e,actions:t}){let{server:n}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(p,{className:`text-danger`}),title:e.exitCode===null?`${n.label} was stopped by a signal`:`${n.label} exited with code ${e.exitCode}`,children:[(0,Y.jsx)(Z,{children:`${L(n.command)} stopped.`}),(0,Y.jsx)(Ne,{text:e.logTail,source:L(n.command),onCopy:t.copy}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(D,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(Be,{server:n})]})}function nt({state:e,actions:t}){let{server:n}=e,r=e.reason===`idle`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(x,{}),title:r?`Stopped after 15 min idle`:`${n.label} stopped`,children:[(0,Y.jsx)(Z,{children:r?`Nobody had this pane open for 15 min, so Squawk stopped ${n.label} :${n.port} and the browser to free memory. Start again reopens ${Le(e.lastUrl)}.`:`You stopped ${n.label} :${n.port}. Start again reopens ${Le(e.lastUrl)}.`}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(D,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(Be,{server:n})]})}var rt=[`browser`,`page`,`frame`];function it({step:e,url:t}){let n=rt.indexOf(e),i=t?Le(t):`the page`;return(0,Y.jsx)(`div`,{"data-slot":`preview-state`,"data-state":`loading`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center px-6 py-8`,children:(0,Y.jsx)(`ol`,{"aria-label":`Opening the page`,className:`mx-auto flex flex-col gap-4 text-sm`,children:[{done:`Browser started`,active:`Starting the browser`},{done:`Opened ${i}`,active:`Opening ${i}`},{done:`First frame`,active:`First frame`}].map((e,t)=>{let i=t<n,a=t===n;return(0,Y.jsxs)(`li`,{"aria-current":a?`step`:void 0,className:r(`flex items-center gap-3`,a?`font-semibold text-foreground`:i?`text-foreground`:`text-soft-foreground`),children:[i?(0,Y.jsx)(m,{className:`size-5 text-success`,"aria-hidden":`true`}):a?(0,Y.jsx)(y,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,Y.jsx)(xe,{className:`size-5 text-border`,"aria-hidden":`true`}),i?e.done:a?e.active:e.done]},t)})})})}function at({state:e,actions:t,worktree:n}){let r=n?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(n)?.[0]:void 0,i=e.server?.label;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(B,{}),title:`This task's worktree is gone`,children:[(0,Y.jsx)(Z,{children:`${i??`The server`} ran in ${r??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,Y.jsx)(w,{entry:{kind:`preview-server`,id:`preview-server:${e.server.port}`,server:e.server,state:`unavailable`},inPreview:!1}):null,(0,Y.jsx)(Q,{children:(0,Y.jsx)(D,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function ot({actions:e}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":`proxy-blocked`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Me,{})}),(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:(0,Y.jsx)(W,{})}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,Y.jsx)(Z,{children:`The proxy in front of Squawk didn't let the preview's WebSocket through. This is a known gap behind Basic Auth. Everything else in Squawk keeps working.`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(D,{variant:`outline`,onClick:e.close,children:`Close preview`}),(0,Y.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Re,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function st(e){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Windows/.test(e)?`Windows`:/Mac OS X|Macintosh/.test(e)?`Mac`:/Linux|X11/.test(e)?`Linux`:``,n=/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n&&t?`${n} on ${t}`:n||t}function ct({state:e,actions:t}){let n=st(e.by);return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(U,{}),title:`Preview is open somewhere else`,children:[(0,Y.jsx)(Z,{children:`Another tab took this browser${n?` (${n})`:``}. Only one tab can view and drive it at a time.`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(D,{variant:`contrast`,onClick:t.useHere,children:[(0,Y.jsx)(R,{"aria-hidden":`true`}),`Use it here`]}),(0,Y.jsx)(D,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function lt({attempt:e,exhausted:t,onReconnect:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-connection-banner`,role:`status`,className:`absolute inset-x-3 top-3 z-10 flex flex-wrap items-center justify-between gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-3.5 py-2.5 text-sm shadow-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(De,{className:`size-4 shrink-0 text-danger`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Lost the connection to the host`}),t?null:(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · reconnecting (attempt ${e} of 5)`})]})]}),(0,Y.jsx)(D,{variant:`outline`,onClick:n,children:t?`Reconnect`:`Reconnect now`})]})}function ut({servers:e,states:t,onOpen:n,agentLive:r=!1,agentIdle:i=!1,onOpenAgent:a}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":i?`agent-idle`:`empty`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,Y.jsx)(Z,{children:`The browser runs on the host, next to the worktree. Type a URL, a bare port such as 3000, or open a server the agent registered.`}),i?(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,Y.jsx)(Ee,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`The agent is not driving the browser now.`})]}):null,r&&a!==void 0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-agent`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Driven by the agent`}),(0,Y.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(P,{tone:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,Y.jsx)(D,{variant:`outline`,size:`sm`,className:`max-md:h-11`,"aria-label":`Open the agent's page`,onClick:a,children:`Open`})]})]}):null,e.length>0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-registered`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Registered in this task`}),(0,Y.jsx)(`ul`,{children:e.map(e=>{let r=_e(e,t),i=he(r);return(0,Y.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border px-3.5 py-2 text-sm last:border-b-0`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(P,{tone:i.tone,shape:i.ring?`ring`:`filled`,pulse:i.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:i.text})]}),(0,Y.jsx)(D,{variant:`outline`,size:`sm`,className:`max-md:h-11`,onClick:()=>n(e.port),children:de(r)?`Open`:`Review`})]},e.port)})})]}):null,(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(v,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Review opens a server's approval in this pane: its command, cwd and Run and open. Nothing runs from this list. Paste works; copying text out, file pickers and downloads don't yet.`})]})]})}function dt({dialog:e,onResult:t}){let[n,r]=(0,J.useState)(e.defaultPrompt??``),i=e.type===`beforeunload`,a=(0,J.useRef)(null),o=(0,J.useRef)(null);(0,J.useEffect)(()=>{(e.type===`prompt`?o.current:a.current)?.focus()},[e.type]);let s=(0,J.useRef)(t);s.current=t,(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target instanceof Element?e.target:null;t&&t!==document.body&&!t.closest(`[data-slot="preview-pane-body"], [data-slot="preview-page-dialog"]`)||(e.stopPropagation(),s.current({accept:!1}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let c=()=>t(e.type===`prompt`?{accept:!0,text:n}:{accept:!0});return(0,Y.jsx)(`div`,{"data-slot":`preview-page-dialog`,className:`absolute inset-0 z-20 flex items-center justify-center bg-foreground/30 p-4`,children:(0,Y.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`${e.origin} says`,className:`w-full max-w-[380px] rounded-xl border border-border bg-card p-4 shadow-lg`,children:[(0,Y.jsx)(`p`,{className:`mb-3 truncate font-mono text-xs text-muted-foreground`,children:`${e.origin} says`}),(0,Y.jsx)(`p`,{className:`mb-4 text-sm break-words whitespace-pre-wrap text-foreground`,children:e.message||(i?`Changes you made may not be saved.`:``)}),e.type===`prompt`?(0,Y.jsx)(`input`,{ref:o,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()},className:`mb-4 h-11 w-full rounded-md border border-border bg-background px-3 text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,Y.jsx)(D,{variant:`outline`,onClick:()=>t({accept:!1}),children:i?`Stay`:`Cancel`}),(0,Y.jsx)(D,{ref:a,variant:`contrast`,onClick:c,children:i?`Leave`:`OK`})]})]})})}var ft=10,pt=500,mt=500,ht=4,gt=16,_t=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function vt(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function yt(e,t){return{rect:e,scale:t,touches:new Map,multiTouch:!1,click:{at:-1/0,x:0,y:0,button:-1,count:1}}}var bt=[`left`,`middle`,`right`];function $(e,t,n,r){let i=vt(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:bt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:_t(n),...r}}var xt=e=>e===0?0:-e;function St(e,t,n,r,i){let a=vt(t,n,e.rect,e.scale);return{t:`mouse`,type:`mouseWheel`,x:a.x,y:a.y,button:`none`,buttons:0,deltaX:xt(r/e.scale),deltaY:xt(i/e.scale),modifiers:0}}function Ct(e,t){let{touches:n}=t,r=n.get(e.pointerId),i=()=>{n.delete(e.pointerId),n.size===0&&(t.multiTouch=!1)};switch(e.type){case`pointerdown`:return n.set(e.pointerId,{startX:e.clientX,startY:e.clientY,startAt:e.timeStamp,lastX:e.clientX,lastY:e.clientY,scrolling:!1}),n.size>1&&(t.multiTouch=!0),[];case`pointermove`:{if(!r)return[];if(t.multiTouch)return r.lastX=e.clientX,r.lastY=e.clientY,[];if(!r.scrolling){if(Math.hypot(e.clientX-r.startX,e.clientY-r.startY)<=ft)return[];r.scrolling=!0}let n=e.clientX-r.lastX,i=e.clientY-r.lastY;return r.lastX=e.clientX,r.lastY=e.clientY,n===0&&i===0?[]:[St(t,e.clientX,e.clientY,n,i)]}case`pointerup`:{let n=r!==void 0&&!t.multiTouch&&!r.scrolling&&e.timeStamp-r.startAt<=pt;if(i(),!n||!r)return[];let a={...e,clientX:r.startX,clientY:r.startY};return[$(`mouseMoved`,t,a,{button:`none`,buttons:0}),$(`mousePressed`,t,a,{button:`left`,buttons:1}),$(`mouseReleased`,t,a,{button:`left`,buttons:0})]}case`pointercancel`:return i(),[]}}function wt(e,t){if(e.pointerType===`touch`)return Ct(e,t);switch(e.type){case`pointerdown`:{let n=t.click,r=n.button===e.button&&e.timeStamp-n.at<=mt&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=ht;return t.click={at:e.timeStamp,x:e.clientX,y:e.clientY,button:e.button,count:r?n.count+1:1},[$(`mousePressed`,t,e,{clickCount:t.click.count})]}case`pointermove`:return[$(`mouseMoved`,t,e,{button:e.buttons&1?`left`:`none`})];case`pointerup`:return[$(`mouseReleased`,t,e,{clickCount:t.click.count})];case`pointercancel`:return[]}}function Tt(e,t,n){let r=vt(e.clientX,e.clientY,t,n),i=e.deltaMode===1?gt:1;return{t:`mouse`,type:`mouseWheel`,x:r.x,y:r.y,button:`none`,buttons:e.buttons??0,deltaX:e.deltaX*i/n,deltaY:e.deltaY*i/n,modifiers:_t(e)}}var Et={a:`selectAll`,c:`copy`,x:`cut`,z:`undo`,y:`redo`};function Dt(e){let t=e.key.toLowerCase(),n=(e.ctrlKey||e.metaKey)&&!e.getModifierState?.(`AltGraph`);if(n&&(t===`v`||t===`k`))return;let r={t:`key`,key:e.key,code:e.code,modifiers:_t(e),vk:e.keyCode};if(e.type===`keyup`)return{...r,type:`keyUp`};let i=n?``:e.key.length===1?e.key:e.key===`Enter`?`\r`:e.key===`Tab`?` `:``,a=n?t===`z`&&e.shiftKey?`redo`:Et[t]:void 0,o={t:`key`,type:i?`keyDown`:`rawKeyDown`,key:e.key,code:e.code,text:i,modifiers:_t(e),vk:e.keyCode};return a?{...o,commands:[a]}:o}function Ot(e){return e?{t:`insertText`,text:e}:void 0}var kt=e=>e,At=e=>e.key===`Escape`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey;function jt({scale:e,send:t,onLeave:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(yt({left:0,top:0},e)),a=(0,J.useRef)(e);a.current=e;let o=(0,J.useRef)(t);o.current=t;let s=(0,J.useRef)(void 0),c=()=>{let e=r.current;e&&(i.current.rect=e.getBoundingClientRect()),i.current.scale=a.current},l=e=>{c();for(let t of wt(kt(e),i.current))o.current(t)},u=()=>{let e=s.current;e&&(s.current=void 0,cancelAnimationFrame(e.frame),l(e.event))};(0,J.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current.frame)},[]),(0,J.useEffect)(()=>{document.activeElement===document.body&&r.current?.focus({preventScroll:!0})},[]),(0,J.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{e.preventDefault(),c(),o.current(Tt(e,i.current.rect,i.current.scale))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,J.useEffect)(()=>{let e=e=>{if(document.activeElement!==r.current)return;let t=Ot(e.clipboardData?.getData(`text`)??``);t&&(e.preventDefault(),o.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[]);let d=e=>{u(),r.current?.focus({preventScroll:!0});try{r.current?.setPointerCapture(e.pointerId)}catch{}l(e.nativeEvent)},f=e=>{let t=e.nativeEvent;if(t.pointerType===`touch`)return l(t);let n=s.current;if(n){n.event=t;return}s.current={event:t,frame:requestAnimationFrame(()=>{let e=s.current;s.current=void 0,e&&l(e.event)})}},p=e=>{u(),l(e.nativeEvent)},m=e=>{if(At(e)){e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&(n?n():r.current?.blur());return}let i=Dt(e.nativeEvent);i&&(e.preventDefault(),e.stopPropagation(),t(i))};return(0,Y.jsx)(`div`,{ref:r,"data-slot":`preview-input`,role:`application`,"aria-label":`Page preview, interactive`,"aria-description":`Keys go to the page, Tab included. Press Shift+Escape to return to the cockpit.`,tabIndex:0,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onContextMenu:e=>e.preventDefault(),onKeyDown:m,onKeyUp:m,className:`absolute inset-0 touch-none select-none outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset`})}async function Mt(e){if(typeof createImageBitmap==`function`){let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,release:()=>t.close()}}let t=URL.createObjectURL(e),n=new Image;return n.src=t,await n.decode(),{source:n,width:n.naturalWidth,height:n.naturalHeight,release:()=>URL.revokeObjectURL(t)}}function Nt({ref:e,viewport:t,dimmed:n=!1,cursor:i,onSize:a,renderInput:s,children:c}){let l=(0,J.useRef)(0),u=(0,J.useRef)(null),d=(0,J.useRef)(null),[f,p]=(0,J.useState)(null),m=(0,J.useRef)(a);m.current=a,(0,J.useImperativeHandle)(e,()=>({async draw(e){let t=++l.current,n=d.current,r=n?.getContext(`2d`);if(!(!n||!r||!o()))try{let i=await Mt(e);try{if(t!==l.current||!o()||d.current!==n)return;n.width!==i.width&&(n.width=i.width),n.height!==i.height&&(n.height=i.height),r.drawImage(i.source,0,0)}finally{i.release()}}catch{}}}),[]),(0,J.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{let t=Math.round(e.clientWidth),n=Math.round(e.clientHeight);t===0||n===0||(p(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n}),m.current?.({w:t,h:n}))};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let h=t===`fit`?f:t,g=t===`fit`||!f?1:Math.min(1,(f.w-24)/t.w,(f.h-24)/t.h),_=h?{width:Math.floor(h.w*g),height:Math.floor(h.h*g)}:void 0;return(0,Y.jsxs)(`div`,{ref:u,"data-slot":`preview-stage`,"data-viewport":t===`fit`?`fit`:`${t.w}x${t.h}`,className:r(`relative min-h-0 flex-1 overflow-hidden bg-muted`,t!==`fit`&&`flex items-start justify-center overflow-auto p-3`),children:[h?(0,Y.jsxs)(`div`,{"data-slot":`preview-surface`,"data-scale":g,style:{..._,cursor:i},className:r(`relative shrink-0 bg-card`,t!==`fit`&&`shadow-md`,n&&`opacity-60 saturate-50`),children:[(0,Y.jsx)(`canvas`,{ref:d,"aria-label":`Page preview`,role:`img`,style:_,className:`block touch-none select-none`}),s?.({canvas:d.current,scale:g,viewport:h})]}):null,c]})}var Pt=`cez-preview-quality`,Ft=[{value:`normal`,label:`Normal`,detail:`The default. Lighter on CPU and network.`},{value:`high`,label:`High`,detail:`Sharper text and fine detail. Uses more CPU and network.`},{value:`ultra`,label:`Ultra`,detail:`High at your screen's pixel density, up to 2×. Uses the most CPU and network.`}];function It(e){return Ft.find(t=>t.value===e)?.value??`normal`}var Lt=e=>Ft.find(t=>t.value===e)?.label??`Normal`;function Rt(){try{return It(localStorage.getItem(Pt))}catch{return`normal`}}function zt(e){try{localStorage.setItem(Pt,e)}catch{}}var Bt=[{w:390,h:844,icon:_},{w:820,h:1180,icon:we},{w:1440,h:900,icon:b}],Vt=`size-8 shrink-0 max-md:size-11`,Ht=e=>e===`fit`?`Fit`:`${e.w} × ${e.h}`;function Ut(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Wt=e=>`${e.fps} fps · ${e.kbps} KB/s${e.rttMs===void 0?``:` · ${e.rttMs} ms`}`;function Gt({stats:e,shrunk:t}){let n=Ut(250),r=e.lastFrameAt===void 0||n-e.lastFrameAt>=1e3;return t?(0,Y.jsx)(P,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,Y.jsxs)(`span`,{"data-slot":`preview-stats`,role:`img`,"aria-label":r?`idle`:Wt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(P,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline-block w-[28ch] overflow-hidden text-ellipsis`,children:r?`idle`:Wt(e)})]})}function Kt({current:e,agentShown:t,...n}){let r=e?e.label:t?`Agent's page`:`Server`;return(0,Y.jsxs)(D,{variant:`outline`,size:`sm`,className:`max-w-[11rem] min-w-0 gap-1.5 max-md:h-11`,"aria-label":e?`Server: ${e.label} :${e.port}`:t?`Server: ${r}`:`Server`,...n,children:[e||t?(0,Y.jsx)(P,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,Y.jsx)(T,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:r}),e?(0,Y.jsxs)(`span`,{className:`font-mono font-normal text-muted-foreground`,children:[`:`,e.port]}):null,(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function qt({shown:e,live:t,onSelect:n}){return(0,Y.jsxs)(k,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":e||void 0,onSelect:n,children:[(0,Y.jsx)(P,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]})}function Jt(e,t){return e?`${e.label} :${e.port}`:t?`Agent's page`:`Preview`}function Yt(e){let t=e.onPickAgent!==void 0,n=e.agentLive===!0&&t,r=e.agentShown===!0;return{agentLive:n,agentShown:r,agentListed:n||r&&t}}function Xt(e){let{compact:t=!1,navEnabled:n,loading:r=!1}=e,i=(0,J.useRef)(null),a=e.urlInputRef??i,o=(0,J.useRef)(!1),[s,c]=(0,J.useState)(null),[l,d]=(0,J.useState)(!1),f=(0,Y.jsx)(D,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Back`,disabled:!n,onClick:e.onBack,children:(0,Y.jsx)(ye,{"aria-hidden":`true`})}),p=(0,Y.jsx)(D,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Forward`,disabled:!n,onClick:e.onForward,children:(0,Y.jsx)(u,{"aria-hidden":`true`})}),m=(0,Y.jsx)(D,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Reload`,"aria-busy":r||void 0,disabled:!n||r,onClick:()=>e.onReload(!1),children:(0,Y.jsx)(K,{"aria-hidden":`true`})}),h=e.onSession?(0,Y.jsxs)(D,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1 max-md:h-11`,onClick:e.onSession,children:[(0,Y.jsx)(ge,{"aria-hidden":`true`}),`Session`]}):null,g=r?(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Loading the page`,className:`absolute inset-x-0 bottom-0 h-0.5 overflow-hidden bg-transparent`,children:(0,Y.jsx)(`div`,{className:`preview-progress h-full w-2/5 bg-success`})}):null,_=(0,Y.jsx)(Qt,{props:e,input:a,draft:s,setDraft:c,focused:l,setFocused:d}),{agentListed:v}=Yt(e),y=e.servers.length+ +!!v>=2,b=y||e.adopted,x={back:f,forward:p,reload:m,address:_,more:(0,Y.jsx)(rn,{props:e,compact:t,crowded:b}),session:h,progress:g};return t?(0,Y.jsx)(an,{props:e,elements:x}):(0,Y.jsx)(on,{props:e,elements:x,switcher:y,crowded:b,input:a,focusUrlAfterMenu:o})}function Zt({props:e,input:t,focusUrlAfterMenu:n}){let{servers:r,current:i}=e,{agentLive:a,agentShown:o,agentListed:s}=Yt(e);return(0,Y.jsxs)(N,{children:[(0,Y.jsx)(j,{asChild:!0,children:(0,Y.jsx)(Kt,{current:i,agentShown:o})}),(0,Y.jsxs)(M,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,Y.jsx)(qt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=he(_e(t,e.serverStates));return(0,Y.jsxs)(k,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":i?.port===t.port||void 0,onSelect:()=>e.onPickServer(t.port),children:[(0,Y.jsx)(P,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,Y.jsx)(A,{}),(0,Y.jsxs)(k,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,Y.jsx)(g,{"aria-hidden":`true`}),`Type a URL instead`]})]})]})}function Qt({props:e,input:t,draft:n,setDraft:i,focused:a,setFocused:o}){let{url:s,adopted:c}=e;return(0,Y.jsxs)(`div`,{className:`relative flex min-w-[9rem] flex-1 items-center`,children:[(0,Y.jsx)(g,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`input`,{ref:t,type:`text`,"aria-label":`Page address`,placeholder:`Type a URL or a port`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:n??(a?s:Le(s)),title:s||void 0,className:r(`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-muted pl-8 font-mono text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:bg-background focus-visible:ring-[3px] focus-visible:ring-ring/30 max-md:h-11`,c?`pr-40`:`pr-2.5`),onFocus:e=>{let t=e.currentTarget;o(!0),requestAnimationFrame(()=>{document.activeElement===t&&t.select()})},onBlur:()=>{o(!1),i(null)},onChange:e=>i(e.target.value),onKeyDown:t=>{t.key===`Enter`?(e.onNavigate(n??s),t.currentTarget.blur()):t.key===`Escape`&&t.currentTarget.blur()}}),c&&!a?(0,Y.jsxs)(`span`,{className:`pointer-events-none absolute right-2 inline-flex h-6 items-center gap-1 rounded-full border border-border bg-card px-2 text-xs font-semibold text-muted-foreground`,children:[(0,Y.jsx)(Se,{className:`size-3`,"aria-hidden":`true`}),`Not started by Squawk`]}):null]})}function $t({props:e}){let{viewport:t}=e;return(0,Y.jsxs)(N,{children:[(0,Y.jsx)(j,{asChild:!0,children:(0,Y.jsxs)(D,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ht(t)}`,children:[t===`fit`?(0,Y.jsx)(H,{"aria-hidden":`true`}):(0,Y.jsx)(b,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:r(`hidden @min-[500px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ht(t)}),(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(M,{align:`start`,className:`min-w-56`,children:[(0,Y.jsxs)(k,{className:`gap-2.5`,"aria-current":t===`fit`||void 0,onSelect:()=>e.onViewport(`fit`),children:[(0,Y.jsx)(H,{"aria-hidden":`true`}),`Fit`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]}),Bt.map(({w:n,h:r,icon:i})=>(0,Y.jsxs)(k,{className:`gap-2.5 font-mono`,"aria-current":t!==`fit`&&t.w===n&&t.h===r||void 0,onSelect:()=>e.onViewport({w:n,h:r}),children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,Y.jsx)(d,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function en({quality:e,onQuality:t,compact:n}){return(0,Y.jsx)(ne,{value:e,onValueChange:e=>t(It(e)),children:Ft.map(e=>(0,Y.jsx)(te,{value:e.value,"data-quality":e.value,className:r(`items-start`,n&&`min-h-11`),children:(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{children:e.label}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:e.detail})]})},e.value))})}function tn({props:e}){let{quality:t}=e;return(0,Y.jsxs)(N,{children:[(0,Y.jsx)(j,{asChild:!0,children:(0,Y.jsxs)(D,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Lt(t)}`,children:[(0,Y.jsx)(V,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[560px]:inline`,children:Lt(t)}),(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(M,{align:`start`,className:`w-64`,children:[(0,Y.jsx)(O,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function nn({stats:e,status:t,crowded:n}){return e?(0,Y.jsx)(Gt,{stats:e,shrunk:n}):t?(0,Y.jsxs)(`span`,{"data-slot":`preview-status`,className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(P,{tone:t.tone,"aria-hidden":`true`}),t.label]}):null}function rn({props:e,compact:t,crowded:n}){let{stats:r,navEnabled:i,url:a,current:o,adopted:s}=e;return(0,Y.jsxs)(N,{children:[(0,Y.jsx)(j,{asChild:!0,children:(0,Y.jsx)(D,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`More`,children:(0,Y.jsx)(ie,{"aria-hidden":`true`})})}),(0,Y.jsxs)(M,{align:`end`,className:`min-w-64`,children:[n&&r&&!t?(0,Y.jsx)(O,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Wt(r)}):null,(0,Y.jsxs)(k,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!i,onSelect:()=>e.onReload(!0),children:[(0,Y.jsx)(G,{"aria-hidden":`true`}),`Reload without cache`]}),(0,Y.jsxs)(k,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:a===``,onSelect:e.onCopyUrl,children:[(0,Y.jsx)(ce,{"aria-hidden":`true`}),`Copy page URL`]}),o?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(A,{}),s?(0,Y.jsxs)(k,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,Y.jsx)(Ce,{className:`mt-0.5 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Stop server · ${o.label} :${o.port}`}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:`Squawk didn't start this server, so it won't stop it. Stop it where it was started.`})]})]}):(0,Y.jsxs)(k,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(o.port),children:[(0,Y.jsx)(be,{"aria-hidden":`true`}),`Stop server · ${o.label} :${o.port}`]})]}):null,t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(A,{}),(0,Y.jsx)(O,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,Y.jsx)(A,{}),(0,Y.jsxs)(k,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,Y.jsx)(se,{"aria-hidden":`true`}),`Close preview`]})]}):null]})]})}function an({props:e,elements:t}){let{stats:n,current:r,badge:i=!0}=e,{agentShown:a}=Yt(e),{back:o,forward:s,reload:c,address:l,more:u,session:d,progress:f}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,"data-compact":``,className:`relative flex shrink-0 flex-col border-b border-border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pt-[max(0.25rem,env(safe-area-inset-top))]`,children:[d,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-center leading-tight`,children:[(0,Y.jsxs)(`span`,{className:`flex max-w-full items-center gap-1.5 text-sm font-semibold text-foreground`,children:[n?(0,Y.jsx)(P,{tone:`success`,"aria-hidden":`true`}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:Jt(r,a)})]}),i?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Experimental`}):null]}),u]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[o,s,c,l]}),f]})}function on({props:e,elements:t,switcher:n,crowded:r,input:i,focusUrlAfterMenu:a}){let{badge:o=!0,stats:s,status:c}=e,{back:l,forward:u,reload:d,address:f,more:p,session:m,progress:h}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,className:`@container relative flex shrink-0 items-center gap-1.5 border-b border-border bg-background px-2.5 py-2`,children:[m,l,u,d,n?(0,Y.jsx)(Zt,{props:e,input:i,focusUrlAfterMenu:a}):null,f,(0,Y.jsx)($t,{props:e}),(0,Y.jsx)(tn,{props:e}),(0,Y.jsx)(nn,{stats:s,status:c,crowded:r}),o?(0,Y.jsx)(Me,{iconOnly:r,responsive:!r}):null,(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),p,(0,Y.jsx)(D,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Close preview`,onClick:e.onClose,children:(0,Y.jsx)(se,{"aria-hidden":`true`})}),h]})}function sn({transport:e,takenOver:t,empty:n,stage:r,hasFrame:i,lost:a,url:o,worktree:s}){let c=a||e!==`blocked`&&t!==void 0;return e===`blocked`?{content:{kind:`state`,state:{stage:`proxy-blocked`}},dim:c}:t===void 0?n||r?.stage===`agent-idle`?{content:{kind:`empty`,agentIdle:!n&&r?.stage===`agent-idle`},dim:c}:r?.stage===`streaming`||r?.stage===`loading`&&i?{content:{kind:`none`},dim:c}:r?{content:{kind:`state`,state:r,url:o,worktree:s},dim:c}:a?{content:{kind:`none`},dim:c}:{content:{kind:`state`,state:{t:`state`,stage:`loading`,step:`browser`},url:o},dim:c}:{content:{kind:`state`,state:{stage:`taken-over`,by:t}},dim:c}}function cn(e,{servers:t,serverStates:n,agentLive:r,openServer:i,openAgent:a,actions:o}){switch(e.kind){case`none`:return null;case`state`:{let{kind:t,...n}=e;return(0,Y.jsx)(ze,{...n,actions:o})}case`empty`:return(0,Y.jsx)(ut,{servers:t,states:n,onOpen:e=>i(e),agentLive:r===!0,agentIdle:e.agentIdle,onOpenAgent:a})}}function ln(){let e=typeof window>`u`?void 0:window.devicePixelRatio;return typeof e==`number`&&e>0?e:1}function un(){let[e,t]=(0,J.useState)(ln);return(0,J.useEffect)(()=>{let n=window.matchMedia?.(`(resolution: ${e}dppx)`);if(!n)return;let r=()=>t(ln());return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[e]),e}var dn=2e3,fn=500,pn=1e3;function mn(e,t){switch(e.stage){case`needs-approval`:case`port-held`:case`server-starting`:case`server-stalled`:case`server-exited`:case`server-stopped`:return e.server.port===t;case`loading`:case`streaming`:return!0;default:return!1}}function hn(e){navigator.clipboard?.writeText(e).then(()=>c(`Copied`),()=>c(`Couldn't copy to the clipboard`,{tone:`danger`}))}var gn=e=>`http://localhost:${e.port}${e.path&&e.path!==`/`?e.path:``}`;function _n(e,t){return e?.port===void 0?e?.agent===!0||e?.url!==void 0:e.restored!==!0||t.some(t=>t.port===e.port)}function vn(e){return`port`in e?{port:e.port}:`agent`in e?{agent:!0}:{url:e.url}}function yn({run:e,servers:t,request:n,onTarget:r,onLive:i,onClose:s}){let c=un(),l=(0,J.useRef)(c);l.current=c;let u=a(),d=(0,J.useRef)(crypto.randomUUID()),f=(0,J.useRef)(!1),p=re(),m=le(fe,!1),[h,g]=(0,J.useState)(0),[_,v]=(0,J.useState)({state:`connecting`,attempt:0}),[y,b]=(0,J.useState)(!1),[x,S]=(0,J.useState)(void 0),[C,w]=(0,J.useState)(void 0),[ee,T]=(0,J.useState)(``),[E,D]=(0,J.useState)(void 0),[O,te]=(0,J.useState)(!1),[k,A]=(0,J.useState)(void 0),[j,M]=(0,J.useState)(!1),[ne,N]=(0,J.useState)(!1),[P,ie]=(0,J.useState)(void 0),[ae,oe]=(0,J.useState)(void 0),[se,ce]=(0,J.useState)(void 0),[F,ue]=(0,J.useState)(`fit`),[de,I]=(0,J.useState)(Rt),[L,pe]=(0,J.useState)(null),[me,he]=(0,J.useState)(void 0),[ge,_e]=(0,J.useState)(0),ve=(0,J.useRef)(void 0),ye=(0,J.useRef)(null),be=(0,J.useRef)(null),xe=(0,J.useRef)(void 0),R=(0,J.useRef)(void 0),z=(0,J.useRef)(de);z.current=de;let B=(0,J.useRef)({port:E,stage:C,agent:O});B.current={port:E,stage:C,agent:O};let V=(0,J.useRef)([]),Se=(0,J.useRef)(void 0),Ce=(0,J.useRef)(!1),H=(0,J.useRef)(!1),U=(0,J.useCallback)(e=>{H.current&&ve.current?.send(e)},[]);(0,J.useEffect)(()=>{let t;return t=je({projectId:p??`default`,runId:e.id},{onFrame(e){if(!o())return;let n=Date.now();V.current.push({at:n,bytes:e.size}),Ce.current||(Ce.current=!0,N(!0)),(ye.current?.draw(e)??Promise.resolve()).finally(()=>t?.send({t:`ack`}))},onMessage(e){switch(e.t){case`state`:if(w(e),(e.stage===`streaming`||e.stage===`loading`)&&_e(e=>e+1),R.current!==void 0&&mn(e,R.current)){let n=R.current;R.current=void 0,(e.stage===`needs-approval`||e.stage===`server-exited`||e.stage===`server-stopped`)&&t?.send({t:`run`,port:n})}return;case`url`:return T(e.url);case`cursor`:return ie(e.cursor);case`dialog`:return oe(e);case`pong`:Se.current=Math.max(0,Date.now()-e.ts);return;case`downloadProgress`:w(t=>t?.stage===`downloading`?{...t,received:e.received,total:e.total}:t);return;case`replaced`:S(e.by),H.current=!1,t?.close();return}},onTransport(e,n){H.current=e===`open`,v({state:e,attempt:n??0}),e===`open`&&(b(!0),xe.current&&(t?.send({t:`open`,target:xe.current,viewerId:d.current,resume:f.current,quality:z.current,dpr:l.current}),f.current=!0))}}),ve.current=t,()=>{H.current=!1,t?.close(),ve.current===t&&(ve.current=void 0)}},[p,e.id,h]);let W=u&&_.state===`open`&&x===void 0,G=m||F===`fit`?L:F;(0,J.useEffect)(()=>{G&&W&&(C?.stage===`streaming`||C?.stage===`loading`)&&U({t:`resize`,w:G.w,h:G.h,...c===1?{}:{dpr:c}})},[G?.w,G?.h,c,W,C?.stage,ge,U]),(0,J.useEffect)(()=>{if(!W)return;let e=setInterval(()=>U({t:`ping`,ts:Date.now()}),dn);return()=>clearInterval(e)},[W,U]);let K=W&&C?.stage===`streaming`;(0,J.useEffect)(()=>{if(!K){ce(void 0);return}let e=setInterval(()=>{let e=Date.now();V.current=V.current.filter(t=>e-t.at<=pn);let t={fps:V.current.length,kbps:Math.round(V.current.reduce((e,t)=>e+t.bytes,0)/1024),...Se.current===void 0?{}:{rttMs:Se.current},...V.current.length>0?{lastFrameAt:V.current.at(-1).at}:{}};ce(e=>{let n=t.lastFrameAt??e?.lastFrameAt,r={...t,...n===void 0?{}:{lastFrameAt:n}};return e&&e.fps===r.fps&&e.kbps===r.kbps&&e.rttMs===r.rttMs&&e.lastFrameAt===r.lastFrameAt?e:r})},fn);return()=>clearInterval(e)},[K]),(0,J.useEffect)(()=>(i?.(K),()=>i?.(!1)),[K,i]),(0,J.useEffect)(()=>{k&&r?.(k)},[k,r]);let q=(0,J.useCallback)((e,t,n=!1)=>{xe.current=e,R.current=n&&`port`in e?e.port:void 0,M(!0),w(void 0),S(void 0),he(void 0),T(t),D(`port`in e?e.port:void 0),te(`agent`in e),A(vn(e)),U({t:`open`,target:e,viewerId:d.current,quality:z.current,dpr:l.current}),f.current=H.current},[U]),we=(0,J.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);q({port:e},r?gn(r):`http://localhost:${e}`,n)},[t,q]),Te=(0,J.useCallback)(()=>q({agent:!0},``),[q]);(0,J.useEffect)(()=>{if(n?.agent){if(B.current.agent&&B.current.stage?.stage===`streaming`)return;Te();return}if(n?.url!==void 0){let e=Fe(n.url,t);e.kind===`server`?we(e.port):e.kind===`url`&&q({url:e.url},e.url);return}n?.port!==void 0&&(n.restored&&!t.some(e=>e.port===n.port)||B.current.port===n.port&&B.current.stage?.stage===`streaming`&&n.run!==!0||we(n.port,n.run===!0))},[n]);let Ee=!j&&!x&&_.state!==`blocked`,De=_n(n,t);(0,J.useEffect)(()=>{Ee&&!De&&be.current?.focus()},[Ee,De]);let Oe=e=>{let n=Fe(e,t);if(n.kind===`error`)return he(n.message);if(n.kind===`server`)return we(n.port);if(B.current.stage?.stage===`streaming`&&!B.current.agent)return xe.current={url:n.url},R.current=void 0,D(void 0),A({url:n.url}),he(void 0),T(n.url),U({t:`nav`,url:n.url});q({url:n.url},n.url)},ke=(0,J.useCallback)(e=>{z.current=e,I(e),zt(e),U({t:`quality`,quality:e})},[U]),Ae=()=>{f.current=!1,S(void 0),v({state:`connecting`,attempt:0}),Ce.current=!1,g(e=>e+1)};return{compact:m,transport:_,everOpened:y,takenOver:x,stage:C,url:ee,port:E,agent:O,hasFrame:ne,cursor:P,dialog:ae,setDialog:oe,stats:se,viewport:F,setViewport:ue,quality:de,chooseQuality:ke,setStageSize:pe,addressError:me,stageHandle:ye,urlInput:be,send:U,connected:W,streaming:K,openServer:we,openAgent:Te,empty:Ee,navigate:Oe,reconnect:Ae,actions:(0,J.useMemo)(()=>({download:()=>U({t:`download`}),cancelDownload:()=>U({t:`cancelDownload`}),retryBrowser:()=>U({t:`retryBrowser`}),run:e=>U({t:`run`,port:e}),stop:e=>U({t:`stop`,port:e}),keepWaiting:e=>U({t:`keepWaiting`,port:e}),close:s,useHere:Ae,copy:hn}),[U,s])}}function bn(e){return(0,Y.jsx)(ve,{onClose:e.onClose,children:(0,Y.jsx)(Cn,{...e})})}function xn(e,t,n,r){return e.state===`blocked`?{tone:`neutral`,label:`not supported`}:n?{tone:`neutral`,label:`paused`}:t&&(e.state===`reconnecting`||e.state===`closed`)?{tone:`danger`,label:`offline`}:e.state===`open`?r?Sn(r):void 0:{tone:`neutral`,label:`connecting…`}}function Sn(e){switch(e.stage){case`downloading`:return{tone:`pending`,label:`downloading`};case`download-failed`:return{tone:`danger`,label:`download failed`};case`sandbox-failed`:return{tone:`danger`,label:`browser failed`};case`browser-exited`:return{tone:`danger`,label:e.reason===`timeout`?`browser timed out`:`browser exited`};case`needs-approval`:return{tone:`neutral`,label:`not started`};case`port-held`:return{tone:`danger`,label:`port in use`};case`server-starting`:return{tone:`pending`,label:`waiting for :${e.server.port}`};case`server-stalled`:return{tone:`pending`,label:`waiting · 2 min`};case`server-exited`:return{tone:`danger`,label:`server exited`};case`server-stopped`:return{tone:`neutral`,label:`stopped`};case`agent-idle`:return{tone:`neutral`,label:`agent idle`};case`loading`:return{tone:`neutral`,label:`connecting…`};default:return}}function Cn(e){let{run:t,servers:n,serverStates:r,agentLive:i,onSession:a,onClose:o}=e,s=yn(e),{compact:c,transport:l,everOpened:u,takenOver:d,stage:f,url:p,port:m,agent:h,hasFrame:g,stats:_,viewport:v,setViewport:y,quality:b,chooseQuality:x,addressError:S,urlInput:C,send:w,streaming:ee,openServer:T,openAgent:E,empty:D,navigate:O,actions:te}=s,k=n.find(e=>e.port===m),A=f?.stage===`streaming`&&f.adopted,j=u&&(l.state===`reconnecting`||l.state===`closed`),{content:M,dim:ne}=sn({transport:l.state,takenOver:d,empty:D,stage:f,hasFrame:g,lost:j,url:p,worktree:t.worktreePath}),N=cn(M,{servers:n,serverStates:r,agentLive:i,openServer:T,openAgent:E,actions:te});return(0,Y.jsxs)(`section`,{"data-slot":`preview-pane-body`,"aria-label":`Live preview`,className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[(0,Y.jsx)(Xt,{url:p,servers:n,serverStates:r,badge:l.state!==`blocked`,current:k,agentLive:i===!0,agentShown:h,adopted:A,viewport:c?`fit`:v,quality:b,compact:c,navEnabled:ee,loading:f?.stage===`loading`,stats:ee?_??{fps:0,kbps:0}:void 0,status:ee?void 0:xn(l,u,d!==void 0,f),urlInputRef:C,onSession:a,onNavigate:O,onBack:()=>w({t:`back`}),onForward:()=>w({t:`forward`}),onReload:e=>w({t:`reload`,...e?{ignoreCache:!0}:{}}),onPickServer:e=>T(e),onPickAgent:E,onViewport:y,onQuality:x,onCopyUrl:()=>hn(p),onStop:e=>w({t:`stop`,port:e}),onClose:o}),S?(0,Y.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:S}):null,(0,Y.jsx)(wn,{transportState:s,overlay:N,dim:ne,lost:j})]})}function wn({transportState:e,overlay:t,dim:n,lost:r}){let{connected:i,dialog:a,hasFrame:o,stage:s,stageHandle:c,compact:l,viewport:u,cursor:d,setStageSize:f,send:p,urlInput:m,transport:h,reconnect:g,setDialog:_}=e,v=s?.stage,y=i&&t===null&&!a;return(0,Y.jsxs)(Nt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,Y.jsx)(jt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,Y.jsx)(lt,{attempt:h.attempt,exhausted:h.state===`closed`,onReconnect:g}):null,t?(0,Y.jsx)(`div`,{"data-slot":`preview-overlay`,className:n&&o?`absolute inset-0 overflow-auto bg-background/85`:`absolute inset-0 overflow-auto bg-background`,children:t}):null,a?(0,Y.jsx)(dt,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function Tn(e){let{visibleEvents:t}=me(e);return(0,J.useMemo)(()=>{let e=new Map;for(let n of ee(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function En(e){let t=Tn(e.run.id),n=ue(e.run.id);return(0,Y.jsx)(bn,{...e,serverStates:t,agentLive:n})}export{En as ConnectedPreviewPane};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{ci as i,j as a}from"./project-scope-context-d3J3hWPR.js";import{E as o,Lt as s,Vt as c,in as l}from"./queries-dnpdX9VT.js";import{n as u}from"./toaster-Bo5vCbz-.js";import{J as d,W as f,c as p,ft as m,l as h,tt as g}from"./design-icons-CzEoMH9c.js";import{t as _}from"./button-BQ2y4XRB.js";import{i as v,r as y,t as b}from"./popover-BPgUYFyu.js";import{a as x,i as S,o as C,r as w,s as T,t as E}from"./command-CDt1BsZy.js";import{f as D,i as O,p as k,u as A}from"./skills-pM_PouEs.js";import{t as j}from"./centered-state-V15AR_qo.js";import{Q as M,Un as N,at as P,nt as F,tt as I}from"./index-DgdiXHgV.js";import{t as L}from"./textarea-vJt9undk.js";var R=e(t(),1),z=n();function B(){let e=o();return e.isPending?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading prompt templates…`}):e.isError?(0,z.jsx)(j,{icon:(0,z.jsx)(f,{}),tone:`danger`,title:`Prompt templates did not load`,subtitle:e.error.message,heading:`h2`}):(0,z.jsx)(V,{initial:F(e.data.promptTemplates)})}function V({initial:e}){let t=i(),n=c(),r=o(),[f,p]=(0,R.useState)(e),[h,g]=(0,R.useState)(``),[v,y]=(0,R.useState)(``),b=l({mutationFn:e=>a({promptTemplates:e}),onSuccess:e=>{t.setQueryData(s.uiState,e),u(`Prompt templates saved`)},onError:e=>u(e.message,{tone:`danger`})}),x=JSON.stringify(f)!==JSON.stringify(e),S=f.some(e=>e.label.trim()===``||e.text.trim()===``),C=(e,t)=>p(n=>n.map(n=>n.id===e?{...n,...t}:n)),w=(e,t)=>p(n=>n.map(n=>{if(n.id!==e)return n;let r=n.skills??[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],{skills:a,...o}=n;return i.length>0?{...o,skills:i}:o})),T=e=>p(t=>t.filter(t=>t.id!==e));return(0,z.jsx)(`div`,{"data-slot":`prompt-templates-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,z.jsxs)(U,{title:`Reusable instructions`,hint:`Insert templates from task composers, or apply them automatically with selected skills when the prompt is empty.`,children:[(0,z.jsx)(`div`,{"data-slot":`prompt-template-list`,className:`flex flex-col gap-3`,children:f.length===0?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-empty`,className:`text-[13px] text-soft-foreground`,children:`No templates. Add one below, or reset to the built-ins.`}):f.map(e=>(0,z.jsxs)(`div`,{"data-slot":`prompt-template-row`,"data-template":e.id,className:`flex flex-col gap-1.5 rounded-md border border-border bg-card p-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`label`,{htmlFor:`template-label-${e.id}`,className:`text-sm`,children:`Template label`}),(0,z.jsx)(N,{id:`template-label-${e.id}`,"aria-label":`Label for ${e.label||`this template`}`,"data-slot":`prompt-template-label-input`,value:e.label,maxLength:80,onChange:t=>C(e.id,{label:t.target.value}),className:`flex-1`})]}),(0,z.jsx)(`label`,{htmlFor:`template-text-${e.id}`,className:`text-sm`,children:`Instructions`}),(0,z.jsx)(L,{id:`template-text-${e.id}`,"aria-label":`Text for ${e.label||`this template`}`,"data-slot":`prompt-template-text-input`,value:e.text,maxLength:2e3,onChange:t=>C(e.id,{text:t.target.value}),className:`min-h-14 text-[13px]`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm`,children:`Apply automatically with skills`}),(0,z.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5`,children:[(0,z.jsx)(H,{label:e.label,skills:n.data??[],skillUsage:r.data?.skillUsage,selected:e.skills??[],onToggle:t=>w(e.id,t)}),(e.skills??[]).map(t=>(0,z.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skill-chip`,"data-skill":t,title:`Stop applying “${e.label}” automatically with ${t}`,onClick:()=>w(e.id,t),className:`inline-flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-px font-mono text-[11px] font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[t,(0,z.jsx)(m,{"aria-hidden":`true`,className:`size-3`})]},t))]}),(0,z.jsx)(_,{type:`button`,className:`self-start`,variant:`outline`,size:`sm`,"data-action":`prompt-template-remove`,title:`Remove this template`,onClick:()=>T(e.id),children:`Delete template`})]},e.id))}),(0,z.jsxs)(`div`,{"data-slot":`prompt-template-new`,className:`flex flex-col gap-1.5 rounded-md border border-dashed border-border p-3`,children:[(0,z.jsx)(`h3`,{className:`text-lg`,children:`New template`}),(0,z.jsx)(`label`,{htmlFor:`new-template-label`,className:`text-sm`,children:`Label`}),(0,z.jsx)(N,{id:`new-template-label`,"aria-label":`New template label`,"data-slot":`prompt-template-new-label`,placeholder:`e.g. Review security`,value:h,maxLength:80,onChange:e=>g(e.target.value)}),(0,z.jsx)(`label`,{htmlFor:`new-template-text`,className:`text-sm`,children:`Instructions to insert`}),(0,z.jsx)(L,{id:`new-template-text`,"aria-label":`New template text`,"data-slot":`prompt-template-new-text`,placeholder:`Enter reusable instructions…`,value:v,maxLength:2e3,onChange:e=>y(e.target.value),className:`min-h-14 text-[13px]`}),(0,z.jsxs)(_,{type:`button`,variant:`outline`,size:`sm`,"data-action":`prompt-template-add`,disabled:!h.trim()||!v.trim(),onClick:()=>{let e=h.trim(),t=v.trim();!e||!t||(p(n=>[...n,{id:I(),label:e,text:t}]),g(``),y(``))},className:`self-start`,children:[(0,z.jsx)(d,{"aria-hidden":`true`,className:`size-3.5`}),`Add template`]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(_,{type:`button`,variant:`primary`,size:`sm`,"data-action":`prompt-templates-save`,disabled:!x||S||b.isPending,onClick:()=>b.mutate(f),children:`Save`}),(0,z.jsx)(_,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-templates-reset`,disabled:b.isPending,onClick:()=>p(M.map(e=>({...e}))),children:`Reset to defaults`}),S?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-invalid`,className:`text-[11px] text-danger`,children:`Every template needs both a label and text.`}):null]})]})})}function H({label:e,skills:t,skillUsage:n,selected:i,onToggle:a}){let[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(``),u=(0,R.useRef)(null),{mostUsed:d,project:f,global:m,ranked:_}=A(t,c,n),j=(e,t)=>{let n=i.includes(e.id);return(0,z.jsxs)(C,{value:D(e),keywords:k(e.name,e.description),"data-slot":`prompt-template-skill-option`,"data-skill":e.id,"data-selected":n?`true`:void 0,onSelect:()=>a(e.id),children:[(0,z.jsx)(P,{skill:e,emphasized:t}),n?(0,z.jsx)(p,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},D(e))};return(0,z.jsxs)(b,{open:o,onOpenChange:e=>{s(e),e||l(``)},children:[(0,z.jsx)(v,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skills-trigger`,"aria-label":`Apply ${e||`this template`} automatically with a skill`,title:`Pick the skills this template applies itself to`,className:r(`inline-flex h-[26px] items-center gap-1.5 rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,i.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,z.jsx)(g,{"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`apply with…`,(0,z.jsx)(h,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,z.jsx)(y,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,z.jsxs)(E,{shouldFilter:!1,children:[(0,z.jsx)(x,{placeholder:`search skills…`,value:c,onValueChange:l,onInput:()=>u.current?.scrollTo(0,0)}),(0,z.jsxs)(T,{ref:u,"data-slot":`prompt-template-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.trim()&&!t.some(e=>e.id===c.trim())?(0,z.jsx)(S,{children:(0,z.jsxs)(C,{value:`typed-skill`,onSelect:()=>a(c.trim()),children:[`Use skill id “`,c.trim(),`” (unchecked)`]})}):null,(_?_.length===0:d.length===0&&f.length===0&&m.length===0)?(0,z.jsx)(w,{children:`Nothing matches.`}):null,_?_.length>0?(0,z.jsx)(S,{children:_.map(e=>j(e,O(e)))}):null:(0,z.jsxs)(z.Fragment,{children:[d.length>0?(0,z.jsx)(S,{heading:`Most used`,children:d.map(e=>j(e,O(e)))}):null,f.length>0?(0,z.jsx)(S,{heading:`Project skills`,children:f.map(e=>j(e,!0))}):null,m.length>0?(0,z.jsx)(S,{heading:`Global`,children:m.map(e=>j(e,!1))}):null]})]})]})})]})}function U({title:e,hint:t,children:n}){return(0,z.jsxs)(`section`,{className:`settings-field flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,z.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}export{B as PromptTemplatesSection};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{ci as r,nn as i}from"./project-scope-context-d3J3hWPR.js";import{Mt as a,Rt as o,in as s}from"./queries-dnpdX9VT.js";import{n as c}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as l}from"./toaster-Bo5vCbz-.js";import{k as u}from"./design-icons-CzEoMH9c.js";import{t as d}from"./button-BQ2y4XRB.js";import{t as f}from"./switch-Bv2Zf1uU.js";import{t as p}from"./centered-state-V15AR_qo.js";import{t as m}from"./settings-field-Bl6WuvGX.js";var h=e(t(),1),g=n(),_=1,v=1,y=60,b=256;function x(){let e=a();return e.isPending?(0,g.jsx)(`p`,{"data-slot":`resources-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading resource settings…`}):e.isError?(0,g.jsx)(p,{icon:(0,g.jsx)(u,{}),tone:`danger`,title:`Resource settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,g.jsx)(S,{config:e.data})}function S({config:e}){let t=r(),n=s({mutationFn:e=>i(e),onSuccess:e=>t.setQueryData(o.config,e),onError:e=>l(e.message,{tone:`danger`})}),[a,c]=(0,h.useState)(e.resources.memoryLimitMb?String(e.resources.memoryLimitMb):``),u=e.resources.monitoringWakeIntervalMinutes??null,[d,p]=(0,h.useState)(u===null?`park`:`interval`),[_,x]=(0,h.useState)(String(u??5)),S=Number(_),D=!Number.isInteger(S)||S<v||S>y,k=d===`park`?u===null:!D&&u===S,A=d===`interval`&&D,j=()=>n.mutate({resources:{monitoringWakeIntervalMinutes:d===`park`?null:S}},{onSuccess:()=>l(d===`park`?`Monitoring will stay parked`:`Monitoring will re-check every ${S} minutes`)}),M=e.resources.autoResumeOnUsageLimit??!0,N=e=>n.mutate({resources:{autoResumeOnUsageLimit:e}},{onSuccess:()=>l(e?`Tasks stopped by a usage limit will resume themselves`:`Tasks stopped by a usage limit will stay failed`)}),P=a.trim()===``?0:Number(a),F=a.trim()!==``&&(!Number.isInteger(P)||P<b),I=(e.resources.memoryLimitMb??0)===(F?-1:P),L=()=>n.mutate({resources:{memoryLimitMb:P===0?null:P}},{onSuccess:()=>l(P===0?`Memory limit cleared`:`Memory limit set to ${P} MiB`)}),R=e.composerDefaults??{autonomous:null,worktree:null,inheritedAutonomous:`source-dependent`,inheritedWorktree:!0};return(0,g.jsxs)(`div`,{"data-slot":`resources-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,g.jsx)(C,{maxParallel:e.resources.maxParallel,onSelect:e=>n.mutate({resources:{maxParallel:e}}),disabled:n.isPending}),(0,g.jsx)(w,{maxParallel:e.resources.maxParallel,maxMonitoringSessions:e.resources.maxMonitoringSessions,onSelect:e=>n.mutate({resources:{maxMonitoringSessions:e}}),disabled:n.isPending}),(0,g.jsx)(T,{wakeMode:d,setWakeMode:p,wakeInterval:_,setWakeInterval:x,showInvalid:A,wakeSaved:k,saveWake:j,saveIsPending:n.isPending}),(0,g.jsxs)(m,{title:`Auto-resume after a usage limit`,hint:`Resume eligible tasks once the provider usage limit resets.`,children:[(0,g.jsx)(f,{"aria-label":`Auto-resume after a usage limit`,"data-slot":`resources-auto-resume`,checked:M,disabled:n.isPending,onCheckedChange:N}),(0,g.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Applies to Claude, Codex and OpenCode — whenever the provider says when the limit lifts.`})]}),(0,g.jsx)(E,{memory:a,setMemory:c,memoryInvalid:F,memorySaved:I,saveMemory:L,saveIsPending:n.isPending}),(0,g.jsx)(O,{composerDefaults:R,saveComposerDefault:(e,t)=>n.mutate({composerDefaults:{[e]:t===`inherit`?null:t===`on`}}),saveIsPending:n.isPending})]})}function C({maxParallel:e,onSelect:t,disabled:n}){return(0,g.jsxs)(m,{title:`Max parallel tasks`,hint:`Limit simultaneously running tasks.`,children:[(0,g.jsx)(`select`,{"aria-label":`Max parallel tasks`,"data-slot":`resources-max-parallel`,value:e,disabled:n,onChange:e=>t(Number(e.target.value)),className:`block w-28 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:Array.from({length:16},(e,t)=>t+_).map(e=>(0,g.jsx)(`option`,{value:e,children:e},e))}),(0,g.jsxs)(`p`,{className:`text-[11px] text-soft-foreground`,children:[`Need a different limit for one project?`,` `,(0,g.jsx)(c,{to:`/settings/global/projects`,"data-slot":`resources-project-limits-link`,className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground`,children:`Configure per-project limits`}),`.`]})]})}function w({maxParallel:e,maxMonitoringSessions:t,onSelect:n,disabled:r}){return(0,g.jsxs)(m,{title:`Extra monitoring sessions`,hint:`Additional capacity reserved for monitoring.`,children:[(0,g.jsx)(`select`,{"aria-label":`Extra monitoring sessions`,"data-slot":`resources-max-monitoring`,value:t??2,disabled:r,onChange:e=>n(Number(e.target.value)),className:`block w-28 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:Array.from({length:17},(e,t)=>(0,g.jsx)(`option`,{value:t,children:t},t))}),(0,g.jsxs)(`p`,{className:`text-[11px] text-soft-foreground`,children:[`Capacity: `,e,` active + `,t??2,` monitoring. Set 0 to make monitoring share active slots.`]})]})}function T({wakeMode:e,setWakeMode:t,wakeInterval:n,setWakeInterval:r,showInvalid:i,wakeSaved:a,saveWake:o,saveIsPending:s}){return(0,g.jsxs)(m,{title:`Monitoring wake-up`,hint:`Wake monitoring sessions periodically.`,children:[(0,g.jsxs)(`div`,{className:`settings-resource-controls flex flex-wrap items-center gap-2`,children:[(0,g.jsx)(f,{"aria-label":`Monitoring wake-up`,"data-slot":`resources-monitoring-wake-mode`,checked:e===`interval`,disabled:s,onCheckedChange:e=>t(e?`interval`:`park`)}),e===`interval`?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`label`,{htmlFor:`monitoring-wake-interval`,className:`w-full text-sm`,children:`Wake interval`}),(0,g.jsx)(`input`,{id:`monitoring-wake-interval`,type:`number`,min:v,max:y,"aria-label":`Wake interval in minutes`,"data-slot":`resources-monitoring-wake-interval`,value:n,disabled:s,onChange:e=>r(e.target.value),className:`block w-24 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,g.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`minutes`})]}):null,(0,g.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,"data-action":`resources-save-monitoring-wake`,disabled:a||i||s,onClick:o,children:`Save`})]}),i?(0,g.jsx)(`p`,{"data-slot":`resources-monitoring-wake-invalid`,className:`text-[11px] text-danger`,children:`Enter a whole number from 1 to 60 minutes.`}):(0,g.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Applied consistently to Claude, Codex and OpenCode.`})]})}function E({memory:e,setMemory:t,memoryInvalid:n,memorySaved:r,saveMemory:i,saveIsPending:a}){return(0,g.jsxs)(m,{title:`Per-task memory limit`,hint:`Leave blank for no limit.`,children:[(0,g.jsxs)(`div`,{className:`settings-resource-controls flex flex-wrap items-center gap-2`,children:[(0,g.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:b,step:256,"aria-label":`Per-task memory limit in MiB`,"data-slot":`resources-memory-limit`,value:e,disabled:a,placeholder:`no limit`,onChange:e=>t(e.target.value),className:`block w-32 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,g.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`MiB`}),(0,g.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,"data-action":`resources-save-memory`,disabled:r||n||a,onClick:i,children:`Save`})]}),n?(0,g.jsxs)(`p`,{"data-slot":`resources-memory-invalid`,className:`text-[11px] text-danger`,children:[`Enter a whole number of at least `,b,` MiB, or leave empty for no limit.`]}):(0,g.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Applies to newly started tasks.`})]})}function D(e){return e===null?`inherit`:e?`on`:`off`}function O({composerDefaults:e,saveComposerDefault:t,saveIsPending:n}){return(0,g.jsxs)(m,{title:`New task defaults`,hint:`Apply to new tasks unless overridden.`,children:[(0,g.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,"data-slot":`resources-composer-defaults`,children:[(0,g.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,g.jsx)(`span`,{className:`font-medium`,children:`Autonomous by default`}),(0,g.jsxs)(`select`,{"aria-label":`Autonomous by default`,value:D(e.autonomous),disabled:n,onChange:e=>t(`autonomous`,e.target.value),className:`rounded-md border border-input bg-card px-3 py-1.5 shadow-xs outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[(0,g.jsx)(`option`,{value:`inherit`,children:`Inherit environment`}),(0,g.jsx)(`option`,{value:`on`,children:`On`}),(0,g.jsx)(`option`,{value:`off`,children:`Off`})]}),(0,g.jsxs)(`span`,{className:`text-[11px] text-soft-foreground`,children:[`Inherited: `,e.inheritedAutonomous===`source-dependent`?`Source-dependent — skills on, workflows off`:e.inheritedAutonomous?`On`:`Off`]})]}),(0,g.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,g.jsx)(`span`,{className:`font-medium`,children:`Use a worktree by default`}),(0,g.jsxs)(`select`,{"aria-label":`Use a worktree by default`,value:D(e.worktree),disabled:n,onChange:e=>t(`worktree`,e.target.value),className:`rounded-md border border-input bg-card px-3 py-1.5 shadow-xs outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[(0,g.jsx)(`option`,{value:`inherit`,children:`Inherit environment`}),(0,g.jsx)(`option`,{value:`on`,children:`On`}),(0,g.jsx)(`option`,{value:`off`,children:`Off`})]}),(0,g.jsxs)(`span`,{className:`text-[11px] text-soft-foreground`,children:[`Inherited: `,e.inheritedWorktree?`On`:`Off`]})]})]}),(0,g.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Interactive skills may recommend both off. Multi-step and parallel runs remain isolated.`})]})}export{x as ResourcesSection};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{n as r,t as i}from"./utils-DSMR_WLb.js";import{An as a,Gn as o,Mt as s,On as c,Tn as l,Wn as u,X as d,at as f,ci as p,jt as m,kn as h,mr as g,pr as _,qn as v,rr as y,tr as ee}from"./project-scope-context-d3J3hWPR.js";import{$ as b,B as te,F as x,H as S,K as ne,Lt as re,Q as ie,U as C,V as w,Xt as T,_t as E,at as ae,et as D,f as O,ht as oe,in as k,nn as se,rn as ce,vt as le,yt as ue,z as de}from"./queries-dnpdX9VT.js";import{d as fe,h as pe}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{a as me,d as he,f as ge,g as _e,m as ve,o as ye,p as be,s as xe}from"./tasks-table-CzLkD-kr.js";import{n as A}from"./toaster-Bo5vCbz-.js";import{A as Se,F as Ce,a as we,at as Te,f as Ee,ft as De,g as Oe,h as ke,i as Ae,l as je,m as Me,p as Ne,q as Pe,t as Fe,v as j,x as Ie}from"./design-icons-CzEoMH9c.js";import{t as M}from"./createLucideIcon-BHp8sXmF.js";import{t as Le}from"./app-window-CSHwDX9N.js";import{n as Re,r as ze,t as Be}from"./open-in-menu-BeAj_aq3.js";import{t as Ve}from"./info-DA1x_4bz.js";import{a as He,t as Ue}from"./format-BNCkW110.js";import{t as We}from"./message-square-B-MD-8rD.js";import{i as Ge,n as Ke,t as N}from"./reference-chip-DHWnJcWz.js";import{t as qe}from"./square-terminal-B6RYYieR.js";import{t as P}from"./button-BQ2y4XRB.js";import{a as F,i as I,l as L,n as R,p as z,r as B,t as V}from"./dropdown-menu-4e2iKSMT.js";import{i as Je,r as Ye,t as Xe}from"./popover-BPgUYFyu.js";import{a as Ze,i as Qe,o as $e,r as et,s as tt,t as nt}from"./dialog-BVF6dIeS.js";import{c as rt,s as it,t as H}from"./project-router-C6zhlnwO.js";import"./attention-VcsXbAZz.js";import{T as at,f as U,u as ot,x as st}from"./task-groups-BF7_ZZTh.js";import{t as W}from"./status-dot-DtAOFiIi.js";import{$t as ct,An as lt,B as ut,Gt as dt,Ht as ft,Jt as pt,Kn as mt,Kt as ht,Mn as gt,R as _t,Ut as vt,Vt as yt,Wt as bt,Zn as xt,a as St,bn as Ct,cn as wt,en as Tt,fn as G,in as Et,jn as Dt,m as Ot,o as kt,pn as K,qn as At,qt as jt,r as Mt,rn as Nt,rr as Pt,tn as Ft,z as It}from"./index-DgdiXHgV.js";import{r as Lt,t as Rt}from"./markdown-Dj9PnU5f.js";import{i as zt}from"./automation-format-CUP262Tk.js";import{t as Bt}from"./textarea-vJt9undk.js";import{t as q}from"./tab-link-Cq8g7cFx.js";var Vt=M(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),Ht=M(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),Ut=M(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),J=e(t(),1),Y=n();function Wt(e){let t=ae();return k({mutationFn:t=>d(ce(e),t),onSuccess:()=>t.invalidateAfter(`runs`,()=>se()),onError:e=>A(e.message,{tone:`danger`})})}function Gt(e){return e.archived?`Unarchive`:`Archive task`}function Kt({run:e,open:t,onOpenChange:n,onConfirm:r}){return(0,Y.jsx)(yt,{open:t,onOpenChange:n,children:(0,Y.jsxs)(bt,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,Y.jsxs)(jt,{children:[(0,Y.jsx)(pt,{children:`Archive task?`}),(0,Y.jsxs)(dt,{children:[`Move “`,(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,title:U(e),children:U(e)}),`” out of Active tasks. You can restore it from Archived.`]})]}),(0,Y.jsxs)(ht,{children:[(0,Y.jsx)(vt,{children:`Cancel`}),(0,Y.jsx)(ft,{className:`bg-accent-strong text-accent-strong-foreground hover:brightness-[0.96]`,onClick:r,children:`Archive task`})]})]})})}function X({run:e,className:t,compactOnMobile:n=!1}){let[r,a]=(0,J.useState)(!1),o=Wt(e.id),s=Gt(e);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(P,{type:`button`,variant:`outline`,"data-slot":`archive-action`,"aria-label":s,title:e.archived?`Put this task back in Active tasks`:`Move this task out of Active tasks`,disabled:o.isPending,className:i(`h-11 gap-[7px] px-3`,n&&`max-md:size-11 max-md:px-0`,t),onClick:()=>e.archived?o.mutate(!1):a(!0),children:[e.archived?(0,Y.jsx)(Pt,{"aria-hidden":`true`}):(0,Y.jsx)(Fe,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:i(n&&`max-md:sr-only`),children:s})]}),(0,Y.jsx)(Kt,{run:e,open:r,onOpenChange:a,onConfirm:()=>{o.mutate(!0),a(!1)}})]})}function qt({run:e,action:t,prUrl:n,patch:i}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`text-sm [overflow-wrap:anywhere]`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:t.phase===`blocked`?`Completion blocked`:`Completion pending`}),` · `,t.message||(t.phase===`blocked`?`Completion needs attention.`:`Checking completion actions.`)]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n&&r(n)?(0,Y.jsx)(P,{variant:`outline`,asChild:!0,children:(0,Y.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,children:`Open PR`})}):null,e.autoMergePr?(0,Y.jsx)(P,{variant:`outline`,disabled:i.isPending,onClick:()=>i.mutate({autoMergePr:!1},{onError:e=>A(e.message,{tone:`danger`})}),children:i.isPending?`Saving…`:`Disable auto-merge`}):null]})]})}function Jt({run:e,blocker:t,flags:n}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`text-sm [overflow-wrap:anywhere]`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Archive blocked`}),` · `,t.message]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.runId?(0,Y.jsx)(P,{variant:`outline`,asChild:!0,children:(0,Y.jsx)(H,{to:`/tasks/${t.runId}`,children:`Open blocking task`})}):null,t.pullRequestUrl&&r(t.pullRequestUrl)?(0,Y.jsx)(P,{variant:`outline`,asChild:!0,children:(0,Y.jsx)(`a`,{href:t.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,children:`Open blocking PR`})}):null,n.archive?(0,Y.jsx)(X,{run:e}):null]})]})}function Yt({run:e}){let t=S(e.id),n=K(e),r=e.status===`done`?e.completionAction:void 0,i=n.archive?e.archiveBlocker:void 0,a=r&&r.phase!==`complete`?r:void 0;if(!a&&!i)return null;let o=e.pullRequestUrl??e.pullRequests?.find(e=>e.url)?.url;return(0,Y.jsxs)(`section`,{"data-slot":`completion-status`,"aria-label":`Completion action`,className:`grid min-w-0 gap-2 rounded-lg border border-border bg-card p-3 [margin-block:0.75rem]`,children:[a?(0,Y.jsx)(qt,{run:e,action:a,prUrl:o,patch:t}):null,i?(0,Y.jsx)(Jt,{run:e,blocker:i,flags:n}):null]})}var Xt=[`running`,`queued`,`waiting`];function Zt(e,{queuePosition:t,now:n=new Date}){let r=l(e),i=r.label.charAt(0).toUpperCase()+r.label.slice(1),a=t===void 0?i:`${i} #${t}`,o=Xt.includes(e.status)?$t(e,n):void 0;return o?{attention:r,label:a,nextCheck:o}:{attention:r,label:a}}function Qt(e){return e.nextCheck?`${e.label} · Next check ${e.nextCheck.text}`:e.label}function $t(e,t){let n;for(let t of Array.isArray(e.waits)?e.waits:[]){if(t?.kind!==`timer`||t.phase!==`open`)continue;let e=new Date(t.deadline);Number.isFinite(e.getTime())&&(!n||e<n)&&(n=e)}if(n)return{at:n.toISOString(),text:Ue(n,t)}}async function Z(e,t){try{await navigator.clipboard.writeText(e),A(t)}catch{A(`Run manually: ${e}`)}}function en(e){let t=E(),n=O(),r=(0,J.useMemo)(()=>_e(e,t),[e,t]);return{referenceProjectId:n,repoBase:t,references:r,requests:(0,J.useMemo)(()=>n===void 0?[]:r.filter(e=>me(e,t)).map(e=>({projectId:n,kind:e.kind,number:e.number})),[r,n,t])}}function tn(e){return k({mutationFn:()=>s(e.id),onError:e=>{if(e instanceof a&&e.command){Z(e.command,`No terminal found — command copied to clipboard.`);return}A(e.message,{tone:`danger`})}})}function Q(e,t){let n=w(),r=ue(),i=T(),a=k({mutationFn:t=>m(e.id,t),onError:e=>A(e.message,{tone:`danger`})}),o=Ct(),s=at(e),c=o.runnersOn(e=>t&&s.sessionId!==void 0&&e===s.backend?s.profileId??`default`:o.repoAccount?.[e]).runners,l=e=>!r.isSuccess||!i.isSuccess||c.includes(e??`claude`);return{canResumeHere:t&&l(wt(e)),choices:e.worktreePath?(n.data?.targets??[]).filter(e=>{let t=Re(e.id);return t===void 0||i.isSuccess&&l(t)}).map(t=>({target:t,...Et(e,t.id)?{suffix:` (resume)`,title:`Resume this run's session`}:{}})):[],open:a}}function nn({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:a}=Q(e,t),o=T().data,s=G(e);return!r&&i.length===0&&!s?null:(0,Y.jsxs)(Y.Fragment,{children:[r||i.length>0?(0,Y.jsxs)(`div`,{className:`task-open-targets flex flex-wrap gap-3`,children:[r?(0,Y.jsxs)(P,{variant:`outline`,"data-target":`terminal-resume`,onClick:n,children:[(0,Y.jsx)(qe,{}),`Terminal (resume session)`]}):null,i.map(({target:e,suffix:t,title:n})=>{let r=ze(e,o);return(0,Y.jsxs)(P,{variant:`outline`,"data-target":e.id,title:n,disabled:a.isPending,onClick:()=>a.mutate(e.id),children:[(0,Y.jsx)(r,{"aria-hidden":`true`}),e.label,t??``]},e.id)}),e.worktreePath?(0,Y.jsxs)(P,{variant:`outline`,onClick:()=>{let t=e.worktreePath;t&&navigator.clipboard.writeText(t).then(()=>A(`Worktree path copied`)).catch(()=>A(`Path: ${t}`))},children:[(0,Y.jsx)(j,{}),`Copy worktree path`]}):null]}):null,s?(0,Y.jsxs)(`div`,{"data-slot":`resume-command`,className:`mt-5 border-t border-border pt-5`,children:[(0,Y.jsx)(`h3`,{className:`text-base font-medium`,children:`Resume in a terminal`}),(0,Y.jsx)(`pre`,{className:`my-4 whitespace-pre-wrap break-all rounded-lg border border-border bg-background p-4 text-xs`,children:s}),(0,Y.jsxs)(P,{variant:`outline`,onClick:()=>void Z(s,`Command copied to clipboard.`),children:[(0,Y.jsx)(j,{}),`Copy resume command`]})]}):null]})}function rn({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:a}=Q(e,t),o=G(e),s=e.worktreePath;if(!r&&i.length===0&&!o&&!s)return null;let c=`max-md:min-h-11`;return(0,Y.jsxs)(`div`,{"data-slot":`workspace-tools`,className:`flex min-w-0 flex-wrap gap-2`,children:[r||i.length>0?(0,Y.jsx)(Be,{choices:i,onPick:e=>a.mutate(e),disabled:a.isPending,triggerVariant:`outline`,className:c,leading:r?(0,Y.jsxs)(I,{"data-target":`terminal-resume`,onSelect:n,children:[(0,Y.jsx)(qe,{"aria-hidden":`true`}),`Terminal (resume session)`]}):void 0}):null,s?(0,Y.jsxs)(P,{variant:`outline`,size:`sm`,className:c,onClick:()=>void Z(s,`Worktree path copied`),children:[(0,Y.jsx)(j,{"aria-hidden":`true`}),`Copy worktree path`]}):null,o?(0,Y.jsxs)(P,{variant:`outline`,size:`sm`,"data-slot":`resume-command`,title:o,className:c,onClick:()=>void Z(o,`Command copied to clipboard.`),children:[(0,Y.jsx)(j,{"aria-hidden":`true`}),`Copy resume command`]}):null]})}function an({run:e,canResume:t,onResume:n,onOpen:r,onClose:i}){let{canResumeHere:a,choices:o}=Q(e,t);return!a&&o.length===0?null:r?(0,Y.jsx)(I,{onSelect:r,children:`Open in…`}):(0,Y.jsxs)(`section`,{"aria-label":`Open task worktree in…`,className:`task-action-panel my-5 rounded-xl border border-border bg-card p-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsx)(`h2`,{className:`text-lg font-medium`,children:`Open task worktree in…`}),(0,Y.jsx)(P,{variant:`ghost`,size:`icon`,"aria-label":`Close worktree chooser`,onClick:i,children:(0,Y.jsx)(De,{})})]}),e.worktreePath?(0,Y.jsx)(`p`,{className:`my-4 break-all text-xs text-muted-foreground`,children:e.worktreePath}):null,(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(nn,{run:e,canResume:t,onResume:n})})]})}function on({branch:e}){let[t,n]=(0,J.useState)(null),r=(0,J.useRef)(null);(0,J.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);let i=t===e,a=async()=>{r.current!==null&&clearTimeout(r.current),n(null);try{if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(e),n(e),r.current=setTimeout(()=>n(null),2e3)}catch{A(`Could not copy branch. Select and copy: ${e}`)}};return(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,children:[(0,Y.jsx)(`span`,{"data-slot":`branch-chip`,className:`min-w-0 rounded-sm border border-border bg-card px-1.5 py-px font-mono text-[11px] font-medium break-all`,children:e}),(0,Y.jsxs)(`button`,{type:`button`,"aria-label":i?`Copied branch name`:`Copy branch name`,onClick:()=>void a(),className:`inline-flex min-h-11 shrink-0 items-center gap-1 rounded-sm px-2 text-xs font-medium text-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground md:min-h-8`,children:[(0,Y.jsx)(j,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{"aria-live":`polite`,children:i?`Copied`:`Copy`})]})]})}function sn({run:e}){let t=E(),n=O(),i=r=>n===void 0?void 0:ge(n,e.id,r,t),a=(0,J.useMemo)(()=>_e(e,t),[e,t]),o=[],s=[],c=a.filter(e=>e.kind===`PR`);for(let t of c)o.push((0,Y.jsx)(N,{reference:t,to:i(t),taskTitle:U(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`,conflictAction:(0,Y.jsx)(Ft,{run:e,prNumber:t.number})},xe(t)));let l=ve(e);l&&r(l)&&!c.some(e=>e.url===l)&&o.push((0,Y.jsx)(N,{reference:{kind:`PR`,url:l},taskTitle:U(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`pr`));let u=a.filter(e=>e.kind===`Issue`);for(let t of u)s.push((0,Y.jsx)(N,{reference:t,to:i(t),taskTitle:U(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},xe(t)));let d=he(e,t);if(d&&r(d)&&!u.some(e=>e.url===d)){let t=ye(d);s.push((0,Y.jsx)(N,{reference:{kind:`Issue`,...t?{number:Number(t)}:{},url:d},to:t?i({kind:`Issue`,number:Number(t),url:d}):void 0,taskTitle:U(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`issue`))}return o.length===0&&s.length===0?null:(0,Y.jsx)(`div`,{"data-slot":`linked-references`,className:`flex min-w-0 flex-col gap-3`,children:[[`PR`,`PRs`,o],[`Issue`,`Issues`,s]].map(([e,t,n])=>n.length>0?(0,Y.jsxs)(`div`,{"data-reference-kind":e,className:`grid min-w-0 grid-cols-[5rem_minmax(0,1fr)] items-center gap-x-2 gap-y-1`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:n})]},e):null)})}function cn(){let e=it(),t=le();return _t(t.data?.projects?.find(n=>n.id===(e??t.data?.bootProject)))}var ln=e=>e.map(e=>`${e.name}: ${It(e.url)}`).join(`
|
|
2
|
-
`);function un(e){return cn().length>0||e.notify===!0}function dn({run:e}){let t=cn(),n=t.length>0,r=te(e.id),[i,a]=(0,J.useState)(null),o=e.notify===!0;return!n&&!o?null:(0,Y.jsxs)(Y.Fragment,{children:[o?(0,Y.jsxs)(V,{children:[(0,Y.jsx)(z,{asChild:!0,children:(0,Y.jsxs)(P,{variant:`outline`,size:`sm`,"data-slot":`notifying-chip`,className:`h-11 gap-1.5 md:h-[30px]`,"aria-label":n?`Notifying ${ut(t)} — webhook actions`:`Notifying — webhook actions`,title:n?ln(t):void 0,children:[(0,Y.jsx)(W,{tone:`success`}),(0,Y.jsx)(`span`,{children:`Notifying`}),(0,Y.jsx)(je,{"aria-hidden":`true`,className:`size-3.5`})]})}),(0,Y.jsxs)(B,{align:`end`,"data-slot":`notifying-menu`,className:`w-[240px] max-w-[calc(100vw-2rem)] p-2`,children:[n?(0,Y.jsx)(F,{"data-slot":`notifying-targets`,className:`flex flex-col gap-0.5 px-2 py-1.5 text-[11px] font-normal text-muted-foreground`,children:t.map(e=>(0,Y.jsx)(`span`,{"data-webhook-target":e.id,className:`truncate`,title:It(e.url),children:e.name},e.id))}):null,n?(0,Y.jsxs)(I,{className:`min-h-11`,onSelect:()=>a(`note`),children:[(0,Y.jsx)(We,{"aria-hidden":`true`}),` Send a note…`]}):null,(0,Y.jsxs)(I,{variant:`destructive`,className:`min-h-11`,disabled:r.isPending,onSelect:()=>r.mutate({notify:!1},{onSuccess:()=>A(`Stopped notifying the webhook`),onError:e=>A(`Could not stop notifying. ${e.message}`,{tone:`danger`})}),children:[(0,Y.jsx)(Vt,{"aria-hidden":`true`}),` Stop notifying`]})]})]}):(0,Y.jsxs)(P,{variant:`outline`,size:`sm`,"data-action":`handoff`,className:`size-11 px-0 md:h-[30px] md:w-auto md:px-2.5`,"aria-label":`Hand off to webhook`,onClick:()=>a(`handoff`),children:[(0,Y.jsx)(mt,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`max-md:sr-only`,children:`Hand off`})]}),n?(0,Y.jsx)(fn,{mode:i,targets:t,pending:r.isPending,onOpenChange:e=>!e&&a(null),onSubmit:e=>r.mutate({notify:!0,...e?{message:e}:{}},{onSuccess:()=>{a(null),A(i===`note`?`Note sent to the webhook`:`Handed off to the webhook`)},onError:e=>A(`Could not hand off. ${e.message}`,{tone:`danger`})})}):null]})}function fn({mode:e,targets:t,pending:n,onOpenChange:r,onSubmit:i}){let a=(0,J.useId)(),o=(0,J.useId)(),[s,c]=(0,J.useState)(``);(0,J.useEffect)(()=>{e!==null&&c(``)},[e]);let l=e===`note`,u=ut(t);return(0,Y.jsx)(nt,{open:e!==null,onOpenChange:e=>{e||c(``),r(e)},children:(0,Y.jsx)(et,{"data-slot":`handoff-dialog`,className:`max-sm:top-auto max-sm:bottom-0 max-sm:left-0 max-sm:max-w-none max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-xl max-sm:border-x-0 max-sm:border-b-0 max-sm:pb-[max(1.5rem,env(safe-area-inset-bottom))] max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100`,children:(0,Y.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),i(s.trim())},children:[(0,Y.jsxs)($e,{className:`text-left`,children:[(0,Y.jsx)(tt,{children:l?`Send a note to ${t.length===1?`the webhook`:`the webhooks`}`:`Hand off to webhook`}),(0,Y.jsx)(Qe,{children:(0,Y.jsx)(`span`,{"data-webhook-destination":``,title:ln(t),children:l?`${u} ${t.length===1?`gets`:`get`} this note with the task's current status.`:`${u} will start receiving this task's status updates. Add a note (optional).`})})]}),(0,Y.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Y.jsx)(`label`,{htmlFor:a,className:`text-[13px] font-medium`,children:`Note`}),(0,Y.jsx)(Bt,{id:a,"data-slot":`handoff-note`,"aria-describedby":o,rows:4,maxLength:1e5,className:`min-h-24`,placeholder:`e.g. Take over from here, ping me when the PR is green`,value:s,onChange:e=>c(e.target.value)}),(0,Y.jsxs)(`p`,{id:o,className:`flex items-center gap-1.5 text-[12px] text-muted-foreground`,children:[(0,Y.jsx)(Ve,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`The note goes to the webhook only, not to the agent.`]})]}),(0,Y.jsxs)(Ze,{className:`gap-2 max-sm:flex-col-reverse max-sm:[&>button]:h-11 max-sm:[&>button]:w-full`,children:[(0,Y.jsx)(P,{type:`button`,variant:`ghost`,className:`sm:h-9`,onClick:()=>r(!1),children:`Cancel`}),(0,Y.jsxs)(P,{type:`submit`,variant:`contrast`,className:`sm:h-9`,"data-action":`handoff-submit`,disabled:n||l&&s.trim()===``,children:[(0,Y.jsx)(mt,{"aria-hidden":`true`}),l?`Send note`:`Hand off`]})]})]})})})}function pn({runId:e,children:t}){let n=fe(),r=(0,J.useMemo)(()=>({runId:e}),[e]);return n?(0,Y.jsx)(mn,{runId:e,children:t}):(0,Y.jsx)(Lt.Provider,{value:r,children:t})}function mn({runId:e,children:t}){let{projectId:n}=pe(),r=(0,J.useMemo)(()=>({runId:e,...n?{projectId:n}:{}}),[e,n]);return(0,Y.jsx)(Lt.Provider,{value:r,children:t})}function hn(e,t,n,r){return n?r===`step`?`Step ${e} of ${t}`:`${e} of ${t} complete`:`${e} / ${t}`}function gn(e){return typeof e==`object`&&!!e&&!(0,J.isValidElement)(e)&&`keep`in e}function _n({slot:e,icon:t,title:n,meta:r,summary:a,aside:o,open:s,onToggle:c,className:l,children:u}){let d=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center text-accent-text`,children:t}),(0,Y.jsx)(`span`,{className:i(`truncate text-[14px] font-semibold text-foreground`,typeof n==`string`?`shrink-0`:`min-w-0 shrink`),children:n}),a??(gn(r)?(0,Y.jsxs)(`span`,{"data-slot":`run-activity-meta`,className:`contents text-[13px] text-muted-foreground tabular-nums`,children:[r.drop===void 0?null:(0,Y.jsxs)(`span`,{className:`flex h-[1lh] min-w-0 shrink-[2] flex-wrap overflow-hidden`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`h-[1lh] w-0`}),(0,Y.jsxs)(`span`,{"data-slot":`run-activity-meta-drop`,className:`whitespace-nowrap`,children:[r.drop,(0,Y.jsx)(`span`,{className:`text-soft-foreground`,children:` ·`})]})]}),` `,(0,Y.jsx)(`span`,{"data-slot":`run-activity-meta-keep`,className:`shrink-0 whitespace-nowrap`,children:r.keep})]}):r===void 0?null:(0,Y.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`min-w-0 shrink-[2] truncate text-[13px] text-muted-foreground tabular-nums`,children:r}))]}),f=c!==void 0;return(0,Y.jsxs)(`div`,{"data-slot":`run-activity-${e}`,"data-state":f&&s?`open`:`collapsed`,className:i(`min-w-0 border-t border-border first:border-t-0`,l),children:[f?(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:c,className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2 text-start hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,children:[d,o,(0,Y.jsx)(je,{"aria-hidden":!0,className:i(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,!o&&`ms-auto`,s&&`rotate-180`)})]}):(0,Y.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2`,children:[d,o]}),f&&s?(0,Y.jsx)(`div`,{"data-slot":`run-activity-body`,className:`min-w-0 border-t border-border/60 bg-muted/30 px-3.5 py-2.5`,children:u}):null]})}function $(e){return _(e.delegation)}function vn(e,t){let n=e?.role===`root`?e.receipts.map(e=>e.workerId).reverse():[];return[...new Set([...n,...(t?.workers??[]).map(e=>e.workerId)])]}function yn(e){let t=e.delegation,n=$(e),r=b(e.id,{enabled:n});if(!n||!t)return`complete`;if(!r.isSuccess)return r.isError||r.fetchStatus===`paused`?`unknown`:`pending`;let i=new Map(r.data.workers.map(e=>[e.workerId,e])),a=vn(t,r.data).map(e=>{let t=i.get(e)?.status;return t===`done`||t===`cancelled`?`complete`:t===void 0||t===`failed`?`issue`:`pending`});return a.includes(`pending`)?`pending`:a.includes(`issue`)?`issue`:`complete`}function bn(e){let t=b(e.id,{enabled:e.delegation?.role===`root`});return t.isSuccess&&t.data.workers.some(e=>st(e.status))}function xn({run:e,open:t,onToggle:n}){let r=b(e.id),a=D(),s=Tt(),c=e.delegation,l=new Map(r.data?.workers.map(e=>[e.workerId,e])),d=vn(c,r.data),f=u(e)??o(e),p=f?Sn(e,f):void 0,m=e=>a.data?.find(t=>t.id===e)??r.data?.titles?.find(t=>t.id===e),h=e=>{let t=m(e);return t?U(t):`worker ${e.slice(0,8)}`};return(0,Y.jsx)(_n,{slot:`workers`,icon:(0,Y.jsx)(Se,{className:`size-4`}),title:`Workers`,meta:Cn({ids:d,workers:l,desktop:s,query:r}),aside:r.data?.capacity?(0,Y.jsx)(An,{capacity:r.data.capacity}):void 0,open:t,onToggle:n,children:(0,Y.jsxs)(`div`,{"aria-label":`Task relationships`,className:`min-w-0 text-[13px] text-muted-foreground`,role:`group`,children:[r.data?.capacity&&r.data.capacity.outstanding>=r.data.capacity.limit?(0,Y.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`All worker slots are in use. Clean up finished workers to free a slot.`}):null,f?(0,Y.jsx)(Dn,{wait:f,dependencyLabel:p}):null,d.length>0?(0,Y.jsx)(`ul`,{className:`grid max-h-64 min-w-0 gap-0.5 overflow-y-auto`,children:d.map(t=>{let n=l.get(t),a=m(t),o=n?Tn(n.status):r.isSuccess?`Record unavailable or deleted`:`Status unavailable`;return(0,Y.jsxs)(`li`,{"data-slot":`worker-item`,"data-status":n?.status,className:`min-w-0`,children:[(0,Y.jsxs)(H,{to:`/tasks/${t}`,"aria-label":`Worker task ${t}`,className:`group flex min-h-11 min-w-0 items-center gap-2.5 rounded-md px-1 text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Y.jsx)(wn,{status:n?.status}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate`,children:a?U(a):`Worker ${t.slice(0,8)}`}),n?.supervisorRunId&&n.supervisorRunId!==e.id?(0,Y.jsxs)(`span`,{"data-slot":`worker-supervisor`,className:`block truncate text-xs text-muted-foreground`,children:[`Started by `,h(n.supervisorRunId)]}):null]}),(0,Y.jsx)(`span`,{className:i(`max-w-[45%] shrink-0 truncate text-xs`,En(n?.status)),children:o}),(0,Y.jsx)(we,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`})]}),n?(0,Y.jsx)(Mn,{parentRunId:e.id,worker:n}):null,n?.destroy?(0,Y.jsx)(In,{state:n.destroy}):null]},t)})}):$(e)&&r.isSuccess?(0,Y.jsx)(`p`,{className:`px-1 py-1`,children:`No workers`}):null,r.fetchStatus===`paused`?(0,Y.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Offline — relationship details will refresh when connected.`}):r.isPending?(0,Y.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Loading relationships…`}):null,r.isError?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1`,children:[(0,Y.jsx)(`p`,{role:`status`,children:`Could not load relationships. Known task links are retained.`}),(0,Y.jsx)(P,{variant:`outline`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry relationships`})]}):null]})})}function Sn(e,t){let n=e.delegation;if(!(!n||n.role===`invalid`))return h(e)??c(n.role,t,`requestIds`in t&&v(n,t.requestIds))}function Cn({ids:e,workers:t,desktop:n,query:r}){if(e.length===0)return r.isError?`Unavailable`:r.isPending?`Linking…`:`No workers`;let i=`${e.length} linked`;if(!n)return i;let a=new Map;for(let n of e){let e=t.get(n)?.status;e!==void 0&&a.set(e,(a.get(e)??0)+1)}return[i,...[...a.entries()].map(([e,t])=>`${t} ${e}`)].join(` · `)}function wn({status:e}){let t=`size-[15px] shrink-0`;return e===`done`?(0,Y.jsx)(Ee,{"aria-hidden":!0,className:i(t,`text-success`)}):e===`failed`?(0,Y.jsx)(Oe,{"aria-hidden":!0,className:i(t,`text-danger`)}):e===`cancelled`?(0,Y.jsx)(ke,{"aria-hidden":!0,className:i(t,`text-soft-foreground`)}):e===`running`||e===`waiting`||e===`review`?(0,Y.jsx)(He,{role:`status`,"aria-label":`Worker running`,className:i(t,`animate-spin stroke-pending motion-reduce:animate-none`)}):(0,Y.jsx)(Me,{"aria-hidden":!0,className:i(t,`text-soft-foreground`)})}function Tn(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function En(e){return e===`done`?`text-success`:e===`failed`?`text-danger`:`text-muted-foreground`}function Dn({wait:e,dependencyLabel:t}){return(0,Y.jsxs)(`p`,{className:`px-2 break-words`,children:[e.phase===`parked`&&t?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:`requestIds`in e&&e.requestIds?e.phase===`parked`?`Waiting on request replies`:e.phase===`wake-pending`?`Conversation update queued for this task`:`Request wait registered — the agent is finishing its turn`:e.phase===`parked`?`Waiting on workers`:e.phase===`wake-pending`?`Worker update queued for the parent`:`Worker wait registered — the agent is finishing its turn`,`.`,`deadline`in e?(0,Y.jsxs)(Y.Fragment,{children:[` `,`Deadline: `,(0,Y.jsx)(`time`,{dateTime:e.deadline,children:e.deadline})]}):` No deadline: Squawk wakes this task when they have all settled.`]})}function On(e){return e.delegation?.role===`worker`&&o(e)?.phase===`wake-pending`}function kn({run:e}){let t=o(e);return e.delegation?.role===`worker`&&t?.phase===`wake-pending`?(0,Y.jsx)(Dn,{wait:t,dependencyLabel:c(`worker`,t)}):null}function An({capacity:e}){return(0,Y.jsxs)(`span`,{"data-slot":`worker-capacity`,role:`status`,"aria-label":`Worker capacity: ${e.outstanding} of ${e.limit} in use`,className:`ms-auto shrink-0 whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:[e.outstanding,` of `,e.limit,` in use`]})}var jn=new Set([`review`,`done`,`failed`,`cancelled`]);function Mn({parentRunId:e,worker:t}){let n=x(e),[r,i]=(0,J.useState)(!1);if(!jn.has(t.status)||t.destroy?.phase===`complete`&&t.destroy.remaining.length===0)return null;let o=t.workerId.slice(0,8),s=!!t.destroy&&t.destroy.phase!==`complete`,c=n.error instanceof a?n.error.work:void 0;return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-1`,children:[r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`break-words text-xs`,children:g(t.workspace)?`Removes this worker's worktree and branch. Its result is saved first.`:`Stops this worker and frees its slot. It runs in this task's worktree, so no worktree or branch is removed. Its result is saved first.`}),(0,Y.jsx)(P,{variant:`danger-ghost`,size:`sm`,className:`min-h-11`,"aria-label":`Confirm clean up of worker ${o}`,onClick:()=>{i(!1),n.mutate({workerId:t.workerId})},children:`Clean up`}),(0,Y.jsx)(P,{variant:`outline`,size:`sm`,className:`min-h-11`,onClick:()=>i(!1),children:`Cancel`})]}):(0,Y.jsx)(P,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":s?`Retry clean up of worker ${o}`:`Clean up worker ${o}`,disabled:n.isPending,onClick:()=>i(!0),children:n.isPending?`Cleaning up…`:s?`Retry clean up`:`Clean up`}),n.isError&&!r?(0,Y.jsx)(`span`,{role:`status`,className:`break-words text-xs`,children:c?`Cleanup stopped: this worker holds ${Pn(c)}. Land or commit what you need first, or discard it.`:`Cleanup did not finish: ${n.error.message}`}):null,c&&!r&&!n.isPending?(0,Y.jsx)(P,{variant:`danger-ghost`,size:`sm`,className:`min-h-11`,"aria-label":`Discard work and clean up worker ${o}`,onClick:()=>n.mutate({workerId:t.workerId,discardWork:!0}),children:`Discard work and clean up`}):null]})}var Nn=(e,t,n)=>`${e} ${e===1?t:n}`;function Pn(e){return[...e.uncommittedFiles?[Nn(e.uncommittedFiles,`uncommitted file`,`uncommitted files`)]:[],...e.commits?[`${Nn(e.commits,`commit`,`commits`)} no other branch reaches`]:[]].join(` and `)}function Fn(e){return e!==void 0&&(e.phase!==`complete`||e.remaining.length>0||e.error!==void 0)}function In({state:e}){if(!Fn(e))return null;let t=e.phase===`complete`?void 0:e.retry,n=t&&(0,Y.jsx)(Ln,{at:t.nextAt});return(0,Y.jsxs)(`p`,{className:`px-2 pb-2 break-words`,children:[t?.needsAttention?`Cleanup needs attention`:e.phase===`incomplete`?`Cleanup incomplete`:e.phase===`complete`?`Cleanup complete`:`Cleanup ${e.phase}`,e.remaining.length?` — remaining: ${e.remaining.join(`, `)}`:``,e.error?` — ${t?e.error.replace(/\.$/,``):e.error}`:``,t?.needsAttention?(0,Y.jsxs)(Y.Fragment,{children:[`. Nothing changed after `,t.attempts,` automatic attempts; checking hourly, next check `,n,`. Retry clean up to try now.`]}):t?(0,Y.jsxs)(Y.Fragment,{children:[`. Retrying automatically, next attempt `,n,`.`]}):null]})}function Ln({at:e}){let t=ct(3e4);return(0,Y.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:zt(t,Date.parse(e))})}function Rn({id:e}){return(0,Y.jsxs)(H,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,"data-slot":`mobile-parent-task-link`,className:`inline-flex shrink-0 items-center justify-center gap-1 rounded-sm px-2 text-[13px] text-muted-foreground [min-block-size:2.75rem] [min-inline-size:2.75rem] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted active:text-foreground`,children:[(0,Y.jsx)(Ae,{"aria-hidden":!0,className:`shrink-0 [block-size:1.2cap] [inline-size:auto]`}),`Parent`]})}function zn({id:e}){let t=ne(e),n=t.data?U(t.data):e;return(0,Y.jsxs)(`div`,{"data-slot":`parent-task`,className:`flex min-w-0 flex-wrap items-center gap-x-2 text-[13px] text-muted-foreground`,children:[(0,Y.jsxs)(H,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,title:`Parent · ${n}`,"data-slot":`parent-task-link`,className:`flex min-h-11 min-w-0 max-w-full items-center gap-2 rounded-sm text-muted-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:text-foreground`,children:[(0,Y.jsx)(Ae,{"aria-hidden":!0,className:`h-[1.2cap] w-auto shrink-0`}),(0,Y.jsx)(`span`,{className:`shrink-0`,children:`Parent`}),(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Y.jsx)(`span`,{className:`min-w-0 overflow-clip text-ellipsis whitespace-nowrap`,children:n})]}),t.isError?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{children:`Parent record unavailable or deleted`}),(0,Y.jsx)(P,{variant:`outline`,className:`min-h-11`,onClick:()=>void t.refetch(),children:`Retry parent task`})]}):null]})}var Bn=3,Vn=(e,t)=>e.kind===t.kind&&e.number===t.number;function Hn(e,t,n=Bn){let r=t?e.findIndex(e=>Vn(e,t)):-1;if(e.length<=n||r<n)return{inline:e.slice(0,n),overflow:e.slice(n)};let i=[...e.slice(0,n-1),e[r]];return{inline:i,overflow:e.filter(e=>!i.includes(e))}}var Un=(e,t)=>`/tasks/${e}/${t.kind}/${t.number}`;function Wn({tab:e}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(e.kind===`pr`?Ce:Ne,{"aria-hidden":`true`,className:`mr-1 size-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:e.kind===`pr`?`Pull request`:`Issue`}),` #`,e.number,(0,Y.jsx)(Ke,{kind:e.kind===`pr`?`PR`:`Issue`,number:e.number,className:`ml-1`})]})}function Gn(e,t){let n=e[0],r=e.length+ +!!t;return n?`Preview :${n.port}${r>1?` +${r-1}`:``}`:t?`Preview · agent`:`Preview`}function Kn({servers:e}){let t=Ot();if(t===null)return null;let n=t.agentLive===!0,r=e[0],i=e.length+ +!!n===1?r?{port:r.port}:{agent:!0}:{};return(0,Y.jsxs)(P,{variant:`outline`,size:`sm`,"data-slot":`preview-toggle`,className:`max-md:h-11`,"aria-pressed":t.open,onClick:()=>t.openPane(i),children:[(0,Y.jsx)(Le,{"aria-hidden":`true`}),Gn(e,n),t.live?(0,Y.jsx)(W,{tone:`success`,"aria-label":`Preview is live`}):null]})}function qn(e){return e?.role===`worker`?`Worker session`:e?.role===`root`?`Parent session`:`Task session`}function Jn({run:e,compact:t=!1}){if(e.delegation?.role!==`worker`)return null;let n=e.delegation.supervisorRunId??e.delegation.parentRunId;return t?(0,Y.jsx)(Rn,{id:n}):(0,Y.jsx)(zn,{id:n})}function Yn(e,t,n,r){return!e.archiveBlocker&&t.archive&&(n!==`session`||!Nt(e,r))?(0,Y.jsx)(X,{run:e}):null}function Xn({run:e}){return e.archived&&e.autoArchive?.reason===`pull-requests-merged`&&e.autoArchive.archivedAt===e.archivedAt?(0,Y.jsx)(`p`,{"data-slot":`auto-archive-reason`,className:`text-[13px] text-muted-foreground`,children:`Archived automatically after all associated PRs merged.`}):null}function Zn({shown:e,run:t,archiveButton:n,previewToggle:r}){let i=un(t);return e&&(n||r||i)?(0,Y.jsxs)(`div`,{"data-slot":`run-mobile-actions`,className:`flex flex-wrap items-center gap-2 pt-2`,children:[n,r,(0,Y.jsx)(dn,{run:t})]}):null}function Qn({run:e,tab:t,activeItem:n,inlineItemTabs:r,overflowItemTabs:i,phoneBar:a,isDesktop:o}){let s=(0,J.useRef)(null),c=n?`${n.kind}#${n.number}`:null;return(0,J.useEffect)(()=>{!c||o||s.current?.querySelector(`[aria-current="page"]`)?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[c,r.map(e=>`${e.kind}#${e.number}`).join(`,`),o]),(0,Y.jsxs)(`div`,{ref:s,"data-slot":`run-tabs`,"data-phone-bar":a||void 0,className:`mt-3 flex flex-wrap items-end gap-1 border-b border-border md:mt-5 max-md:flex-nowrap max-md:overflow-x-auto max-md:border-b-0 max-md:shadow-[inset_0_-1px_0_var(--border)] max-md:gap-0 max-md:[&>*]:mb-0 max-md:[&>*]:shrink-0 max-md:[&>a]:min-h-11 max-md:[&>a]:px-3.5 max-md:[&>a]:text-[13.5px]`,children:[(0,Y.jsx)(q,{to:`/tasks/${e.id}`,active:t===`session`,replace:a,children:`Session`}),(0,Y.jsx)(q,{to:`/tasks/${e.id}/changes`,active:t===`changes`,replace:a,count:e.diffStat&&e.diffStat.files>0?e.diffStat.files:void 0,children:`Changes`}),(0,Y.jsx)(q,{to:`/tasks/${e.id}/commits`,active:t===`commits`,replace:a,children:`Commits`}),(0,Y.jsx)(q,{to:`/tasks/${e.id}/files`,active:t===`files`,replace:a,children:`Files`}),r.map(t=>(0,Y.jsx)(q,{to:Un(e.id,t),active:n!==null&&Vn(t,n),replace:a,children:(0,Y.jsx)(Wn,{tab:t})},`${t.kind}-${t.number}`)),i.length>0?(0,Y.jsxs)(V,{children:[(0,Y.jsxs)(z,{"data-slot":`run-tabs-more`,"aria-label":`${i.length} more linked items`,className:`-mb-px flex h-8 items-center rounded-t-md border-b-2 border-transparent px-3 text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground max-md:min-h-11 max-md:px-3.5 max-md:text-[13.5px]`,children:[`+`,i.length]}),(0,Y.jsx)(B,{align:`end`,children:i.map(t=>(0,Y.jsx)(I,{asChild:!0,children:(0,Y.jsx)(H,{to:Un(e.id,t),replace:a,children:(0,Y.jsx)(Wn,{tab:t})})},`${t.kind}-${t.number}`))})]}):null]})}function $n({run:e,tab:t=`session`,onMarkedUnread:n}){let r=l(e),a=K(e),o=bn(e),[s,c]=(0,J.useState)(!1),[u,d]=(0,J.useState)(!1),f=er(e,n),p=D(),m=oe(),h=Zt(e,{queuePosition:e.status===`queued`?ot(p.data??[]).get(e.id):void 0}),g=gt(),_=Dt(),v=g!==null&&!_?g:null,y=v!==null,{referenceProjectId:ee,repoBase:b,requests:te}=en(e),x=(0,J.useMemo)(()=>be(e,b),[e,b]),S=typeof t==`object`?t:null,{inline:ne,overflow:re}=Hn(x,S),ie=m.data?.capabilities?.preview===!0,C=e.worktreePath&&ie?(0,Y.jsx)(Kn,{servers:e.previewServers??[]}):null,w=(0,Y.jsx)(ir,{run:e,actions:f,onOpenChooser:()=>d(!0),onToggleNotes:()=>c(e=>!e)}),T=Yn(e,a,t,o);return(0,Y.jsx)(Ge,{projectId:ee,repoBase:b,requests:te,children:(0,Y.jsxs)(`header`,{"data-slot":`run-header`,className:i(`relative z-20 bg-background px-[18px] md:px-9 md:pt-7`,y?`pt-0`:`pt-[18px]`,t===`session`&&`md:sticky md:top-0`),children:[(0,Y.jsx)(Xn,{run:e}),(0,Y.jsx)(Yt,{run:e}),(0,Y.jsxs)(`div`,{className:`w-full`,children:[(0,Y.jsx)(Jn,{run:e}),v?(0,Y.jsxs)(lt,{slot:v,children:[(0,Y.jsx)(rr,{run:e}),(0,Y.jsx)(Jn,{run:e,compact:!0}),w]}):(0,Y.jsxs)(`div`,{"data-slot":`run-title-row`,className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 md:flex-nowrap`,children:[(0,Y.jsx)(`p`,{"data-slot":`session-kind`,className:`text-[12px] font-semibold tracking-[0.14em] text-muted-foreground uppercase md:hidden`,children:qn(e.delegation)}),(0,Y.jsx)(nr,{run:e}),(0,Y.jsx)(Mt,{dot:r.tone,shape:r.shape,pulse:r.pulse,className:`max-md:hidden`,children:Qt(h)}),(0,Y.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 md:gap-2.5`,children:[T,C,(0,Y.jsx)(dn,{run:e}),w]})]}),(0,Y.jsx)(Zn,{shown:v!==null,run:e,archiveButton:T,previewToggle:C}),(0,Y.jsx)(Qn,{run:e,tab:t,activeItem:S,inlineItemTabs:ne,overflowItemTabs:re,phoneBar:y,isDesktop:_}),s?(0,Y.jsx)(sr,{runId:e.id,onClose:()=>c(!1)}):null,u?(0,Y.jsx)(an,{run:e,canResume:K(e).terminal,onResume:()=>f.terminal.mutate(),onClose:()=>d(!1)}):null]}),(0,Y.jsx)(or,{run:e,actions:f})]})})}function er(e,t){let n=p(),r=rt(),[i,a]=(0,J.useState)(null),o=()=>n.invalidateQueries({queryKey:re.runs.all}),s=e=>A(e.message,{tone:`danger`}),c=C(),l={isPending:c.isPending,mutate:()=>c.mutate({id:e.id,pinned:!e.pinned})},u=de();return{pin:l,markUnread:{isPending:u.isPending,mutate:()=>{t?.(),u.mutate(e.id,{onError:s})}},delete:k({mutationFn:()=>f(e.id),onSuccess:()=>{o(),r(`/`)},onError:s}),terminal:tn(e),confirming:i,setConfirming:a}}function tr(e){let t=S(e.id),n=U(e);return{title:n,editor:kt(n,e=>t.mutate({title:e},{onError:e=>A(e.message,{tone:`danger`})}))}}function nr({run:e}){let{title:t,editor:n}=tr(e);return n.editing?(0,Y.jsx)(St,{editor:n,className:`flex-1 text-[16px] font-semibold`}):(0,Y.jsxs)(`span`,{className:`group flex min-w-0 items-center gap-1`,children:[(0,Y.jsx)(`h1`,{className:`line-clamp-2 min-w-0 break-words text-2xl font-semibold tracking-tight`,title:e.task,children:t}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,onClick:n.begin,className:`shrink-0 rounded-sm p-1 text-soft-foreground opacity-0 transition-opacity group-hover:opacity-100 hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Y.jsx)(At,{className:`size-3.5`,"aria-hidden":`true`})})]})}function rr({run:e}){let{title:t,editor:n}=tr(e);return(0,Y.jsxs)(Xe,{open:n.editing,onOpenChange:e=>{e?n.begin():n.commit()},children:[(0,Y.jsx)(`div`,{"data-slot":`mobile-run-title`,className:`flex min-w-0 flex-1 flex-col gap-px`,children:(0,Y.jsx)(`h1`,{className:`truncate text-[15px] leading-tight font-semibold text-foreground`,title:e.task,children:t})}),(0,Y.jsx)(Je,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,className:`flex size-11 shrink-0 items-center justify-center rounded-sm text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Y.jsx)(At,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(Ye,{align:`end`,className:`w-64 max-w-[calc(100vw-16px)] p-2`,onEscapeKeyDown:e=>{e.preventDefault(),n.cancel()},children:(0,Y.jsx)(St,{editor:n,className:`text-[16px] font-semibold`})})]})}function ir({run:e,actions:t,onToggleNotes:n,onOpenChooser:r}){let i=K(e),a=G(e),o=S(e.id),s=(0,J.useId)();return(0,Y.jsxs)(V,{children:[(0,Y.jsx)(z,{asChild:!0,children:(0,Y.jsx)(P,{variant:`ghost`,size:`icon-sm`,className:`size-11`,"aria-label":`Run actions`,children:(0,Y.jsx)(Ie,{"aria-hidden":`true`})})}),(0,Y.jsxs)(B,{align:`end`,"data-slot":`run-actions-menu`,className:`w-[270px] max-w-[calc(100vw-2rem)] p-3`,children:[(0,Y.jsx)(F,{className:`px-2 py-3 text-[12px] font-normal text-muted-foreground`,children:`TASK ACTIONS`}),(0,Y.jsxs)(I,{onSelect:n,children:[(0,Y.jsx)(xt,{"aria-hidden":`true`}),` Notes / handoff`]}),(0,Y.jsx)(an,{run:e,canResume:i.terminal,onResume:()=>t.terminal.mutate(),onOpen:r}),a?(0,Y.jsxs)(I,{onSelect:()=>void Z(a,`Command copied to clipboard.`),children:[(0,Y.jsx)(j,{"aria-hidden":`true`}),` Copy resume command`]}):null,i.markUnread?(0,Y.jsxs)(I,{disabled:t.markUnread.isPending,onSelect:()=>t.markUnread.mutate(),children:[(0,Y.jsx)(Ht,{"aria-hidden":`true`}),` Mark unread`]}):null,i.pin?(0,Y.jsxs)(R,{"data-slot":`pin-run`,className:`min-h-11`,checked:!!e.pinned,disabled:t.pin.isPending,onCheckedChange:()=>t.pin.mutate(),children:[e.pinned?(0,Y.jsx)(Ut,{"aria-hidden":`true`}):(0,Y.jsx)(Pe,{"aria-hidden":`true`}),e.pinned?`Unpin task`:`Pin task`]}):null,(0,Y.jsx)(L,{}),(0,Y.jsx)(F,{className:`text-xs text-muted-foreground`,children:`AFTER DONE`}),(0,Y.jsx)(R,{"data-slot":`archive-when-done`,className:`min-h-11`,checked:e.archiveWhenDone===!0,disabled:o.isPending,onCheckedChange:e=>o.mutate({archiveWhenDone:e},{onError:e=>A(e.message,{tone:`danger`})}),children:`Archive when Done`}),(0,Y.jsx)(R,{"data-slot":`auto-merge-pr`,className:`min-h-11`,checked:e.autoMergePr===!0,disabled:o.isPending,"aria-describedby":s,onCheckedChange:e=>o.mutate({autoMergePr:e},{onError:e=>A(e.message,{tone:`danger`})}),children:`Auto-merge PR`}),(0,Y.jsx)(`p`,{id:s,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block:0.5rem]`,children:`After Done, auto-merge can mark a draft PR ready. It waits for current-head CI and GitHub rules. Merge comes before archive.`}),e.delegation?.role===`worker`?null:(0,Y.jsx)(ar,{run:e,patch:o}),i.deleteRun?(0,Y.jsx)(L,{}):null,i.deleteRun?(0,Y.jsxs)(I,{variant:`destructive`,onSelect:()=>t.setConfirming(`delete`),children:[(0,Y.jsx)(Te,{"aria-hidden":`true`}),` Delete task…`]}):null]})]})}function ar({run:e,patch:t}){let n=(0,J.useId)(),r=(0,J.useId)(),i=(0,J.useId)(),a=e=>A(e.message,{tone:`danger`});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L,{}),(0,Y.jsx)(F,{className:`text-xs text-muted-foreground`,children:`TASK ACCESS`}),(0,Y.jsx)(R,{"data-slot":`allow-workers`,className:`min-h-11`,checked:y(e),disabled:t.isPending,"aria-describedby":`${n} ${i}`,onCheckedChange:e=>t.mutate({allowWorkers:e},{onError:a}),children:`Allow Squawk workers`}),(0,Y.jsx)(`p`,{id:n,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Agents in this task can start Squawk workers. Each worker is a separate paid agent session. Worker limits cap resources, not spending.`}),(0,Y.jsx)(R,{"data-slot":`allow-messaging`,className:`min-h-11`,checked:ee(e),disabled:t.isPending,"aria-describedby":`${r} ${i}`,onCheckedChange:e=>t.mutate({allowMessaging:e},{onError:a}),children:`Allow task messaging`}),(0,Y.jsx)(`p`,{id:r,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Agents in this task can message other tasks in this project.`}),(0,Y.jsx)(`p`,{id:i,"data-slot":`task-access-session-note`,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Turning one off applies at once. Turning one on reaches a running agent at its next session.`})]})}function or({run:e,actions:t}){let n=t.confirming;return(0,Y.jsx)(yt,{open:n!==null,onOpenChange:e=>!e&&t.setConfirming(null),children:(0,Y.jsxs)(bt,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,Y.jsxs)(jt,{children:[(0,Y.jsx)(pt,{className:`text-danger`,children:`Delete task permanently?`}),(0,Y.jsx)(dt,{children:(0,Y.jsxs)(Y.Fragment,{children:[`Delete “`,(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,title:U(e),children:U(e)}),`” and its transcript`,e.delegation?.role===`worker`&&!g(e.delegation.workspace)?``:`, worktree and branch`,`. This cannot be undone.`]})})]}),(0,Y.jsxs)(ht,{children:[(0,Y.jsx)(vt,{children:`Cancel`}),(0,Y.jsx)(ft,{className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{t.delete.mutate(),t.setConfirming(null)},children:`Delete task`})]})]})})}function sr({runId:e,onClose:t}){let n=ie(e);return(0,Y.jsxs)(`div`,{"data-slot":`notes-panel`,className:`my-5 rounded-xl border border-border bg-card p-6`,children:[(0,Y.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,Y.jsx)(`h2`,{className:`text-lg font-medium`,children:`Notes / handoff`}),(0,Y.jsx)(P,{variant:`ghost`,size:`icon`,"aria-label":`Close notes`,onClick:t,children:(0,Y.jsx)(De,{})})]}),n.isPending?(0,Y.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`Loading notes…`}):n.isError?(0,Y.jsx)(`p`,{className:`text-xs text-danger`,children:n.error.message}):n.data.trim().length>0?(0,Y.jsx)(pn,{runId:e,children:(0,Y.jsx)(Rt,{children:n.data})}):(0,Y.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`No notes yet — the handoff file is seeded when the task starts.`}),(0,Y.jsxs)(`div`,{className:`mt-4 flex gap-3`,children:[(0,Y.jsx)(P,{variant:`outline`,disabled:!n.data?.trim(),onClick:()=>void Z(n.data??``,`Notes copied`),children:`Copy notes`}),(0,Y.jsx)(P,{variant:`outline`,onClick:t,children:`Close`})]})]})}export{en as _,Fn as a,bn as c,hn as d,pn as f,tn as g,rn as h,kn as i,yn as l,sn as m,In as n,On as o,on as p,xn as r,$ as s,$n as t,_n as u,Zt as v,X as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Cn as r,Sn as i,_n as a,vn as o,yn as s}from"./project-scope-context-d3J3hWPR.js";import{Mt as c,Ot as l,Tt as u,ft as d,jt as f,vt as p}from"./queries-dnpdX9VT.js";import{n as m,p as h,r as g}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as _}from"./toaster-Bo5vCbz-.js";import{l as v,u as y}from"./design-icons-CzEoMH9c.js";import{t as b}from"./createLucideIcon-BHp8sXmF.js";import{t as x}from"./button-BQ2y4XRB.js";import{n as ee,r as te,t as ne}from"./collapsible-BEV4FO-1.js";import{t as S}from"./switch-Bv2Zf1uU.js";import{t as C}from"./badge-D9JrXe0o.js";import{n as w,s as T,t as E}from"./project-router-C6zhlnwO.js";import"./attention-VcsXbAZz.js";import{Un as D,dt as re,ft as O,pt as k,z as A,zn as j}from"./index-DgdiXHgV.js";import{t as ie}from"./textarea-vJt9undk.js";import{ArchiveOnMergeField as ae}from"./archive-on-merge-field-Dx8afb0D.js";import{a as oe,i as se,n as ce,t as le}from"./projects-section-C-ji_9Jb.js";import{t as M}from"./settings-field-Bl6WuvGX.js";import{t as ue}from"./project-location-DJEH4PmN.js";var de=b(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),N=e(t(),1),P={"needs-you":{label:`Needs you`,hint:`Asks a question, asks for permission, or waits for review`},failed:{label:`Failed`,hint:`Failed, with no scheduled resume`},done:{label:`Done`,hint:`Finished`},cancelled:{label:`Cancelled`,hint:`Was cancelled`},running:{label:`Running`,hint:`Runs an agent turn`},"waiting-workers":{label:`Waiting for agents`,hint:`Waits on its workers or their replies`},"waiting-ci":{label:`Waiting on CI`,hint:`Waits on a pull request's checks`},"waiting-timer":{label:`Waiting`,hint:`Waits on a timer`},"waiting-other":{label:`Any other wait`,hint:`Waits on anything else, including wait types added later`}},F=(e,t)=>e.length===t.length&&e.every(e=>t.includes(e)),I={name:``,description:``,url:``,token:``,tasks:!0,triggers:i,agent:!1};function L(e){return{name:e.name,description:e.description??``,url:e.url,token:``,tasks:e.tasks,triggers:e.triggers??i,agent:e.agent}}var R=e=>r.filter(t=>e.includes(t));function z(e){let t=e.description.trim();return{name:e.name.trim(),url:e.url.trim(),...t?{description:t}:{},...e.token?{token:e.token}:{},tasks:e.tasks,...F(e.triggers,i)?{}:{triggers:R(e.triggers)},agent:e.agent}}function B(e,t){let n={},r=e.name.trim(),a=e.description.trim(),o=e.url.trim();return r!==t.name&&(n.name=r),a!==(t.description??``)&&(n.description=a),o!==t.url&&(n.url=o),e.token&&(n.token=e.token),e.tasks!==t.tasks&&(n.tasks=e.tasks),F(e.triggers,t.triggers??i)||(n.triggers=R(e.triggers)),e.agent!==t.agent&&(n.agent=e.agent),n}var V=n(),H=`flex flex-col gap-1 text-[13px]`,U=`text-[11px] text-muted-foreground`;function W({draft:e,onChange:t,tokenSet:n}){let i=(0,N.useId)(),c=(0,N.useId)(),l=(0,N.useId)(),u=(0,N.useId)(),d=(0,N.useId)(),f=(0,N.useId)(),p=(0,N.useId)(),m=(0,N.useId)(),h=(0,N.useId)(),g=(0,N.useId)();return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-3`,children:[(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:i,className:U,children:`Name`}),(0,V.jsx)(D,{id:i,"data-slot":`webhook-name`,autoComplete:`off`,maxLength:80,placeholder:`e.g. Team bot`,value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:u,className:U,children:`URL`}),(0,V.jsx)(D,{id:u,"data-slot":`webhook-url`,type:`url`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,maxLength:s,placeholder:`https://bot.example/hooks/cez`,value:e.url,onChange:e=>t({url:e.target.value})})]})]}),(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:c,className:U,children:`Description`}),(0,V.jsx)(ie,{id:c,"data-slot":`webhook-description`,"aria-describedby":l,rows:2,maxLength:a,placeholder:`e.g. Posts to the #releases channel. Use it for release notes.`,value:e.description,onChange:e=>t({description:e.target.value})}),(0,V.jsx)(`span`,{id:l,className:`text-[11px] text-soft-foreground`,children:`Agents read the name and description to decide when to use this webhook.`})]}),(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:d,className:U,children:`Token`}),(0,V.jsx)(D,{id:d,"data-slot":`webhook-token`,type:`password`,autoComplete:`new-password`,spellCheck:!1,maxLength:o,"aria-describedby":f,placeholder:n?`Token set — type to replace`:`Optional Bearer token`,value:e.token,onChange:e=>t({token:e.target.value})}),(0,V.jsx)(`span`,{id:f,className:`text-[11px] text-soft-foreground`,children:n?`The token is stored in ~/.cezar and never shown again. Leave it empty to keep it.`:`The token is stored in ~/.cezar, never in the repo. It is sent as a Bearer header.`})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,V.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,V.jsx)(S,{id:p,"aria-describedby":m,"data-slot":`webhook-tasks`,checked:e.tasks,onCheckedChange:e=>t({tasks:e})}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,V.jsx)(`label`,{htmlFor:p,className:`font-medium`,children:`Task notifications`}),(0,V.jsx)(`span`,{id:m,className:`text-[11px] text-soft-foreground`,children:`Tasks you hand off, or start with notify on, send their status here.`})]})]}),e.tasks?(0,V.jsxs)(`fieldset`,{"data-slot":`webhook-triggers`,className:`flex flex-col gap-1 sm:ps-[3.25rem]`,children:[(0,V.jsx)(`legend`,{className:`pbe-1 text-[11px] text-muted-foreground`,children:`Send a delivery when a task enters`}),(0,V.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-x-3`,children:r.map(n=>(0,V.jsxs)(`label`,{className:`flex min-h-11 items-start gap-2.5 pbs-2 text-[13px]`,children:[(0,V.jsx)(`input`,{type:`checkbox`,"data-trigger":n,checked:e.triggers.includes(n),onChange:r=>t({triggers:r.target.checked?[...e.triggers,n]:e.triggers.filter(e=>e!==n)}),className:`mbs-0.5 size-[18px] shrink-0`}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:P[n].label}),(0,V.jsx)(`span`,{className:`text-[11px] text-soft-foreground`,children:P[n].hint})]})]},n))}),(0,V.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Handing a task off and Send test always deliver.`})]}):null]}),(0,V.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,V.jsx)(S,{id:h,"aria-describedby":g,"data-slot":`webhook-agent`,checked:e.agent,onCheckedChange:e=>t({agent:e})}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,V.jsx)(`label`,{htmlFor:h,className:`font-medium`,children:`Let agents send reports`}),(0,V.jsx)(`span`,{id:g,className:`text-[11px] text-soft-foreground`,children:`Agents in this project may post a report here when the task calls for it.`})]})]})]})}var G=`max-sm:h-11`,K=(e,t)=>({tone:`alert`,text:`Not saved: ${e.message}. Fix the field and select ${t} again.`}),fe=e=>e.dryRun?{tone:`ok`,text:`Dry run: nothing was sent.`}:e.ok?{tone:`ok`,text:`Delivered (HTTP ${e.status??200}).`}:{tone:`danger`,text:`Not delivered: ${e.error??`unknown error`}.`};function q({feedback:e}){return e?(0,V.jsx)(`p`,{"data-slot":e.tone===`alert`?`webhook-error`:`webhook-result`,role:e.tone===`alert`?`alert`:`status`,className:e.tone===`ok`?`text-[13px] text-muted-foreground`:`text-[13px] text-danger`,children:e.text}):null}var J=`rounded-md border border-border bg-background`,Y=`flex flex-col gap-3 border-bs border-border p-3`;function pe({projectId:e,webhook:t,defaultOpen:n=!1}){let r=f(),i=u(),a=l(),[o,s]=(0,N.useState)(n),[c,d]=(0,N.useState)(()=>L(t)),[p,m]=(0,N.useState)(null),h=B(c,t),g=Object.keys(h).length>0,y=c.name.trim()!==``&&c.url.trim()!==``,b=r.isPending||i.isPending||a.isPending,S={projectId:e,webhookId:t.id},w=e=>r.mutate({...S,...h},{onSuccess:()=>{d(e=>({...e,token:``})),e?e():_(`${c.name.trim()} saved`)},onError:e=>m(K(e,`Save`))}),T=()=>a.mutate(S,{onSuccess:e=>m(fe(e)),onError:e=>m({tone:`danger`,text:e.message})});return(0,V.jsx)(`li`,{"data-slot":`webhook-card`,"data-webhook-id":t.id,className:J,children:(0,V.jsxs)(ne,{open:o,onOpenChange:s,children:[(0,V.jsx)(te,{asChild:!0,children:(0,V.jsxs)(`button`,{type:`button`,"data-action":`webhook-toggle`,className:`group flex min-h-11 w-full items-center gap-3 rounded-md p-3 text-start focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-foreground pointer-hover:bg-muted/50 active:bg-muted/50`,children:[(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,V.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,V.jsx)(`span`,{"data-slot":`webhook-card-name`,className:`min-w-0 break-words text-[13px] font-medium`,children:t.name}),t.tasks?(0,V.jsx)(C,{variant:`secondary`,"data-badge":`tasks`,children:`Task notifications`}):null,t.agent?(0,V.jsx)(C,{variant:`secondary`,"data-badge":`agent`,children:`Agents`}):null]}),(0,V.jsx)(`span`,{"data-slot":`webhook-card-url`,className:`truncate text-[12px] text-muted-foreground`,children:A(t.url)})]}),(0,V.jsx)(v,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground group-data-[state=open]:rotate-180`})]})}),(0,V.jsx)(ee,{children:(0,V.jsxs)(`form`,{"data-slot":`webhook-form`,className:Y,onSubmit:e=>{e.preventDefault(),m(null),y&&g&&w()},children:[(0,V.jsx)(W,{draft:c,tokenSet:t.tokenSet,onChange:e=>d(t=>({...t,...e}))}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(x,{type:`submit`,size:`sm`,className:G,"data-action":`webhook-save`,disabled:b||!y||!g,children:`Save`}),(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`outline`,"data-action":`webhook-test`,disabled:b||!y,onClick:()=>{m(null),g?w(T):T()},children:`Send test`}),t.tokenSet?(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`ghost`,"data-action":`webhook-clear-token`,disabled:b,onClick:()=>r.mutate({...S,token:``},{onSuccess:()=>_(`Webhook token cleared`),onError:e=>m({tone:`danger`,text:`Token not cleared: ${e.message}.`})}),children:`Clear token`}):null,(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`danger-ghost`,"data-action":`webhook-remove`,"aria-label":`Remove ${t.name}`,disabled:b,onClick:()=>i.mutate(S,{onSuccess:()=>_(`${t.name} removed`),onError:e=>m({tone:`danger`,text:`Not removed: ${e.message}.`})}),children:`Remove`})]}),(0,V.jsx)(q,{feedback:p})]})})]})})}function me({projectId:e,onCreated:t,onCancel:n}){let r=d(),[i,a]=(0,N.useState)(I),[o,s]=(0,N.useState)(null),c=i.name.trim()!==``&&i.url.trim()!==``;return(0,V.jsxs)(`li`,{"data-slot":`webhook-card`,"data-draft":``,className:J,children:[(0,V.jsx)(`p`,{className:`p-3 text-[13px] font-medium`,children:`New webhook`}),(0,V.jsxs)(`form`,{"data-slot":`webhook-form`,"aria-label":`New webhook`,className:Y,onSubmit:n=>{n.preventDefault(),s(null),c&&r.mutate({projectId:e,...z(i)},{onSuccess:({webhook:e})=>{_(`${e.name} created`),t(e)},onError:e=>s(K(e,`Create`))})},children:[(0,V.jsx)(W,{draft:i,tokenSet:!1,onChange:e=>a(t=>({...t,...e}))}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(x,{type:`submit`,size:`sm`,className:G,"data-action":`webhook-create`,disabled:r.isPending||!c,children:`Create`}),(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`ghost`,"data-action":`webhook-cancel`,disabled:r.isPending,onClick:n,children:`Cancel`})]}),(0,V.jsx)(q,{feedback:o})]})]})}function he({project:e}){let t=e.webhooks??[],[n,r]=(0,N.useState)(!1),[i,a]=(0,N.useState)(null),o=t.length>=16;return(0,V.jsx)(M,{title:`Webhooks`,hint:`A webhook gets a POST from Squawk. Tasks can send their status to it, and agents can send it reports.`,children:(0,V.jsxs)(`div`,{"data-slot":`project-webhooks`,className:`flex flex-col gap-3`,children:[t.length===0&&!n?(0,V.jsx)(`p`,{"data-slot":`webhooks-empty`,className:`text-[13px] text-soft-foreground`,children:`No webhooks yet. Add one to send task updates to a bot, or to let agents post reports.`}):null,t.length>0||n?(0,V.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[t.map(t=>(0,V.jsx)(pe,{projectId:e.id,webhook:t,defaultOpen:t.id===i},t.id)),n?(0,V.jsx)(me,{projectId:e.id,onCancel:()=>r(!1),onCreated:e=>{a(e.id),r(!1)}}):null]}):null,n?null:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsxs)(x,{type:`button`,size:`sm`,variant:`outline`,className:`max-sm:h-11`,"data-action":`webhook-add`,disabled:o,onClick:()=>r(!0),children:[(0,V.jsx)(de,{"aria-hidden":`true`}),`Add webhook`]}),o?(0,V.jsxs)(`span`,{className:`text-[11px] text-soft-foreground`,children:[`A project holds at most `,16,` webhooks.`]}):null]})]})})}function X(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function Z(){let e=T(),t=p(),n=c();if(t.isPending)return(0,V.jsx)(`p`,{"data-slot":`project-general-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading project…`});if(t.isError)return(0,V.jsxs)(`p`,{"data-slot":`project-general-error`,className:`text-[13px] text-danger`,children:[`Could not read the project registry — `,t.error.message]});let r=t.data,i=r?.projects.find(t=>t.id===e);return!r||!i?null:(0,V.jsxs)(`div`,{"data-slot":`project-general`,className:`flex w-full flex-col gap-5`,children:[(0,V.jsxs)(`section`,{className:`flex flex-col gap-5 rounded-lg border border-border bg-card p-5 [&_select]:min-h-11 [&_select]:w-full`,children:[(0,V.jsx)(`h2`,{className:`text-lg font-semibold`,children:`General`}),(0,V.jsx)(ue,{}),(0,V.jsx)(ge,{project:i}),(0,V.jsx)(M,{title:`Max parallel tasks`,hint:n.data?`The workspace limit (${n.data.resources.maxParallel}) still applies as an overall ceiling.`:`How many of this project's tasks may run at once. The workspace limit still applies as an overall ceiling.`,children:n.data?(0,V.jsx)(le,{project:i,workspaceMax:n.data.resources.maxParallel}):(0,V.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading the workspace limit…`})}),(0,V.jsx)(he,{project:i},i.id)]}),(0,V.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,V.jsx)(_e,{project:i,bootProject:r.bootProject})})]})}function ge({project:e}){return(0,V.jsxs)(`dl`,{"data-slot":`project-facts`,className:`grid grid-cols-1 gap-4 text-[13px] sm:grid-cols-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Project`}),(0,V.jsx)(`dd`,{className:`mt-1 font-medium`,children:e.name})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Branch`}),(0,V.jsx)(`dd`,{className:`mt-1 break-all`,children:e.branch??`—`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Status`}),(0,V.jsxs)(`dd`,{"data-slot":`project-general-status`,className:e.status===`missing`?`mt-1 text-danger`:`mt-1`,children:[ce[e.status],e.status===`missing`?` — remove it below, or restore the folder`:null]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Added`}),(0,V.jsxs)(`dd`,{className:`mt-1`,children:[X(e.addedAt),(0,V.jsx)(`span`,{className:`text-soft-foreground`,children:e.source===`checkout`?` · cloned from GitHub`:` · opened locally`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Last opened`}),(0,V.jsx)(`dd`,{className:`mt-1`,children:X(e.lastOpenedAt)})]})]})}function _e({project:e,bootProject:t}){let[n,r]=(0,N.useState)(null),i=oe(),a=h(),o=e.id===t;return(0,V.jsxs)(M,{title:`Remove from workspace`,hint:`Unregisters this project so it leaves the sidebar and the project list. Nothing on disk is deleted — the folder, its git history and its task history all stay, and opening it again re-registers it.`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,"data-action":`project-general-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:o?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:o||i.isPending,onClick:()=>r(e),className:`text-danger`,children:[`Remove `,e.name]}),o?(0,V.jsx)(`span`,{"data-slot":`project-general-remove-boot`,className:`text-[11px] text-soft-foreground`,children:`Squawk is serving this project — it re-registers itself at every start.`}):null]}),(0,V.jsx)(se,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{r(null),i.confirm(e,()=>void a(`/p/${encodeURIComponent(t)}`))}})]})}function ve(e){return e===`global`?{Link:m,NavLink:g}:{Link:E,NavLink:w}}function Q({scope:e,title:t,mobileTitle:n}){let r=j().name;return(0,V.jsxs)(`header`,{"data-slot":`settings-main-header`,className:`settings-route-header flex shrink-0 flex-col gap-2`,children:[(0,V.jsxs)(`h1`,{className:`text-[15px] font-semibold tracking-normal max-md:text-[24px] max-md:font-normal`,children:[(0,V.jsx)(`span`,{className:`md:hidden`,children:n}),(0,V.jsxs)(`span`,{className:`max-md:hidden`,children:[t,` · `,e===`global`?`every project`:r??`this project`]})]}),e===`global`?(0,V.jsx)(`span`,{"data-slot":`settings-scope-chip`,className:`sr-only`,children:`Global settings`}):null]})}function $({scope:e,activeId:t}){let{NavLink:n}=ve(e),r=k(e);return(0,V.jsxs)(`details`,{className:`settings-section-picker md:hidden`,children:[(0,V.jsxs)(`summary`,{children:[r.find(e=>e.id===t)?.title??`General`,(0,V.jsx)(v,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`})]}),(0,V.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-slot":`settings-nav-mobile`,"data-scope":e,children:[e===`project`?(0,V.jsx)(n,{to:`/settings`,end:!0,"data-slot":`settings-nav-index`,children:`General`}):null,r.map(t=>(0,V.jsx)(n,{to:O(e,t.id),"data-section":t.id,children:t.title},t.id))]})]},`${e}-${t}`)}function ye({section:e,scope:t}){let n=e.component;return(0,V.jsxs)(`div`,{"data-route":t===`global`?`settings-global-${e.id}`:`settings-${e.id}`,className:`settings-route mx-auto flex min-h-full w-full flex-col`,children:[(0,V.jsx)(Q,{scope:t,title:e.title,mobileTitle:t===`global`?`Global settings`:`Project settings`}),(0,V.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,V.jsx)($,{scope:t,activeId:e.id}),(0,V.jsxs)(`section`,{className:`settings-panel min-w-0 self-start md:flex-1`,"aria-label":e.title,children:[(0,V.jsx)(`h2`,{className:`settings-panel-title`,children:e.title}),(0,V.jsx)(n,{})]})]})]})}function be(){return(0,V.jsxs)(`div`,{"data-route":`settings`,className:`settings-route mx-auto flex min-h-full w-full flex-col`,children:[(0,V.jsx)(Q,{scope:`project`,title:`General`,mobileTitle:`Project settings`}),(0,V.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,V.jsx)($,{scope:`project`,activeId:null}),(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,V.jsx)(Z,{}),(0,V.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,V.jsx)(ae,{})}),(0,V.jsx)(`h2`,{className:`settings-other-title mt-6 rounded-t-lg border border-b-0 border-border bg-card px-5 pt-5 text-base font-semibold md:hidden`,children:`Other project settings`}),(0,V.jsx)(`ul`,{"data-slot":`settings-index`,className:`mt-7 flex w-full flex-col gap-5 md:hidden`,children:k(`project`).map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(E,{to:O(`project`,e.id),"data-section":e.id,className:`flex items-center gap-3.5 rounded-lg border border-border bg-card p-4 transition-colors hover:bg-card-2`,children:[(0,V.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center text-accent-text`,children:(0,V.jsx)(e.icon,{"aria-hidden":`true`,className:`size-4`})}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.title}),(0,V.jsx)(`span`,{className:`block text-xs text-soft-foreground`,children:e.description})]}),(0,V.jsx)(y,{"aria-hidden":`true`,className:`size-4 shrink-0 text-soft-foreground`})]})},e.id))}),(0,V.jsxs)(`p`,{className:`mt-5 w-full text-[12px] text-soft-foreground`,children:[`Appearance, notifications, host resources and the project registry live in`,` `,(0,V.jsx)(m,{to:re,"data-slot":`settings-global-link`,className:`underline underline-offset-2 hover:text-foreground`,children:`Global settings`}),`.`]})]})]})]})}export{be as SettingsIndexRoute,ye as SettingsSectionRoute};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r}from"./utils-DSMR_WLb.js";import{Nr as i,Pr as a,ci as o,j as s}from"./project-scope-context-d3J3hWPR.js";import{in as c,y as l}from"./queries-dnpdX9VT.js";import{t as u}from"./button-BQ2y4XRB.js";var d=e(t(),1),f=n(),p=[[`overall`,`Overall`],[`needsYou`,`Needs You`],[`finished`,`Finished`],[`working`,`Working`]];function m(){let e=r(),t=l(e);return t.isPending?(0,f.jsx)(`p`,{role:`status`,className:`p-4 text-sm text-muted-foreground`,children:`Loading sidebar settings…`}):t.isError?(0,f.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,f.jsxs)(`p`,{role:`alert`,children:[`Sidebar settings did not load: `,t.error.message]}),(0,f.jsx)(u,{className:`min-h-[44px]`,onClick:()=>void t.refetch(),children:`Retry`})]}):(0,f.jsx)(h,{scope:e,initial:t.data.sidebarLimits??{}},e)}function h({scope:e,initial:t}){let n=o(),r=i(void 0),l=g(t),[m,h]=(0,d.useState)(()=>({values:l,saved:l,received:l})),{values:v,saved:y}=m,b=e=>h(t=>({...t,values:e})),x=a.safeParse(Object.fromEntries(p.map(([e])=>[e,v[e]===null?null:Number(v[e])]))),S=e=>v[e]!==null&&(v[e].trim()===``||!Number.isSafeInteger(Number(v[e]))||Number(v[e])<=0),C=p.some(([e])=>v[e]!==y[e]),w=c({onMutate:()=>n.cancelQueries({queryKey:[e,`ui-state`],exact:!0}),mutationFn:t=>s({sidebarLimits:t},e),onSuccess:async t=>{await n.cancelQueries({queryKey:[e,`ui-state`],exact:!0}),n.setQueryData([e,`ui-state`],t);let r=g(t.sidebarLimits);h({values:r,saved:r,received:r})}});return!w.isPending&&!_(m.received,l)&&h({values:C?v:l,saved:l,received:l}),(0,f.jsxs)(`form`,{"data-slot":`sidebar-settings`,className:`flex w-full max-w-2xl flex-col gap-5 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6`,onSubmit:e=>{e.preventDefault(),x.success&&!p.some(([e])=>S(e))&&!w.isPending&&w.mutate(x.data)},children:[(0,f.jsx)(`p`,{id:`sidebar-limits-help`,className:`text-sm text-muted-foreground`,children:`Limits apply to this project on desktop and mobile. The overall budget is shared in section order: Needs You, Finished, then Working. Each section also respects its own limit. Unlimited removes only that constraint.`}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pinned tasks and groups containing a pin bypass both limits. A task group counts as one row. Archived uses only the overall limit; archived pins are not exempt.`}),p.map(([e,t])=>(0,f.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`label`,{htmlFor:`sidebar-${e}`,className:`text-sm font-medium`,children:t}),(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,f.jsx)(`input`,{id:`sidebar-${e}`,type:`number`,inputMode:`numeric`,min:`1`,step:`1`,value:v[e]??``,disabled:v[e]===null||w.isPending,"aria-invalid":S(e),"aria-describedby":S(e)?`sidebar-${e}-error sidebar-limits-help`:`sidebar-limits-help`,onChange:t=>b({...v,[e]:t.target.value}),className:`min-h-[44px] w-28 rounded-md border border-input bg-card px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50`}),(0,f.jsxs)(`label`,{className:`flex min-h-[44px] cursor-pointer items-center gap-2 text-sm`,children:[(0,f.jsx)(`input`,{type:`checkbox`,"aria-label":`${t} Unlimited`,checked:v[e]===null,disabled:w.isPending,onChange:t=>b({...v,[e]:t.target.checked?null:String(r[e]??10)}),className:`size-4 accent-[var(--accent-strong)]`}),`Unlimited`]})]}),S(e)&&(0,f.jsx)(`p`,{id:`sidebar-${e}-error`,className:`text-sm text-danger`,children:`Enter a positive whole number or choose Unlimited.`})]},e)),(0,f.jsx)(u,{type:`submit`,className:`min-h-[44px] self-start`,variant:`primary`,disabled:!C||!x.success||p.some(([e])=>S(e))||w.isPending,children:w.isPending?`Saving…`:`Save sidebar limits`}),w.isError&&(0,f.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Could not save sidebar limits: `,w.error.message]}),w.isSuccess&&!C&&(0,f.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Sidebar limits saved.`})]})}function g(e){let t=i(e);return Object.fromEntries(p.map(([e])=>[e,t[e]===null?null:String(t[e])]))}function _(e,t){return p.every(([n])=>e[n]===t[n])}export{m as SidebarSection};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,An as i,Mr as a,ci as o,jr as s}from"./project-scope-context-d3J3hWPR.js";import{Lt as c,_ as l,ht as u,in as d}from"./queries-dnpdX9VT.js";import{n as f}from"./toaster-Bo5vCbz-.js";import{u as p}from"./design-icons-CzEoMH9c.js";import{t as m}from"./button-BQ2y4XRB.js";import{t as h}from"./project-router-C6zhlnwO.js";import{t as g}from"./centered-state-V15AR_qo.js";import{Xn as _}from"./index-DgdiXHgV.js";import{n as v,r as y,t as b}from"./remote-settings-notice-D12kO_fx.js";import{t as x}from"./settings-field-Bl6WuvGX.js";import{n as S}from"./project-location-DJEH4PmN.js";var C=e(t(),1),w=n();function T({copy:e,savedCommandCount:t,settingsAdmin:n,configPath:r,issue:i,invalid:a,children:o}){let s=e.slot;return(0,w.jsxs)(w.Fragment,{children:[t===0&&i===null?(0,w.jsx)(`p`,{"data-slot":`${s}-empty`,className:`text-sm text-foreground`,children:e.empty}):null,o,n===!1?(0,w.jsxs)(`p`,{"data-slot":`${s}-readonly`,className:`text-xs text-foreground`,children:[`Edit `,(0,w.jsxs)(`code`,{children:[e.key,`.commands`]}),` in`,` `,r===null?(0,w.jsxs)(w.Fragment,{children:[`the project’s `,(0,w.jsx)(`code`,{children:`.ai/cezar/config.json`})]}):(0,w.jsx)(`code`,{className:`break-all`,children:r}),` `,`on the machine running Squawk. `,e.fileEditApplies,` No restart is needed. To edit here, the host operator runs `,(0,w.jsx)(`code`,{children:b}),`.`]}):null,i===null?null:(0,w.jsxs)(`p`,{"data-slot":`${s}-issue`,className:`text-[11px] text-danger`,children:[`config.json has an invalid `,e.key,` (`,i,`) — saving replaces it.`]}),a===null?null:(0,w.jsx)(`p`,{"data-slot":`${s}-invalid`,className:`text-[11px] text-danger`,children:a})]})}function E(e,t){let n=e.split(`
|
|
2
|
-
`).map(e=>e.trim()).filter(e=>e!==``),r=Number(t);return{commands:n,timeoutSeconds:r,invalid:n.length>20?`Enter at most 20 commands.`:n.some(e=>e.length>4e3)?`Keep each command under ${s.toLocaleString(`en-US`)} characters.`:t.trim()===``||!Number.isInteger(r)||r<1||r>7200?`Enter a whole number of seconds from 1 to ${a}.`:null}}var D={setup:{key:`worktreeSetup`,issueKey:`worktreeSetupIssue`,slot:`worktree-setup`,title:`Prepare new worktrees`,hint:`Runs in every new task and worker worktree before the agent starts, in order, stopping at the first failure. Leave commands empty to skip setup.`,empty:`No setup commands configured. No commands will run in new worktrees.`,label:`Worktree setup commands, one per line`,example:`npm ci`,fileEditApplies:`Valid file edits apply to new worktrees.`,saved:`Worktree setup saved`,cleared:`Worktree setup cleared`,save:`Save setup`},teardown:{key:`worktreeTeardown`,issueKey:`worktreeTeardownIssue`,slot:`worktree-teardown`,title:`Stop worker services before destroy`,hint:`Runs in a worker’s worktree when the worker is destroyed, before destroy stops the worker’s processes, in order, stopping at the first failure. A failure is recorded on the worker and destroy goes on. Leave commands empty to skip teardown.`,empty:`No teardown commands configured. Destroy runs no commands in worker worktrees.`,label:`Worktree teardown commands, one per line`,example:`docker compose down`,fileEditApplies:`Valid file edits apply to the next worker destroy.`,saved:`Worktree teardown saved`,cleared:`Worktree teardown cleared`,save:`Save teardown`}};function O({config:e,copy:t}){let n=o(),s=u(),l=y(),p=S(),h=p===null?null:`${p.replace(/\/$/,``)}/.ai/cezar/config.json`,g=s.data?.capabilities?.settingsAdmin===!0,_=e[t.key],b=e[t.issueKey],D=_?.commands??[],O=_?.timeoutSeconds??900,[k,A]=(0,C.useState)(D.join(`
|
|
3
|
-
`)),[j,M]=(0,C.useState)(String(O)),{commands:N,timeoutSeconds:P,invalid:F}=E(k,j),I=b===null&&N.length===D.length&&N.every((e,t)=>e===D[t])&&(N.length===0||P===O),L=d({mutationFn:e=>r(e),onSuccess:e=>{n.setQueryData(c.config,e),A(N.join(`
|
|
4
|
-
`)),f(N.length===0?t.cleared:t.saved)},onError:e=>{f(e.message,{tone:`danger`}),e instanceof i&&e.status===409&&l()}}),R=()=>L.mutate({[t.key]:N.length===0?null:{commands:N,...P===900?{}:{timeoutSeconds:P}}}),z=`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50 read-only:bg-muted read-only:text-muted-foreground`;return(0,w.jsxs)(x,{title:t.title,hint:t.hint,children:[(0,w.jsx)(v,{risk:`These commands run on the machine running Squawk`}),(0,w.jsxs)(T,{copy:t,savedCommandCount:D.length,settingsAdmin:s.data?.capabilities?.settingsAdmin,configPath:h,issue:b,invalid:F,children:[(0,w.jsx)(`textarea`,{"data-slot":`${t.slot}-commands`,"aria-label":t.label,rows:4,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:k,readOnly:!g,disabled:L.isPending,onChange:e=>A(e.target.value),className:`${z} min-h-24 w-full resize-y font-mono text-[13px] leading-relaxed`}),(0,w.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[`Example only: `,(0,w.jsx)(`code`,{children:t.example}),`. Commands run only after they are saved.`]}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-soft-foreground`,children:[(0,w.jsx)(`span`,{children:`Timeout per command`}),(0,w.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:1,max:a,step:1,"data-slot":`${t.slot}-timeout`,value:j,readOnly:!g,disabled:L.isPending,onChange:e=>M(e.target.value),className:`${z} min-h-11 w-28 md:min-h-0`}),(0,w.jsx)(`span`,{children:`seconds`})]}),(0,w.jsx)(m,{type:`button`,variant:`primary`,size:`sm`,className:`min-h-11 self-start md:min-h-0`,"data-action":`${t.slot}-save`,disabled:!g||I||F!==null||L.isPending,onClick:R,children:t.save})]})]})]})}var k=0,A=1e3;function j(){let e=l();return e.isPending?(0,w.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading worktree settings…`}):e.isError?(0,w.jsx)(g,{icon:(0,w.jsx)(_,{}),tone:`danger`,title:`Worktree settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,w.jsx)(M,{config:e.data})}function M({config:e}){let t=o(),n=d({mutationFn:e=>r(e),onSuccess:e=>t.setQueryData(c.config,e),onError:e=>f(e.message,{tone:`danger`})}),[i,a]=(0,C.useState)(String(e.worktreeRetention)),s=Number(i),l=i.trim()===``||!Number.isInteger(s)||s<k||s>A,u=e.worktreeRetention===(l?-1:s);return(0,w.jsxs)(`div`,{"data-slot":`worktrees-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,w.jsxs)(x,{title:`Keep N finished worktrees`,hint:`Older finished worktrees are reclaimed to free disk; their branch is kept so the work stays recoverable. 0 = unlimited. In-review and running tasks are never reclaimed, so the count on disk can exceed this.`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:k,max:A,step:1,"aria-label":`Keep last N finished worktrees`,"data-slot":`resources-worktree-retention`,value:i,disabled:n.isPending,onChange:e=>a(e.target.value),className:`block w-32 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,w.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`worktrees`}),(0,w.jsx)(m,{type:`button`,variant:`primary`,size:`sm`,className:`self-start`,"data-action":`resources-save-retention`,disabled:u||l||n.isPending,onClick:()=>n.mutate({worktreeRetention:s},{onSuccess:()=>{t.invalidateQueries({queryKey:c.worktrees}),f(s===0?`Keeping all worktrees (unlimited)`:`Keeping the last ${s} finished worktree${s===1?``:`s`}`)}}),children:`Save retention`})]}),l?(0,w.jsxs)(`p`,{"data-slot":`resources-retention-invalid`,className:`text-[11px] text-danger`,children:[`Enter a whole number from `,k,` to `,A,` (0 = unlimited).`]}):(0,w.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:s===0?`Keeping every finished worktree.`:`Keeping the last ${s} finished worktree${s===1?``:`s`} on disk.`})]}),(0,w.jsx)(O,{config:e,copy:D.setup}),(0,w.jsx)(O,{config:e,copy:D.teardown}),(0,w.jsxs)(h,{to:`/git/cleanup`,"data-slot":`worktrees-manage-link`,className:`inline-flex min-h-11 items-center gap-1 self-start text-[13px] font-medium text-link-foreground hover:underline focus-visible:outline-2 focus-visible:outline-ring md:min-h-0`,children:[`Manage worktrees on Git`,(0,w.jsx)(p,{"aria-hidden":`true`,className:`size-[14px]`})]})]})}export{j as WorktreesSection};
|