@dendelion/paper-camp 0.21.0 → 0.21.1

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 (24) hide show
  1. package/dist/app/assets/{index-BxQBW2Oi.js → index-By-exAb7.js} +2 -2
  2. package/dist/app/assets/{index-BxQBW2Oi.js.map → index-By-exAb7.js.map} +1 -1
  3. package/dist/app/assets/{index-vgBxkLmQ.js → index-CAmVn0M_.js} +2 -2
  4. package/dist/app/assets/{index-vgBxkLmQ.js.map → index-CAmVn0M_.js.map} +1 -1
  5. package/dist/app/assets/{index-VXeQcBh1.js → index-CBsx6hnr.js} +2 -2
  6. package/dist/app/assets/{index-VXeQcBh1.js.map → index-CBsx6hnr.js.map} +1 -1
  7. package/dist/app/assets/{index-BZnU3b_x.js → index-DHe347Nk.js} +2 -2
  8. package/dist/app/assets/{index-BZnU3b_x.js.map → index-DHe347Nk.js.map} +1 -1
  9. package/dist/app/assets/{index-DIlqYxon.js → index-DQ8GyDR3.js} +2 -2
  10. package/dist/app/assets/{index-DIlqYxon.js.map → index-DQ8GyDR3.js.map} +1 -1
  11. package/dist/app/assets/{index-COQOoPiS.js → index-Dff7A8Rp.js} +2 -2
  12. package/dist/app/assets/{index-COQOoPiS.js.map → index-Dff7A8Rp.js.map} +1 -1
  13. package/dist/app/assets/{index-BK4XPXt_.js → index-DqrpCrzX.js} +2 -2
  14. package/dist/app/assets/{index-BK4XPXt_.js.map → index-DqrpCrzX.js.map} +1 -1
  15. package/dist/app/assets/{index-COEivZHG.js → index-H8Ja9gnB.js} +2 -2
  16. package/dist/app/assets/{index-COEivZHG.js.map → index-H8Ja9gnB.js.map} +1 -1
  17. package/dist/app/assets/{main-s2b5XHSS.js → main-C8ibbBFi.js} +4 -4
  18. package/dist/app/assets/{main-s2b5XHSS.js.map → main-C8ibbBFi.js.map} +1 -1
  19. package/dist/app/assets/{sidebar-section-4MxZoa3M.js → sidebar-section-0u_lUROT.js} +2 -2
  20. package/dist/app/assets/{sidebar-section-4MxZoa3M.js.map → sidebar-section-0u_lUROT.js.map} +1 -1
  21. package/dist/app/index.html +1 -1
  22. package/dist/cli/index.js +2283 -2270
  23. package/dist/cli/index.js.map +1 -1
  24. package/package.json +1 -1
@@ -1,2 +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
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-C8ibbBFi.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-By-exAb7.js.map
@@ -1 +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,OAA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EAAM,SAAoBA,EAAM,WAAqB,EACtE,OAEN,OAAQ8D,IAAkB9D,EAAM,GAChC,YAAa8D,IAAkB,OAC/B,MAAO,IAAMX,EAAenD,EAAM,GAAIA,EAAM,MAAOA,EAAM,OAAQA,EAAM,MAAM,EAC7E,aAAcqB,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
+ {"version":3,"file":"index-By-exAb7.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,qB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AAAd,EACA,SAAUuC,IAAevC,EAAM,GAC/B,SAAU,IAAMwC,EAAe0B,GAASA,IAAQlE,EAAM,GAAK,KAAOA,EAAM,EAAG,EAC3E,OACEA,EAAM,UAAYA,EAAM,YACpB,IAAMuD,EAAWvD,EAAM,SAAoBA,EAAM,WAAqB,EACtE,OAEN,OAAQ8D,IAAkB9D,EAAM,GAChC,YAAa8D,IAAkB,OAC/B,MAAO,IAAMX,EAAenD,EAAM,GAAIA,EAAM,MAAOA,EAAM,OAAQA,EAAM,MAAM,EAC7E,aAAcqB,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,3 +1,3 @@
1
- import{u as h,E as v,r,j as e,P as L,R as u,z as y,g as S,q as f,F as b,J as A}from"./main-s2b5XHSS.js";const T={phase:"Phase run",audit:"Audit","batch-reconcile":"Batch reconcile","batch-draft":"Batch draft","run-all":"Run all phases",draft:"Draft",extend:"Extend",suggest:"Suggest ideas","commit-suggest":"Commit suggest","overlap-check":"Overlap check",prioritise:"Prioritise queue",sync:"Sync",reconcile:"Reconcile","fix-review":"Fix review","resolve-conflict":"Resolve conflict",feedback:"Feedback reply","pr-review":"PR review","issue-fix":"Issue fix"},m=s=>String(s).padStart(2,"0"),R=s=>{const a=new Date(s);return`${a.getFullYear()}-${m(a.getMonth()+1)}-${m(a.getDate())}`},_=s=>new Date(s).toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"}),k=s=>{const a=new Date(s);return`${m(a.getHours())}:${m(a.getMinutes())}:${m(a.getSeconds())}`},p="text-sm font-semibold whitespace-nowrap overflow-hidden",N="grid grid-cols-[20px_116px_minmax(0,1fr)_88px_150px_72px] gap-2.5 items-center max-lg:grid-cols-[20px_116px_minmax(0,1fr)_88px_72px] max-[480px]:grid-cols-1 max-[480px]:gap-1",D=({id:s})=>{const[a,c]=r.useState(null),[l,i]=r.useState(!1),[o,x]=r.useState(0);r.useEffect(()=>{let n=!1,d;c(null),i(!1);const g=j=>{b(s).then(w=>{n||c(w.lines??[])}).catch(()=>{if(!n){if(j>0){d=setTimeout(()=>g(j-1),700);return}i(!0),c([])}})};return g(3),()=>{n=!0,d&&clearTimeout(d)}},[s,o]);const t=e.jsx(A,{variant:"ghost",size:"small",onClick:()=>x(n=>n+1),children:"Retry"});return a===null?e.jsx("p",{className:"opacity-50 m-0",children:"Loading…"}):l?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"opacity-50 m-0",children:"Couldn't load this task's output."}),t]}):a.length===0?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"opacity-50 m-0",children:"No output recorded."}),t]}):e.jsx("pre",{className:"font-mono text-xs m-0 max-h-[320px] overflow-y-auto whitespace-pre-wrap",children:a.join(`
1
+ import{u as h,E as v,r,j as e,P as L,R as u,z as y,g as S,q as f,F as b,J as A}from"./main-C8ibbBFi.js";const T={phase:"Phase run",audit:"Audit","batch-reconcile":"Batch reconcile","batch-draft":"Batch draft","run-all":"Run all phases",draft:"Draft",extend:"Extend",suggest:"Suggest ideas","commit-suggest":"Commit suggest","overlap-check":"Overlap check",prioritise:"Prioritise queue",sync:"Sync",reconcile:"Reconcile","fix-review":"Fix review","resolve-conflict":"Resolve conflict",feedback:"Feedback reply","pr-review":"PR review","issue-fix":"Issue fix"},m=s=>String(s).padStart(2,"0"),R=s=>{const a=new Date(s);return`${a.getFullYear()}-${m(a.getMonth()+1)}-${m(a.getDate())}`},_=s=>new Date(s).toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"}),k=s=>{const a=new Date(s);return`${m(a.getHours())}:${m(a.getMinutes())}:${m(a.getSeconds())}`},p="text-sm font-semibold whitespace-nowrap overflow-hidden",N="grid grid-cols-[20px_116px_minmax(0,1fr)_88px_150px_72px] gap-2.5 items-center max-lg:grid-cols-[20px_116px_minmax(0,1fr)_88px_72px] max-[480px]:grid-cols-1 max-[480px]:gap-1",D=({id:s})=>{const[a,c]=r.useState(null),[l,i]=r.useState(!1),[o,x]=r.useState(0);r.useEffect(()=>{let n=!1,d;c(null),i(!1);const g=j=>{b(s).then(w=>{n||c(w.lines??[])}).catch(()=>{if(!n){if(j>0){d=setTimeout(()=>g(j-1),700);return}i(!0),c([])}})};return g(3),()=>{n=!0,d&&clearTimeout(d)}},[s,o]);const t=e.jsx(A,{variant:"ghost",size:"small",onClick:()=>x(n=>n+1),children:"Retry"});return a===null?e.jsx("p",{className:"opacity-50 m-0",children:"Loading…"}):l?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"opacity-50 m-0",children:"Couldn't load this task's output."}),t]}):a.length===0?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"opacity-50 m-0",children:"No output recorded."}),t]}):e.jsx("pre",{className:"font-mono text-xs m-0 max-h-[320px] overflow-y-auto whitespace-pre-wrap",children:a.join(`
2
2
  `)})},E=({size:s=14,className:a})=>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",className:a,children:e.jsx("polyline",{points:"9 18 15 12 9 6"})}),$=({entry:s,highlighted:a})=>{const[c,l]=r.useState(a);r.useEffect(()=>{a&&l(!0)},[a]);const i=()=>l(o=>!o);return e.jsxs("div",{className:a?"task-row-highlighted flex flex-col gap-1 rounded-[10px] outline outline-2 outline-offset-[-2px] outline-[rgba(200,154,90,0.5)]":"flex flex-col gap-1 rounded-[10px]",children:[e.jsx("div",{role:"button",tabIndex:0,"aria-expanded":c,onClick:i,onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),i())},className:"group cursor-pointer rounded-[10px]",children:e.jsx(u,{size:"small",texture:"canvas",className:"plan-row-card",children:e.jsxs("div",{className:N,children:[e.jsx("span",{className:"inline-flex items-center opacity-50",children:e.jsx(E,{className:"group-aria-expanded:rotate-90"})}),e.jsx("span",{className:"font-semibold whitespace-nowrap overflow-hidden",children:T[s.taskKind]??s.taskKind}),e.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap opacity-70",children:s.planTitle}),e.jsx("span",{className:"text-sm opacity-50 whitespace-nowrap",children:y[s.agentId]}),e.jsxs("span",{className:"max-lg:hidden font-mono text-xs opacity-[0.55] whitespace-nowrap",children:[k(s.startedAt),"–",k(s.endedAt)]}),e.jsx("div",{className:"flex items-center",children:e.jsx(S,{size:"small",fillColor:s.outcome==="done"?"rgba(143, 185, 150, 0.25)":s.outcome==="superseded"?"rgba(212, 163, 115, 0.25)":"rgba(201, 139, 139, 0.25)",textColor:s.outcome==="done"?f.accentGreenDark:s.outcome==="superseded"?f.accentAmberDark:f.accentRoseDark,children:s.outcome})})]})})}),c&&e.jsxs(u,{size:"small",texture:"kraft",className:"plan-row-card",children:[s.outcome==="error"&&s.reason&&e.jsx("p",{className:"m-0 mb-2 text-sm text-state-danger",children:s.reason}),e.jsx(D,{id:s.id})]})]})},I=()=>{const s=h(t=>t.taskLog),a=h(t=>t.taskLogLoading),c=h(t=>t.loadTaskLog),{taskId:l}=v({from:"/tasks"}),i=r.useRef(null);r.useEffect(()=>{c()},[c]),r.useEffect(()=>{var n;if(!l)return;const t=(n=i.current)==null?void 0:n.querySelector(".task-row-highlighted");t==null||t.scrollIntoView({behavior:"smooth",block:"center"})},[l]);const o=[...s].sort((t,n)=>n.endedAt.localeCompare(t.endedAt)),x=[];for(const t of o){const n=R(t.endedAt),d=x.at(-1);(d==null?void 0:d.key)===n?d.entries.push(t):x.push({key:n,entries:[t]})}return e.jsxs("div",{ref:i,children:[e.jsx(L,{children:"Tasks"}),a&&e.jsx("p",{className:"opacity-50",children:"Loading…"}),!a&&o.length===0&&e.jsx("p",{className:"opacity-50",children:"No tasks have run yet."}),!a&&o.length>0&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(u,{size:"small",texture:"kraft",className:"plan-row-card",children:e.jsxs("div",{className:N,children:[e.jsx("span",{}),e.jsx("span",{className:`${p} opacity-60`,children:"Task"}),e.jsx("span",{className:`${p} opacity-60`,children:"Plan"}),e.jsx("span",{className:`${p} opacity-60`,children:"Agent"}),e.jsx("span",{className:`max-lg:hidden ${p} opacity-60`,children:"Time"}),e.jsx("span",{className:`${p} opacity-60`,children:"Outcome"})]})}),x.map(t=>e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(u,{size:"small",texture:"kraft",className:"plan-row-card",children:e.jsx("span",{className:`${p} opacity-75`,children:_(t.entries[0].endedAt)})}),t.entries.map(n=>e.jsx($,{entry:n,highlighted:n.id===l},n.id))]},t.key))]})]})};export{I as TasksPage};
3
- //# sourceMappingURL=index-vgBxkLmQ.js.map
3
+ //# sourceMappingURL=index-CAmVn0M_.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-vgBxkLmQ.js","sources":["../../../src/app/features/tasks/tasks-page.tsx"],"sourcesContent":["import { PageTitle } from '@/app/components/page-title';\nimport { fetchTaskLogLines } from '@/app/services/content/docs-api';\nimport { useAppStore } from '@/app/stores/app-store';\nimport { color } from '@/app/styles/tokens';\nimport { AGENT_LABELS, type TaskKind, type TaskLogEntry } from '@/types/index';\nimport { Button, Card, Stamp } from '@dendelion/paper-ui';\nimport { useSearch } from '@tanstack/react-router';\nimport { useEffect, useRef, useState } from 'react';\n\nconst TASK_KIND_LABELS: Record<TaskKind, string> = {\n phase: 'Phase run',\n audit: 'Audit',\n 'batch-reconcile': 'Batch reconcile',\n 'batch-draft': 'Batch draft',\n 'run-all': 'Run all phases',\n draft: 'Draft',\n extend: 'Extend',\n suggest: 'Suggest ideas',\n 'commit-suggest': 'Commit suggest',\n 'overlap-check': 'Overlap check',\n prioritise: 'Prioritise queue',\n sync: 'Sync',\n reconcile: 'Reconcile',\n 'fix-review': 'Fix review',\n 'resolve-conflict': 'Resolve conflict',\n feedback: 'Feedback reply',\n 'pr-review': 'PR review',\n 'issue-fix': 'Issue fix',\n};\n\nconst pad = (n: number) => String(n).padStart(2, '0');\n\nconst dayKey = (iso: string) => {\n const d = new Date(iso);\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;\n};\n\nconst formatDayHeader = (iso: string) =>\n new Date(iso).toLocaleDateString(undefined, {\n weekday: 'long',\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n });\n\nconst formatTime = (iso: string) => {\n const d = new Date(iso);\n return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;\n};\n\nconst headerLabelClassName = 'text-sm font-semibold whitespace-nowrap overflow-hidden';\n\nconst TASK_ROWS_GRID_CLASS =\n 'grid grid-cols-[20px_116px_minmax(0,1fr)_88px_150px_72px] gap-2.5 items-center max-lg:grid-cols-[20px_116px_minmax(0,1fr)_88px_72px] max-[480px]:grid-cols-1 max-[480px]:gap-1';\n\nconst TaskLogLines = ({ id }: { id: string }) => {\n const [lines, setLines] = useState<string[] | null>(null);\n const [failed, setFailed] = useState(false);\n const [attempt, setAttempt] = useState(0);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: attempt is the retry trigger (re-runs the fetch), not a value read in the body.\n useEffect(() => {\n let cancelled = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n setLines(null);\n setFailed(false);\n // Auto-retry first (dev server briefly drops requests on hot reload); manual Retry only if it stays down.\n const load = (remaining: number) => {\n fetchTaskLogLines(id)\n .then((data) => {\n if (cancelled) return;\n setLines(data.lines ?? []);\n })\n .catch(() => {\n if (cancelled) return;\n if (remaining > 0) {\n timer = setTimeout(() => load(remaining - 1), 700);\n return;\n }\n // Empty result != failed request: conflating them mislabels a fetch error as \"no output\".\n setFailed(true);\n setLines([]);\n });\n };\n load(3);\n return () => {\n cancelled = true;\n if (timer) clearTimeout(timer);\n };\n }, [id, attempt]);\n\n const retry = (\n <Button variant=\"ghost\" size=\"small\" onClick={() => setAttempt((n) => n + 1)}>\n Retry\n </Button>\n );\n\n if (lines === null) return <p className=\"opacity-50 m-0\">Loading…</p>;\n if (failed)\n return (\n <div className=\"flex items-center gap-2\">\n <p className=\"opacity-50 m-0\">Couldn't load this task's output.</p>\n {retry}\n </div>\n );\n if (lines.length === 0)\n return (\n <div className=\"flex items-center gap-2\">\n <p className=\"opacity-50 m-0\">No output recorded.</p>\n {retry}\n </div>\n );\n return (\n <pre className=\"font-mono text-xs m-0 max-h-[320px] overflow-y-auto whitespace-pre-wrap\">\n {lines.join('\\n')}\n </pre>\n );\n};\n\nconst ChevronRightIcon = ({ size = 14, className }: { size?: number; className?: string }) => (\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 className={className}\n >\n <polyline points=\"9 18 15 12 9 6\" />\n </svg>\n);\n\nconst TaskRow = ({ entry, highlighted }: { entry: TaskLogEntry; highlighted: boolean }) => {\n const [expanded, setExpanded] = useState(highlighted);\n useEffect(() => {\n if (highlighted) setExpanded(true);\n }, [highlighted]);\n const toggle = () => setExpanded((v) => !v);\n\n return (\n <div\n className={\n highlighted\n ? 'task-row-highlighted flex flex-col gap-1 rounded-[10px] outline outline-2 outline-offset-[-2px] outline-[rgba(200,154,90,0.5)]'\n : 'flex flex-col gap-1 rounded-[10px]'\n }\n >\n {/* biome-ignore lint/a11y/useSemanticElements: the clickable row wraps a Card whose block layout a native <button> would break; keyboard toggling is wired on the div. */}\n <div\n role=\"button\"\n tabIndex={0}\n aria-expanded={expanded}\n onClick={toggle}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n toggle();\n }\n }}\n className=\"group cursor-pointer rounded-[10px]\"\n >\n <Card size=\"small\" texture=\"canvas\" className=\"plan-row-card\">\n <div className={TASK_ROWS_GRID_CLASS}>\n <span className=\"inline-flex items-center opacity-50\">\n <ChevronRightIcon className=\"group-aria-expanded:rotate-90\" />\n </span>\n <span className=\"font-semibold whitespace-nowrap overflow-hidden\">\n {TASK_KIND_LABELS[entry.taskKind] ?? entry.taskKind}\n </span>\n <span className=\"overflow-hidden text-ellipsis whitespace-nowrap opacity-70\">\n {entry.planTitle}\n </span>\n <span className=\"text-sm opacity-50 whitespace-nowrap\">\n {AGENT_LABELS[entry.agentId]}\n </span>\n <span className=\"max-lg:hidden font-mono text-xs opacity-[0.55] whitespace-nowrap\">\n {formatTime(entry.startedAt)}–{formatTime(entry.endedAt)}\n </span>\n <div className=\"flex items-center\">\n <Stamp\n size=\"small\"\n fillColor={\n entry.outcome === 'done'\n ? 'rgba(143, 185, 150, 0.25)'\n : entry.outcome === 'superseded'\n ? 'rgba(212, 163, 115, 0.25)'\n : 'rgba(201, 139, 139, 0.25)'\n }\n textColor={\n entry.outcome === 'done'\n ? color.accentGreenDark\n : entry.outcome === 'superseded'\n ? color.accentAmberDark\n : color.accentRoseDark\n }\n >\n {entry.outcome}\n </Stamp>\n </div>\n </div>\n </Card>\n </div>\n {expanded && (\n <Card size=\"small\" texture=\"kraft\" className=\"plan-row-card\">\n {entry.outcome === 'error' && entry.reason && (\n <p className=\"m-0 mb-2 text-sm text-state-danger\">{entry.reason}</p>\n )}\n <TaskLogLines id={entry.id} />\n </Card>\n )}\n </div>\n );\n};\n\nexport const TasksPage = () => {\n const taskLog = useAppStore((s) => s.taskLog);\n const taskLogLoading = useAppStore((s) => s.taskLogLoading);\n const loadTaskLog = useAppStore((s) => s.loadTaskLog);\n const { taskId } = useSearch({ from: '/tasks' });\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n loadTaskLog();\n }, [loadTaskLog]);\n\n useEffect(() => {\n if (!taskId) return;\n const row = containerRef.current?.querySelector('.task-row-highlighted');\n row?.scrollIntoView({ behavior: 'smooth', block: 'center' });\n }, [taskId]);\n\n const sorted = [...taskLog].sort((a, b) => b.endedAt.localeCompare(a.endedAt));\n\n const groups: { key: string; entries: TaskLogEntry[] }[] = [];\n for (const entry of sorted) {\n const key = dayKey(entry.endedAt);\n const group = groups.at(-1);\n if (group?.key === key) group.entries.push(entry);\n else groups.push({ key, entries: [entry] });\n }\n\n return (\n <div ref={containerRef}>\n <PageTitle>Tasks</PageTitle>\n {taskLogLoading && <p className=\"opacity-50\">Loading…</p>}\n {!taskLogLoading && sorted.length === 0 && (\n <p className=\"opacity-50\">No tasks have run yet.</p>\n )}\n {!taskLogLoading && sorted.length > 0 && (\n <div className=\"flex flex-col gap-1\">\n <Card size=\"small\" texture=\"kraft\" className=\"plan-row-card\">\n <div className={TASK_ROWS_GRID_CLASS}>\n <span />\n <span className={`${headerLabelClassName} opacity-60`}>Task</span>\n <span className={`${headerLabelClassName} opacity-60`}>Plan</span>\n <span className={`${headerLabelClassName} opacity-60`}>Agent</span>\n <span className={`max-lg:hidden ${headerLabelClassName} opacity-60`}>Time</span>\n <span className={`${headerLabelClassName} opacity-60`}>Outcome</span>\n </div>\n </Card>\n {groups.map((group) => (\n <div key={group.key} className=\"flex flex-col gap-1\">\n <Card size=\"small\" texture=\"kraft\" className=\"plan-row-card\">\n <span className={`${headerLabelClassName} opacity-75`}>\n {formatDayHeader(group.entries[0].endedAt)}\n </span>\n </Card>\n {group.entries.map((entry) => (\n <TaskRow key={entry.id} entry={entry} highlighted={entry.id === taskId} />\n ))}\n </div>\n ))}\n </div>\n )}\n </div>\n );\n};\n"],"names":["TASK_KIND_LABELS","pad","n","dayKey","iso","d","formatDayHeader","formatTime","headerLabelClassName","TASK_ROWS_GRID_CLASS","TaskLogLines","id","lines","setLines","useState","failed","setFailed","attempt","setAttempt","useEffect","cancelled","timer","load","remaining","fetchTaskLogLines","data","retry","jsx","Button","jsxs","ChevronRightIcon","size","className","TaskRow","entry","highlighted","expanded","setExpanded","toggle","v","e","Card","AGENT_LABELS","Stamp","color","TasksPage","taskLog","useAppStore","s","taskLogLoading","loadTaskLog","taskId","useSearch","containerRef","useRef","row","_a","sorted","a","b","groups","key","group","PageTitle"],"mappings":"wGASA,MAAMA,EAA6C,CACjD,MAAO,YACP,MAAO,QACP,kBAAmB,kBACnB,cAAe,cACf,UAAW,iBACX,MAAO,QACP,OAAQ,SACR,QAAS,gBACT,iBAAkB,iBAClB,gBAAiB,gBACjB,WAAY,mBACZ,KAAM,OACN,UAAW,YACX,aAAc,aACd,mBAAoB,mBACpB,SAAU,iBACV,YAAa,YACb,YAAa,WACf,EAEMC,EAAOC,GAAc,OAAOA,CAAC,EAAE,SAAS,EAAG,GAAG,EAE9CC,EAAUC,GAAgB,CAC9B,MAAMC,EAAI,IAAI,KAAKD,CAAG,EACtB,MAAO,GAAGC,EAAE,YAAA,CAAa,IAAIJ,EAAII,EAAE,SAAA,EAAa,CAAC,CAAC,IAAIJ,EAAII,EAAE,QAAA,CAAS,CAAC,EACxE,EAEMC,EAAmBF,GACvB,IAAI,KAAKA,CAAG,EAAE,mBAAmB,OAAW,CAC1C,QAAS,OACT,KAAM,UACN,MAAO,OACP,IAAK,SACP,CAAC,EAEGG,EAAcH,GAAgB,CAClC,MAAMC,EAAI,IAAI,KAAKD,CAAG,EACtB,MAAO,GAAGH,EAAII,EAAE,SAAA,CAAU,CAAC,IAAIJ,EAAII,EAAE,WAAA,CAAY,CAAC,IAAIJ,EAAII,EAAE,WAAA,CAAY,CAAC,EAC3E,EAEMG,EAAuB,0DAEvBC,EACJ,iLAEIC,EAAe,CAAC,CAAE,GAAAC,KAAyB,CAC/C,KAAM,CAACC,EAAOC,CAAQ,EAAIC,EAAAA,SAA0B,IAAI,EAClD,CAACC,EAAQC,CAAS,EAAIF,EAAAA,SAAS,EAAK,EACpC,CAACG,EAASC,CAAU,EAAIJ,EAAAA,SAAS,CAAC,EAGxCK,EAAAA,UAAU,IAAM,CACd,IAAIC,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ACM,EAAA,CAAuB,MAAAC,EAAc,YAAaA,EAAM,KAAOiB,CAAA,EAAlDjB,EAAM,EAAoD,CACzE,CAAA,CAAA,EARO4B,EAAM,GAShB,CACD,CAAA,CAAA,CACH,CAAA,EAEJ,CAEJ"}
1
+ {"version":3,"file":"index-CAmVn0M_.js","sources":["../../../src/app/features/tasks/tasks-page.tsx"],"sourcesContent":["import { PageTitle } from '@/app/components/page-title';\nimport { fetchTaskLogLines } from '@/app/services/content/docs-api';\nimport { useAppStore } from '@/app/stores/app-store';\nimport { color } from '@/app/styles/tokens';\nimport { AGENT_LABELS, type TaskKind, type TaskLogEntry } from '@/types/index';\nimport { Button, Card, Stamp } from '@dendelion/paper-ui';\nimport { useSearch } from '@tanstack/react-router';\nimport { useEffect, useRef, useState } from 'react';\n\nconst TASK_KIND_LABELS: Record<TaskKind, string> = {\n phase: 'Phase run',\n audit: 'Audit',\n 'batch-reconcile': 'Batch reconcile',\n 'batch-draft': 'Batch draft',\n 'run-all': 'Run all phases',\n draft: 'Draft',\n extend: 'Extend',\n suggest: 'Suggest ideas',\n 'commit-suggest': 'Commit suggest',\n 'overlap-check': 'Overlap check',\n prioritise: 'Prioritise queue',\n sync: 'Sync',\n reconcile: 'Reconcile',\n 'fix-review': 'Fix review',\n 'resolve-conflict': 'Resolve conflict',\n feedback: 'Feedback reply',\n 'pr-review': 'PR review',\n 'issue-fix': 'Issue fix',\n};\n\nconst pad = (n: number) => String(n).padStart(2, '0');\n\nconst dayKey = (iso: string) => {\n const d = new Date(iso);\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;\n};\n\nconst formatDayHeader = (iso: string) =>\n new Date(iso).toLocaleDateString(undefined, {\n weekday: 'long',\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n });\n\nconst formatTime = (iso: string) => {\n const d = new Date(iso);\n return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;\n};\n\nconst headerLabelClassName = 'text-sm font-semibold whitespace-nowrap overflow-hidden';\n\nconst TASK_ROWS_GRID_CLASS =\n 'grid grid-cols-[20px_116px_minmax(0,1fr)_88px_150px_72px] gap-2.5 items-center max-lg:grid-cols-[20px_116px_minmax(0,1fr)_88px_72px] max-[480px]:grid-cols-1 max-[480px]:gap-1';\n\nconst TaskLogLines = ({ id }: { id: string }) => {\n const [lines, setLines] = useState<string[] | null>(null);\n const [failed, setFailed] = useState(false);\n const [attempt, setAttempt] = useState(0);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: attempt is the retry trigger (re-runs the fetch), not a value read in the body.\n useEffect(() => {\n let cancelled = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n setLines(null);\n setFailed(false);\n // Auto-retry first (dev server briefly drops requests on hot reload); manual Retry only if it stays down.\n const load = (remaining: number) => {\n fetchTaskLogLines(id)\n .then((data) => {\n if (cancelled) return;\n setLines(data.lines ?? []);\n })\n .catch(() => {\n if (cancelled) return;\n if (remaining > 0) {\n timer = setTimeout(() => load(remaining - 1), 700);\n return;\n }\n // Empty result != failed request: conflating them mislabels a fetch error as \"no output\".\n setFailed(true);\n setLines([]);\n });\n };\n load(3);\n return () => {\n cancelled = true;\n if (timer) clearTimeout(timer);\n };\n }, [id, attempt]);\n\n const retry = (\n <Button variant=\"ghost\" size=\"small\" onClick={() => setAttempt((n) => n + 1)}>\n Retry\n </Button>\n );\n\n if (lines === null) return <p className=\"opacity-50 m-0\">Loading…</p>;\n if (failed)\n return (\n <div className=\"flex items-center gap-2\">\n <p className=\"opacity-50 m-0\">Couldn't load this task's output.</p>\n {retry}\n </div>\n );\n if (lines.length === 0)\n return (\n <div className=\"flex items-center gap-2\">\n <p className=\"opacity-50 m-0\">No output recorded.</p>\n {retry}\n </div>\n );\n return (\n <pre className=\"font-mono text-xs m-0 max-h-[320px] overflow-y-auto whitespace-pre-wrap\">\n {lines.join('\\n')}\n </pre>\n );\n};\n\nconst ChevronRightIcon = ({ size = 14, className }: { size?: number; className?: string }) => (\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 className={className}\n >\n <polyline points=\"9 18 15 12 9 6\" />\n </svg>\n);\n\nconst TaskRow = ({ entry, highlighted }: { entry: TaskLogEntry; highlighted: boolean }) => {\n const [expanded, setExpanded] = useState(highlighted);\n useEffect(() => {\n if (highlighted) setExpanded(true);\n }, [highlighted]);\n const toggle = () => setExpanded((v) => !v);\n\n return (\n <div\n className={\n highlighted\n ? 'task-row-highlighted flex flex-col gap-1 rounded-[10px] outline outline-2 outline-offset-[-2px] outline-[rgba(200,154,90,0.5)]'\n : 'flex flex-col gap-1 rounded-[10px]'\n }\n >\n {/* biome-ignore lint/a11y/useSemanticElements: the clickable row wraps a Card whose block layout a native <button> would break; keyboard toggling is wired on the div. */}\n <div\n role=\"button\"\n tabIndex={0}\n aria-expanded={expanded}\n onClick={toggle}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n toggle();\n }\n }}\n className=\"group cursor-pointer rounded-[10px]\"\n >\n <Card size=\"small\" texture=\"canvas\" className=\"plan-row-card\">\n <div className={TASK_ROWS_GRID_CLASS}>\n <span className=\"inline-flex items-center opacity-50\">\n <ChevronRightIcon className=\"group-aria-expanded:rotate-90\" />\n </span>\n <span className=\"font-semibold whitespace-nowrap overflow-hidden\">\n {TASK_KIND_LABELS[entry.taskKind] ?? entry.taskKind}\n </span>\n <span className=\"overflow-hidden text-ellipsis whitespace-nowrap opacity-70\">\n {entry.planTitle}\n </span>\n <span className=\"text-sm opacity-50 whitespace-nowrap\">\n {AGENT_LABELS[entry.agentId]}\n </span>\n <span className=\"max-lg:hidden font-mono text-xs opacity-[0.55] whitespace-nowrap\">\n {formatTime(entry.startedAt)}–{formatTime(entry.endedAt)}\n </span>\n <div className=\"flex items-center\">\n <Stamp\n size=\"small\"\n fillColor={\n entry.outcome === 'done'\n ? 'rgba(143, 185, 150, 0.25)'\n : entry.outcome === 'superseded'\n ? 'rgba(212, 163, 115, 0.25)'\n : 'rgba(201, 139, 139, 0.25)'\n }\n textColor={\n entry.outcome === 'done'\n ? color.accentGreenDark\n : entry.outcome === 'superseded'\n ? color.accentAmberDark\n : color.accentRoseDark\n }\n >\n {entry.outcome}\n </Stamp>\n </div>\n </div>\n </Card>\n </div>\n {expanded && (\n <Card size=\"small\" texture=\"kraft\" className=\"plan-row-card\">\n {entry.outcome === 'error' && entry.reason && (\n <p className=\"m-0 mb-2 text-sm text-state-danger\">{entry.reason}</p>\n )}\n <TaskLogLines id={entry.id} />\n </Card>\n )}\n </div>\n );\n};\n\nexport const TasksPage = () => {\n const taskLog = useAppStore((s) => s.taskLog);\n const taskLogLoading = useAppStore((s) => s.taskLogLoading);\n const loadTaskLog = useAppStore((s) => s.loadTaskLog);\n const { taskId } = useSearch({ from: '/tasks' });\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n loadTaskLog();\n }, [loadTaskLog]);\n\n useEffect(() => {\n if (!taskId) return;\n const row = containerRef.current?.querySelector('.task-row-highlighted');\n row?.scrollIntoView({ behavior: 'smooth', block: 'center' });\n }, [taskId]);\n\n const sorted = [...taskLog].sort((a, b) => b.endedAt.localeCompare(a.endedAt));\n\n const groups: { key: string; entries: TaskLogEntry[] }[] = [];\n for (const entry of sorted) {\n const key = dayKey(entry.endedAt);\n const group = groups.at(-1);\n if (group?.key === key) group.entries.push(entry);\n else groups.push({ key, entries: [entry] });\n }\n\n return (\n <div ref={containerRef}>\n <PageTitle>Tasks</PageTitle>\n {taskLogLoading && <p className=\"opacity-50\">Loading…</p>}\n {!taskLogLoading && sorted.length === 0 && (\n <p className=\"opacity-50\">No tasks have run yet.</p>\n )}\n {!taskLogLoading && sorted.length > 0 && (\n <div className=\"flex flex-col gap-1\">\n <Card size=\"small\" texture=\"kraft\" className=\"plan-row-card\">\n <div className={TASK_ROWS_GRID_CLASS}>\n <span />\n <span className={`${headerLabelClassName} opacity-60`}>Task</span>\n <span className={`${headerLabelClassName} opacity-60`}>Plan</span>\n <span className={`${headerLabelClassName} opacity-60`}>Agent</span>\n <span className={`max-lg:hidden ${headerLabelClassName} opacity-60`}>Time</span>\n <span className={`${headerLabelClassName} opacity-60`}>Outcome</span>\n </div>\n </Card>\n {groups.map((group) => (\n <div key={group.key} className=\"flex flex-col gap-1\">\n <Card size=\"small\" texture=\"kraft\" className=\"plan-row-card\">\n <span className={`${headerLabelClassName} opacity-75`}>\n {formatDayHeader(group.entries[0].endedAt)}\n </span>\n </Card>\n {group.entries.map((entry) => (\n <TaskRow key={entry.id} entry={entry} highlighted={entry.id === taskId} />\n ))}\n </div>\n ))}\n </div>\n )}\n </div>\n );\n};\n"],"names":["TASK_KIND_LABELS","pad","n","dayKey","iso","d","formatDayHeader","formatTime","headerLabelClassName","TASK_ROWS_GRID_CLASS","TaskLogLines","id","lines","setLines","useState","failed","setFailed","attempt","setAttempt","useEffect","cancelled","timer","load","remaining","fetchTaskLogLines","data","retry","jsx","Button","jsxs","ChevronRightIcon","size","className","TaskRow","entry","highlighted","expanded","setExpanded","toggle","v","e","Card","AGENT_LABELS","Stamp","color","TasksPage","taskLog","useAppStore","s","taskLogLoading","loadTaskLog","taskId","useSearch","containerRef","useRef","row","_a","sorted","a","b","groups","key","group","PageTitle"],"mappings":"wGASA,MAAMA,EAA6C,CACjD,MAAO,YACP,MAAO,QACP,kBAAmB,kBACnB,cAAe,cACf,UAAW,iBACX,MAAO,QACP,OAAQ,SACR,QAAS,gBACT,iBAAkB,iBAClB,gBAAiB,gBACjB,WAAY,mBACZ,KAAM,OACN,UAAW,YACX,aAAc,aACd,mBAAoB,mBACpB,SAAU,iBACV,YAAa,YACb,YAAa,WACf,EAEMC,EAAOC,GAAc,OAAOA,CAAC,EAAE,SAAS,EAAG,GAAG,EAE9CC,EAAUC,GAAgB,CAC9B,MAAMC,EAAI,IAAI,KAAKD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AU,gBAC3C,SAAAZ,EAAAA,KAAC,MAAA,CAAI,UAAWpB,EACd,SAAA,CAAAkB,EAAAA,IAAC,OAAA,EAAK,QACL,OAAA,CAAK,UAAW,GAAGnB,CAAoB,cAAe,SAAA,OAAI,QAC1D,OAAA,CAAK,UAAW,GAAGA,CAAoB,cAAe,SAAA,OAAI,QAC1D,OAAA,CAAK,UAAW,GAAGA,CAAoB,cAAe,SAAA,QAAK,QAC3D,OAAA,CAAK,UAAW,iBAAiBA,CAAoB,cAAe,SAAA,OAAI,QACxE,OAAA,CAAK,UAAW,GAAGA,CAAoB,cAAe,SAAA,SAAA,CAAO,CAAA,CAAA,CAChE,CAAA,CACF,EACCoD,EAAO,IAAKE,GACXjC,EAAAA,KAAC,MAAA,CAAoB,UAAU,sBAC7B,SAAA,CAAAF,EAAAA,IAACc,EAAA,CAAK,KAAK,QAAQ,QAAQ,QAAQ,UAAU,gBAC3C,eAAC,OAAA,CAAK,UAAW,GAAGjC,CAAoB,cACrC,WAAgBsD,EAAM,QAAQ,CAAC,EAAE,OAAO,EAC3C,CAAA,CACF,EACCA,EAAM,QAAQ,IAAK5B,GAClBP,EAAAA,IAACM,EAAA,CAAuB,MAAAC,EAAc,YAAaA,EAAM,KAAOiB,CAAA,EAAlDjB,EAAM,EAAoD,CACzE,CAAA,CAAA,EARO4B,EAAM,GAShB,CACD,CAAA,CAAA,CACH,CAAA,EAEJ,CAEJ"}
@@ -1,2 +1,2 @@
1
- import{c as X,r as d,C as O,j as e,e as T,g as U,R as P,J as v,w as N,h as $,k as Q,$ as ae,l as ne,s as L,u as F,t as Z,m as le,a as ee,n as se,P as ie,o as oe,i as Y,q as re,D as C,v as ce,A as B,x as G,y as de,z as me,B as pe,p as _}from"./main-s2b5XHSS.js";import{S as V}from"./sidebar-section-4MxZoa3M.js";const he=async()=>{try{const s=await fetch(X("/api/merge-policy"));return s.ok?await s.json():null}catch{return null}},ue=async()=>{try{const s=await fetch(X("/api/merge-policy/apply"),{method:"POST"});return s.ok?await s.json():null}catch{return null}},te={allowSquashMerge:!0,allowMergeCommit:!1,allowRebaseMerge:!1,squashMergeCommitTitle:"PR_TITLE",squashMergeCommitMessage:"PR_BODY"},H=[{key:"allowSquashMerge",label:"Allow squash merge"},{key:"allowMergeCommit",label:"Allow merge commit"},{key:"allowRebaseMerge",label:"Allow rebase merge"},{key:"squashMergeCommitTitle",label:"Squash commit title"},{key:"squashMergeCommitMessage",label:"Squash commit message"}];function W(s){return typeof s=="boolean"?s?"Yes":"No":s}function xe(s){return H.every(t=>s[t.key]===te[t.key])}const je=({label:s,current:t,recommended:r,isLast:i})=>{const m=t===r;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 pb-2 pt-2",children:[e.jsx("span",{className:"flex-1",children:s}),e.jsx("span",{className:m?"opacity-[0.65] font-normal":"font-semibold",children:W(t)}),!m&&e.jsxs("span",{className:"opacity-[0.45]",children:["→ ",W(r)]})]}),!i&&e.jsx(N,{})]})},ge=()=>{const[s,t]=d.useState(void 0),[r,i]=d.useState(!1),{toast:m}=O();d.useEffect(()=>{he().then(t)},[]);const x=async()=>{i(!0);const l=await ue();i(!1),(l==null?void 0:l.status)==="ok"?(t(l),m({title:"Merge policy applied",variant:"success"})):m({title:"Failed to apply merge policy",description:(l==null?void 0:l.status)==="unavailable"?l.reason:void 0,variant:"error"})},h=(s==null?void 0:s.status)==="ok"&&xe(s.policy);return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"m-0",children:"Merge Policy"}),e.jsx("p",{className:"opacity-50 mt-1",children:"Paper Camp's canonical policy: squash-only merges, with the commit title and body taken from the PR."})]}),s===void 0&&e.jsx("p",{children:"Loading…"}),s===null&&e.jsx(T,{variant:"warning",children:"Failed to load merge policy."}),(s==null?void 0:s.status)==="unavailable"&&e.jsx(T,{variant:"warning",children:s.reason}),(s==null?void 0:s.status)==="ok"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("span",{className:"font-medium",children:s.repo}),e.jsx(U,{size:"small",fillColor:h?"rgba(143, 185, 150, 0.25)":"rgba(212, 163, 115, 0.25)",textColor:h?"#5E8A66":"#A67B4F",children:h?"Matches recommended policy":"Differs from recommended policy"})]}),e.jsx(P,{size:"small",texture:"kraft",children:H.map((l,c)=>e.jsx(je,{label:l.label,current:s.policy[l.key],recommended:te[l.key],isLast:c===H.length-1},l.key))}),e.jsx("div",{className:"mt-4",children:e.jsx(v,{size:"small",onClick:x,disabled:r||h,children:r?"Applying…":"Apply recommended policy"})})]})]})},fe=2e3,ve="agent:claude-code",be=["claude auth login","claude setup-token"],ye=()=>e.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[e.jsx("p",{className:"opacity-[0.65] text-sm m-0",children:"The in-app relay couldn't complete. Run one of these in a terminal instead:"}),be.map(s=>e.jsx(Z,{code:s},s)),e.jsxs("p",{className:"opacity-50 text-sm m-0",children:["Alternatively, set ",e.jsx("code",{children:"ANTHROPIC_API_KEY"})," in the server's environment — that bills as API usage rather than your Max subscription, so treat it as a fallback, not the default."]})]}),Ne=({onSignedIn:s})=>{const t=F(c=>c.loginRelay),r=F(c=>c.startLoginRelay),i=F(c=>c.loadLoginRelayStatus),m=F(c=>c.cancelLoginRelay),{toast:x}=O(),h=d.useRef(null),l=t==null?void 0:t.phase;return d.useEffect(()=>{if(l!=="starting"&&l!=="awaiting-authorization")return;const c=window.setInterval(()=>i(),fe);return()=>window.clearInterval(c)},[l,i]),d.useEffect(()=>{const c=t==null?void 0:t.authorizeUrl;l!=="awaiting-authorization"||!c||h.current===c||(h.current=c,window.open(c,"_blank","noopener,noreferrer"))},[l,t==null?void 0:t.authorizeUrl]),d.useEffect(()=>{l==="success"?(x({title:"Signed in",variant:"success"}),s()):l==="error"&&x({title:"Sign-in failed",description:t==null?void 0:t.error,variant:"error"})},[l]),l==="starting"?e.jsx(v,{size:"small",disabled:!0,children:"Starting…"}):l==="awaiting-authorization"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{size:"small",onClick:()=>(t==null?void 0:t.authorizeUrl)&&window.open(t.authorizeUrl,"_blank","noopener,noreferrer"),children:"Reopen sign-in tab"}),e.jsx(v,{size:"small",onClick:()=>m(),children:"Cancel"})]}):e.jsxs("div",{children:[e.jsx(v,{size:"small",onClick:()=>r(),children:"Sign in"}),l==="error"&&e.jsx(ye,{})]})},Se={ok:{fill:"rgba(143, 185, 150, 0.25)",text:"#5E8A66",label:"Ready"},warn:{fill:"rgba(212, 163, 115, 0.25)",text:"#A67B4F",label:"Needs attention"},missing:{fill:"rgba(201, 139, 139, 0.25)",text:"#6E3A3A",label:"Missing"}},we=({connection:s,onConnect:t,connecting:r})=>{const{connect:i}=s;return i?i.kind==="command"&&i.runnable?e.jsx(v,{size:"small",onClick:()=>t(s.id),disabled:r,children:r?"Running…":`Run \`${i.command}\``}):i.kind==="command"?e.jsx("div",{className:"mt-2",children:e.jsx(Z,{code:i.command})}):i.kind==="link"?e.jsx(v,{size:"small",onClick:()=>window.open(i.url,"_blank","noopener,noreferrer"),children:i.label}):e.jsx("p",{className:"opacity-[0.65] text-sm mt-2 mx-0 mb-0",children:i.message}):null},J=({connection:s,isLast:t,onRecheck:r,rechecking:i,onConnect:m,connecting:x})=>{const h=Se[s.status];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pb-3 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex-1 font-medium",children:s.label}),s.authenticated===!1&&e.jsx(ae,{content:"Installed, but not signed in",children:e.jsx(U,{size:"small",variant:"warning",children:"Not signed in"})}),e.jsx(U,{size:"small",fillColor:h.fill,textColor:h.text,children:h.label}),e.jsx(v,{size:"small",onClick:()=>r(s.id),disabled:i,children:i?"Checking…":"Recheck"})]}),e.jsxs("p",{className:"opacity-[0.65] text-sm mt-1 mx-0 mb-0",children:["Unlocks: ",s.unlocks]}),e.jsx("p",{className:"opacity-50 text-sm mt-1 mx-0 mb-0",children:s.detail}),e.jsx("div",{className:"mt-2",children:s.id===ve&&s.authenticated===!1?e.jsx(Ne,{onSignedIn:()=>r(s.id)}):e.jsx(we,{connection:s,onConnect:m,connecting:x})})]}),!t&&e.jsx(N,{})]})},ke=()=>{const[s,t]=d.useState(null),[r,i]=d.useState(!1),[m,x]=d.useState(null),[h,l]=d.useState(null),[c,S]=d.useState(!1),{toast:b}=O(),w=d.useCallback(n=>{if(n===null){i(!0);return}i(!1),t(n)},[]);d.useEffect(()=>{$().then(w),Q().then(n=>S((n==null?void 0:n.setupDismissed)??!1))},[w]);const R=async n=>{x(n),w(await $()),x(null)},k=async n=>{l(n);const f=await ne(n);f?t(E=>(E==null?void 0:E.map(M=>M.id===n?f:M))??E):b({title:"Failed to connect",variant:"error"}),l(null)},j=async()=>{const n=!c,{ok:f}=await L({setupDismissed:n});f?(S(n),b({title:"Saved",variant:"success"})):b({title:"Failed to save",variant:"error"})},p=(s==null?void 0:s.every(n=>n.status==="ok"))??!0,A=(s==null?void 0:s.filter(n=>n.kind==="external"))??[],y=(s==null?void 0:s.filter(n=>n.kind==="local"))??[];return e.jsxs("div",{children:[e.jsx("div",{className:"mb-6",children:e.jsx("h2",{className:"m-0",children:"Setup"})}),s===null&&!r&&e.jsx("p",{children:"Loading…"}),r&&e.jsx("div",{className:"mb-4",children:e.jsx(T,{variant:"warning",children:"Failed to load connections. Try refreshing."})}),s&&e.jsxs(e.Fragment,{children:[!p&&e.jsx("div",{className:"mb-4",children:e.jsx(T,{variant:"warning",children:"Some connections are incomplete — features that depend on them stay disabled until fixed. Run the connect command below, then recheck."})}),A.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"opacity-[0.45] text-sm mt-0 mb-2",children:"External services — reached on your behalf with their own remote credential."}),e.jsx(P,{size:"small",texture:"kraft",children:A.map((n,f)=>e.jsx(J,{connection:n,isLast:f===A.length-1,onRecheck:R,rechecking:m===n.id,onConnect:k,connecting:h===n.id},n.id))})]}),y.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"opacity-[0.45] text-sm mt-0 mb-2",children:"Local adapters — driven on this machine with their own local session."}),e.jsx(P,{size:"small",texture:"kraft",children:y.map((n,f)=>e.jsx(J,{connection:n,isLast:f===y.length-1,onRecheck:R,rechecking:m===n.id,onConnect:k,connecting:h===n.id},n.id))})]}),e.jsx("div",{className:"mt-4",children:e.jsx(v,{size:"small",onClick:j,children:c?"Show Setup on open again":"Don't show Setup on open"})})]})]})},Ae=()=>{const{subjects:s,loading:t,available:r}=le(),i=ee();return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"m-0",children:"Subjects"}),e.jsx("p",{className:"opacity-50 mt-1",children:"Subjects are the roadmap's bets and standing concerns. Edit the vocabulary on the Roadmap page."})]}),t&&e.jsx("p",{children:"Loading…"}),!t&&!r&&e.jsx("p",{className:"opacity-60 m-0",children:"Couldn't load subjects — check the server config."}),!t&&r&&e.jsxs(P,{size:"small",texture:"kraft",children:[s.length===0&&e.jsx("p",{className:"opacity-[0.45] m-0 pb-2",children:"No subjects yet."}),s.map((m,x)=>e.jsxs("div",{children:[e.jsx("div",{className:"pb-2 pt-2",children:m}),x<s.length-1&&e.jsx(N,{})]},m)),s.length>0&&e.jsx(N,{}),e.jsx("div",{className:"pt-3",children:e.jsx(v,{size:"small",onClick:()=>i({to:"/roadmap"}),children:"Go to Roadmap"})})]})]})},K=["phase","planDraft","ideaExtend","commitSuggest","feedback","codeReview"],Ce={phase:"Phase run",planDraft:"Plan draft",ideaExtend:"Idea extend",commitSuggest:"Commit suggest",feedback:"Scout chat",codeReview:"Code review"},Re=140,Ee=160,Ie=110,ze=()=>e.jsxs("div",{className:"flex items-center gap-3 pb-1",children:[e.jsx("span",{className:"w-[110px] shrink-0 text-sm opacity-[0.45]",children:"Task"}),e.jsx("span",{className:"w-[140px] shrink-0 text-sm opacity-[0.45]",children:"Agent"}),e.jsx("span",{className:"w-[160px] shrink-0 text-sm opacity-[0.45]",children:"Model"}),e.jsx("span",{className:"w-[110px] shrink-0 text-sm opacity-[0.45]",children:"Effort"})]}),De=({taskKey:s,agentConfig:t,isLast:r,onSave:i,authorConfig:m})=>{const x=B[t.agent]??B["claude-code"],h=m&&m.agent===t.agent?m.model??"":void 0,l=Array.isArray(x.model)?x.model.filter(p=>p!==h):x.model,c=x.effort,[S,b]=d.useState(t.model??"");d.useEffect(()=>{b(t.model??"")},[t.model]);const w=p=>{var f;const A=p,y=B[A],n={agent:A};t.model&&(y.model===null||(f=y.model)!=null&&f.includes(t.model))&&(n.model=t.model),t.effort&&Array.isArray(y.effort)&&(n.effort=t.effort),i(s,n)},R=p=>{i(s,{...t,model:p||void 0})},k=()=>{i(s,{...t,model:S||void 0})},j=p=>{i(s,{...t,effort:p||void 0})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 pb-2 pt-2",children:[e.jsx("span",{className:"w-[110px] shrink-0 text-sm opacity-[0.65]",children:Ce[s]}),e.jsx(G,{size:"small",width:Re,value:t.agent,onChange:w,options:de.map(p=>({value:p,label:me[p]}))}),Array.isArray(l)?e.jsx(G,{size:"small",width:Ee,value:t.model??"",onChange:R,options:[...h===""?[]:[{value:"",label:"Default"}],...l.map(p=>({value:p,label:p}))]}):l===null?e.jsx(Y,{size:"small",className:"w-[160px]",value:S,placeholder:"Default model",onChange:p=>b(p.target.value),onBlur:k}):null,e.jsx("div",{className:Array.isArray(c)?"visible":"invisible",children:e.jsx(G,{size:"small",width:Ie,value:t.effort??"",onChange:j,options:[{value:"",label:"Default"},...(Array.isArray(c)?c:[]).map(p=>({value:p,label:p}))]})})]}),!r&&e.jsx(N,{})]})},Me=()=>{var E,M;const s=d.useRef(null),[t,r]=d.useState(void 0),{iconDataUri:i,loading:m}=oe(),[x,h]=d.useState(null),l=x??i,[c,S]=d.useState(!1),[b,w]=d.useState(""),[R,k]=d.useState(""),{toast:j}=O();d.useEffect(()=>{Q().then(a=>{r(a),(a==null?void 0:a.port)!==void 0&&w(String(a.port)),(a==null?void 0:a.projectName)!==void 0&&k(a.projectName)})},[]);const p=async(a,g)=>{const o=t==null?void 0:t.defaultAgents,u={phase:(o==null?void 0:o.phase)??C.phase,planDraft:(o==null?void 0:o.planDraft)??C.planDraft,ideaExtend:(o==null?void 0:o.ideaExtend)??C.ideaExtend,commitSuggest:(o==null?void 0:o.commitSuggest)??C.commitSuggest,feedback:(o==null?void 0:o.feedback)??C.feedback,codeReview:(o==null?void 0:o.codeReview)??C.codeReview,[a]:g};if(a==="codeReview"&&pe(g,u.phase)){j({title:"Failed to save",description:"Code review must use a different model than Phase run.",variant:"error"});return}const{ok:I,error:z}=await L({defaultAgents:u});I?(r(D=>D&&{...D,defaultAgents:u}),j({title:"Saved",variant:"success"})):j({title:"Failed to save",description:z,variant:"error"})},A=async()=>{const a=Number(b);if(!t||!Number.isInteger(a)||a<=0||a===t.port)return;const{ok:g,error:o}=await L({port:a});g?(r(u=>u&&{...u,port:a}),j({title:"Saved",description:"Restart `paper-camp dev` to apply the new port.",variant:"success"})):j({title:"Failed to save",description:o,variant:"error"})},y=async()=>{var I,z,D;if(!t)return;const a=!(((z=(I=t.integration)==null?void 0:I.toolbar)==null?void 0:z.enabled)??!0),g={...t.integration,toolbar:{...(D=t.integration)==null?void 0:D.toolbar,enabled:a}},{ok:o,error:u}=await L({integration:g});o?(r(q=>q&&{...q,integration:g}),j({title:"Saved",variant:"success"})):j({title:"Failed to save",description:u,variant:"error"})},n=async()=>{const a=R.trim();if(!t||!a||a===t.projectName)return;const{ok:g,error:o}=await L({projectName:a});g?(r(u=>u&&{...u,projectName:a}),k(a),j({title:"Saved",variant:"success"})):j({title:"Failed to save",description:o,variant:"error"})},f=async a=>{var u;const g=(u=a.target.files)==null?void 0:u[0];if(!g)return;S(!0);const o=new FileReader;o.onloadend=async()=>{const I=o.result,z=await ce(I);S(!1),z?(h(I),j({title:"Saved",variant:"success"})):j({title:"Failed to save",variant:"error"})},o.readAsDataURL(g)};return e.jsxs("div",{children:[e.jsx("div",{className:"mb-6",children:e.jsx("h2",{className:"m-0",children:"Project Info"})}),t===void 0&&e.jsx("p",{children:"Loading…"}),t===null&&e.jsxs(T,{variant:"warning",children:["No papercamp/config.json found — run ",e.jsx("code",{children:"paper-camp init"})," in this directory first."]}),t&&e.jsxs(P,{size:"small",texture:"kraft",children:[e.jsxs("div",{className:"flex items-end gap-3 pb-3",children:[e.jsx(Y,{value:R,onChange:a=>k(a.target.value),onBlur:n,label:"Project Name"}),e.jsxs(U,{size:"small",fillColor:"rgba(143, 185, 150, 0.25)",textColor:re.accentGreenDark,children:["v",t.version]})]}),e.jsx(N,{}),e.jsxs("div",{className:"flex items-center gap-3 pb-3 pt-3",children:[l&&e.jsx("img",{src:l,alt:"Project icon",className:"w-10 h-10 object-contain shrink-0 rounded"}),e.jsxs("div",{children:[e.jsx("input",{ref:s,type:"file",accept:".svg,.png,.jpg,.jpeg,.gif,.webp",onChange:f,className:"hidden"}),e.jsx(v,{size:"small",onClick:()=>{var a;return(a=s.current)==null?void 0:a.click()},disabled:c,children:c?"Uploading…":"Choose File"}),m&&e.jsx("p",{className:"text-sm opacity-50 mt-1 mx-0 mb-0",children:"Loading…"}),!m&&!l&&!c&&e.jsx("p",{className:"text-sm opacity-[0.45] mt-1 mx-0 mb-0",children:"No icon set."})]})]}),e.jsx(N,{}),e.jsx("div",{className:"flex items-end gap-3 pb-3 pt-3",children:e.jsx(Y,{type:"number",value:b,onChange:a=>w(a.target.value),onBlur:A,label:"Port",helperText:"Default for `paper-camp dev`. Restart the server to apply a change."})}),e.jsx(N,{}),e.jsxs("div",{className:"flex items-center justify-between gap-3 pb-3 pt-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"m-0",children:"In-app dev toolbar"}),e.jsx("p",{className:"opacity-[0.45] text-sm mt-1 mx-0 mb-0",children:"Inject the paper-camp toolbar into this project's dev server via the Vite plugin."})]}),e.jsx(v,{size:"small",onClick:y,children:((M=(E=t.integration)==null?void 0:E.toolbar)==null?void 0:M.enabled)??!0?"Disable":"Enable"})]}),e.jsx(N,{}),e.jsx(ze,{}),K.map((a,g)=>{var o,u;return e.jsx(De,{taskKey:a,agentConfig:((o=t.defaultAgents)==null?void 0:o[a])??C[a],isLast:g===K.length-1,onSave:p,authorConfig:a==="codeReview"?((u=t.defaultAgents)==null?void 0:u.phase)??C.phase:void 0},a)})]}),e.jsxs("p",{className:"opacity-[0.45] text-sm mt-4",children:[e.jsx("strong",{children:"Initialized:"})," ",t?new Date(t.initializedAt).toLocaleString():"—"]})]})},Pe=()=>{const s=se();return e.jsxs("div",{children:[e.jsx(ie,{children:"Settings"}),s==="subjects"?e.jsx(Ae,{}):s==="setup"?e.jsx(ke,{}):s==="merge-policy"?e.jsx(ge,{}):e.jsx(Me,{})]})},Fe=()=>{const s=se(),t=ee();return e.jsxs(e.Fragment,{children:[e.jsxs(V,{label:"General",children:[e.jsx(_,{size:"small",className:"pc-row text-xs",active:s===null,onClick:()=>t({to:"/settings"}),children:"Project Info"}),e.jsx(_,{size:"small",className:"pc-row text-xs",active:s==="setup",onClick:()=>t({to:"/settings/$section",params:{section:"setup"}}),children:"Setup"}),e.jsx(_,{size:"small",className:"pc-row text-xs",active:s==="merge-policy",onClick:()=>t({to:"/settings/$section",params:{section:"merge-policy"}}),children:"Merge Policy"})]}),e.jsx(V,{label:"Ideas",children:e.jsx(_,{size:"small",className:"pc-row text-xs",active:s==="subjects",onClick:()=>t({to:"/settings/$section",params:{section:"subjects"}}),children:"Subjects"})})]})};export{Pe as SettingsPage,Fe as SettingsSidebar};
2
- //# sourceMappingURL=index-VXeQcBh1.js.map
1
+ import{c as X,r as d,C as O,j as e,e as T,g as U,R as P,J as v,w as N,h as $,k as Q,$ as ae,l as ne,s as L,u as F,t as Z,m as le,a as ee,n as se,P as ie,o as oe,i as Y,q as re,D as C,v as ce,A as B,x as G,y as de,z as me,B as pe,p as _}from"./main-C8ibbBFi.js";import{S as V}from"./sidebar-section-0u_lUROT.js";const he=async()=>{try{const s=await fetch(X("/api/merge-policy"));return s.ok?await s.json():null}catch{return null}},ue=async()=>{try{const s=await fetch(X("/api/merge-policy/apply"),{method:"POST"});return s.ok?await s.json():null}catch{return null}},te={allowSquashMerge:!0,allowMergeCommit:!1,allowRebaseMerge:!1,squashMergeCommitTitle:"PR_TITLE",squashMergeCommitMessage:"PR_BODY"},H=[{key:"allowSquashMerge",label:"Allow squash merge"},{key:"allowMergeCommit",label:"Allow merge commit"},{key:"allowRebaseMerge",label:"Allow rebase merge"},{key:"squashMergeCommitTitle",label:"Squash commit title"},{key:"squashMergeCommitMessage",label:"Squash commit message"}];function W(s){return typeof s=="boolean"?s?"Yes":"No":s}function xe(s){return H.every(t=>s[t.key]===te[t.key])}const je=({label:s,current:t,recommended:r,isLast:i})=>{const m=t===r;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 pb-2 pt-2",children:[e.jsx("span",{className:"flex-1",children:s}),e.jsx("span",{className:m?"opacity-[0.65] font-normal":"font-semibold",children:W(t)}),!m&&e.jsxs("span",{className:"opacity-[0.45]",children:["→ ",W(r)]})]}),!i&&e.jsx(N,{})]})},ge=()=>{const[s,t]=d.useState(void 0),[r,i]=d.useState(!1),{toast:m}=O();d.useEffect(()=>{he().then(t)},[]);const x=async()=>{i(!0);const l=await ue();i(!1),(l==null?void 0:l.status)==="ok"?(t(l),m({title:"Merge policy applied",variant:"success"})):m({title:"Failed to apply merge policy",description:(l==null?void 0:l.status)==="unavailable"?l.reason:void 0,variant:"error"})},h=(s==null?void 0:s.status)==="ok"&&xe(s.policy);return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"m-0",children:"Merge Policy"}),e.jsx("p",{className:"opacity-50 mt-1",children:"Paper Camp's canonical policy: squash-only merges, with the commit title and body taken from the PR."})]}),s===void 0&&e.jsx("p",{children:"Loading…"}),s===null&&e.jsx(T,{variant:"warning",children:"Failed to load merge policy."}),(s==null?void 0:s.status)==="unavailable"&&e.jsx(T,{variant:"warning",children:s.reason}),(s==null?void 0:s.status)==="ok"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("span",{className:"font-medium",children:s.repo}),e.jsx(U,{size:"small",fillColor:h?"rgba(143, 185, 150, 0.25)":"rgba(212, 163, 115, 0.25)",textColor:h?"#5E8A66":"#A67B4F",children:h?"Matches recommended policy":"Differs from recommended policy"})]}),e.jsx(P,{size:"small",texture:"kraft",children:H.map((l,c)=>e.jsx(je,{label:l.label,current:s.policy[l.key],recommended:te[l.key],isLast:c===H.length-1},l.key))}),e.jsx("div",{className:"mt-4",children:e.jsx(v,{size:"small",onClick:x,disabled:r||h,children:r?"Applying…":"Apply recommended policy"})})]})]})},fe=2e3,ve="agent:claude-code",be=["claude auth login","claude setup-token"],ye=()=>e.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[e.jsx("p",{className:"opacity-[0.65] text-sm m-0",children:"The in-app relay couldn't complete. Run one of these in a terminal instead:"}),be.map(s=>e.jsx(Z,{code:s},s)),e.jsxs("p",{className:"opacity-50 text-sm m-0",children:["Alternatively, set ",e.jsx("code",{children:"ANTHROPIC_API_KEY"})," in the server's environment — that bills as API usage rather than your Max subscription, so treat it as a fallback, not the default."]})]}),Ne=({onSignedIn:s})=>{const t=F(c=>c.loginRelay),r=F(c=>c.startLoginRelay),i=F(c=>c.loadLoginRelayStatus),m=F(c=>c.cancelLoginRelay),{toast:x}=O(),h=d.useRef(null),l=t==null?void 0:t.phase;return d.useEffect(()=>{if(l!=="starting"&&l!=="awaiting-authorization")return;const c=window.setInterval(()=>i(),fe);return()=>window.clearInterval(c)},[l,i]),d.useEffect(()=>{const c=t==null?void 0:t.authorizeUrl;l!=="awaiting-authorization"||!c||h.current===c||(h.current=c,window.open(c,"_blank","noopener,noreferrer"))},[l,t==null?void 0:t.authorizeUrl]),d.useEffect(()=>{l==="success"?(x({title:"Signed in",variant:"success"}),s()):l==="error"&&x({title:"Sign-in failed",description:t==null?void 0:t.error,variant:"error"})},[l]),l==="starting"?e.jsx(v,{size:"small",disabled:!0,children:"Starting…"}):l==="awaiting-authorization"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{size:"small",onClick:()=>(t==null?void 0:t.authorizeUrl)&&window.open(t.authorizeUrl,"_blank","noopener,noreferrer"),children:"Reopen sign-in tab"}),e.jsx(v,{size:"small",onClick:()=>m(),children:"Cancel"})]}):e.jsxs("div",{children:[e.jsx(v,{size:"small",onClick:()=>r(),children:"Sign in"}),l==="error"&&e.jsx(ye,{})]})},Se={ok:{fill:"rgba(143, 185, 150, 0.25)",text:"#5E8A66",label:"Ready"},warn:{fill:"rgba(212, 163, 115, 0.25)",text:"#A67B4F",label:"Needs attention"},missing:{fill:"rgba(201, 139, 139, 0.25)",text:"#6E3A3A",label:"Missing"}},we=({connection:s,onConnect:t,connecting:r})=>{const{connect:i}=s;return i?i.kind==="command"&&i.runnable?e.jsx(v,{size:"small",onClick:()=>t(s.id),disabled:r,children:r?"Running…":`Run \`${i.command}\``}):i.kind==="command"?e.jsx("div",{className:"mt-2",children:e.jsx(Z,{code:i.command})}):i.kind==="link"?e.jsx(v,{size:"small",onClick:()=>window.open(i.url,"_blank","noopener,noreferrer"),children:i.label}):e.jsx("p",{className:"opacity-[0.65] text-sm mt-2 mx-0 mb-0",children:i.message}):null},J=({connection:s,isLast:t,onRecheck:r,rechecking:i,onConnect:m,connecting:x})=>{const h=Se[s.status];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pb-3 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex-1 font-medium",children:s.label}),s.authenticated===!1&&e.jsx(ae,{content:"Installed, but not signed in",children:e.jsx(U,{size:"small",variant:"warning",children:"Not signed in"})}),e.jsx(U,{size:"small",fillColor:h.fill,textColor:h.text,children:h.label}),e.jsx(v,{size:"small",onClick:()=>r(s.id),disabled:i,children:i?"Checking…":"Recheck"})]}),e.jsxs("p",{className:"opacity-[0.65] text-sm mt-1 mx-0 mb-0",children:["Unlocks: ",s.unlocks]}),e.jsx("p",{className:"opacity-50 text-sm mt-1 mx-0 mb-0",children:s.detail}),e.jsx("div",{className:"mt-2",children:s.id===ve&&s.authenticated===!1?e.jsx(Ne,{onSignedIn:()=>r(s.id)}):e.jsx(we,{connection:s,onConnect:m,connecting:x})})]}),!t&&e.jsx(N,{})]})},ke=()=>{const[s,t]=d.useState(null),[r,i]=d.useState(!1),[m,x]=d.useState(null),[h,l]=d.useState(null),[c,S]=d.useState(!1),{toast:b}=O(),w=d.useCallback(n=>{if(n===null){i(!0);return}i(!1),t(n)},[]);d.useEffect(()=>{$().then(w),Q().then(n=>S((n==null?void 0:n.setupDismissed)??!1))},[w]);const R=async n=>{x(n),w(await $()),x(null)},k=async n=>{l(n);const f=await ne(n);f?t(E=>(E==null?void 0:E.map(M=>M.id===n?f:M))??E):b({title:"Failed to connect",variant:"error"}),l(null)},j=async()=>{const n=!c,{ok:f}=await L({setupDismissed:n});f?(S(n),b({title:"Saved",variant:"success"})):b({title:"Failed to save",variant:"error"})},p=(s==null?void 0:s.every(n=>n.status==="ok"))??!0,A=(s==null?void 0:s.filter(n=>n.kind==="external"))??[],y=(s==null?void 0:s.filter(n=>n.kind==="local"))??[];return e.jsxs("div",{children:[e.jsx("div",{className:"mb-6",children:e.jsx("h2",{className:"m-0",children:"Setup"})}),s===null&&!r&&e.jsx("p",{children:"Loading…"}),r&&e.jsx("div",{className:"mb-4",children:e.jsx(T,{variant:"warning",children:"Failed to load connections. Try refreshing."})}),s&&e.jsxs(e.Fragment,{children:[!p&&e.jsx("div",{className:"mb-4",children:e.jsx(T,{variant:"warning",children:"Some connections are incomplete — features that depend on them stay disabled until fixed. Run the connect command below, then recheck."})}),A.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"opacity-[0.45] text-sm mt-0 mb-2",children:"External services — reached on your behalf with their own remote credential."}),e.jsx(P,{size:"small",texture:"kraft",children:A.map((n,f)=>e.jsx(J,{connection:n,isLast:f===A.length-1,onRecheck:R,rechecking:m===n.id,onConnect:k,connecting:h===n.id},n.id))})]}),y.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"opacity-[0.45] text-sm mt-0 mb-2",children:"Local adapters — driven on this machine with their own local session."}),e.jsx(P,{size:"small",texture:"kraft",children:y.map((n,f)=>e.jsx(J,{connection:n,isLast:f===y.length-1,onRecheck:R,rechecking:m===n.id,onConnect:k,connecting:h===n.id},n.id))})]}),e.jsx("div",{className:"mt-4",children:e.jsx(v,{size:"small",onClick:j,children:c?"Show Setup on open again":"Don't show Setup on open"})})]})]})},Ae=()=>{const{subjects:s,loading:t,available:r}=le(),i=ee();return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"m-0",children:"Subjects"}),e.jsx("p",{className:"opacity-50 mt-1",children:"Subjects are the roadmap's bets and standing concerns. Edit the vocabulary on the Roadmap page."})]}),t&&e.jsx("p",{children:"Loading…"}),!t&&!r&&e.jsx("p",{className:"opacity-60 m-0",children:"Couldn't load subjects — check the server config."}),!t&&r&&e.jsxs(P,{size:"small",texture:"kraft",children:[s.length===0&&e.jsx("p",{className:"opacity-[0.45] m-0 pb-2",children:"No subjects yet."}),s.map((m,x)=>e.jsxs("div",{children:[e.jsx("div",{className:"pb-2 pt-2",children:m}),x<s.length-1&&e.jsx(N,{})]},m)),s.length>0&&e.jsx(N,{}),e.jsx("div",{className:"pt-3",children:e.jsx(v,{size:"small",onClick:()=>i({to:"/roadmap"}),children:"Go to Roadmap"})})]})]})},K=["phase","planDraft","ideaExtend","commitSuggest","feedback","codeReview"],Ce={phase:"Phase run",planDraft:"Plan draft",ideaExtend:"Idea extend",commitSuggest:"Commit suggest",feedback:"Scout chat",codeReview:"Code review"},Re=140,Ee=160,Ie=110,ze=()=>e.jsxs("div",{className:"flex items-center gap-3 pb-1",children:[e.jsx("span",{className:"w-[110px] shrink-0 text-sm opacity-[0.45]",children:"Task"}),e.jsx("span",{className:"w-[140px] shrink-0 text-sm opacity-[0.45]",children:"Agent"}),e.jsx("span",{className:"w-[160px] shrink-0 text-sm opacity-[0.45]",children:"Model"}),e.jsx("span",{className:"w-[110px] shrink-0 text-sm opacity-[0.45]",children:"Effort"})]}),De=({taskKey:s,agentConfig:t,isLast:r,onSave:i,authorConfig:m})=>{const x=B[t.agent]??B["claude-code"],h=m&&m.agent===t.agent?m.model??"":void 0,l=Array.isArray(x.model)?x.model.filter(p=>p!==h):x.model,c=x.effort,[S,b]=d.useState(t.model??"");d.useEffect(()=>{b(t.model??"")},[t.model]);const w=p=>{var f;const A=p,y=B[A],n={agent:A};t.model&&(y.model===null||(f=y.model)!=null&&f.includes(t.model))&&(n.model=t.model),t.effort&&Array.isArray(y.effort)&&(n.effort=t.effort),i(s,n)},R=p=>{i(s,{...t,model:p||void 0})},k=()=>{i(s,{...t,model:S||void 0})},j=p=>{i(s,{...t,effort:p||void 0})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 pb-2 pt-2",children:[e.jsx("span",{className:"w-[110px] shrink-0 text-sm opacity-[0.65]",children:Ce[s]}),e.jsx(G,{size:"small",width:Re,value:t.agent,onChange:w,options:de.map(p=>({value:p,label:me[p]}))}),Array.isArray(l)?e.jsx(G,{size:"small",width:Ee,value:t.model??"",onChange:R,options:[...h===""?[]:[{value:"",label:"Default"}],...l.map(p=>({value:p,label:p}))]}):l===null?e.jsx(Y,{size:"small",className:"w-[160px]",value:S,placeholder:"Default model",onChange:p=>b(p.target.value),onBlur:k}):null,e.jsx("div",{className:Array.isArray(c)?"visible":"invisible",children:e.jsx(G,{size:"small",width:Ie,value:t.effort??"",onChange:j,options:[{value:"",label:"Default"},...(Array.isArray(c)?c:[]).map(p=>({value:p,label:p}))]})})]}),!r&&e.jsx(N,{})]})},Me=()=>{var E,M;const s=d.useRef(null),[t,r]=d.useState(void 0),{iconDataUri:i,loading:m}=oe(),[x,h]=d.useState(null),l=x??i,[c,S]=d.useState(!1),[b,w]=d.useState(""),[R,k]=d.useState(""),{toast:j}=O();d.useEffect(()=>{Q().then(a=>{r(a),(a==null?void 0:a.port)!==void 0&&w(String(a.port)),(a==null?void 0:a.projectName)!==void 0&&k(a.projectName)})},[]);const p=async(a,g)=>{const o=t==null?void 0:t.defaultAgents,u={phase:(o==null?void 0:o.phase)??C.phase,planDraft:(o==null?void 0:o.planDraft)??C.planDraft,ideaExtend:(o==null?void 0:o.ideaExtend)??C.ideaExtend,commitSuggest:(o==null?void 0:o.commitSuggest)??C.commitSuggest,feedback:(o==null?void 0:o.feedback)??C.feedback,codeReview:(o==null?void 0:o.codeReview)??C.codeReview,[a]:g};if(a==="codeReview"&&pe(g,u.phase)){j({title:"Failed to save",description:"Code review must use a different model than Phase run.",variant:"error"});return}const{ok:I,error:z}=await L({defaultAgents:u});I?(r(D=>D&&{...D,defaultAgents:u}),j({title:"Saved",variant:"success"})):j({title:"Failed to save",description:z,variant:"error"})},A=async()=>{const a=Number(b);if(!t||!Number.isInteger(a)||a<=0||a===t.port)return;const{ok:g,error:o}=await L({port:a});g?(r(u=>u&&{...u,port:a}),j({title:"Saved",description:"Restart `paper-camp dev` to apply the new port.",variant:"success"})):j({title:"Failed to save",description:o,variant:"error"})},y=async()=>{var I,z,D;if(!t)return;const a=!(((z=(I=t.integration)==null?void 0:I.toolbar)==null?void 0:z.enabled)??!0),g={...t.integration,toolbar:{...(D=t.integration)==null?void 0:D.toolbar,enabled:a}},{ok:o,error:u}=await L({integration:g});o?(r(q=>q&&{...q,integration:g}),j({title:"Saved",variant:"success"})):j({title:"Failed to save",description:u,variant:"error"})},n=async()=>{const a=R.trim();if(!t||!a||a===t.projectName)return;const{ok:g,error:o}=await L({projectName:a});g?(r(u=>u&&{...u,projectName:a}),k(a),j({title:"Saved",variant:"success"})):j({title:"Failed to save",description:o,variant:"error"})},f=async a=>{var u;const g=(u=a.target.files)==null?void 0:u[0];if(!g)return;S(!0);const o=new FileReader;o.onloadend=async()=>{const I=o.result,z=await ce(I);S(!1),z?(h(I),j({title:"Saved",variant:"success"})):j({title:"Failed to save",variant:"error"})},o.readAsDataURL(g)};return e.jsxs("div",{children:[e.jsx("div",{className:"mb-6",children:e.jsx("h2",{className:"m-0",children:"Project Info"})}),t===void 0&&e.jsx("p",{children:"Loading…"}),t===null&&e.jsxs(T,{variant:"warning",children:["No papercamp/config.json found — run ",e.jsx("code",{children:"paper-camp init"})," in this directory first."]}),t&&e.jsxs(P,{size:"small",texture:"kraft",children:[e.jsxs("div",{className:"flex items-end gap-3 pb-3",children:[e.jsx(Y,{value:R,onChange:a=>k(a.target.value),onBlur:n,label:"Project Name"}),e.jsxs(U,{size:"small",fillColor:"rgba(143, 185, 150, 0.25)",textColor:re.accentGreenDark,children:["v",t.version]})]}),e.jsx(N,{}),e.jsxs("div",{className:"flex items-center gap-3 pb-3 pt-3",children:[l&&e.jsx("img",{src:l,alt:"Project icon",className:"w-10 h-10 object-contain shrink-0 rounded"}),e.jsxs("div",{children:[e.jsx("input",{ref:s,type:"file",accept:".svg,.png,.jpg,.jpeg,.gif,.webp",onChange:f,className:"hidden"}),e.jsx(v,{size:"small",onClick:()=>{var a;return(a=s.current)==null?void 0:a.click()},disabled:c,children:c?"Uploading…":"Choose File"}),m&&e.jsx("p",{className:"text-sm opacity-50 mt-1 mx-0 mb-0",children:"Loading…"}),!m&&!l&&!c&&e.jsx("p",{className:"text-sm opacity-[0.45] mt-1 mx-0 mb-0",children:"No icon set."})]})]}),e.jsx(N,{}),e.jsx("div",{className:"flex items-end gap-3 pb-3 pt-3",children:e.jsx(Y,{type:"number",value:b,onChange:a=>w(a.target.value),onBlur:A,label:"Port",helperText:"Default for `paper-camp dev`. Restart the server to apply a change."})}),e.jsx(N,{}),e.jsxs("div",{className:"flex items-center justify-between gap-3 pb-3 pt-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"m-0",children:"In-app dev toolbar"}),e.jsx("p",{className:"opacity-[0.45] text-sm mt-1 mx-0 mb-0",children:"Inject the paper-camp toolbar into this project's dev server via the Vite plugin."})]}),e.jsx(v,{size:"small",onClick:y,children:((M=(E=t.integration)==null?void 0:E.toolbar)==null?void 0:M.enabled)??!0?"Disable":"Enable"})]}),e.jsx(N,{}),e.jsx(ze,{}),K.map((a,g)=>{var o,u;return e.jsx(De,{taskKey:a,agentConfig:((o=t.defaultAgents)==null?void 0:o[a])??C[a],isLast:g===K.length-1,onSave:p,authorConfig:a==="codeReview"?((u=t.defaultAgents)==null?void 0:u.phase)??C.phase:void 0},a)})]}),e.jsxs("p",{className:"opacity-[0.45] text-sm mt-4",children:[e.jsx("strong",{children:"Initialized:"})," ",t?new Date(t.initializedAt).toLocaleString():"—"]})]})},Pe=()=>{const s=se();return e.jsxs("div",{children:[e.jsx(ie,{children:"Settings"}),s==="subjects"?e.jsx(Ae,{}):s==="setup"?e.jsx(ke,{}):s==="merge-policy"?e.jsx(ge,{}):e.jsx(Me,{})]})},Fe=()=>{const s=se(),t=ee();return e.jsxs(e.Fragment,{children:[e.jsxs(V,{label:"General",children:[e.jsx(_,{size:"small",className:"pc-row text-xs",active:s===null,onClick:()=>t({to:"/settings"}),children:"Project Info"}),e.jsx(_,{size:"small",className:"pc-row text-xs",active:s==="setup",onClick:()=>t({to:"/settings/$section",params:{section:"setup"}}),children:"Setup"}),e.jsx(_,{size:"small",className:"pc-row text-xs",active:s==="merge-policy",onClick:()=>t({to:"/settings/$section",params:{section:"merge-policy"}}),children:"Merge Policy"})]}),e.jsx(V,{label:"Ideas",children:e.jsx(_,{size:"small",className:"pc-row text-xs",active:s==="subjects",onClick:()=>t({to:"/settings/$section",params:{section:"subjects"}}),children:"Subjects"})})]})};export{Pe as SettingsPage,Fe as SettingsSidebar};
2
+ //# sourceMappingURL=index-CBsx6hnr.js.map