@openchamber/web 1.21.1 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-BGj8TJxW.js → CodeMirrorCommentWidgets-CPvfxh0N.js} +1 -1
  2. package/dist/assets/{CommitSection-DwGiXyjf.js → CommitSection-CC5mFzO2.js} +1 -1
  3. package/dist/assets/DiffView-6xGdyI0n.js +4 -0
  4. package/dist/assets/FilesView-Bm3vT63N.js +17 -0
  5. package/dist/assets/GitView-B6y1Y69c.js +6 -0
  6. package/dist/assets/{JsonTreeView-CggOsLot.js → JsonTreeView-rwHz84MX.js} +1 -1
  7. package/dist/assets/LinearIssuesView-B0UM_Rkx.js +1 -0
  8. package/dist/assets/MarkdownImageGallery-sGilV9Hs.js +1 -0
  9. package/dist/assets/MarkdownRendererImpl--4sRsKBn.js +12 -0
  10. package/dist/assets/OnboardingScreen-CECL_Cms.js +1 -0
  11. package/dist/assets/{PatchDiff-DJYMUiXA.js → PatchDiff-BGPl1s-U.js} +1 -1
  12. package/dist/assets/{PierreDiffViewer-CY2bx_SB.js → PierreDiffViewer-Cvz9Z-io.js} +3 -3
  13. package/dist/assets/{PlanView-PkiOY_9H.js → PlanView-BFMsnHk3.js} +4 -4
  14. package/dist/assets/SettingsView-_Gtn5SdT.js +28 -0
  15. package/dist/assets/{SettingsWindow-oyOm2fHR.js → SettingsWindow-C1Qa09YO.js} +1 -1
  16. package/dist/assets/{ToolOutputDialog-lKyeQTPL.js → ToolOutputDialog-DzQlzMF4.js} +5 -5
  17. package/dist/assets/{ToolPartDiffPreview-C7kBQNAA.js → ToolPartDiffPreview-DfVOfwHy.js} +2 -2
  18. package/dist/assets/{VirtualizedFileDiff-BP7ebDFF.js → VirtualizedFileDiff-DT5MDv-u.js} +1 -1
  19. package/dist/assets/WalkthroughView-D8sLH_M8.js +4 -0
  20. package/dist/assets/{computeVirtualFileMetrics-CZ0xPeaT.js → computeVirtualFileMetrics-DmpLWhll.js} +1 -1
  21. package/dist/assets/{contextPanelEmbeddedChat-C9abMBTb.js → contextPanelEmbeddedChat-BK78t3M_.js} +1 -1
  22. package/dist/assets/{de-CEoCz3j6.js → de-C3luvSd_.js} +4 -4
  23. package/dist/assets/{es-DwyXCqaL.js → es-CmU4HLv9.js} +3 -3
  24. package/dist/assets/{fr-CS7Csln9.js → fr-Bgyni40l.js} +4 -4
  25. package/dist/assets/index-C57jT0Sa.css +1 -0
  26. package/dist/assets/{index-CaPAjwXQ.js → index-CWYs7sMK.js} +1 -1
  27. package/dist/assets/index-b0zDkWyg.js +7 -0
  28. package/dist/assets/{isDiffPlainText-ZBvDxhVB.js → isDiffPlainText-BO_q5ezD.js} +1 -1
  29. package/dist/assets/{isFilePlainText-DiLRrkJr.js → isFilePlainText-D8qPqUAf.js} +1 -1
  30. package/dist/assets/{ja-vnwqLcx6.js → ja-C1ImKinT.js} +4 -4
  31. package/dist/assets/{ko-CXuSfZv5.js → ko-CP7OdxYH.js} +4 -4
  32. package/dist/assets/main-D4rd8Hy5.js +928 -0
  33. package/dist/assets/{main-D5RWr6sJ.js → main-D7fwjW2z.js} +2 -2
  34. package/dist/assets/markdownCore-BcmkWZPO.js +3 -0
  35. package/dist/assets/{miniChat-CqR3icsk.js → miniChat-D5rraz-g.js} +2 -2
  36. package/dist/assets/{mobile-RN_UTTlB.js → mobile-Cg_DE3KL.js} +2 -2
  37. package/dist/assets/{patchFileDiff-CjRR5ESs.js → patchFileDiff-Bpql0QGw.js} +3 -3
  38. package/dist/assets/{pl-BJxry0Mi.js → pl-DQYSiGYX.js} +4 -4
  39. package/dist/assets/{pt-BR-DxLmkhdv.js → pt-BR-DytpsW4M.js} +3 -3
  40. package/dist/assets/{renderElectronMiniChatApp-1wC94fQK.js → renderElectronMiniChatApp-B_Bn7BbN.js} +2 -2
  41. package/dist/assets/renderMobileApp-DLfxMzGJ.js +25 -0
  42. package/dist/assets/runtimeEndpointReset-HlRmXFGW.js +16 -0
  43. package/dist/assets/scheduledTasksApi-BPvxrynl.js +1 -0
  44. package/dist/assets/{shikiHighlight-fGmFkxAM.js → shikiHighlight-CFAVs_lu.js} +1 -1
  45. package/dist/assets/tr-aizaUvft.js +6 -0
  46. package/dist/assets/{uk-ClgQjmlw.js → uk-DwnRxJZd.js} +3 -3
  47. package/dist/assets/{useAppFontEffects-KP8_yiGW.js → useAppFontEffects-DWXGRUPZ.js} +191 -151
  48. package/dist/assets/useInlineCommentController-Cc0OCXr0.js +2 -0
  49. package/dist/assets/useRootScrollLock-BFZtfciC.js +1 -0
  50. package/dist/assets/{vendor-codemirror-language-data-DrTPkHl4.js → vendor-codemirror-language-data-BGFszm8n.js} +2 -2
  51. package/dist/assets/{web-components-DOXvU-tB.js → web-components-CD-GFayc.js} +4 -4
  52. package/dist/assets/{zh-CN-Ba6y8H-i.js → zh-CN-UDNMxm7r.js} +3 -3
  53. package/dist/assets/zh-TW-BsswdYL-.js +15 -0
  54. package/dist/index.html +4 -4
  55. package/dist/mini-chat.html +3 -3
  56. package/dist/mobile.html +3 -3
  57. package/package.json +1 -1
  58. package/server/index.js +4 -0
  59. package/server/lib/dictation/DOCUMENTATION.md +19 -6
  60. package/server/lib/dictation/local/model-catalog.js +220 -0
  61. package/server/lib/dictation/local/model-catalog.test.js +42 -0
  62. package/server/lib/dictation/local/sherpa-tts.js +41 -20
  63. package/server/lib/dictation/local/worker-process.js +2 -0
  64. package/server/lib/dictation/runtime.js +4 -0
  65. package/server/lib/dictation/service.js +27 -4
  66. package/server/lib/fs/DOCUMENTATION.md +4 -0
  67. package/server/lib/fs/routes.js +129 -0
  68. package/server/lib/fs/routes.test.js +219 -0
  69. package/server/lib/linear/DOCUMENTATION.md +97 -0
  70. package/server/lib/linear/OAUTH-BROKER-HANDOFF.md +91 -0
  71. package/server/lib/linear/auth.js +436 -0
  72. package/server/lib/linear/auth.test.js +242 -0
  73. package/server/lib/linear/client.js +191 -0
  74. package/server/lib/linear/index.js +61 -0
  75. package/server/lib/linear/issues.js +499 -0
  76. package/server/lib/linear/issues.test.js +512 -0
  77. package/server/lib/linear/mapping.js +188 -0
  78. package/server/lib/linear/mapping.test.js +147 -0
  79. package/server/lib/linear/oauth.js +345 -0
  80. package/server/lib/linear/oauth.test.js +166 -0
  81. package/server/lib/linear/parse.js +23 -0
  82. package/server/lib/linear/routes.js +432 -0
  83. package/server/lib/linear/routes.test.js +661 -0
  84. package/server/lib/linear/status-runtime.js +64 -0
  85. package/server/lib/linear/status-runtime.test.js +167 -0
  86. package/server/lib/linear/status.js +280 -0
  87. package/server/lib/linear/status.test.js +271 -0
  88. package/server/lib/linear/teams.js +72 -0
  89. package/server/lib/linear/teams.test.js +94 -0
  90. package/server/lib/opencode/feature-routes-runtime.js +2 -0
  91. package/server/lib/opencode/static-routes-runtime.js +3 -3
  92. package/server/lib/projects/project-config.js +33 -5
  93. package/server/lib/projects/project-config.test.js +85 -0
  94. package/server/lib/scheduled-tasks/DOCUMENTATION.md +7 -0
  95. package/server/lib/tts/DOCUMENTATION.md +1 -0
  96. package/server/lib/tts/language-detect.js +210 -0
  97. package/server/lib/tts/language-detect.test.js +76 -0
  98. package/server/lib/tts/routes.js +23 -1
  99. package/server/lib/tts/routes.test.js +26 -0
  100. package/dist/assets/DiffView-Db6bjVv1.js +0 -4
  101. package/dist/assets/FilesView-DQOa7Lgz.js +0 -17
  102. package/dist/assets/GitView-CHzJxTi0.js +0 -6
  103. package/dist/assets/MarkdownImageGallery-DoZpaHev.js +0 -1
  104. package/dist/assets/MarkdownRendererImpl-B5Y5xCOz.js +0 -12
  105. package/dist/assets/OnboardingScreen-C98d69Fp.js +0 -1
  106. package/dist/assets/SettingsView-D-K3ELCM.js +0 -28
  107. package/dist/assets/WalkthroughView-MuJodAHD.js +0 -4
  108. package/dist/assets/index-CUKcHnUA.css +0 -1
  109. package/dist/assets/index-DIvDEKE-.js +0 -7
  110. package/dist/assets/main-DLlfDjQ_.js +0 -926
  111. package/dist/assets/markdownCore-CcTcLsQF.js +0 -3
  112. package/dist/assets/renderMobileApp-ltva2Plg.js +0 -25
  113. package/dist/assets/runtimeEndpointReset-D6SmNZaP.js +0 -15
  114. package/dist/assets/scheduledTasksApi-mjMDet_H.js +0 -1
  115. package/dist/assets/tr-5Mk_hQ2Q.js +0 -6
  116. package/dist/assets/useInlineCommentController-HIjtuhxD.js +0 -2
  117. package/dist/assets/useRootScrollLock-BSiQ5F75.js +0 -1
  118. package/dist/assets/zh-TW-Dv8yyhN1.js +0 -15
@@ -1,5 +1,5 @@
1
- import{R as t,j as n}from"./vendor-react-BUCujlKS.js";import{m as xt,u as Ze,a as he,o as qe,r as Xe,v as jt}from"./index-DIvDEKE-.js";import{c as Ct,s as Rt,P as Pt,C as Mt}from"./shikiHighlight-fGmFkxAM.js";import{f as Tt,y as Y,c8 as kt,at as Nt,b as et,af as Et,ab as It,V as Dt,bo as Vt,L as Ft,eZ as Lt,Y as $t,gP as At,l as tt,eY as Ot,al as nt,g2 as Kt,eW as Wt,cS as rt,e$ as zt,f0 as _t,m as Bt,gQ as Gt,b2 as st,a6 as ge,a7 as we,a$ as it,B as ne,I as W,a8 as ve,b1 as ot,a_ as re,g as Jt,c0 as Ut,an as Yt,bY as Ht,gR as Qt}from"./useAppFontEffects-KP8_yiGW.js";import{u as Zt,n as qt}from"./useInlineCommentController-HIjtuhxD.js";import{b as Xt}from"./CodeMirrorCommentWidgets-BGj8TJxW.js";import{getResolvedShikiTheme as en}from"./appThemeRegistry-BK0dHKa6.js";import{E as tn}from"./vendor-codemirror-view-CiLROUVV.js";import{Y as nn}from"./runtimeEndpointReset-D6SmNZaP.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-zod-BLfBSgBh.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BeMD8X_w.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-C9abMBTb.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DrTPkHl4.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-legendapp-list-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./registerCustomTheme-BBXUCRnG.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";const rn=()=>{const l=new Map,c=new Map;return{schedule:(o,s,f)=>{if(s<=(c.get(o)??Number.NEGATIVE_INFINITY))return l.get(o)??Promise.resolve();c.set(o,s);const g=(l.get(o)??Promise.resolve()).then(f,f);return l.set(o,g.catch(()=>{c.get(o)===s&&c.delete(o)})),g},pendingFor:async o=>{await l.get(o)},reset:o=>{c.delete(o)}}},b=l=>{if(!l)return"";const c=l.replace(/\\/g,"/");return c==="/"?"/":c.replace(/\/+$/,"")},Se=(l,c)=>{const o=b(l),s=c.replace(/\\/g,"/").replace(/^\/+/,"").replace(/\/+$/,"");return!o||o==="/"?`/${s}`:`${o}/${s}`},sn=(l,c,o)=>Se(Se(Se(l,".opencode"),"plans"),`${c}-${o}.md`),on=(l,c)=>`~/.opencode/plans/${l}-${c}.md`,an=(l,c)=>{const o=l.trim();return o.startsWith("~")?o==="~"?c||o:(o.startsWith("~/")||o.startsWith("~\\"))&&c?`${c}${o.slice(1)}`:o:o},ln=(l,c)=>{const o=b(c.currentDirectory),s=b(c.homeDirectory),f=b(l);return o&&f.startsWith(o+"/")?f.slice(o.length+1):s&&f===s?"~":s&&f.startsWith(s+"/")?`~${f.slice(s.length)}`:f},cn=(l,c,o)=>{const s=b(l.trim());if(!s)return null;const f=o?c.find(g=>g.id===o)??null:null;if(f?.path){const g=b(f.path);if(s===g||s.startsWith(`${g}/`))return{id:f.id,path:f.path}}const N=c.filter(g=>{const E=b(g.path);return s===E||s.startsWith(`${E}/`)}).sort((g,E)=>b(E.path).length-b(g.path).length)[0];return N?{id:N.id,path:N.path}:null},un=l=>jt(()=>l()),cs=({targetPath:l=null,savedProjectPlan:c=null,onNavigatedToChat:o})=>{const{t:s}=Tt(),f=Y(e=>e.currentSessionId),N=Y(e=>e.createSession),g=Y(e=>e.initializeNewOpenChamberSession),E=Y(e=>e.sendMessage),ye=Y(e=>e.setCurrentSession),be=kt(),z=xt(e=>e.homeDirectory),xe=Nt(e=>e.planModeEnabled),je=et(e=>e.projects),Ce=et(e=>e.activeProjectId),Re=Et(e=>e.directories),Pe=It()??"",Me=Ze(e=>e.setSessionSwitcherOpen),_=Dt(),I=t.useSyncExternalStore(un,he,he),{isMobile:Te}=Vt(),{currentTheme:H}=Ft(),S=t.useMemo(()=>f?be.find(e=>e.id===f)??null:null,[f,be]),R=t.useMemo(()=>{const e=typeof S?.directory=="string"?S.directory:"";return b(e||"")},[S?.directory]),ke=t.useMemo(()=>b(Pe||R),[Pe,R]),B=t.useMemo(()=>cn(ke,je,Ce),[Ce,ke,je]),se=c?.projectRef.id??null,ie=c?.projectRef.path??null,v=t.useMemo(()=>se&&ie?{id:se,path:ie}:null,[se,ie]),P=c?.planId??null,G=v&&P?JSON.stringify(["saved-plan",I,Lt(v),P]):null,L=v?.id===$t,Q=t.useMemo(()=>{const e=v??B;return e?Re.get(e.path)?.isGitRepo===!0:!1},[B,Re,v]),[D,$]=t.useState(null),[Ne,Ee]=t.useState(!1),[p,M]=t.useState(null),[oe,ae]=t.useState(null),at=!!p||!!oe,le=t.useMemo(()=>!p||!R||!z?p:ln(p,{currentDirectory:R,homeDirectory:z}),[p,R,z]),[h,x]=t.useState(""),{isPlaying:Z,play:lt,stop:ct}=At(),ut=tt(e=>e.showMessageTTSButtons),[Ie,ce]=t.useState(null),[De,ue]=t.useState(null),de=t.useMemo(()=>le&&le.split("/").pop()||s("planView.file.defaultName"),[le,s]),me=t.useMemo(()=>h.trim()?Ot(h,s("planView.title.default")).title:s("planView.title.default"),[h,s]),q=t.useMemo(()=>me.trim()||s("planView.title.default"),[me,s]),[dt,V]=t.useState(!1),[mt,Ve]=t.useState(!1),[X,Fe]=t.useState("edit"),J=t.useRef(null),[u,y]=t.useState(null),Le=t.useRef(null),pt=t.useRef(null),$e="openchamber:plan:md-viewer-mode";t.useEffect(()=>{try{const e=localStorage.getItem($e);if(!e)return;const i=JSON.parse(e);(i==="preview"||i==="edit")&&Fe(i)}catch{}},[]);const ft=t.useCallback(e=>{Fe(e);try{localStorage.setItem($e,JSON.stringify(e))}catch{}},[]),A=t.useRef(!1),T=t.useRef(null),[Ae,O]=t.useState(!1);t.useEffect(()=>{const e=()=>{A.current=!1,T.current=null,O(!1)};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[]);const ht=t.useCallback((e,i)=>{const a=e.split(`
1
+ import{R as t,j as n}from"./vendor-react-BUCujlKS.js";import{m as xt,u as qe,a as he,o as Xe,r as Ze,v as jt}from"./index-b0zDkWyg.js";import{c as Ct,s as Rt,P as Pt,C as Mt}from"./shikiHighlight-CFAVs_lu.js";import{f as Tt,y as H,ca as kt,av as Nt,b as et,ag as Et,ab as It,V as Dt,b5 as Vt,L as Ft,f4 as Lt,Y as At,g_ as Ot,l as tt,f3 as $t,am as nt,gd as Kt,f1 as Wt,cU as rt,f6 as zt,f7 as _t,m as Bt,g$ as Gt,b4 as st,a6 as ge,a7 as ve,b1 as it,B as ne,I as W,a8 as we,b3 as ot,b0 as re,g as Jt,c2 as Ut,ao as Ht,b_ as Yt,h0 as Qt}from"./useAppFontEffects-DWXGRUPZ.js";import{u as qt,n as Xt}from"./useInlineCommentController-Cc0OCXr0.js";import{b as Zt}from"./CodeMirrorCommentWidgets-CPvfxh0N.js";import{getResolvedShikiTheme as en}from"./appThemeRegistry-BK0dHKa6.js";import{E as tn}from"./vendor-codemirror-view-CiLROUVV.js";import{_ as nn}from"./runtimeEndpointReset-HlRmXFGW.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-zod-BLfBSgBh.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BeMD8X_w.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-BK78t3M_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BGFszm8n.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-legendapp-list-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./registerCustomTheme-BBXUCRnG.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";const rn=()=>{const l=new Map,c=new Map;return{schedule:(o,s,f)=>{if(s<=(c.get(o)??Number.NEGATIVE_INFINITY))return l.get(o)??Promise.resolve();c.set(o,s);const g=(l.get(o)??Promise.resolve()).then(f,f);return l.set(o,g.catch(()=>{c.get(o)===s&&c.delete(o)})),g},pendingFor:async o=>{await l.get(o)},reset:o=>{c.delete(o)}}},b=l=>{if(!l)return"";const c=l.replace(/\\/g,"/");return c==="/"?"/":c.replace(/\/+$/,"")},Se=(l,c)=>{const o=b(l),s=c.replace(/\\/g,"/").replace(/^\/+/,"").replace(/\/+$/,"");return!o||o==="/"?`/${s}`:`${o}/${s}`},sn=(l,c,o)=>Se(Se(Se(l,".opencode"),"plans"),`${c}-${o}.md`),on=(l,c)=>`~/.opencode/plans/${l}-${c}.md`,an=(l,c)=>{const o=l.trim();return o.startsWith("~")?o==="~"?c||o:(o.startsWith("~/")||o.startsWith("~\\"))&&c?`${c}${o.slice(1)}`:o:o},ln=(l,c)=>{const o=b(c.currentDirectory),s=b(c.homeDirectory),f=b(l);return o&&f.startsWith(o+"/")?f.slice(o.length+1):s&&f===s?"~":s&&f.startsWith(s+"/")?`~${f.slice(s.length)}`:f},cn=(l,c,o)=>{const s=b(l.trim());if(!s)return null;const f=o?c.find(g=>g.id===o)??null:null;if(f?.path){const g=b(f.path);if(s===g||s.startsWith(`${g}/`))return{id:f.id,path:f.path}}const N=c.filter(g=>{const E=b(g.path);return s===E||s.startsWith(`${E}/`)}).sort((g,E)=>b(E.path).length-b(g.path).length)[0];return N?{id:N.id,path:N.path}:null},un=l=>jt(()=>l()),cs=({targetPath:l=null,savedProjectPlan:c=null,onNavigatedToChat:o})=>{const{t:s}=Tt(),f=H(e=>e.currentSessionId),N=H(e=>e.createSession),g=H(e=>e.initializeNewOpenChamberSession),E=H(e=>e.sendMessage),ye=H(e=>e.setCurrentSession),be=kt(),z=xt(e=>e.homeDirectory),xe=Nt(e=>e.planModeEnabled),je=et(e=>e.projects),Ce=et(e=>e.activeProjectId),Re=Et(e=>e.directories),Pe=It()??"",Me=qe(e=>e.setSessionSwitcherOpen),_=Dt(),I=t.useSyncExternalStore(un,he,he),{isMobile:Te}=Vt(),{currentTheme:Y}=Ft(),S=t.useMemo(()=>f?be.find(e=>e.id===f)??null:null,[f,be]),R=t.useMemo(()=>{const e=typeof S?.directory=="string"?S.directory:"";return b(e||"")},[S?.directory]),ke=t.useMemo(()=>b(Pe||R),[Pe,R]),B=t.useMemo(()=>cn(ke,je,Ce),[Ce,ke,je]),se=c?.projectRef.id??null,ie=c?.projectRef.path??null,w=t.useMemo(()=>se&&ie?{id:se,path:ie}:null,[se,ie]),P=c?.planId??null,G=w&&P?JSON.stringify(["saved-plan",I,Lt(w),P]):null,L=w?.id===At,Q=t.useMemo(()=>{const e=w??B;return e?Re.get(e.path)?.isGitRepo===!0:!1},[B,Re,w]),[D,A]=t.useState(null),[Ne,Ee]=t.useState(!1),[p,M]=t.useState(null),[oe,ae]=t.useState(null),at=!!p||!!oe,le=t.useMemo(()=>!p||!R||!z?p:ln(p,{currentDirectory:R,homeDirectory:z}),[p,R,z]),[h,x]=t.useState(""),{isPlaying:q,play:lt,stop:ct}=Ot(),ut=tt(e=>e.showMessageTTSButtons),[Ie,ce]=t.useState(null),[De,ue]=t.useState(null),de=t.useMemo(()=>le&&le.split("/").pop()||s("planView.file.defaultName"),[le,s]),me=t.useMemo(()=>h.trim()?$t(h,s("planView.title.default")).title:s("planView.title.default"),[h,s]),X=t.useMemo(()=>me.trim()||s("planView.title.default"),[me,s]),[dt,V]=t.useState(!1),[mt,Ve]=t.useState(!1),[Z,Fe]=t.useState("edit"),J=t.useRef(null),[u,y]=t.useState(null),Le=t.useRef(null),pt=t.useRef(null),Ae="openchamber:plan:md-viewer-mode";t.useEffect(()=>{try{const e=localStorage.getItem(Ae);if(!e)return;const i=JSON.parse(e);(i==="preview"||i==="edit")&&Fe(i)}catch{}},[]);const ft=t.useCallback(e=>{Fe(e);try{localStorage.setItem(Ae,JSON.stringify(e))}catch{}},[]),O=t.useRef(!1),T=t.useRef(null),[Oe,$]=t.useState(!1);t.useEffect(()=>{const e=()=>{O.current=!1,T.current=null,$(!1)};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[]);const ht=t.useCallback((e,i)=>{const a=e.split(`
2
2
  `),r=Math.max(1,i.start),d=Math.min(a.length,i.end);return r>d?"":a.slice(r-1,d).join(`
3
- `)},[]),gt=Zt({source:"plan",fileLabel:de,language:p&&nt(p)||"markdown",getCodeForRange:e=>ht(h,qt(e)),toStoreRange:e=>({startLine:e.start,endLine:e.end}),fromDraftRange:e=>({start:e.startLine,end:e.endLine})}),{drafts:Oe,commentText:ee,setCommentText:Ke,editingDraftId:pe,setSelection:We,saveComment:ze,cancel:U,reset:_e,startEdit:Be,deleteDraft:Ge}=gt;t.useEffect(()=>{y(null),_e()},[h,_e]),t.useEffect(()=>{We(u)},[u,We]);const Je=t.useCallback(()=>{y(null),U()},[U]),Ue=t.useCallback((e,i)=>{i&&y(i),ze(e,i??u??void 0),y(null)},[u,ze]);t.useEffect(()=>{if(!u)return;const e=a=>{const r=a.target;r.closest('[data-comment-card="true"]')||r.closest('[data-comment-input="true"]')||r.closest(".oc-block-widget")||r.closest(".cm-gutterElement")||r.closest("[data-sonner-toast]")||r.closest("[data-sonner-toaster]")||ee.trim()||(y(null),U())},i=window.setTimeout(()=>{document.addEventListener("click",e)},100);return()=>{window.clearTimeout(i),document.removeEventListener("click",e)}},[U,ee,pe,Te,u]);const fe=Ze(e=>e.editorFontSize),wt=t.useMemo(()=>{const e=p?nt(p):null,i=!!e&&e!=="markdown",a=[Ct(H,i?{syntaxColors:!1,fontSize:fe}:{fontSize:fe})],r=Kt(p||"plan.md");return r&&a.push(r),i&&e&&a.push(Rt({language:e,themeName:H.metadata.id,theme:en(H)})),a.push(tn.lineWrapping),a},[H,p,fe]),j=t.useRef({key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""}),C=t.useState(rn)[0],Ye=t.useCallback(async(e,i)=>{if("filePath"in e){const r=_.files??qe()?.files;if(r?.writeFile){if(!(await r.writeFile(e.filePath,i))?.success)throw new Error("Plan file write failed");return}const d=await Xe("/api/fs/write",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e.filePath,content:i})});if(!d.ok)throw new Error(`Failed to write plan file (${d.status})`);return}if(!await Wt.getState().savePlan(e.projectRef,e.planId,i))throw new Error("Plan save rejected: the plan no longer exists")},[_.files]),He=t.useRef(Ye);He.current=Ye;const F=t.useCallback(()=>{const e=j.current;if(!e.key||!e.target||e.editRevision<=e.savedRevision)return;const i={key:e.key,target:e.target,content:e.content,revision:e.editRevision,runtimeKey:e.runtimeKey,write:He.current};C.schedule(i.key,i.revision,async()=>{if(he()!==i.runtimeKey)return;await i.write(i.target,i.content);const a=j.current;a.key===i.key&&(a.savedRevision=Math.max(a.savedRevision,i.revision),ce(null))}).catch(a=>{j.current.key===i.key&&ce(a instanceof Error?a.message:"Plan save failed")})},[C]);t.useEffect(()=>{if(!xe&&!l&&!P){F(),j.current={key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""},M(null),ae(null),x(""),V(!1);return}let e=!1;const i=async r=>{if(_.files?.readFile)return(await _.files.readFile(r))?.content??"";const d=qe()?.files;if(d?.readFile)return(await d.readFile(r,{optional:!0}))?.content??"";const m=await Xe(`/api/fs/read?path=${encodeURIComponent(r)}&optional=true`,{cache:"no-store"});if(!m.ok)throw new Error(`Failed to read plan file (${m.status})`);return m.text()};return(async()=>{if(F(),j.current={key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""},M(null),ae(null),x(""),ce(null),ue(null),P&&v&&G){if(await C.pendingFor(G),e)return;C.reset(G),V(!0);try{const r=await Qt(v,P);if(e)return;if(!r){ue("Plan not found");return}j.current={key:G,target:{projectRef:v,planId:P},content:r.raw,editRevision:0,savedRevision:0,runtimeKey:I},x(r.raw),ae(P)}catch(r){if(e)return;ue(r instanceof Error?r.message:"Plan load failed")}finally{e||V(!1)}return}if(l){const r=JSON.stringify(["plan-file",I,l]);if(await C.pendingFor(r),e)return;C.reset(r),V(!0);try{const d=await i(l);if(e)return;j.current={key:r,target:{filePath:l},content:d,editRevision:0,savedRevision:0,runtimeKey:I},M(l),x(d)}catch{if(e)return;M(null),x("")}finally{e||V(!1)}return}if(!S?.slug||!S?.time?.created||!R){M(null),x("");return}V(!0);try{const r=sn(R,S.time.created,S.slug),d=an(on(S.time.created,S.slug),z||null);let m=null;try{await i(r),m=r}catch{}if(!m)try{await i(d),m=d}catch{}if(e)return;if(!m){M(null),x("");return}const w=JSON.stringify(["plan-file",I,m]);if(await C.pendingFor(w),e)return;const K=await i(m);if(e)return;C.reset(w),j.current={key:w,target:{filePath:m},content:K,editRevision:0,savedRevision:0,runtimeKey:I},M(m),x(K)}catch{if(e)return;M(null),x("")}finally{e||V(!1)}})(),()=>{e=!0}},[I,z,xe,_.files,P,G,v,C,F,S?.slug,S?.time?.created,R,l]);const vt=t.useCallback(e=>{j.current.content=e,j.current.editRevision+=1,x(e)},[]);t.useEffect(()=>{if(!p&&!oe)return;const e=window.setTimeout(()=>{F()},350);return()=>{window.clearTimeout(e)}},[h,oe,p,F]),t.useEffect(()=>()=>{F()},[F]),t.useEffect(()=>()=>{J.current!==null&&window.clearTimeout(J.current)},[]);const Qe=t.useCallback(()=>{Me(!1),o?.()},[o,Me]),St=t.useCallback(async e=>{const i=v??B;if(!i||!D||L)return;const a=await rt(D.action==="improve"?"plan.improve.visible":"plan.implement.visible",{plan_title:q}),r=await rt(D.action==="improve"?"plan.improve.instructions":"plan.implement.instructions",{plan_title:q,plan_path:p??""}),m=[{synthetic:!0,text:p?r:[r,"","The plan is not stored as a file in the repository and has no file path. Its full current contents follow below this note and are the source of truth for the plan. Where the instructions above refer to the plan file, treat the plan as stored in OpenChamber project knowledge (it is edited through the OpenChamber UI): propose plan revisions as plan text in the chat rather than editing a file.","",h].join(`
4
- `)}];Ee(!0);try{Qe();let w=null,K=i.path;if(D.target==="worktree"){if(!Q)return;const k=await zt(i.path,_t());if(!k?.id)return;w=k.id,K=k.path}else{const k=await N(void 0,i.path,null);if(!k?.id)return;w=k.id,K=k.directory??i.path,g(k.id,tt.getState().agents??[])}if(!w)return;const te=Bt.getState();te.saveSessionModelSelection(w,e.providerID,e.modelID),e.agent.trim()&&(te.saveSessionAgentSelection(w,e.agent),te.saveAgentModelForSession(w,e.agent,e.providerID,e.modelID),te.saveAgentModelVariantForSession(w,e.agent,e.providerID,e.modelID,e.variant||void 0)),ye(w,K);const bt=e.runAsGoal===!0?[`Implement the plan "${q}" end-to-end${p?` (plan file: ${p})`:" (the full plan follows)"}.`,p?"Re-read that file for full details — it is the source of truth.":"The full plan follows in this message and is the source of truth.","",h].join(`
5
- `):null;Gt.getState().setArmed(e.runAsGoal===!0,bt),await E(a,e.providerID,e.modelID,e.agent.trim()||void 0,void 0,void 0,m,e.variant||void 0),$(null)}finally{Ee(!1)}},[Q,h,N,B,g,L,D,p,Qe,v,E,q,ye]),yt=t.useMemo(()=>Xt({drafts:Oe,editingDraftId:pe,commentText:ee,onTextChange:Ke,selection:u,isDragging:Ae,fileLabel:de,newWidgetId:"plan-new-comment-input",mapDraftToRange:e=>({start:e.startLine,end:e.endLine}),onSave:Ue,onCancel:Je,onEdit:e=>{Be(e),y({start:e.startLine,end:e.endLine})},onDelete:Ge}),[ee,Ge,pe,Je,Ue,Ae,u,Oe,de,Ke,Be]);return n.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2 border-b border-border/40 px-3 py-1.5 flex-shrink-0",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"typography-ui-label font-medium truncate",children:me}),De?n.jsx("div",{className:"typography-micro text-[color:var(--status-error)] truncate",title:De,children:s("planView.error.loadFailed")}):null,Ie?n.jsx("div",{className:"typography-micro text-[color:var(--status-error)] truncate",title:Ie,children:s("planView.error.saveFailed")}):null]}),at?n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsxs(st,{children:[n.jsxs(ge,{children:[n.jsx(we,{asChild:!0,children:n.jsx(it,{asChild:!0,children:n.jsx(ne,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":s("planView.actions.improvePlanAria"),disabled:!h.trim()||L,children:n.jsx(W,{name:"loop-right-ai",className:"size-4"})})})}),n.jsx(ve,{sideOffset:8,children:s("planView.actions.improve")})]}),n.jsxs(ot,{align:"end",children:[n.jsx(re,{onClick:()=>$({action:"improve",target:"session"}),disabled:L,children:s("planView.actions.sendToNewSession")}),n.jsx(re,{onClick:()=>$({action:"improve",target:"worktree"}),disabled:!Q,children:s("planView.actions.sendToNewWorktreeSession")})]})]}),n.jsxs(st,{children:[n.jsxs(ge,{children:[n.jsx(we,{asChild:!0,children:n.jsx(it,{asChild:!0,children:n.jsx(ne,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":s("planView.actions.implementPlanAria"),disabled:!h.trim()||L,children:n.jsx(W,{name:"code-ai",className:"size-4"})})})}),n.jsx(ve,{sideOffset:8,children:s("planView.actions.implement")})]}),n.jsxs(ot,{align:"end",children:[n.jsx(re,{onClick:()=>$({action:"implement",target:"session"}),disabled:L,children:s("planView.actions.sendToNewSession")}),n.jsx(re,{onClick:()=>$({action:"implement",target:"worktree"}),disabled:!Q,children:s("planView.actions.sendToNewWorktreeSession")})]})]}),n.jsx(Pt,{currentMode:X,onToggle:()=>ft(X==="preview"?"edit":"preview")}),X==="preview"&&ut&&n.jsxs(ge,{children:[n.jsx(we,{asChild:!0,children:n.jsx(ne,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":s(Z?"planView.tts.stopSpeaking":"planView.tts.readAloud"),onClick:()=>{Z?ct():h.trim()&&lt(h)},children:Z?n.jsx(W,{name:"stop",className:"h-4 w-4 text-[color:var(--status-success)]"}):n.jsx(W,{name:"volume-up",className:"h-4 w-4"})})}),n.jsx(ve,{sideOffset:8,children:s(Z?"planView.tts.stopSpeaking":"planView.tts.readAloud")})]}),n.jsx(ne,{variant:"ghost",size:"sm",onClick:async()=>{(await Jt(h)).ok&&(Ve(!0),J.current!==null&&window.clearTimeout(J.current),J.current=window.setTimeout(()=>{Ve(!1)},1200))},className:"h-5 w-5 p-0",title:s("planView.actions.copyPlanContents"),"aria-label":s("planView.actions.copyPlanContents"),children:mt?n.jsx(W,{name:"check",className:"h-4 w-4 text-[color:var(--status-success)]"}):n.jsx(W,{name:"clipboard",className:"h-4 w-4"})})]}):null]}),n.jsx(nn,{open:D!==null,onOpenChange:e=>{!e&&!Ne&&$(null)},target:D?.target??"session",projectDirectory:v?.path??B?.path??null,submitting:Ne,allowRunAsGoal:!0,onConfirm:St}),n.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:n.jsx(Ut,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:dt?n.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:s("planView.state.loading")}):n.jsx("div",{className:"relative h-full",children:n.jsx("div",{className:"h-full",children:X==="preview"?n.jsx("div",{className:"h-full overflow-auto p-3",children:n.jsx(Yt,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:s("planView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:s("planView.error.switchToEditMode")})]}),children:n.jsx(Ht,{content:h,className:"typography-markdown-body",enableFileReferences:!1})})}):n.jsx("div",{className:"relative h-full",ref:pt,children:n.jsx(Mt,{value:h,onChange:vt,readOnly:!1,className:"h-full",extensions:wt,onViewReady:e=>{Le.current=e},onViewDestroy:()=>{Le.current=null},blockWidgets:yt,highlightLines:u?{start:Math.min(u.start,u.end),end:Math.max(u.start,u.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(e,i,a)=>{if(!(a instanceof MouseEvent)||a.button!==0)return!1;a.preventDefault();const r=e.state.doc.lineAt(i.from).number;if(u&&!a.shiftKey&&Math.min(u.start,u.end)===r&&Math.max(u.start,u.end)===r)return y(null),U(),A.current=!1,T.current=null,O(!1),!0;if(Te&&u&&!a.shiftKey){const d=Math.min(u.start,u.end,r),m=Math.max(u.start,u.end,r);return y({start:d,end:m}),A.current=!1,T.current=null,O(!1),!0}if(A.current=!0,T.current=r,O(!0),u&&a.shiftKey){const d=Math.min(u.start,r),m=Math.max(u.end,r);y({start:d,end:m})}else y({start:r,end:r});return!0},mouseover:(e,i,a)=>{if(!(a instanceof MouseEvent)||a.buttons!==1||!A.current||T.current===null)return!1;const r=e.state.doc.lineAt(i.from).number,d=Math.min(T.current,r),m=Math.max(T.current,r);return y({start:d,end:m}),O(!0),!1},mouseup:()=>(A.current=!1,T.current=null,O(!1),!1)}}})})})})})})]})};export{cs as PlanView};
3
+ `)},[]),gt=qt({source:"plan",fileLabel:de,language:p&&nt(p)||"markdown",getCodeForRange:e=>ht(h,Xt(e)),toStoreRange:e=>({startLine:e.start,endLine:e.end}),fromDraftRange:e=>({start:e.startLine,end:e.endLine})}),{drafts:$e,commentText:ee,setCommentText:Ke,editingDraftId:pe,setSelection:We,saveComment:ze,cancel:U,reset:_e,startEdit:Be,deleteDraft:Ge}=gt;t.useEffect(()=>{y(null),_e()},[h,_e]),t.useEffect(()=>{We(u)},[u,We]);const Je=t.useCallback(()=>{y(null),U()},[U]),Ue=t.useCallback((e,i)=>{i&&y(i),ze(e,i??u??void 0),y(null)},[u,ze]);t.useEffect(()=>{if(!u)return;const e=a=>{const r=a.target;r.closest('[data-comment-card="true"]')||r.closest('[data-comment-input="true"]')||r.closest(".oc-block-widget")||r.closest(".cm-gutterElement")||r.closest("[data-sonner-toast]")||r.closest("[data-sonner-toaster]")||ee.trim()||(y(null),U())},i=window.setTimeout(()=>{document.addEventListener("click",e)},100);return()=>{window.clearTimeout(i),document.removeEventListener("click",e)}},[U,ee,pe,Te,u]);const fe=qe(e=>e.editorFontSize),vt=t.useMemo(()=>{const e=p?nt(p):null,i=!!e&&e!=="markdown",a=[Ct(Y,i?{syntaxColors:!1,fontSize:fe}:{fontSize:fe})],r=Kt(p||"plan.md");return r&&a.push(r),i&&e&&a.push(Rt({language:e,themeName:Y.metadata.id,theme:en(Y)})),a.push(tn.lineWrapping),a},[Y,p,fe]),j=t.useRef({key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""}),C=t.useState(rn)[0],He=t.useCallback(async(e,i)=>{if("filePath"in e){const r=_.files??Xe()?.files;if(r?.writeFile){if(!(await r.writeFile(e.filePath,i))?.success)throw new Error("Plan file write failed");return}const d=await Ze("/api/fs/write",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e.filePath,content:i})});if(!d.ok)throw new Error(`Failed to write plan file (${d.status})`);return}if(!await Wt.getState().savePlan(e.projectRef,e.planId,i))throw new Error("Plan save rejected: the plan no longer exists")},[_.files]),Ye=t.useRef(He);Ye.current=He;const F=t.useCallback(()=>{const e=j.current;if(!e.key||!e.target||e.editRevision<=e.savedRevision)return;const i={key:e.key,target:e.target,content:e.content,revision:e.editRevision,runtimeKey:e.runtimeKey,write:Ye.current};C.schedule(i.key,i.revision,async()=>{if(he()!==i.runtimeKey)return;await i.write(i.target,i.content);const a=j.current;a.key===i.key&&(a.savedRevision=Math.max(a.savedRevision,i.revision),ce(null))}).catch(a=>{j.current.key===i.key&&ce(a instanceof Error?a.message:"Plan save failed")})},[C]);t.useEffect(()=>{if(!xe&&!l&&!P){F(),j.current={key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""},M(null),ae(null),x(""),V(!1);return}let e=!1;const i=async r=>{if(_.files?.readFile)return(await _.files.readFile(r))?.content??"";const d=Xe()?.files;if(d?.readFile)return(await d.readFile(r,{optional:!0}))?.content??"";const m=await Ze(`/api/fs/read?path=${encodeURIComponent(r)}&optional=true`,{cache:"no-store"});if(!m.ok)throw new Error(`Failed to read plan file (${m.status})`);return m.text()};return(async()=>{if(F(),j.current={key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""},M(null),ae(null),x(""),ce(null),ue(null),P&&w&&G){if(await C.pendingFor(G),e)return;C.reset(G),V(!0);try{const r=await Qt(w,P);if(e)return;if(!r){ue("Plan not found");return}j.current={key:G,target:{projectRef:w,planId:P},content:r.raw,editRevision:0,savedRevision:0,runtimeKey:I},x(r.raw),ae(P)}catch(r){if(e)return;ue(r instanceof Error?r.message:"Plan load failed")}finally{e||V(!1)}return}if(l){const r=JSON.stringify(["plan-file",I,l]);if(await C.pendingFor(r),e)return;C.reset(r),V(!0);try{const d=await i(l);if(e)return;j.current={key:r,target:{filePath:l},content:d,editRevision:0,savedRevision:0,runtimeKey:I},M(l),x(d)}catch{if(e)return;M(null),x("")}finally{e||V(!1)}return}if(!S?.slug||!S?.time?.created||!R){M(null),x("");return}V(!0);try{const r=sn(R,S.time.created,S.slug),d=an(on(S.time.created,S.slug),z||null);let m=null;try{await i(r),m=r}catch{}if(!m)try{await i(d),m=d}catch{}if(e)return;if(!m){M(null),x("");return}const v=JSON.stringify(["plan-file",I,m]);if(await C.pendingFor(v),e)return;const K=await i(m);if(e)return;C.reset(v),j.current={key:v,target:{filePath:m},content:K,editRevision:0,savedRevision:0,runtimeKey:I},M(m),x(K)}catch{if(e)return;M(null),x("")}finally{e||V(!1)}})(),()=>{e=!0}},[I,z,xe,_.files,P,G,w,C,F,S?.slug,S?.time?.created,R,l]);const wt=t.useCallback(e=>{j.current.content=e,j.current.editRevision+=1,x(e)},[]);t.useEffect(()=>{if(!p&&!oe)return;const e=window.setTimeout(()=>{F()},350);return()=>{window.clearTimeout(e)}},[h,oe,p,F]),t.useEffect(()=>()=>{F()},[F]),t.useEffect(()=>()=>{J.current!==null&&window.clearTimeout(J.current)},[]);const Qe=t.useCallback(()=>{Me(!1),o?.()},[o,Me]),St=t.useCallback(async e=>{const i=w??B;if(!i||!D||L)return;const a=await rt(D.action==="improve"?"plan.improve.visible":"plan.implement.visible",{plan_title:X}),r=await rt(D.action==="improve"?"plan.improve.instructions":"plan.implement.instructions",{plan_title:X,plan_path:p??""}),m=[{synthetic:!0,text:p?r:[r,"","The plan is not stored as a file in the repository and has no file path. Its full current contents follow below this note and are the source of truth for the plan. Where the instructions above refer to the plan file, treat the plan as stored in OpenChamber project knowledge (it is edited through the OpenChamber UI): propose plan revisions as plan text in the chat rather than editing a file.","",h].join(`
4
+ `)}];Ee(!0);try{Qe();let v=null,K=i.path;if(D.target==="worktree"){if(!Q)return;const k=await zt(i.path,_t());if(!k?.id)return;v=k.id,K=k.path}else{const k=await N(void 0,i.path,null);if(!k?.id)return;v=k.id,K=k.directory??i.path,g(k.id,tt.getState().agents??[])}if(!v)return;const te=Bt.getState();te.saveSessionModelSelection(v,e.providerID,e.modelID),e.agent.trim()&&(te.saveSessionAgentSelection(v,e.agent),te.saveAgentModelForSession(v,e.agent,e.providerID,e.modelID),te.saveAgentModelVariantForSession(v,e.agent,e.providerID,e.modelID,e.variant||void 0)),ye(v,K);const bt=e.runAsGoal===!0?[`Implement the plan "${X}" end-to-end${p?` (plan file: ${p})`:" (the full plan follows)"}.`,p?"Re-read that file for full details — it is the source of truth.":"The full plan follows in this message and is the source of truth.","",h].join(`
5
+ `):null;Gt.getState().setArmed(e.runAsGoal===!0,bt),await E(a,e.providerID,e.modelID,e.agent.trim()||void 0,void 0,void 0,m,e.variant||void 0),A(null)}finally{Ee(!1)}},[Q,h,N,B,g,L,D,p,Qe,w,E,X,ye]),yt=t.useMemo(()=>Zt({drafts:$e,editingDraftId:pe,commentText:ee,onTextChange:Ke,selection:u,isDragging:Oe,fileLabel:de,newWidgetId:"plan-new-comment-input",mapDraftToRange:e=>({start:e.startLine,end:e.endLine}),onSave:Ue,onCancel:Je,onEdit:e=>{Be(e),y({start:e.startLine,end:e.endLine})},onDelete:Ge}),[ee,Ge,pe,Je,Ue,Oe,u,$e,de,Ke,Be]);return n.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2 border-b border-border/40 px-3 py-1.5 flex-shrink-0",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"typography-ui-label font-medium truncate",children:me}),De?n.jsx("div",{className:"typography-micro text-[color:var(--status-error)] truncate",title:De,children:s("planView.error.loadFailed")}):null,Ie?n.jsx("div",{className:"typography-micro text-[color:var(--status-error)] truncate",title:Ie,children:s("planView.error.saveFailed")}):null]}),at?n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsxs(st,{children:[n.jsxs(ge,{children:[n.jsx(ve,{asChild:!0,children:n.jsx(it,{asChild:!0,children:n.jsx(ne,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":s("planView.actions.improvePlanAria"),disabled:!h.trim()||L,children:n.jsx(W,{name:"loop-right-ai",className:"size-4"})})})}),n.jsx(we,{sideOffset:8,children:s("planView.actions.improve")})]}),n.jsxs(ot,{align:"end",children:[n.jsx(re,{onClick:()=>A({action:"improve",target:"session"}),disabled:L,children:s("planView.actions.sendToNewSession")}),n.jsx(re,{onClick:()=>A({action:"improve",target:"worktree"}),disabled:!Q,children:s("planView.actions.sendToNewWorktreeSession")})]})]}),n.jsxs(st,{children:[n.jsxs(ge,{children:[n.jsx(ve,{asChild:!0,children:n.jsx(it,{asChild:!0,children:n.jsx(ne,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":s("planView.actions.implementPlanAria"),disabled:!h.trim()||L,children:n.jsx(W,{name:"code-ai",className:"size-4"})})})}),n.jsx(we,{sideOffset:8,children:s("planView.actions.implement")})]}),n.jsxs(ot,{align:"end",children:[n.jsx(re,{onClick:()=>A({action:"implement",target:"session"}),disabled:L,children:s("planView.actions.sendToNewSession")}),n.jsx(re,{onClick:()=>A({action:"implement",target:"worktree"}),disabled:!Q,children:s("planView.actions.sendToNewWorktreeSession")})]})]}),n.jsx(Pt,{currentMode:Z,onToggle:()=>ft(Z==="preview"?"edit":"preview")}),Z==="preview"&&ut&&n.jsxs(ge,{children:[n.jsx(ve,{asChild:!0,children:n.jsx(ne,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":s(q?"planView.tts.stopSpeaking":"planView.tts.readAloud"),onClick:()=>{q?ct():h.trim()&&lt(h)},children:q?n.jsx(W,{name:"stop",className:"h-4 w-4 text-[color:var(--status-success)]"}):n.jsx(W,{name:"volume-up",className:"h-4 w-4"})})}),n.jsx(we,{sideOffset:8,children:s(q?"planView.tts.stopSpeaking":"planView.tts.readAloud")})]}),n.jsx(ne,{variant:"ghost",size:"sm",onClick:async()=>{(await Jt(h)).ok&&(Ve(!0),J.current!==null&&window.clearTimeout(J.current),J.current=window.setTimeout(()=>{Ve(!1)},1200))},className:"h-5 w-5 p-0",title:s("planView.actions.copyPlanContents"),"aria-label":s("planView.actions.copyPlanContents"),children:mt?n.jsx(W,{name:"check",className:"h-4 w-4 text-[color:var(--status-success)]"}):n.jsx(W,{name:"clipboard",className:"h-4 w-4"})})]}):null]}),n.jsx(nn,{open:D!==null,onOpenChange:e=>{!e&&!Ne&&A(null)},target:D?.target??"session",projectDirectory:w?.path??B?.path??null,submitting:Ne,allowRunAsGoal:!0,onConfirm:St}),n.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:n.jsx(Ut,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:dt?n.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:s("planView.state.loading")}):n.jsx("div",{className:"relative h-full",children:n.jsx("div",{className:"h-full",children:Z==="preview"?n.jsx("div",{className:"h-full overflow-auto p-3",children:n.jsx(Ht,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:s("planView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:s("planView.error.switchToEditMode")})]}),children:n.jsx(Yt,{content:h,className:"typography-markdown-body",enableFileReferences:!1})})}):n.jsx("div",{className:"relative h-full",ref:pt,children:n.jsx(Mt,{value:h,onChange:wt,readOnly:!1,className:"h-full",extensions:vt,onViewReady:e=>{Le.current=e},onViewDestroy:()=>{Le.current=null},blockWidgets:yt,highlightLines:u?{start:Math.min(u.start,u.end),end:Math.max(u.start,u.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(e,i,a)=>{if(!(a instanceof MouseEvent)||a.button!==0)return!1;a.preventDefault();const r=e.state.doc.lineAt(i.from).number;if(u&&!a.shiftKey&&Math.min(u.start,u.end)===r&&Math.max(u.start,u.end)===r)return y(null),U(),O.current=!1,T.current=null,$(!1),!0;if(Te&&u&&!a.shiftKey){const d=Math.min(u.start,u.end,r),m=Math.max(u.start,u.end,r);return y({start:d,end:m}),O.current=!1,T.current=null,$(!1),!0}if(O.current=!0,T.current=r,$(!0),u&&a.shiftKey){const d=Math.min(u.start,r),m=Math.max(u.end,r);y({start:d,end:m})}else y({start:r,end:r});return!0},mouseover:(e,i,a)=>{if(!(a instanceof MouseEvent)||a.buttons!==1||!O.current||T.current===null)return!1;const r=e.state.doc.lineAt(i.from).number,d=Math.min(T.current,r),m=Math.max(T.current,r);return y({start:d,end:m}),$(!0),!1},mouseup:()=>(O.current=!1,T.current=null,$(!1),!1)}}})})})})})})]})};export{cs as PlanView};