import{n as u,u as f,j as e,k as j,B as p,L as g,I as N,C as b}from"./index-O0BQoyzo.js";import{r as c}from"./react-Cb2sDjhD.js";import{T as y,a as v,b as m,c as i,d as k,e as l}from"./table-CPn1MRcy.js";import{f as C}from"./use-background-tasks-BQrEeUwY.js";import{L as w}from"./loader-circle-9VUMGitw.js";import{R as V}from"./refresh-ccw-D2CWiyU_.js";import{C as F}from"./chevron-right-uP_l9MMb.js";import{C as L}from"./clock-qxbYSynv.js";import{C as M}from"./circle-x-Ccg1HyV-.js";import{C as T}from"./circle-check-CewnjFgv.js";import"./useQuery-PdiC7-sY.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const R=u("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const P=u("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]),E={approved:e.jsx(T,{className:"h-3 w-3"}),rejected:e.jsx(M,{className:"h-3 w-3"}),edited:e.jsx(P,{className:"h-3 w-3"}),expired:e.jsx(L,{className:"h-3 w-3"})},O={approved:"success",rejected:"warning",edited:"info",expired:"outline"};function A(a){if(a==null)return"—";if(a<1e3)return`${a}ms`;const s=a/1e3;return s<60?`${s.toFixed(1)}s`:`${(s/60).toFixed(1)}min`}function X(){const{t:a}=f(["tasks","common"]),[s,r]=c.useState(""),[d,o]=c.useState(""),t=C({threadKey:d||void 0,limit:200}),h=c.useMemo(()=>t.data?.plans??[],[t.data]);function x(){o(s.trim())}return e.jsxs("div",{className:"mx-auto flex max-w-6xl flex-col gap-4 p-4",children:[e.jsxs("header",{className:"flex items-center gap-3",children:[e.jsx(R,{className:"h-5 w-5 text-text-dim"}),e.jsx("h1",{className:"text-xl font-semibold",children:a("plans.title",{defaultValue:"Plan history"})}),e.jsx(j,{variant:"info",children:h.length}),e.jsxs(p,{variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>void t.refetch(),disabled:t.isFetching,"aria-label":a("actions.refresh",{ns:"common"}),children:[t.isFetching?e.jsx(w,{className:"h-4 w-4 animate-spin"}):e.jsx(V,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:a("plans.refresh",{defaultValue:"Refresh"})})]})]}),e.jsx("p",{className:"text-sm text-text-dim",children:a("plans.subtitle",{defaultValue:"Every native_exit_plan_mode handshake (v1.2.131) lands here with outcome + the plan markdown the model proposed."})}),e.jsxs("section",{className:"flex items-end gap-2 rounded-md border border-border bg-surface p-3",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[e.jsx(g,{className:"text-xs font-medium",children:a("plans.filterLabel",{defaultValue:"Filter by thread key (optional)"})}),e.jsx(N,{value:s,onChange:n=>r(n.target.value),onKeyDown:n=>{n.key==="Enter"&&x()},placeholder:"tg:8754479311:default",className:"font-mono text-xs"})]}),e.jsx(p,{size:"sm",onClick:x,disabled:t.isFetching,children:a("plans.applyFilter",{defaultValue:"Apply"})}),d&&e.jsx(p,{size:"sm",variant:"ghost",onClick:()=>{r(""),o("")},children:a("plans.clearFilter",{defaultValue:"Clear"})})]}),t.isLoading?e.jsx("div",{className:"h-32 rounded-md bg-surface-2 animate-pulse"}):h.length===0?e.jsx("section",{className:"rounded-md border border-border bg-surface p-6 text-center text-sm text-text-dim",children:d?a("plans.emptyFiltered",{defaultValue:"No plan history for this thread. Either the thread never entered plan mode, or it was approved without going through the exit handshake (e.g. /plan off manually)."}):a("plans.empty",{defaultValue:"No plans yet. Try /plan on in an IM thread and let the model build a plan."})}):e.jsxs(y,{children:[e.jsx(v,{children:e.jsxs(m,{children:[e.jsx(i,{className:"w-8"}),e.jsx(i,{children:a("plans.col.outcome",{defaultValue:"Outcome"})}),e.jsx(i,{children:a("plans.col.thread",{defaultValue:"Thread"})}),e.jsx(i,{children:a("plans.col.resolvedAt",{defaultValue:"Resolved"})}),e.jsx(i,{children:a("plans.col.pending",{defaultValue:"Wait"})}),e.jsx(i,{children:a("plans.col.detail",{defaultValue:"Detail"})})]})}),e.jsx(k,{children:h.map(n=>e.jsx(I,{row:n},n.id))})]})]})}function I({row:a}){const{t:s}=f(["tasks"]),[r,d]=c.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(m,{className:"cursor-pointer hover:bg-surface-hover",onClick:()=>d(o=>!o),children:[e.jsx(l,{className:"p-1 align-top text-text-dim",children:r?e.jsx(b,{className:"h-4 w-4"}):e.jsx(F,{className:"h-4 w-4"})}),e.jsx(l,{className:"align-top",children:e.jsxs(j,{variant:O[a.outcome],children:[E[a.outcome],e.jsx("span",{className:"ml-1",children:a.outcome})]})}),e.jsx(l,{className:"align-top",children:e.jsx("code",{className:"text-[11px]",children:a.threadKey})}),e.jsx(l,{className:"align-top text-[11px] text-text-dim",children:a.resolvedAt}),e.jsx(l,{className:"align-top text-[11px] text-text-dim",children:A(a.pendingMs)}),e.jsx(l,{className:"align-top text-xs",children:a.detail?e.jsxs("span",{title:a.detail,children:[a.detail.slice(0,80),a.detail.length>80?"…":""]}):e.jsx("span",{className:"text-text-dim",children:"—"})})]}),r&&e.jsx(m,{children:e.jsxs(l,{colSpan:6,className:"bg-surface-2 p-3",children:[e.jsx("div",{className:"text-[11px] text-text-dim",children:s("plans.planMdLabel",{defaultValue:"Plan markdown the model proposed:"})}),e.jsx("pre",{className:"mt-1 max-h-96 overflow-y-auto whitespace-pre-wrap rounded border border-border bg-surface p-3 text-[12px]",children:a.planMd})]})})]})}export{X as default};
//# sourceMappingURL=plans-CZoEs5SY.js.map
