openpond 0.0.32 → 0.0.34

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 (92) hide show
  1. package/dist/chunks/{app-layer-CUQQUVJS.js → app-layer-UQQNF5VZ.js} +3 -3
  2. package/dist/chunks/{apps-TAYMUCWX.js → apps-7NSC56K5.js} +3 -3
  3. package/dist/chunks/{chunk-W2DJR3FA.js → chunk-2GCNPJMD.js} +1 -1
  4. package/dist/chunks/{chunk-GYZYZGKS.js → chunk-5MM3P5KY.js} +2 -2
  5. package/dist/chunks/{chunk-E5RVRUJB.js → chunk-B5CFIWWU.js} +1 -1
  6. package/dist/chunks/{chunk-FQW3AQVJ.js → chunk-BZPAW4JY.js} +31 -0
  7. package/dist/chunks/{chunk-5RHZKQRK.js → chunk-E3RLJ5XT.js} +2 -2
  8. package/dist/chunks/{chunk-3UOLQG6N.js → chunk-EBCLEJRO.js} +1 -1
  9. package/dist/chunks/{chunk-D264OHTR.js → chunk-F6FFL3AA.js} +2 -2
  10. package/dist/chunks/{chunk-PJXJ2HRT.js → chunk-G7XOSECC.js} +33 -0
  11. package/dist/chunks/{chunk-EONKWOLU.js → chunk-HGZ3O4TS.js} +2 -2
  12. package/dist/chunks/{chunk-DCNAXREU.js → chunk-JVTACGKD.js} +3 -3
  13. package/dist/chunks/{chunk-Y4F4XD5V.js → chunk-MMDKFTJB.js} +1 -1
  14. package/dist/chunks/{chunk-4HQURM3N.js → chunk-TF234YN4.js} +1 -1
  15. package/dist/chunks/{chunk-3ZJIEA5F.js → chunk-U4TUOBXO.js} +1 -1
  16. package/dist/chunks/{chunk-4M4WAORL.js → chunk-UASXM3RR.js} +4 -4
  17. package/dist/chunks/{chunk-OXQG773T.js → chunk-V7SHAMUN.js} +33 -33
  18. package/dist/chunks/{chunk-Q5MZCRJA.js → chunk-ZDEBKTWR.js} +1 -1
  19. package/dist/chunks/{chunk-XADW35CL.js → chunk-ZRNFOHFH.js} +3 -3
  20. package/dist/chunks/{cli-WW5BVN5Z.js → cli-4ETE5RS2.js} +4 -4
  21. package/dist/chunks/{cli-ZOCP7X5M.js → cli-VEDK2B42.js} +6 -6
  22. package/dist/chunks/{core-commands-SYGK7K57.js → core-commands-J3IQGQOL.js} +4 -4
  23. package/dist/chunks/{extend-Q5HZ7TMA.js → extend-3F3LLDOF.js} +9 -9
  24. package/dist/chunks/{harness-ZPBPQVAS.js → harness-JER7P6MJ.js} +3 -3
  25. package/dist/chunks/{help-3V3TRQNX.js → help-75NFCYJ4.js} +1 -1
  26. package/dist/chunks/{opchat-OUPMEFE5.js → opchat-UT5V7MR2.js} +5 -5
  27. package/dist/chunks/{organizations-5CSLBDAW.js → organizations-ERKRLVNQ.js} +4 -4
  28. package/dist/chunks/{profile-OQYSXHOG.js → profile-A3CUSDIF.js} +7 -7
  29. package/dist/chunks/{project-agent-TBTWOUJF.js → project-agent-FCV5HPYT.js} +6 -6
  30. package/dist/chunks/{sandbox-command-HCHPY7KW.js → sandbox-command-L2QPIWZ5.js} +4 -4
  31. package/dist/chunks/{sandbox-template-PNTOZ6W3.js → sandbox-template-XOIWROEK.js} +5 -5
  32. package/dist/chunks/{src-C6MXLDYQ.js → src-ENVQ7ARM.js} +2 -2
  33. package/dist/chunks/{src-GZT4UX6I.js → src-V4FUQNHR.js} +676 -462
  34. package/dist/chunks/{teams-bot-CQ76XI6T.js → teams-bot-OR3ZJHQ5.js} +3 -3
  35. package/dist/chunks/{workspaces-DHVVOTVR.js → workspaces-L73SRLPA.js} +2 -2
  36. package/dist/cli.js +10 -10
  37. package/dist/web/assets/{AppsView-CF2g-7FH.js → AppsView-CLjjVkjr.js} +1 -1
  38. package/dist/web/assets/{BrowserSidebar-lUsLUl20.js → BrowserSidebar-CkNO8723.js} +1 -1
  39. package/dist/web/assets/{CloudWorkView-BnfGW4OV.js → CloudWorkView-Cu_VqkaD.js} +1 -1
  40. package/dist/web/assets/{CommandMenu-BsS4Bgb6.js → CommandMenu-DWtdkvmq.js} +1 -1
  41. package/dist/web/assets/{CommunityView-C8qVOwlp.js → CommunityView-f03qOTER.js} +1 -1
  42. package/dist/web/assets/{ComposerCreateImproveStrip-C_LIpfSq.js → ComposerCreateImproveStrip-CZpiQJsJ.js} +1 -1
  43. package/dist/web/assets/{GetStartedView-Du533wOh.js → GetStartedView-CLMmryTG.js} +1 -1
  44. package/dist/web/assets/LabsRoute-BwR2g71k.js +4 -0
  45. package/dist/web/assets/{NewProjectDialog-DH7wA1z9.js → NewProjectDialog-PrbA4fL6.js} +1 -1
  46. package/dist/web/assets/{ProfileSettingsSection-D7JvMZdW.js → ProfileSettingsSection-CD_x_V8d.js} +1 -1
  47. package/dist/web/assets/SettingsView-BMmlKvlB.js +63 -0
  48. package/dist/web/assets/SettingsView-CAPf81v3.css +1 -0
  49. package/dist/web/assets/{TeamChatView-D_CE7br9.js → TeamChatView-B5SlhDso.js} +2 -2
  50. package/dist/web/assets/{TerminalOverlay-CC-VDSlp.js → TerminalOverlay-DaGfEprz.js} +1 -1
  51. package/dist/web/assets/TrainingComputeDialog-BFY6E0yU.js +1 -0
  52. package/dist/web/assets/{TrainingCreationPanel-NFCoaBUI.js → TrainingCreationPanel-Cp66gMed.js} +1 -1
  53. package/dist/web/assets/{TrainingDraftPanel-BWEmVFjM.js → TrainingDraftPanel-BX5CCqlO.js} +1 -1
  54. package/dist/web/assets/{WorkspaceDiffPanel-SlLlGZM1.js → WorkspaceDiffPanel-D7ZEbryF.js} +3 -3
  55. package/dist/web/assets/{WorkspaceEnvironmentMenu-BAoMBTVD.js → WorkspaceEnvironmentMenu-D4DmAJaS.js} +1 -1
  56. package/dist/web/assets/{WorkspaceGitDialogs-CVIFrzyl.js → WorkspaceGitDialogs-DHOfJxbL.js} +1 -1
  57. package/dist/web/assets/{WorkspaceMonacoEditor-0trp0-TI.js → WorkspaceMonacoEditor-C0fDue2d.js} +3 -3
  58. package/dist/web/assets/{boxes-CFihgX2z.js → boxes-CXLqRF98.js} +1 -1
  59. package/dist/web/assets/{create-pipeline-request-AJWLMTyw.js → create-pipeline-request-C26NOc7v.js} +1 -1
  60. package/dist/web/assets/{cssMode-HvqfCFyP.js → cssMode-DmtwKUVm.js} +1 -1
  61. package/dist/web/assets/{git-commit-horizontal-C5mUmACv.js → git-commit-horizontal-CDDZl4iA.js} +1 -1
  62. package/dist/web/assets/{htmlMode-C8btgUt-.js → htmlMode-Box0EOm1.js} +1 -1
  63. package/dist/web/assets/index-BUyeKpY6.js +1 -0
  64. package/dist/web/assets/{index-D7Vr3zcV.js → index-CKmte5ok.js} +55 -55
  65. package/dist/web/assets/{info-D0xuy5IB.js → info-4Iy6BKvT.js} +1 -1
  66. package/dist/web/assets/{jsonMode-5zVz9G0X.js → jsonMode-g7t_3HFv.js} +1 -1
  67. package/dist/web/assets/{lspLanguageFeatures-DxlSSL7c.js → lspLanguageFeatures-CwhFOYc9.js} +1 -1
  68. package/dist/web/assets/{monaco.contribution-BKpVvKK9.js → monaco.contribution-B-QC_ls9.js} +2 -2
  69. package/dist/web/assets/{monaco.contribution-B1pWWwqT.js → monaco.contribution-CW2ctrTm.js} +2 -2
  70. package/dist/web/assets/{monaco.contribution-BXdXsSWI.js → monaco.contribution-CwMt3eHi.js} +2 -2
  71. package/dist/web/assets/{monaco.contribution-CIjjzpUR.js → monaco.contribution-DGZAePHI.js} +2 -2
  72. package/dist/web/assets/{monitor-B4-9Shtp.js → monitor-DOVjBLkr.js} +1 -1
  73. package/dist/web/assets/{play-BJdhBqQE.js → play-DLCuESeG.js} +1 -1
  74. package/dist/web/assets/{python-CEK8J4w_.js → python-DRNmHcYd.js} +1 -1
  75. package/dist/web/assets/{refresh-cw-DE0u_nmZ.js → refresh-cw-JNUovwk4.js} +1 -1
  76. package/dist/web/assets/{reply-2MfLJ93n.js → reply-D4QvJyzE.js} +1 -1
  77. package/dist/web/assets/{save-CBIVKaf8.js → save-BR4O4UDP.js} +1 -1
  78. package/dist/web/assets/{toggleHighContrast-CC73mtvA.js → toggleHighContrast-CrfdWIsV.js} +1 -1
  79. package/dist/web/assets/training-DeVTd0m8.css +1 -0
  80. package/dist/web/assets/{tsMode-Bhn9wr_1.js → tsMode-ZuV9go1B.js} +1 -1
  81. package/dist/web/assets/useComputeSettings-DUNS6uOl.js +1 -0
  82. package/dist/web/assets/useComputeSettings-R2Sw621I.css +1 -0
  83. package/dist/web/assets/{wifi-off-BKTqnqj0.js → wifi-off-XFVqsf4c.js} +1 -1
  84. package/dist/web/assets/{workers-C_adgrEg.js → workers-CJpO1Wzj.js} +1 -1
  85. package/dist/web/assets/{yaml-DDRAcADU.js → yaml-AQ4ok5ED.js} +1 -1
  86. package/dist/web/index.html +1 -1
  87. package/package.json +1 -1
  88. package/dist/web/assets/LabsRoute-yk8lNMQc.js +0 -3
  89. package/dist/web/assets/SettingsView-C9TgCaWG.js +0 -63
  90. package/dist/web/assets/SettingsView-DwbGu8Kj.css +0 -1
  91. package/dist/web/assets/index-DUqAiF57.js +0 -1
  92. package/dist/web/assets/training-BY8siNUK.css +0 -1
@@ -1,13 +1,13 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
2
  import {
3
3
  resolveSandboxClient
4
- } from "./chunk-D264OHTR.js";
5
- import "./chunk-3ZJIEA5F.js";
4
+ } from "./chunk-F6FFL3AA.js";
5
+ import "./chunk-U4TUOBXO.js";
6
6
  import {
7
7
  optionString,
8
8
  parseJsonOption,
9
9
  requiredTeamId
10
- } from "./chunk-OXQG773T.js";
10
+ } from "./chunk-V7SHAMUN.js";
11
11
  import "./chunk-UACZUFIA.js";
12
12
 
13
13
  // src/cli/teams-bot.ts
@@ -43,8 +43,8 @@ import {
43
43
  truncatePatch,
44
44
  uniqueSortedPaths,
45
45
  workspaceImageContentType
46
- } from "./chunk-E5RVRUJB.js";
47
- import "./chunk-Q5MZCRJA.js";
46
+ } from "./chunk-B5CFIWWU.js";
47
+ import "./chunk-ZDEBKTWR.js";
48
48
  import "./chunk-UACZUFIA.js";
49
49
  export {
50
50
  MACOS_GIT_MISSING_DEVELOPER_TOOLS_ERROR,
package/dist/cli.js CHANGED
@@ -4,12 +4,12 @@ import {
4
4
  parseArgs,
5
5
  resolveAccountOption,
6
6
  resolveBaseUrlOption
7
- } from "./chunks/chunk-3ZJIEA5F.js";
7
+ } from "./chunks/chunk-U4TUOBXO.js";
8
8
  import {
9
9
  getInstalledCliVersion,
10
10
  parseBooleanOption,
11
11
  runCliCommand
12
- } from "./chunks/chunk-OXQG773T.js";
12
+ } from "./chunks/chunk-V7SHAMUN.js";
13
13
  import "./chunks/chunk-UACZUFIA.js";
14
14
 
15
15
  // src/cli/top-level-action.ts
@@ -32,11 +32,11 @@ async function runOpenPondCli(argv = process.argv.slice(2)) {
32
32
  return;
33
33
  }
34
34
  if (action === "check-update") {
35
- await (await import("./chunks/core-commands-SYGK7K57.js")).runCheckUpdate();
35
+ await (await import("./chunks/core-commands-J3IQGQOL.js")).runCheckUpdate();
36
36
  return;
37
37
  }
38
38
  if (action === "help") {
39
- (await import("./chunks/help-3V3TRQNX.js")).printHelp();
39
+ (await import("./chunks/help-75NFCYJ4.js")).printHelp();
40
40
  return;
41
41
  }
42
42
  const selectedAccount = resolveAccountOption(options);
@@ -48,31 +48,31 @@ async function runOpenPondCli(argv = process.argv.slice(2)) {
48
48
  process.env.OPENPOND_BASE_URL = selectedBaseUrl;
49
49
  }
50
50
  if (action === "tui") {
51
- await (await import("./chunks/app-layer-CUQQUVJS.js")).runOpenPondTerminalCommand(options, rest);
51
+ await (await import("./chunks/app-layer-UQQNF5VZ.js")).runOpenPondTerminalCommand(options, rest);
52
52
  return;
53
53
  }
54
54
  if (action === "ui") {
55
- await (await import("./chunks/app-layer-CUQQUVJS.js")).runOpenPondServerCommand("web", options, rest);
55
+ await (await import("./chunks/app-layer-UQQNF5VZ.js")).runOpenPondServerCommand("web", options, rest);
56
56
  return;
57
57
  }
58
58
  if (await runCliCommand({ command, options, rest })) {
59
59
  return;
60
60
  }
61
- (await import("./chunks/help-3V3TRQNX.js")).printHelp();
61
+ (await import("./chunks/help-75NFCYJ4.js")).printHelp();
62
62
  process.exit(1);
63
63
  }
64
64
  async function runEmbeddedCompanion(argv) {
65
65
  if (argv[0] === "__server") {
66
66
  process.argv = [process.execPath, "openpond-server", ...argv.slice(1)];
67
67
  const [{ createOpenPondServer }, { runOpenPondServerCli }] = await Promise.all([
68
- import("./chunks/src-GZT4UX6I.js"),
69
- import("./chunks/cli-WW5BVN5Z.js")
68
+ import("./chunks/src-V4FUQNHR.js"),
69
+ import("./chunks/cli-4ETE5RS2.js")
70
70
  ]);
71
71
  await runOpenPondServerCli(createOpenPondServer);
72
72
  return true;
73
73
  }
74
74
  if (argv[0] === "__terminal") {
75
- await (await import("./chunks/src-C6MXLDYQ.js")).runOpenPondTerminalCli(argv.slice(1));
75
+ await (await import("./chunks/src-ENVQ7ARM.js")).runOpenPondTerminalCli(argv.slice(1));
76
76
  return true;
77
77
  }
78
78
  return false;
@@ -1 +1 @@
1
- import{r,b4 as b,m as L,j as e,S as I,aT as k,X as P,b5 as E,R as F,E as U,b6 as T,b7 as R}from"./index-D7Vr3zcV.js";const D=["For agents","Featured","Productivity","Developer tools"],M=new Set(["slack","google","github","mcp"]);function J({account:s,connection:n,defaultTeamId:a,onToast:o}){const[c,f]=r.useState(null),[p,v]=r.useState(""),[i,y]=r.useState("For agents"),[u,h]=r.useState(()=>b()),[g,d]=r.useState("idle"),[w,x]=r.useState(null),S=s?.baseUrl??s?.activeProfile?.baseUrl??null,C=O(a,w),N=r.useMemo(()=>u.filter(t=>z(t,i)).filter(t=>q(t,p)),[i,p,u]);r.useEffect(()=>{let t=!0;return n?(d("loading"),L.connectedAppStatus(n,{status:"all"}).then(l=>{t&&(h(l.apps),x(l.teamId?.trim()||null),d("ready"))}).catch(l=>{t&&(console.warn("Unable to load connected app status.",l),h(b()),x(null),d("error"))}),()=>{t=!1}):(h(b()),d("idle"),x(null),()=>{t=!1})},[n]);function A(t){const l=T({appId:t.id,baseUrl:S,teamId:C});V(l).catch(j=>{o?.(j instanceof Error?j.message:String(j),"error")})}return e.jsxs("section",{className:"connected-apps-view","aria-label":"Apps",children:[e.jsxs("div",{className:"connected-apps-header",children:[e.jsxs("div",{children:[e.jsx("h1",{children:"Apps"}),e.jsx("p",{children:"Connect apps that agents can use for chat, knowledge, files, and workflow actions."})]}),e.jsxs("label",{className:"connected-apps-search",children:[e.jsx(I,{size:15}),e.jsx("input",{"aria-label":"Search apps",onChange:t=>v(t.target.value),placeholder:"Search apps",type:"search",value:p})]})]}),e.jsxs("div",{className:`connected-apps-status-strip ${g}`,children:[e.jsx("span",{children:W(g)}),e.jsxs("span",{children:[X(u)," connected"]})]}),e.jsxs("section",{className:"connected-apps-hero","aria-label":"App context",children:[e.jsxs("div",{className:"connected-apps-hero-copy",children:[e.jsx("span",{className:"connected-apps-hero-icon",children:e.jsx(m,{appId:"github"})}),e.jsx("h2",{children:"Work with your apps"}),e.jsx("p",{children:"Bring repositories, documents, chat, calendars, and custom MCP tools into OpenPond."})]}),e.jsxs("div",{className:"connected-apps-context-card","aria-hidden":"true",children:[e.jsx("strong",{children:"Agent context"}),e.jsxs("div",{children:[e.jsx("span",{className:"files",children:"Files"}),e.jsx("span",{className:"chat",children:"Chat"}),e.jsx("span",{className:"oauth",children:"OAuth"}),e.jsx("span",{className:"mcp",children:"MCP"})]})]})]}),e.jsx("div",{className:"connected-apps-filters",role:"tablist","aria-label":"App categories",children:D.map(t=>e.jsx("button",{"aria-selected":i===t,className:i===t?"active":"",onClick:()=>y(t),role:"tab",type:"button",children:t},t))}),e.jsxs("div",{className:"connected-apps-list",children:[N.map(t=>e.jsx(_,{app:t,onSelect:()=>f(t)},t.id)),N.length===0?e.jsx("div",{className:"connected-apps-empty",children:"No apps match the current search."}):null]}),c?e.jsx($,{app:c,onClose:()=>f(null),onInstall:()=>A(c)}):null]})}function O(s,n){const a=s?.trim();return a||n?.trim()||null}function _({app:s,onSelect:n}){return e.jsxs("button",{className:"connected-app-row",onClick:n,type:"button",children:[e.jsxs("span",{className:"connected-app-row-main",children:[e.jsx(m,{appId:s.id}),e.jsxs("span",{className:"connected-app-copy",children:[e.jsxs("span",{className:"connected-app-title",children:[e.jsx("strong",{children:s.label}),e.jsxs("span",{children:[s.shortLabel!==s.label?s.shortLabel:s.category," / ",s.setupSurfaceLabel]})]}),e.jsx("span",{children:s.description}),e.jsxs("span",{className:"connected-app-capability-row",children:[s.capabilityLabels.slice(0,2).map(a=>e.jsx("span",{children:a},a)),s.capabilityLabels.length>2?e.jsxs("span",{children:["+",s.capabilityLabels.length-2]}):null]})]})]}),e.jsx("span",{className:`connected-app-status-pill ${s.status}`,children:s.statusLabel}),e.jsx(k,{size:16})]})}function $({app:s,onClose:n,onInstall:a}){const o=s.connections.filter(c=>c.status==="active");return e.jsx("div",{className:"connected-app-dialog-backdrop",role:"presentation",onMouseDown:c=>{c.target===c.currentTarget&&n()},children:e.jsxs("section",{className:"connected-app-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"connected-app-dialog-title",children:[e.jsx("button",{className:"connected-app-dialog-close",type:"button","aria-label":"Close app details",onClick:n,children:e.jsx(P,{size:17})}),e.jsxs("div",{className:"connected-app-dialog-identity",children:[e.jsx("span",{className:"openpond-mark",children:e.jsx("img",{alt:"",src:E})}),e.jsxs("span",{className:"connection-dots","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx(m,{appId:s.id})]}),e.jsxs("h2",{id:"connected-app-dialog-title",children:["Connect ",s.label]}),e.jsxs("div",{className:"connected-app-approval",children:[e.jsx(F,{size:16}),e.jsx("span",{children:s.statusLabel})]}),e.jsxs("div",{className:"connected-app-dialog-body",children:[e.jsxs("section",{children:[e.jsx("h3",{children:s.setupSurfaceLabel}),e.jsx("p",{children:"The web flow shows the provider account, workspace, and requested access before anything is connected."})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Connected account"}),e.jsx("p",{children:G(o)})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Available capabilities"}),e.jsx("div",{className:"connected-app-dialog-capabilities",children:s.capabilities.map(c=>e.jsx("span",{children:c.label},c.id))})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Sandbox lease policy"}),e.jsx("p",{children:s.leasePolicy.leaseable?`Leaseable for ${s.leasePolicy.defaultTtlSeconds??0} seconds with scoped proxy access.`:"Managed as setup or tool discovery; no OAuth lease is required."})]})]}),e.jsxs("button",{className:"connected-app-dialog-primary",type:"button",onClick:a,children:[e.jsx("span",{children:s.installLabel}),e.jsx(U,{size:15})]})]})})}function m({appId:s}){return e.jsx("span",{className:`connected-app-icon app-${s}`,children:e.jsx("img",{alt:"",src:B(s)})})}function z(s,n){return n==="For agents"?!0:n==="Featured"?M.has(s.id):n==="Productivity"?s.category==="Productivity"||s.category==="Chat":s.category==="Developer tools"||s.id==="mcp"}function q(s,n){const a=n.trim().toLowerCase();return a?[s.id,s.label,s.shortLabel,s.category,s.description,s.providerFamily,s.setupSurface].some(o=>o.toLowerCase().includes(a)):!0}function B(s){return R(s)}async function V(s){const n=window.openpond?.browser;if(n){const a=await n.openExternal({conversationId:"connected-apps",url:s});if(!a.ok)throw new Error(a.error??"Unable to open app setup.");return}window.open(s,"_blank","noopener,noreferrer")}function W(s){return s==="loading"?"Checking connections":s==="ready"?"Connection status current":s==="error"?"Connection status unavailable":"Connection status pending"}function X(s){return s.filter(n=>n.connected).length}function G(s){return s.length===0?"No active OAuth connection for this setup surface.":s.map(n=>{const a=n.accountLabel??"Connected account";return n.workspaceLabel?`${a} / ${n.workspaceLabel}`:a}).join(", ")}export{J as AppsView,_ as ConnectedAppRow,O as connectedAppSetupTeamId};
1
+ import{r,b4 as b,m as L,j as e,S as I,aT as k,X as P,b5 as E,R as F,E as U,b6 as T,b7 as R}from"./index-CKmte5ok.js";const D=["For agents","Featured","Productivity","Developer tools"],M=new Set(["slack","google","github","mcp"]);function J({account:s,connection:n,defaultTeamId:a,onToast:o}){const[c,f]=r.useState(null),[p,v]=r.useState(""),[i,y]=r.useState("For agents"),[u,h]=r.useState(()=>b()),[g,d]=r.useState("idle"),[w,x]=r.useState(null),S=s?.baseUrl??s?.activeProfile?.baseUrl??null,C=O(a,w),N=r.useMemo(()=>u.filter(t=>z(t,i)).filter(t=>q(t,p)),[i,p,u]);r.useEffect(()=>{let t=!0;return n?(d("loading"),L.connectedAppStatus(n,{status:"all"}).then(l=>{t&&(h(l.apps),x(l.teamId?.trim()||null),d("ready"))}).catch(l=>{t&&(console.warn("Unable to load connected app status.",l),h(b()),x(null),d("error"))}),()=>{t=!1}):(h(b()),d("idle"),x(null),()=>{t=!1})},[n]);function A(t){const l=T({appId:t.id,baseUrl:S,teamId:C});V(l).catch(j=>{o?.(j instanceof Error?j.message:String(j),"error")})}return e.jsxs("section",{className:"connected-apps-view","aria-label":"Apps",children:[e.jsxs("div",{className:"connected-apps-header",children:[e.jsxs("div",{children:[e.jsx("h1",{children:"Apps"}),e.jsx("p",{children:"Connect apps that agents can use for chat, knowledge, files, and workflow actions."})]}),e.jsxs("label",{className:"connected-apps-search",children:[e.jsx(I,{size:15}),e.jsx("input",{"aria-label":"Search apps",onChange:t=>v(t.target.value),placeholder:"Search apps",type:"search",value:p})]})]}),e.jsxs("div",{className:`connected-apps-status-strip ${g}`,children:[e.jsx("span",{children:W(g)}),e.jsxs("span",{children:[X(u)," connected"]})]}),e.jsxs("section",{className:"connected-apps-hero","aria-label":"App context",children:[e.jsxs("div",{className:"connected-apps-hero-copy",children:[e.jsx("span",{className:"connected-apps-hero-icon",children:e.jsx(m,{appId:"github"})}),e.jsx("h2",{children:"Work with your apps"}),e.jsx("p",{children:"Bring repositories, documents, chat, calendars, and custom MCP tools into OpenPond."})]}),e.jsxs("div",{className:"connected-apps-context-card","aria-hidden":"true",children:[e.jsx("strong",{children:"Agent context"}),e.jsxs("div",{children:[e.jsx("span",{className:"files",children:"Files"}),e.jsx("span",{className:"chat",children:"Chat"}),e.jsx("span",{className:"oauth",children:"OAuth"}),e.jsx("span",{className:"mcp",children:"MCP"})]})]})]}),e.jsx("div",{className:"connected-apps-filters",role:"tablist","aria-label":"App categories",children:D.map(t=>e.jsx("button",{"aria-selected":i===t,className:i===t?"active":"",onClick:()=>y(t),role:"tab",type:"button",children:t},t))}),e.jsxs("div",{className:"connected-apps-list",children:[N.map(t=>e.jsx(_,{app:t,onSelect:()=>f(t)},t.id)),N.length===0?e.jsx("div",{className:"connected-apps-empty",children:"No apps match the current search."}):null]}),c?e.jsx($,{app:c,onClose:()=>f(null),onInstall:()=>A(c)}):null]})}function O(s,n){const a=s?.trim();return a||n?.trim()||null}function _({app:s,onSelect:n}){return e.jsxs("button",{className:"connected-app-row",onClick:n,type:"button",children:[e.jsxs("span",{className:"connected-app-row-main",children:[e.jsx(m,{appId:s.id}),e.jsxs("span",{className:"connected-app-copy",children:[e.jsxs("span",{className:"connected-app-title",children:[e.jsx("strong",{children:s.label}),e.jsxs("span",{children:[s.shortLabel!==s.label?s.shortLabel:s.category," / ",s.setupSurfaceLabel]})]}),e.jsx("span",{children:s.description}),e.jsxs("span",{className:"connected-app-capability-row",children:[s.capabilityLabels.slice(0,2).map(a=>e.jsx("span",{children:a},a)),s.capabilityLabels.length>2?e.jsxs("span",{children:["+",s.capabilityLabels.length-2]}):null]})]})]}),e.jsx("span",{className:`connected-app-status-pill ${s.status}`,children:s.statusLabel}),e.jsx(k,{size:16})]})}function $({app:s,onClose:n,onInstall:a}){const o=s.connections.filter(c=>c.status==="active");return e.jsx("div",{className:"connected-app-dialog-backdrop",role:"presentation",onMouseDown:c=>{c.target===c.currentTarget&&n()},children:e.jsxs("section",{className:"connected-app-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"connected-app-dialog-title",children:[e.jsx("button",{className:"connected-app-dialog-close",type:"button","aria-label":"Close app details",onClick:n,children:e.jsx(P,{size:17})}),e.jsxs("div",{className:"connected-app-dialog-identity",children:[e.jsx("span",{className:"openpond-mark",children:e.jsx("img",{alt:"",src:E})}),e.jsxs("span",{className:"connection-dots","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx(m,{appId:s.id})]}),e.jsxs("h2",{id:"connected-app-dialog-title",children:["Connect ",s.label]}),e.jsxs("div",{className:"connected-app-approval",children:[e.jsx(F,{size:16}),e.jsx("span",{children:s.statusLabel})]}),e.jsxs("div",{className:"connected-app-dialog-body",children:[e.jsxs("section",{children:[e.jsx("h3",{children:s.setupSurfaceLabel}),e.jsx("p",{children:"The web flow shows the provider account, workspace, and requested access before anything is connected."})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Connected account"}),e.jsx("p",{children:G(o)})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Available capabilities"}),e.jsx("div",{className:"connected-app-dialog-capabilities",children:s.capabilities.map(c=>e.jsx("span",{children:c.label},c.id))})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Sandbox lease policy"}),e.jsx("p",{children:s.leasePolicy.leaseable?`Leaseable for ${s.leasePolicy.defaultTtlSeconds??0} seconds with scoped proxy access.`:"Managed as setup or tool discovery; no OAuth lease is required."})]})]}),e.jsxs("button",{className:"connected-app-dialog-primary",type:"button",onClick:a,children:[e.jsx("span",{children:s.installLabel}),e.jsx(U,{size:15})]})]})})}function m({appId:s}){return e.jsx("span",{className:`connected-app-icon app-${s}`,children:e.jsx("img",{alt:"",src:B(s)})})}function z(s,n){return n==="For agents"?!0:n==="Featured"?M.has(s.id):n==="Productivity"?s.category==="Productivity"||s.category==="Chat":s.category==="Developer tools"||s.id==="mcp"}function q(s,n){const a=n.trim().toLowerCase();return a?[s.id,s.label,s.shortLabel,s.category,s.description,s.providerFamily,s.setupSurface].some(o=>o.toLowerCase().includes(a)):!0}function B(s){return R(s)}async function V(s){const n=window.openpond?.browser;if(n){const a=await n.openExternal({conversationId:"connected-apps",url:s});if(!a.ok)throw new Error(a.error??"Unable to open app setup.");return}window.open(s,"_blank","noopener,noreferrer")}function W(s){return s==="loading"?"Checking connections":s==="ready"?"Connection status current":s==="error"?"Connection status unavailable":"Connection status pending"}function X(s){return s.filter(n=>n.connected).length}function G(s){return s.length===0?"No active OAuth connection for this setup surface.":s.map(n=>{const a=n.accountLabel??"Connected account";return n.workspaceLabel?`${a} / ${n.workspaceLabel}`:a}).join(", ")}export{J as AppsView,_ as ConnectedAppRow,O as connectedAppSetupTeamId};
@@ -1 +1 @@
1
- import{r as c,bi as v,j as a,aM as f,X as k,h as j,U as C,aJ as g,aq as B,E as N,aN as y}from"./index-D7Vr3zcV.js";import{R as T}from"./refresh-cw-DE0u_nmZ.js";const x=[];function P(r){const e=window.openpond?.browser,[b,l]=c.useState(()=>({conversationId:r,activeTabId:null,tabs:x}));c.useEffect(()=>{if(l({conversationId:r,activeTabId:null,tabs:x}),!e)return;let s=!1;e.getState({conversationId:r}).then(o=>{s||l(o)});const i=e.onState(o=>{o.conversationId===r&&l(o)});return()=>{s=!0,i()}},[e,r]);const u=c.useMemo(()=>b.tabs.find(s=>s.id===b.activeTabId)??null,[b.activeTabId,b.tabs]),t=c.useCallback(async(s,i={})=>{if(!e)return!1;const o=v(s,{explicitFile:i.explicitFile});return o?(i.newTab?await e.newTab({conversationId:r,url:o,explicitFile:i.explicitFile}):await e.open({conversationId:r,url:o,explicitFile:i.explicitFile}),!0):!1},[e,r]),n=u?{conversationId:r,tabId:u.id}:null;return{activeTab:u,available:!!e,bridge:e,state:b,back:()=>e&&n?e.back(n):Promise.resolve({ok:!1}),clearData:()=>e?e.clearData({conversationId:r}):Promise.resolve({ok:!1}),closeTab:s=>e?e.closeTab({conversationId:r,tabId:s}):Promise.resolve({ok:!1}),forward:()=>e&&n?e.forward(n):Promise.resolve({ok:!1}),newTab:s=>e?e.newTab({conversationId:r,url:s}):Promise.resolve({ok:!1}),open:t,openExternal:()=>e&&n?e.openExternal(n):Promise.resolve({ok:!1}),reload:()=>e&&n?e.reload(n):Promise.resolve({ok:!1}),snapshot:(s={})=>e?e.snapshot({conversationId:r,...s}):Promise.resolve({ok:!1,output:"Desktop browser bridge unavailable."}),moveCursor:s=>e?e.moveCursor({conversationId:r,...s}):Promise.resolve({ok:!1,output:"Desktop browser bridge unavailable."}),click:s=>e?e.click({conversationId:r,...s}):Promise.resolve({ok:!1,output:"Desktop browser bridge unavailable."}),typeText:s=>e?e.typeText({conversationId:r,...s}):Promise.resolve({ok:!1,output:"Desktop browser bridge unavailable."}),key:s=>e?e.key({conversationId:r,...s}):Promise.resolve({ok:!1,output:"Desktop browser bridge unavailable."}),scroll:s=>e?e.scroll({conversationId:r,...s}):Promise.resolve({ok:!1,output:"Desktop browser bridge unavailable."}),selectTab:s=>e?e.selectTab({conversationId:r,tabId:s}):Promise.resolve({ok:!1}),setBounds:s=>e?e.setBounds({conversationId:r,bounds:s}):Promise.resolve({ok:!1}),stop:()=>e&&n?e.stop(n):Promise.resolve({ok:!1})}}function E({activeTabId:r,tabs:e,onCloseTab:b,onNewTab:l,onSelectTab:u}){return a.jsxs("div",{className:"browser-tabs",role:"tablist","aria-label":"Browser tabs",children:[e.map(t=>a.jsxs("div",{className:`browser-tab ${t.id===r?"active":""}`,children:[a.jsx("span",{className:"browser-tab-favicon","aria-hidden":"true",children:t.faviconUrl?a.jsx("img",{alt:"",referrerPolicy:"no-referrer",src:t.faviconUrl}):a.jsx(f,{size:13})}),a.jsx("button",{type:"button",className:"browser-tab-main",role:"tab","aria-selected":t.id===r,title:t.url,onClick:()=>u(t.id),children:R(t)}),a.jsx("button",{type:"button",className:"browser-tab-close",title:"Close tab","aria-label":"Close tab",onClick:()=>b(t.id),children:a.jsx(k,{size:12})})]},t.id)),a.jsx("button",{type:"button",className:"browser-tab-add",title:"New tab","aria-label":"New tab",onClick:l,children:a.jsx(j,{size:14})})]})}function R(r){if(r.title?.trim())return r.title.trim();try{return new URL(r.url).host||r.url}catch{return r.url||"New tab"}}function z({activeTab:r,available:e,onBack:b,onClearData:l,onForward:u,onNavigate:t,onOpenExternal:n,onReload:s,onStop:i}){const[o,d]=c.useState(""),[p,m]=c.useState(!1);c.useEffect(()=>{d(r?.url??"")},[r?.url]);function h(w){w.preventDefault(),t(o)}return a.jsxs("div",{className:"browser-toolbar",children:[a.jsxs("div",{className:"browser-nav-actions",children:[a.jsx("button",{type:"button",title:"Back","aria-label":"Back",disabled:!r?.canGoBack,onClick:b,children:a.jsx(C,{size:15})}),a.jsx("button",{type:"button",title:"Forward","aria-label":"Forward",disabled:!r?.canGoForward,onClick:u,children:a.jsx(g,{size:15})}),a.jsx("button",{type:"button",title:r?.loading?"Stop":"Reload","aria-label":r?.loading?"Stop":"Reload",disabled:!r,onClick:r?.loading?i:s,children:r?.loading?a.jsx(B,{size:13}):a.jsx(T,{size:14})})]}),a.jsx("form",{className:"browser-address-form",onSubmit:h,children:a.jsx("input",{"aria-label":"Browser address",disabled:!e,placeholder:e?"Search or enter address":"Desktop browser unavailable",spellCheck:!1,value:o,onChange:w=>d(w.target.value)})}),a.jsxs("div",{className:"browser-panel-actions",children:[a.jsx("button",{type:"button",title:"Open external","aria-label":"Open external",disabled:!r,onClick:n,children:a.jsx(N,{size:14})}),a.jsxs("div",{className:"browser-menu-anchor",children:[a.jsx("button",{type:"button",title:"Browser actions","aria-label":"Browser actions",onClick:()=>m(w=>!w),children:a.jsx(y,{size:15})}),p&&a.jsx("div",{className:"browser-options-menu",role:"menu",children:a.jsx("button",{type:"button",role:"menuitem",onClick:()=>{m(!1),l()},children:"Clear Browser Data..."})})]})]})]})}function D({active:r,onBounds:e}){const b=c.useRef(null),l=c.useRef(null),u=c.useRef(null),t=c.useCallback(i=>{const o=i?`${i.x}:${i.y}:${i.width}:${i.height}`:"null";l.current!==o&&(l.current=o,e(i))},[e]),n=c.useCallback(()=>{const i=b.current;if(!r||!i){t(null);return}const o=i.getBoundingClientRect(),d=Math.max(0,Math.round(o.width)),p=Math.max(0,Math.round(o.height));if(d===0||p===0){t(null);return}t({x:Math.round(o.left),y:Math.round(o.top),width:d,height:p})},[r,t]),s=c.useCallback(()=>{u.current===null&&(u.current=window.requestAnimationFrame(()=>{u.current=null,n()}))},[n]);return c.useLayoutEffect(()=>{l.current=null,n();const i=b.current;if(!r||!i)return t(null),()=>t(null);const o=new ResizeObserver(s);return o.observe(i),window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{u.current!==null&&(window.cancelAnimationFrame(u.current),u.current=null),o.disconnect(),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0),t(null)}},[r,t,n,s]),a.jsx("div",{className:"browser-viewport",ref:b})}function L({conversationId:r,expanded:e,onResizeStart:b}){const l=P(r),u=c.useCallback(s=>{window.openpond?.browser?.setBounds({conversationId:r,bounds:s})},[r]),t=c.useCallback(s=>{l.open(s,{explicitFile:!0})},[l]),n=c.useCallback(()=>{window.confirm("Clear browser data for this conversation? Tabs, cookies, cache, and local storage for this conversation will be removed.")&&l.clearData()},[l]);return a.jsxs("aside",{className:`workspace-diff-panel browser-sidebar-panel ${e?"expanded":""}`,"aria-label":"Browser",children:[!e&&a.jsx("div",{className:"workspace-diff-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize browser panel",onPointerDown:b}),a.jsx(E,{activeTabId:l.state.activeTabId,tabs:l.state.tabs,onCloseTab:s=>{l.closeTab(s)},onNewTab:()=>{l.newTab()},onSelectTab:s=>{l.selectTab(s)}}),a.jsx(z,{activeTab:l.activeTab,available:l.available,onBack:()=>{l.back()},onClearData:n,onForward:()=>{l.forward()},onNavigate:t,onOpenExternal:()=>{l.openExternal()},onReload:()=>{l.reload()},onStop:()=>{l.stop()}}),a.jsxs("div",{className:"browser-content",children:[l.available?l.state.tabs.length===0?a.jsxs("div",{className:"browser-empty-state",children:[a.jsx(f,{size:18}),a.jsx("span",{children:"Enter a URL to open a browser tab for this conversation."})]}):null:a.jsxs("div",{className:"browser-empty-state",children:[a.jsx(f,{size:18}),a.jsx("span",{children:"Desktop browser bridge unavailable."})]}),a.jsx(D,{active:l.available&&l.state.tabs.length>0,onBounds:u})]})]})}export{L as BrowserSidebar};
1
+ import{r as c,bj as v,j as a,aM as f,X as k,h as j,U as C,aJ as g,aq as B,E as N,aN as y}from"./index-CKmte5ok.js";import{R as T}from"./refresh-cw-JNUovwk4.js";const x=[];function P(r){const e=window.openpond?.browser,[b,l]=c.useState(()=>({conversationId:r,activeTabId:null,tabs:x}));c.useEffect(()=>{if(l({conversationId:r,activeTabId:null,tabs:x}),!e)return;let s=!1;e.getState({conversationId:r}).then(o=>{s||l(o)});const n=e.onState(o=>{o.conversationId===r&&l(o)});return()=>{s=!0,n()}},[e,r]);const u=c.useMemo(()=>b.tabs.find(s=>s.id===b.activeTabId)??null,[b.activeTabId,b.tabs]),t=c.useCallback(async(s,n={})=>{if(!e)return!1;const o=v(s,{explicitFile:n.explicitFile});return o?(n.newTab?await e.newTab({conversationId:r,url:o,explicitFile:n.explicitFile}):await e.open({conversationId:r,url:o,explicitFile:n.explicitFile}),!0):!1},[e,r]),i=u?{conversationId:r,tabId:u.id}:null;return{activeTab:u,available:!!e,bridge:e,state:b,back:()=>e&&i?e.back(i):Promise.resolve({ok:!1}),clearData:()=>e?e.clearData({conversationId:r}):Promise.resolve({ok:!1}),closeTab:s=>e?e.closeTab({conversationId:r,tabId:s}):Promise.resolve({ok:!1}),forward:()=>e&&i?e.forward(i):Promise.resolve({ok:!1}),newTab:s=>e?e.newTab({conversationId:r,url:s}):Promise.resolve({ok:!1}),open:t,openExternal:()=>e&&i?e.openExternal(i):Promise.resolve({ok:!1}),reload:()=>e&&i?e.reload(i):Promise.resolve({ok:!1}),snapshot:(s={})=>e?e.snapshot({conversationId:r,...s}):Promise.resolve({ok:!1,output:"Desktop browser bridge unavailable."}),moveCursor:s=>e?e.moveCursor({conversationId:r,...s}):Promise.resolve({ok:!1,output:"Desktop browser bridge unavailable."}),click:s=>e?e.click({conversationId:r,...s}):Promise.resolve({ok:!1,output:"Desktop browser bridge unavailable."}),typeText:s=>e?e.typeText({conversationId:r,...s}):Promise.resolve({ok:!1,output:"Desktop browser bridge unavailable."}),key:s=>e?e.key({conversationId:r,...s}):Promise.resolve({ok:!1,output:"Desktop browser bridge unavailable."}),scroll:s=>e?e.scroll({conversationId:r,...s}):Promise.resolve({ok:!1,output:"Desktop browser bridge unavailable."}),selectTab:s=>e?e.selectTab({conversationId:r,tabId:s}):Promise.resolve({ok:!1}),setBounds:s=>e?e.setBounds({conversationId:r,bounds:s}):Promise.resolve({ok:!1}),stop:()=>e&&i?e.stop(i):Promise.resolve({ok:!1})}}function E({activeTabId:r,tabs:e,onCloseTab:b,onNewTab:l,onSelectTab:u}){return a.jsxs("div",{className:"browser-tabs",role:"tablist","aria-label":"Browser tabs",children:[e.map(t=>a.jsxs("div",{className:`browser-tab ${t.id===r?"active":""}`,children:[a.jsx("span",{className:"browser-tab-favicon","aria-hidden":"true",children:t.faviconUrl?a.jsx("img",{alt:"",referrerPolicy:"no-referrer",src:t.faviconUrl}):a.jsx(f,{size:13})}),a.jsx("button",{type:"button",className:"browser-tab-main",role:"tab","aria-selected":t.id===r,title:t.url,onClick:()=>u(t.id),children:R(t)}),a.jsx("button",{type:"button",className:"browser-tab-close",title:"Close tab","aria-label":"Close tab",onClick:()=>b(t.id),children:a.jsx(k,{size:12})})]},t.id)),a.jsx("button",{type:"button",className:"browser-tab-add",title:"New tab","aria-label":"New tab",onClick:l,children:a.jsx(j,{size:14})})]})}function R(r){if(r.title?.trim())return r.title.trim();try{return new URL(r.url).host||r.url}catch{return r.url||"New tab"}}function z({activeTab:r,available:e,onBack:b,onClearData:l,onForward:u,onNavigate:t,onOpenExternal:i,onReload:s,onStop:n}){const[o,d]=c.useState(""),[p,m]=c.useState(!1);c.useEffect(()=>{d(r?.url??"")},[r?.url]);function h(w){w.preventDefault(),t(o)}return a.jsxs("div",{className:"browser-toolbar",children:[a.jsxs("div",{className:"browser-nav-actions",children:[a.jsx("button",{type:"button",title:"Back","aria-label":"Back",disabled:!r?.canGoBack,onClick:b,children:a.jsx(C,{size:15})}),a.jsx("button",{type:"button",title:"Forward","aria-label":"Forward",disabled:!r?.canGoForward,onClick:u,children:a.jsx(g,{size:15})}),a.jsx("button",{type:"button",title:r?.loading?"Stop":"Reload","aria-label":r?.loading?"Stop":"Reload",disabled:!r,onClick:r?.loading?n:s,children:r?.loading?a.jsx(B,{size:13}):a.jsx(T,{size:14})})]}),a.jsx("form",{className:"browser-address-form",onSubmit:h,children:a.jsx("input",{"aria-label":"Browser address",disabled:!e,placeholder:e?"Search or enter address":"Desktop browser unavailable",spellCheck:!1,value:o,onChange:w=>d(w.target.value)})}),a.jsxs("div",{className:"browser-panel-actions",children:[a.jsx("button",{type:"button",title:"Open external","aria-label":"Open external",disabled:!r,onClick:i,children:a.jsx(N,{size:14})}),a.jsxs("div",{className:"browser-menu-anchor",children:[a.jsx("button",{type:"button",title:"Browser actions","aria-label":"Browser actions",onClick:()=>m(w=>!w),children:a.jsx(y,{size:15})}),p&&a.jsx("div",{className:"browser-options-menu",role:"menu",children:a.jsx("button",{type:"button",role:"menuitem",onClick:()=>{m(!1),l()},children:"Clear Browser Data..."})})]})]})]})}function D({active:r,onBounds:e}){const b=c.useRef(null),l=c.useRef(null),u=c.useRef(null),t=c.useCallback(n=>{const o=n?`${n.x}:${n.y}:${n.width}:${n.height}`:"null";l.current!==o&&(l.current=o,e(n))},[e]),i=c.useCallback(()=>{const n=b.current;if(!r||!n){t(null);return}const o=n.getBoundingClientRect(),d=Math.max(0,Math.round(o.width)),p=Math.max(0,Math.round(o.height));if(d===0||p===0){t(null);return}t({x:Math.round(o.left),y:Math.round(o.top),width:d,height:p})},[r,t]),s=c.useCallback(()=>{u.current===null&&(u.current=window.requestAnimationFrame(()=>{u.current=null,i()}))},[i]);return c.useLayoutEffect(()=>{l.current=null,i();const n=b.current;if(!r||!n)return t(null),()=>t(null);const o=new ResizeObserver(s);return o.observe(n),window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{u.current!==null&&(window.cancelAnimationFrame(u.current),u.current=null),o.disconnect(),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0),t(null)}},[r,t,i,s]),a.jsx("div",{className:"browser-viewport",ref:b})}function L({conversationId:r,expanded:e,onResizeStart:b}){const l=P(r),u=c.useCallback(s=>{window.openpond?.browser?.setBounds({conversationId:r,bounds:s})},[r]),t=c.useCallback(s=>{l.open(s,{explicitFile:!0})},[l]),i=c.useCallback(()=>{window.confirm("Clear browser data for this conversation? Tabs, cookies, cache, and local storage for this conversation will be removed.")&&l.clearData()},[l]);return a.jsxs("aside",{className:`workspace-diff-panel browser-sidebar-panel ${e?"expanded":""}`,"aria-label":"Browser",children:[!e&&a.jsx("div",{className:"workspace-diff-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize browser panel",onPointerDown:b}),a.jsx(E,{activeTabId:l.state.activeTabId,tabs:l.state.tabs,onCloseTab:s=>{l.closeTab(s)},onNewTab:()=>{l.newTab()},onSelectTab:s=>{l.selectTab(s)}}),a.jsx(z,{activeTab:l.activeTab,available:l.available,onBack:()=>{l.back()},onClearData:i,onForward:()=>{l.forward()},onNavigate:t,onOpenExternal:()=>{l.openExternal()},onReload:()=>{l.reload()},onStop:()=>{l.stop()}}),a.jsxs("div",{className:"browser-content",children:[l.available?l.state.tabs.length===0?a.jsxs("div",{className:"browser-empty-state",children:[a.jsx(f,{size:18}),a.jsx("span",{children:"Enter a URL to open a browser tab for this conversation."})]}):null:a.jsxs("div",{className:"browser-empty-state",children:[a.jsx(f,{size:18}),a.jsx("span",{children:"Desktop browser bridge unavailable."})]}),a.jsx(D,{active:l.available&&l.state.tabs.length>0,onBounds:u})]})]})}export{L as BrowserSidebar};
@@ -1 +1 @@
1
- import{r,a9 as ye,j as e,U as Ne,b as B,aq as ee,h as D,bj as se,bk as ne,D as te,A as ke,bl as Se,S as Ae,K as ie,ay as H,aF as we,X as Re,bm as ae}from"./index-D7Vr3zcV.js";import{P as Pe}from"./play-BJdhBqQE.js";import{createPipelineAgentIdFromObjective as le,createPipelineSourceRootPathForAgent as Te}from"./create-pipeline-request-AJWLMTyw.js";function _e(s,t){return t==="archive"?!!s.archivedAt:t==="reviews"?s.status==="needs_review":!s.archivedAt}function ze(s){return s==="backlog"?"Task":s==="needs_review"?"Review":s.replace(/_/g," ")}function $e(s,t){const a=s.get(t);return a?.organizationName?`${a.organizationName} / ${a.name}`:a?.name??"Cloud Project"}function Me(s){const t=s.filter(a=>!ce(a));return t.find(a=>a.role==="user")??t[0]??null}function ce(s){return s.metadata.source==="openpond_app_cloud_create_improve_link"||s.metadata.hidden===!0}function Oe(s){return s.adapter.kind==="local"?"Local profile":s.adapter.kind==="promote_local_to_hosted"?"Local to hosted":"Hosted profile"}function Ee(s){return s?.plan?.checks?.length?s.plan.checks.map(t=>({name:t.name,command:t.command})):[{name:"inspect",command:"pnpm agent:inspect"},{name:"build",command:"pnpm build"},{name:"validate",command:"pnpm agent:validate"},{name:"eval",command:"pnpm agent:eval"}]}function Le(s){return s?.plan?.requirements?.map(t=>({name:t.name,detail:[t.kind.replace(/_/g," "),t.status,t.detail].filter(Boolean).join(" / ")}))??[]}function De(s){const t=s?.workflowCapture;return t?[{name:"Actions",values:t.profileActions},{name:"Providers",values:t.externalProviders},{name:"Side effects",values:t.sideEffects},{name:"Files",values:t.files},{name:"Artifacts",values:t.outputArtifacts},{name:"Traces",values:t.traceRefs},{name:"Channels",values:t.channelTargets}].flatMap(({name:a,values:u})=>u.length?[{name:a,detail:u.join(", ")}]:[]):[]}function He(s){if(s.plan?.sourcePlan?.length)return s.plan.sourcePlan;const t=s.operation==="improve"?"update":"create",a=s.target.kind==="agent"?s.target.id??le(s.objective):le(s.objective);return[{path:Te(a),operation:t,reason:s.objective},{path:"settings/profile.yaml",operation:"update",reason:"Expose the default chat action through the hosted profile catalog."}]}function qe({workItem:s,detail:t,actionBusy:a,localProjectName:u,onApplyLocalPatch:m,onShowFiles:c}){const d=Ve(s,t),h=s.status==="needs_review"&&!!(u&&m);return e.jsxs("article",{className:"cloud-work-boundary-strip",children:[e.jsxs("div",{children:[e.jsx("span",{children:Fe(s)}),e.jsx("small",{children:Ke(s)})]}),e.jsx("div",{className:"cloud-work-boundary-chips",children:d.map(j=>e.jsx("span",{children:j},j))}),s.status==="needs_review"?e.jsxs("button",{type:"button",onClick:()=>{m&&m()},disabled:a||!h,title:h?`Apply to ${u}`:"Link this Cloud Project to a local checkout before applying locally.",children:[e.jsx(ie,{size:13}),e.jsx("span",{children:h?"Apply locally":"No local checkout"})]}):null,c?e.jsxs("button",{type:"button",onClick:c,children:[e.jsx(H,{size:13}),e.jsx("span",{children:"Files"})]}):null]})}function Fe(s){return s.status==="needs_review"?"Cloud patch ready":s.status==="queued"||s.status==="running"?"Running in Cloud":s.status==="failed"?"Cloud task failed":"Cloud task"}function Ke(s){return s.status==="needs_review"?"Review files and apply locally only when ready.":s.status==="queued"||s.status==="running"?"The local checkout is unchanged while the sandbox works.":s.status==="failed"?"Open files/logs to inspect the remote run before retrying.":"Cloud changes stay remote until an explicit apply or pull action."}function Ve(s,t){const a=[s.status.replace(/_/g," ")];return s.sourceRef&&a.push(s.sourceRef),s.latestSandboxId&&a.push("sandbox"),s.latestTaskRunId&&a.push("task run"),t?.activity.length&&a.push(`${t.activity.length} log${t.activity.length===1?"":"s"}`),s.status==="needs_review"&&a.push("patch only"),a.push("local unchanged"),a}function Ue({run:s,actionBusy:t,onApprove:a,onEdit:u,onCancel:m}){const c=s.state,d=s.plan,h=Ee(s),j=Le(s),f=De(s),N=He(s),x=we(d?.metadata),k=s.scope.targetProject?.name??s.scope.targetProject?.id??"Profile source",S=!!d&&c==="awaiting_plan_approval"&&(d?.status==="draft"||d?.status==="pending_approval"),A=(c==="planning"||c==="awaiting_plan_approval")&&(d?.status==="draft"||d?.status==="pending_approval");return e.jsxs("article",{className:"cloud-create-plan-review",children:[e.jsxs("div",{className:"cloud-create-plan-heading",children:[e.jsx(H,{size:16}),e.jsxs("div",{children:[e.jsx("span",{children:"Agent plan review"}),e.jsxs("small",{children:[s.operation," / ",Oe(s)," / ",c.replace(/_/g," ")]})]})]}),e.jsxs("div",{className:"cloud-create-plan-copy",children:[e.jsxs("section",{children:[e.jsx("span",{children:"Objective"}),e.jsx("p",{children:s.objective})]}),e.jsxs("section",{children:[e.jsx("span",{children:"Target"}),e.jsx("p",{children:k})]}),d?.capturedContextSummary?e.jsxs("section",{children:[e.jsx("span",{children:"Captured context"}),e.jsx("p",{children:d.capturedContextSummary})]}):s.context.targetRepoAssumptions.length?e.jsxs("section",{children:[e.jsx("span",{children:"Captured context"}),e.jsx("p",{children:s.context.targetRepoAssumptions.join("; ")})]}):null,s.context.attachments.length?e.jsxs("section",{children:[e.jsx("span",{children:"Inputs"}),e.jsx("p",{children:s.context.attachments.map(l=>l.name).join(", ")})]}):null,s.context.apps.length?e.jsxs("section",{children:[e.jsx("span",{children:"Apps"}),e.jsx("p",{children:s.context.apps.map(l=>l.name).join(", ")})]}):null,s.context.tools.length?e.jsxs("section",{children:[e.jsx("span",{children:"Tools"}),e.jsx("p",{children:s.context.tools.map(l=>l.name).join(", ")})]}):null,x?e.jsxs("section",{children:[e.jsx("span",{children:"Action shape"}),e.jsxs("p",{children:[x.label,": ",x.detail]})]}):null]}),e.jsxs("div",{className:"cloud-create-plan-grid",children:[x?e.jsxs("section",{children:[e.jsx("span",{children:"Actions"}),e.jsxs("ul",{children:[e.jsxs("li",{children:[e.jsx("code",{children:x.defaultActionKey??"chat"}),e.jsx("small",{children:x.label})]}),x.directActionHint?e.jsxs("li",{children:[e.jsx("code",{children:"direct action"}),e.jsx("small",{children:x.directActionHint})]}):null]})]}):null,e.jsxs("section",{children:[e.jsx("span",{children:"Source plan"}),e.jsx("ul",{children:N.map(l=>e.jsxs("li",{children:[e.jsx("code",{children:l.path}),e.jsx("small",{children:l.operation})]},`${l.operation}:${l.path}`))})]}),e.jsxs("section",{children:[e.jsx("span",{children:"Checks"}),e.jsx("ul",{children:h.map(l=>e.jsxs("li",{children:[e.jsx("code",{children:l.name}),e.jsx("small",{children:l.command})]},`${l.name}:${l.command}`))})]}),j.length?e.jsxs("section",{children:[e.jsx("span",{children:"Requirements"}),e.jsx("ul",{children:j.map(l=>e.jsxs("li",{children:[e.jsx("code",{children:l.name}),e.jsx("small",{children:l.detail})]},`${l.name}:${l.detail}`))})]}):null,f.length?e.jsxs("section",{children:[e.jsx("span",{children:"Workflow evidence"}),e.jsx("ul",{children:f.map(l=>e.jsxs("li",{children:[e.jsx("code",{children:l.name}),e.jsx("small",{children:l.detail})]},`${l.name}:${l.detail}`))})]}):null]}),e.jsxs("div",{className:"cloud-create-plan-actions",children:[e.jsxs("button",{type:"button",onClick:a,disabled:t||!S,children:[e.jsx(ie,{size:14}),e.jsx("span",{children:"Confirm plan"})]}),e.jsxs("button",{type:"button",onClick:u,disabled:t||!A,children:[e.jsx(H,{size:14}),e.jsx("span",{children:"Edit plan"})]}),e.jsxs("button",{type:"button",onClick:m,disabled:t,children:[e.jsx(Re,{size:14}),e.jsx("span",{children:"Cancel"})]})]})]})}function Qe({projects:s,workItems:t,selectedWorkItem:a,detail:u,loading:m,actionBusy:c,connection:d,error:h,model:j,showToast:f,onBack:N,onModelChange:x,onSetupCloudProject:k,onCreateWork:S,onSelectWorkItem:A,onSendMessage:l,onHandleBackground:q,onCancelCreatePlan:oe,onCancelTask:F,localProjectName:re,onApplyLocalPatch:de,onShowFiles:w}){const[y,R]=r.useState(""),[b,g]=r.useState(""),K=r.useRef(null),P=r.useRef(null),[ue,V]=r.useState(0),[pe,T]=r.useState(0),[U,_]=r.useState(!1),[X,G]=r.useState(!1),[C,z]=r.useState("tasks"),[$,he]=r.useState(""),[J,xe]=r.useState(()=>s[0]?.id??""),M=r.useMemo(()=>new Map(s.map(n=>[n.id,n])),[s]),v=M.has(J)?J:s[0]?.id??"",me=ye("openpond",j),je=r.useMemo(()=>s.length?s.map(n=>({value:n.id,label:n.organizationName?`${n.organizationName} / ${n.name}`:n.name,shortLabel:n.name,description:n.sourceLabel??n.defaultBranch??void 0})):[{value:"",label:"No Cloud Project"}],[s]),Q=r.useMemo(()=>{const n=$.trim().toLowerCase();return t.filter(o=>_e(o,C)?n?o.title.toLowerCase().includes(n):!0:!1)},[$,C,t]);async function Y(){const n=y.trim();!n||!v||c||(await S({projectId:v,prompt:n}),R(""),_(!1))}async function Z(){const n=b.trim();!n||c||(await l(n),g(""))}async function ve(){const n=b.trim();await q(n||null),g(""),G(!1)}function O(n){V(n.selectionStart??n.value.length)}function E(n){T(n.selectionStart??n.value.length)}function fe(n){const o=K.current,p=ae(y,n,o?.selectionStart??ue);R(p.value),V(p.cursorIndex),window.requestAnimationFrame(()=>{o?.focus(),o?.setSelectionRange(p.cursorIndex,p.cursorIndex)})}function be(n){const o=P.current,p=ae(b,n,o?.selectionStart??pe);g(p.value),T(p.cursorIndex),window.requestAnimationFrame(()=>{o?.focus(),o?.setSelectionRange(p.cursorIndex,p.cursorIndex)})}function ge(){g(n=>n||"Revise plan: "),window.requestAnimationFrame(()=>{const n=P.current,o=n?.value.length??0;n?.focus(),n?.setSelectionRange(o,o),T(o)})}if(a){const n=u?.messages??[],o=u?.activity??[],p=u?.createImproveRun??a.createImproveRun??null,W=Me(n),L=W?.body??a.title,Ce=M.get(a.projectId)??null,I=a.status==="queued"||a.status==="running";return e.jsxs("section",{className:"cloud-work-view thread",children:[e.jsx("div",{className:"cloud-thread-body",children:e.jsxs("div",{className:"cloud-thread-timeline",children:[e.jsxs("div",{className:"cloud-thread-inline-nav",children:[e.jsxs("button",{type:"button",onClick:N,children:[e.jsx(Ne,{size:15}),e.jsx("span",{children:"All tasks"})]}),e.jsx("span",{children:Ce?.name??"Cloud Project"}),a.sourceRef?e.jsx("span",{children:a.sourceRef}):null,w?e.jsx("button",{type:"button",onClick:w,children:e.jsx("span",{children:"Files"})}):null]}),L&&e.jsx("article",{className:"cloud-message user",children:e.jsx("p",{children:L})}),e.jsxs("div",{className:"cloud-worked-line",children:[e.jsx("span",{children:ze(a.status)}),e.jsx("span",{children:B(a.updatedAt)}),I&&e.jsxs("button",{type:"button",onClick:()=>{F()},disabled:c,children:[e.jsx(ee,{size:12}),e.jsx("span",{children:"Stop task"})]})]}),e.jsx(qe,{workItem:a,detail:u,actionBusy:c,localProjectName:re,onApplyLocalPatch:de,onShowFiles:w}),p?e.jsx(Ue,{run:p,actionBusy:c,onApprove:()=>{q(null)},onEdit:ge,onCancel:()=>{oe()}}):null,n.filter(i=>i.id!==W?.id).filter(i=>!ce(i)).map(i=>e.jsx("article",{className:`cloud-message ${i.role}`,children:e.jsx("p",{children:i.body})},i.id)),o.map(i=>e.jsxs("article",{className:"cloud-activity",children:[e.jsx("span",{children:i.kind.replace(/_/g," ")}),e.jsx("p",{children:i.summary})]},i.id)),!m&&n.length===0&&o.length===0&&!L&&e.jsx("p",{className:"cloud-muted",children:"No messages yet."})]})}),e.jsxs("div",{className:"cloud-thread-composer",children:[e.jsx("button",{type:"button",className:`cloud-composer-plus ${X?"active":""}`,onClick:()=>G(i=>!i),title:"Cloud task options",children:e.jsx(D,{size:18})}),X&&e.jsxs("div",{className:"cloud-composer-options thread-options",children:[e.jsxs("button",{type:"button",onClick:()=>{ve()},disabled:c,children:[e.jsx(Pe,{size:14}),e.jsx("span",{children:"Handle in background"})]}),I&&e.jsxs("button",{type:"button",onClick:()=>{F()},disabled:c,children:[e.jsx(ee,{size:14}),e.jsx("span",{children:"Stop task"})]})]}),e.jsx("textarea",{ref:P,value:b,rows:1,placeholder:"Request changes or ask a question",onChange:i=>{g(i.target.value),E(i.currentTarget)},onClick:i=>E(i.currentTarget),onSelect:i=>E(i.currentTarget),onKeyDown:i=>{i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),Z())}}),e.jsx(se,{buttonClassName:"cloud-composer-mic-button",connection:d,disabled:c,iconSize:17,wrapperClassName:"cloud-composer-mic",showToast:f,onTranscript:be}),e.jsx("button",{type:"button",className:"cloud-composer-submit",disabled:!b.trim()||c,onClick:()=>{Z()},title:"Send",children:e.jsx(ne,{size:17})})]}),h&&e.jsx("div",{className:"cloud-error",children:h})]})}return e.jsx("section",{className:"cloud-work-view home",children:e.jsxs("div",{className:"cloud-home-shell",children:[e.jsx("h1",{children:"What should we change next?"}),e.jsxs("div",{className:"cloud-home-composer",children:[e.jsx("textarea",{ref:K,value:y,rows:2,placeholder:"Describe a task",onChange:n=>{R(n.target.value),O(n.currentTarget)},onClick:n=>O(n.currentTarget),onSelect:n=>O(n.currentTarget),onKeyDown:n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),Y())}}),e.jsxs("div",{className:"cloud-home-composer-actions",children:[e.jsx("button",{type:"button",className:`cloud-composer-plus ${U?"active":""}`,onClick:()=>_(n=>!n),title:"Cloud task options",children:e.jsx(D,{size:18})}),e.jsxs("div",{className:"cloud-composer-selects",children:[e.jsx(te,{compact:!0,className:"cloud-project-select",disabled:c||s.length===0,label:"Cloud Project",options:je,placement:"top",value:v,onChange:xe}),e.jsx(te,{compact:!0,className:"cloud-model-select",disabled:c,label:"Model",options:ke("openpond"),placement:"top",value:me,onChange:x})]}),e.jsx(se,{buttonClassName:"cloud-composer-mic-button",connection:d,disabled:c,iconSize:17,wrapperClassName:"cloud-composer-mic",showToast:f,onTranscript:fe}),e.jsx("button",{type:"button",className:"cloud-composer-submit",disabled:!y.trim()||!v||c,onClick:()=>{Y()},title:"Handle in background",children:e.jsx(ne,{size:17})})]}),U&&e.jsxs("div",{className:"cloud-composer-options",children:[e.jsxs("button",{type:"button",onClick:()=>_(!1),disabled:c,children:[e.jsx(D,{size:14}),e.jsx("span",{children:"New task"})]}),e.jsxs("button",{type:"button",onClick:()=>k(v),disabled:!v||c,children:[e.jsx(Se,{size:14}),e.jsx("span",{children:"Create environment"})]})]})]}),e.jsxs("div",{className:"cloud-task-list-toolbar",children:[e.jsxs("div",{className:"cloud-task-tabs",role:"tablist","aria-label":"Cloud tasks",children:[e.jsx("button",{type:"button",className:C==="tasks"?"active":"",onClick:()=>z("tasks"),children:"Tasks"}),e.jsx("button",{type:"button",className:C==="reviews"?"active":"",onClick:()=>z("reviews"),children:"Code reviews"}),e.jsx("button",{type:"button",className:C==="archive"?"active":"",onClick:()=>z("archive"),children:"Archive"})]}),e.jsxs("label",{className:"cloud-task-search",children:[e.jsx(Ae,{size:17}),e.jsx("input",{value:$,placeholder:"Search",onChange:n=>he(n.target.value)})]})]}),e.jsxs("div",{className:"cloud-task-list",children:[Q.map(n=>e.jsxs("button",{type:"button",className:"cloud-task-row",onClick:()=>A(n),children:[e.jsx("span",{children:n.title}),e.jsxs("small",{children:[B(n.updatedAt)," · ",$e(M,n.projectId)]})]},n.id)),!m&&Q.length===0&&e.jsx("p",{className:"cloud-empty",children:s.length?"No tasks yet":"Create or link a Cloud Project before starting a task"}),m&&e.jsx("p",{className:"cloud-empty",children:"Loading tasks..."})]}),h&&e.jsx("div",{className:"cloud-error",children:h})]})})}export{Qe as CloudWorkView};
1
+ import{r,a8 as ye,j as e,U as Ne,b as B,aq as ee,h as D,bk as se,bl as ne,D as te,A as ke,bm as Se,S as Ae,K as ie,ay as H,aF as we,X as Re,bn as ae}from"./index-CKmte5ok.js";import{P as Pe}from"./play-DLCuESeG.js";import{createPipelineAgentIdFromObjective as le,createPipelineSourceRootPathForAgent as Te}from"./create-pipeline-request-C26NOc7v.js";function _e(s,t){return t==="archive"?!!s.archivedAt:t==="reviews"?s.status==="needs_review":!s.archivedAt}function ze(s){return s==="backlog"?"Task":s==="needs_review"?"Review":s.replace(/_/g," ")}function $e(s,t){const a=s.get(t);return a?.organizationName?`${a.organizationName} / ${a.name}`:a?.name??"Cloud Project"}function Me(s){const t=s.filter(a=>!ce(a));return t.find(a=>a.role==="user")??t[0]??null}function ce(s){return s.metadata.source==="openpond_app_cloud_create_improve_link"||s.metadata.hidden===!0}function Oe(s){return s.adapter.kind==="local"?"Local profile":s.adapter.kind==="promote_local_to_hosted"?"Local to hosted":"Hosted profile"}function Ee(s){return s?.plan?.checks?.length?s.plan.checks.map(t=>({name:t.name,command:t.command})):[{name:"inspect",command:"pnpm agent:inspect"},{name:"build",command:"pnpm build"},{name:"validate",command:"pnpm agent:validate"},{name:"eval",command:"pnpm agent:eval"}]}function Le(s){return s?.plan?.requirements?.map(t=>({name:t.name,detail:[t.kind.replace(/_/g," "),t.status,t.detail].filter(Boolean).join(" / ")}))??[]}function De(s){const t=s?.workflowCapture;return t?[{name:"Actions",values:t.profileActions},{name:"Providers",values:t.externalProviders},{name:"Side effects",values:t.sideEffects},{name:"Files",values:t.files},{name:"Artifacts",values:t.outputArtifacts},{name:"Traces",values:t.traceRefs},{name:"Channels",values:t.channelTargets}].flatMap(({name:a,values:u})=>u.length?[{name:a,detail:u.join(", ")}]:[]):[]}function He(s){if(s.plan?.sourcePlan?.length)return s.plan.sourcePlan;const t=s.operation==="improve"?"update":"create",a=s.target.kind==="agent"?s.target.id??le(s.objective):le(s.objective);return[{path:Te(a),operation:t,reason:s.objective},{path:"settings/profile.yaml",operation:"update",reason:"Expose the default chat action through the hosted profile catalog."}]}function qe({workItem:s,detail:t,actionBusy:a,localProjectName:u,onApplyLocalPatch:m,onShowFiles:c}){const d=Ve(s,t),h=s.status==="needs_review"&&!!(u&&m);return e.jsxs("article",{className:"cloud-work-boundary-strip",children:[e.jsxs("div",{children:[e.jsx("span",{children:Fe(s)}),e.jsx("small",{children:Ke(s)})]}),e.jsx("div",{className:"cloud-work-boundary-chips",children:d.map(j=>e.jsx("span",{children:j},j))}),s.status==="needs_review"?e.jsxs("button",{type:"button",onClick:()=>{m&&m()},disabled:a||!h,title:h?`Apply to ${u}`:"Link this Cloud Project to a local checkout before applying locally.",children:[e.jsx(ie,{size:13}),e.jsx("span",{children:h?"Apply locally":"No local checkout"})]}):null,c?e.jsxs("button",{type:"button",onClick:c,children:[e.jsx(H,{size:13}),e.jsx("span",{children:"Files"})]}):null]})}function Fe(s){return s.status==="needs_review"?"Cloud patch ready":s.status==="queued"||s.status==="running"?"Running in Cloud":s.status==="failed"?"Cloud task failed":"Cloud task"}function Ke(s){return s.status==="needs_review"?"Review files and apply locally only when ready.":s.status==="queued"||s.status==="running"?"The local checkout is unchanged while the sandbox works.":s.status==="failed"?"Open files/logs to inspect the remote run before retrying.":"Cloud changes stay remote until an explicit apply or pull action."}function Ve(s,t){const a=[s.status.replace(/_/g," ")];return s.sourceRef&&a.push(s.sourceRef),s.latestSandboxId&&a.push("sandbox"),s.latestTaskRunId&&a.push("task run"),t?.activity.length&&a.push(`${t.activity.length} log${t.activity.length===1?"":"s"}`),s.status==="needs_review"&&a.push("patch only"),a.push("local unchanged"),a}function Ue({run:s,actionBusy:t,onApprove:a,onEdit:u,onCancel:m}){const c=s.state,d=s.plan,h=Ee(s),j=Le(s),f=De(s),N=He(s),x=we(d?.metadata),k=s.scope.targetProject?.name??s.scope.targetProject?.id??"Profile source",S=!!d&&c==="awaiting_plan_approval"&&(d?.status==="draft"||d?.status==="pending_approval"),A=(c==="planning"||c==="awaiting_plan_approval")&&(d?.status==="draft"||d?.status==="pending_approval");return e.jsxs("article",{className:"cloud-create-plan-review",children:[e.jsxs("div",{className:"cloud-create-plan-heading",children:[e.jsx(H,{size:16}),e.jsxs("div",{children:[e.jsx("span",{children:"Agent plan review"}),e.jsxs("small",{children:[s.operation," / ",Oe(s)," / ",c.replace(/_/g," ")]})]})]}),e.jsxs("div",{className:"cloud-create-plan-copy",children:[e.jsxs("section",{children:[e.jsx("span",{children:"Objective"}),e.jsx("p",{children:s.objective})]}),e.jsxs("section",{children:[e.jsx("span",{children:"Target"}),e.jsx("p",{children:k})]}),d?.capturedContextSummary?e.jsxs("section",{children:[e.jsx("span",{children:"Captured context"}),e.jsx("p",{children:d.capturedContextSummary})]}):s.context.targetRepoAssumptions.length?e.jsxs("section",{children:[e.jsx("span",{children:"Captured context"}),e.jsx("p",{children:s.context.targetRepoAssumptions.join("; ")})]}):null,s.context.attachments.length?e.jsxs("section",{children:[e.jsx("span",{children:"Inputs"}),e.jsx("p",{children:s.context.attachments.map(l=>l.name).join(", ")})]}):null,s.context.apps.length?e.jsxs("section",{children:[e.jsx("span",{children:"Apps"}),e.jsx("p",{children:s.context.apps.map(l=>l.name).join(", ")})]}):null,s.context.tools.length?e.jsxs("section",{children:[e.jsx("span",{children:"Tools"}),e.jsx("p",{children:s.context.tools.map(l=>l.name).join(", ")})]}):null,x?e.jsxs("section",{children:[e.jsx("span",{children:"Action shape"}),e.jsxs("p",{children:[x.label,": ",x.detail]})]}):null]}),e.jsxs("div",{className:"cloud-create-plan-grid",children:[x?e.jsxs("section",{children:[e.jsx("span",{children:"Actions"}),e.jsxs("ul",{children:[e.jsxs("li",{children:[e.jsx("code",{children:x.defaultActionKey??"chat"}),e.jsx("small",{children:x.label})]}),x.directActionHint?e.jsxs("li",{children:[e.jsx("code",{children:"direct action"}),e.jsx("small",{children:x.directActionHint})]}):null]})]}):null,e.jsxs("section",{children:[e.jsx("span",{children:"Source plan"}),e.jsx("ul",{children:N.map(l=>e.jsxs("li",{children:[e.jsx("code",{children:l.path}),e.jsx("small",{children:l.operation})]},`${l.operation}:${l.path}`))})]}),e.jsxs("section",{children:[e.jsx("span",{children:"Checks"}),e.jsx("ul",{children:h.map(l=>e.jsxs("li",{children:[e.jsx("code",{children:l.name}),e.jsx("small",{children:l.command})]},`${l.name}:${l.command}`))})]}),j.length?e.jsxs("section",{children:[e.jsx("span",{children:"Requirements"}),e.jsx("ul",{children:j.map(l=>e.jsxs("li",{children:[e.jsx("code",{children:l.name}),e.jsx("small",{children:l.detail})]},`${l.name}:${l.detail}`))})]}):null,f.length?e.jsxs("section",{children:[e.jsx("span",{children:"Workflow evidence"}),e.jsx("ul",{children:f.map(l=>e.jsxs("li",{children:[e.jsx("code",{children:l.name}),e.jsx("small",{children:l.detail})]},`${l.name}:${l.detail}`))})]}):null]}),e.jsxs("div",{className:"cloud-create-plan-actions",children:[e.jsxs("button",{type:"button",onClick:a,disabled:t||!S,children:[e.jsx(ie,{size:14}),e.jsx("span",{children:"Confirm plan"})]}),e.jsxs("button",{type:"button",onClick:u,disabled:t||!A,children:[e.jsx(H,{size:14}),e.jsx("span",{children:"Edit plan"})]}),e.jsxs("button",{type:"button",onClick:m,disabled:t,children:[e.jsx(Re,{size:14}),e.jsx("span",{children:"Cancel"})]})]})]})}function Qe({projects:s,workItems:t,selectedWorkItem:a,detail:u,loading:m,actionBusy:c,connection:d,error:h,model:j,showToast:f,onBack:N,onModelChange:x,onSetupCloudProject:k,onCreateWork:S,onSelectWorkItem:A,onSendMessage:l,onHandleBackground:q,onCancelCreatePlan:oe,onCancelTask:F,localProjectName:re,onApplyLocalPatch:de,onShowFiles:w}){const[y,R]=r.useState(""),[b,g]=r.useState(""),K=r.useRef(null),P=r.useRef(null),[ue,V]=r.useState(0),[pe,T]=r.useState(0),[U,_]=r.useState(!1),[X,G]=r.useState(!1),[C,z]=r.useState("tasks"),[$,he]=r.useState(""),[J,xe]=r.useState(()=>s[0]?.id??""),M=r.useMemo(()=>new Map(s.map(n=>[n.id,n])),[s]),v=M.has(J)?J:s[0]?.id??"",me=ye("openpond",j),je=r.useMemo(()=>s.length?s.map(n=>({value:n.id,label:n.organizationName?`${n.organizationName} / ${n.name}`:n.name,shortLabel:n.name,description:n.sourceLabel??n.defaultBranch??void 0})):[{value:"",label:"No Cloud Project"}],[s]),Q=r.useMemo(()=>{const n=$.trim().toLowerCase();return t.filter(o=>_e(o,C)?n?o.title.toLowerCase().includes(n):!0:!1)},[$,C,t]);async function Y(){const n=y.trim();!n||!v||c||(await S({projectId:v,prompt:n}),R(""),_(!1))}async function Z(){const n=b.trim();!n||c||(await l(n),g(""))}async function ve(){const n=b.trim();await q(n||null),g(""),G(!1)}function O(n){V(n.selectionStart??n.value.length)}function E(n){T(n.selectionStart??n.value.length)}function fe(n){const o=K.current,p=ae(y,n,o?.selectionStart??ue);R(p.value),V(p.cursorIndex),window.requestAnimationFrame(()=>{o?.focus(),o?.setSelectionRange(p.cursorIndex,p.cursorIndex)})}function be(n){const o=P.current,p=ae(b,n,o?.selectionStart??pe);g(p.value),T(p.cursorIndex),window.requestAnimationFrame(()=>{o?.focus(),o?.setSelectionRange(p.cursorIndex,p.cursorIndex)})}function ge(){g(n=>n||"Revise plan: "),window.requestAnimationFrame(()=>{const n=P.current,o=n?.value.length??0;n?.focus(),n?.setSelectionRange(o,o),T(o)})}if(a){const n=u?.messages??[],o=u?.activity??[],p=u?.createImproveRun??a.createImproveRun??null,W=Me(n),L=W?.body??a.title,Ce=M.get(a.projectId)??null,I=a.status==="queued"||a.status==="running";return e.jsxs("section",{className:"cloud-work-view thread",children:[e.jsx("div",{className:"cloud-thread-body",children:e.jsxs("div",{className:"cloud-thread-timeline",children:[e.jsxs("div",{className:"cloud-thread-inline-nav",children:[e.jsxs("button",{type:"button",onClick:N,children:[e.jsx(Ne,{size:15}),e.jsx("span",{children:"All tasks"})]}),e.jsx("span",{children:Ce?.name??"Cloud Project"}),a.sourceRef?e.jsx("span",{children:a.sourceRef}):null,w?e.jsx("button",{type:"button",onClick:w,children:e.jsx("span",{children:"Files"})}):null]}),L&&e.jsx("article",{className:"cloud-message user",children:e.jsx("p",{children:L})}),e.jsxs("div",{className:"cloud-worked-line",children:[e.jsx("span",{children:ze(a.status)}),e.jsx("span",{children:B(a.updatedAt)}),I&&e.jsxs("button",{type:"button",onClick:()=>{F()},disabled:c,children:[e.jsx(ee,{size:12}),e.jsx("span",{children:"Stop task"})]})]}),e.jsx(qe,{workItem:a,detail:u,actionBusy:c,localProjectName:re,onApplyLocalPatch:de,onShowFiles:w}),p?e.jsx(Ue,{run:p,actionBusy:c,onApprove:()=>{q(null)},onEdit:ge,onCancel:()=>{oe()}}):null,n.filter(i=>i.id!==W?.id).filter(i=>!ce(i)).map(i=>e.jsx("article",{className:`cloud-message ${i.role}`,children:e.jsx("p",{children:i.body})},i.id)),o.map(i=>e.jsxs("article",{className:"cloud-activity",children:[e.jsx("span",{children:i.kind.replace(/_/g," ")}),e.jsx("p",{children:i.summary})]},i.id)),!m&&n.length===0&&o.length===0&&!L&&e.jsx("p",{className:"cloud-muted",children:"No messages yet."})]})}),e.jsxs("div",{className:"cloud-thread-composer",children:[e.jsx("button",{type:"button",className:`cloud-composer-plus ${X?"active":""}`,onClick:()=>G(i=>!i),title:"Cloud task options",children:e.jsx(D,{size:18})}),X&&e.jsxs("div",{className:"cloud-composer-options thread-options",children:[e.jsxs("button",{type:"button",onClick:()=>{ve()},disabled:c,children:[e.jsx(Pe,{size:14}),e.jsx("span",{children:"Handle in background"})]}),I&&e.jsxs("button",{type:"button",onClick:()=>{F()},disabled:c,children:[e.jsx(ee,{size:14}),e.jsx("span",{children:"Stop task"})]})]}),e.jsx("textarea",{ref:P,value:b,rows:1,placeholder:"Request changes or ask a question",onChange:i=>{g(i.target.value),E(i.currentTarget)},onClick:i=>E(i.currentTarget),onSelect:i=>E(i.currentTarget),onKeyDown:i=>{i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),Z())}}),e.jsx(se,{buttonClassName:"cloud-composer-mic-button",connection:d,disabled:c,iconSize:17,wrapperClassName:"cloud-composer-mic",showToast:f,onTranscript:be}),e.jsx("button",{type:"button",className:"cloud-composer-submit",disabled:!b.trim()||c,onClick:()=>{Z()},title:"Send",children:e.jsx(ne,{size:17})})]}),h&&e.jsx("div",{className:"cloud-error",children:h})]})}return e.jsx("section",{className:"cloud-work-view home",children:e.jsxs("div",{className:"cloud-home-shell",children:[e.jsx("h1",{children:"What should we change next?"}),e.jsxs("div",{className:"cloud-home-composer",children:[e.jsx("textarea",{ref:K,value:y,rows:2,placeholder:"Describe a task",onChange:n=>{R(n.target.value),O(n.currentTarget)},onClick:n=>O(n.currentTarget),onSelect:n=>O(n.currentTarget),onKeyDown:n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),Y())}}),e.jsxs("div",{className:"cloud-home-composer-actions",children:[e.jsx("button",{type:"button",className:`cloud-composer-plus ${U?"active":""}`,onClick:()=>_(n=>!n),title:"Cloud task options",children:e.jsx(D,{size:18})}),e.jsxs("div",{className:"cloud-composer-selects",children:[e.jsx(te,{compact:!0,className:"cloud-project-select",disabled:c||s.length===0,label:"Cloud Project",options:je,placement:"top",value:v,onChange:xe}),e.jsx(te,{compact:!0,className:"cloud-model-select",disabled:c,label:"Model",options:ke("openpond"),placement:"top",value:me,onChange:x})]}),e.jsx(se,{buttonClassName:"cloud-composer-mic-button",connection:d,disabled:c,iconSize:17,wrapperClassName:"cloud-composer-mic",showToast:f,onTranscript:fe}),e.jsx("button",{type:"button",className:"cloud-composer-submit",disabled:!y.trim()||!v||c,onClick:()=>{Y()},title:"Handle in background",children:e.jsx(ne,{size:17})})]}),U&&e.jsxs("div",{className:"cloud-composer-options",children:[e.jsxs("button",{type:"button",onClick:()=>_(!1),disabled:c,children:[e.jsx(D,{size:14}),e.jsx("span",{children:"New task"})]}),e.jsxs("button",{type:"button",onClick:()=>k(v),disabled:!v||c,children:[e.jsx(Se,{size:14}),e.jsx("span",{children:"Create environment"})]})]})]}),e.jsxs("div",{className:"cloud-task-list-toolbar",children:[e.jsxs("div",{className:"cloud-task-tabs",role:"tablist","aria-label":"Cloud tasks",children:[e.jsx("button",{type:"button",className:C==="tasks"?"active":"",onClick:()=>z("tasks"),children:"Tasks"}),e.jsx("button",{type:"button",className:C==="reviews"?"active":"",onClick:()=>z("reviews"),children:"Code reviews"}),e.jsx("button",{type:"button",className:C==="archive"?"active":"",onClick:()=>z("archive"),children:"Archive"})]}),e.jsxs("label",{className:"cloud-task-search",children:[e.jsx(Ae,{size:17}),e.jsx("input",{value:$,placeholder:"Search",onChange:n=>he(n.target.value)})]})]}),e.jsxs("div",{className:"cloud-task-list",children:[Q.map(n=>e.jsxs("button",{type:"button",className:"cloud-task-row",onClick:()=>A(n),children:[e.jsx("span",{children:n.title}),e.jsxs("small",{children:[B(n.updatedAt)," · ",$e(M,n.projectId)]})]},n.id)),!m&&Q.length===0&&e.jsx("p",{className:"cloud-empty",children:s.length?"No tasks yet":"Create or link a Cloud Project before starting a task"}),m&&e.jsx("p",{className:"cloud-empty",children:"Loading tasks..."})]}),h&&e.jsx("div",{className:"cloud-error",children:h})]})})}export{Qe as CloudWorkView};
@@ -1 +1 @@
1
- import{r as j,j as e,S as g,a as b,i as f,C,F as P,P as k,M,b as v,c as S}from"./index-D7Vr3zcV.js";function E({open:a,query:r,projects:c,sessions:o,onQueryChange:n,onClose:d,onNewChat:x,onOpenProject:u,onOpenSession:p}){const t=r.trim().toLowerCase(),l=j.useMemo(()=>w(o,t,10),[t,o]),i=j.useMemo(()=>L(c,t,8),[t,c]);if(!a)return null;const N=()=>{const s=i[0];if(s){u(s);return}const m=l[0];m&&p(m)};return e.jsx("div",{className:"command-overlay",role:"presentation",onMouseDown:d,children:e.jsxs("section",{className:"command-menu",role:"dialog","aria-modal":"true","aria-label":"Search chats and projects",onMouseDown:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"command-input-row",children:[e.jsx(g,{size:17}),e.jsx("input",{autoFocus:!0,value:r,onChange:s=>n(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),N()),s.key==="Escape"&&(s.preventDefault(),d())},placeholder:"Search chats and projects"}),e.jsx("kbd",{children:"Esc"})]}),e.jsxs("div",{className:"command-results",children:[e.jsxs("button",{className:"command-result command-create",onClick:x,children:[e.jsx(b,{size:15}),e.jsx("span",{children:"New local task"}),e.jsx("small",{children:"General"})]}),e.jsxs(h,{label:"Projects",children:[i.map(s=>e.jsxs("button",{className:"command-result",onClick:()=>u(s),children:[f(s)?e.jsx(C,{size:15}):e.jsx(P,{size:15}),e.jsx("span",{children:s.project.name}),e.jsx("small",{children:z(s)})]},s.project.id)),i.length===0&&e.jsx("div",{className:"command-empty",children:"No projects found"})]}),e.jsxs(h,{label:"Chats",children:[l.map(s=>e.jsxs("button",{className:"command-result",onClick:()=>p(s),children:[s.pinned?e.jsx(k,{size:15}):e.jsx(M,{size:15}),e.jsx("span",{children:s.title}),e.jsx("small",{children:s.appName??v(s.updatedAt)})]},s.id)),l.length===0&&e.jsx("div",{className:"command-empty",children:"No chats found"})]})]})]})})}function w(a,r,c){const o=[];for(const n of a)if((!r||`${n.title} ${n.appName??""}`.toLowerCase().includes(r))&&(o.push(n),o.length>=c))break;return o}function L(a,r,c){const o=[];for(const n of a)if((!r||$(n).toLowerCase().includes(r))&&(o.push(n),o.length>=c))break;return o}function $(a){return S(a)?`${a.project.name} ${a.project.path} ${a.project.workspacePath}`:`${a.project.name} ${a.project.sourceLabel??""} ${a.project.organizationName??""}`}function z(a){return f(a)?a.project.organizationName??"Cloud Project":a.project.linkedOpenPondApp?"OpenPond project":a.project.source==="git"?"Local Git":"Local folder"}function h({label:a,children:r}){return e.jsxs("div",{className:"command-group",children:[e.jsx("div",{className:"command-group-label",children:a}),r]})}export{E as CommandMenu};
1
+ import{r as j,j as e,S as g,a as b,i as f,C,F as P,P as k,M,b as v,c as S}from"./index-CKmte5ok.js";function E({open:a,query:r,projects:c,sessions:o,onQueryChange:n,onClose:d,onNewChat:x,onOpenProject:u,onOpenSession:p}){const t=r.trim().toLowerCase(),l=j.useMemo(()=>w(o,t,10),[t,o]),i=j.useMemo(()=>L(c,t,8),[t,c]);if(!a)return null;const N=()=>{const s=i[0];if(s){u(s);return}const m=l[0];m&&p(m)};return e.jsx("div",{className:"command-overlay",role:"presentation",onMouseDown:d,children:e.jsxs("section",{className:"command-menu",role:"dialog","aria-modal":"true","aria-label":"Search chats and projects",onMouseDown:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"command-input-row",children:[e.jsx(g,{size:17}),e.jsx("input",{autoFocus:!0,value:r,onChange:s=>n(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),N()),s.key==="Escape"&&(s.preventDefault(),d())},placeholder:"Search chats and projects"}),e.jsx("kbd",{children:"Esc"})]}),e.jsxs("div",{className:"command-results",children:[e.jsxs("button",{className:"command-result command-create",onClick:x,children:[e.jsx(b,{size:15}),e.jsx("span",{children:"New local task"}),e.jsx("small",{children:"General"})]}),e.jsxs(h,{label:"Projects",children:[i.map(s=>e.jsxs("button",{className:"command-result",onClick:()=>u(s),children:[f(s)?e.jsx(C,{size:15}):e.jsx(P,{size:15}),e.jsx("span",{children:s.project.name}),e.jsx("small",{children:z(s)})]},s.project.id)),i.length===0&&e.jsx("div",{className:"command-empty",children:"No projects found"})]}),e.jsxs(h,{label:"Chats",children:[l.map(s=>e.jsxs("button",{className:"command-result",onClick:()=>p(s),children:[s.pinned?e.jsx(k,{size:15}):e.jsx(M,{size:15}),e.jsx("span",{children:s.title}),e.jsx("small",{children:s.appName??v(s.updatedAt)})]},s.id)),l.length===0&&e.jsx("div",{className:"command-empty",children:"No chats found"})]})]})]})})}function w(a,r,c){const o=[];for(const n of a)if((!r||`${n.title} ${n.appName??""}`.toLowerCase().includes(r))&&(o.push(n),o.length>=c))break;return o}function L(a,r,c){const o=[];for(const n of a)if((!r||$(n).toLowerCase().includes(r))&&(o.push(n),o.length>=c))break;return o}function $(a){return S(a)?`${a.project.name} ${a.project.path} ${a.project.workspacePath}`:`${a.project.name} ${a.project.sourceLabel??""} ${a.project.organizationName??""}`}function z(a){return f(a)?a.project.organizationName??"Cloud Project":a.project.linkedOpenPondApp?"OpenPond project":a.project.source==="git"?"Local Git":"Local folder"}function h({label:a,children:r}){return e.jsxs("div",{className:"command-group",children:[e.jsx("div",{className:"command-group-label",children:a}),r]})}export{E as CommandMenu};
@@ -1 +1 @@
1
- import{r as l,j as e,X as H,bC as W,bD as Z,bE as ee,bk as se,bF as ne,bG as te,a as ie,T as ae,aQ as Y,bH as q,J as le}from"./index-D7Vr3zcV.js";import{S as re,W as oe,B as ce}from"./wifi-off-BKTqnqj0.js";import{R as O}from"./refresh-cw-DE0u_nmZ.js";import{R as de}from"./reply-2MfLJ93n.js";const me=2e4,A=10,ue=12*1024*1024,he=new Set(["image/png","image/jpeg","image/webp","image/gif"]);function ye(s){const[n,m]=l.useState(""),[a,y]=l.useState(0),[c,u]=l.useState([]),[b,i]=l.useState(null),[f,h]=l.useState(!1),[p,C]=l.useState([]),[N,v]=l.useState(0),[M,r]=l.useState(null),k=l.useRef(null),R=l.useRef(null),I=l.useRef(c);I.current=c;const g=l.useMemo(()=>ge(n,a),[n,a]),S=g?`${g.start}:${g.end}:${g.query}`:null,L=g?.query??null,w=l.useMemo(()=>{if(!g)return[];const t=new Map;for(const d of[...s.members,...p])t.set(d.userId,d);const o=g.query.toLowerCase();return[...t.values()].filter(d=>`${d.handle??""} ${d.name??""}`.toLowerCase().includes(o)).slice(0,8)},[g,s.members,p]),D=!!(g&&S!==M&&w.length>0),T=!!(s.disabled||s.busy||f),B=!T&&(!!n.trim()||c.length>0);l.useEffect(()=>{if(L==null){C([]);return}let t=!0;const o=window.setTimeout(()=>{s.onSearchMembers(L).then(d=>{t&&C(d)},()=>{t&&C([])})},150);return()=>{t=!1,window.clearTimeout(o)}},[L,s.onSearchMembers]),l.useEffect(()=>{v(0)},[S]),l.useEffect(()=>()=>F(I.current),[]);async function U(t){if(t?.preventDefault(),!!B){i(null),h(!0);try{const o=await Promise.all(c.map(ne));if(!await s.onSend({body:n,mentionUserIds:xe(n,s.members),attachments:o,replyToMessageId:s.replyTo?.id??null}))return;F(c),m(""),y(0),u([]),s.onCancelReply()}catch(o){i(o instanceof Error?o.message:String(o))}finally{h(!1)}}}function X(t){if(D){if(t.key==="ArrowDown"){t.preventDefault(),v(o=>(o+1)%w.length);return}if(t.key==="ArrowUp"){t.preventDefault(),v(o=>(o-1+w.length)%w.length);return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),$(w[N]??w[0]);return}if(t.key==="Escape"){t.preventDefault(),r(S);return}}t.key!=="Enter"||t.shiftKey||t.nativeEvent.isComposing||(t.preventDefault(),U())}function G(t){if(!t)return;i(null);const o=Math.max(0,A-c.length);if(o===0){i(`You can attach up to ${A} images.`),E();return}const d=[...t],j=d.slice(0,o),z=j.find(x=>!he.has(x.type)),P=j.find(x=>x.size<=0||x.size>ue);if(z){i(`${z.name} is not a supported image type.`),E();return}if(P){i(`${P.name} must be smaller than 12 MB.`),E();return}const Q=j.map(x=>({id:te(),file:x,name:x.name,mediaType:x.type,sizeBytes:x.size,kind:"image",previewUrl:URL.createObjectURL(x)}));u(x=>[...x,...Q]),d.length>o&&i(`Only ${A} images can be attached to one message.`),E()}function V(t){u(o=>{const d=o.find(j=>j.id===t);return d?.previewUrl&&URL.revokeObjectURL(d.previewUrl),o.filter(j=>j.id!==t)})}function E(){k.current&&(k.current.value="")}function $(t){if(!g)return;const o=`@${J(t)} `,d=`${n.slice(0,g.start)}${o}${n.slice(g.end)}`,j=g.start+o.length;m(d),y(j),r(null),window.requestAnimationFrame(()=>R.current?.focusAtPromptIndex(j))}return e.jsxs("form",{className:`composer dock community-composer${c.length>0?" has-attachments":""}${b?" has-attachment-error":""}`,onSubmit:U,children:[s.replyTo?e.jsxs("div",{className:"community-composer-reply",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Replying to"}),s.replyTo.body.slice(0,100)||"message"]}),e.jsx("button",{type:"button","aria-label":"Cancel reply",onClick:s.onCancelReply,children:e.jsx(H,{size:13})})]}):null,D?e.jsx("div",{className:"community-mention-menu",role:"listbox","aria-label":"Community members",children:w.map((t,o)=>e.jsxs("button",{type:"button",role:"option","aria-selected":o===N,onMouseDown:d=>d.preventDefault(),onClick:()=>$(t),children:[e.jsx("strong",{children:t.name??t.handle??"Community member"}),t.handle?e.jsxs("small",{children:["@",t.handle]}):null]},t.userId))}):null,e.jsxs("div",{className:"composer-input-shell",children:[c.length>0?e.jsx("div",{className:"composer-attachments","aria-label":"Selected attachments",children:c.map(t=>e.jsx(W,{attachment:t,onRemove:()=>V(t.id)},t.id))}):null,b?e.jsx("div",{className:"composer-attachment-error",role:"status",children:b}):null,e.jsx("div",{className:"composer-textarea-frame",onClick:t=>{t.target===t.currentTarget&&R.current?.focusAtPromptIndex(a)},children:e.jsx(Z,{ref:R,disabled:T,onCursorChange:y,onKeyDown:X,onPromptChange:(t,o)=>{const d=t.slice(0,me);m(d),y(Math.min(o,d.length))},onTokenPositionChange:()=>{},placeholder:s.disabled?"Accept the community rules to post":"Message community",prompt:n,token:null})}),e.jsxs("div",{className:"composer-primary-controls team-chat-composer-controls",children:[e.jsx("input",{ref:k,className:"composer-file-input",hidden:!0,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",multiple:!0,onChange:t=>G(t.currentTarget.files)}),e.jsx("button",{type:"button",className:"composer-icon","aria-label":"Attach images",disabled:T||c.length>=A,onClick:()=>k.current?.click(),children:e.jsx(ee,{size:17})}),e.jsx("div",{className:"composer-spacer"}),e.jsx("button",{type:"submit",className:"send-button","aria-label":"Send message",disabled:!B,children:e.jsx(se,{size:17})})]})]})]})}function ge(s,n=s.length){const m=Math.max(0,Math.min(n,s.length)),a=/(?:^|\s)@([\w-]*)$/.exec(s.slice(0,m));return!a||a.index==null?null:{start:a.index+a[0].indexOf("@"),end:m,query:a[1]??""}}function xe(s,n){const m=new Set([...s.matchAll(/(?:^|\s)@([\w-]+)/g)].map(a=>a[1]?.toLowerCase()));return n.filter(a=>m.has(J(a).toLowerCase())).map(a=>a.userId)}function J(s){return s.handle??s.name?.replace(/[^\w-]/g,"")??s.userId}function F(s){for(const n of s)n.previewUrl&&URL.revokeObjectURL(n.previewUrl)}function be(s){const[n,m]=l.useState(!1),[a,y]=l.useState(s.message.body),c=s.message.refs.find(i=>i.refType==="message_reply"),u=c?s.messagesById.get(c.refId)??null:null,b=u?.authorUserId?s.membersById.get(u.authorUserId)??null:null;return e.jsxs("article",{className:`community-message${s.own?" own":""}`,id:`community-message-${s.message.id}`,children:[e.jsx("div",{className:"community-avatar",children:fe(s.author?.name??s.author?.handle??"?")}),e.jsxs("div",{className:"community-message-content",children:[e.jsxs("header",{children:[e.jsx("strong",{children:s.author?.name??s.author?.handle??"Community member"}),e.jsx("time",{dateTime:s.message.createdAt,children:je(s.message.createdAt)}),s.message.editedAt?e.jsx("span",{children:"edited"}):null,s.message.deletedAt?null:e.jsxs("div",{className:"community-message-actions",children:[e.jsx("button",{type:"button","aria-label":"Reply",onClick:()=>s.onReply(s.message),children:e.jsx(de,{size:13})}),s.own?e.jsx("button",{type:"button","aria-label":"Edit",onClick:()=>m(!0),children:e.jsx(ie,{size:13})}):null,s.own?e.jsx("button",{type:"button","aria-label":"Delete",onClick:()=>{s.onDelete(s.message.id)},children:e.jsx(ae,{size:13})}):null]})]}),c?e.jsxs("button",{type:"button",className:"community-reply-quote",onClick:()=>document.getElementById(`community-message-${c.refId}`)?.scrollIntoView({behavior:"smooth",block:"center"}),children:[e.jsx("strong",{children:b?.name??"Community member"}),e.jsx("span",{children:u?.deletedAt?"Message deleted":u?.body??String(c.preview.body??"Earlier message")})]}):null,n?e.jsxs("form",{className:"community-message-edit",onSubmit:i=>{i.preventDefault(),s.onEdit(s.message.id,a).then(f=>{f&&m(!1)})},children:[e.jsx("textarea",{autoFocus:!0,value:a,onChange:i=>y(i.currentTarget.value)}),e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>m(!1),children:"Cancel"}),e.jsx("button",{type:"submit",disabled:!a.trim(),children:"Save"})]})]}):s.message.deletedAt?e.jsx("div",{className:"community-message-deleted",children:"Message deleted"}):e.jsx(Y,{content:s.message.body}),!s.message.deletedAt&&s.message.attachments.length>0?e.jsx("div",{className:"community-message-attachments",children:s.message.attachments.map(i=>s.attachmentsAccessible?e.jsxs("button",{type:"button",onClick:()=>{s.onDownloadAttachment(i.id)},children:[e.jsx("span",{children:i.name}),e.jsx("small",{children:K(i.sizeBytes)})]},i.id):e.jsxs("div",{className:"community-attachment-placeholder",children:[e.jsx("span",{children:i.name}),e.jsxs("small",{children:["Join to view · ",K(i.sizeBytes)]})]},i.id))}):null]})]})}function fe(s){return s.split(/\s+/).slice(0,2).map(n=>n[0]?.toUpperCase()??"").join("")||"?"}function je(s){const n=new Date(s);return Number.isNaN(n.getTime())?"":n.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function K(s){return s<1024?`${s} B`:s<1024*1024?`${Math.round(s/1024)} KB`:`${(s/1024/1024).toFixed(1)} MB`}function pe(s){const[n,m]=l.useState(!1),a=l.useRef(null),y=l.useRef(s.onClose);l.useEffect(()=>m(!1),[s.rules.id]),l.useEffect(()=>{y.current=s.onClose},[s.onClose]),l.useEffect(()=>{const u=document.activeElement instanceof HTMLElement?document.activeElement:null,b=a.current,i=()=>[...b?.querySelectorAll('button:not([disabled]), input:not([disabled]), [href], [tabindex]:not([tabindex="-1"])')??[]];i()[0]?.focus();const f=h=>{if(h.key==="Escape"){h.preventDefault(),y.current();return}if(h.key!=="Tab")return;const p=i();if(p.length===0){h.preventDefault(),b?.focus();return}const C=p[0],N=p.at(-1);h.shiftKey&&document.activeElement===C?(h.preventDefault(),N.focus()):!h.shiftKey&&document.activeElement===N&&(h.preventDefault(),C.focus())};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),u?.focus()}},[]);const c=s.mode!=="review";return e.jsx("div",{className:"community-dialog-backdrop",role:"presentation",onMouseDown:s.onClose,children:e.jsxs("section",{ref:a,className:"community-rules-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"community-rules-title",tabIndex:-1,onMouseDown:u=>u.stopPropagation(),children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsxs("small",{children:["Community rules · version ",s.rules.version]}),e.jsx("h2",{id:"community-rules-title",children:s.rules.title})]}),e.jsx("button",{type:"button","aria-label":"Close rules",onClick:s.onClose,children:e.jsx(H,{size:16})})]}),e.jsx("div",{className:"community-rules-body",children:e.jsx(Y,{content:s.rules.bodyMarkdown})}),s.error?e.jsx("div",{className:"community-state error",role:"alert",children:s.error}):null,e.jsxs("footer",{children:[c?e.jsxs("label",{className:"community-rules-acceptance",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:u=>m(u.currentTarget.checked)}),e.jsx("span",{children:"I have read and agree to follow these rules."})]}):e.jsx("span",{}),e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"secondary",onClick:s.onClose,children:"Cancel"}),c?e.jsx("button",{type:"button",disabled:!n||s.busy,onClick:()=>{s.onAccept().then(u=>{u&&s.onClose()})},children:s.busy?"Saving…":s.mode==="join"?"Agree and join":"Accept updated rules"}):null]})]})]})})}function ke({communities:s,chat:n,currentUserId:m}){const[a,y]=l.useState(null),[c,u]=l.useState(null),b=l.useRef(null),i=s.preview,f=i?.membership?.status==="active",h=!!i?.capabilities.requiresRulesAcceptance,p=l.useMemo(()=>new Map(n.members.map(r=>[r.userId,r])),[n.members]),C=l.useMemo(()=>new Map(n.messages.map(r=>[r.id,r])),[n.messages]),N=n.messages.at(-1)?.sequence??0;if(l.useEffect(()=>{const r=b.current;r&&(r.scrollTop=r.scrollHeight)},[n.selectedChannelId,N]),l.useEffect(()=>{u(null),h&&i?.currentRules&&y("reaccept")},[i?.currentRules,h]),!s.selectedSummary)return e.jsx("section",{className:"community-empty-page",children:e.jsxs("div",{className:"community-discovery-card",children:[e.jsx(q,{size:30}),e.jsx("h1",{children:"Discover communities"}),e.jsx("p",{children:s.discoveryLoading&&s.items.length===0?"Finding communities…":"Preview public conversations and join after accepting each community's rules."}),s.discoveryError?e.jsx("div",{className:"community-state error",children:s.discoveryError}):null,s.items.length>0?e.jsx("div",{className:"community-discovery-list",children:s.items.map(r=>e.jsxs("button",{type:"button",onClick:()=>s.selectCommunity(r.id),children:[e.jsx(_,{name:r.displayName,imageUrl:r.imageUrl}),e.jsxs("span",{children:[e.jsx("strong",{children:r.displayName}),e.jsx("small",{children:r.description})]}),e.jsx("em",{children:r.membership?.status==="active"?"Joined":r.featuredAt?"Featured":`${r.memberCount.toLocaleString()} members`})]},r.id))}):s.discoveryLoading?null:e.jsx("div",{className:"community-state",children:"No public communities are available yet."}),e.jsxs("div",{className:"community-discovery-actions",children:[e.jsxs("button",{type:"button",onClick:()=>{s.refresh()},disabled:s.discoveryLoading,children:[e.jsx(O,{size:14})," Refresh"]}),s.nextCursor?e.jsx("button",{type:"button",className:"secondary",onClick:()=>{s.loadMore()},disabled:s.discoveryLoading,children:"Load more"}):null]})]})});if(!i&&s.previewLoading)return e.jsx("section",{className:"community-empty-page",children:e.jsxs("div",{className:"community-empty-card",children:[e.jsx("span",{className:"community-spinner"})," Loading community…"]})});if(!i)return e.jsx("section",{className:"community-empty-page",children:e.jsxs("div",{className:"community-empty-card",children:[e.jsx("h1",{children:s.selectedSummary.displayName}),e.jsx("div",{className:"community-state error",children:s.previewError??"This community preview is unavailable."}),e.jsxs("button",{type:"button",onClick:()=>s.selectCommunity(s.selectedSummary.id),children:[e.jsx(O,{size:14})," Retry preview"]})]})});const v=i.currentRules,M=s.membershipError?.message??null;return e.jsxs("section",{className:"community-view",children:[e.jsxs("header",{className:"community-header",children:[e.jsxs("div",{className:"community-heading",children:[e.jsx(_,{name:i.displayName,imageUrl:i.imageUrl}),e.jsxs("div",{children:[e.jsx("small",{children:i.displayName}),e.jsx("h1",{children:n.selectedChannel?`# ${n.selectedChannel.displayName}`:i.displayName}),e.jsx("p",{children:n.selectedChannel?.topic||i.description})]})]}),e.jsxs("div",{className:"community-header-actions",children:[e.jsxs("span",{className:"community-member-count",children:[e.jsx(q,{size:14})," ",i.memberCount.toLocaleString()]}),v?e.jsxs("button",{type:"button",className:"secondary",onClick:()=>y("review"),children:[e.jsx(re,{size:14})," Rules"]}):null,f?e.jsx(ve,{mode:i.membership?.notificationMode??"mentions",busy:s.membershipBusy,onMode:s.updateNotifications,onLeave:s.leave}):null]})]}),e.jsxs("div",{className:"community-chat-main conversation-surface-main",children:[e.jsxs("div",{className:"community-chat-notices",children:[f?h?e.jsxs("div",{className:"community-preview-banner warning",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"The rules have changed"}),e.jsx("span",{children:"Accept the current rules to continue reading live updates and posting."})]}),e.jsx("button",{type:"button",disabled:!v||s.membershipBusy,onClick:()=>y("reaccept"),children:"Review updated rules"})]}):null:e.jsxs("div",{className:"community-preview-banner",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:["Previewing ",i.displayName]}),e.jsx("span",{children:"Read the public conversation, then accept the rules to join and post."})]}),e.jsx("button",{type:"button",disabled:!v||s.membershipBusy,onClick:()=>y("join"),children:"Join community"})]}),n.realtimeError&&f&&!h?e.jsxs("div",{className:"community-realtime-state",children:[e.jsx(oe,{size:14}),e.jsx("span",{children:"Live updates are reconnecting. Loaded messages are still available."})]}):null,n.lostMembership?e.jsx("div",{className:"community-state error",children:"Your membership changed. Refresh the community before continuing."}):null,n.channelsError?e.jsxs("div",{className:"community-state error",children:["Channels: ",n.channelsError," ",e.jsx("button",{type:"button",onClick:()=>{n.loadChannels()},children:"Retry"})]}):null,M?e.jsx("div",{className:"community-state error",role:"alert",children:M}):null]}),e.jsxs("div",{className:"community-message-pane conversation-message-scroll",ref:b,role:"log","aria-live":"polite","aria-relevant":"additions text","aria-busy":n.messagesLoading,"aria-label":n.selectedChannel?`${i.displayName}, ${n.selectedChannel.displayName}`:i.displayName,tabIndex:0,children:[n.hasMoreBefore?e.jsx("button",{type:"button",className:"community-load-older",disabled:n.olderMessagesLoading,onClick:()=>{n.loadOlder()},children:n.olderMessagesLoading?"Loading…":"Load earlier messages"}):null,n.messagesLoading&&n.messages.length===0?e.jsx("div",{className:"community-message-state",children:"Loading messages…"}):null,n.messagesError?e.jsxs("div",{className:"community-message-state error",children:["Could not load messages: ",n.messagesError," ",e.jsx("button",{type:"button",onClick:()=>{n.loadMessages()},children:"Retry"})]}):null,!n.messagesLoading&&!n.messagesError&&n.messages.length===0?e.jsx("div",{className:"community-message-state",children:"No messages in this channel yet."}):null,n.messages.map(r=>e.jsx(be,{message:r,author:r.authorUserId?p.get(r.authorUserId)??null:null,own:r.authorUserId===m,attachmentsAccessible:!n.previewMode,membersById:p,messagesById:C,onReply:u,onEdit:n.editMessage,onDelete:n.deleteMessage,onDownloadAttachment:n.downloadAttachment},r.id))]}),f?e.jsxs("div",{className:"community-composer-wrap conversation-composer-shell",children:[n.actionError?e.jsx("div",{className:"community-composer-action-error",children:n.actionError}):null,n.failedSend?e.jsxs("div",{className:"community-failed-send",children:[e.jsxs("span",{children:["Message not sent. ",n.failedSend.message]}),e.jsx("button",{type:"button",disabled:n.sending,onClick:()=>{n.retrySend()},children:"Retry"}),e.jsx("button",{type:"button",onClick:n.dismissFailedSend,children:"Dismiss"})]}):null,e.jsx(ye,{members:n.members,replyTo:c,busy:n.sending,disabled:h||n.lostMembership||!n.selectedChannel||n.selectedChannel.postingPolicy==="admins"&&i.membership?.role==="member",onCancelReply:()=>u(null),onSearchMembers:n.searchMembers,onSend:n.sendMessage})]}):null]}),a&&v?e.jsx(pe,{rules:v,mode:a,busy:s.membershipBusy,error:M,onAccept:a==="join"?s.join:s.acceptRules,onClose:()=>y(null)}):null]})}function ve(s){const[n,m]=l.useState(!1);return e.jsxs("div",{className:"community-membership-menu",children:[e.jsxs("button",{type:"button",className:"secondary","aria-expanded":n,onClick:()=>m(a=>!a),children:[s.mode==="none"?e.jsx(le,{size:14}):e.jsx(ce,{size:14})," Joined"]}),n?e.jsxs("div",{className:"community-membership-popover",children:[e.jsx("strong",{children:"Notifications"}),["mentions","all","none"].map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"radio",name:"community-notifications",checked:s.mode===a,disabled:s.busy,onChange:()=>{s.onMode(a)}})," ",a==="mentions"?"Mentions":a==="all"?"All messages":"Nothing"]},a)),e.jsx("button",{type:"button",className:"danger",disabled:s.busy,onClick:()=>{window.confirm("Leave this community? You can join again later by accepting the current rules.")&&s.onLeave().then(a=>{a&&m(!1)})},children:"Leave community"})]}):null]})}function _({name:s,imageUrl:n}){return n?e.jsx("img",{className:"community-icon",src:n,alt:""}):e.jsx("span",{className:"community-icon fallback",children:s.slice(0,2).toUpperCase()})}export{ke as CommunityView};
1
+ import{r as l,j as e,X as H,bC as W,bD as Z,bE as ee,bl as se,bF as ne,bG as te,a as ie,T as ae,aQ as Y,bH as q,J as le}from"./index-CKmte5ok.js";import{S as re,W as oe,B as ce}from"./wifi-off-XFVqsf4c.js";import{R as O}from"./refresh-cw-JNUovwk4.js";import{R as de}from"./reply-D4QvJyzE.js";const me=2e4,A=10,ue=12*1024*1024,he=new Set(["image/png","image/jpeg","image/webp","image/gif"]);function ye(s){const[n,m]=l.useState(""),[a,y]=l.useState(0),[c,u]=l.useState([]),[b,i]=l.useState(null),[f,h]=l.useState(!1),[p,C]=l.useState([]),[N,v]=l.useState(0),[M,r]=l.useState(null),k=l.useRef(null),R=l.useRef(null),I=l.useRef(c);I.current=c;const g=l.useMemo(()=>ge(n,a),[n,a]),S=g?`${g.start}:${g.end}:${g.query}`:null,L=g?.query??null,w=l.useMemo(()=>{if(!g)return[];const t=new Map;for(const d of[...s.members,...p])t.set(d.userId,d);const o=g.query.toLowerCase();return[...t.values()].filter(d=>`${d.handle??""} ${d.name??""}`.toLowerCase().includes(o)).slice(0,8)},[g,s.members,p]),D=!!(g&&S!==M&&w.length>0),T=!!(s.disabled||s.busy||f),B=!T&&(!!n.trim()||c.length>0);l.useEffect(()=>{if(L==null){C([]);return}let t=!0;const o=window.setTimeout(()=>{s.onSearchMembers(L).then(d=>{t&&C(d)},()=>{t&&C([])})},150);return()=>{t=!1,window.clearTimeout(o)}},[L,s.onSearchMembers]),l.useEffect(()=>{v(0)},[S]),l.useEffect(()=>()=>F(I.current),[]);async function U(t){if(t?.preventDefault(),!!B){i(null),h(!0);try{const o=await Promise.all(c.map(ne));if(!await s.onSend({body:n,mentionUserIds:xe(n,s.members),attachments:o,replyToMessageId:s.replyTo?.id??null}))return;F(c),m(""),y(0),u([]),s.onCancelReply()}catch(o){i(o instanceof Error?o.message:String(o))}finally{h(!1)}}}function X(t){if(D){if(t.key==="ArrowDown"){t.preventDefault(),v(o=>(o+1)%w.length);return}if(t.key==="ArrowUp"){t.preventDefault(),v(o=>(o-1+w.length)%w.length);return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),$(w[N]??w[0]);return}if(t.key==="Escape"){t.preventDefault(),r(S);return}}t.key!=="Enter"||t.shiftKey||t.nativeEvent.isComposing||(t.preventDefault(),U())}function G(t){if(!t)return;i(null);const o=Math.max(0,A-c.length);if(o===0){i(`You can attach up to ${A} images.`),E();return}const d=[...t],j=d.slice(0,o),z=j.find(x=>!he.has(x.type)),P=j.find(x=>x.size<=0||x.size>ue);if(z){i(`${z.name} is not a supported image type.`),E();return}if(P){i(`${P.name} must be smaller than 12 MB.`),E();return}const Q=j.map(x=>({id:te(),file:x,name:x.name,mediaType:x.type,sizeBytes:x.size,kind:"image",previewUrl:URL.createObjectURL(x)}));u(x=>[...x,...Q]),d.length>o&&i(`Only ${A} images can be attached to one message.`),E()}function V(t){u(o=>{const d=o.find(j=>j.id===t);return d?.previewUrl&&URL.revokeObjectURL(d.previewUrl),o.filter(j=>j.id!==t)})}function E(){k.current&&(k.current.value="")}function $(t){if(!g)return;const o=`@${J(t)} `,d=`${n.slice(0,g.start)}${o}${n.slice(g.end)}`,j=g.start+o.length;m(d),y(j),r(null),window.requestAnimationFrame(()=>R.current?.focusAtPromptIndex(j))}return e.jsxs("form",{className:`composer dock community-composer${c.length>0?" has-attachments":""}${b?" has-attachment-error":""}`,onSubmit:U,children:[s.replyTo?e.jsxs("div",{className:"community-composer-reply",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Replying to"}),s.replyTo.body.slice(0,100)||"message"]}),e.jsx("button",{type:"button","aria-label":"Cancel reply",onClick:s.onCancelReply,children:e.jsx(H,{size:13})})]}):null,D?e.jsx("div",{className:"community-mention-menu",role:"listbox","aria-label":"Community members",children:w.map((t,o)=>e.jsxs("button",{type:"button",role:"option","aria-selected":o===N,onMouseDown:d=>d.preventDefault(),onClick:()=>$(t),children:[e.jsx("strong",{children:t.name??t.handle??"Community member"}),t.handle?e.jsxs("small",{children:["@",t.handle]}):null]},t.userId))}):null,e.jsxs("div",{className:"composer-input-shell",children:[c.length>0?e.jsx("div",{className:"composer-attachments","aria-label":"Selected attachments",children:c.map(t=>e.jsx(W,{attachment:t,onRemove:()=>V(t.id)},t.id))}):null,b?e.jsx("div",{className:"composer-attachment-error",role:"status",children:b}):null,e.jsx("div",{className:"composer-textarea-frame",onClick:t=>{t.target===t.currentTarget&&R.current?.focusAtPromptIndex(a)},children:e.jsx(Z,{ref:R,disabled:T,onCursorChange:y,onKeyDown:X,onPromptChange:(t,o)=>{const d=t.slice(0,me);m(d),y(Math.min(o,d.length))},onTokenPositionChange:()=>{},placeholder:s.disabled?"Accept the community rules to post":"Message community",prompt:n,token:null})}),e.jsxs("div",{className:"composer-primary-controls team-chat-composer-controls",children:[e.jsx("input",{ref:k,className:"composer-file-input",hidden:!0,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",multiple:!0,onChange:t=>G(t.currentTarget.files)}),e.jsx("button",{type:"button",className:"composer-icon","aria-label":"Attach images",disabled:T||c.length>=A,onClick:()=>k.current?.click(),children:e.jsx(ee,{size:17})}),e.jsx("div",{className:"composer-spacer"}),e.jsx("button",{type:"submit",className:"send-button","aria-label":"Send message",disabled:!B,children:e.jsx(se,{size:17})})]})]})]})}function ge(s,n=s.length){const m=Math.max(0,Math.min(n,s.length)),a=/(?:^|\s)@([\w-]*)$/.exec(s.slice(0,m));return!a||a.index==null?null:{start:a.index+a[0].indexOf("@"),end:m,query:a[1]??""}}function xe(s,n){const m=new Set([...s.matchAll(/(?:^|\s)@([\w-]+)/g)].map(a=>a[1]?.toLowerCase()));return n.filter(a=>m.has(J(a).toLowerCase())).map(a=>a.userId)}function J(s){return s.handle??s.name?.replace(/[^\w-]/g,"")??s.userId}function F(s){for(const n of s)n.previewUrl&&URL.revokeObjectURL(n.previewUrl)}function be(s){const[n,m]=l.useState(!1),[a,y]=l.useState(s.message.body),c=s.message.refs.find(i=>i.refType==="message_reply"),u=c?s.messagesById.get(c.refId)??null:null,b=u?.authorUserId?s.membersById.get(u.authorUserId)??null:null;return e.jsxs("article",{className:`community-message${s.own?" own":""}`,id:`community-message-${s.message.id}`,children:[e.jsx("div",{className:"community-avatar",children:fe(s.author?.name??s.author?.handle??"?")}),e.jsxs("div",{className:"community-message-content",children:[e.jsxs("header",{children:[e.jsx("strong",{children:s.author?.name??s.author?.handle??"Community member"}),e.jsx("time",{dateTime:s.message.createdAt,children:je(s.message.createdAt)}),s.message.editedAt?e.jsx("span",{children:"edited"}):null,s.message.deletedAt?null:e.jsxs("div",{className:"community-message-actions",children:[e.jsx("button",{type:"button","aria-label":"Reply",onClick:()=>s.onReply(s.message),children:e.jsx(de,{size:13})}),s.own?e.jsx("button",{type:"button","aria-label":"Edit",onClick:()=>m(!0),children:e.jsx(ie,{size:13})}):null,s.own?e.jsx("button",{type:"button","aria-label":"Delete",onClick:()=>{s.onDelete(s.message.id)},children:e.jsx(ae,{size:13})}):null]})]}),c?e.jsxs("button",{type:"button",className:"community-reply-quote",onClick:()=>document.getElementById(`community-message-${c.refId}`)?.scrollIntoView({behavior:"smooth",block:"center"}),children:[e.jsx("strong",{children:b?.name??"Community member"}),e.jsx("span",{children:u?.deletedAt?"Message deleted":u?.body??String(c.preview.body??"Earlier message")})]}):null,n?e.jsxs("form",{className:"community-message-edit",onSubmit:i=>{i.preventDefault(),s.onEdit(s.message.id,a).then(f=>{f&&m(!1)})},children:[e.jsx("textarea",{autoFocus:!0,value:a,onChange:i=>y(i.currentTarget.value)}),e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>m(!1),children:"Cancel"}),e.jsx("button",{type:"submit",disabled:!a.trim(),children:"Save"})]})]}):s.message.deletedAt?e.jsx("div",{className:"community-message-deleted",children:"Message deleted"}):e.jsx(Y,{content:s.message.body}),!s.message.deletedAt&&s.message.attachments.length>0?e.jsx("div",{className:"community-message-attachments",children:s.message.attachments.map(i=>s.attachmentsAccessible?e.jsxs("button",{type:"button",onClick:()=>{s.onDownloadAttachment(i.id)},children:[e.jsx("span",{children:i.name}),e.jsx("small",{children:K(i.sizeBytes)})]},i.id):e.jsxs("div",{className:"community-attachment-placeholder",children:[e.jsx("span",{children:i.name}),e.jsxs("small",{children:["Join to view · ",K(i.sizeBytes)]})]},i.id))}):null]})]})}function fe(s){return s.split(/\s+/).slice(0,2).map(n=>n[0]?.toUpperCase()??"").join("")||"?"}function je(s){const n=new Date(s);return Number.isNaN(n.getTime())?"":n.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function K(s){return s<1024?`${s} B`:s<1024*1024?`${Math.round(s/1024)} KB`:`${(s/1024/1024).toFixed(1)} MB`}function pe(s){const[n,m]=l.useState(!1),a=l.useRef(null),y=l.useRef(s.onClose);l.useEffect(()=>m(!1),[s.rules.id]),l.useEffect(()=>{y.current=s.onClose},[s.onClose]),l.useEffect(()=>{const u=document.activeElement instanceof HTMLElement?document.activeElement:null,b=a.current,i=()=>[...b?.querySelectorAll('button:not([disabled]), input:not([disabled]), [href], [tabindex]:not([tabindex="-1"])')??[]];i()[0]?.focus();const f=h=>{if(h.key==="Escape"){h.preventDefault(),y.current();return}if(h.key!=="Tab")return;const p=i();if(p.length===0){h.preventDefault(),b?.focus();return}const C=p[0],N=p.at(-1);h.shiftKey&&document.activeElement===C?(h.preventDefault(),N.focus()):!h.shiftKey&&document.activeElement===N&&(h.preventDefault(),C.focus())};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),u?.focus()}},[]);const c=s.mode!=="review";return e.jsx("div",{className:"community-dialog-backdrop",role:"presentation",onMouseDown:s.onClose,children:e.jsxs("section",{ref:a,className:"community-rules-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"community-rules-title",tabIndex:-1,onMouseDown:u=>u.stopPropagation(),children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsxs("small",{children:["Community rules · version ",s.rules.version]}),e.jsx("h2",{id:"community-rules-title",children:s.rules.title})]}),e.jsx("button",{type:"button","aria-label":"Close rules",onClick:s.onClose,children:e.jsx(H,{size:16})})]}),e.jsx("div",{className:"community-rules-body",children:e.jsx(Y,{content:s.rules.bodyMarkdown})}),s.error?e.jsx("div",{className:"community-state error",role:"alert",children:s.error}):null,e.jsxs("footer",{children:[c?e.jsxs("label",{className:"community-rules-acceptance",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:u=>m(u.currentTarget.checked)}),e.jsx("span",{children:"I have read and agree to follow these rules."})]}):e.jsx("span",{}),e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"secondary",onClick:s.onClose,children:"Cancel"}),c?e.jsx("button",{type:"button",disabled:!n||s.busy,onClick:()=>{s.onAccept().then(u=>{u&&s.onClose()})},children:s.busy?"Saving…":s.mode==="join"?"Agree and join":"Accept updated rules"}):null]})]})]})})}function ke({communities:s,chat:n,currentUserId:m}){const[a,y]=l.useState(null),[c,u]=l.useState(null),b=l.useRef(null),i=s.preview,f=i?.membership?.status==="active",h=!!i?.capabilities.requiresRulesAcceptance,p=l.useMemo(()=>new Map(n.members.map(r=>[r.userId,r])),[n.members]),C=l.useMemo(()=>new Map(n.messages.map(r=>[r.id,r])),[n.messages]),N=n.messages.at(-1)?.sequence??0;if(l.useEffect(()=>{const r=b.current;r&&(r.scrollTop=r.scrollHeight)},[n.selectedChannelId,N]),l.useEffect(()=>{u(null),h&&i?.currentRules&&y("reaccept")},[i?.currentRules,h]),!s.selectedSummary)return e.jsx("section",{className:"community-empty-page",children:e.jsxs("div",{className:"community-discovery-card",children:[e.jsx(q,{size:30}),e.jsx("h1",{children:"Discover communities"}),e.jsx("p",{children:s.discoveryLoading&&s.items.length===0?"Finding communities…":"Preview public conversations and join after accepting each community's rules."}),s.discoveryError?e.jsx("div",{className:"community-state error",children:s.discoveryError}):null,s.items.length>0?e.jsx("div",{className:"community-discovery-list",children:s.items.map(r=>e.jsxs("button",{type:"button",onClick:()=>s.selectCommunity(r.id),children:[e.jsx(_,{name:r.displayName,imageUrl:r.imageUrl}),e.jsxs("span",{children:[e.jsx("strong",{children:r.displayName}),e.jsx("small",{children:r.description})]}),e.jsx("em",{children:r.membership?.status==="active"?"Joined":r.featuredAt?"Featured":`${r.memberCount.toLocaleString()} members`})]},r.id))}):s.discoveryLoading?null:e.jsx("div",{className:"community-state",children:"No public communities are available yet."}),e.jsxs("div",{className:"community-discovery-actions",children:[e.jsxs("button",{type:"button",onClick:()=>{s.refresh()},disabled:s.discoveryLoading,children:[e.jsx(O,{size:14})," Refresh"]}),s.nextCursor?e.jsx("button",{type:"button",className:"secondary",onClick:()=>{s.loadMore()},disabled:s.discoveryLoading,children:"Load more"}):null]})]})});if(!i&&s.previewLoading)return e.jsx("section",{className:"community-empty-page",children:e.jsxs("div",{className:"community-empty-card",children:[e.jsx("span",{className:"community-spinner"})," Loading community…"]})});if(!i)return e.jsx("section",{className:"community-empty-page",children:e.jsxs("div",{className:"community-empty-card",children:[e.jsx("h1",{children:s.selectedSummary.displayName}),e.jsx("div",{className:"community-state error",children:s.previewError??"This community preview is unavailable."}),e.jsxs("button",{type:"button",onClick:()=>s.selectCommunity(s.selectedSummary.id),children:[e.jsx(O,{size:14})," Retry preview"]})]})});const v=i.currentRules,M=s.membershipError?.message??null;return e.jsxs("section",{className:"community-view",children:[e.jsxs("header",{className:"community-header",children:[e.jsxs("div",{className:"community-heading",children:[e.jsx(_,{name:i.displayName,imageUrl:i.imageUrl}),e.jsxs("div",{children:[e.jsx("small",{children:i.displayName}),e.jsx("h1",{children:n.selectedChannel?`# ${n.selectedChannel.displayName}`:i.displayName}),e.jsx("p",{children:n.selectedChannel?.topic||i.description})]})]}),e.jsxs("div",{className:"community-header-actions",children:[e.jsxs("span",{className:"community-member-count",children:[e.jsx(q,{size:14})," ",i.memberCount.toLocaleString()]}),v?e.jsxs("button",{type:"button",className:"secondary",onClick:()=>y("review"),children:[e.jsx(re,{size:14})," Rules"]}):null,f?e.jsx(ve,{mode:i.membership?.notificationMode??"mentions",busy:s.membershipBusy,onMode:s.updateNotifications,onLeave:s.leave}):null]})]}),e.jsxs("div",{className:"community-chat-main conversation-surface-main",children:[e.jsxs("div",{className:"community-chat-notices",children:[f?h?e.jsxs("div",{className:"community-preview-banner warning",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"The rules have changed"}),e.jsx("span",{children:"Accept the current rules to continue reading live updates and posting."})]}),e.jsx("button",{type:"button",disabled:!v||s.membershipBusy,onClick:()=>y("reaccept"),children:"Review updated rules"})]}):null:e.jsxs("div",{className:"community-preview-banner",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:["Previewing ",i.displayName]}),e.jsx("span",{children:"Read the public conversation, then accept the rules to join and post."})]}),e.jsx("button",{type:"button",disabled:!v||s.membershipBusy,onClick:()=>y("join"),children:"Join community"})]}),n.realtimeError&&f&&!h?e.jsxs("div",{className:"community-realtime-state",children:[e.jsx(oe,{size:14}),e.jsx("span",{children:"Live updates are reconnecting. Loaded messages are still available."})]}):null,n.lostMembership?e.jsx("div",{className:"community-state error",children:"Your membership changed. Refresh the community before continuing."}):null,n.channelsError?e.jsxs("div",{className:"community-state error",children:["Channels: ",n.channelsError," ",e.jsx("button",{type:"button",onClick:()=>{n.loadChannels()},children:"Retry"})]}):null,M?e.jsx("div",{className:"community-state error",role:"alert",children:M}):null]}),e.jsxs("div",{className:"community-message-pane conversation-message-scroll",ref:b,role:"log","aria-live":"polite","aria-relevant":"additions text","aria-busy":n.messagesLoading,"aria-label":n.selectedChannel?`${i.displayName}, ${n.selectedChannel.displayName}`:i.displayName,tabIndex:0,children:[n.hasMoreBefore?e.jsx("button",{type:"button",className:"community-load-older",disabled:n.olderMessagesLoading,onClick:()=>{n.loadOlder()},children:n.olderMessagesLoading?"Loading…":"Load earlier messages"}):null,n.messagesLoading&&n.messages.length===0?e.jsx("div",{className:"community-message-state",children:"Loading messages…"}):null,n.messagesError?e.jsxs("div",{className:"community-message-state error",children:["Could not load messages: ",n.messagesError," ",e.jsx("button",{type:"button",onClick:()=>{n.loadMessages()},children:"Retry"})]}):null,!n.messagesLoading&&!n.messagesError&&n.messages.length===0?e.jsx("div",{className:"community-message-state",children:"No messages in this channel yet."}):null,n.messages.map(r=>e.jsx(be,{message:r,author:r.authorUserId?p.get(r.authorUserId)??null:null,own:r.authorUserId===m,attachmentsAccessible:!n.previewMode,membersById:p,messagesById:C,onReply:u,onEdit:n.editMessage,onDelete:n.deleteMessage,onDownloadAttachment:n.downloadAttachment},r.id))]}),f?e.jsxs("div",{className:"community-composer-wrap conversation-composer-shell",children:[n.actionError?e.jsx("div",{className:"community-composer-action-error",children:n.actionError}):null,n.failedSend?e.jsxs("div",{className:"community-failed-send",children:[e.jsxs("span",{children:["Message not sent. ",n.failedSend.message]}),e.jsx("button",{type:"button",disabled:n.sending,onClick:()=>{n.retrySend()},children:"Retry"}),e.jsx("button",{type:"button",onClick:n.dismissFailedSend,children:"Dismiss"})]}):null,e.jsx(ye,{members:n.members,replyTo:c,busy:n.sending,disabled:h||n.lostMembership||!n.selectedChannel||n.selectedChannel.postingPolicy==="admins"&&i.membership?.role==="member",onCancelReply:()=>u(null),onSearchMembers:n.searchMembers,onSend:n.sendMessage})]}):null]}),a&&v?e.jsx(pe,{rules:v,mode:a,busy:s.membershipBusy,error:M,onAccept:a==="join"?s.join:s.acceptRules,onClose:()=>y(null)}):null]})}function ve(s){const[n,m]=l.useState(!1);return e.jsxs("div",{className:"community-membership-menu",children:[e.jsxs("button",{type:"button",className:"secondary","aria-expanded":n,onClick:()=>m(a=>!a),children:[s.mode==="none"?e.jsx(le,{size:14}):e.jsx(ce,{size:14})," Joined"]}),n?e.jsxs("div",{className:"community-membership-popover",children:[e.jsx("strong",{children:"Notifications"}),["mentions","all","none"].map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"radio",name:"community-notifications",checked:s.mode===a,disabled:s.busy,onChange:()=>{s.onMode(a)}})," ",a==="mentions"?"Mentions":a==="all"?"All messages":"Nothing"]},a)),e.jsx("button",{type:"button",className:"danger",disabled:s.busy,onClick:()=>{window.confirm("Leave this community? You can join again later by accepting the current rules.")&&s.onLeave().then(a=>{a&&m(!1)})},children:"Leave community"})]}):null]})}function _({name:s,imageUrl:n}){return n?e.jsx("img",{className:"community-icon",src:n,alt:""}):e.jsx("span",{className:"community-icon fallback",children:s.slice(0,2).toUpperCase()})}export{ke as CommunityView};
@@ -1 +1 @@
1
- import{d as _,r as j,j as e,t as P,N as w,ay as x,X as v,K as y,w as q,aF as N}from"./index-D7Vr3zcV.js";import{P as C}from"./play-BJdhBqQE.js";import{R as k}from"./refresh-cw-DE0u_nmZ.js";const A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],z=_("circle-question-mark",A);function D({runtime:s}){const[a,o]=j.useState(!1),[i,u]=j.useState(""),[t,p]=j.useState(null),n=s.run,g=n.plan,h=B(n),c={run:n},f=E(n.state),r=$(n),R=r?.git?.pullRequest??n.releaseOutcome.pullRequest;j.useEffect(()=>{o(!1),u(""),p(null)},[n.id,n.revision,n.state,g?.id,h?.id]);async function l(d,b){if(!(!b||t)){p(d);try{await b()}finally{p(null)}}}return e.jsxs("section",{className:`composer-create-strip ${f}`,"aria-label":"Create or improve status",children:[e.jsxs("div",{className:"composer-create-strip-heading",children:[f==="danger"?e.jsx(P,{size:15}):n.state==="awaiting_questions"?e.jsx(z,{size:15}):S(n.state)?e.jsx(w,{className:"composer-create-spin",size:15}):e.jsx(x,{size:15}),e.jsx("span",{children:I(n)}),e.jsx("small",{children:n.target.kind})]}),n.state==="awaiting_questions"&&h?e.jsxs("div",{className:"composer-create-question",children:[e.jsx("p",{children:h.prompt}),e.jsx("div",{className:"composer-create-options",children:h.options.map(d=>e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l(`answer:${d.id}`,()=>s.onAnswerQuestion?s.onAnswerQuestion(c,h.id,d.value):Promise.resolve())},children:[e.jsx("span",{children:t===`answer:${d.id}`?"Saving":d.label}),d.description?e.jsx("small",{children:d.description}):null]},d.id))})]}):n.state==="awaiting_plan_approval"&&g?e.jsxs("div",{className:"composer-create-plan-summary",children:[e.jsx("p",{children:g.summary}),e.jsx(m,{run:n}),a?e.jsxs("div",{className:"composer-create-revision",children:[e.jsx("textarea",{rows:2,value:i,placeholder:"Describe the plan revision",onChange:d=>u(d.currentTarget.value)}),e.jsxs("div",{children:[e.jsxs("button",{type:"button",disabled:!i.trim()||!!t,onClick:()=>{l("revise",()=>s.onRevise?s.onRevise(c,i):Promise.resolve())},children:[e.jsx(x,{size:13}),e.jsx("span",{children:t==="revise"?"Saving":"Save revision"})]}),e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>o(!1),children:[e.jsx(v,{size:13}),e.jsx("span",{children:"Close"})]})]})]}):e.jsxs("div",{className:"composer-create-actions",children:[e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("approve",()=>s.onApprove?s.onApprove(c):Promise.resolve())},children:[e.jsx(y,{size:13}),e.jsx("span",{children:t==="approve"?"Confirming":"Confirm plan"})]}),e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>o(!0),children:[e.jsx(x,{size:13}),e.jsx("span",{children:"Edit plan"})]}),e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("cancel",()=>s.onCancel?s.onCancel(c):Promise.resolve())},children:[e.jsx(v,{size:13}),e.jsx("span",{children:t==="cancel"?"Cancelling":"Cancel"})]})]})]}):n.state==="paused"?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:"This work is paused. Resume it when you are ready to continue."}),e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("resume",()=>s.onResume?s.onResume(c):Promise.resolve())},children:[e.jsx(C,{size:13}),e.jsx("span",{children:t==="resume"?"Resuming":"Resume"})]})]}):n.state==="awaiting_promotion"&&r?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:F(n,r.id)}),e.jsxs("div",{className:"composer-create-actions",children:[e.jsxs("button",{type:"button",disabled:!!t||!M(n,r.id),onClick:()=>{l("apply-candidate",()=>s.onApplyCandidate?s.onApplyCandidate(c,r.id):Promise.resolve())},children:[e.jsx(y,{size:13}),e.jsx("span",{children:t==="apply-candidate"?"Merging":"Merge change"})]}),e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("reject-candidate",()=>s.onRejectCandidate?s.onRejectCandidate(c,r.id):Promise.resolve())},children:[e.jsx(v,{size:13}),e.jsx("span",{children:t==="reject-candidate"?"Rejecting":"Reject"})]})]})]}):n.state==="pull_request_open"&&r&&R?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:"An external review is open. Merge or close it, then refresh its status."}),e.jsxs("div",{className:"composer-create-actions",children:[e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("reconcile-pr",()=>s.onReconcilePullRequest?s.onReconcilePullRequest(c,r.id):Promise.resolve())},children:[e.jsx(k,{size:13}),e.jsx("span",{children:t==="reconcile-pr"?"Checking":"Refresh review"})]}),e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("reject-candidate",()=>s.onRejectCandidate?s.onRejectCandidate(c,r.id):Promise.resolve())},children:[e.jsx(v,{size:13}),e.jsx("span",{children:t==="reject-candidate"?"Closing":"Close review"})]})]})]}):n.state==="blocked"||n.state==="failed"||n.state==="cancelled"?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:n.blockedReason??"This work stopped before it was ready."}),n.state==="blocked"&&r?.git?.worktreePath&&["draft","checking"].includes(r.status)?e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("resume",()=>s.onResume?s.onResume(c):Promise.resolve())},children:[e.jsx(C,{size:13}),e.jsx("span",{children:t==="resume"?"Continuing":"Continue candidate"})]}):n.state==="blocked"&&r?.git?.pullRequest?.state==="merged"?e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("reconcile-pr",()=>s.onReconcilePullRequest?s.onReconcilePullRequest(c,r.id):Promise.resolve())},children:[e.jsx(k,{size:13}),e.jsx("span",{children:t==="reconcile-pr"?"Checking":"Re-run verification"})]}):null]}):n.state==="released"||n.state==="rejected"||n.state==="ready_local"||n.state==="ready"||n.state==="published_hosted"?e.jsxs("div",{className:"composer-create-status-body composer-create-status-body-reveals",children:[e.jsx("p",{children:n.state==="released"?"The Agent change merged and the active Profile passed its post-merge Evals.":n.state==="rejected"?"The Agent candidate was rejected.":n.state==="published_hosted"?"Published to the hosted Profile.":"The workproduct is ready."}),e.jsx("div",{className:"composer-create-hover-details",children:e.jsx(m,{run:n})})]}):e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:T(n.state)}),e.jsx(m,{run:n}),n.executionPolicy.pauseAllowed&&s.onPause?e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("pause",()=>s.onPause?.(c)??Promise.resolve())},children:[e.jsx(q,{size:13}),e.jsx("span",{children:t==="pause"?"Pausing":"Pause"})]}):null]})]})}function B(s){return s.questions.find(a=>a.status==="pending"&&a.required)??s.questions.find(a=>a.status==="pending")??null}function m({run:s}){const a=s.plan,o=s.sourceRefs[0]??a?.sourcePlan[0]?.path??null,i=s.checkRefs.length||a?.checks.length||0,u=a?.requirements.length??0,t=[...s.sourceRefs,...s.checkRefs].slice(0,4),p=N(a?.metadata);return!o&&i===0&&u===0&&t.length===0&&!p?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"composer-create-facts",children:[p?e.jsx("span",{title:p.detail,children:p.label}):null,o?e.jsx("span",{title:o,children:o}):null,i?e.jsx("span",{children:s.checkRefs.length?`${s.checkRefs.length} check refs`:`${i} checks`}):null,u?e.jsxs("span",{children:[u," setup rows"]}):null]}),t.length?e.jsx("ul",{className:"composer-create-refs","aria-label":"Source and check refs",children:t.map(n=>e.jsx("li",{children:e.jsx("code",{title:n,children:n})},n))}):null]})}function I(s){return s.state==="awaiting_questions"?"Question":s.state==="awaiting_plan_approval"?"Plan":s.state==="applying_source"?"Applying source":s.state==="running_checks"?"Running checks":s.state==="evaluating"?"Evaluating":s.state==="awaiting_promotion"?"Candidate ready":s.state==="opening_pull_request"?"Opening review":s.state==="pull_request_open"?"Review open":s.state==="reconciling_release"?"Merging change":s.state==="released"?"Released":s.state==="rejected"?"Rejected":s.state==="paused"?"Paused":s.state==="ready"||s.state==="ready_local"?"Ready":s.state==="published_hosted"?"Published":s.state==="cancelled"?"Cancelled":s.state==="blocked"?"Blocked":s.state==="failed"?"Failed":s.operation==="improve"?"Improve":"Create"}function T(s){return s==="applying_source"?"Applying the approved source changes.":s==="running_checks"?"Running checks against the candidate.":s==="evaluating"?"Evaluating the candidate against its Evals.":s==="opening_pull_request"?"Opening the candidate review.":s==="reconciling_release"?"Applying the change and verifying the active Profile.":s==="pushing_hosted"?"Pushing the Profile source.":s==="running_hosted_checks"?"Running hosted checks.":"Preparing the work."}function E(s){return["released","ready","ready_local","published_hosted"].includes(s)?"success":["rejected","blocked","failed","cancelled"].includes(s)?"danger":["awaiting_questions","awaiting_plan_approval","awaiting_promotion","pull_request_open","paused"].includes(s)?"warning":"info"}function S(s){return["planning","applying_source","running_checks","evaluating","opening_pull_request","reconciling_release","pushing_hosted","running_hosted_checks"].includes(s)}function $(s){return[...s.candidates].reverse().find(a=>a.target.kind==="agent")??null}function M(s,a){const o=s.evaluationReceipts.filter(i=>i.candidateId===a&&i.subject==="candidate");return o.length>0&&o.every(i=>i.status==="passed"&&i.publishGate!=="failed")}function F(s,a){const o=s.evaluationReceipts.find(t=>t.candidateId===a&&t.subject==="active"),i=s.evaluationReceipts.find(t=>t.candidateId===a&&t.subject==="candidate"),u=t=>t?.summaryCounts?`${t.summaryCounts.passed}/${t.summaryCounts.total}`:t?.status??"not run";return`Base Evals: ${u(o)} passed. Candidate Evals: ${u(i)} passed.`}export{D as ComposerCreateImproveStrip};
1
+ import{d as _,r as j,j as e,t as P,N as w,ay as x,X as v,K as y,w as q,aF as N}from"./index-CKmte5ok.js";import{P as C}from"./play-DLCuESeG.js";import{R as k}from"./refresh-cw-JNUovwk4.js";const A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],z=_("circle-question-mark",A);function D({runtime:s}){const[a,o]=j.useState(!1),[i,u]=j.useState(""),[t,p]=j.useState(null),n=s.run,g=n.plan,h=B(n),c={run:n},f=E(n.state),r=$(n),R=r?.git?.pullRequest??n.releaseOutcome.pullRequest;j.useEffect(()=>{o(!1),u(""),p(null)},[n.id,n.revision,n.state,g?.id,h?.id]);async function l(d,b){if(!(!b||t)){p(d);try{await b()}finally{p(null)}}}return e.jsxs("section",{className:`composer-create-strip ${f}`,"aria-label":"Create or improve status",children:[e.jsxs("div",{className:"composer-create-strip-heading",children:[f==="danger"?e.jsx(P,{size:15}):n.state==="awaiting_questions"?e.jsx(z,{size:15}):S(n.state)?e.jsx(w,{className:"composer-create-spin",size:15}):e.jsx(x,{size:15}),e.jsx("span",{children:I(n)}),e.jsx("small",{children:n.target.kind})]}),n.state==="awaiting_questions"&&h?e.jsxs("div",{className:"composer-create-question",children:[e.jsx("p",{children:h.prompt}),e.jsx("div",{className:"composer-create-options",children:h.options.map(d=>e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l(`answer:${d.id}`,()=>s.onAnswerQuestion?s.onAnswerQuestion(c,h.id,d.value):Promise.resolve())},children:[e.jsx("span",{children:t===`answer:${d.id}`?"Saving":d.label}),d.description?e.jsx("small",{children:d.description}):null]},d.id))})]}):n.state==="awaiting_plan_approval"&&g?e.jsxs("div",{className:"composer-create-plan-summary",children:[e.jsx("p",{children:g.summary}),e.jsx(m,{run:n}),a?e.jsxs("div",{className:"composer-create-revision",children:[e.jsx("textarea",{rows:2,value:i,placeholder:"Describe the plan revision",onChange:d=>u(d.currentTarget.value)}),e.jsxs("div",{children:[e.jsxs("button",{type:"button",disabled:!i.trim()||!!t,onClick:()=>{l("revise",()=>s.onRevise?s.onRevise(c,i):Promise.resolve())},children:[e.jsx(x,{size:13}),e.jsx("span",{children:t==="revise"?"Saving":"Save revision"})]}),e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>o(!1),children:[e.jsx(v,{size:13}),e.jsx("span",{children:"Close"})]})]})]}):e.jsxs("div",{className:"composer-create-actions",children:[e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("approve",()=>s.onApprove?s.onApprove(c):Promise.resolve())},children:[e.jsx(y,{size:13}),e.jsx("span",{children:t==="approve"?"Confirming":"Confirm plan"})]}),e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>o(!0),children:[e.jsx(x,{size:13}),e.jsx("span",{children:"Edit plan"})]}),e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("cancel",()=>s.onCancel?s.onCancel(c):Promise.resolve())},children:[e.jsx(v,{size:13}),e.jsx("span",{children:t==="cancel"?"Cancelling":"Cancel"})]})]})]}):n.state==="paused"?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:"This work is paused. Resume it when you are ready to continue."}),e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("resume",()=>s.onResume?s.onResume(c):Promise.resolve())},children:[e.jsx(C,{size:13}),e.jsx("span",{children:t==="resume"?"Resuming":"Resume"})]})]}):n.state==="awaiting_promotion"&&r?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:F(n,r.id)}),e.jsxs("div",{className:"composer-create-actions",children:[e.jsxs("button",{type:"button",disabled:!!t||!M(n,r.id),onClick:()=>{l("apply-candidate",()=>s.onApplyCandidate?s.onApplyCandidate(c,r.id):Promise.resolve())},children:[e.jsx(y,{size:13}),e.jsx("span",{children:t==="apply-candidate"?"Merging":"Merge change"})]}),e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("reject-candidate",()=>s.onRejectCandidate?s.onRejectCandidate(c,r.id):Promise.resolve())},children:[e.jsx(v,{size:13}),e.jsx("span",{children:t==="reject-candidate"?"Rejecting":"Reject"})]})]})]}):n.state==="pull_request_open"&&r&&R?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:"An external review is open. Merge or close it, then refresh its status."}),e.jsxs("div",{className:"composer-create-actions",children:[e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("reconcile-pr",()=>s.onReconcilePullRequest?s.onReconcilePullRequest(c,r.id):Promise.resolve())},children:[e.jsx(k,{size:13}),e.jsx("span",{children:t==="reconcile-pr"?"Checking":"Refresh review"})]}),e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("reject-candidate",()=>s.onRejectCandidate?s.onRejectCandidate(c,r.id):Promise.resolve())},children:[e.jsx(v,{size:13}),e.jsx("span",{children:t==="reject-candidate"?"Closing":"Close review"})]})]})]}):n.state==="blocked"||n.state==="failed"||n.state==="cancelled"?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:n.blockedReason??"This work stopped before it was ready."}),n.state==="blocked"&&r?.git?.worktreePath&&["draft","checking"].includes(r.status)?e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("resume",()=>s.onResume?s.onResume(c):Promise.resolve())},children:[e.jsx(C,{size:13}),e.jsx("span",{children:t==="resume"?"Continuing":"Continue candidate"})]}):n.state==="blocked"&&r?.git?.pullRequest?.state==="merged"?e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("reconcile-pr",()=>s.onReconcilePullRequest?s.onReconcilePullRequest(c,r.id):Promise.resolve())},children:[e.jsx(k,{size:13}),e.jsx("span",{children:t==="reconcile-pr"?"Checking":"Re-run verification"})]}):null]}):n.state==="released"||n.state==="rejected"||n.state==="ready_local"||n.state==="ready"||n.state==="published_hosted"?e.jsxs("div",{className:"composer-create-status-body composer-create-status-body-reveals",children:[e.jsx("p",{children:n.state==="released"?"The Agent change merged and the active Profile passed its post-merge Evals.":n.state==="rejected"?"The Agent candidate was rejected.":n.state==="published_hosted"?"Published to the hosted Profile.":"The workproduct is ready."}),e.jsx("div",{className:"composer-create-hover-details",children:e.jsx(m,{run:n})})]}):e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:T(n.state)}),e.jsx(m,{run:n}),n.executionPolicy.pauseAllowed&&s.onPause?e.jsxs("button",{type:"button",disabled:!!t,onClick:()=>{l("pause",()=>s.onPause?.(c)??Promise.resolve())},children:[e.jsx(q,{size:13}),e.jsx("span",{children:t==="pause"?"Pausing":"Pause"})]}):null]})]})}function B(s){return s.questions.find(a=>a.status==="pending"&&a.required)??s.questions.find(a=>a.status==="pending")??null}function m({run:s}){const a=s.plan,o=s.sourceRefs[0]??a?.sourcePlan[0]?.path??null,i=s.checkRefs.length||a?.checks.length||0,u=a?.requirements.length??0,t=[...s.sourceRefs,...s.checkRefs].slice(0,4),p=N(a?.metadata);return!o&&i===0&&u===0&&t.length===0&&!p?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"composer-create-facts",children:[p?e.jsx("span",{title:p.detail,children:p.label}):null,o?e.jsx("span",{title:o,children:o}):null,i?e.jsx("span",{children:s.checkRefs.length?`${s.checkRefs.length} check refs`:`${i} checks`}):null,u?e.jsxs("span",{children:[u," setup rows"]}):null]}),t.length?e.jsx("ul",{className:"composer-create-refs","aria-label":"Source and check refs",children:t.map(n=>e.jsx("li",{children:e.jsx("code",{title:n,children:n})},n))}):null]})}function I(s){return s.state==="awaiting_questions"?"Question":s.state==="awaiting_plan_approval"?"Plan":s.state==="applying_source"?"Applying source":s.state==="running_checks"?"Running checks":s.state==="evaluating"?"Evaluating":s.state==="awaiting_promotion"?"Candidate ready":s.state==="opening_pull_request"?"Opening review":s.state==="pull_request_open"?"Review open":s.state==="reconciling_release"?"Merging change":s.state==="released"?"Released":s.state==="rejected"?"Rejected":s.state==="paused"?"Paused":s.state==="ready"||s.state==="ready_local"?"Ready":s.state==="published_hosted"?"Published":s.state==="cancelled"?"Cancelled":s.state==="blocked"?"Blocked":s.state==="failed"?"Failed":s.operation==="improve"?"Improve":"Create"}function T(s){return s==="applying_source"?"Applying the approved source changes.":s==="running_checks"?"Running checks against the candidate.":s==="evaluating"?"Evaluating the candidate against its Evals.":s==="opening_pull_request"?"Opening the candidate review.":s==="reconciling_release"?"Applying the change and verifying the active Profile.":s==="pushing_hosted"?"Pushing the Profile source.":s==="running_hosted_checks"?"Running hosted checks.":"Preparing the work."}function E(s){return["released","ready","ready_local","published_hosted"].includes(s)?"success":["rejected","blocked","failed","cancelled"].includes(s)?"danger":["awaiting_questions","awaiting_plan_approval","awaiting_promotion","pull_request_open","paused"].includes(s)?"warning":"info"}function S(s){return["planning","applying_source","running_checks","evaluating","opening_pull_request","reconciling_release","pushing_hosted","running_hosted_checks"].includes(s)}function $(s){return[...s.candidates].reverse().find(a=>a.target.kind==="agent")??null}function M(s,a){const o=s.evaluationReceipts.filter(i=>i.candidateId===a&&i.subject==="candidate");return o.length>0&&o.every(i=>i.status==="passed"&&i.publishGate!=="failed")}function F(s,a){const o=s.evaluationReceipts.find(t=>t.candidateId===a&&t.subject==="active"),i=s.evaluationReceipts.find(t=>t.candidateId===a&&t.subject==="candidate"),u=t=>t?.summaryCounts?`${t.summaryCounts.passed}/${t.summaryCounts.total}`:t?.status??"not run";return`Base Evals: ${u(o)} passed. Candidate Evals: ${u(i)} passed.`}export{D as ComposerCreateImproveStrip};