@dendelion/paper-camp 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +34 -0
  2. package/dist/app/assets/index-BK4XPXt_.js +4 -0
  3. package/dist/app/assets/index-BK4XPXt_.js.map +1 -0
  4. package/dist/app/assets/index-BZnU3b_x.js +2 -0
  5. package/dist/app/assets/index-BZnU3b_x.js.map +1 -0
  6. package/dist/app/assets/index-BxQBW2Oi.js +2 -0
  7. package/dist/app/assets/index-BxQBW2Oi.js.map +1 -0
  8. package/dist/app/assets/{index-D_Lo8ptS.js → index-COEivZHG.js} +4 -4
  9. package/dist/app/assets/{index-D_Lo8ptS.js.map → index-COEivZHG.js.map} +1 -1
  10. package/dist/app/assets/index-COQOoPiS.js +2 -0
  11. package/dist/app/assets/{index-BHmWkgBW.js.map → index-COQOoPiS.js.map} +1 -1
  12. package/dist/app/assets/index-DIlqYxon.js +7 -0
  13. package/dist/app/assets/index-DIlqYxon.js.map +1 -0
  14. package/dist/app/assets/index-VXeQcBh1.js +2 -0
  15. package/dist/app/assets/index-VXeQcBh1.js.map +1 -0
  16. package/dist/app/assets/{index-DMDqfoCe.js → index-vgBxkLmQ.js} +2 -2
  17. package/dist/app/assets/{index-DMDqfoCe.js.map → index-vgBxkLmQ.js.map} +1 -1
  18. package/dist/app/assets/main-DEUaro51.css +1 -0
  19. package/dist/app/assets/main-s2b5XHSS.js +425 -0
  20. package/dist/app/assets/main-s2b5XHSS.js.map +1 -0
  21. package/dist/app/assets/{sidebar-section-B-A20bg9.js → sidebar-section-4MxZoa3M.js} +2 -2
  22. package/dist/app/assets/{sidebar-section-B-A20bg9.js.map → sidebar-section-4MxZoa3M.js.map} +1 -1
  23. package/dist/app/index.html +6 -6
  24. package/dist/app/toolbar.js +13775 -5454
  25. package/dist/app/toolbar.js.map +1 -1
  26. package/dist/chunks/{phase-progress.DPAZ01Gg.js → phase-progress.DimXpZFz.js} +1337 -1300
  27. package/dist/chunks/phase-progress.DimXpZFz.js.map +1 -0
  28. package/dist/cli/index.js +5289 -5105
  29. package/dist/cli/index.js.map +1 -1
  30. package/dist/core/corpus-format.d.ts +14 -0
  31. package/dist/core/corpus-format.d.ts.map +1 -1
  32. package/dist/core/entity-view.d.ts +6 -0
  33. package/dist/core/entity-view.d.ts.map +1 -0
  34. package/dist/core/git-log.d.ts +2 -0
  35. package/dist/core/git-log.d.ts.map +1 -1
  36. package/dist/core/git-pr/pr-lookup.d.ts.map +1 -1
  37. package/dist/core/index.js +106 -104
  38. package/dist/core/issues.d.ts +2 -3
  39. package/dist/core/issues.d.ts.map +1 -1
  40. package/dist/core/parse/parser.d.ts.map +1 -1
  41. package/dist/core/parse/schemas.d.ts +11 -0
  42. package/dist/core/parse/schemas.d.ts.map +1 -1
  43. package/dist/core/phase-run.d.ts +1 -0
  44. package/dist/core/phase-run.d.ts.map +1 -1
  45. package/dist/core/readers.d.ts +4 -3
  46. package/dist/core/readers.d.ts.map +1 -1
  47. package/dist/core/release-notes.d.ts +2 -0
  48. package/dist/core/release-notes.d.ts.map +1 -1
  49. package/dist/core/roadmap.d.ts +21 -0
  50. package/dist/core/roadmap.d.ts.map +1 -1
  51. package/dist/core/run-order.d.ts +2 -1
  52. package/dist/core/run-order.d.ts.map +1 -1
  53. package/dist/core/scaffold/scaffold.d.ts +1 -1
  54. package/dist/core/scaffold/scaffold.d.ts.map +1 -1
  55. package/dist/core/sections.d.ts.map +1 -1
  56. package/dist/core/serialize/entity-file.d.ts +79 -0
  57. package/dist/core/serialize/entity-file.d.ts.map +1 -0
  58. package/dist/core/serialize/index.d.ts +1 -0
  59. package/dist/core/serialize/index.d.ts.map +1 -1
  60. package/dist/core/serialize/serializer.d.ts +1 -76
  61. package/dist/core/serialize/serializer.d.ts.map +1 -1
  62. package/dist/core/stats.d.ts +2 -0
  63. package/dist/core/stats.d.ts.map +1 -1
  64. package/dist/core/status/status.d.ts +18 -1
  65. package/dist/core/status/status.d.ts.map +1 -1
  66. package/dist/types/index.d.ts +36 -18
  67. package/dist/types/index.d.ts.map +1 -1
  68. package/dist/types/index.js +16 -15
  69. package/dist/types/index.js.map +1 -1
  70. package/package.json +2 -2
  71. package/dist/app/assets/index-3pzg7Iyw.js +0 -2
  72. package/dist/app/assets/index-3pzg7Iyw.js.map +0 -1
  73. package/dist/app/assets/index-BHmWkgBW.js +0 -2
  74. package/dist/app/assets/index-BuzzfADD.js +0 -2
  75. package/dist/app/assets/index-BuzzfADD.js.map +0 -1
  76. package/dist/app/assets/index-CkLeljbk.js +0 -2
  77. package/dist/app/assets/index-CkLeljbk.js.map +0 -1
  78. package/dist/app/assets/index-DfekHwwU.js +0 -7
  79. package/dist/app/assets/index-DfekHwwU.js.map +0 -1
  80. package/dist/app/assets/index-Gi97Lmex.js +0 -4
  81. package/dist/app/assets/index-Gi97Lmex.js.map +0 -1
  82. package/dist/app/assets/main-Bm0W4ucz.css +0 -1
  83. package/dist/app/assets/main-DP_okYxh.js +0 -215
  84. package/dist/app/assets/main-DP_okYxh.js.map +0 -1
  85. package/dist/chunks/phase-progress.DPAZ01Gg.js.map +0 -1
package/README.md CHANGED
@@ -23,6 +23,40 @@ bun run dev
23
23
 
24
24
  Open `http://localhost:3333` to access the dashboard.
25
25
 
26
+ ## Reachable from anywhere
27
+
28
+ `paper-camp dev` only answers requests from the machine it runs on, or another
29
+ device on the same LAN/tailnet. To reach it from the hosted client on a
30
+ different machine over the open internet, run:
31
+
32
+ ```bash
33
+ paper-camp dev --share
34
+ ```
35
+
36
+ This opens an account-less `cloudflared` quick tunnel and prints a
37
+ registration link with its `https://…trycloudflare.com` address baked in —
38
+ open that link in the hosted client and it's paired. The address changes every
39
+ restart; that's the trade for needing no setup and no account.
40
+
41
+ ### Already on Tailscale?
42
+
43
+ If every machine involved is already on your tailnet, `tailscale serve` gives
44
+ you a stable address and a real certificate with no third party in the path —
45
+ worth it if you have Tailscale, but more setup than `--share`:
46
+
47
+ 1. Enable HTTPS certificates for your tailnet once, in the
48
+ [Tailscale admin console](https://login.tailscale.com/admin/dns) under
49
+ **DNS → HTTPS Certificates**.
50
+ 2. From the machine running `paper-camp dev`, serve it over HTTPS at a stable
51
+ MagicDNS address:
52
+ ```bash
53
+ sudo tailscale serve --bg --https=443 / http://localhost:3333
54
+ ```
55
+ The first run needs `sudo` so Tailscale can provision the certificate.
56
+ 3. Open `https://<your-machine>.<your-tailnet>.ts.net/` — directly, or pasted
57
+ into the hosted client — from any device on the tailnet. Stop sharing with
58
+ `tailscale serve reset`.
59
+
26
60
  ## Pages
27
61
 
28
62
  - **Plans** — Browse and manage plans from `papercamp/plans/`
@@ -0,0 +1,4 @@
1
+ import{u as b,m as L,r as c,C as O,j as e,G as P,x as T,J as y,H as M,I as B,a as D,K as F,E as U,P as S,L as q,M as E,g as k,S as N,N as V,R as _,O as $,Q as H,i as z,T as G,U as J,V as K,p as A}from"./main-s2b5XHSS.js";import{W as xe}from"./main-s2b5XHSS.js";const w="__no-subject__",W=({horizonTitle:s,item:t,candidateName:o,onClose:d,onPromoted:a})=>{const m=b(x=>x.promoteRoadmapItem),i=b(x=>x.launchIdeaExtend),{subjects:g,available:j}=L(),[u,h]=c.useState(w),[f,n]=c.useState(!1),[p,v]=c.useState(null),{toast:l}=O();c.useEffect(()=>{t&&(h(o?t.name:w),n(!1),v(null))},[t,o]);const r=async()=>{if(!(!t||!s)){n(!0),v(null);try{const x=await m(s,t,u===w?void 0:u,o??void 0),C=b.getState().ideaEntries.find(R=>R.id===x);if(C)try{await i(x,M(C,s))}catch(R){l({title:"Idea created, but the refine agent failed to launch",description:B(R.message),variant:"error"})}a(),d()}catch(x){v(x.message)}finally{n(!1)}}};return e.jsx(P,{open:t!==null,onClose:d,title:o??(t==null?void 0:t.name)??"",size:"small",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[!o&&e.jsx("p",{className:"m-0 opacity-80",children:t==null?void 0:t.description}),e.jsx("div",{children:e.jsx(T,{size:"small",value:u,onChange:h,disabled:f||!j,options:[{value:w,label:"No subject"},...!j&&u!==w?[{value:u,label:u}]:[],...g.map(x=>({value:x,label:x}))]})}),p&&e.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:p}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{type:"button",variant:"ghost",onClick:d,disabled:f,children:"Cancel"}),e.jsx(y,{type:"button",variant:"primary",onClick:r,disabled:f,children:f?"Promoting…":"Promote to idea"})]})]})})},Q=s=>({shipped:s.filter(t=>t.status==="done").length,queued:s.filter(t=>t.status!=="done"&&t.status!=="dropped").length}),Z="font-handwritten text-md font-semibold opacity-70 leading-none pt-2 px-1 pb-0",X=({size:s=14})=>e.jsx("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("polyline",{points:"9 18 15 12 9 6"})}),Y=({name:s,onPromote:t})=>e.jsx(_,{size:"small",texture:"kraft",className:"plan-row-card",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex-1",children:s}),e.jsx(y,{type:"button",variant:"ghost",size:"small",onClick:t,children:"Promote to idea"})]})}),ee=({onAdd:s})=>{const[t,o]=c.useState(""),[d,a]=c.useState(!1),m=async()=>{if(t.trim()){a(!0);try{await s(t.trim()),o("")}finally{a(!1)}}};return e.jsxs("div",{className:"flex gap-2",children:[e.jsx(z,{size:"small",value:t,onChange:i=>o(i.target.value),onKeyDown:i=>{i.key==="Enter"&&m()},placeholder:"Add option…",disabled:d,className:"flex-1"}),e.jsx(y,{type:"button",variant:"ghost",size:"small",onClick:m,disabled:d||!t.trim(),children:"Add"})]})},se=(s,t)=>{const o=new Set,d=t.map(a=>(a.id&&o.add(a.id),a.idea&&o.add(a.idea),{key:a.title,label:a.title,status:a.status,pr:a.pr,planId:a.id,planTitle:a.title}));for(const a of s)o.has(a.id)||d.push({key:a.id,label:a.id,status:a.status,pr:a.pr});return d},te=({idea:s,onOpen:t})=>e.jsx(_,{size:"small",texture:"kraft",className:"plan-row-card",children:e.jsxs("div",{className:"flex items-center gap-3",children:[t?e.jsx("button",{type:"button",onClick:t,className:"flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap bg-transparent border-none p-0 cursor-pointer [font:inherit] text-inherit text-left",children:s.label}):e.jsx("span",{className:"flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap",children:s.label}),s.pr&&e.jsx($,{pr:s.pr}),e.jsx(k,{size:"small",fillColor:N[s.status].fill,textColor:N[s.status].text,children:H[s.status]})]})}),ae=({done:s,total:t})=>{const o=t>0?Math.round(s/t*100):0;return e.jsx("div",{className:"w-24 h-1.5 rounded-full bg-black/[0.08] overflow-hidden shrink-0",children:e.jsx("div",{className:`h-full rounded-full ${t>0?"bg-watercolor-green":"bg-transparent"}`,style:{width:`${o}%`}})})},ne=({item:s,graduated:t,highlighted:o,onPromote:d,onPromoteCandidate:a,onAddCandidate:m,onOpenGraduated:i})=>{const[g,j]=c.useState(o),{shipped:u,queued:h}=Q(t),f=s.candidates.length,n=se(s.links,t);return c.useEffect(()=>{o&&j(!0)},[o]),e.jsxs("div",{className:`border-b border-black/10 last:border-b-0 ${o?"roadmap-item-highlighted outline outline-2 outline-offset-[-2px] outline-[rgba(200,154,90,0.5)]":""}`,children:[e.jsxs("button",{type:"button","aria-expanded":g,onClick:()=>j(p=>!p),className:"flex w-full items-center gap-3 py-2.5 px-0 bg-transparent border-none cursor-pointer text-left [font:inherit] text-inherit",children:[e.jsx("span",{className:`inline-flex items-center opacity-50 shrink-0 ${g?"rotate-90":""}`,children:e.jsx(X,{})}),e.jsx("span",{className:"font-semibold flex-1 min-w-0 truncate",children:s.name}),e.jsx(ae,{done:s.rollup.done,total:s.rollup.total}),h>0&&e.jsxs(k,{size:"small",fillColor:N.planned.fill,textColor:N.planned.text,children:[h," in queue"]}),u>0&&e.jsxs(k,{size:"small",fillColor:N.done.fill,textColor:N.done.text,children:[u," shipped"]}),f>0&&e.jsxs(k,{size:"small",fillColor:"rgba(0, 0, 0, 0.06)",textColor:"rgba(0, 0, 0, 0.55)",children:[f," candidate",f===1?"":"s"]})]}),g&&e.jsxs("div",{className:"flex flex-col gap-1 pl-6 pb-4",children:[e.jsx("span",{className:"text-sm opacity-70",children:s.description}),n.map(p=>e.jsx(te,{idea:p,onOpen:p.planTitle?()=>i(p.planId,p.planTitle):void 0},p.key)),s.candidates.map(p=>e.jsx(Y,{name:p,onPromote:()=>a(p)},p)),e.jsx(ee,{onAdd:m}),e.jsx(y,{type:"button",variant:"ghost",size:"small",onClick:d,className:"self-start",children:"Promote to idea"})]})]})},le=({goal:s})=>{const[t,o]=c.useState(!1),[d,...a]=s.split(/\n{2,}/),m=a.length>0;return e.jsxs("div",{className:"mb-6 pb-4 border-b border-black/[8%]",children:[e.jsx("span",{className:"font-handwritten text-xs font-semibold opacity-[0.55]",children:"The goal"}),e.jsxs("div",{className:"text-sm leading-relaxed opacity-80 mt-2",children:[e.jsx(E,{children:d}),t&&m&&e.jsx(E,{children:a.join(`
2
+
3
+ `)})]}),m&&e.jsx("button",{type:"button",onClick:()=>o(i=>!i),className:"bg-transparent border-none p-0 mt-2 cursor-pointer text-2xs opacity-[0.65] underline",children:t?"Show less":"Show more"})]})},de=()=>{const s=b(l=>l.roadmap),t=b(l=>l.roadmapError),o=b(l=>l.loadRoadmap),d=b(l=>l.roadmapFilters),[a,m]=c.useState(null),i=b(l=>l.plans);D();const g=F(),{item:j}=U({from:"/roadmap"}),u=c.useRef(null);if(c.useEffect(()=>{o()},[o]),c.useEffect(()=>{var r;if(!j||!s)return;const l=(r=u.current)==null?void 0:r.querySelector(".roadmap-item-highlighted");l==null||l.scrollIntoView({behavior:"smooth",block:"center"})},[j,s]),t)return e.jsxs("div",{children:[e.jsx(S,{children:"Roadmap"}),e.jsx("p",{className:"opacity-50",children:"Couldn't load the roadmap — the server may need a restart to pick up new routes."})]});if(!s)return e.jsxs("div",{children:[e.jsx(S,{children:"Roadmap"}),e.jsx("p",{className:"opacity-50",children:"Loading…"})]});if(s.horizons.length===0)return e.jsxs("div",{children:[e.jsx(S,{children:"Roadmap"}),e.jsx("p",{className:"opacity-50",children:"No `ROADMAP.md` found at the project root."})]});const h=l=>(i==null?void 0:i.entries.filter(r=>r.subject===l.name))??[],f=async(l,r,x)=>{await V(l,r,x),await o()},n=q(s,d),p=n.reduce((l,r)=>l+r.items.length,0),v=d.horizons.length>0||d.statuses.length>0;return e.jsxs("div",{ref:u,children:[e.jsx(S,{children:"Roadmap"}),e.jsx(le,{goal:s.goal}),p===0?e.jsx("p",{className:"opacity-50 py-6 px-0 text-center",children:v?"Nothing matches these filters — clear one from the sidebar to see more.":"No roadmap items yet — add one from the sidebar."}):e.jsx("div",{className:"flex flex-col gap-6",children:n.filter(l=>l.items.length>0).map(l=>e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("div",{className:Z,children:l.title}),e.jsx("div",{className:"flex flex-col",children:l.items.map(r=>e.jsx(ne,{item:r,graduated:h(r),highlighted:r.name===j,onPromote:()=>m({horizonTitle:l.title,item:r}),onPromoteCandidate:x=>m({horizonTitle:l.title,item:r,candidateName:x}),onAddCandidate:x=>f(l.title,r.name,x),onOpenGraduated:(x,C)=>g(x,C)},r.name))})]},l.title))}),e.jsx(W,{horizonTitle:(a==null?void 0:a.horizonTitle)??null,item:(a==null?void 0:a.item)??null,candidateName:a==null?void 0:a.candidateName,onClose:()=>m(null),onPromoted:o})]})},oe=({open:s,horizonTitles:t,onClose:o})=>{const d=b(r=>r.loadRoadmap),[a,m]=c.useState(t[0]??""),[i,g]=c.useState(""),[j,u]=c.useState(""),[h,f]=c.useState(!1),[n,p]=c.useState(null),v=c.useRef(t);v.current=t,c.useEffect(()=>{s&&(m(v.current[0]??""),g(""),u(""),p(null),f(!1))},[s]);const l=async()=>{if(!(!i.trim()||!a)){f(!0),p(null);try{await G(a,i.trim(),j.trim()),await d(),o()}catch(r){p(r.message)}finally{f(!1)}}};return e.jsx(P,{open:s,onClose:o,title:"Add roadmap item",size:"small",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(T,{size:"small",value:a,onChange:m,disabled:h,options:t.map(r=>({value:r,label:r}))}),e.jsx(z,{size:"small",value:i,onChange:r=>g(r.target.value),placeholder:"Item name…",disabled:h,autoFocus:!0}),e.jsx(z,{size:"small",value:j,onChange:r=>u(r.target.value),onKeyDown:r=>{r.key==="Enter"&&l()},placeholder:"Description…",disabled:h}),n&&e.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:n}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{type:"button",variant:"ghost",onClick:o,disabled:h,children:"Cancel"}),e.jsx(y,{type:"button",variant:"primary",onClick:l,disabled:h||!i.trim()||!a,children:h?"Adding…":"Add item"})]})]})})},re=["in-progress","review","planned","idea","done","dropped"],I="pc-row-label font-handwritten text-xs font-semibold opacity-[0.45]",ce=()=>{const s=b(n=>n.roadmap),t=b(n=>n.roadmapFilters),o=b(n=>n.toggleRoadmapHorizon),d=b(n=>n.toggleRoadmapStatus),[a,m]=c.useState(!1);if(!s)return null;const i=s.horizons.map(n=>n.title),g=J(s,t),j=K(s,t),u=new Set(t.horizons),h=new Set(t.statuses),f=re.filter(n=>(j[n]??0)>0||h.has(n));return e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"flex h-[64px] items-center",children:e.jsx(y,{type:"button",variant:"primary",size:"small",onClick:()=>m(!0),disabled:i.length===0,children:"+ Add item"})}),e.jsxs("div",{children:[e.jsx("div",{className:I,children:"Horizon"}),e.jsx("div",{className:"flex flex-col",children:i.map(n=>e.jsx(A,{size:"small",active:u.has(n),onClick:()=>o(n),className:"pc-row text-xs",action:e.jsx("span",{className:"text-2xs text-ink-500",children:g[n]??0}),children:n},n))})]}),e.jsxs("div",{children:[e.jsx("div",{className:I,children:"Status"}),e.jsxs("div",{className:"flex flex-col",children:[f.length===0&&e.jsx("span",{className:"opacity-50 text-2xs",children:"No linked ideas"}),f.map(n=>e.jsx(A,{size:"small",active:h.has(n),onClick:()=>d(n),className:"pc-row text-xs",icon:e.jsx("span",{className:"w-[9px] h-[9px] rounded-full shrink-0",style:{background:N[n].text}}),action:e.jsx("span",{className:"text-2xs text-ink-500",children:j[n]??0}),children:H[n]},n))]})]}),e.jsx(oe,{open:a,horizonTitles:i,onClose:()=>m(!1)})]})};export{de as RoadmapPage,ce as RoadmapSidebar,xe as useRoadmapItemNames};
4
+ //# sourceMappingURL=index-BK4XPXt_.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BK4XPXt_.js","sources":["../../../src/app/features/roadmap/promote-roadmap-item-modal.tsx","../../../src/app/features/roadmap/roadmap-page.tsx","../../../src/app/features/roadmap/add-roadmap-item-modal.tsx","../../../src/app/features/roadmap/roadmap-sidebar.tsx"],"sourcesContent":["import { buildRoadmapPromotePrompt } from '@/app/features/plans/prompts';\nimport { useSubjectVocabulary } from '@/app/hooks/use-subject-vocabulary';\nimport { useAppStore } from '@/app/stores/app-store';\nimport { oneLineErrorSummary } from '@/app/utils/error-summary';\nimport type { RoadmapItem } from '@/types/index';\nimport { Button, Modal, Select, useToast } from '@dendelion/paper-ui';\nimport { useEffect, useState } from 'react';\n\nconst NO_SUBJECT = '__no-subject__';\n\ninterface PromoteRoadmapItemModalProps {\n horizonTitle: string | null;\n item: RoadmapItem | null;\n candidateName?: string | null;\n onClose: () => void;\n onPromoted: () => void;\n}\n\nexport const PromoteRoadmapItemModal = ({\n horizonTitle,\n item,\n candidateName,\n onClose,\n onPromoted,\n}: PromoteRoadmapItemModalProps) => {\n const promoteRoadmapItem = useAppStore((s) => s.promoteRoadmapItem);\n const launchIdeaExtend = useAppStore((s) => s.launchIdeaExtend);\n const { subjects, available: subjectsAvailable } = useSubjectVocabulary();\n const [subject, setSubject] = useState(NO_SUBJECT);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const { toast } = useToast();\n\n useEffect(() => {\n if (item) {\n // A candidate defaults to its parent item's name — the \"big bet becomes a\n // Subject\" rule — but the picker still lets the user override it.\n setSubject(candidateName ? item.name : NO_SUBJECT);\n setLoading(false);\n setError(null);\n }\n }, [item, candidateName]);\n\n const handlePromote = async () => {\n if (!item || !horizonTitle) return;\n setLoading(true);\n setError(null);\n try {\n const id = await promoteRoadmapItem(\n horizonTitle,\n item,\n subject === NO_SUBJECT ? undefined : subject,\n candidateName ?? undefined,\n );\n const idea = useAppStore.getState().ideaEntries.find((e) => e.id === id);\n if (idea) {\n try {\n await launchIdeaExtend(id, buildRoadmapPromotePrompt(idea, horizonTitle));\n } catch (err) {\n // The idea was created either way — a failed refine launch just means\n // no background research ran, not that the promotion itself failed.\n toast({\n title: 'Idea created, but the refine agent failed to launch',\n description: oneLineErrorSummary((err as Error).message),\n variant: 'error',\n });\n }\n }\n onPromoted();\n onClose();\n } catch (err) {\n setError((err as Error).message);\n } finally {\n setLoading(false);\n }\n };\n\n return (\n <Modal\n open={item !== null}\n onClose={onClose}\n title={candidateName ?? item?.name ?? ''}\n size=\"small\"\n >\n <div className=\"flex flex-col gap-4\">\n {!candidateName && <p className=\"m-0 opacity-80\">{item?.description}</p>}\n <div>\n <Select\n size=\"small\"\n value={subject}\n onChange={setSubject}\n disabled={loading || !subjectsAvailable}\n options={[\n { value: NO_SUBJECT, label: 'No subject' },\n ...(!subjectsAvailable && subject !== NO_SUBJECT\n ? [{ value: subject, label: subject }]\n : []),\n ...subjects.map((s) => ({ value: s, label: s })),\n ]}\n />\n </div>\n {error && <p className=\"m-0 text-watercolor-rose-dark text-sm\">{error}</p>}\n <div className=\"flex justify-end gap-2\">\n <Button type=\"button\" variant=\"ghost\" onClick={onClose} disabled={loading}>\n Cancel\n </Button>\n <Button type=\"button\" variant=\"primary\" onClick={handlePromote} disabled={loading}>\n {loading ? 'Promoting…' : 'Promote to idea'}\n </Button>\n </div>\n </div>\n </Modal>\n );\n};\n","import { Markdown } from '@/app/components/markdown';\nimport { PageTitle } from '@/app/components/page-title';\nimport { PrBadge } from '@/app/features/plans/components/pr-badge';\nimport { STATUS_LABEL, STATUS_STAMP } from '@/app/features/plans/constants';\nimport { entityRouteParam, useOpenEntity } from '@/app/hooks';\nimport { addRoadmapCandidate } from '@/app/services/content/docs-api';\nimport { useAppStore } from '@/app/stores/app-store';\nimport type {\n PlanEntry,\n PlanStatus,\n PrInfo,\n ResolvedRoadmapItem,\n RoadmapLink,\n} from '@/types/index';\nimport { Button, Card, Input, Stamp } from '@dendelion/paper-ui';\nimport { useNavigate, useSearch } from '@tanstack/react-router';\nimport { useEffect, useRef, useState } from 'react';\nimport { PromoteRoadmapItemModal } from './promote-roadmap-item-modal';\nimport { filterHorizons } from './roadmap-filters';\n\nconst graduationCounts = (graduated: PlanEntry[]) => ({\n shipped: graduated.filter((p) => p.status === 'done').length,\n queued: graduated.filter((p) => p.status !== 'done' && p.status !== 'dropped').length,\n});\n\nconst HORIZON_HEADER_CLASSES =\n 'font-handwritten text-md font-semibold opacity-70 leading-none pt-2 px-1 pb-0';\n\nconst ChevronRightIcon = ({ size = 14 }: { size?: number }) => (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <polyline points=\"9 18 15 12 9 6\" />\n </svg>\n);\n\nconst CandidateRow = ({\n name,\n onPromote,\n}: {\n name: string;\n onPromote: () => void;\n}) => (\n <Card size=\"small\" texture=\"kraft\" className=\"plan-row-card\">\n <div className=\"flex items-center gap-3\">\n <span className=\"flex-1\">{name}</span>\n <Button type=\"button\" variant=\"ghost\" size=\"small\" onClick={onPromote}>\n Promote to idea\n </Button>\n </div>\n </Card>\n);\n\nconst AddCandidateForm = ({ onAdd }: { onAdd: (name: string) => Promise<void> }) => {\n const [name, setName] = useState('');\n const [saving, setSaving] = useState(false);\n\n const handleAdd = async () => {\n if (!name.trim()) return;\n setSaving(true);\n try {\n await onAdd(name.trim());\n setName('');\n } finally {\n setSaving(false);\n }\n };\n\n return (\n <div className=\"flex gap-2\">\n <Input\n size=\"small\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') handleAdd();\n }}\n placeholder=\"Add option…\"\n disabled={saving}\n className=\"flex-1\"\n />\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"small\"\n onClick={handleAdd}\n disabled={saving || !name.trim()}\n >\n Add\n </Button>\n </div>\n );\n};\n\ninterface MergedIdea {\n key: string;\n label: string;\n status: PlanStatus;\n pr?: PrInfo;\n planId?: string;\n planTitle?: string;\n}\n\nconst mergeIdeas = (links: RoadmapLink[], graduated: PlanEntry[]): MergedIdea[] => {\n const represented = new Set<string>();\n const merged: MergedIdea[] = graduated.map((plan) => {\n if (plan.id) represented.add(plan.id);\n if (plan.idea) represented.add(plan.idea);\n return {\n key: plan.title,\n label: plan.title,\n status: plan.status,\n pr: plan.pr,\n planId: plan.id,\n planTitle: plan.title,\n };\n });\n for (const link of links) {\n if (represented.has(link.id)) continue;\n merged.push({ key: link.id, label: link.id, status: link.status, pr: link.pr });\n }\n return merged;\n};\n\nconst IdeaRow = ({ idea, onOpen }: { idea: MergedIdea; onOpen?: () => void }) => (\n <Card size=\"small\" texture=\"kraft\" className=\"plan-row-card\">\n <div className=\"flex items-center gap-3\">\n {onOpen ? (\n <button\n type=\"button\"\n onClick={onOpen}\n className=\"flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap bg-transparent border-none p-0 cursor-pointer [font:inherit] text-inherit text-left\"\n >\n {idea.label}\n </button>\n ) : (\n <span className=\"flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap\">\n {idea.label}\n </span>\n )}\n {idea.pr && <PrBadge pr={idea.pr} />}\n <Stamp\n size=\"small\"\n fillColor={STATUS_STAMP[idea.status].fill}\n textColor={STATUS_STAMP[idea.status].text}\n >\n {STATUS_LABEL[idea.status]}\n </Stamp>\n </div>\n </Card>\n);\n\nconst ProgressBar = ({ done, total }: { done: number; total: number }) => {\n const percent = total > 0 ? Math.round((done / total) * 100) : 0;\n return (\n <div className=\"w-24 h-1.5 rounded-full bg-black/[0.08] overflow-hidden shrink-0\">\n <div\n className={`h-full rounded-full ${total > 0 ? 'bg-watercolor-green' : 'bg-transparent'}`}\n style={{ width: `${percent}%` }}\n />\n </div>\n );\n};\n\nconst RoadmapItemRow = ({\n item,\n graduated,\n highlighted,\n onPromote,\n onPromoteCandidate,\n onAddCandidate,\n onOpenGraduated,\n}: {\n item: ResolvedRoadmapItem;\n graduated: PlanEntry[];\n highlighted: boolean;\n onPromote: () => void;\n onPromoteCandidate: (candidateName: string) => void;\n onAddCandidate: (name: string) => Promise<void>;\n onOpenGraduated: (id: string | undefined, title: string) => void;\n}) => {\n const [expanded, setExpanded] = useState(highlighted);\n const { shipped, queued } = graduationCounts(graduated);\n const candidates = item.candidates.length;\n const ideas = mergeIdeas(item.links, graduated);\n\n useEffect(() => {\n if (highlighted) setExpanded(true);\n }, [highlighted]);\n\n return (\n <div\n className={`border-b border-black/10 last:border-b-0 ${highlighted ? 'roadmap-item-highlighted outline outline-2 outline-offset-[-2px] outline-[rgba(200,154,90,0.5)]' : ''}`}\n >\n <button\n type=\"button\"\n aria-expanded={expanded}\n onClick={() => setExpanded((v) => !v)}\n className=\"flex w-full items-center gap-3 py-2.5 px-0 bg-transparent border-none cursor-pointer text-left [font:inherit] text-inherit\"\n >\n <span\n className={`inline-flex items-center opacity-50 shrink-0 ${expanded ? 'rotate-90' : ''}`}\n >\n <ChevronRightIcon />\n </span>\n <span className=\"font-semibold flex-1 min-w-0 truncate\">{item.name}</span>\n <ProgressBar done={item.rollup.done} total={item.rollup.total} />\n {queued > 0 && (\n <Stamp\n size=\"small\"\n fillColor={STATUS_STAMP.planned.fill}\n textColor={STATUS_STAMP.planned.text}\n >\n {queued} in queue\n </Stamp>\n )}\n {shipped > 0 && (\n <Stamp size=\"small\" fillColor={STATUS_STAMP.done.fill} textColor={STATUS_STAMP.done.text}>\n {shipped} shipped\n </Stamp>\n )}\n {candidates > 0 && (\n <Stamp size=\"small\" fillColor=\"rgba(0, 0, 0, 0.06)\" textColor=\"rgba(0, 0, 0, 0.55)\">\n {candidates} candidate{candidates === 1 ? '' : 's'}\n </Stamp>\n )}\n </button>\n {expanded && (\n <div className=\"flex flex-col gap-1 pl-6 pb-4\">\n <span className=\"text-sm opacity-70\">{item.description}</span>\n {ideas.map((idea) => (\n <IdeaRow\n key={idea.key}\n idea={idea}\n onOpen={\n idea.planTitle\n ? () => onOpenGraduated(idea.planId, idea.planTitle as string)\n : undefined\n }\n />\n ))}\n {item.candidates.map((candidateName) => (\n <CandidateRow\n key={candidateName}\n name={candidateName}\n onPromote={() => onPromoteCandidate(candidateName)}\n />\n ))}\n <AddCandidateForm onAdd={onAddCandidate} />\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"small\"\n onClick={onPromote}\n className=\"self-start\"\n >\n Promote to idea\n </Button>\n </div>\n )}\n </div>\n );\n};\n\nconst GoalBanner = ({ goal }: { goal: string }) => {\n const [expanded, setExpanded] = useState(false);\n const [firstParagraph, ...restParagraphs] = goal.split(/\\n{2,}/);\n const hasMore = restParagraphs.length > 0;\n\n return (\n <div className=\"mb-6 pb-4 border-b border-black/[8%]\">\n <span className=\"font-handwritten text-xs font-semibold opacity-[0.55]\">The goal</span>\n <div className=\"text-sm leading-relaxed opacity-80 mt-2\">\n <Markdown>{firstParagraph}</Markdown>\n {expanded && hasMore && <Markdown>{restParagraphs.join('\\n\\n')}</Markdown>}\n </div>\n {hasMore && (\n <button\n type=\"button\"\n onClick={() => setExpanded((v) => !v)}\n className=\"bg-transparent border-none p-0 mt-2 cursor-pointer text-2xs opacity-[0.65] underline\"\n >\n {expanded ? 'Show less' : 'Show more'}\n </button>\n )}\n </div>\n );\n};\n\nexport const RoadmapPage = () => {\n const roadmap = useAppStore((s) => s.roadmap);\n const roadmapError = useAppStore((s) => s.roadmapError);\n const loadRoadmap = useAppStore((s) => s.loadRoadmap);\n const filters = useAppStore((s) => s.roadmapFilters);\n const [promoting, setPromoting] = useState<{\n horizonTitle: string;\n item: ResolvedRoadmapItem;\n candidateName?: string;\n } | null>(null);\n const plans = useAppStore((s) => s.plans);\n const navigate = useNavigate();\n const openEntity = useOpenEntity();\n const { item: highlightedItem } = useSearch({ from: '/roadmap' });\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n loadRoadmap();\n }, [loadRoadmap]);\n\n useEffect(() => {\n if (!highlightedItem || !roadmap) return;\n const row = containerRef.current?.querySelector('.roadmap-item-highlighted');\n row?.scrollIntoView({ behavior: 'smooth', block: 'center' });\n }, [highlightedItem, roadmap]);\n\n if (roadmapError) {\n return (\n <div>\n <PageTitle>Roadmap</PageTitle>\n <p className=\"opacity-50\">\n Couldn't load the roadmap — the server may need a restart to pick up new routes.\n </p>\n </div>\n );\n }\n\n if (!roadmap) {\n return (\n <div>\n <PageTitle>Roadmap</PageTitle>\n <p className=\"opacity-50\">Loading…</p>\n </div>\n );\n }\n\n if (roadmap.horizons.length === 0) {\n return (\n <div>\n <PageTitle>Roadmap</PageTitle>\n <p className=\"opacity-50\">No `ROADMAP.md` found at the project root.</p>\n </div>\n );\n }\n\n const graduatedByItem = (item: ResolvedRoadmapItem) =>\n plans?.entries.filter((p) => p.subject === item.name) ?? [];\n\n const handleAddCandidate = async (horizonTitle: string, itemName: string, name: string) => {\n await addRoadmapCandidate(horizonTitle, itemName, name);\n await loadRoadmap();\n };\n\n const horizons = filterHorizons(roadmap, filters);\n const totalVisible = horizons.reduce((count, horizon) => count + horizon.items.length, 0);\n const hasActiveFilters = filters.horizons.length > 0 || filters.statuses.length > 0;\n\n return (\n <div ref={containerRef}>\n <PageTitle>Roadmap</PageTitle>\n <GoalBanner goal={roadmap.goal} />\n {totalVisible === 0 ? (\n <p className=\"opacity-50 py-6 px-0 text-center\">\n {hasActiveFilters\n ? 'Nothing matches these filters — clear one from the sidebar to see more.'\n : 'No roadmap items yet — add one from the sidebar.'}\n </p>\n ) : (\n <div className=\"flex flex-col gap-6\">\n {horizons\n .filter((horizon) => horizon.items.length > 0)\n .map((horizon) => (\n <div key={horizon.title} className=\"flex flex-col gap-1\">\n <div className={HORIZON_HEADER_CLASSES}>{horizon.title}</div>\n <div className=\"flex flex-col\">\n {horizon.items.map((item) => (\n <RoadmapItemRow\n key={item.name}\n item={item}\n graduated={graduatedByItem(item)}\n highlighted={item.name === highlightedItem}\n onPromote={() => setPromoting({ horizonTitle: horizon.title, item })}\n onPromoteCandidate={(candidateName) =>\n setPromoting({ horizonTitle: horizon.title, item, candidateName })\n }\n onAddCandidate={(name) => handleAddCandidate(horizon.title, item.name, name)}\n onOpenGraduated={(id, title) => openEntity(id, title)}\n />\n ))}\n </div>\n </div>\n ))}\n </div>\n )}\n <PromoteRoadmapItemModal\n horizonTitle={promoting?.horizonTitle ?? null}\n item={promoting?.item ?? null}\n candidateName={promoting?.candidateName}\n onClose={() => setPromoting(null)}\n onPromoted={loadRoadmap}\n />\n </div>\n );\n};\n","import { addRoadmapItem } from '@/app/services/content/docs-api';\nimport { useAppStore } from '@/app/stores/app-store';\nimport { Button, Input, Modal, Select } from '@dendelion/paper-ui';\nimport { useEffect, useRef, useState } from 'react';\n\ninterface AddRoadmapItemModalProps {\n open: boolean;\n horizonTitles: string[];\n onClose: () => void;\n}\n\nexport const AddRoadmapItemModal = ({ open, horizonTitles, onClose }: AddRoadmapItemModalProps) => {\n const loadRoadmap = useAppStore((s) => s.loadRoadmap);\n const [horizon, setHorizon] = useState(horizonTitles[0] ?? '');\n const [name, setName] = useState('');\n const [description, setDescription] = useState('');\n const [saving, setSaving] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const horizonTitlesRef = useRef(horizonTitles);\n horizonTitlesRef.current = horizonTitles;\n\n useEffect(() => {\n if (open) {\n setHorizon(horizonTitlesRef.current[0] ?? '');\n setName('');\n setDescription('');\n setError(null);\n setSaving(false);\n }\n }, [open]);\n\n const handleAdd = async () => {\n if (!name.trim() || !horizon) return;\n setSaving(true);\n setError(null);\n try {\n await addRoadmapItem(horizon, name.trim(), description.trim());\n await loadRoadmap();\n onClose();\n } catch (err) {\n setError((err as Error).message);\n } finally {\n setSaving(false);\n }\n };\n\n return (\n <Modal open={open} onClose={onClose} title=\"Add roadmap item\" size=\"small\">\n <div className=\"flex flex-col gap-4\">\n <Select\n size=\"small\"\n value={horizon}\n onChange={setHorizon}\n disabled={saving}\n options={horizonTitles.map((title) => ({ value: title, label: title }))}\n />\n <Input\n size=\"small\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder=\"Item name…\"\n disabled={saving}\n autoFocus\n />\n <Input\n size=\"small\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') handleAdd();\n }}\n placeholder=\"Description…\"\n disabled={saving}\n />\n {error && <p className=\"m-0 text-watercolor-rose-dark text-sm\">{error}</p>}\n <div className=\"flex justify-end gap-2\">\n <Button type=\"button\" variant=\"ghost\" onClick={onClose} disabled={saving}>\n Cancel\n </Button>\n <Button\n type=\"button\"\n variant=\"primary\"\n onClick={handleAdd}\n disabled={saving || !name.trim() || !horizon}\n >\n {saving ? 'Adding…' : 'Add item'}\n </Button>\n </div>\n </div>\n </Modal>\n );\n};\n","import { STATUS_LABEL, STATUS_STAMP } from '@/app/features/plans/constants';\nimport { useAppStore } from '@/app/stores/app-store';\nimport type { PlanStatus } from '@/types/index';\nimport { Button, ListItem } from '@dendelion/paper-ui';\nimport { useState } from 'react';\nimport { AddRoadmapItemModal } from './add-roadmap-item-modal';\nimport { horizonItemCounts, statusItemCounts } from './roadmap-filters';\n\nconst STATUS_CHIP_ORDER: PlanStatus[] = [\n 'in-progress',\n 'review',\n 'planned',\n 'idea',\n 'done',\n 'dropped',\n];\n\n// Matches SidebarSection — handwritten, no caps, one grid cell.\nconst sectionLabelClass = 'pc-row-label font-handwritten text-xs font-semibold opacity-[0.45]';\n\nexport const RoadmapSidebar = () => {\n const roadmap = useAppStore((s) => s.roadmap);\n const filters = useAppStore((s) => s.roadmapFilters);\n const toggleRoadmapHorizon = useAppStore((s) => s.toggleRoadmapHorizon);\n const toggleRoadmapStatus = useAppStore((s) => s.toggleRoadmapStatus);\n const [addOpen, setAddOpen] = useState(false);\n\n if (!roadmap) return null;\n\n const horizonTitles = roadmap.horizons.map((horizon) => horizon.title);\n const horizonCounts = horizonItemCounts(roadmap, filters);\n const statusCounts = statusItemCounts(roadmap, filters);\n const activeHorizons = new Set(filters.horizons);\n const activeStatuses = new Set(filters.statuses);\n const visibleStatuses = STATUS_CHIP_ORDER.filter(\n (status) => (statusCounts[status] ?? 0) > 0 || activeStatuses.has(status),\n );\n\n return (\n <div className=\"flex flex-col\">\n <div className=\"flex h-[64px] items-center\">\n <Button\n type=\"button\"\n variant=\"primary\"\n size=\"small\"\n onClick={() => setAddOpen(true)}\n disabled={horizonTitles.length === 0}\n >\n + Add item\n </Button>\n </div>\n\n <div>\n <div className={sectionLabelClass}>Horizon</div>\n <div className=\"flex flex-col\">\n {horizonTitles.map((title) => (\n <ListItem\n key={title}\n size=\"small\"\n active={activeHorizons.has(title)}\n onClick={() => toggleRoadmapHorizon(title)}\n className=\"pc-row text-xs\"\n action={<span className=\"text-2xs text-ink-500\">{horizonCounts[title] ?? 0}</span>}\n >\n {title}\n </ListItem>\n ))}\n </div>\n </div>\n\n <div>\n <div className={sectionLabelClass}>Status</div>\n <div className=\"flex flex-col\">\n {visibleStatuses.length === 0 && (\n <span className=\"opacity-50 text-2xs\">No linked ideas</span>\n )}\n {visibleStatuses.map((status) => (\n <ListItem\n key={status}\n size=\"small\"\n active={activeStatuses.has(status)}\n onClick={() => toggleRoadmapStatus(status)}\n className=\"pc-row text-xs\"\n icon={\n <span\n className=\"w-[9px] h-[9px] rounded-full shrink-0\"\n style={{ background: STATUS_STAMP[status].text }}\n />\n }\n action={<span className=\"text-2xs text-ink-500\">{statusCounts[status] ?? 0}</span>}\n >\n {STATUS_LABEL[status]}\n </ListItem>\n ))}\n </div>\n </div>\n\n <AddRoadmapItemModal\n open={addOpen}\n horizonTitles={horizonTitles}\n onClose={() => setAddOpen(false)}\n />\n </div>\n );\n};\n"],"names":["NO_SUBJECT","PromoteRoadmapItemModal","horizonTitle","item","candidateName","onClose","onPromoted","promoteRoadmapItem","useAppStore","s","launchIdeaExtend","subjects","subjectsAvailable","useSubjectVocabulary","subject","setSubject","useState","loading","setLoading","error","setError","toast","useToast","useEffect","handlePromote","id","idea","e","buildRoadmapPromotePrompt","err","oneLineErrorSummary","jsx","Modal","jsxs","Select","Button","graduationCounts","graduated","p","HORIZON_HEADER_CLASSES","ChevronRightIcon","size","CandidateRow","name","onPromote","Card","AddCandidateForm","onAdd","setName","saving","setSaving","handleAdd","Input","mergeIdeas","links","represented","merged","plan","link","IdeaRow","onOpen","PrBadge","Stamp","STATUS_STAMP","STATUS_LABEL","ProgressBar","done","total","percent","RoadmapItemRow","highlighted","onPromoteCandidate","onAddCandidate","onOpenGraduated","expanded","setExpanded","shipped","queued","candidates","ideas","v","GoalBanner","goal","firstParagraph","restParagraphs","hasMore","Markdown","RoadmapPage","roadmap","roadmapError","loadRoadmap","filters","promoting","setPromoting","plans","useNavigate","openEntity","useOpenEntity","highlightedItem","useSearch","containerRef","useRef","row","_a","PageTitle","graduatedByItem","handleAddCandidate","itemName","addRoadmapCandidate","horizons","filterHorizons","totalVisible","count","horizon","hasActiveFilters","title","AddRoadmapItemModal","open","horizonTitles","setHorizon","description","setDescription","horizonTitlesRef","addRoadmapItem","STATUS_CHIP_ORDER","sectionLabelClass","RoadmapSidebar","toggleRoadmapHorizon","toggleRoadmapStatus","addOpen","setAddOpen","horizonCounts","horizonItemCounts","statusCounts","statusItemCounts","activeHorizons","activeStatuses","visibleStatuses","status","ListItem"],"mappings":"qQAQA,MAAMA,EAAa,iBAUNC,EAA0B,CAAC,CACtC,aAAA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b5XHSS.js";function S(a){return Math.floor((Date.now()-Date.parse(a))/864e5)}function L(a){return a.kind==="question"?a.ageDays:S(a.date)}const N=a=>Number.isFinite(a)?a<=0?"today":a===1?"1 day ago":`${a} days ago`:"age unknown",A={completed:"Completed",reply:"Reply"},K=({notification:a,ageDays:o,onOpen:s})=>e.jsxs("div",{className:"flex items-center gap-3 py-2.5 border-b border-black/10 last:border-b-0",children:[e.jsx("button",{type:"button",onClick:s,"aria-label":`Open ${a.entityTitle}`,className:"bg-transparent border-none p-0 cursor-pointer",children:e.jsx(g,{id:a.entityId})}),e.jsx("span",{className:"text-xs uppercase tracking-wide opacity-40 whitespace-nowrap",children:A[a.kind]}),e.jsx("span",{className:"flex-1 min-w-0 truncate",children:a.text}),e.jsx("span",{className:"opacity-50 text-xs whitespace-nowrap",children:N(o)})]}),O=({question:a,plan:o,expanded:s,onToggle:b,onOpen:d,reload:h})=>{const{toast:p}=k(),[n,x]=c.useState(""),{sending:u,send:t,undo:j,undoing:r,undoEdit:y}=w(o,{reload:h,notify:p}),i=`question-reply:${a.entityId}`;c.useEffect(()=>{const f=v(i);f&&x(f)},[i]),c.useEffect(()=>{n&&E(i,n)},[i,n]);const m=async()=>{n.trim()&&await t(n.trim())&&(x(""),$(i))};return e.jsxs("div",{className:"border-b border-black/10 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[e.jsx("button",{type:"button",onClick:d,"aria-label":`Open ${a.entityTitle}`,className:"bg-transparent border-none p-0 cursor-pointer",children:e.jsx(g,{id:a.entityId})}),e.jsx("button",{type:"button",onClick:b,"aria-expanded":s,className:"flex-1 min-w-0 truncate text-left bg-transparent border-none p-0 cursor-pointer",children:a.text}),e.jsx("span",{className:"opacity-50 text-xs whitespace-nowrap",children:N(a.ageDays)})]}),s&&e.jsxs("div",{className:"flex flex-col gap-3 pb-4",children:[e.jsx(I,{messages:o.thread??[],undo:j,undoing:r,onUndo:y}),e.jsx(C,{value:n,onChange:f=>x(f.target.value),"aria-label":`Reply to ${a.entityTitle}`,placeholder:"Reply to resolve and resume…",rows:2,disabled:u}),e.jsxs("div",{className:"flex justify-end items-center gap-3",children:[e.jsx("span",{className:u?"visible":"invisible",children:e.jsx(D,{size:"small",label:"Agent replying…"})}),e.jsx(R,{size:"small",onClick:m,disabled:u||!n.trim(),children:"Reply"})]})]})]})},q=()=>{const[a,o]=c.useState(null),s=l(t=>t.notifications),b=l(t=>t.notificationsError!==null),d=l(t=>t.plans),h=l(t=>t.loadPlans),p=l(t=>t.loadNotifications),n=l(t=>t.markRead),x=T();c.useEffect(()=>{p()},[p]),c.useEffect(()=>{if(s)for(const t of s)t.kind!=="question"&&!t.read&&n(t.id)},[s,n]);const u=async()=>{await Promise.all([h(),p()])};return e.jsxs("div",{children:[e.jsx(P,{children:"Inbox"}),e.jsx("p",{className:"opacity-50 mb-6",children:"Every parked question, completed run, and agent reply, oldest first."}),b&&e.jsx("p",{className:"opacity-50",children:"Couldn't load notifications."}),!b&&!s&&e.jsx("p",{className:"opacity-50",children:"Loading…"}),s&&s.length===0&&e.jsx("p",{className:"opacity-50",children:"Nothing here — no parked questions or recent activity."}),s&&s.length>0&&e.jsx("div",{className:"flex flex-col",children:s.map((t,j)=>{const r=`${t.entityId}-${t.kind}-${j}`,y=()=>x(t.entityId,t.entityTitle);if(t.kind!=="question")return e.jsx(K,{notification:t,ageDays:L(t),onOpen:y},r);const i=d==null?void 0:d.entries.find(m=>m.id===t.entityId);return i?e.jsx(O,{question:t,plan:i,expanded:a===r,onToggle:()=>o(m=>m===r?null:r),onOpen:y,reload:u},r):e.jsxs("div",{className:"flex items-center gap-3 py-2.5 border-b border-black/10 last:border-b-0",children:[e.jsx("button",{type:"button",onClick:y,"aria-label":`Open ${t.entityTitle}`,className:"bg-transparent border-none p-0 cursor-pointer",children:e.jsx(g,{id:t.entityId})}),e.jsx("span",{className:"flex-1 min-w-0 truncate",children:t.text}),e.jsx("span",{className:"opacity-50 text-xs whitespace-nowrap",children:N(t.ageDays)})]},r)})})]})};export{q as InboxPage};
2
+ //# sourceMappingURL=index-BZnU3b_x.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BZnU3b_x.js","sources":["../../../src/core/notifications.ts","../../../src/app/features/inbox/helpers.ts","../../../src/app/features/inbox/notification-row.tsx","../../../src/app/features/inbox/question-row.tsx","../../../src/app/features/inbox/inbox-page.tsx"],"sourcesContent":["import type { Notification, ParkedQuestion, StoredNotification } from '../types/index';\n\nfunction ageInDays(date: string): number {\n return Math.floor((Date.now() - Date.parse(date)) / 86_400_000);\n}\n\nexport function notificationAgeDays(notification: Notification): number {\n return notification.kind === 'question' ? notification.ageDays : ageInDays(notification.date);\n}\n\n/** Every parked question alongside completed/reply notifications, oldest-first — the\n * unified feed (IDEA-153) replacing the questions-only Inbox. */\nexport function mergeNotifications(\n parkedQuestions: ParkedQuestion[],\n stored: StoredNotification[],\n): Notification[] {\n const entries: Notification[] = [\n ...parkedQuestions.map((q): Notification => ({ ...q, kind: 'question' })),\n ...stored,\n ];\n return entries.sort((a, b) => notificationAgeDays(b) - notificationAgeDays(a));\n}\n","export const formatAge = (ageDays: number): string => {\n if (!Number.isFinite(ageDays)) return 'age unknown';\n if (ageDays <= 0) return 'today';\n return ageDays === 1 ? '1 day ago' : `${ageDays} days ago`;\n};\n","import { PlanIdStamp } from '@/app/features/plans/components';\nimport type { StoredNotification } from '@/types/index';\nimport { formatAge } from './helpers';\n\nconst KIND_LABELS: Record<StoredNotification['kind'], string> = {\n completed: 'Completed',\n reply: 'Reply',\n};\n\ninterface NotificationRowProps {\n notification: StoredNotification;\n ageDays: number;\n onOpen: () => void;\n}\n\nexport const NotificationRow = ({ notification, ageDays, onOpen }: NotificationRowProps) => (\n <div className=\"flex items-center gap-3 py-2.5 border-b border-black/10 last:border-b-0\">\n <button\n type=\"button\"\n onClick={onOpen}\n aria-label={`Open ${notification.entityTitle}`}\n className=\"bg-transparent border-none p-0 cursor-pointer\"\n >\n <PlanIdStamp id={notification.entityId} />\n </button>\n <span className=\"text-xs uppercase tracking-wide opacity-40 whitespace-nowrap\">\n {KIND_LABELS[notification.kind]}\n </span>\n <span className=\"flex-1 min-w-0 truncate\">{notification.text}</span>\n <span className=\"opacity-50 text-xs whitespace-nowrap\">{formatAge(ageDays)}</span>\n </div>\n);\n","import { FeedbackThread, PlanIdStamp } from '@/app/features/plans/components';\nimport { useSendFeedbackMessage } from '@/app/features/plans/hooks';\nimport { readLocalDraft, removeLocalDraft, writeLocalDraft } from '@/app/utils/local-draft-store';\nimport type { ParkedQuestion, PlanEntry } from '@/types/index';\nimport { Button, Spinner, Textarea, useToast } from '@dendelion/paper-ui';\nimport { useEffect, useState } from 'react';\nimport { formatAge } from './helpers';\n\ninterface QuestionRowProps {\n question: ParkedQuestion;\n plan: PlanEntry;\n expanded: boolean;\n onToggle: () => void;\n onOpen: () => void;\n reload: () => Promise<void>;\n}\n\nexport const QuestionRow = ({\n question,\n plan,\n expanded,\n onToggle,\n onOpen,\n reload,\n}: QuestionRowProps) => {\n const { toast } = useToast();\n const [input, setInput] = useState('');\n const { sending, send, undo, undoing, undoEdit } = useSendFeedbackMessage(plan, {\n reload,\n notify: toast,\n });\n\n const draftKey = `question-reply:${question.entityId}`;\n\n useEffect(() => {\n const draft = readLocalDraft<string>(draftKey);\n if (draft) setInput(draft);\n }, [draftKey]);\n\n useEffect(() => {\n if (!input) return;\n writeLocalDraft(draftKey, input);\n }, [draftKey, input]);\n\n const handleSend = async () => {\n if (!input.trim()) return;\n if (await send(input.trim())) {\n setInput('');\n removeLocalDraft(draftKey);\n }\n };\n\n return (\n <div className=\"border-b border-black/10 last:border-b-0\">\n <div className=\"flex items-center gap-3 py-2.5\">\n <button\n type=\"button\"\n onClick={onOpen}\n aria-label={`Open ${question.entityTitle}`}\n className=\"bg-transparent border-none p-0 cursor-pointer\"\n >\n <PlanIdStamp id={question.entityId} />\n </button>\n <button\n type=\"button\"\n onClick={onToggle}\n aria-expanded={expanded}\n className=\"flex-1 min-w-0 truncate text-left bg-transparent border-none p-0 cursor-pointer\"\n >\n {question.text}\n </button>\n <span className=\"opacity-50 text-xs whitespace-nowrap\">{formatAge(question.ageDays)}</span>\n </div>\n {expanded && (\n <div className=\"flex flex-col gap-3 pb-4\">\n <FeedbackThread\n messages={plan.thread ?? []}\n undo={undo}\n undoing={undoing}\n onUndo={undoEdit}\n />\n <Textarea\n value={input}\n onChange={(e) => setInput(e.target.value)}\n aria-label={`Reply to ${question.entityTitle}`}\n placeholder=\"Reply to resolve and resume…\"\n rows={2}\n disabled={sending}\n />\n <div className=\"flex justify-end items-center gap-3\">\n <span className={sending ? 'visible' : 'invisible'}>\n <Spinner size=\"small\" label=\"Agent replying…\" />\n </span>\n <Button size=\"small\" onClick={handleSend} disabled={sending || !input.trim()}>\n Reply\n </Button>\n </div>\n </div>\n )}\n </div>\n );\n};\n","import { PageTitle } from '@/app/components/page-title';\nimport { PlanIdStamp } from '@/app/features/plans/components';\nimport { useOpenEntity } from '@/app/hooks';\nimport { useAppStore } from '@/app/stores/app-store';\nimport { notificationAgeDays } from '@/core/notifications';\nimport { useEffect, useState } from 'react';\nimport { formatAge } from './helpers';\nimport { NotificationRow } from './notification-row';\nimport { QuestionRow } from './question-row';\n\nexport const InboxPage = () => {\n const [expandedKey, setExpandedKey] = useState<string | null>(null);\n const notifications = useAppStore((s) => s.notifications);\n const loadFailed = useAppStore((s) => s.notificationsError !== null);\n const plans = useAppStore((s) => s.plans);\n const loadPlans = useAppStore((s) => s.loadPlans);\n const loadNotifications = useAppStore((s) => s.loadNotifications);\n const markRead = useAppStore((s) => s.markRead);\n const openEntity = useOpenEntity();\n\n useEffect(() => {\n loadNotifications();\n }, [loadNotifications]);\n\n useEffect(() => {\n if (!notifications) return;\n for (const n of notifications) {\n if (n.kind !== 'question' && !n.read) markRead(n.id);\n }\n }, [notifications, markRead]);\n\n const reload = async () => {\n await Promise.all([loadPlans(), loadNotifications()]);\n };\n\n return (\n <div>\n <PageTitle>Inbox</PageTitle>\n <p className=\"opacity-50 mb-6\">\n Every parked question, completed run, and agent reply, oldest first.\n </p>\n {loadFailed && <p className=\"opacity-50\">Couldn't load notifications.</p>}\n {!loadFailed && !notifications && <p className=\"opacity-50\">Loading…</p>}\n {notifications && notifications.length === 0 && (\n <p className=\"opacity-50\">Nothing here — no parked questions or recent activity.</p>\n )}\n {notifications && notifications.length > 0 && (\n <div className=\"flex flex-col\">\n {notifications.map((n, i) => {\n const key = `${n.entityId}-${n.kind}-${i}`;\n const onOpen = () => openEntity(n.entityId, n.entityTitle);\n\n if (n.kind !== 'question') {\n return (\n <NotificationRow\n key={key}\n notification={n}\n ageDays={notificationAgeDays(n)}\n onOpen={onOpen}\n />\n );\n }\n\n const plan = plans?.entries.find((p) => p.id === n.entityId);\n if (!plan) {\n return (\n <div\n key={key}\n className=\"flex items-center gap-3 py-2.5 border-b border-black/10 last:border-b-0\"\n >\n <button\n type=\"button\"\n onClick={onOpen}\n aria-label={`Open ${n.entityTitle}`}\n className=\"bg-transparent border-none p-0 cursor-pointer\"\n >\n <PlanIdStamp id={n.entityId} />\n </button>\n <span className=\"flex-1 min-w-0 truncate\">{n.text}</span>\n <span className=\"opacity-50 text-xs whitespace-nowrap\">\n {formatAge(n.ageDays)}\n </span>\n </div>\n );\n }\n return (\n <QuestionRow\n key={key}\n question={n}\n plan={plan}\n expanded={expandedKey === key}\n onToggle={() => setExpandedKey((cur) => (cur === key ? null : key))}\n onOpen={onOpen}\n reload={reload}\n />\n );\n })}\n </div>\n )}\n </div>\n );\n};\n"],"names":["ageInDays","date","notificationAgeDays","notification","formatAge","ageDays","KIND_LABELS","NotificationRow","onOpen","jsxs","jsx","PlanIdStamp","QuestionRow","question","plan","expanded","onToggle","reload","toast","useToast","input","setInput","useState","sending","send","undo","undoing","undoEdit","useSendFeedbackMessage","draftKey","useEffect","draft","readLocalDraft","writeLocalDraft","handleSend","removeLocalDraft","FeedbackThread","Textarea","e","Spinner","Button","InboxPage","expandedKey","setExpandedKey","notifications","useAppStore","s","loadFailed","plans","loadPlans","loadNotifications","markRead","openEntity","useOpenEntity","n","PageTitle","i","key","p","cur"],"mappings":"4IAEA,SAASA,EAAUC,EAAsB,CACvC,OAAO,KAAK,OAAO,KAAK,MAAQ,KAAK,MAAMA,CAAI,GAAK,KAAU,CAChE,CAEO,SAASC,EAAoBC,EAAoC,CACtE,OAAOA,EAAa,OAAS,WAAaA,EAAa,QAAUH,EAAUG,EAAa,IAAI,CAC9F,CCRO,MAAMC,EAAaC,GACnB,OAAO,SAASA,CAAO,EACxBA,GAAW,EAAU,QAClBA,IAAY,EAAI,YAAc,GAAGA,CAAO,YAFT,cCGlCC,EAA0D,CAC9D,UAAW,YACX,MAAO,OACT,EAQaC,EAAkB,CAAC,CAAE,aAAAJ,EAAc,QAAAE,EAAS,OAAAG,KACvDC,EAAAA,KAAC,MAAA,CAAI,UAAU,0EACb,SAAA,CAAAC,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,QAASF,EACT,aAAY,QAAQL,EAAa,WAAW,GAC5C,UAAU,gDAEV,SAAAO,EAAAA,IAACC,EAAA,CAAY,GAAIR,EAAa,QAAA,CAAU,CAAA,CAAA,QAEzC,OAAA,CAAK,UAAU,+DACb,SAAAG,EAAYH,EAAa,IAAI,EAChC,EACAO,EAAAA,IAAC,OAAA,CAAK,UAAU,0BAA2B,WAAa,KAAK,QAC5D,OAAA,CAAK,UAAU,uCAAwC,SAAAN,EAAUC,CAAO,CAAA,CAAE,CAAA,EAC7E,ECbWO,EAAc,CAAC,CAC1B,SAAAC,EACA,KAAAC,EACA,SAAAC,EACA,SAAAC,EACA,OAAAR,EACA,OAAAS,CACF,IAAwB,CACtB,KAAM,CAAE,MAAAC,CAAA,EAAUC,EAAA,EACZ,CAACC,EAAOC,CAAQ,EAAIC,EAAAA,SAAS,EAAE,EAC/B,CAAE,QAAAC,EAAS,KAAAC,EAAM,KAAAC,EAAM,QAAAC,EAAS,SAAAC,CAAA,EAAaC,EAAuBd,EAAM,CAC9E,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J,CAEJ"}
@@ -0,0 +1,2 @@
1
+ import{j as a,ag as L,ak as R,J as v,a7 as N,r as p,u as i,a4 as C,K,P as S,an as D,ao as M}from"./main-s2b5XHSS.js";const w=(o,t)=>`${o}:${t}`;function z(o){return o.filter(t=>t.outcome==="error").map(t=>{const n=t.planId??t.id;return{id:w("agent-run",n),sourceKind:"agent-run",sourceKey:n,entityId:t.planId,entityTitle:t.planTitle,title:`${t.planTitle} — ${t.taskKind} failed`,reason:t.reason??"The run ended in error with no reason recorded.",occurredAt:t.endedAt,thread:[],status:"open"}})}function O(o){return o.filter(t=>t.status==="fail").map(t=>({id:w("check",t.name),sourceKind:"check",sourceKey:t.name,title:`"${t.name}" check is failing`,reason:`The command was \`${t.cmd}\`.`,output:t.output||void 0,occurredAt:t.lastRun??void 0,thread:[],status:"open"}))}function q(o){return o.filter(t=>{var n;return((n=t.pr)==null?void 0:n.reviewDecision)==="changes-requested"}).map(t=>{const n=t.pr,r=`${n.number}:${n.headSha??"unknown"}`;return{id:w("pr-review",r),sourceKind:"pr-review",sourceKey:r,entityId:t.id,entityTitle:t.title,title:`${t.title} — PR review requested changes`,reason:`PR #${n.number} has unresolved change requests.`,thread:[],status:"open"}})}function J(o,t){return o.map(n=>{var l;const r=t.find(s=>s.issueSource===n.id);if(r!=null&&r.id)return{...n,promotedFixId:r.id};const d=n.entityId?t.find(s=>s.id===n.entityId):void 0;return((l=d==null?void 0:d.fixes)==null?void 0:l.some(s=>s.source==="issue"&&s.text===n.title))&&(d!=null&&d.id)?{...n,promotedFixId:d.id}:n}).filter(n=>{const r=n.promotedFixId&&t.find(d=>d.id===n.promotedFixId);return!(r&&r.status==="done")})}function B(o,t){return t.filter(n=>n.issueId===o.id).sort((n,r)=>n.endedAt.localeCompare(r.endedAt)).map(n=>({kind:"log",date:n.endedAt.slice(0,10),from:"agent",text:n.outcome==="done"?"Ran a fix agent — finished.":n.outcome==="error"?`Ran a fix agent — failed: ${n.reason??"no reason recorded"}`:"Ran a fix agent — superseded by a newer run."}))}const U=o=>{if(!o)return"";const t=Math.floor((Date.now()-Date.parse(o))/864e5);return Number.isFinite(t)?t<=0?"today":t===1?"1 day ago":`${t} days ago`:""},$="9999-12-31T23:59:59.999Z",V=o=>[...o].sort((t,n)=>(t.occurredAt??$).localeCompare(n.occurredAt??$)),Z=({issue:o,expanded:t,onToggle:n,onOpen:r,fixing:d,fixDisabled:m,onFix:l,promoteLabel:s,promoting:u,promoteDisabled:I,onPromote:b,onOpenPromoted:y})=>{const j=async()=>{try{await l()}catch(c){alert(c.message)}},g=async()=>{try{await b()}catch(c){alert(c.message)}};return a.jsxs("div",{className:"border-b border-black/10 last:border-b-0",children:[a.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[r&&a.jsx("button",{type:"button",onClick:r,"aria-label":`Open ${o.entityTitle}`,className:"bg-transparent border-none p-0 cursor-pointer",children:a.jsx(L,{id:o.entityId})}),a.jsx("button",{type:"button",onClick:n,"aria-expanded":t,className:"flex-1 min-w-0 truncate text-left bg-transparent border-none p-0 cursor-pointer",children:o.title}),a.jsx("span",{className:"opacity-50 text-xs whitespace-nowrap",children:U(o.occurredAt)})]}),t&&a.jsxs("div",{className:"flex flex-col gap-3 pb-4",children:[a.jsx("p",{children:o.reason}),o.output&&a.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap text-left font-mono text-2xs opacity-70",children:o.output}),o.thread.length>0&&a.jsx(R,{messages:o.thread,undo:null,undoing:!1,onUndo:()=>{}}),a.jsx("div",{className:"flex items-center gap-3",children:o.promotedFixId?a.jsxs(v,{size:"small",onClick:y,children:["View ",o.promotedFixId]}):a.jsxs(a.Fragment,{children:[a.jsx(v,{size:"small",onClick:j,disabled:m,children:d?"Fixing…":"Fix it here"}),d&&a.jsx(N,{size:"small",label:"Agent fixing…"}),a.jsx(v,{size:"small",onClick:g,disabled:I,children:u?"Promoting…":s}),u&&a.jsx(N,{size:"small",label:"Promoting…"})]})})]})]})},_=(o,t)=>{const n=o.entityId?t.find(r=>r.id===o.entityId):void 0;return n?M(n)?"Promote to fix":`Add to ${n.id}'s fixes`:"Promote to idea"},H=()=>{var T;const[o,t]=p.useState(null),[n,r]=p.useState(null),d=i(e=>e.taskLog),m=i(e=>e.taskLogLoading),l=i(e=>e.loadTaskLog),s=i(e=>e.plans),u=i(e=>e.ideaEntries),I=i(e=>e.agentStatus),b=i(e=>e.launchIssueFix),y=i(e=>e.loadPlans),j=i(e=>e.loadIdeas),{checks:g}=C(),c=K();p.useEffect(()=>{l()},[l]);const P=p.useMemo(()=>((s==null?void 0:s.entries)??[]).filter(e=>e.id!=null),[s]),x=p.useMemo(()=>[...P,...u].filter(e=>e.id!=null),[P,u]),f=p.useMemo(()=>{const e=V([...z(d),...O(g),...q(x)]);return J(e,x).map(h=>({...h,thread:B(h,d)}))},[d,g,x]),E=async e=>{r(e.id);try{await D(e),await Promise.all([y(),j()])}finally{r(null)}},F=(T=I.find(e=>e.taskKind==="issue-fix"&&e.status!=="done"&&e.status!=="error"&&e.status!=="superseded"))==null?void 0:T.issueId;return a.jsxs("div",{children:[a.jsx(S,{children:"Issues"}),a.jsx("p",{className:"opacity-50 mb-6",children:"Every failing agent run, red check, and PR review, oldest first."}),m&&f.length===0&&a.jsx("p",{className:"opacity-50",children:"Loading…"}),!m&&f.length===0&&a.jsx("p",{className:"opacity-50",children:"Nothing broken right now."}),f.length>0&&a.jsx("div",{className:"flex flex-col",children:f.map(e=>{var A;const h=e.promotedFixId?((A=x.find(k=>k.id===e.promotedFixId))==null?void 0:A.title)??e.promotedFixId:void 0;return a.jsx(Z,{issue:e,expanded:o===e.id,onToggle:()=>t(k=>k===e.id?null:e.id),onOpen:e.entityId&&e.entityTitle?()=>c(e.entityId,e.entityTitle):void 0,fixing:F===e.id,fixDisabled:F!==void 0,onFix:()=>b(e.id,e.title,e.reason,e.output),promoteLabel:_(e,x),promoting:n===e.id,promoteDisabled:n!==null,onPromote:()=>E(e),onOpenPromoted:e.promotedFixId?()=>c(e.promotedFixId,h):void 0},e.id)})})]})};export{H as IssuesPage};
2
+ //# sourceMappingURL=index-BxQBW2Oi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BxQBW2Oi.js","sources":["../../../src/core/issues.ts","../../../src/app/features/issues/helpers.ts","../../../src/app/features/issues/issue-row.tsx","../../../src/app/features/issues/issues-page.tsx"],"sourcesContent":["import type {\n DeskCheckState,\n EntityStatus,\n GitSyncFailure,\n Issue,\n PhaseItem,\n PrInfo,\n TaskLogEntry,\n ThreadMessage,\n} from '../types/index';\n\nconst issueId = (sourceKind: Issue['sourceKind'], sourceKey: string): string =>\n `${sourceKind}:${sourceKey}`;\n\n/** A failed agent run (`outcome: 'error'` in tasks.log), keyed by the plan it ran\n * against so a repeat failure on the same plan continues one issue. Runs with no\n * `planId` (e.g. a batch task) key off their own task id instead. */\nexport function collectAgentRunIssues(taskLog: TaskLogEntry[]): Issue[] {\n return taskLog\n .filter((entry) => entry.outcome === 'error')\n .map((entry) => {\n const sourceKey = entry.planId ?? entry.id;\n return {\n id: issueId('agent-run', sourceKey),\n sourceKind: 'agent-run',\n sourceKey,\n entityId: entry.planId,\n entityTitle: entry.planTitle,\n title: `${entry.planTitle} — ${entry.taskKind} failed`,\n reason: entry.reason ?? 'The run ended in error with no reason recorded.',\n occurredAt: entry.endedAt,\n thread: [],\n status: 'open',\n };\n });\n}\n\n/** A red project check (Quality/Tests/Consistency — Docs keeps its own browse flow\n * and is excluded, same carve-out as `buildCheckFixes`), keyed by check name. */\nexport function collectCheckIssues(checks: DeskCheckState[]): Issue[] {\n return checks\n .filter((check) => check.status === 'fail')\n .map((check) => ({\n id: issueId('check', check.name),\n sourceKind: 'check',\n sourceKey: check.name,\n title: `\"${check.name}\" check is failing`,\n reason: `The command was \\`${check.cmd}\\`.`,\n output: check.output || undefined,\n occurredAt: check.lastRun ?? undefined,\n thread: [],\n status: 'open',\n }));\n}\n\n/** A PR review that requested changes, keyed by PR number + head sha so a fresh\n * push that gets re-reviewed continues the same issue rather than a new one. */\nexport function collectPrReviewIssues(\n entities: { id: string; title: string; pr?: PrInfo }[],\n): Issue[] {\n return entities\n .filter((entity) => entity.pr?.reviewDecision === 'changes-requested')\n .map((entity) => {\n const pr = entity.pr as PrInfo;\n const sourceKey = `${pr.number}:${pr.headSha ?? 'unknown'}`;\n return {\n id: issueId('pr-review', sourceKey),\n sourceKind: 'pr-review',\n sourceKey,\n entityId: entity.id,\n entityTitle: entity.title,\n title: `${entity.title} — PR review requested changes`,\n reason: `PR #${pr.number} has unresolved change requests.`,\n thread: [],\n status: 'open',\n };\n });\n}\n\n/** A git rebase/sync failure on the currently checked-out branch, keyed by branch +\n * the ref it failed to reconcile against so a repeat failure of the same rebase\n * continues one issue. */\nexport function collectSyncIssues(\n failure: GitSyncFailure | undefined,\n branch: string,\n entity?: { id: string; title: string },\n): Issue[] {\n if (!failure) return [];\n const sourceKey = `${branch}:${failure.conflictRef ?? failure.stage}`;\n return [\n {\n id: issueId('sync', sourceKey),\n sourceKind: 'sync',\n sourceKey,\n entityId: entity?.id,\n entityTitle: entity?.title,\n title: `${branch} failed to sync`,\n reason: failure.message,\n output: failure.conflictedFiles?.length\n ? `Conflicted files: ${failure.conflictedFiles.join(', ')}`\n : undefined,\n thread: [],\n status: 'open',\n },\n ];\n}\n\n/** Reconciles freshly-collected issues (every one currently detected as failing, so\n * always 'open') against the existing set, keyed by `id`. A repeat failure of the\n * same thing replaces that issue's title/reason/output in place, preserving its\n * position and its thread. An existing issue absent from `fresh` has stopped\n * failing, so it closes — unless it was promoted to a fix entity that hasn't\n * shipped yet (`fixEntityStatus` reports its status), which keeps it open until\n * that entity reaches 'done'. Closure is derived here, never a mark-read button. */\nexport function reconcileIssues(\n existing: Issue[],\n fresh: Issue[],\n fixEntityStatus: (fixId: string) => EntityStatus | undefined = () => undefined,\n): Issue[] {\n const freshById = new Map(fresh.map((issue) => [issue.id, issue]));\n const merged = existing.map((issue): Issue => {\n if (issue.promotedFixId && fixEntityStatus(issue.promotedFixId) === 'done') {\n freshById.delete(issue.id);\n return { ...issue, status: 'closed' };\n }\n const next = freshById.get(issue.id);\n if (!next) return { ...issue, status: 'closed' };\n freshById.delete(issue.id);\n return { ...next, thread: issue.thread, promotedFixId: issue.promotedFixId };\n });\n return [...merged, ...freshById.values()];\n}\n\n/** A spawned fix/idea entity from Promote (IDEA-192 phase 6) stamps `issueSource`;\n * an open parent instead gets a `source: 'issue'` item appended to its inline Fixes list. */\ntype PromotionTarget = {\n id?: string;\n status?: EntityStatus;\n issueSource?: string;\n fixes?: PhaseItem[];\n};\n\n/** Matches every issue against the corpus for a prior Promote (IDEA-192 phase 6),\n * re-derived from disk on every read since issues carry no store of their own —\n * the promotion survives a reload because git holds it, not a stored issue. Once\n * matched, an issue whose target has shipped (`status: 'done'`) closes, even if\n * its original source is still detected as failing. */\nexport function applyPromotions(issues: Issue[], entities: PromotionTarget[]): Issue[] {\n return issues\n .map((issue): Issue => {\n const spawned = entities.find((e) => e.issueSource === issue.id);\n if (spawned?.id) return { ...issue, promotedFixId: spawned.id };\n const parent = issue.entityId ? entities.find((e) => e.id === issue.entityId) : undefined;\n const appended = parent?.fixes?.some((f) => f.source === 'issue' && f.text === issue.title);\n return appended && parent?.id ? { ...issue, promotedFixId: parent.id } : issue;\n })\n .filter((issue) => {\n const target = issue.promotedFixId && entities.find((e) => e.id === issue.promotedFixId);\n return !(target && target.status === 'done');\n });\n}\n\n/** \"Fix it here\" (IDEA-192) launches an `issue-fix` task carrying the issue's id;\n * this reconstructs that issue's thread from every tasks.log entry carrying it,\n * oldest first, so a repeat fix attempt reads as a continuation, not a fresh mystery. */\nexport function issueThreadFromTaskLog(issue: Issue, taskLog: TaskLogEntry[]): ThreadMessage[] {\n return taskLog\n .filter((entry) => entry.issueId === issue.id)\n .sort((a, b) => a.endedAt.localeCompare(b.endedAt))\n .map((entry) => ({\n kind: 'log',\n date: entry.endedAt.slice(0, 10),\n from: 'agent',\n text:\n entry.outcome === 'done'\n ? 'Ran a fix agent — finished.'\n : entry.outcome === 'error'\n ? `Ran a fix agent — failed: ${entry.reason ?? 'no reason recorded'}`\n : 'Ran a fix agent — superseded by a newer run.',\n }));\n}\n","export const formatIssueAge = (occurredAt: string | undefined): string => {\n if (!occurredAt) return '';\n const ageDays = Math.floor((Date.now() - Date.parse(occurredAt)) / 86_400_000);\n if (!Number.isFinite(ageDays)) return '';\n if (ageDays <= 0) return 'today';\n return ageDays === 1 ? '1 day ago' : `${ageDays} days ago`;\n};\n\n// Missing timestamps (a live PR review decision) sort last, not first.\nconst NO_TIMESTAMP = '9999-12-31T23:59:59.999Z';\nexport const sortIssuesByAge = <T extends { occurredAt?: string }>(issues: T[]): T[] =>\n [...issues].sort((a, b) =>\n (a.occurredAt ?? NO_TIMESTAMP).localeCompare(b.occurredAt ?? NO_TIMESTAMP),\n );\n","import { FeedbackThread, PlanIdStamp } from '@/app/features/plans/components';\nimport type { Issue } from '@/types/index';\nimport { Button, Spinner } from '@dendelion/paper-ui';\nimport { formatIssueAge } from './helpers';\n\ninterface IssueRowProps {\n issue: Issue;\n expanded: boolean;\n onToggle: () => void;\n onOpen?: () => void;\n fixing: boolean;\n fixDisabled: boolean;\n onFix: () => Promise<void>;\n promoteLabel: string;\n promoting: boolean;\n promoteDisabled: boolean;\n onPromote: () => Promise<void>;\n onOpenPromoted?: () => void;\n}\n\nexport const IssueRow = ({\n issue,\n expanded,\n onToggle,\n onOpen,\n fixing,\n fixDisabled,\n onFix,\n promoteLabel,\n promoting,\n promoteDisabled,\n onPromote,\n onOpenPromoted,\n}: IssueRowProps) => {\n const handleFix = async () => {\n try {\n await onFix();\n } catch (err) {\n alert((err as Error).message);\n }\n };\n\n const handlePromote = async () => {\n try {\n await onPromote();\n } catch (err) {\n alert((err as Error).message);\n }\n };\n\n return (\n <div className=\"border-b border-black/10 last:border-b-0\">\n <div className=\"flex items-center gap-3 py-2.5\">\n {onOpen && (\n <button\n type=\"button\"\n onClick={onOpen}\n aria-label={`Open ${issue.entityTitle}`}\n className=\"bg-transparent border-none p-0 cursor-pointer\"\n >\n <PlanIdStamp id={issue.entityId} />\n </button>\n )}\n <button\n type=\"button\"\n onClick={onToggle}\n aria-expanded={expanded}\n className=\"flex-1 min-w-0 truncate text-left bg-transparent border-none p-0 cursor-pointer\"\n >\n {issue.title}\n </button>\n <span className=\"opacity-50 text-xs whitespace-nowrap\">\n {formatIssueAge(issue.occurredAt)}\n </span>\n </div>\n {expanded && (\n <div className=\"flex flex-col gap-3 pb-4\">\n <p>{issue.reason}</p>\n {issue.output && (\n <pre className=\"max-h-48 overflow-auto whitespace-pre-wrap text-left font-mono text-2xs opacity-70\">\n {issue.output}\n </pre>\n )}\n {issue.thread.length > 0 && (\n <FeedbackThread messages={issue.thread} undo={null} undoing={false} onUndo={() => {}} />\n )}\n <div className=\"flex items-center gap-3\">\n {issue.promotedFixId ? (\n <Button size=\"small\" onClick={onOpenPromoted}>\n View {issue.promotedFixId}\n </Button>\n ) : (\n <>\n <Button size=\"small\" onClick={handleFix} disabled={fixDisabled}>\n {fixing ? 'Fixing…' : 'Fix it here'}\n </Button>\n {fixing && <Spinner size=\"small\" label=\"Agent fixing…\" />}\n <Button size=\"small\" onClick={handlePromote} disabled={promoteDisabled}>\n {promoting ? 'Promoting…' : promoteLabel}\n </Button>\n {promoting && <Spinner size=\"small\" label=\"Promoting…\" />}\n </>\n )}\n </div>\n </div>\n )}\n </div>\n );\n};\n","import { PageTitle } from '@/app/components/page-title';\nimport { useOpenEntity } from '@/app/hooks';\nimport { useDeskChecks } from '@/app/hooks/use-desk-checks';\nimport { promoteIssue } from '@/app/services/agent-api';\nimport { useAppStore } from '@/app/stores/app-store';\nimport {\n applyPromotions,\n collectAgentRunIssues,\n collectCheckIssues,\n collectPrReviewIssues,\n issueThreadFromTaskLog,\n} from '@/core/issues';\nimport { isClosedEntity } from '@/core/status';\nimport type { EntityStatus, Issue, PlanEntry } from '@/types/index';\nimport { useEffect, useMemo, useState } from 'react';\nimport { sortIssuesByAge } from './helpers';\nimport { IssueRow } from './issue-row';\n\nconst promoteLabel = (\n issue: Issue,\n entities: { id: string; status?: EntityStatus; archived?: boolean }[],\n): string => {\n const parent = issue.entityId ? entities.find((p) => p.id === issue.entityId) : undefined;\n if (!parent) return 'Promote to idea';\n return isClosedEntity(parent) ? 'Promote to fix' : `Add to ${parent.id}'s fixes`;\n};\n\nexport const IssuesPage = () => {\n const [expandedId, setExpandedId] = useState<string | null>(null);\n const [promotingId, setPromotingId] = useState<string | null>(null);\n const taskLog = useAppStore((s) => s.taskLog);\n const taskLogLoading = useAppStore((s) => s.taskLogLoading);\n const loadTaskLog = useAppStore((s) => s.loadTaskLog);\n const plans = useAppStore((s) => s.plans);\n const ideaEntries = useAppStore((s) => s.ideaEntries);\n const agentStatus = useAppStore((s) => s.agentStatus);\n const launchIssueFix = useAppStore((s) => s.launchIssueFix);\n const loadPlans = useAppStore((s) => s.loadPlans);\n const loadIdeas = useAppStore((s) => s.loadIdeas);\n const { checks } = useDeskChecks();\n const openEntity = useOpenEntity();\n\n useEffect(() => {\n loadTaskLog();\n }, [loadTaskLog]);\n\n const planEntities = useMemo(\n () => (plans?.entries ?? []).filter((p): p is PlanEntry & { id: string } => p.id != null),\n [plans],\n );\n\n const entities = useMemo(\n () =>\n [...planEntities, ...ideaEntries].filter(\n (entity): entity is typeof entity & { id: string } => entity.id != null,\n ),\n [planEntities, ideaEntries],\n );\n\n const issues = useMemo(() => {\n const collected = sortIssuesByAge([\n ...collectAgentRunIssues(taskLog),\n ...collectCheckIssues(checks),\n ...collectPrReviewIssues(entities),\n ]);\n return applyPromotions(collected, entities).map((issue) => ({\n ...issue,\n thread: issueThreadFromTaskLog(issue, taskLog),\n }));\n }, [taskLog, checks, entities]);\n\n const handlePromote = async (issue: Issue) => {\n setPromotingId(issue.id);\n try {\n await promoteIssue(issue);\n await Promise.all([loadPlans(), loadIdeas()]);\n } finally {\n setPromotingId(null);\n }\n };\n\n const fixingIssueId = agentStatus.find(\n (t) =>\n t.taskKind === 'issue-fix' &&\n t.status !== 'done' &&\n t.status !== 'error' &&\n t.status !== 'superseded',\n )?.issueId;\n\n return (\n <div>\n <PageTitle>Issues</PageTitle>\n <p className=\"opacity-50 mb-6\">\n Every failing agent run, red check, and PR review, oldest first.\n </p>\n {taskLogLoading && issues.length === 0 && <p className=\"opacity-50\">Loading…</p>}\n {!taskLogLoading && issues.length === 0 && (\n <p className=\"opacity-50\">Nothing broken right now.</p>\n )}\n {issues.length > 0 && (\n <div className=\"flex flex-col\">\n {issues.map((issue) => {\n const promotedTitle = issue.promotedFixId\n ? (entities.find((p) => p.id === issue.promotedFixId)?.title ?? issue.promotedFixId)\n : undefined;\n return (\n <IssueRow\n key={issue.id}\n issue={issue}\n expanded={expandedId === issue.id}\n onToggle={() => setExpandedId((cur) => (cur === issue.id ? null : issue.id))}\n onOpen={\n issue.entityId && issue.entityTitle\n ? () => openEntity(issue.entityId as string, issue.entityTitle as string)\n : undefined\n }\n fixing={fixingIssueId === issue.id}\n fixDisabled={fixingIssueId !== undefined}\n onFix={() => launchIssueFix(issue.id, issue.title, issue.reason, issue.output)}\n promoteLabel={promoteLabel(issue, entities)}\n promoting={promotingId === issue.id}\n promoteDisabled={promotingId !== null}\n onPromote={() => handlePromote(issue)}\n onOpenPromoted={\n issue.promotedFixId\n ? () => openEntity(issue.promotedFixId as string, promotedTitle as string)\n : undefined\n }\n />\n );\n })}\n </div>\n )}\n </div>\n );\n};\n"],"names":["issueId","sourceKind","sourceKey","collectAgentRunIssues","taskLog","entry","collectCheckIssues","checks","check","collectPrReviewIssues","entities","entity","_a","pr","applyPromotions","issues","issue","spawned","e","parent","f","target","issueThreadFromTaskLog","a","b","formatIssueAge","occurredAt","ageDays","NO_TIMESTAMP","sortIssuesByAge","IssueRow","expanded","onToggle","onOpen","fixing","fixDisabled","onFix","promoteLabel","promoting","promoteDisabled","onPromote","onOpenPromoted","handleFix","err","handlePromote","jsxs","jsx","PlanIdStamp","FeedbackThread","Button","Fragment","Spinner","p","isClosedEntity","IssuesPage","expandedId","setExpandedId","useState","promotingId","setPromotingId","useAppStore","s","taskLogLoading","loadTaskLog","plans","ideaEntries","agentStatus","launchIssueFix","loadPlans","loadIdeas","useDeskChecks","openEntity","useOpenEntity","useEffect","planEntities","useMemo","collected","promoteIssue","fixingIssueId","t","PageTitle","promotedTitle","cur"],"mappings":"qHAWA,MAAMA,EAAU,CAACC,EAAiCC,IAChD,GAAGD,CAAU,IAAIC,CAAS,GAKrB,SAASC,EAAsBC,EAAkC,CACtE,OAAOA,EACJ,OAAQC,GAAUA,EAAM,UAAY,OAAO,EAC3C,IAAKA,GAAU,CACd,MAAMH,EAAYG,EAAM,QAAUA,EAAM,GACxC,MAAO,CACL,GAAIL,EAAQ,YAAaE,CAAS,EAClC,WAAY,YACZ,UAAAA,EACA,SAAUG,EAAM,OAChB,YAAaA,EAAM,UACnB,MAAO,GAAGA,EAAM,SAAS,MAAMA,EAAM,QAAQ,UAC7C,OAAQA,EAAM,QAAU,kDACxB,WAAYA,EAAM,QAClB,OAAQ,CAAA,EACR,OAAQ,MAAA,CAEZ,CAAC,CACL,CAIO,SAASC,EAAmBC,EAAmC,CACpE,OAAOA,EACJ,OAAQC,GAAUA,EAAM,SAAW,MAAM,EACzC,IAAKA,IAAW,CACf,GAAIR,EAAQ,QAASQ,EAAM,IAAI,EAC/B,WAAY,QACZ,UAAWA,EAAM,KACjB,MAAO,IAAIA,EAAM,IAAI,qBACrB,OAAQ,qBAAqBA,EAAM,GAAG,MACtC,OAAQA,EAAM,QAAU,OACxB,WAAYA,EAAM,SAAW,OAC7B,OAAQ,CAAA,EACR,OAAQ,MAAA,EACR,CACN,CAIO,SAASC,EACdC,EACS,CACT,OAAOA,EACJ,OAAQC,UAAW,QAAAC,EAAAD,EAAO,KAAP,YAAAC,EAAW,kBAAmB,oBAAmB,EACpE,IAAKD,GAAW,CACf,MAAME,EAAKF,EAAO,GACZT,EAAY,GAAGW,EAAG,MAAM,IAAIA,EAAG,SAAW,SAAS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qB,EAAarB,EAAON,CAAQ,EAC1C,UAAWgD,IAAgB1C,EAAM,GACjC,gBAAiB0C,IAAgB,KACjC,UAAW,IAAMd,EAAc5B,CAAK,EACpC,eACEA,EAAM,cACF,IAAMuD,EAAWvD,EAAM,cAAyBiE,CAAuB,EACvE,MAAA,EAnBDjE,EAAM,EAAA,CAuBjB,CAAC,CAAA,CACH,CAAA,EAEJ,CAEJ"}
@@ -1,6 +1,6 @@
1
- import{j as s,g as v,u as x,a3 as y,a4 as $,a5 as L,r as p,a6 as D,J as C,$ as k,a7 as E,a8 as A,a9 as T,w as I,P as R,aa as _,ab as M,C as U,ac as G,ad as O,ae as z,p as B,af as N,ag as S,K as H}from"./main-DP_okYxh.js";const K=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function W(e){if(!e)return[];const a=(e.endsWith(`
1
+ import{j as s,g as v,u as x,a2 as y,a3 as $,a4 as L,r as p,a5 as D,J as C,$ as k,a6 as E,a7 as A,a8 as T,w as I,P as R,a9 as _,aa as M,C as U,ab as G,ac as O,ad as z,p as B,ae as N,af as S,I as H}from"./main-s2b5XHSS.js";const W=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function K(e){if(!e)return[];const a=(e.endsWith(`
2
2
  `)?e.slice(0,-1):e).split(`
3
- `),t=[];let i=null,l=0,d=0;for(const r of a){const f=r.match(K);if(f){i={header:r,lines:[]},t.push(i),l=Number(f[1]),d=Number(f[2]);continue}i&&(r.startsWith("\\")||(r.startsWith("+")?(i.lines.push({type:"add",text:r.slice(1),oldLine:null,newLine:d}),d++):r.startsWith("-")?(i.lines.push({type:"remove",text:r.slice(1),oldLine:l,newLine:null}),l++):(i.lines.push({type:"context",text:r.startsWith(" ")?r.slice(1):r,oldLine:l,newLine:d}),l++,d++)))}return t}function q(e){return e?[{header:"",lines:(e.endsWith(`
3
+ `),t=[];let i=null,l=0,d=0;for(const r of a){const f=r.match(W);if(f){i={header:r,lines:[]},t.push(i),l=Number(f[1]),d=Number(f[2]);continue}i&&(r.startsWith("\\")||(r.startsWith("+")?(i.lines.push({type:"add",text:r.slice(1),oldLine:null,newLine:d}),d++):r.startsWith("-")?(i.lines.push({type:"remove",text:r.slice(1),oldLine:l,newLine:null}),l++):(i.lines.push({type:"context",text:r.startsWith(" ")?r.slice(1):r,oldLine:l,newLine:d}),l++,d++)))}return t}function q(e){return e?[{header:"",lines:(e.endsWith(`
4
4
  `)?e.slice(0,-1):e).split(`
5
- `).map((t,i)=>({type:"add",text:t,oldLine:null,newLine:i+1}))}]:[]}const F=({additions:e,deletions:a})=>s.jsxs("span",{className:"inline-flex shrink-0 gap-1.5 font-mono text-3xs",children:[s.jsxs("span",{className:"text-watercolor-green-dark",children:["+",e]}),s.jsxs("span",{className:"text-watercolor-rose-dark",children:["-",a]})]});function b(e){const a=e.lastIndexOf("/");return a===-1?{dir:"",base:e}:{dir:e.slice(0,a+1),base:e.slice(a+1)}}const J=({path:e,prefix:a,className:t=""})=>{const{dir:i,base:l}=b(e),d=`${a??""}${i}`;return s.jsxs("span",{className:`flex min-w-0 items-center font-mono ${t}`,children:[d&&s.jsx("span",{className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap opacity-50",children:d}),s.jsx("span",{className:"shrink-0 whitespace-nowrap",children:l})]})},Q={success:"text-watercolor-green-dark",info:"text-watercolor-blue-dark",error:"text-watercolor-rose-dark",warning:"text-watercolor-amber-dark",neutral:"text-watercolor-slate-dark"},V={A:{letter:"A",label:"Added",variant:"success"},M:{letter:"M",label:"Modified",variant:"info"},D:{letter:"D",label:"Deleted",variant:"error"},R:{letter:"R",label:"Renamed",variant:"info"},C:{letter:"C",label:"Copied",variant:"info"},U:{letter:"U",label:"Conflicted",variant:"warning"}},X=e=>{if(e==="??")return{letter:"??",label:"Untracked",variant:"neutral"};const[a,t]=e,i=a!==" "&&a!=="?"?a:t;return V[i]??{letter:i??"?",label:i??"Unknown",variant:"neutral"}},P=({status:e,compact:a=!1})=>{const t=X(e);return a?s.jsx("span",{title:t.label,className:`w-4 shrink-0 text-center font-mono text-3xs font-semibold leading-none ${Q[t.variant]??""}`,children:t.letter}):s.jsx("span",{title:t.label,children:s.jsx(v,{size:"small",variant:t.variant,children:t.letter})})},Y=60,Z={add:"bg-watercolor-green/[18%] text-watercolor-green-dark",remove:"bg-watercolor-rose/[18%] text-watercolor-rose-dark",context:""},ee={add:"+",remove:"-",context:" "},se=({entry:e})=>s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-3",children:[s.jsx(P,{status:e.status}),s.jsx(J,{path:e.path,prefix:e.renameSource?`${e.renameSource} → `:void 0,className:"min-w-0 flex-1 text-xs"}),s.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[e.staged&&s.jsx(v,{size:"small",children:"staged"}),!e.binary&&s.jsx(F,{additions:e.additions,deletions:e.deletions})]})]}),te=({entry:e})=>{if(e.binary)return s.jsx("p",{className:"m-0 opacity-60",children:"Binary file not shown."});if(e.contentKind==="too-large")return s.jsx("p",{className:"m-0 opacity-60",children:"File too large to preview."});const a=e.contentKind==="raw"?q(e.patch):W(e.patch);return a.length===0?e.renameSource?s.jsx("p",{className:"m-0 opacity-60",children:e.additions===0&&e.deletions===0?"Renamed, no content changes.":"Renamed with unrelated content — diff omitted."}):s.jsx("p",{className:"m-0 opacity-60",children:"No changes to preview."}):s.jsx("div",{className:"flex min-w-0 max-w-full flex-col gap-3",children:a.map((t,i)=>s.jsxs("div",{className:"min-w-0 max-w-full",children:[t.header&&s.jsx("div",{className:"mb-1 font-mono text-2xs opacity-50",children:t.header}),s.jsx("pre",{className:"m-0 min-w-0 max-w-full overflow-x-auto font-mono text-2xs leading-normal",children:t.lines.map((l,d)=>s.jsxs("span",{className:`flex ${Z[l.type]}`,children:[s.jsxs("span",{className:"inline-flex shrink-0 select-none gap-2 pr-2 opacity-40","aria-hidden":"true",children:[s.jsx("span",{className:"w-8 text-right",children:l.oldLine??""}),s.jsx("span",{className:"w-8 text-right",children:l.newLine??""})]}),s.jsxs("span",{children:[ee[l.type],l.text]})]},`${l.type}-${d}`))})]},`${t.header}-${i}`))})},ae=({entry:e})=>{const a=x(r=>r.manuallyExpandedDiffPaths.has(e.path)),t=x(r=>r.manuallyCollapsedDiffPaths.has(e.path)),i=x(r=>r.setDiffCollapsed),l=t||!a&&e.additions+e.deletions>Y,d=e.renameSource?`${e.renameSource} → ${e.path}`:e.path;return s.jsxs("div",{"data-diff-path":e.path,className:"min-w-0 max-w-full scroll-mt-4",children:[s.jsx("h2",{className:"sr-only",children:d}),s.jsx(y,{title:s.jsx(se,{entry:e}),expanded:!l,onToggle:()=>i(e.path,!l),children:s.jsx(te,{entry:e})})]})},ie="__git__",ne=()=>!0,le=e=>$(e,{formKey:ie,matchesSuggestionTask:ne}),oe=({state:e,filesEmpty:a})=>{const t=x(n=>n.status),{checks:i}=L(),{qualityStatus:l,testStatus:d,consistencyStatus:r}=p.useMemo(()=>D(t,i),[t,i]),f=[l==="fail"&&"Quality",d==="fail"&&"Tests",r==="fail"&&"Consistency"].filter(n=>n!==!1),u=s.jsx(C,{size:"small",disabled:a||!e.commitTitle.trim()||e.committing||e.commitInFlight,onClick:e.handleCommit,children:e.committing||e.commitInFlight?"Committing…":e.stagedCount>0?`Commit ${e.stagedCount} staged`:"Commit"});return f.length===0?u:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(k,{content:`${f.join(", ")} failing`,children:s.jsx(v,{size:"small",variant:"warning",children:"!"})}),u]})},he=()=>{const e=x(n=>n.diffFiles),a=x(n=>n.diffLoadFailed),t=x(n=>n.loadDiffFiles),i=x(n=>n.setActiveDiffPath),l=p.useRef(null),d=p.useMemo(()=>(e==null?void 0:e.map(n=>({path:n.path,staged:n.staged})))??[],[e]),r=le(d);p.useEffect(()=>{t()},[t]),p.useEffect(()=>{let n;const h=E(w=>{w.message==="changed"&&(n&&clearTimeout(n),n=setTimeout(t,250))}),g=()=>t();return window.addEventListener("focus",g),()=>{n&&clearTimeout(n),window.removeEventListener("focus",g),h()}},[t]),p.useEffect(()=>{const n=l.current;if(!n)return;const h=Array.from(n.querySelectorAll("[data-diff-path]"));if(h.length===0)return;const g=new Set,w=new IntersectionObserver(o=>{for(const m of o)m.isIntersecting?g.add(m.target):g.delete(m.target);const c=h.find(m=>g.has(m));c&&i(c.dataset.diffPath??null)},{rootMargin:"0px 0px -70% 0px"});for(const o of h)w.observe(o);return()=>w.disconnect()},[e,i]);const f="min-h-page",u=s.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[s.jsx(R,{className:"!mb-0",children:"Git"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{}),s.jsx(M,{})]})]});return a?s.jsxs("div",{children:[u,s.jsxs("div",{className:`${f} flex flex-col items-start gap-3`,children:[s.jsx("p",{className:"opacity-50 m-0",children:"Couldn't load the working-tree diff."}),s.jsx(C,{variant:"secondary",size:"small",onClick:t,children:"Retry"})]})]}):e?s.jsxs("div",{children:[u,e.length===0?s.jsx("div",{className:f,children:s.jsx("p",{className:"opacity-50",children:"No changed files."})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sticky top-0 z-10 mb-4 flex items-center gap-2 py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx(T,{state:r,filesEmpty:!1})}),s.jsx(oe,{state:r,filesEmpty:!1})]}),s.jsx("div",{ref:l,className:`flex min-w-0 flex-col gap-6 ${f}`,children:e.map((n,h)=>s.jsxs(p.Fragment,{children:[h>0&&s.jsx(I,{}),s.jsx(ae,{entry:n})]},n.path))})]})]}):s.jsxs("div",{children:[u,s.jsx("div",{className:f,children:s.jsx(A,{label:"Loading the working-tree diff…"})})]})},ce="font-handwritten text-xs font-semibold leading-none opacity-[0.45]",re=(e,a)=>{a(e),requestAnimationFrame(()=>{var t;(t=document.querySelector(`[data-diff-path="${CSS.escape(e)}"]`))==null||t.scrollIntoView({behavior:"smooth",block:"start"})})},de=e=>{const[a,t]=e;return a!==" "&&a!=="?"&&t!==" "&&t!=="?"};function me(e){const a=new Map;for(const t of e){const{dir:i}=b(t.path),l=i||"./",d=a.get(l);d?d.push(t):a.set(l,[t])}return[...a].map(([t,i])=>({dir:t,entries:i}))}const xe=()=>{const e=x(o=>o.diffFiles),a=x(o=>o.activeDiffPath),t=x(o=>o.loadDiffFiles),i=x(o=>o.expandDiffPath),[l,d]=p.useState(new Set),[r,f]=p.useState(!1),{toast:u}=U(),n=p.useMemo(()=>me(e??[]),[e]),h=(e??[]).length>0&&(e??[]).every(o=>o.staged);if(!e||e.length===0)return null;const g=async()=>{const o=e.filter(c=>c.staged===h);f(!0);try{const m=(await Promise.allSettled(o.map(j=>h?N(j.path):S(j.path)))).filter(j=>j.status==="rejected").length;m>0&&u({title:h?"Unstage failed":"Stage failed",description:`${m} of ${o.length} file(s) could not be updated.`,variant:"error"})}finally{await t(),f(!1)}},w=async(o,c)=>{d(m=>new Set(m).add(o.path));try{await(c?S(o.path):N(o.path)),await t()}catch(m){u({title:c?"Stage failed":"Unstage failed",description:H(m.message),variant:"error"})}finally{d(m=>{const j=new Set(m);return j.delete(o.path),j})}};return s.jsxs("nav",{"aria-label":"Changed files",className:"flex flex-col",children:[s.jsxs("div",{className:`${ce} flex h-[32px] items-end justify-between pb-1`,children:[s.jsx("span",{children:"Changed files"}),s.jsx(k,{content:h?"Unstage every file":"Stage every file",children:s.jsx(G,{variant:"ghost",size:"tiny",className:"-mb-1",disabled:r,label:h?"Unstage all files":"Stage all files",onClick:g,icon:s.jsx(O,{})})})]}),s.jsx("ul",{className:"m-0 flex list-none flex-col p-0",children:n.map(o=>s.jsxs("li",{children:[s.jsx("div",{className:"flex h-[32px] items-end overflow-hidden text-ellipsis whitespace-nowrap pb-1 font-mono text-3xs leading-none opacity-50",title:o.dir,children:o.dir}),s.jsx("ul",{className:"m-0 flex list-none flex-col p-0",children:o.entries.map(c=>s.jsxs("li",{className:"pc-git-file-row flex h-[32px] min-w-0 items-end gap-1.5 pb-1",children:[s.jsx(z,{checked:c.staged,indeterminate:de(c.status),disabled:l.has(c.path),onChange:m=>w(c,m.target.checked),"aria-label":c.staged?`Unstage ${c.path}`:`Stage ${c.path}`}),s.jsx(P,{status:c.status,compact:!0}),s.jsx(B,{size:"small",active:c.path===a,onClick:()=>re(c.path,i),className:"min-w-0 flex-1 items-end py-0 text-3xs",action:!c.binary&&s.jsx(F,{additions:c.additions,deletions:c.deletions}),children:s.jsx("span",{className:"block min-w-0 overflow-hidden text-ellipsis whitespace-nowrap font-mono text-3xs",title:c.path,children:b(c.path).base})})]},c.path))})]},o.dir))})]})};export{xe as GitFileList,he as GitPage};
6
- //# sourceMappingURL=index-D_Lo8ptS.js.map
5
+ `).map((t,i)=>({type:"add",text:t,oldLine:null,newLine:i+1}))}]:[]}const F=({additions:e,deletions:a})=>s.jsxs("span",{className:"inline-flex shrink-0 gap-1.5 font-mono text-3xs",children:[s.jsxs("span",{className:"text-watercolor-green-dark",children:["+",e]}),s.jsxs("span",{className:"text-watercolor-rose-dark",children:["-",a]})]});function b(e){const a=e.lastIndexOf("/");return a===-1?{dir:"",base:e}:{dir:e.slice(0,a+1),base:e.slice(a+1)}}const J=({path:e,prefix:a,className:t=""})=>{const{dir:i,base:l}=b(e),d=`${a??""}${i}`;return s.jsxs("span",{className:`flex min-w-0 items-center font-mono ${t}`,children:[d&&s.jsx("span",{className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap opacity-50",children:d}),s.jsx("span",{className:"shrink-0 whitespace-nowrap",children:l})]})},Q={success:"text-watercolor-green-dark",info:"text-watercolor-blue-dark",error:"text-watercolor-rose-dark",warning:"text-watercolor-amber-dark",neutral:"text-watercolor-slate-dark"},V={A:{letter:"A",label:"Added",variant:"success"},M:{letter:"M",label:"Modified",variant:"info"},D:{letter:"D",label:"Deleted",variant:"error"},R:{letter:"R",label:"Renamed",variant:"info"},C:{letter:"C",label:"Copied",variant:"info"},U:{letter:"U",label:"Conflicted",variant:"warning"}},X=e=>{if(e==="??")return{letter:"??",label:"Untracked",variant:"neutral"};const[a,t]=e,i=a!==" "&&a!=="?"?a:t;return V[i]??{letter:i??"?",label:i??"Unknown",variant:"neutral"}},P=({status:e,compact:a=!1})=>{const t=X(e);return a?s.jsx("span",{title:t.label,className:`w-4 shrink-0 text-center font-mono text-3xs font-semibold leading-none ${Q[t.variant]??""}`,children:t.letter}):s.jsx("span",{title:t.label,children:s.jsx(v,{size:"small",variant:t.variant,children:t.letter})})},Y=60,Z={add:"bg-watercolor-green/[18%] text-watercolor-green-dark",remove:"bg-watercolor-rose/[18%] text-watercolor-rose-dark",context:""},ee={add:"+",remove:"-",context:" "},se=({entry:e})=>s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-3",children:[s.jsx(P,{status:e.status}),s.jsx(J,{path:e.path,prefix:e.renameSource?`${e.renameSource} → `:void 0,className:"min-w-0 flex-1 text-xs"}),s.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[e.staged&&s.jsx(v,{size:"small",children:"staged"}),!e.binary&&s.jsx(F,{additions:e.additions,deletions:e.deletions})]})]}),te=({entry:e})=>{if(e.binary)return s.jsx("p",{className:"m-0 opacity-60",children:"Binary file not shown."});if(e.contentKind==="too-large")return s.jsx("p",{className:"m-0 opacity-60",children:"File too large to preview."});const a=e.contentKind==="raw"?q(e.patch):K(e.patch);return a.length===0?e.renameSource?s.jsx("p",{className:"m-0 opacity-60",children:e.additions===0&&e.deletions===0?"Renamed, no content changes.":"Renamed with unrelated content — diff omitted."}):s.jsx("p",{className:"m-0 opacity-60",children:"No changes to preview."}):s.jsx("div",{className:"flex min-w-0 max-w-full flex-col gap-3",children:a.map((t,i)=>s.jsxs("div",{className:"min-w-0 max-w-full",children:[t.header&&s.jsx("div",{className:"mb-1 font-mono text-2xs opacity-50",children:t.header}),s.jsx("pre",{className:"m-0 min-w-0 max-w-full overflow-x-auto font-mono text-2xs leading-normal",children:t.lines.map((l,d)=>s.jsxs("span",{className:`flex ${Z[l.type]}`,children:[s.jsxs("span",{className:"inline-flex shrink-0 select-none gap-2 pr-2 opacity-40","aria-hidden":"true",children:[s.jsx("span",{className:"w-8 text-right",children:l.oldLine??""}),s.jsx("span",{className:"w-8 text-right",children:l.newLine??""})]}),s.jsxs("span",{children:[ee[l.type],l.text]})]},`${l.type}-${d}`))})]},`${t.header}-${i}`))})},ae=({entry:e})=>{const a=x(r=>r.manuallyExpandedDiffPaths.has(e.path)),t=x(r=>r.manuallyCollapsedDiffPaths.has(e.path)),i=x(r=>r.setDiffCollapsed),l=t||!a&&e.additions+e.deletions>Y,d=e.renameSource?`${e.renameSource} → ${e.path}`:e.path;return s.jsxs("div",{"data-diff-path":e.path,className:"min-w-0 max-w-full scroll-mt-4",children:[s.jsx("h2",{className:"sr-only",children:d}),s.jsx(y,{title:s.jsx(se,{entry:e}),expanded:!l,onToggle:()=>i(e.path,!l),children:s.jsx(te,{entry:e})})]})},ie="__git__",ne=()=>!0,le=e=>$(e,{formKey:ie,matchesSuggestionTask:ne}),oe=({state:e,filesEmpty:a})=>{const t=x(n=>n.status),{checks:i}=L(),{qualityStatus:l,testStatus:d,consistencyStatus:r}=p.useMemo(()=>D(t,i),[t,i]),f=[l==="fail"&&"Quality",d==="fail"&&"Tests",r==="fail"&&"Consistency"].filter(n=>n!==!1),u=s.jsx(C,{size:"small",disabled:a||!e.commitTitle.trim()||e.committing||e.commitInFlight,onClick:e.handleCommit,children:e.committing||e.commitInFlight?"Committing…":e.stagedCount>0?`Commit ${e.stagedCount} staged`:"Commit"});return f.length===0?u:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(k,{content:`${f.join(", ")} failing`,children:s.jsx(v,{size:"small",variant:"warning",children:"!"})}),u]})},he=()=>{const e=x(n=>n.diffFiles),a=x(n=>n.diffLoadFailed),t=x(n=>n.loadDiffFiles),i=x(n=>n.setActiveDiffPath),l=p.useRef(null),d=p.useMemo(()=>(e==null?void 0:e.map(n=>({path:n.path,staged:n.staged})))??[],[e]),r=le(d);p.useEffect(()=>{t()},[t]),p.useEffect(()=>{let n;const h=E(w=>{w.message==="changed"&&(n&&clearTimeout(n),n=setTimeout(t,250))}),g=()=>t();return window.addEventListener("focus",g),()=>{n&&clearTimeout(n),window.removeEventListener("focus",g),h()}},[t]),p.useEffect(()=>{const n=l.current;if(!n)return;const h=Array.from(n.querySelectorAll("[data-diff-path]"));if(h.length===0)return;const g=new Set,w=new IntersectionObserver(o=>{for(const m of o)m.isIntersecting?g.add(m.target):g.delete(m.target);const c=h.find(m=>g.has(m));c&&i(c.dataset.diffPath??null)},{rootMargin:"0px 0px -70% 0px"});for(const o of h)w.observe(o);return()=>w.disconnect()},[e,i]);const f="min-h-page",u=s.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[s.jsx(R,{className:"!mb-0",children:"Git"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{}),s.jsx(M,{})]})]});return a?s.jsxs("div",{children:[u,s.jsxs("div",{className:`${f} flex flex-col items-start gap-3`,children:[s.jsx("p",{className:"opacity-50 m-0",children:"Couldn't load the working-tree diff."}),s.jsx(C,{variant:"secondary",size:"small",onClick:t,children:"Retry"})]})]}):e?s.jsxs("div",{children:[u,e.length===0?s.jsx("div",{className:f,children:s.jsx("p",{className:"opacity-50",children:"No changed files."})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sticky top-0 z-10 mb-4 flex items-center gap-2 py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx(T,{state:r,filesEmpty:!1})}),s.jsx(oe,{state:r,filesEmpty:!1})]}),s.jsx("div",{ref:l,className:`flex min-w-0 flex-col gap-6 ${f}`,children:e.map((n,h)=>s.jsxs(p.Fragment,{children:[h>0&&s.jsx(I,{}),s.jsx(ae,{entry:n})]},n.path))})]})]}):s.jsxs("div",{children:[u,s.jsx("div",{className:f,children:s.jsx(A,{label:"Loading the working-tree diff…"})})]})},ce="font-handwritten text-xs font-semibold leading-none opacity-[0.45]",re=(e,a)=>{a(e),requestAnimationFrame(()=>{var t;(t=document.querySelector(`[data-diff-path="${CSS.escape(e)}"]`))==null||t.scrollIntoView({behavior:"smooth",block:"start"})})},de=e=>{const[a,t]=e;return a!==" "&&a!=="?"&&t!==" "&&t!=="?"};function me(e){const a=new Map;for(const t of e){const{dir:i}=b(t.path),l=i||"./",d=a.get(l);d?d.push(t):a.set(l,[t])}return[...a].map(([t,i])=>({dir:t,entries:i}))}const xe=()=>{const e=x(o=>o.diffFiles),a=x(o=>o.activeDiffPath),t=x(o=>o.loadDiffFiles),i=x(o=>o.expandDiffPath),[l,d]=p.useState(new Set),[r,f]=p.useState(!1),{toast:u}=U(),n=p.useMemo(()=>me(e??[]),[e]),h=(e??[]).length>0&&(e??[]).every(o=>o.staged);if(!e||e.length===0)return null;const g=async()=>{const o=e.filter(c=>c.staged===h);f(!0);try{const m=(await Promise.allSettled(o.map(j=>h?N(j.path):S(j.path)))).filter(j=>j.status==="rejected").length;m>0&&u({title:h?"Unstage failed":"Stage failed",description:`${m} of ${o.length} file(s) could not be updated.`,variant:"error"})}finally{await t(),f(!1)}},w=async(o,c)=>{d(m=>new Set(m).add(o.path));try{await(c?S(o.path):N(o.path)),await t()}catch(m){u({title:c?"Stage failed":"Unstage failed",description:H(m.message),variant:"error"})}finally{d(m=>{const j=new Set(m);return j.delete(o.path),j})}};return s.jsxs("nav",{"aria-label":"Changed files",className:"flex flex-col",children:[s.jsxs("div",{className:`${ce} flex h-[32px] items-end justify-between pb-1`,children:[s.jsx("span",{children:"Changed files"}),s.jsx(k,{content:h?"Unstage every file":"Stage every file",children:s.jsx(G,{variant:"ghost",size:"tiny",className:"-mb-1",disabled:r,label:h?"Unstage all files":"Stage all files",onClick:g,icon:s.jsx(O,{})})})]}),s.jsx("ul",{className:"m-0 flex list-none flex-col p-0",children:n.map(o=>s.jsxs("li",{children:[s.jsx("div",{className:"flex h-[32px] items-end overflow-hidden text-ellipsis whitespace-nowrap pb-1 font-mono text-3xs leading-none opacity-50",title:o.dir,children:o.dir}),s.jsx("ul",{className:"m-0 flex list-none flex-col p-0",children:o.entries.map(c=>s.jsxs("li",{className:"pc-git-file-row flex h-[32px] min-w-0 items-end gap-1.5 pb-1",children:[s.jsx(z,{checked:c.staged,indeterminate:de(c.status),disabled:l.has(c.path),onChange:m=>w(c,m.target.checked),"aria-label":c.staged?`Unstage ${c.path}`:`Stage ${c.path}`}),s.jsx(P,{status:c.status,compact:!0}),s.jsx(B,{size:"small",active:c.path===a,onClick:()=>re(c.path,i),className:"min-w-0 flex-1 items-end py-0 text-3xs",action:!c.binary&&s.jsx(F,{additions:c.additions,deletions:c.deletions}),children:s.jsx("span",{className:"block min-w-0 overflow-hidden text-ellipsis whitespace-nowrap font-mono text-3xs",title:c.path,children:b(c.path).base})})]},c.path))})]},o.dir))})]})};export{xe as GitFileList,he as GitPage};
6
+ //# sourceMappingURL=index-COEivZHG.js.map