@bendyline/gezel-service 1.0.7 → 1.1.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.
- package/dist/bin/gezeld.js +6253 -3616
- package/dist/handboek-content/whats-new/1.26224.md +1 -0
- package/dist/handboek-content/whats-new/1.26226.md +1 -0
- package/dist/handboek-content/whats-new/1.26231.md +1 -0
- package/dist/handboek-content/whats-new/1.26234.md +1 -0
- package/dist/handboek-content/whats-new/1.26237.md +1 -0
- package/dist/handboek-content/whats-new/1.26244.md +2 -1
- package/dist/handboek-content/whats-new/1.26247.md +88 -0
- package/dist/handboek-content/whats-new/whats-new-index.md +1 -0
- package/dist/index-store/static-index-worker.js +17 -1
- package/dist/index.d.ts +473 -209
- package/dist/index.js +6251 -3614
- package/dist/memory/embed-worker.js +58 -2
- package/dist/memory/image-embed-worker.js +8 -0
- package/dist/providers/llama-cpp/gguf-metadata-worker.js +2 -0
- package/dist/providers/mlx/python/gezel_mlx_server.py +18 -18
- package/dist/ui/assets/AmbientDashboardCard-Cf5fi_fY.js +1 -0
- package/dist/ui/assets/{AudioEngineSettings-BDrNIGGm.js → AudioEngineSettings-D3L7HOHe.js} +1 -1
- package/dist/ui/assets/{BenchmarksView-CHyujjs8.js → BenchmarksView-B68hrLCl.js} +1 -1
- package/dist/ui/assets/CatalogBrowser-DEM9t7Es.js +1 -0
- package/dist/ui/assets/{ChannelsSettings-Be_W1mr8.js → ChannelsSettings-DtK_k0Ul.js} +1 -1
- package/dist/ui/assets/ChatTimelineView-CQ4Sf4Ip.js +7 -0
- package/dist/ui/assets/ConfirmDialog-Dt1ed4Fh.js +1 -0
- package/dist/ui/assets/ConnectedAppsPanel-Cl8LEkrt.js +1 -0
- package/dist/ui/assets/CraftbookEditor-DEQRlQ2p.js +1 -0
- package/dist/ui/assets/{CraftbookScriptEditorView-DXIZYZT3.js → CraftbookScriptEditorView-DhXkkIdK.js} +1 -1
- package/dist/ui/assets/{CraftbookTabContent-Bm7t_b37.js → CraftbookTabContent-_oIdpQTG.js} +1 -1
- package/dist/ui/assets/{CraftbookToolsetSetup-DTEA-3K3.js → CraftbookToolsetSetup-BKg136L1.js} +1 -1
- package/dist/ui/assets/{CraftbooksView-C4X99TTe.js → CraftbooksView-Dm2zH-nW.js} +2 -2
- package/dist/ui/assets/{DiffpackReviewView-ClcNxtmF.js → DiffpackReviewView-EFLGJnwr.js} +1 -1
- package/dist/ui/assets/DocumentDetail-ClDRj2N-.js +1 -0
- package/dist/ui/assets/DocumentsView-ny9oieg2.js +1 -0
- package/dist/ui/assets/DropdownMenu-S4d9-3j3.js +1 -0
- package/dist/ui/assets/Ds4Settings-CeWlm5Vf.js +1 -0
- package/dist/ui/assets/EmbeddedChat-Hjrrgpao.js +1 -0
- package/dist/ui/assets/{FaceRecognitionCard-D3hdc7uU.js → FaceRecognitionCard-D7ufKqjI.js} +1 -1
- package/dist/ui/assets/FileMapView-DRjf59RH.js +1 -0
- package/dist/ui/assets/{FoldersSettings-BcNzl4vT.js → FoldersSettings-DDUhaFio.js} +1 -1
- package/dist/ui/assets/GezelDetail-Cph6pVGb.js +1 -0
- package/dist/ui/assets/{GezelJsonEditor-fOvYclu9.js → GezelJsonEditor-7vDGyBib.js} +1 -1
- package/dist/ui/assets/{GezellenView-BTzhHrxi.js → GezellenView-DQhcO1CP.js} +1 -1
- package/dist/ui/assets/{GildeUpdatesCard-Bq6XEpLP.js → GildeUpdatesCard-UKKNm_U8.js} +1 -1
- package/dist/ui/assets/{GithubSignInChip-CnlTCG8G.js → GithubSignInChip-DjM3qZsL.js} +1 -1
- package/dist/ui/assets/{HandboekMediaProvider-BfQW8_Nr.js → HandboekMediaProvider-DixaXTAH.js} +1 -1
- package/dist/ui/assets/HandboekView-BeNQqho9.js +1 -0
- package/dist/ui/assets/HistoryView-E2szGNGS.js +1 -0
- package/dist/ui/assets/{HomeView-CB_5TJIp.css → HomeView-CNeqCFPc.css} +1 -1
- package/dist/ui/assets/HomeView-CkiS3DXy.js +1 -0
- package/dist/ui/assets/{ImageEngineSettings-BpMfQy4f.js → ImageEngineSettings-BCKT7Gvi.js} +1 -1
- package/dist/ui/assets/{ImageRecognitionSettings-Ct-7-Oas.js → ImageRecognitionSettings-DD6syFez.js} +1 -1
- package/dist/ui/assets/IncompleteDownloads-BiPaaahS.js +1 -0
- package/dist/ui/assets/InstallProgressRow-DyKOI4MU.js +1 -0
- package/dist/ui/assets/KnowledgeCatalogsCard-B132vzRa.js +1 -0
- package/dist/ui/assets/KnowledgeView-CtPuIlN4.js +1 -0
- package/dist/ui/assets/LlamaCppSettings-D6zHcu4W.js +1 -0
- package/dist/ui/assets/{MarkdownField-D-0Zw7gM.js → MarkdownField-CK8K3fzj.js} +1 -1
- package/dist/ui/assets/MemoriesTree-DzjXzIrM.js +1 -0
- package/dist/ui/assets/{MicrophoneSettings-BIaFxyY_.js → MicrophoneSettings-1FH83SCq.js} +1 -1
- package/dist/ui/assets/MlxSettings-BYxUqFnJ.js +1 -0
- package/dist/ui/assets/ModelPicker-DoXPfQkQ.js +1 -0
- package/dist/ui/assets/{NewScriptDialog-D-gkY8TS.js → NewScriptDialog-C5X-7PMt.js} +1 -1
- package/dist/ui/assets/NewTaskDialog-Cyqtmigv.js +2 -0
- package/dist/ui/assets/{OllamaSettings-oIE2Mech.js → OllamaSettings-DkjmA-sB.js} +1 -1
- package/dist/ui/assets/ProjectChat-YEqUME6k.js +5 -0
- package/dist/ui/assets/{ProjectConnectionsTab-BZqp-oKI.js → ProjectConnectionsTab-dFCJpW93.js} +1 -1
- package/dist/ui/assets/ProjectGitStatusBar-CjZxG54t.js +1 -0
- package/dist/ui/assets/{ProjectGithubView-w8suLCsA.js → ProjectGithubView-CQ4-tmPx.js} +1 -1
- package/dist/ui/assets/{ProjectMailTab-DGo7eyB8.js → ProjectMailTab-NaScsZJf.js} +1 -1
- package/dist/ui/assets/ProjectOverviewView-ChjxbQas.js +1 -0
- package/dist/ui/assets/{ProjectTimeline-DRe3D9qY.js → ProjectTimeline-BZpdCisR.js} +1 -1
- package/dist/ui/assets/ProjectsView-J77ECk6V.js +7 -0
- package/dist/ui/assets/{RecommendedBadge-BKiDixnB.js → RecommendedBadge-D0m68PAu.js} +1 -1
- package/dist/ui/assets/{RemoteServersPanel-DGyl6-Rg.js → RemoteServersPanel-BdLOoORu.js} +1 -1
- package/dist/ui/assets/ScriptEditorTabs-BFvIiDFZ.js +2 -0
- package/dist/ui/assets/ScriptEditorView-B09rm1vz.js +5 -0
- package/dist/ui/assets/{ScriptsView-WQc28TmQ.js → ScriptsView-BvNAJXpo.js} +1 -1
- package/dist/ui/assets/{SecurityComplianceSettings-DsMEA4J3.js → SecurityComplianceSettings-DzGOnptO.js} +1 -1
- package/dist/ui/assets/SessionSwitcher-6okzcxT7.js +1 -0
- package/dist/ui/assets/SettingsView-Dur4dLhW.js +3 -0
- package/dist/ui/assets/SquisqIntegration-6v3yNOIP.js +2 -0
- package/dist/ui/assets/{StorageCleanupDialog-DHqwyMZZ.js → StorageCleanupDialog-OQlomMJD.js} +1 -1
- package/dist/ui/assets/{StorageUsageCard-CdT6SU51.js → StorageUsageCard-f6c6qTbM.js} +1 -1
- package/dist/ui/assets/Tabs-jE0Z5Tzd.js +1 -0
- package/dist/ui/assets/TaskTabContent-0w3kAUWR.js +1 -0
- package/dist/ui/assets/TasksView-BVMT4BAY.js +1 -0
- package/dist/ui/assets/{TerminalCodeEditor-77pBm6f3.js → TerminalCodeEditor-DO7zLKy-.js} +2 -2
- package/dist/ui/assets/ToolsetsEditor-Bb1wD5mV.js +8 -0
- package/dist/ui/assets/TransformToolbarButton-BWYkEB0d.js +5 -0
- package/dist/ui/assets/UnrecognizedModels-HtdMZUqK.js +1 -0
- package/dist/ui/assets/{VideoEngineSettings-DzMeINuv.js → VideoEngineSettings-Dq8Nw_tK.js} +1 -1
- package/dist/ui/assets/{WorkspaceIndexPane-DU4yd4Ai.js → WorkspaceIndexPane-fpDz4MwZ.js} +1 -1
- package/dist/ui/assets/{api-BX5xXiFs.js → api-BPraLwsh.js} +1 -1
- package/dist/ui/assets/chat-thread-memory-Be48zsyG.js +1 -0
- package/dist/ui/assets/chunk-6ECMNUIP-DDVjPyfK.js +15 -0
- package/dist/ui/assets/{chunk-6N2J7C2B-B5QIrD9m.js → chunk-6N2J7C2B-CsppiLVr.js} +1 -1
- package/dist/ui/assets/{chunk-A6N6IN3I-DXok09eC.js → chunk-A6N6IN3I-ofeM4l8g.js} +1 -1
- package/dist/ui/assets/chunk-B7GEAZBI-Divd2h1k.js +1 -0
- package/dist/ui/assets/chunk-DXYWKZ52-BXcAlClu.js +1 -0
- package/dist/ui/assets/chunk-FLR2ARKC-D7wrvQgT.js +2 -0
- package/dist/ui/assets/chunk-IIQYS2YH-DKZhWMpn.js +1 -0
- package/dist/ui/assets/{chunk-ILCJ3WFD-WRukZ7R1.js → chunk-ILCJ3WFD-CLZxw4Ge.js} +3 -3
- package/dist/ui/assets/chunk-OBADJV7C-CDVOcmYt.js +1 -0
- package/dist/ui/assets/chunk-Q77KNJIN-BIDRf0aP.js +6 -0
- package/dist/ui/assets/chunk-S5PCVMKU-Df5XzhSE.js +6 -0
- package/dist/ui/assets/chunk-UBFT2CDQ-FexGDigd.js +31 -0
- package/dist/ui/assets/{chunk-USU6HTKB-D5FmDzJU.js → chunk-USU6HTKB-B_p-YcDp.js} +1 -1
- package/dist/ui/assets/chunk-VKXOZTYP-BoVvWSBR.js +5 -0
- package/dist/ui/assets/{chunk-6RQOV3B3-CwvKotJw.js → chunk-VPWPEMZJ-DRKoa_j0.js} +1 -1
- package/dist/ui/assets/{chunk-WATAOG4Y-DXg2lov5.js → chunk-WATAOG4Y-C1EXVPmG.js} +1 -1
- package/dist/ui/assets/{container-B7jJtK5V.js → container-Ce94efbg.js} +1 -1
- package/dist/ui/assets/csv-62UGQMzZ.js +1 -0
- package/dist/ui/assets/data-B2kHjlc5.js +1 -0
- package/dist/ui/assets/dist-B9-VrAP8.js +2 -0
- package/dist/ui/assets/dist-BaHut5iX.js +2 -0
- package/dist/ui/assets/dist-BqGwkOe5.js +225 -0
- package/dist/ui/assets/dist-ZnIgkoEi.js +4 -0
- package/dist/ui/assets/{dist-BHl1ZAVG.js → dist-l6uUFZMV.js} +2 -2
- package/dist/ui/assets/dist-pLLFUPO-.js +1 -0
- package/dist/ui/assets/{doc-s6H7T0IO.js → doc-Dr5K49bx.js} +28 -28
- package/dist/ui/assets/document-companion-BQk2kS0F.js +1 -0
- package/dist/ui/assets/document-import-QoM9UxJr.js +1 -0
- package/dist/ui/assets/docx-sXa1Rf41.js +2 -0
- package/dist/ui/assets/{epub-B98SgHBz.js → epub-RopMP0ec.js} +4 -4
- package/dist/ui/assets/{export-options-Bu-tI6og.js → export-options-f7PKjEBb.js} +1 -1
- package/dist/ui/assets/extract-UTAOG7LV-4WDRw1o4.js +1 -0
- package/dist/ui/assets/file-browser-c2tf4MIb.js +5 -0
- package/dist/ui/assets/html-BGVOMhkv.js +253 -0
- package/dist/ui/assets/icons-DWaUNQbT.js +1 -0
- package/dist/ui/assets/images-JLBFCDD4-6JitW0hD.js +1 -0
- package/dist/ui/assets/index-B8NcxqcR.css +1 -0
- package/dist/ui/assets/index-C0DYtvfg.js +34 -0
- package/dist/ui/assets/index-J8TOMdvV.js +2 -0
- package/dist/ui/assets/{infer-kCLH1C8z.js → infer-LEGOsu64.js} +2 -2
- package/dist/ui/assets/ironcalc-BAi5gOlE.js +3 -0
- package/dist/ui/assets/layouts-2A7QNF6Y-CVwP7noP.js +1 -0
- package/dist/ui/assets/{mail-link-CI6YD6k2.js → mail-link-DXkmCd5b.js} +1 -1
- package/dist/ui/assets/markdown-baseline-9B52XlX2.js +1 -0
- package/dist/ui/assets/{markdown-Bi9b5f5Y.js → markdown-ryKA_OmY.js} +1 -1
- package/dist/ui/assets/materialize-A34OZGEU-xNNKzytx.js +1 -0
- package/dist/ui/assets/model-inventory-ykSm_IT5.js +1 -0
- package/dist/ui/assets/{model-quantization-BDzrELN_.js → model-quantization-CLO7XLoF.js} +1 -1
- package/dist/ui/assets/{monaco-base-BiVSa1J-.js → monaco-base-B1H1U1Sw.js} +1 -1
- package/dist/ui/assets/{monaco-setup-UeltVkg_.js → monaco-setup-DjhrGQui.js} +1 -1
- package/dist/ui/assets/{new-project-meta-0xhggGA_.js → new-project-meta-_f9sfcRX.js} +1 -1
- package/dist/ui/assets/outside-in-D73N1g_b.js +3 -0
- package/dist/ui/assets/{pdf-DgTjy3rN.js → pdf-BOjVDlCK.js} +3 -3
- package/dist/ui/assets/{pending-drafts-YVW6X55O.js → pending-drafts-B11MKQ9R.js} +1 -1
- package/dist/ui/assets/{poppetje-Ce-02Aqi.js → poppetje-DLB8uevw.js} +2 -2
- package/dist/ui/assets/pptx-BuxyNxQh.js +6 -0
- package/dist/ui/assets/primitives-CWrGZpPI.js +41 -0
- package/dist/ui/assets/run-export-ChaMXrKS.js +23 -0
- package/dist/ui/assets/squisq-formats-aAdypXoy.js +1 -0
- package/dist/ui/assets/standalone-source-q_Zzd1bd.js +11 -0
- package/dist/ui/assets/storage-D8pE2zg0.js +1 -0
- package/dist/ui/assets/styles-BhnF3s2q.css +1 -0
- package/dist/ui/assets/styles-CKVKwqoQ.js +550 -0
- package/dist/ui/assets/table-fcouR4db.js +1 -0
- package/dist/ui/assets/{terminal-monaco-setup-DNoK2tN4.js → terminal-monaco-setup-BAzrVzeR.js} +1 -1
- package/dist/ui/assets/{useCompactLayout-BarJPYcv.js → useCompactLayout-Dtolvzye.js} +0 -0
- package/dist/ui/assets/{useCopilotAvailability-BH1nLXQI.js → useCopilotAvailability-3xZvKgTF.js} +1 -1
- package/dist/ui/assets/{useDiffpacks-CK8W_OD_.js → useDiffpacks-Dsnr0wtX.js} +1 -1
- package/dist/ui/assets/{useGitSync-DWxX5-7K.js → useGitSync-BCTptQsp.js} +1 -1
- package/dist/ui/assets/{useShowWorkInProgressFeatures-DwwviLRO.js → useShowWorkInProgressFeatures-BhDNuQiU.js} +1 -1
- package/dist/ui/assets/{useTotalRamBytes-WoN_mi-V.js → useTotalRamBytes-DIx-_pf8.js} +1 -1
- package/dist/ui/assets/wasm-DdxEDD2H.js +1 -0
- package/dist/ui/assets/wasm_bg-DW9Xt_vt.wasm +0 -0
- package/dist/ui/assets/xlsx-DyBGuAO1.js +4 -0
- package/dist/ui/index.html +19 -18
- package/package.json +11 -11
- package/dist/ui/assets/AmbientDashboardCard-C1Ee-FKZ.js +0 -1
- package/dist/ui/assets/CatalogBrowser-Bz8ZtxPn.js +0 -1
- package/dist/ui/assets/ChatTimelineView-Do9EryEH.js +0 -7
- package/dist/ui/assets/ConfirmDialog-BHFs6vmJ.js +0 -1
- package/dist/ui/assets/ConnectedAppsPanel-BtMayq0R.js +0 -1
- package/dist/ui/assets/CraftbookEditor-D5jTzWwF.js +0 -1
- package/dist/ui/assets/DocumentDetail-CPU51d04.js +0 -1
- package/dist/ui/assets/DocumentsView-B6OyjvJ0.js +0 -1
- package/dist/ui/assets/DropdownMenu-D5fCzIrh.js +0 -1
- package/dist/ui/assets/Ds4Settings-CrUM_KGP.js +0 -1
- package/dist/ui/assets/EmbeddedChat-ue9ia-WY.js +0 -1
- package/dist/ui/assets/FileMapView-CxvfDLGA.js +0 -1
- package/dist/ui/assets/GezelDetail-DHuqBK55.js +0 -1
- package/dist/ui/assets/HandboekView-CPnnyj29.js +0 -1
- package/dist/ui/assets/HistoryView-B4VAfEMe.js +0 -1
- package/dist/ui/assets/HomeView-ccH60J6f.js +0 -1
- package/dist/ui/assets/KnowledgeCatalogsCard-Bi5Rx9Iz.js +0 -1
- package/dist/ui/assets/KnowledgeView-DAwjwLZo.js +0 -1
- package/dist/ui/assets/LlamaCppSettings-Ceyk9pDP.js +0 -1
- package/dist/ui/assets/MemoriesTree-BKZEPJpm.js +0 -1
- package/dist/ui/assets/MlxSettings-CG3wfuc3.js +0 -1
- package/dist/ui/assets/ModelPicker-CCBVjLMS.js +0 -1
- package/dist/ui/assets/NewPathDialog-D4jnNBfP.js +0 -1
- package/dist/ui/assets/NewTaskDialog-Ox9D612Z.js +0 -2
- package/dist/ui/assets/ProjectChat-DMwKnkW-.js +0 -5
- package/dist/ui/assets/ProjectGitStatusBar-C6bkCSby.js +0 -1
- package/dist/ui/assets/ProjectOverviewView-NNwXd_QQ.js +0 -1
- package/dist/ui/assets/ProjectsView-SBPgYOq8.js +0 -7
- package/dist/ui/assets/ScriptEditorTabs-paocQ6dj.js +0 -2
- package/dist/ui/assets/ScriptEditorView-N9zSLqqi.js +0 -5
- package/dist/ui/assets/SessionSwitcher-C8te7YSe.js +0 -1
- package/dist/ui/assets/SettingsView-Brl4JQkW.js +0 -3
- package/dist/ui/assets/Tabs-BAY1Q79B.js +0 -1
- package/dist/ui/assets/TaskTabContent-CNPJ4DQj.js +0 -1
- package/dist/ui/assets/TasksView-DuMjFS8S.js +0 -1
- package/dist/ui/assets/ToolsetsEditor-BdxHnIBj.js +0 -8
- package/dist/ui/assets/TransformToolbarButton-CVg5nz36.js +0 -5
- package/dist/ui/assets/UnrecognizedModels-Cw9Ku_bW.js +0 -1
- package/dist/ui/assets/chat-thread-memory-CZGcwgGo.js +0 -1
- package/dist/ui/assets/chunk-6ECMNUIP-C1kohb1U.js +0 -15
- package/dist/ui/assets/chunk-AONELFLA-Cv2nS9ga.js +0 -1
- package/dist/ui/assets/chunk-IIQYS2YH-Dxg6MAfT.js +0 -1
- package/dist/ui/assets/chunk-MIKKUKOD-XIkmalSN.js +0 -31
- package/dist/ui/assets/chunk-NNJLSQPW-DJA6camf.js +0 -5
- package/dist/ui/assets/chunk-S5PCVMKU-DbCZ5AUH.js +0 -6
- package/dist/ui/assets/csv-xmd1_Aqd.js +0 -4
- package/dist/ui/assets/dist-BPx-FyRH.js +0 -222
- package/dist/ui/assets/dist-Bvo52IGx.js +0 -1
- package/dist/ui/assets/dist-D5aoNQwk.js +0 -2
- package/dist/ui/assets/docx-Cj4A9MhC.js +0 -2
- package/dist/ui/assets/extract-UTAOG7LV-C4b7ycaL.js +0 -1
- package/dist/ui/assets/file-browser-80qWoVju.js +0 -5
- package/dist/ui/assets/html-C9TlzI57.js +0 -253
- package/dist/ui/assets/icons-C9dD-bDi.js +0 -1
- package/dist/ui/assets/images-ESPQKVTW-D7SgdVJ_.js +0 -1
- package/dist/ui/assets/index-D1m4Wx8V.css +0 -1
- package/dist/ui/assets/index-DXWR4qW1.js +0 -34
- package/dist/ui/assets/layouts-2A7QNF6Y-De2t-YXl.js +0 -1
- package/dist/ui/assets/markdown-baseline-HMqF2ChK.js +0 -1
- package/dist/ui/assets/outside-in-BFVUUcLa.js +0 -3
- package/dist/ui/assets/pptx-6ChgUEf4.js +0 -6
- package/dist/ui/assets/primitives-DEsn1shf.js +0 -41
- package/dist/ui/assets/run-export-BrYhHj1O.js +0 -23
- package/dist/ui/assets/standalone-source-D6mbpa3h.js +0 -11
- package/dist/ui/assets/storage-fn4FCEVK.js +0 -1
- package/dist/ui/assets/styles-C0EoNJbk.css +0 -1
- package/dist/ui/assets/styles-CKr_yrbn.js +0 -541
- package/dist/ui/assets/xlsx-DH7sTb3W.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{mt as r}from"./dist-BPx-FyRH.js";import{t as i}from"./api-BX5xXiFs.js";import{t as a}from"./model-context-DBqdK0PS.js";import{t as o}from"./ConfirmDialog-BHFs6vmJ.js";import{t as s}from"./CatalogBrowser-Bz8ZtxPn.js";import{t as c}from"./LicenseButton-D3VmcVG1.js";import{t as l}from"./TimeoutRow-B9SZiKH6.js";var u=e(t(),1),d=n(),f=1.2,p={"mix of experts":`Only a fraction of the model's parameters run per token, so it's faster than a dense model of the same nominal size. Gezels generally benefit from MoE models.`,moe:`Only a fraction of the model's parameters run per token, so it's faster than a dense model of the same nominal size. Gezels generally benefit from MoE models.`,thinking:`The model reasons through the problem step-by-step before answering. Slower, but generally more accurate on hard questions.`,agentic:`Tuned for multi-step agent workflows — tool use, planning, and iterating toward a goal.`,vision:`Can accept images alongside text.`,tools:`Supports function/tool calling via the API.`,multimodal:`Handles multiple input types (text + images).`,large:`Heavy model — needs a lot of memory and runs more slowly.`,small:`Compact model — runs quickly on modest hardware.`};function m(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${(e/1024**2).toFixed(0)} MB`:e>=1024?`${(e/1024).toFixed(0)} KB`:`${e} B`}function h(e){return e>=1024**3?`~${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`~${(e/1024**2).toFixed(0)} MB`:e>=1024?`~${(e/1024).toFixed(0)} KB`:`~${e} B`}function g(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`})}function _(e){return e.kind!==`chat-model`||!e.ollama?null:e}function v({enabled:e,onModelsChanged:t,compact:n=!1}){let[l,m]=(0,u.useState)([]),[v,b]=(0,u.useState)(null),[C,w]=(0,u.useState)(new Map),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(null),[k,A]=(0,u.useState)(null),[j,M]=(0,u.useState)(!1),[N,P]=(0,u.useState)(`all`),[F,I]=(0,u.useState)([]),L=(0,u.useRef)(C);L.current=C;let R=(0,u.useRef)(null);(0,u.useEffect)(()=>{let e=!1;return i.getMemoryProfile().then(t=>{e||A(t)}).catch(()=>{}),()=>{e=!0}},[]);let z=(0,u.useCallback)(async()=>{try{let e=await i.listProviderModels(`ollama`);m(e.models),b(null)}catch(e){b(e.message),m([])}},[]);(0,u.useEffect)(()=>{e&&z()},[e,z]),(0,u.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{try{let[{pulls:e},{models:n}]=await Promise.all([i.listPendingOllamaPulls(),i.listProviderModels(`ollama`)]);if(t)return;let r=new Set(n.map(e=>e.id));for(let t of e){if(r.has(t.name)){i.clearPendingOllamaPull(t.name).catch(()=>{});continue}L.current.has(t.name)||R.current?.(t.name)}}catch{}})(),()=>{t=!0}},[e]);let B=(0,u.useCallback)(async e=>{if(L.current.has(e))return;let n=new AbortController,r={name:e,status:`queued`,completed:0,total:0,controller:n};w(t=>new Map(t).set(e,r));try{await i.pullOllamaModel(e,t=>{if(t.type===`progress`){let n=t.chunk;w(t=>{let r=new Map(t),i=r.get(e);return i?(r.set(e,{...i,status:n.status,completed:n.completed??i.completed,total:n.total??i.total}),r):t})}else t.type===`error`&&w(n=>{let r=new Map(n),i=r.get(e);return i&&r.set(e,{...i,error:t.error}),r})},n.signal),setTimeout(()=>{w(t=>{let n=new Map(t);return n.delete(e),n}),z(),t?.(),(async()=>{try{let t=await i.getConfig();t.defaultModel?.ollama||await i.updateConfig({defaultModel:{...t.defaultModel,ollama:e}})}catch{}})()},900)}catch(t){if(n.signal.aborted){w(t=>{let n=new Map(t);return n.delete(e),n});return}w(n=>{let r=new Map(n),i=r.get(e);return i&&r.set(e,{...i,error:t.message}),r})}},[z,t]);R.current=B;let V=(0,u.useCallback)(e=>{L.current.get(e)?.controller.abort(),i.clearPendingOllamaPull(e).catch(()=>{})},[]),H=(0,u.useCallback)(async()=>{if(D)try{await i.deleteOllamaModel(D),await z(),t?.()}catch(e){b(e.message)}finally{O(null)}},[D,z,t]),U=(0,u.useMemo)(()=>new Set(l.map(e=>e.id)),[l]),W=(0,u.useMemo)(()=>{let e=new Set;for(let t of F){let n=_(t.manifest);n&&e.add(n.category??`general`)}return[`all`,...[`general`,`coding`,`reasoning`,`vision`,`embedding`].filter(t=>e.has(t))]},[F]),G=(0,u.useMemo)(()=>{if(!k)return new Set;let e=k.usableBytes,t=new Map;for(let n of F){let i=_(n.manifest);if(!i||r(i)||i.supportsTools===!1||i.approxSizeBytes*f>e)continue;let a=i.category??`general`;if(N!==`all`&&a!==N)continue;let o=t.get(a);(!o||i.approxSizeBytes>o.size)&&t.set(a,{tag:i.ollama.tag,size:i.approxSizeBytes})}return new Set([...t.values()].map(e=>e.tag))},[F,k,N]);return(0,d.jsxs)(`div`,{className:`ollama-model-manager`,children:[C.size>0&&(0,d.jsxs)(`div`,{className:`ollama-section`,children:[(0,d.jsx)(`h4`,{children:`Downloading…`}),(0,d.jsx)(`div`,{className:`ollama-pull-list`,children:Array.from(C.values()).map(e=>(0,d.jsx)(S,{pull:e,onCancel:()=>V(e.name)},e.name))})]}),(l.length>0||v)&&(0,d.jsxs)(`div`,{className:`ollama-section`,children:[(0,d.jsx)(`h4`,{children:n?`Models on this device`:`Local models`}),v&&(0,d.jsx)(`p`,{className:`error`,children:v}),l.length>0&&(0,d.jsxs)(`table`,{className:`ollama-model-table`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`th`,{children:`Name`}),(0,d.jsx)(`th`,{children:`Size`}),(0,d.jsx)(`th`,{title:`Effective per-turn context size Gezel sends to Ollama`,children:`Context size`}),(0,d.jsx)(`th`,{children:`Tools`}),(0,d.jsx)(`th`,{})]})}),(0,d.jsx)(`tbody`,{children:l.map(e=>(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`td`,{children:(0,d.jsx)(`code`,{children:e.id})}),(0,d.jsx)(`td`,{children:e.parameterSize??`—`}),(0,d.jsx)(`td`,{children:a(e.contextWindow)}),(0,d.jsx)(`td`,{children:e.supportsTools?(0,d.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok`,children:`✓`}):(0,d.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,children:`no`})}),(0,d.jsx)(`td`,{children:(0,d.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>O(e.id),children:`Delete`})})]},e.id))})]})]}),(0,d.jsxs)(`div`,{className:`ollama-section ollama-section--flat ollama-section--download`,children:[(0,d.jsx)(`h4`,{children:`Download a model`}),(0,d.jsx)(y,{memory:k,showAll:j,setShowAll:M}),(0,d.jsx)(x,{active:N,onChange:P,available:W}),(0,d.jsx)(s,{kind:`chat-model`,emptyMessage:`No model recommendations in the catalog yet.`,onItemsLoaded:I,tagTooltips:p,filter:e=>{let t=_(e.manifest);return!(!t||!j&&r(t)||N!==`all`&&(t.category??`general`)!==N||!j&&k&&t.approxSizeBytes*f>k.usableBytes)},action:t=>{let n=_(t.manifest);if(!n)return null;let r=n.ollama.tag,i=U.has(r),a=C.get(r),o=!!a,s=a&&a.total>0?Math.min(100,Math.round(a.completed/a.total*100)):null,l=k?n.approxSizeBytes*f>k.usableBytes:!1,u=G.has(r);return(0,d.jsxs)(`div`,{className:`catalog-ollama-action`,children:[(0,d.jsxs)(`div`,{className:`catalog-ollama-meta`,children:[(0,d.jsxs)(`div`,{className:`catalog-ollama-specs muted small`,children:[(0,d.jsx)(`code`,{children:r}),(0,d.jsx)(`span`,{children:`·`}),(0,d.jsx)(`span`,{children:n.parameterSize}),(0,d.jsx)(`span`,{children:`·`}),(0,d.jsx)(`span`,{children:h(n.approxSizeBytes)}),g(n.releasedAt)&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`span`,{children:`·`}),(0,d.jsx)(`span`,{children:g(n.releasedAt)})]})]}),(0,d.jsxs)(`div`,{className:`catalog-ollama-pills`,children:[(0,d.jsx)(c,{manifest:n,allowOllamaLink:!0}),u&&(0,d.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok`,title:`Largest model in this category that fits your device's memory budget — a good default.`,children:`★ recommended`}),l&&(0,d.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:`This model is larger than the memory Gezel estimates your device can dedicate to inference. It may run very slowly or fail to load.`,children:`may not fit`})]})]}),(0,d.jsx)(`button`,{type:`button`,disabled:i||o||!e,onClick:()=>void B(r),children:i?`On device`:o?s===null?`Downloading…`:`Downloading… ${s}%`:`Download`})]})}}),(0,d.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`},children:[(0,d.jsx)(`input`,{placeholder:`Or download by name: e.g. qwen2.5-coder:14b`,value:T,onChange:e=>E(e.target.value),style:{flex:1}}),(0,d.jsx)(`button`,{type:`button`,disabled:!T.trim()||C.has(T.trim())||!e,onClick:()=>{let e=T.trim();e&&(B(e),E(``))},children:`Download`})]})]}),(0,d.jsx)(o,{open:D!==null,title:`Delete model?`,message:D?`"${D}" will be removed from your device. This frees disk space, but you'll need to download it again to use it.`:``,confirmLabel:`Delete`,danger:!0,onCancel:()=>O(null),onConfirm:H})]})}function y({memory:e,showAll:t,setShowAll:n}){let r=e?m(e.usableBytes):null;return(0,d.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[r?`Models larger than your ~${r} budget, and retired models, are hidden by default. `:`Retired models are hidden by default. `,(0,d.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>n(!t),children:t?r?`Hide retired and oversized models`:`Hide retired models`:`Show all models`})]})}var b={all:`All`,general:`General`,coding:`Coding`,reasoning:`Reasoning`,vision:`Vision`,embedding:`Embedding`};function x({active:e,onChange:t,available:n}){return n.length<=1?null:(0,d.jsx)(`div`,{className:`ollama-category-tabs`,role:`tablist`,style:{display:`flex`,flexWrap:`wrap`,gap:`0.4rem`,margin:`0.5rem 0 0.75rem`},children:n.map(n=>(0,d.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===n,className:`provider-pill${e===n?` provider-pill-active`:``}`,onClick:()=>t(n),children:b[n]},n))})}function S({pull:e,onCancel:t}){let n=e.total>0,r=n?Math.min(100,Math.round(e.completed/e.total*100)):0,i=e.error?e.error:n?`Downloading… (${r}%)`:`${C(e.status)}…`;return(0,d.jsxs)(`div`,{className:`ollama-pull${e.error?` ollama-pull-error`:``}`,children:[(0,d.jsxs)(`div`,{className:`ollama-pull-head`,children:[(0,d.jsx)(`code`,{children:e.name}),(0,d.jsx)(`span`,{className:`muted small`,children:i}),(0,d.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:t,children:`Cancel`})]}),n?(0,d.jsxs)(`div`,{className:`ollama-pull-bar`,children:[(0,d.jsx)(`div`,{className:`ollama-pull-bar-fill`,style:{width:`${r}%`}}),(0,d.jsxs)(`span`,{className:`ollama-pull-bar-label`,children:[r,`%`]})]}):(0,d.jsx)(`div`,{className:`ollama-pull-bar ollama-pull-bar-indeterminate`,children:(0,d.jsx)(`div`,{className:`ollama-pull-bar-fill`})})]})}function C(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}function w({config:e,onConfigChanged:t}){let[n,r]=(0,u.useState)(e?.ollamaBaseUrl??``),[a,o]=(0,u.useState)({kind:`idle`}),[s,c]=(0,u.useState)(e?.ollamaNumCtx?String(e.ollamaNumCtx):``),[f,p]=(0,u.useState)(e?.ollamaStreamingIdleSec?String(e.ollamaStreamingIdleSec):``),[m,h]=(0,u.useState)(e?.ollamaPreFirstByteIdleSec?String(e.ollamaPreFirstByteIdleSec):``),[g,_]=(0,u.useState)(e?.ollamaTurnTimeoutMin?String(e.ollamaTurnTimeoutMin):``),[y,b]=(0,u.useState)(e?.ollamaNumPredict?String(e.ollamaNumPredict):``);(0,u.useEffect)(()=>{r(e?.ollamaBaseUrl??``)},[e?.ollamaBaseUrl]),(0,u.useEffect)(()=>{c(e?.ollamaNumCtx?String(e.ollamaNumCtx):``)},[e?.ollamaNumCtx]),(0,u.useEffect)(()=>{p(e?.ollamaStreamingIdleSec?String(e.ollamaStreamingIdleSec):``)},[e?.ollamaStreamingIdleSec]),(0,u.useEffect)(()=>{h(e?.ollamaPreFirstByteIdleSec?String(e.ollamaPreFirstByteIdleSec):``)},[e?.ollamaPreFirstByteIdleSec]),(0,u.useEffect)(()=>{_(e?.ollamaTurnTimeoutMin?String(e.ollamaTurnTimeoutMin):``)},[e?.ollamaTurnTimeoutMin]),(0,u.useEffect)(()=>{b(e?.ollamaNumPredict?String(e.ollamaNumPredict):``)},[e?.ollamaNumPredict]);let x=(0,u.useCallback)(async()=>{o({kind:`probing`});try{let t=await i.ollamaStatus();if(t.ok){o({kind:`ok`,baseUrl:t.baseUrl,modelCount:t.modelCount});return}if(e?.autoStartOllama!==!1&&(await i.ollamaStart()).started){let e=await i.ollamaStatus();if(e.ok){o({kind:`ok`,baseUrl:e.baseUrl,modelCount:e.modelCount});return}}o({kind:`fail`,baseUrl:t.baseUrl,error:t.error})}catch(e){o({kind:`fail`,error:e.message})}},[e?.autoStartOllama]),S=(0,u.useCallback)(async()=>{o({kind:`probing`});try{let e=await i.ollamaStart();e.started?await x():o({kind:`fail`,error:e.error??`Ollama did not start`})}catch(e){o({kind:`fail`,error:e.message})}},[x]),C=(0,u.useCallback)(async e=>{t(await i.updateConfig({autoStartOllama:e}))},[t]);(0,u.useEffect)(()=>{x()},[x,e?.ollamaBaseUrl]);let w=(0,u.useCallback)(async()=>{let e=n.trim();t(await i.updateConfig({ollamaBaseUrl:e||void 0})),await x()},[n,t,x]),E=(0,u.useCallback)(async()=>{let e=s.trim(),n=e?Number.parseInt(e,10):void 0;e&&(!Number.isFinite(n)||(n??0)<=0)||t(await i.updateConfig({ollamaNumCtx:n}))},[s,t]),D=(0,u.useCallback)(async()=>{let e=y.trim(),n=e?Number.parseInt(e,10):void 0;e&&(!Number.isFinite(n)||(n??0)<=0)||t(await i.updateConfig({ollamaNumPredict:n}))},[y,t]),O=(0,u.useCallback)(async(e,n)=>{let r=n.trim(),a=r?Number.parseInt(r,10):void 0;r&&(!Number.isFinite(a)||(a??0)<=0)||t(await i.updateConfig({[e]:a}))},[t]);return(0,d.jsxs)(`div`,{className:`ollama-settings`,children:[(0,d.jsx)(`h3`,{children:`Ollama (local models)`}),(0,d.jsxs)(`p`,{className:`muted`,style:{marginTop:0},children:[`Run models locally — no credentials, no traffic leaving the machine. Install`,` `,(0,d.jsx)(`code`,{children:`ollama serve`}),` and point gezel at it below.`]}),(0,d.jsxs)(`div`,{className:`ollama-section`,children:[(0,d.jsx)(`h4`,{children:`Server`}),(0,d.jsxs)(`div`,{className:`new-row`,children:[(0,d.jsx)(`input`,{placeholder:`http://localhost:11434`,value:n,onChange:e=>r(e.target.value),style:{flex:1}}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>void w(),disabled:n.trim()===(e?.ollamaBaseUrl??``),children:`Save`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>void x(),children:a.kind===`probing`?`Testing…`:`Test`}),a.kind===`fail`&&(0,d.jsx)(`button`,{type:`button`,onClick:()=>void S(),children:`Start Ollama`})]}),(0,d.jsx)(T,{status:a}),(0,d.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`0.5rem`,marginTop:`0.5rem`,fontSize:`0.85rem`},children:[(0,d.jsx)(`input`,{type:`checkbox`,checked:e?.autoStartOllama!==!1,onChange:e=>void C(e.target.checked)}),(0,d.jsx)(`span`,{children:`Automatically start Ollama when it's installed but not running.`})]})]}),(0,d.jsxs)(`div`,{className:`ollama-section`,children:[(0,d.jsx)(`h4`,{children:`Context window`}),(0,d.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`How much of the conversation the model can keep in mind at once. Ollama's own default is small and silently forgets older messages; Gezel picks a sensible size for each model. Set a value here to force one for every session (Ollama's `,(0,d.jsx)(`code`,{children:`num_ctx`}),`).`]}),(0,d.jsxs)(`div`,{className:`new-row`,children:[(0,d.jsx)(`input`,{type:`number`,min:1,placeholder:`e.g. 8192`,value:s,onChange:e=>c(e.target.value),style:{flex:1}}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>void E(),disabled:s.trim()===(e?.ollamaNumCtx?String(e.ollamaNumCtx):``),children:`Save`})]})]}),(0,d.jsxs)(`div`,{className:`ollama-section`,children:[(0,d.jsx)(`h4`,{children:`Response budget`}),(0,d.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`How much the model may write in a single reply. Ollama's own limit is so low that answers can get cut off before a word appears — Gezel raises it to a comfortable length. Raise it further if long replies get cut short (Ollama's `,(0,d.jsx)(`code`,{children:`num_predict`}),`).`]}),(0,d.jsxs)(`div`,{className:`new-row`,children:[(0,d.jsx)(`input`,{type:`number`,min:1,placeholder:`e.g. 4096`,value:y,onChange:e=>b(e.target.value),style:{flex:1}}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>void D(),disabled:y.trim()===(e?.ollamaNumPredict?String(e.ollamaNumPredict):``),children:`Save`})]})]}),(0,d.jsxs)(`div`,{className:`ollama-section`,children:[(0,d.jsx)(`h4`,{children:`Timeouts`}),(0,d.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`Local models on consumer hardware can take minutes for one turn — these caps decide when we give up. Two of them watch for `,(0,d.jsx)(`em`,{children:`silence`}),` (reset on activity); the third is a hard ceiling that ticks down regardless. Leave blank to use the defaults.`]}),(0,d.jsx)(l,{label:`Pre-first-byte cap`,unit:`seconds`,help:`Cold-start load + prompt prefill before the first visible token. Default 300s. Bump for big models with heavy system prompts or reasoning models that think silently before output.`,value:m,onChange:h,configValue:e?.ollamaPreFirstByteIdleSec,onSave:()=>void O(`ollamaPreFirstByteIdleSec`,m)}),(0,d.jsx)(l,{label:`Mid-stream silence cap`,unit:`seconds`,help:`How long the model can go silent mid-reply before we abort. Default 300s. Bump for reasoning models that pause between visible bursts. The 'wire pulse' dots in the chat tell you whether silence is real or just framing chunks.`,value:f,onChange:p,configValue:e?.ollamaStreamingIdleSec,onSave:()=>void O(`ollamaStreamingIdleSec`,f)}),(0,d.jsx)(l,{label:`Hard turn timeout`,unit:`minutes`,help:`Total wall-clock cap from when the model takes the slot to when it's done. Default 30m. Fires regardless of whether bytes are flowing — the backstop for runaway tool loops.`,value:g,onChange:_,configValue:e?.ollamaTurnTimeoutMin,onSave:()=>void O(`ollamaTurnTimeoutMin`,g)})]}),(0,d.jsx)(v,{enabled:a.kind===`ok`,onModelsChanged:()=>void x()})]})}function T({status:e}){return e.kind===`idle`||e.kind===`probing`?(0,d.jsx)(`p`,{className:`muted small`,children:`Checking…`}):e.kind===`ok`?(0,d.jsxs)(`p`,{className:`muted small`,children:[`✓ Reachable at `,(0,d.jsx)(`code`,{children:e.baseUrl}),` — `,e.modelCount,` model`,e.modelCount===1?``:`s`,` available locally.`]}):(0,d.jsxs)(`p`,{className:`error small`,title:e.error,children:[`Ollama isn't running at `,(0,d.jsx)(`code`,{children:e.baseUrl??`the configured address`}),` — press Start Ollama above to launch it.`]})}export{w as OllamaSettings};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{_t as r}from"./dist-BqGwkOe5.js";import{t as i}from"./api-BPraLwsh.js";import{t as a}from"./model-context-DBqdK0PS.js";import{t as o}from"./ConfirmDialog-Dt1ed4Fh.js";import{t as s}from"./CatalogBrowser-DEM9t7Es.js";import{t as c}from"./LicenseButton-D3VmcVG1.js";import{t as l}from"./TimeoutRow-B9SZiKH6.js";var u=e(t(),1),d=n(),f=1.2,p={"mix of experts":`Only a fraction of the model's parameters run per token, so it's faster than a dense model of the same nominal size. Gezels generally benefit from MoE models.`,moe:`Only a fraction of the model's parameters run per token, so it's faster than a dense model of the same nominal size. Gezels generally benefit from MoE models.`,thinking:`The model reasons through the problem step-by-step before answering. Slower, but generally more accurate on hard questions.`,agentic:`Tuned for multi-step agent workflows — tool use, planning, and iterating toward a goal.`,vision:`Can accept images alongside text.`,tools:`Supports function/tool calling via the API.`,multimodal:`Handles multiple input types (text + images).`,large:`Heavy model — needs a lot of memory and runs more slowly.`,small:`Compact model — runs quickly on modest hardware.`};function m(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${(e/1024**2).toFixed(0)} MB`:e>=1024?`${(e/1024).toFixed(0)} KB`:`${e} B`}function h(e){return e>=1024**3?`~${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`~${(e/1024**2).toFixed(0)} MB`:e>=1024?`~${(e/1024).toFixed(0)} KB`:`~${e} B`}function g(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`})}function _(e){return e.kind!==`chat-model`||!e.ollama?null:e}function v({enabled:e,onModelsChanged:t,compact:n=!1}){let[l,m]=(0,u.useState)([]),[v,b]=(0,u.useState)(null),[C,w]=(0,u.useState)(new Map),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(null),[k,A]=(0,u.useState)(null),[j,M]=(0,u.useState)(!1),[N,P]=(0,u.useState)(`all`),[F,I]=(0,u.useState)([]),L=(0,u.useRef)(C);L.current=C;let R=(0,u.useRef)(null);(0,u.useEffect)(()=>{let e=!1;return i.getMemoryProfile().then(t=>{e||A(t)}).catch(()=>{}),()=>{e=!0}},[]);let z=(0,u.useCallback)(async()=>{try{let e=await i.listProviderModels(`ollama`);m(e.models),b(null)}catch(e){b(e.message),m([])}},[]);(0,u.useEffect)(()=>{e&&z()},[e,z]),(0,u.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{try{let[{pulls:e},{models:n}]=await Promise.all([i.listPendingOllamaPulls(),i.listProviderModels(`ollama`)]);if(t)return;let r=new Set(n.map(e=>e.id));for(let t of e){if(r.has(t.name)){i.clearPendingOllamaPull(t.name).catch(()=>{});continue}L.current.has(t.name)||R.current?.(t.name)}}catch{}})(),()=>{t=!0}},[e]);let B=(0,u.useCallback)(async e=>{if(L.current.has(e))return;let n=new AbortController,r={name:e,status:`queued`,completed:0,total:0,controller:n};w(t=>new Map(t).set(e,r));try{await i.pullOllamaModel(e,t=>{if(t.type===`progress`){let n=t.chunk;w(t=>{let r=new Map(t),i=r.get(e);return i?(r.set(e,{...i,status:n.status,completed:n.completed??i.completed,total:n.total??i.total}),r):t})}else t.type===`error`&&w(n=>{let r=new Map(n),i=r.get(e);return i&&r.set(e,{...i,error:t.error}),r})},n.signal),setTimeout(()=>{w(t=>{let n=new Map(t);return n.delete(e),n}),z(),t?.(),(async()=>{try{let t=await i.getConfig();t.defaultModel?.ollama||await i.updateConfig({defaultModel:{...t.defaultModel,ollama:e}})}catch{}})()},900)}catch(t){if(n.signal.aborted){w(t=>{let n=new Map(t);return n.delete(e),n});return}w(n=>{let r=new Map(n),i=r.get(e);return i&&r.set(e,{...i,error:t.message}),r})}},[z,t]);R.current=B;let V=(0,u.useCallback)(e=>{L.current.get(e)?.controller.abort(),i.clearPendingOllamaPull(e).catch(()=>{})},[]),H=(0,u.useCallback)(async()=>{if(D)try{await i.deleteOllamaModel(D),await z(),t?.()}catch(e){b(e.message)}finally{O(null)}},[D,z,t]),U=(0,u.useMemo)(()=>new Set(l.map(e=>e.id)),[l]),W=(0,u.useMemo)(()=>{let e=new Set;for(let t of F){let n=_(t.manifest);n&&e.add(n.category??`general`)}return[`all`,...[`general`,`coding`,`reasoning`,`vision`,`embedding`].filter(t=>e.has(t))]},[F]),G=(0,u.useMemo)(()=>{if(!k)return new Set;let e=k.usableBytes,t=new Map;for(let n of F){let i=_(n.manifest);if(!i||r(i)||i.supportsTools===!1||i.approxSizeBytes*f>e)continue;let a=i.category??`general`;if(N!==`all`&&a!==N)continue;let o=t.get(a);(!o||i.approxSizeBytes>o.size)&&t.set(a,{tag:i.ollama.tag,size:i.approxSizeBytes})}return new Set([...t.values()].map(e=>e.tag))},[F,k,N]);return(0,d.jsxs)(`div`,{className:`ollama-model-manager`,children:[C.size>0&&(0,d.jsxs)(`div`,{className:`ollama-section`,children:[(0,d.jsx)(`h4`,{children:`Downloading…`}),(0,d.jsx)(`div`,{className:`ollama-pull-list`,children:Array.from(C.values()).map(e=>(0,d.jsx)(S,{pull:e,onCancel:()=>V(e.name)},e.name))})]}),(l.length>0||v)&&(0,d.jsxs)(`div`,{className:`ollama-section`,children:[(0,d.jsx)(`h4`,{children:n?`Models on this device`:`Local models`}),v&&(0,d.jsx)(`p`,{className:`error`,children:v}),l.length>0&&(0,d.jsxs)(`table`,{className:`ollama-model-table`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`th`,{children:`Name`}),(0,d.jsx)(`th`,{children:`Size`}),(0,d.jsx)(`th`,{title:`Effective per-turn context size Gezel sends to Ollama`,children:`Context size`}),(0,d.jsx)(`th`,{children:`Tools`}),(0,d.jsx)(`th`,{})]})}),(0,d.jsx)(`tbody`,{children:l.map(e=>(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`td`,{children:(0,d.jsx)(`code`,{children:e.id})}),(0,d.jsx)(`td`,{children:e.parameterSize??`—`}),(0,d.jsx)(`td`,{children:a(e.contextWindow)}),(0,d.jsx)(`td`,{children:e.supportsTools?(0,d.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok`,children:`✓`}):(0,d.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,children:`no`})}),(0,d.jsx)(`td`,{children:(0,d.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>O(e.id),children:`Delete`})})]},e.id))})]})]}),(0,d.jsxs)(`div`,{className:`ollama-section ollama-section--flat ollama-section--download`,children:[(0,d.jsx)(`h4`,{children:`Download a model`}),(0,d.jsx)(y,{memory:k,showAll:j,setShowAll:M}),(0,d.jsx)(x,{active:N,onChange:P,available:W}),(0,d.jsx)(s,{kind:`chat-model`,emptyMessage:`No model recommendations in the catalog yet.`,onItemsLoaded:I,tagTooltips:p,filter:e=>{let t=_(e.manifest);return!(!t||!j&&r(t)||N!==`all`&&(t.category??`general`)!==N||!j&&k&&t.approxSizeBytes*f>k.usableBytes)},action:t=>{let n=_(t.manifest);if(!n)return null;let r=n.ollama.tag,i=U.has(r),a=C.get(r),o=!!a,s=a&&a.total>0?Math.min(100,Math.round(a.completed/a.total*100)):null,l=k?n.approxSizeBytes*f>k.usableBytes:!1,u=G.has(r);return(0,d.jsxs)(`div`,{className:`catalog-ollama-action`,children:[(0,d.jsxs)(`div`,{className:`catalog-ollama-meta`,children:[(0,d.jsxs)(`div`,{className:`catalog-ollama-specs muted small`,children:[(0,d.jsx)(`code`,{children:r}),(0,d.jsx)(`span`,{children:`·`}),(0,d.jsx)(`span`,{children:n.parameterSize}),(0,d.jsx)(`span`,{children:`·`}),(0,d.jsx)(`span`,{children:h(n.approxSizeBytes)}),g(n.releasedAt)&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`span`,{children:`·`}),(0,d.jsx)(`span`,{children:g(n.releasedAt)})]})]}),(0,d.jsxs)(`div`,{className:`catalog-ollama-pills`,children:[(0,d.jsx)(c,{manifest:n,allowOllamaLink:!0}),u&&(0,d.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok`,title:`Largest model in this category that fits your device's memory budget — a good default.`,children:`★ recommended`}),l&&(0,d.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:`This model is larger than the memory Gezel estimates your device can dedicate to inference. It may run very slowly or fail to load.`,children:`may not fit`})]})]}),(0,d.jsx)(`button`,{type:`button`,disabled:i||o||!e,onClick:()=>void B(r),children:i?`On device`:o?s===null?`Downloading…`:`Downloading… ${s}%`:`Download`})]})}}),(0,d.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`},children:[(0,d.jsx)(`input`,{placeholder:`Or download by name: e.g. qwen2.5-coder:14b`,value:T,onChange:e=>E(e.target.value),style:{flex:1}}),(0,d.jsx)(`button`,{type:`button`,disabled:!T.trim()||C.has(T.trim())||!e,onClick:()=>{let e=T.trim();e&&(B(e),E(``))},children:`Download`})]})]}),(0,d.jsx)(o,{open:D!==null,title:`Delete model?`,message:D?`"${D}" will be removed from your device. This frees disk space, but you'll need to download it again to use it.`:``,confirmLabel:`Delete`,danger:!0,onCancel:()=>O(null),onConfirm:H})]})}function y({memory:e,showAll:t,setShowAll:n}){let r=e?m(e.usableBytes):null;return(0,d.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[r?`Models larger than your ~${r} budget, and retired models, are hidden by default. `:`Retired models are hidden by default. `,(0,d.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>n(!t),children:t?r?`Hide retired and oversized models`:`Hide retired models`:`Show all models`})]})}var b={all:`All`,general:`General`,coding:`Coding`,reasoning:`Reasoning`,vision:`Vision`,embedding:`Embedding`};function x({active:e,onChange:t,available:n}){return n.length<=1?null:(0,d.jsx)(`div`,{className:`ollama-category-tabs`,role:`tablist`,style:{display:`flex`,flexWrap:`wrap`,gap:`0.4rem`,margin:`0.5rem 0 0.75rem`},children:n.map(n=>(0,d.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===n,className:`provider-pill${e===n?` provider-pill-active`:``}`,onClick:()=>t(n),children:b[n]},n))})}function S({pull:e,onCancel:t}){let n=e.total>0,r=n?Math.min(100,Math.round(e.completed/e.total*100)):0,i=e.error?e.error:n?`Downloading… (${r}%)`:`${C(e.status)}…`;return(0,d.jsxs)(`div`,{className:`ollama-pull${e.error?` ollama-pull-error`:``}`,children:[(0,d.jsxs)(`div`,{className:`ollama-pull-head`,children:[(0,d.jsx)(`code`,{children:e.name}),(0,d.jsx)(`span`,{className:`muted small`,children:i}),(0,d.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:t,children:`Cancel`})]}),n?(0,d.jsxs)(`div`,{className:`ollama-pull-bar`,children:[(0,d.jsx)(`div`,{className:`ollama-pull-bar-fill`,style:{width:`${r}%`}}),(0,d.jsxs)(`span`,{className:`ollama-pull-bar-label`,children:[r,`%`]})]}):(0,d.jsx)(`div`,{className:`ollama-pull-bar ollama-pull-bar-indeterminate`,children:(0,d.jsx)(`div`,{className:`ollama-pull-bar-fill`})})]})}function C(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}function w({config:e,onConfigChanged:t}){let[n,r]=(0,u.useState)(e?.ollamaBaseUrl??``),[a,o]=(0,u.useState)({kind:`idle`}),[s,c]=(0,u.useState)(e?.ollamaNumCtx?String(e.ollamaNumCtx):``),[f,p]=(0,u.useState)(e?.ollamaStreamingIdleSec?String(e.ollamaStreamingIdleSec):``),[m,h]=(0,u.useState)(e?.ollamaPreFirstByteIdleSec?String(e.ollamaPreFirstByteIdleSec):``),[g,_]=(0,u.useState)(e?.ollamaTurnTimeoutMin?String(e.ollamaTurnTimeoutMin):``),[y,b]=(0,u.useState)(e?.ollamaNumPredict?String(e.ollamaNumPredict):``);(0,u.useEffect)(()=>{r(e?.ollamaBaseUrl??``)},[e?.ollamaBaseUrl]),(0,u.useEffect)(()=>{c(e?.ollamaNumCtx?String(e.ollamaNumCtx):``)},[e?.ollamaNumCtx]),(0,u.useEffect)(()=>{p(e?.ollamaStreamingIdleSec?String(e.ollamaStreamingIdleSec):``)},[e?.ollamaStreamingIdleSec]),(0,u.useEffect)(()=>{h(e?.ollamaPreFirstByteIdleSec?String(e.ollamaPreFirstByteIdleSec):``)},[e?.ollamaPreFirstByteIdleSec]),(0,u.useEffect)(()=>{_(e?.ollamaTurnTimeoutMin?String(e.ollamaTurnTimeoutMin):``)},[e?.ollamaTurnTimeoutMin]),(0,u.useEffect)(()=>{b(e?.ollamaNumPredict?String(e.ollamaNumPredict):``)},[e?.ollamaNumPredict]);let x=(0,u.useCallback)(async()=>{o({kind:`probing`});try{let t=await i.ollamaStatus();if(t.ok){o({kind:`ok`,baseUrl:t.baseUrl,modelCount:t.modelCount});return}if(e?.autoStartOllama!==!1&&(await i.ollamaStart()).started){let e=await i.ollamaStatus();if(e.ok){o({kind:`ok`,baseUrl:e.baseUrl,modelCount:e.modelCount});return}}o({kind:`fail`,baseUrl:t.baseUrl,error:t.error})}catch(e){o({kind:`fail`,error:e.message})}},[e?.autoStartOllama]),S=(0,u.useCallback)(async()=>{o({kind:`probing`});try{let e=await i.ollamaStart();e.started?await x():o({kind:`fail`,error:e.error??`Ollama did not start`})}catch(e){o({kind:`fail`,error:e.message})}},[x]),C=(0,u.useCallback)(async e=>{t(await i.updateConfig({autoStartOllama:e}))},[t]);(0,u.useEffect)(()=>{x()},[x,e?.ollamaBaseUrl]);let w=(0,u.useCallback)(async()=>{let e=n.trim();t(await i.updateConfig({ollamaBaseUrl:e||void 0})),await x()},[n,t,x]),E=(0,u.useCallback)(async()=>{let e=s.trim(),n=e?Number.parseInt(e,10):void 0;e&&(!Number.isFinite(n)||(n??0)<=0)||t(await i.updateConfig({ollamaNumCtx:n}))},[s,t]),D=(0,u.useCallback)(async()=>{let e=y.trim(),n=e?Number.parseInt(e,10):void 0;e&&(!Number.isFinite(n)||(n??0)<=0)||t(await i.updateConfig({ollamaNumPredict:n}))},[y,t]),O=(0,u.useCallback)(async(e,n)=>{let r=n.trim(),a=r?Number.parseInt(r,10):void 0;r&&(!Number.isFinite(a)||(a??0)<=0)||t(await i.updateConfig({[e]:a}))},[t]);return(0,d.jsxs)(`div`,{className:`ollama-settings`,children:[(0,d.jsx)(`h3`,{children:`Ollama (local models)`}),(0,d.jsxs)(`p`,{className:`muted`,style:{marginTop:0},children:[`Run models locally — no credentials, no traffic leaving the machine. Install`,` `,(0,d.jsx)(`code`,{children:`ollama serve`}),` and point gezel at it below.`]}),(0,d.jsxs)(`div`,{className:`ollama-section`,children:[(0,d.jsx)(`h4`,{children:`Server`}),(0,d.jsxs)(`div`,{className:`new-row`,children:[(0,d.jsx)(`input`,{placeholder:`http://localhost:11434`,value:n,onChange:e=>r(e.target.value),style:{flex:1}}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>void w(),disabled:n.trim()===(e?.ollamaBaseUrl??``),children:`Save`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>void x(),children:a.kind===`probing`?`Testing…`:`Test`}),a.kind===`fail`&&(0,d.jsx)(`button`,{type:`button`,onClick:()=>void S(),children:`Start Ollama`})]}),(0,d.jsx)(T,{status:a}),(0,d.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`0.5rem`,marginTop:`0.5rem`,fontSize:`0.85rem`},children:[(0,d.jsx)(`input`,{type:`checkbox`,checked:e?.autoStartOllama!==!1,onChange:e=>void C(e.target.checked)}),(0,d.jsx)(`span`,{children:`Automatically start Ollama when it's installed but not running.`})]})]}),(0,d.jsxs)(`div`,{className:`ollama-section`,children:[(0,d.jsx)(`h4`,{children:`Context window`}),(0,d.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`How much of the conversation the model can keep in mind at once. Ollama's own default is small and silently forgets older messages; Gezel picks a sensible size for each model. Set a value here to force one for every session (Ollama's `,(0,d.jsx)(`code`,{children:`num_ctx`}),`).`]}),(0,d.jsxs)(`div`,{className:`new-row`,children:[(0,d.jsx)(`input`,{type:`number`,min:1,placeholder:`e.g. 8192`,value:s,onChange:e=>c(e.target.value),style:{flex:1}}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>void E(),disabled:s.trim()===(e?.ollamaNumCtx?String(e.ollamaNumCtx):``),children:`Save`})]})]}),(0,d.jsxs)(`div`,{className:`ollama-section`,children:[(0,d.jsx)(`h4`,{children:`Response budget`}),(0,d.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`How much the model may write in a single reply. Ollama's own limit is so low that answers can get cut off before a word appears — Gezel raises it to a comfortable length. Raise it further if long replies get cut short (Ollama's `,(0,d.jsx)(`code`,{children:`num_predict`}),`).`]}),(0,d.jsxs)(`div`,{className:`new-row`,children:[(0,d.jsx)(`input`,{type:`number`,min:1,placeholder:`e.g. 4096`,value:y,onChange:e=>b(e.target.value),style:{flex:1}}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>void D(),disabled:y.trim()===(e?.ollamaNumPredict?String(e.ollamaNumPredict):``),children:`Save`})]})]}),(0,d.jsxs)(`div`,{className:`ollama-section`,children:[(0,d.jsx)(`h4`,{children:`Timeouts`}),(0,d.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`Local models on consumer hardware can take minutes for one turn — these caps decide when we give up. Two of them watch for `,(0,d.jsx)(`em`,{children:`silence`}),` (reset on activity); the third is a hard ceiling that ticks down regardless. Leave blank to use the defaults.`]}),(0,d.jsx)(l,{label:`Pre-first-byte cap`,unit:`seconds`,help:`Cold-start load + prompt prefill before the first visible token. Default 300s. Bump for big models with heavy system prompts or reasoning models that think silently before output.`,value:m,onChange:h,configValue:e?.ollamaPreFirstByteIdleSec,onSave:()=>void O(`ollamaPreFirstByteIdleSec`,m)}),(0,d.jsx)(l,{label:`Mid-stream silence cap`,unit:`seconds`,help:`How long the model can go silent mid-reply before we abort. Default 300s. Bump for reasoning models that pause between visible bursts. The 'wire pulse' dots in the chat tell you whether silence is real or just framing chunks.`,value:f,onChange:p,configValue:e?.ollamaStreamingIdleSec,onSave:()=>void O(`ollamaStreamingIdleSec`,f)}),(0,d.jsx)(l,{label:`Hard turn timeout`,unit:`minutes`,help:`Total wall-clock cap from when the model takes the slot to when it's done. Default 30m. Fires regardless of whether bytes are flowing — the backstop for runaway tool loops.`,value:g,onChange:_,configValue:e?.ollamaTurnTimeoutMin,onSave:()=>void O(`ollamaTurnTimeoutMin`,g)})]}),(0,d.jsx)(v,{enabled:a.kind===`ok`,onModelsChanged:()=>void x()})]})}function T({status:e}){return e.kind===`idle`||e.kind===`probing`?(0,d.jsx)(`p`,{className:`muted small`,children:`Checking…`}):e.kind===`ok`?(0,d.jsxs)(`p`,{className:`muted small`,children:[`✓ Reachable at `,(0,d.jsx)(`code`,{children:e.baseUrl}),` — `,e.modelCount,` model`,e.modelCount===1?``:`s`,` available locally.`]}):(0,d.jsxs)(`p`,{className:`error small`,title:e.error,children:[`Ollama isn't running at `,(0,d.jsx)(`code`,{children:e.baseUrl??`the configured address`}),` — press Start Ollama above to launch it.`]})}export{w as OllamaSettings};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalCodeEditor-DO7zLKy-.js","assets/rolldown-runtime-aKtaBQYM.js","assets/jsx-runtime-CEpd2cAX.js","assets/preload-helper-Czpn1I53.js","assets/index-C0DYtvfg.js","assets/react-dom-OL4w_gzs.js","assets/dist-BqGwkOe5.js","assets/dist-BaHut5iX.js","assets/api-BPraLwsh.js","assets/primitives-CWrGZpPI.js","assets/Tabs-jE0Z5Tzd.js","assets/document-companion-BQk2kS0F.js","assets/DropdownMenu-S4d9-3j3.js","assets/dist-pLLFUPO-.js","assets/relative-time-B2kBaekd.js","assets/FileTypeIcon-Cwzl1GkZ.js","assets/model-context-DBqdK0PS.js","assets/model-memory-copy-CeuXAj-T.js","assets/StorageCleanupDialog-OQlomMJD.js","assets/poppetje-DLB8uevw.js","assets/safe-svg-image-NbuPaBIv.js","assets/ConfirmDialog-Dt1ed4Fh.js","assets/model-inventory-ykSm_IT5.js","assets/doc-Dr5K49bx.js","assets/chunk-O7JILDEF-CqcO1qaI.js","assets/chunk-BAOV476U-CEOFYt8X.js","assets/chunk-4VOD55SX-BFSSw0c8.js","assets/chunk-GAZKTT4R-BkP6-w3z.js","assets/chunk-UBFT2CDQ-FexGDigd.js","assets/chunk-XRW6P7IF-BeQQgMVK.js","assets/chunk-7ZAAICW4-BsCpYJH6.js","assets/markdown-ryKA_OmY.js","assets/schemas-JY4jmLbC.js","assets/chunk-6ECMNUIP-DDVjPyfK.js","assets/inlineIconMarker-BQI2HLeD.js","assets/chunk-TT6ENR6T-CaYjVwjm.js","assets/chunk-DAMIRKTO-CGniCSiM.js","assets/new-project-meta-_f9sfcRX.js","assets/chunk-AE3IUKMM-mZjzzO8Z.js","assets/index-B8NcxqcR.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{Gt as r,V as i,at as a,lt as o,yn as s}from"./dist-BqGwkOe5.js";import{t as c}from"./api-BPraLwsh.js";import{_ as l,g as u,o as d,v as f,y as p}from"./primitives-CWrGZpPI.js";import{a as m,i as h,n as g,s as _,t as v}from"./DropdownMenu-S4d9-3j3.js";import{n as y,t as b}from"./relative-time-B2kBaekd.js";import{t as x}from"./preload-helper-Czpn1I53.js";import{A as S,C,It as w,dt as T,j as E,p as D,r as O,ut as k,zt as A}from"./index-C0DYtvfg.js";import{t as j}from"./NewTaskDialog-Cyqtmigv.js";import{t as M}from"./useShowWorkInProgressFeatures-BhDNuQiU.js";import{i as N,n as P,r as F}from"./ChatTimelineView-CQ4Sf4Ip.js";import{a as I,i as L,t as ee}from"./SessionSwitcher-6okzcxT7.js";import{n as te,t as ne}from"./ProjectTimeline-BZpdCisR.js";import{a as re,c as ie,i as ae,l as oe,o as se,s as ce,u as R}from"./chat-thread-memory-Be48zsyG.js";import{r as le,t as z}from"./completion-data--97asQiQ.js";var B=e(t(),1),V=[/<function=([a-zA-Z_][a-zA-Z0-9_]*)/,/<invoke\s+name="([a-zA-Z_][a-zA-Z0-9_]*)/,/"(?:tool|name|function)"\s*:\s*"([a-zA-Z_][a-zA-Z0-9_]*)"/],H=/<function[=\s>]|<tool_call>|<invoke[\s>]|<parameter[=\s]|<\|tool_call\|>/i,U=/<\/?think>|<\|?channel\|?>|(?:^|\n)(?:thought|analysis|commentary)\|/i,W=/!\[[^\]]*\]\(/,ue=/<think>(?![\s\S]*<\/think>)/i,G=/\{\s*"(?:tool|name|function)"\s*:\s*"[a-zA-Z_][a-zA-Z0-9_]*"/g;function de(e){if(!e.includes(`{`))return e;let t=``,n=0;G.lastIndex=0;for(let r=G.exec(e);r;r=G.exec(e)){if(r.index<n)continue;let i=0,a=!1,o=!1,s=-1;for(let t=r.index;t<e.length;t++){let n=e[t];if(o)o=!1;else if(n===`\\`&&a)o=!0;else if(n===`"`)a=!a;else if(!a&&n===`{`)i++;else if(!a&&n===`}`&&(i--,i===0)){s=t+1;break}}t+=e.slice(n,r.index),n=s===-1?e.length:s,G.lastIndex=n}return t+e.slice(n)}function K(e){return e.replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/@\[([^\]]+)\]\([^)]+\)/g,`@$1`).replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`).replace(/[*_~`#>]+/g,``).replace(/\s+/g,` `).trim()}function fe(e){let t=E(e);if(t.length>0)return{name:t[0].name,trusted:!0};for(let t of V){let n=e.match(t);if(n?.[1])return{name:n[1],trusted:!1}}return null}function q(e){if(!e)return``;let t=a(e);if(t)return t;let n=e.search(ue),r=n===-1?e:e.slice(0,n),i=K(de(S(r,{hideMidStreamOpener:!0})));if(i)return i;let o=fe(r);return o&&(o.trusted||k(o.name))?`${T(o.name)}…`:o||H.test(r)?`Using a tool…`:U.test(e)?`Thinking…`:W.test(r)?`Shared an image`:``}function J(e,t){let n=(0,B.useRef)(new Map),r=(0,B.useRef)(new Set),[i,a]=(0,B.useState)(0),o=(0,B.useMemo)(()=>[...new Set(e)].sort().join(`
|
|
3
|
+
`),[e]);return(0,B.useEffect)(()=>{for(let[e,t]of[...n.current])t||n.current.delete(e)},[t]),(0,B.useEffect)(()=>{let e=(o?o.split(`
|
|
4
|
+
`):[]).filter(e=>!n.current.has(e)&&!r.current.has(e));if(e.length===0)return;let t=!1;for(let t of e)r.current.add(t);return Promise.all(e.map(async e=>{try{let t=await c.getTaskByRef(e);n.current.set(e,t.status===`complete`||t.status===`canceled`)}catch{n.current.set(e,!1)}finally{r.current.delete(e)}})).then(()=>{t||a(e=>e+1)}),()=>{t=!0}},[o,t]),(0,B.useMemo)(()=>{let e=o?o.split(`
|
|
5
|
+
`):[];return new Set(e.filter(e=>n.current.get(e)===!0))},[o,i])}var Y=750,pe=2e4,me={inflight:0,errored:1,idle:2};function X(e){let t=Date.parse(e);return Number.isNaN(t)?0:t}function he(e){let t=e.replace(/\s+/g,` `).trim(),n=``;for(let e of t){if(n.length+e.length>200)break;n+=e}return n}function ge(e,t,n){let r=!1,i=e.map(e=>{if(e.id!==t)return e;r=!0;let i=new Set(e.involvedGezelIds??[e.gezelId]);n.from&&i.add(n.from.gezelId);let a=he(n.content);return{...e,lastActivityAt:n.at,involvedGezelIds:[...i],...a?{lastMessagePreview:a}:{}}});return r?i:null}function _e(e){let{sessions:t,inflight:n,errored:r,now:i,pinnedSessionId:a,groupedTaskRefs:o,finishedTaskRefs:s,liveTools:c,maxInline:l=6}=e,u=[],d=new Map,f=t.filter(e=>!e.archived&&!e.taskRef).reduce((e,t)=>!e||X(t.lastActivityAt)>X(e.lastActivityAt)?t:e,null)?.id;for(let e of t){if(e.archived)continue;let t=r.get(e.id)??e.lastTurnError,l=n.has(e.id)?`inflight`:t?`errored`:`idle`,p=l===`inflight`?c?.get(e.id):void 0,m={sessionId:e.id,gezelId:e.gezelId,title:I(L(e.title)),lastActivityAt:e.lastActivityAt,state:l,involvedGezelIds:e.involvedGezelIds&&e.involvedGezelIds.length>0?e.involvedGezelIds:[e.gezelId],...e.lastMessagePreview?{lastMessagePreview:e.lastMessagePreview}:{},...p?{liveToolName:p}:{},...e.taskRef?{taskRef:e.taskRef}:{},...t?{error:t}:{}};if(e.taskRef&&o?.has(e.taskRef)){let t=d.get(e.taskRef);(!t||X(m.lastActivityAt)>X(t.lastActivityAt))&&d.set(e.taskRef,m);continue}let h=a!==void 0&&e.id===a;if(l===`idle`&&!h&&e.taskRef&&s?.has(e.taskRef))continue;let g=e.id===f;l===`idle`&&!h&&!g&&i-X(e.lastActivityAt)>864e5||u.push(m)}u.sort((e,t)=>{let n=me[e.state]-me[t.state];return n===0?X(t.lastActivityAt)-X(e.lastActivityAt):n});let p=u.filter(e=>e.state!==`idle`).length,m=Math.max(l,p);for(let e of[a,f]){if(e===void 0)continue;let t=u.findIndex(t=>t.sessionId===e);t>=m&&(m=t+1)}return{pills:u.slice(0,m),overflow:u.slice(m),taskPills:d}}function ve({projectId:e,gezelId:t,pinnedSessionId:n,groupedTaskRefs:r,refreshKey:i}){let[a,o]=(0,B.useState)([]),s=(0,B.useRef)([]),[l,u]=(0,B.useState)(!0),[d,f]=(0,B.useState)(()=>new Set),[p,m]=(0,B.useState)(()=>new Map),[h,g]=(0,B.useState)(()=>new Map),[_,v]=(0,B.useState)(0),y=(0,B.useCallback)(async()=>{try{let n=await c.listChatSessions({projectId:e,...t?{gezelId:t}:{}});s.current=n.sessions,o(n.sessions)}catch{}finally{u(!1)}},[e,t]),b=(0,B.useCallback)(async()=>{try{let{inflight:n}=await c.listInflightTurns({projectId:e,...t?{gezelId:t}:{}});f(new Set(n.map(e=>e.sessionId)))}catch{}},[e,t]);(0,B.useEffect)(()=>{u(!0),y(),b()},[y,b,i,n]),(0,B.useEffect)(()=>{let e=window.setInterval(()=>void b(),pe);return()=>window.clearInterval(e)},[b]),(0,B.useEffect)(()=>{let e=window.setInterval(()=>v(e=>e+1),6e4);return()=>window.clearInterval(e)},[]),(0,B.useEffect)(()=>{let e=()=>void y();return window.addEventListener(`gezel:session-error-cleared`,e),()=>window.removeEventListener(`gezel:session-error-cleared`,e)},[y]);let x=(0,B.useCallback)((e,t)=>{g(n=>{if(t===null){if(!n.has(e))return n;let t=new Map(n);return t.delete(e),t}if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})},[]),S=(0,B.useRef)(null);(0,B.useEffect)(()=>{let n=new AbortController,r=()=>{S.current!==null&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{S.current=null,y()},Y)};return(async()=>{try{for await(let i of A({url:c.projectEventsUrl(e),headers:c.authHeader(),signal:n.signal,fetch:c.getFetch()})){let{event:e,sessionId:n}=i;if(!(t&&i.gezelId!==t)){if(e.type===`tool_args_delta`||e.type===`tool`?x(n,e.name):(e.type===`complete`||e.type===`done`||e.type===`error`||e.type===`cancelled`)&&x(n,null),e.type===`user_message`){f(e=>{if(e.has(n))return e;let t=new Set(e);return t.add(n),t});let t=ge(s.current,n,e.message);t?(s.current=t,o(t)):y()}else(e.type===`done`||e.type===`error`||e.type===`cancelled`)&&f(e=>{if(!e.has(n))return e;let t=new Set(e);return t.delete(n),t});if(e.type===`error`)m(t=>{let r=new Map(t);return r.set(n,e.error),r});else if(e.type===`complete`){let t=ge(s.current,n,e.message);t&&(s.current=t,o(t)),m(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})}(e.type===`done`||e.type===`complete`)&&r()}}}catch{}})(),()=>{n.abort(),S.current!==null&&(window.clearTimeout(S.current),S.current=null)}},[e,t,y,x]);let C=J((0,B.useMemo)(()=>{let e=new Set;for(let t of a)t.archived||!t.taskRef||r?.has(t.taskRef)||e.add(t.taskRef);return[...e]},[a,r]),i),{pills:w,overflow:T,taskPills:E}=(0,B.useMemo)(()=>_e({sessions:a,inflight:d,errored:p,now:Date.now(),pinnedSessionId:n,liveTools:h,finishedTaskRefs:C,...r?{groupedTaskRefs:r}:{}}),[a,d,p,h,n,r,C,_]);return{pills:w,overflow:T,taskPills:E,loading:l}}var Z=n(),ye=1440*60*1e3;function be(e){let t=Date.parse(e);return Number.isNaN(t)?0:t}function xe({projectId:e,gezelId:t,gezels:n,activeSessionId:r,activeTaskRef:a,activeTerminalThreadId:o,onFocusThread:s,onFocusTask:l,onFocusTerminal:u,onNewTask:d,refreshKey:f,terminalRefreshKey:p}){let{tasks:y,loading:b}=te({projectId:e,refreshKey:f}),{pills:x,overflow:S,taskPills:w,loading:T}=ve({projectId:e,gezelId:t,pinnedSessionId:r,groupedTaskRefs:(0,B.useMemo)(()=>new Set(y.map(e=>e.ref)),[y]),refreshKey:f}),[E,D]=(0,B.useState)([]),O=u!==void 0;(0,B.useEffect)(()=>{if(!O){D([]);return}let t=!1;return c.listTerminalThreads(e).then(e=>{if(t)return;let n=Date.now()-ye;D(e.threads.filter(e=>!e.archived&&be(e.lastActivityAt)>=n))}).catch(()=>{}),()=>{t=!0}},[e,O,p]);let k=(0,B.useMemo)(()=>E.filter(t=>t.projectId===e),[E,e]),A=C(),j=e=>{let t=n.find(t=>t.id===e);return t?i({name:t.name,roleBasedName:t.roleBasedName},A):`someone`},M=e=>[...new Set(e.involvedGezelIds.map(j))].join(`, `),N=[...x,...w.values()],P=N.filter(e=>e.state===`inflight`).length,F=N.filter(e=>e.state===`errored`).length,I=[P>0?`${P} ${P===1?`thread`:`threads`} working`:``,F>0?`${F} needs attention`:``].filter(Boolean).join(`, `),L=!(b||T)&&x.length===0&&k.length===0&&y.length===0,{scrollRef:ee,overflowBar:ne}=Se(x.length+S.length+k.length+y.length+ +!!L);return(0,Z.jsxs)(`div`,{className:`chat-pill-row`,role:`toolbar`,"aria-label":`Threads, terminal windows, and tasks`,children:[(0,Z.jsx)(`output`,{className:`sr-only`,children:I}),(0,Z.jsxs)(`div`,{className:`chat-pill-row-scroller`,children:[(0,Z.jsxs)(`div`,{className:`chat-pill-row-scroll`,ref:ee,onScroll:ne.onScroll,children:[L&&(0,Z.jsx)(`span`,{className:`chat-pill-row-empty muted small`,children:`No recent threads`}),y.map(e=>{let t=w.get(e.ref);return(0,Z.jsx)(Ae,{task:e,latestThread:t,gezels:n,gezelNames:t?M(t):e.assignee.kind===`gezel`?j(e.assignee.gezelId):`You`,active:e.ref===a,onFocus:l},e.ref)}),x.map(e=>(0,Z.jsx)(we,{pill:e,gezels:n,gezelNames:M(e),active:e.sessionId===r,onFocus:s},e.sessionId)),S.length>0&&(0,Z.jsxs)(m,{children:[(0,Z.jsxs)(_,{className:`chat-pill chat-pill-overflow`,children:[`+`,S.length,` more`]}),(0,Z.jsx)(h,{children:(0,Z.jsx)(v,{className:`chat-rail-section-tab-menu chat-pill-overflow-menu`,align:`start`,sideOffset:4,children:S.map(e=>(0,Z.jsx)(g,{onSelect:()=>s(e),className:`chat-pill-overflow-item chat-pill-${e.state}`,children:(0,Z.jsx)(Te,{pill:e,gezelNames:M(e)})},e.sessionId))})})]}),u&&k.map(e=>(0,Z.jsx)(Ce,{thread:e,active:e.id===o,onFocus:u},e.id))]}),ne.node]}),d&&(0,Z.jsx)(`button`,{type:`button`,className:`chat-pill-new-task`,onClick:d,"aria-label":`New task`,title:`New task — pick a craftbook`,children:`Do +`})]})}function Se(e){let t=(0,B.useRef)(null),[n,r]=(0,B.useState)(null),i=(0,B.useCallback)(()=>{let e=t.current;if(!e)return;let{scrollWidth:n,clientWidth:i,scrollLeft:a}=e;if(n-i<2){r(e=>e===null?e:null);return}let o=i/n,s=a/n;r(e=>e&&Math.abs(e.left-s)<5e-4&&Math.abs(e.width-o)<5e-4?e:{left:s,width:o})},[]);return(0,B.useEffect)(()=>{i()},[i,e]),(0,B.useEffect)(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>i());return n.observe(e),()=>n.disconnect()},[i]),{scrollRef:t,overflowBar:{onScroll:i,node:n&&(0,Z.jsx)(`div`,{className:`chat-pill-row-bar`,"aria-hidden":`true`,onPointerDown:e=>{let r=t.current;if(!r||!n)return;let i=e.currentTarget.getBoundingClientRect(),a=(e.clientX-i.left)/i.width<n.left?-r.clientWidth:r.clientWidth;r.scrollBy({left:a,behavior:`smooth`})},children:(0,Z.jsx)(`div`,{className:`chat-pill-row-bar-thumb`,style:{left:`${n.left*100}%`,width:`${n.width*100}%`},onPointerDown:e=>{let n=t.current,r=e.currentTarget.parentElement;if(!n||!r)return;e.preventDefault(),e.stopPropagation();let i=n.scrollWidth/r.clientWidth,a=e.clientX,o=n.scrollLeft,s=e=>{n.scrollLeft=o+(e.clientX-a)*i},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c)}})})}}}function Ce({thread:e,active:t,onFocus:n}){let r=F(e.workingDir),i=$(e.lastActivityAt),a=e.lastCommand?.replace(/\s+/g,` `).trim()||null,o=a?Q(a,40):null;return(0,Z.jsxs)(`button`,{type:`button`,className:`chat-pill chat-pill-thread chat-pill-terminal${t?` is-active`:``}`,"aria-pressed":t,"aria-label":`Terminal ${r}.${a?` Last command: ${a}.`:``} Updated ${i}`,title:`Terminal · ${r}${a?` · last command: ${a}`:``} · updated ${i}`,onClick:()=>n(e),children:[(0,Z.jsx)(`span`,{className:`chat-pill-thread-line chat-pill-thread-title`,children:`Terminal`}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-context`,children:[(0,Z.jsx)(`span`,{className:`terminal-prompt-sigil`,"aria-hidden":`true`,children:`>`}),(0,Z.jsx)(`span`,{className:`chat-pill-message-preview${a?` chat-pill-terminal-command`:``}`,children:o??r})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-update`,children:[a&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`chat-pill-terminal-folder`,children:r}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-updated-at`,title:b(e.lastActivityAt),children:[`Updated `,i]})]})]})}function we({pill:e,gezels:t,gezelNames:n,active:r,onFocus:i}){let a=t.find(t=>t.id===e.gezelId),o=$(e.lastActivityAt),s=ke(e.state),c=Oe(e),l=`${n} · ${e.title} · updated ${o} · ${s}${e.error?`: ${e.error}`:``}`;return(0,Z.jsx)(`button`,{type:`button`,className:`chat-pill chat-pill-thread chat-pill-${e.state}${r?` is-active`:``}`,"aria-pressed":r,"aria-label":`${n}: ${e.title}. ${c}. Updated ${o}. ${s}`,title:l,onClick:()=>i(e),children:(0,Z.jsx)(Te,{pill:e,gezelNames:n,gezel:a})})}function Te({pill:e,gezelNames:t,gezel:n}){let r=Oe(e);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`chat-pill-thread-line chat-pill-thread-title`,children:Q(e.title,40)}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-context`,children:[n&&(0,Z.jsx)(w,{svg:n.icon??null,poppetje:n.poppetje,iconOverride:n.iconOverride,name:t,size:14}),(0,Z.jsx)(`span`,{className:`chat-pill-participants`,children:t}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`}),(0,Z.jsx)(`span`,{className:`chat-pill-message-preview`,children:r})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-update`,children:[(0,Z.jsxs)(`span`,{className:`chat-pill-thread-updated-at`,title:b(e.lastActivityAt),children:[`Updated `,$(e.lastActivityAt)]}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-status`,children:[(0,Z.jsx)(`span`,{className:`chat-pill-dot`,"aria-hidden":`true`}),ke(e.state)]})]})]})}var Ee=30,De=34;function Oe(e){if(e.state===`inflight`&&e.liveToolName)return Q(`${T(e.liveToolName)}…`,De);let t=e.lastMessagePreview?q(e.lastMessagePreview):``;return t?Q(t,Ee):`No messages yet`}function Q(e,t){let n=Array.from(e.trim());return n.length<=t?n.join(``):`${n.slice(0,t-1).join(``)}…`}function ke(e){return e===`inflight`?`Working`:e===`errored`?`Needs attention`:`Ready`}function $(e){return y(e,{style:`long`,fallback:e})}function Ae({task:e,latestThread:t,gezels:n,gezelNames:r,active:i,onFocus:a}){let o=e.assignee.kind===`user`,s=e.assignee.kind===`gezel`?e.assignee.gezelId:null,c=t?n.find(e=>e.id===t.gezelId):s?n.find(e=>e.id===s):void 0,l=t?$(t.lastActivityAt):null,u=t?ke(t.state):`Active`,d=t?Oe(t):`No chat yet`,f=t?`Latest chat with ${r}: ${t.title}. ${d}. Updated ${l}. ${u}`:`${d}. Assigned to ${r}. ${u}`;return(0,Z.jsxs)(`button`,{type:`button`,className:`chat-pill chat-pill-thread chat-pill-task${t?` chat-pill-${t.state}`:``}${i?` is-active`:``}`,"aria-pressed":i,"aria-label":`Task ${e.ref}: ${e.title}. ${f}`,title:t?`${e.ref} · ${e.title} · latest chat: ${t.title} · ${r} · updated ${l} · ${u}${t.error?`: ${t.error}`:``}`:o?`${e.ref} · ${e.title} — assigned to you · no chat yet`:`${e.ref} · ${e.title} · no chat yet`,onClick:()=>a(e),children:[(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-task-title`,children:[(0,Z.jsx)(D,{area:`tasks`,size:13,className:`chat-pill-task-icon`}),(0,Z.jsxs)(`span`,{className:`chat-pill-task-number`,children:[`#`,e.num]}),(0,Z.jsx)(`span`,{className:`chat-pill-label`,children:e.title})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-context`,children:[c&&(0,Z.jsx)(w,{svg:c.icon??null,poppetje:c.poppetje,iconOverride:c.iconOverride,name:r,size:14}),(0,Z.jsx)(`span`,{className:`chat-pill-participants`,children:r}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`}),(0,Z.jsx)(`span`,{className:`chat-pill-message-preview`,children:d})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-update`,children:[(0,Z.jsx)(`span`,{className:`chat-pill-thread-updated-at`,title:t?b(t.lastActivityAt):void 0,children:l?`Updated ${l}`:e.ref}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-status`,children:[t?(0,Z.jsx)(`span`,{className:`chat-pill-dot`,"aria-hidden":`true`}):(0,Z.jsx)(`span`,{className:`task-status-dot task-status-active`,"aria-hidden":`true`}),u]})]})]})}function je({projectId:e,workingDir:t,onChangeWorkingDir:n}){let[r,i]=(0,B.useState)([]),[a,o]=(0,B.useState)(null),[s,l]=(0,B.useState)(!1),u=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(!s&&r.length>0)return;let t=!1;return(async()=>{try{let n=await c.listProjectWorkspace(e,void 0,!0);if(t)return;let r=n.files.filter(e=>e.isDirectory).map(e=>{let t=e.path.split(`/`).length-1;return{path:e.path,name:e.name,depth:t}});r.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path)),i(r)}catch(e){if(t)return;o(e instanceof Error?e.message:String(e))}})(),()=>{t=!0}},[e,s]),(0,B.useEffect)(()=>{if(!s)return;function e(e){u.current?.contains(e.target)||l(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[s]);let d=(0,B.useMemo)(()=>[{path:``,name:`/`,depth:0},...r],[r]),f=F(t);return(0,Z.jsxs)(`div`,{className:`folder-tree-switcher`,ref:u,children:[(0,Z.jsx)(`span`,{className:`folder-tree-label`,children:`Folder:`}),(0,Z.jsxs)(`button`,{type:`button`,className:`folder-tree-trigger`,onClick:()=>l(e=>!e),title:`Pick a working folder`,"aria-expanded":s,children:[(0,Z.jsx)(`span`,{className:`folder-tree-trigger-value`,children:f}),(0,Z.jsx)(p,{className:`folder-tree-trigger-caret`})]}),s&&(0,Z.jsxs)(`div`,{className:`folder-tree-popup`,role:`listbox`,children:[a&&(0,Z.jsx)(`div`,{className:`terminal-error-banner`,children:a}),d.map(e=>{let r=e.path===t;return(0,Z.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":r,className:`folder-tree-node${r?` active`:``}`,style:{paddingLeft:`${.4+e.depth*.9}rem`},onClick:()=>{n(e.path),l(!1)},title:e.path||`/`,children:(0,Z.jsx)(`span`,{children:e.path===``?`/`:e.name})},e.path||`__root__`)})]})]})}function Me(){return(0,Z.jsxs)(`div`,{className:`project-chat project-chat-placeholder`,"aria-busy":`true`,children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:`Loading this project's chat…`}),(0,Z.jsx)(`div`,{className:`project-chat-placeholder-timeline`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`project-chat-compose-shell`,"aria-hidden":`true`,children:(0,Z.jsxs)(`div`,{className:`project-chat-compose-main`,children:[(0,Z.jsx)(`div`,{className:`project-chat-placeholder-band`}),(0,Z.jsx)(`div`,{className:`project-chat-placeholder-entry`})]})})]})}function Ne(e){let t=M(),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)([]),[o,l]=(0,B.useState)([]),u=(0,B.useRef)(void 0);(0,B.useEffect)(()=>{let n=!1,i=async()=>{try{let t=await c.getProjectIndex(e);n||r(t)}catch{}},o=async()=>{try{let r=await c.listProjectCraftbooks(e);if(n)return;a(s(r.items,t).flatMap(e=>{let t=e.manifest;return t.kind&&t.kind!==`craftbook-template`||!t.id?[]:[{id:t.id,command:t.command??t.id,name:t.name,description:t.description,paramSchema:t.paramSchema}]}))}catch{}},d=async()=>{try{let t=await c.listProjectTools(e);n||l(t.tools)}catch{}},f=async()=>{n||o();try{let t=await c.getProjectIndexStatus(e);if(n)return;let r=t.meta?.scannedAt;r&&r!==u.current?(u.current=r,await i()):t.state===`never`&&await c.refreshProjectIndex(e).catch(()=>{})}catch{}};i(),o(),d();let p=window.setInterval(f,3e4);return()=>{n=!0,window.clearInterval(p)}},[e,t]),(0,B.useEffect)(()=>{le(e,{index:n,craftbooks:i,mcpTools:o})},[e,n,i,o]),(0,B.useEffect)(()=>()=>z(e),[e])}var Pe=(0,B.lazy)(()=>x(()=>import(`./TerminalCodeEditor-DO7zLKy-.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39]))),Fe=`build, test, git status, … — Enter runs, Shift+Enter for newline, ↑/↓ recalls history`,Ie=[{section:`commands`,label:`Commands`,title:`Everyday terminal commands, and the tools installed on this machine`,icon:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`path`,{d:`M2.5 4 L6 8 L2.5 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,Z.jsx)(`path`,{d:`M8 12 H13.5`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`})]})},{section:`scripts`,label:`Scripts`,title:`Scripts this project already defines — package.json, scripts/, launches`,icon:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`rect`,{x:`3`,y:`2`,width:`10`,height:`12`,rx:`1.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`}),(0,Z.jsx)(`path`,{d:`M5.5 5.5h5M5.5 8h5M5.5 10.5h3`,stroke:`currentColor`,strokeWidth:`1.3`,strokeLinecap:`round`})]})},{section:`tasks`,label:`Tasks`,title:`Craftbooks and workspace skills a gezel can run for you`,icon:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`path`,{d:`M2.5 4.5 L4 6 L6.5 3`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,Z.jsx)(`path`,{d:`M8.5 5 H14`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`}),(0,Z.jsx)(`path`,{d:`M2.5 11 L4 12.5 L6.5 9.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,Z.jsx)(`path`,{d:`M8.5 11.5 H14`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}];function Le({projectId:e,workingDir:t,contextRow:n,toolbarTrailing:r,onSent:i,initialInput:a,onChatEscape:o}){let[s]=(0,B.useState)(()=>a??``),[p,m]=(0,B.useState)(null),[h,g]=(0,B.useState)(null),_=(0,B.useRef)(null),v=(0,B.useRef)([]),y=(0,B.useRef)(-1),b=(0,B.useCallback)(e=>{_.current?.setValue(e),g(null)},[]);Ne(e);let x=(0,B.useCallback)(async n=>{let r=n.trim();if(r!==``){_.current?.setValue(``),m(null),v.current.unshift(r),v.current.length>50&&(v.current.length=50),y.current=-1;try{let n=await c.runTerminalCommand(e,{workingDir:t,input:r});i?.(r,n)}catch(e){m(e instanceof Error?e.message:String(e)),_.current?.focus()}}},[e,t,i]),S=(0,B.useCallback)(()=>{let e=_.current;e&&(x(e.getValue()),e.focus())},[x]),C=(0,B.useCallback)(()=>{if(v.current.length===0)return;let e=Math.min(v.current.length-1,y.current+1);y.current=e,_.current?.setValue(v.current[e])},[]),w=(0,B.useCallback)(()=>{if(y.current<0)return;let e=y.current-1;y.current=e,_.current?.setValue(e<0?``:v.current[e])},[]);return(0,Z.jsxs)(`div`,{className:`terminal-composer`,children:[(0,Z.jsxs)(`div`,{className:`terminal-composer-toolbar`,children:[Ie.map(t=>(0,Z.jsxs)(l,{open:h===t.section,onOpenChange:e=>g(e?t.section:null),children:[(0,Z.jsx)(f,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`terminal-toolbar-btn`,title:t.title,"aria-label":t.title,children:[(0,Z.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:t.icon}),t.label]})}),(0,Z.jsx)(u,{className:`terminal-commands-popover`,side:`top`,align:`start`,onCloseAutoFocus:e=>{e.preventDefault(),_.current?.focus()},children:(0,Z.jsx)(R,{projectId:e,section:t.section,onStageCommand:b})})]},t.section)),r]}),n,(0,Z.jsx)(`div`,{className:`terminal-composer-fire-row`,children:(0,Z.jsx)(`button`,{type:`button`,className:`terminal-fire-btn`,"aria-label":`Fire`,title:`Fire — run this command (Enter)`,onClick:S,children:(0,Z.jsx)(d,{})})}),(0,Z.jsxs)(`div`,{className:`terminal-composer-input-wrap`,children:[(0,Z.jsx)(`span`,{className:`terminal-prompt-sigil`,children:`>`}),(0,Z.jsx)(B.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`terminal-composer-input`,"aria-busy":`true`}),children:(0,Z.jsx)(Pe,{ref:_,projectId:e,initialValue:s,placeholder:Fe,onSubmit:e=>void x(e),onHistoryPrev:C,onHistoryNext:w,onChatEscape:o})})]}),p&&(0,Z.jsx)(`div`,{className:`terminal-error-banner`,children:p})]})}var Re=`project`;function ze(e,t){return P(e?.lastHumanActivityAt,t)}function Be({project:e,compact:t=!1}){let[n,r]=(0,B.useState)([]),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(``);(0,B.useEffect)(()=>{c.listGezels().then(e=>{r(e.gezels),a(!0)}).catch(()=>a(!0))},[e.id,e.voormanGezelId,(e.gezelIds??[]).join(`,`)]),(0,B.useEffect)(()=>{s(``),f(null)},[e.id]);let[l,u]=(0,B.useState)(void 0);(0,B.useEffect)(()=>{u(void 0);let t=!1;return c.listChatSessions({projectId:e.id}).then(e=>{if(t)return;let n=e.sessions.filter(e=>!e.archived&&!e.taskRef)[0];u(n?{gezelId:n.gezelId,...n.lastHumanActivityAt?{lastHumanActivityAt:n.lastHumanActivityAt}:{}}:null)}).catch(()=>{t||u(null)}),()=>{t=!0}},[e.id]);let[d,f]=(0,B.useState)(null),p=(0,B.useCallback)(e=>{f(null),s(e)},[]);(0,B.useEffect)(()=>{if(o)return;let t=se(ae(e.id))?.gezelId;if(t&&n.some(e=>e.id===t)){s(t),f(null);return}if(l===void 0)return;let r=ze(l,Date.now())&&l&&n.some(e=>e.id===l.gezelId)?l.gezelId:``,i=n.find(t=>t.id===e.voormanGezelId)?.id??``,a=(e.gezelIds??[]).map(e=>n.find(t=>t.id===e)?.id).find(Boolean)??``,c=r||i||a||n[0]?.id||``;c&&(s(c),f(r?null:c))},[o,l,n,e.id,e.voormanGezelId,e.gezelIds]),(0,B.useEffect)(()=>{o&&ce(ae(e.id),{gezelId:o})},[e.id,o]);let m=n.find(e=>e.id===o);return!i||n.length>0&&!m?(0,Z.jsx)(Me,{}):n.length===0?(0,Z.jsx)(`p`,{className:`muted project-chat-empty`,children:`No gezellen available to chat with yet. Create one from the Gezellen tab.`}):(0,Z.jsx)(`div`,{className:`project-chat`,children:o&&m&&(0,Z.jsx)(Ve,{project:e,selectedGezel:m,recipientGezels:n,isVoorman:m.id===e.voormanGezelId,startFreshThread:m.id===d,onSelectGezel:p,compact:t})})}function Ve({project:e,selectedGezel:t,recipientGezels:n,isVoorman:a,startFreshThread:s,onSelectGezel:l,compact:u}){let[d,f]=(0,B.useState)(``),[p,m]=(0,B.useState)(``),[h,g]=(0,B.useState)(null),[_,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(0),x=C(),S=i({name:t.name,roleBasedName:t.roleBasedName},x),[w,T]=(0,B.useState)(0),[E,D]=(0,B.useState)([]),[k,A]=(0,B.useState)(`chat`),[M,P]=(0,B.useState)(0),F=(0,B.useCallback)(()=>{P(e=>e+1),A(`chat`)},[]),I=O()&&o(e);(0,B.useEffect)(()=>{!I&&k===`terminal`&&F()},[I,k,F]);let[L,te]=(0,B.useState)(``),[ae,R]=(0,B.useState)(``),[le,z]=(0,B.useState)(``),V=(0,B.useCallback)(e=>{z(``),te(e),R(e)},[]),[H,U]=(0,B.useState)(``);(0,B.useEffect)(()=>{k!==`terminal`&&H!==``&&U(``)},[k,H]);let[W,ue]=(0,B.useState)(0),[G,de]=(0,B.useState)(null),[K,fe]=(0,B.useState)(null),q=(0,B.useRef)(null),J=(0,B.useRef)(null),Y=(0,B.useCallback)((e,n,r)=>{n===t.id?g(r):(q.current=e||null,J.current=r,l(n)),f(e)},[t.id,l]),[pe,me]=(0,B.useState)(null),X=(0,B.useCallback)(e=>{e&&me(t=>({sessionId:e,requestKey:(t?.requestKey??0)+1}))},[]),he=(0,B.useCallback)(async e=>{let t={ref:e.ref,...e.activeStepId?{stepId:e.activeStepId}:{}};try{let{sessions:n}=await c.listTaskSessions(e.projectId,e.num),r=n.find(e=>!e.archived);if(r){Y(r.id,r.gezelId,t),X(r.id);return}}catch{}e.assignee.kind===`gezel`&&e.assignee.gezelId?Y(``,e.assignee.gezelId,t):g(t)},[Y,X]),ge=(0,B.useCallback)(e=>{b(e=>e+1),(e.status===`complete`||e.status===`canceled`)&&g(t=>t?.ref===e.ref?null:t)},[]);(0,B.useEffect)(()=>{let n=q.current;q.current=null,f(n??se(re(e.id,t.id))?.sessionId??``),g(J.current),J.current=null},[t.id,e.id]),(0,B.useEffect)(()=>{ce(re(e.id,t.id),{sessionId:d})},[e.id,t.id,d]);let _e=(0,B.useMemo)(()=>ie({role:a?`voorman`:`other`,gezelName:S,gezelGender:t.gender,projectName:e.name,fixedFunctionTool:t.fixedFunction?.tool}),[a,S,t.gender,e.name,t.fixedFunction?.tool]),ve=r(t.gender),ye=I?(0,Z.jsxs)(`div`,{className:`compose-mode-tabs`,role:`tablist`,"aria-label":`Compose surface`,children:[(0,Z.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":k===`chat`,"aria-label":`AI chat`,className:`compose-mode-tab`,onClick:F,title:`AI chat (@-mention to talk to a gezel)`,children:[(0,Z.jsx)(`span`,{className:`compose-mode-tab-glyph`,"aria-hidden":`true`,children:`@`}),`Chat`]}),(0,Z.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":k===`terminal`,className:`compose-mode-tab`,onClick:()=>A(`terminal`),title:`Terminal (run shell commands in this project's workspace)`,children:[(0,Z.jsx)(`span`,{className:`compose-mode-tab-glyph`,"aria-hidden":`true`,children:`>`}),`Terminal`]})]}):null;return(0,Z.jsx)(oe,{projectId:e.id,skillsProjectId:e.id,compact:u,chatKey:`${e.id}:timeline`,onTaskChanged:ge,banner:({onTaskReference:t})=>(0,Z.jsx)(xe,{projectId:e.id,gezels:n,activeSessionId:k===`chat`&&d||void 0,activeTaskRef:k===`chat`?h?.ref??null:null,activeTerminalThreadId:k===`terminal`?le:null,refreshKey:y,terminalRefreshKey:W,onFocusThread:e=>{Y(e.sessionId,e.gezelId,e.taskRef?{ref:e.taskRef}:null),X(e.sessionId)},onFocusTask:e=>{t(e.ref,{focus:!0}),he(e)},onFocusTerminal:I?t=>{V(t.workingDir),z(t.id),A(`terminal`),de(e=>({threadId:t.id,requestKey:(e?.requestKey??0)+1})),c.getTerminalThread(e.id,t.id).then(e=>{let t=[...e.messages].reverse().find(e=>e.cwd!==void 0)?.cwd;t!==void 0&&R(t)}).catch(()=>{})}:void 0,onNewTask:()=>v(!0)}),children:({onToolActivity:r,onArtifactReference:i,onArtifactSeen:o,onWorkspaceReference:c,onWorkspaceSeen:u,recentReferences:g,onOpenReference:y,onTaskReference:x})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ne,{projectId:e.id,activeSessionId:d||void 0,onFocusSession:(e,t)=>Y(e,t,null),onToolActivity:r,onArtifactReference:i,onArtifactSeen:o,onWorkspaceReference:c,onWorkspaceSeen:u,onOpenReference:y,onTaskReference:x,onTerminalWorkingDirChanged:(e,t)=>{R(t)},terminalRefreshKey:W,...K?{terminalSubmission:K}:{},...G?{terminalFocusRequest:G}:{},...pe?{sessionFocusRequest:pe}:{},emptyPlaceholder:a?`Talk to ${S} about running "${e.name}" — planning tasks, delegating, or checking progress.`:`Chat with ${S} about what ${ve.subject} ${ve.presentBe} working on in "${e.name}".`}),(0,Z.jsx)(`div`,{className:`project-chat-compose-shell`,children:(0,Z.jsx)(`div`,{className:`project-chat-compose-main${k===`terminal`?` project-chat-compose-main-terminal`:``}`,children:k===`chat`?(0,Z.jsx)(N,{gezelId:t.id,gezelName:t.name,gezelRoleBasedName:t.roleBasedName,gezelRole:t.role,gezelIcon:t.icon??null,gezelPoppetje:t.poppetje,gezelIconOverride:t.iconOverride,recipientGezels:n,onPrimaryRecipientChange:l,focusRequestKey:M,projectId:e.id,sessionId:d||void 0,...h?{taskRef:h.ref}:{},...h?.stepId?{stepId:h.stepId}:{},onSessionCreated:e=>{f(e),T(e=>e+1)},onToolActivity:r,recentReferences:g,onOpenReference:y,placeholder:_e,draftScope:Re,onPivotToMention:e=>{e!==t.id&&(D(e=>e.includes(t.id)?e:[...e,t.id]),l(e))},passiveCcGezelIds:E,onPassiveCcConsumed:()=>D([]),onTerminalEscape:I?e=>{U(e),A(`terminal`)}:void 0,addressLineTrailing:ye,draftId:p||void 0,onDraftIdChange:e=>m(e??``),belowAddressLine:(0,Z.jsx)(ee,{gezelId:t.id,projectId:e.id,sessionId:d||void 0,gezelName:S,...h?{taskRef:h.ref}:{},...h?.stepId?{stepId:h.stepId}:{},onSessionIdChange:e=>f(e??``),onFreshThread:()=>P(e=>e+1),refreshKey:w,activeDraftId:p||void 0,onDraftSelect:e=>m(e??``),draftScope:Re,autoPickNewest:!s||!!h})}):(0,Z.jsx)(Le,{projectId:e.id,workingDir:L,contextRow:(0,Z.jsx)(je,{projectId:e.id,workingDir:ae,onChangeWorkingDir:V}),toolbarTrailing:ye,initialInput:H,onSent:(e,t)=>{z(t.threadId),fe({runId:t.runId,threadId:t.threadId,input:e}),ue(e=>e+1)},onChatEscape:F},`terminal:${e.id}`)})}),(0,Z.jsx)(j,{open:_,defaultProjectId:e.id,projects:[e],gezels:n,projectLocked:!0,onClose:()=>v(!1),onCreated:()=>{v(!1),b(e=>e+1)}})]})})}export{Be as ProjectChat};
|
package/dist/ui/assets/{ProjectConnectionsTab-BZqp-oKI.js → ProjectConnectionsTab-dFCJpW93.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-BX5xXiFs.js";import{n as i,t as a}from"./relative-time-B2kBaekd.js";import{t as o}from"./ConfirmDialog-BHFs6vmJ.js";import{r as s}from"./new-project-meta-0xhggGA_.js";import{X as c}from"./index-DXWR4qW1.js";var l=e(t(),1),u=n();function d(e,t){return`connector-${e}-${t}`.replace(/[^a-zA-Z0-9_-]/g,`-`)}function f(e){return e&&/^https:\/\//i.test(e)?e:void 0}function p({required:e}){return e?(0,u.jsx)(`span`,{className:`gz-connector-field-requirement`,"aria-hidden":`true`,children:`Required`}):null}function m({id:e,description:t,helpUrl:n,helpLabel:r}){let i=f(n);return!t&&!i?null:(0,u.jsxs)(`span`,{id:e,className:`gz-connector-field-help`,children:[t,t&&i?` `:``,i&&(0,u.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,children:r??`Learn more`})]})}function h({connectorId:e,fieldKey:t,property:n,required:r,value:i,onChange:a}){let o=d(e,t),s=`${o}-label`,c=`${o}-help`,l=n.title??t,f=n.description?c:void 0;return(0,u.jsxs)(`div`,{className:`gz-connector-field`,children:[(0,u.jsxs)(`label`,{id:s,className:`gz-connector-field-label`,htmlFor:o,children:[(0,u.jsx)(`span`,{children:l}),(0,u.jsx)(p,{required:r})]}),(0,u.jsxs)(`span`,{className:`gz-connector-field-control`,children:[n.type===`boolean`?(0,u.jsx)(`input`,{id:o,type:`checkbox`,"aria-label":l,checked:i===!0,onChange:e=>a(e.target.checked),"aria-describedby":f}):(0,u.jsx)(`input`,{id:o,type:n.type===`integer`||n.type===`number`?`number`:`text`,value:typeof i==`string`?i:``,onChange:e=>a(e.target.value),placeholder:n.type===`array`?`comma,separated`:``,min:n.minimum,max:n.maximum,step:n.type===`integer`?1:void 0,required:r,"aria-label":l,"aria-describedby":f}),(0,u.jsx)(m,{id:c,description:n.description})]})]})}function g({connectorId:e,fieldKey:t,label:n,value:r,onChange:i,required:a=!1,secret:o=!1,description:s,helpUrl:c,helpLabel:l,placeholder:h}){let g=d(e,t),_=`${g}-help`,v=!!(s||f(c));return(0,u.jsxs)(`div`,{className:`gz-connector-field`,children:[(0,u.jsxs)(`label`,{className:`gz-connector-field-label`,htmlFor:g,children:[(0,u.jsx)(`span`,{children:n}),(0,u.jsx)(p,{required:a})]}),(0,u.jsxs)(`span`,{className:`gz-connector-field-control`,children:[(0,u.jsx)(`input`,{id:g,type:o?`password`:`text`,value:r,onChange:e=>i(e.target.value),required:a,autoComplete:o?`off`:void 0,placeholder:h,"aria-label":n,"aria-describedby":v?_:void 0}),(0,u.jsx)(m,{id:_,description:s,helpUrl:c,helpLabel:l})]})]})}function _({connectorId:e,fieldKey:t,label:n,checked:r,onChange:i}){let a=d(e,t);return(0,u.jsxs)(`div`,{className:`gz-connector-field`,children:[(0,u.jsx)(`label`,{className:`gz-connector-field-label`,htmlFor:a,children:(0,u.jsx)(`span`,{children:n})}),(0,u.jsx)(`span`,{className:`gz-connector-field-control gz-connector-checkbox-control`,children:(0,u.jsx)(`input`,{id:a,type:`checkbox`,"aria-label":n,checked:r,onChange:e=>i(e.target.checked)})})]})}function v({title:e,children:t}){return(0,u.jsxs)(`section`,{className:`gz-connector-field-group`,"aria-label":e,children:[(0,u.jsx)(`div`,{className:`gz-connector-field-group-heading`,children:e}),t]})}function y(e){let t={};for(let[n,r]of Object.entries(e.configSchema?.properties??{}))r.default!==void 0&&(t[n]=r.type===`boolean`?r.default===!0:String(r.default));return t}function b({connector:e,config:t,onConfigChange:n,displayName:r,onDisplayNameChange:i,credential:a,onCredentialChange:o,imapHost:s,onImapHostChange:c,imapPort:l,onImapPortChange:d,imapSecure:p,onImapSecureChange:m}){let y=e.secretShape?.kind,b=new Set(e.configSchema?.required??[]),x=Object.entries(e.configSchema?.properties??{}).filter(([,e])=>e.const===void 0),S=([e,t])=>b.has(e)||t[`x-gezel-priority`]===`primary`,C=x.filter(S),w=x.filter(e=>!S(e)),T=e.secretShape?.required===!0||e.secretShape?.[`x-gezel-priority`]===`primary`,E=([r,i])=>(0,u.jsx)(h,{connectorId:e.id,fieldKey:r,property:i,required:b.has(r),value:t[r],onChange:e=>n(r,e)},r),D=y!==`oauth2`&&y!==`imap`&&(0,u.jsx)(g,{connectorId:e.id,fieldKey:`credential`,label:e.secretShape?.label??`API key / token`,value:a,onChange:o,required:e.secretShape?.required===!0,secret:!0,description:e.secretShape?.description,helpUrl:e.secretShape?.helpUrl,helpLabel:e.secretShape?.helpLabel},`credential`),O=y===`imap`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(g,{connectorId:e.id,fieldKey:`imap-host`,label:`IMAP host`,value:s,onChange:c,required:!0,placeholder:`imap.example.com`}),(0,u.jsx)(g,{connectorId:e.id,fieldKey:`credential`,label:`Password / app password`,value:a,onChange:o,required:!0,secret:!0,description:e.secretShape?.description,helpUrl:e.secretShape?.helpUrl,helpLabel:e.secretShape?.helpLabel})]}),k=C.length>0||T||y===`imap`||y===`oauth2`;return(0,u.jsxs)(u.Fragment,{children:[e.setupInstructions&&(0,u.jsxs)(`aside`,{className:`gz-connector-setup-instructions`,children:[(0,u.jsx)(`strong`,{children:e.setupInstructions.title}),e.setupInstructions.description&&(0,u.jsx)(`p`,{children:e.setupInstructions.description}),e.setupInstructions.steps&&e.setupInstructions.steps.length>0&&(0,u.jsx)(`ol`,{children:e.setupInstructions.steps.map(e=>(0,u.jsx)(`li`,{children:e},e))}),f(e.setupInstructions.url)&&(0,u.jsx)(`a`,{href:e.setupInstructions.url,target:`_blank`,rel:`noreferrer`,children:e.setupInstructions.urlLabel??`Open setup instructions`})]}),(0,u.jsxs)(`div`,{className:`gz-connector-config-fields`,children:[k&&(0,u.jsxs)(v,{title:`Connection details`,children:[C.map(E),y===`oauth2`?(0,u.jsx)(`p`,{className:`muted small gz-connector-oauth-note`,children:`You'll authorize this connector in your browser after you click Connect.`}):y===`imap`?O:T?D:null]}),(0,u.jsxs)(v,{title:`Additional settings`,children:[w.map(E),y===`imap`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(g,{connectorId:e.id,fieldKey:`imap-port`,label:`Port`,value:l,onChange:d,placeholder:`993`}),(0,u.jsx)(_,{connectorId:e.id,fieldKey:`imap-tls`,label:`Use TLS`,checked:p,onChange:m})]}),!T&&D,(0,u.jsx)(g,{connectorId:e.id,fieldKey:`display-name`,label:`Display name`,value:r,onChange:i})]})]})]})}var x=/^GEZEL_[A-Z0-9_]{1,120}$/,S=8;function C(e,t){if(!t||typeof t!=`object`)return null;let n=t;if(n.kind!==`oauth2`)return null;let r=typeof n.clientIdEnv==`string`?n.clientIdEnv:``;if(!x.test(r))return null;let i=typeof n.clientSecretEnv==`string`&&n.clientSecretEnv.length>0,a=n.clientSetup&&typeof n.clientSetup==`object`?n.clientSetup:{},o=typeof a.providerLabel==`string`&&a.providerLabel.trim()?a.providerLabel.trim():e,s=typeof a.docsUrl==`string`&&/^https:\/\//.test(a.docsUrl)?a.docsUrl:void 0,c=typeof a.redirectPort==`number`&&Number.isInteger(a.redirectPort)&&a.redirectPort>=1024&&a.redirectPort<=65535?a.redirectPort:void 0,l=typeof a.appTypeNote==`string`&&a.appTypeNote.trim()?a.appTypeNote.trim():void 0,u=typeof a.redirectNote==`string`&&a.redirectNote.trim()?a.redirectNote.trim():void 0,d=Array.isArray(a.steps)?a.steps.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,S):[];return{clientKey:r,hasSecretField:i,secretRequired:i&&a.secretRequired===!0,providerLabel:o,...s?{docsUrl:s}:{},...l?{appTypeNote:l}:{},...c===void 0?{}:{redirectPort:c},...u?{redirectNote:u}:{},...d.length>0?{steps:d}:{}}}function w(e){return`http://127.0.0.1:${e}/callback`}function T(e){let t=e instanceof Error?e.message:typeof e==`string`?e:``;return/oauth is not configured/i.test(t)}function E({requirement:e,registered:t,forceOpenNonce:n,busy:r,onSave:i}){let[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(``),[d,f]=(0,l.useState)(``),[p,m]=(0,l.useState)(``),[h,g]=(0,l.useState)(!1),_=(0,l.useRef)(t);_.current=t;let v=()=>{c(_.current?.clientId??``),f(``),m(``),o(!0)};(0,l.useEffect)(()=>{n&&v()},[n]);let y=e.redirectPort===void 0?null:w(e.redirectPort),b=async()=>{if(y)try{await navigator.clipboard.writeText(y),g(!0),setTimeout(()=>g(!1),1500)}catch{}},x=async()=>{let n=s.trim(),r=d.trim();if(!n){m(`Client ID is required.`);return}if(e.secretRequired&&!r&&!t?.hasSecret){m(`${e.providerLabel} requires a client secret.`);return}m(``);try{await i({clientId:n,...r?{clientSecret:r}:{}})}catch{return}f(``),o(!1)};return a?(0,u.jsxs)(`div`,{className:`gz-oauth-app`,"aria-label":`${e.providerLabel} OAuth app setup`,children:[(0,u.jsxs)(`strong`,{className:`gz-oauth-app-heading`,children:[`Your `,e.providerLabel,` app`]}),(0,u.jsx)(`p`,{className:`muted small`,children:e.appTypeNote??`Create an OAuth app in your ${e.providerLabel} developer settings and paste its client ID here. It is stored on this machine only.`}),e.steps&&(0,u.jsx)(`ol`,{className:`gz-oauth-app-steps`,children:e.steps.map(e=>(0,u.jsx)(`li`,{children:e},e))}),e.docsUrl&&(0,u.jsxs)(`a`,{className:`gz-oauth-app-docs`,href:e.docsUrl,target:`_blank`,rel:`noreferrer`,children:[`Open the `,e.providerLabel,` developer console`]}),(0,u.jsxs)(`div`,{className:`gz-oauth-app-redirect`,children:[(0,u.jsx)(`span`,{children:`Redirect URI to register`}),y?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`span`,{className:`gz-oauth-app-redirect-row`,children:[(0,u.jsx)(`code`,{children:y}),(0,u.jsx)(`button`,{type:`button`,onClick:()=>void b(),title:`Copy the redirect URI`,children:h?`Copied`:`Copy`})]}),e.redirectNote&&(0,u.jsx)(`span`,{className:`muted small`,children:e.redirectNote})]}):(0,u.jsx)(`span`,{className:`muted small`,children:e.redirectNote??`${e.providerLabel} accepts any 127.0.0.1 port, so there is no fixed URI to register — Gezel picks a free port when you connect.`})]}),(0,u.jsxs)(`div`,{className:`gz-oauth-app-fields`,children:[(0,u.jsxs)(`label`,{children:[`Client ID`,(0,u.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),autoComplete:`off`,spellCheck:!1})]}),e.hasSecretField&&(0,u.jsxs)(`label`,{children:[`Client secret`,` `,!e.secretRequired&&(0,u.jsx)(`span`,{className:`muted`,children:`(optional — PKCE public clients don't need one)`}),(0,u.jsx)(`input`,{type:`password`,value:d,onChange:e=>f(e.target.value),autoComplete:`off`,placeholder:t?.hasSecret?`leave blank to keep the saved secret`:``})]})]}),p&&(0,u.jsx)(`p`,{className:`error small`,children:p}),(0,u.jsxs)(`div`,{className:`gz-oauth-app-actions`,children:[(0,u.jsx)(`button`,{type:`button`,onClick:()=>o(!1),disabled:r,children:`Cancel`}),(0,u.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void x(),disabled:r,children:r?`Working…`:`Save & connect`})]})]}):(0,u.jsxs)(`div`,{className:`gz-oauth-app gz-oauth-app-summary`,children:[(0,u.jsx)(`div`,{className:`gz-oauth-app-summary-text`,children:t?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`span`,{children:[`Connects through your `,e.providerLabel,` app`]}),(0,u.jsx)(`code`,{title:t.clientId,children:t.clientId}),t.hasSecret&&(0,u.jsx)(`span`,{children:`· secret saved`})]}):(0,u.jsxs)(`span`,{children:[`Gezel ships no built-in `,e.providerLabel,` client — connecting uses an app you register once on this machine.`]})}),(0,u.jsx)(`button`,{type:`button`,onClick:v,disabled:r,children:t?`Edit`:`Use your own ${e.providerLabel} app`})]})}async function D(e,t,n,i,a){let o=window.__GEZEL__;if(!o?.mailOAuthListen||!o.mailOAuthAwait)throw Error(`Connecting this source needs the Gezel desktop app.`);let{requestId:s,redirectUri:c}=await o.mailOAuthListen(a?.redirectPort===void 0?void 0:{port:a.redirectPort}),{authUrl:l,state:u}=await r.startConnectorOAuth(e,{type:t,redirectUri:c,config:n,...i?{displayName:i}:{}}),d=await o.mailOAuthAwait(s,l);if(`error`in d)throw Error(d.error);await r.completeConnectorOAuth(e,{state:d.state||u,code:d.code})}function O(e){let t=`${e.id} ${(e.tags??[]).join(` `)}`.toLowerCase();return t.includes(`wiki`)?`sheet`:t.includes(`calendar`)?`calendar`:/(mail|gmail|imap|email)/.test(t)?`envelope`:/(github|git)/.test(t)?`branch`:/(issue|linear)/.test(t)?`bubbles`:/(airtable|record|data)/.test(t)?`chart`:`dots`}function k(e){let t=e.secretShape?.kind;return t===`oauth2`?`OAuth`:t===`imap`?`Mail login`:e.secretShape?.required?e.secretShape?.label??`API token`:`Optional token`}function ee({tables:e}){return(0,u.jsx)(`ul`,{className:`gz-connector-tables`,children:e.map(e=>{let t=e.earliestPartition&&e.latestPartition?e.earliestPartition===e.latestPartition?e.earliestPartition:`${e.earliestPartition} → ${e.latestPartition}`:null;return(0,u.jsxs)(`li`,{className:`small muted`,children:[(0,u.jsx)(`strong`,{children:e.table}),` · `,e.rows.toLocaleString(),` `,e.rows===1?`row`:`rows`,t?` · ${t}`:``,e.retentionDays?` · keeps ${e.retentionDays} days`:``,e.schemaInferred?` · schema inferred`:``,e.pendingParts>0?` · tidying up tonight`:``]},e.table)})})}function A(e){return e.completeness===`window`?`Recent window`:`Full mirror`}function j({project:e,onProjectChange:t}){let[n,d]=(0,l.useState)(null),[f,p]=(0,l.useState)(null),[m,h]=(0,l.useState)(``),[g,_]=(0,l.useState)(``),[v,x]=(0,l.useState)(null),[S,w]=(0,l.useState)([]),[j,te]=(0,l.useState)(!1),[ne,re]=(0,l.useState)(!1),[M,N]=(0,l.useState)([]),[P,F]=(0,l.useState)(null),[I,L]=(0,l.useState)({}),[R,z]=(0,l.useState)(``),[B,V]=(0,l.useState)(``),[H,U]=(0,l.useState)(``),[W,G]=(0,l.useState)(``),[K,q]=(0,l.useState)(!0),[ie,ae]=(0,l.useState)({}),[oe,J]=(0,l.useState)(0),Y=(0,l.useCallback)(async()=>{try{let[t,n]=await Promise.all([r.listConnectors(e.id),r.listConnectorActions(e.id)]);d(t),w(n.pending)}catch(e){h(e instanceof Error?e.message:String(e))}},[e.id]),se=(0,l.useCallback)(async t=>{p(t),h(``),_(``);try{let n=await r.commitConnectorAction(e.id,t);_(n.status===`queued-night-shift`?`Held for daytime approval (night shift).`:`Action committed.`),await Y()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null)}},[e.id,Y]),ce=(0,l.useCallback)(async t=>{p(t);try{await r.discardConnectorAction(e.id,t),await Y()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null)}},[e.id,Y]);(0,l.useEffect)(()=>{Y()},[Y]);let X=(0,l.useCallback)(()=>{te(!1),F(null),L({}),z(``),V(``),U(``),G(``),q(!0),J(0)},[]),Z=(0,l.useCallback)(async()=>{let e=await r.listOAuthClients();ae(Object.fromEntries((e.clients??[]).map(e=>[e.key,{clientId:e.clientId,hasSecret:e.hasSecret}])))},[]),le=(0,l.useCallback)(async()=>{te(!0),re(!0),N([]),F(null),h(``),_(``),Z().catch(()=>{});try{let e=await r.listConnectorTypes();N(e.items.map(e=>({...e.manifest,...e.iconSvg?{iconSvg:e.iconSvg}:{},...e.logoUrl?{logoUrl:e.logoUrl}:{}})))}catch(e){h(e instanceof Error?e.message:String(e))}finally{re(!1)}},[Z]),ue=(0,l.useCallback)(async t=>{p(t),h(``),_(``);try{let n=(await r.syncConnector(e.id,t)).result;_(n.error?`Sync error: ${n.error}`:`Synced ${(n.written??0)+(n.quarantined??0)} new record(s).`),await Y()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null)}},[e.id,Y]),de=(0,l.useCallback)(async t=>{p(t);try{await r.unbindConnector(e.id,t),await Y()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null),x(null)}},[e.id,Y]),fe=(0,l.useCallback)(()=>{let e=P?.configSchema?.properties??{},t={};for(let[n,r]of Object.entries(e))if(r.const!==void 0)t[n]=r.const;else if(r.type===`array`){let e=typeof I[n]==`string`?I[n].trim():``;e&&(t[n]=e.split(`,`).map(e=>e.trim()).filter(Boolean))}else if(r.type===`boolean`)typeof I[n]==`boolean`&&(t[n]=I[n]);else if(r.type===`integer`||r.type===`number`){let e=typeof I[n]==`string`?I[n].trim():``;e&&(t[n]=Number(e))}else{let e=typeof I[n]==`string`?I[n].trim():``;e&&(t[n]=e)}return t},[P,I]),Q=(0,l.useMemo)(()=>P?.secretShape?.kind===`oauth2`?C(P.name,P.secretShape):null,[P]),$=(0,l.useCallback)(async()=>{if(!P)return;h(``),_(``);let n=fe(),i=P.secretShape?.kind,a=(P.configSchema?.required??[]).find(e=>{let t=n[e];return t===void 0||t===``||Array.isArray(t)&&t.length===0});if(a){let e=P.configSchema?.properties?.[a]?.title??a;h(`${e} is required.`);return}if(i!==`oauth2`&&i!==`imap`&&P.secretShape?.required&&!B.trim()){h(`${P.secretShape.label??`API key / token`} is required.`);return}p(`add`);try{if(i===`oauth2`)await D(e.id,P.id,n,R.trim()||void 0,Q?.redirectPort===void 0?void 0:{redirectPort:Q.redirectPort});else{let t;i===`imap`?t={host:H.trim(),...W.trim()?{port:Number(W.trim())}:{},secure:K,user:String(n.address??``),pass:B}:B.trim()&&(t=B.trim()),await r.bindConnector(e.id,{type:P.id,...R.trim()?{displayName:R.trim()}:{},config:n,...t===void 0?{}:{credential:t}})}_(`Connector added.`),X(),await Y();try{let n=await r.getProject(e.id);n&&t?.(n)}catch{}}catch(e){let t=e instanceof Error?e.message:String(e);T(t)&&J(e=>e+1),h(t)}finally{p(null)}},[P,e.id,fe,R,B,H,W,K,X,Y,t,Q]),pe=(0,l.useCallback)(async e=>{if(Q){h(``),p(`oauth-app`);try{await r.putOAuthClient(Q.clientKey,e),await Z().catch(()=>{ae(t=>({...t,[Q.clientKey]:{clientId:e.clientId,hasSecret:!!e.clientSecret||(t[Q.clientKey]?.hasSecret??!1)}}))}),J(0)}catch(e){throw h(e instanceof Error?e.message:String(e)),e}finally{p(null)}await $()}},[Q,Z,$]),me=n?.bindings??[],he=P?.secretShape?.kind,ge=e=>{e.id!==P?.id&&(F(e),L(y(e)),z(``),V(``),U(``),G(``),q(!0),h(``),J(0))};return(0,u.jsxs)(`div`,{className:`settings-section`,children:[(0,u.jsxs)(`div`,{className:`gz-mail-header`,children:[(0,u.jsx)(`h3`,{children:`Connections`}),!j&&(0,u.jsx)(`button`,{type:`button`,onClick:()=>void le(),children:`Add connection`})]}),me.length===0&&!j?(0,u.jsx)(`p`,{className:`muted`,children:`No connectors yet. Add one to mirror an external source (email, issues, a data source) into this project as searchable files.`}):(0,u.jsx)(`ul`,{className:`settings-list`,children:me.map(e=>(0,u.jsxs)(`li`,{children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`strong`,{children:e.displayName||e.type}),(0,u.jsxs)(`span`,{className:`muted small`,children:[` · `,e.type]}),(0,u.jsx)(`div`,{className:`small`,children:e.lastError?(0,u.jsxs)(`span`,{className:`error`,children:[`Error: `,e.lastError]}):e.lastSyncedAt?(0,u.jsxs)(`span`,{className:`muted`,title:a(e.lastSyncedAt),children:[`Last synced `,i(e.lastSyncedAt)]}):(0,u.jsx)(`span`,{className:`muted`,children:`Not synced yet`})}),e.tables&&e.tables.length>0?(0,u.jsx)(ee,{tables:e.tables}):null]}),(0,u.jsxs)(`div`,{className:`gz-mail-link-actions`,children:[(0,u.jsx)(`button`,{type:`button`,onClick:()=>void ue(e.id),disabled:f===e.id,children:f===e.id?`Working…`:`Sync now`}),(0,u.jsx)(`button`,{type:`button`,className:`danger`,onClick:()=>x(e.id),disabled:f===e.id,children:`Remove`})]})]},e.id))}),S.length>0&&(0,u.jsxs)(`div`,{className:`settings-subsection`,children:[(0,u.jsx)(`h4`,{children:`Pending actions`}),(0,u.jsx)(`p`,{className:`muted small`,children:`Drafted by a gezel — review, then commit (the live write). You commit; the gezel can't.`}),(0,u.jsx)(`ul`,{className:`settings-list`,children:S.map(e=>(0,u.jsxs)(`li`,{children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`strong`,{children:e.action}),(0,u.jsxs)(`span`,{className:`muted small`,children:[` · `,e.connectorType]}),e.status===`queued`&&(0,u.jsx)(`span`,{className:`badge`,children:` held for daytime`})]}),(0,u.jsxs)(`div`,{className:`gz-mail-link-actions`,children:[(0,u.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void se(e.draftId),disabled:f===e.draftId,children:f===e.draftId?`Working…`:`Commit`}),(0,u.jsx)(`button`,{type:`button`,onClick:()=>void ce(e.draftId),disabled:f===e.draftId,children:`Discard`})]})]},e.draftId))})]}),j&&(0,u.jsxs)(`div`,{className:`gz-connector-picker`,children:[(0,u.jsxs)(`div`,{className:`gz-connector-picker-heading`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`strong`,{children:`Choose a connector`}),(0,u.jsx)(`p`,{className:`muted small`,children:`Pick a source to mirror into this project's searchable files.`})]}),(0,u.jsx)(`span`,{className:`gz-connector-picker-count`,children:ne?`Loading…`:`${M.length} available`})]}),ne?(0,u.jsx)(`div`,{className:`gz-connector-picker-empty muted small`,children:`Gathering connectors…`}):M.length===0?(0,u.jsx)(`div`,{className:`gz-connector-picker-empty muted small`,children:`No connector types are available.`}):(0,u.jsx)(`div`,{className:`gz-connector-grid`,role:`radiogroup`,"aria-label":`Connector type`,children:M.map((e,t)=>(0,u.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":P?.id===e.id,"aria-label":e.name,className:`gz-npd-card gz-connector-card${P?.id===e.id?` active`:``}`,onClick:()=>ge(e),style:{"--card-i":Math.min(t,11)},children:[(0,u.jsx)(`span`,{className:`gz-npd-card-mark`,children:(0,u.jsx)(c,{iconSvg:e.iconSvg,logoUrl:e.logoUrl,svgClassName:`gz-npd-card-mark-svg`,fallback:(0,u.jsx)(s,{glyph:O(e),size:19})})}),(0,u.jsx)(`span`,{className:`gz-npd-card-name`,children:e.name}),(0,u.jsx)(`span`,{className:`gz-npd-card-description`,children:e.description}),(0,u.jsxs)(`span`,{className:`gz-connector-card-meta`,"aria-hidden":`true`,children:[(0,u.jsx)(`span`,{children:k(e)}),(0,u.jsx)(`span`,{children:A(e)})]})]},e.id))}),P&&(0,u.jsxs)(`div`,{className:`gz-mail-link-form gz-connector-config`,"aria-label":`${P.name} setup`,children:[(0,u.jsxs)(`div`,{className:`gz-connector-config-heading`,children:[(0,u.jsx)(`span`,{className:`gz-connector-config-mark`,children:(0,u.jsx)(c,{iconSvg:P.iconSvg,logoUrl:P.logoUrl,svgClassName:`gz-npd-card-mark-svg`,fallback:(0,u.jsx)(s,{glyph:O(P),size:19})})}),(0,u.jsxs)(`div`,{children:[(0,u.jsxs)(`strong`,{children:[`Set up `,P.name]}),(0,u.jsxs)(`div`,{className:`small muted`,children:[k(P),` · `,A(P)]})]})]}),(0,u.jsx)(b,{connector:P,config:I,onConfigChange:(e,t)=>L(n=>({...n,[e]:t})),displayName:R,onDisplayNameChange:z,credential:B,onCredentialChange:V,imapHost:H,onImapHostChange:U,imapPort:W,onImapPortChange:G,imapSecure:K,onImapSecureChange:q}),Q&&(0,u.jsx)(E,{requirement:Q,registered:ie[Q.clientKey]??null,forceOpenNonce:oe,busy:f===`oauth-app`||f===`add`,onSave:pe},P.id)]}),(0,u.jsxs)(`div`,{className:`gz-mail-link-actions gz-connector-picker-actions`,children:[(0,u.jsx)(`button`,{type:`button`,onClick:X,disabled:f===`add`,children:`Cancel`}),P&&(0,u.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void $(),disabled:f===`add`,children:f===`add`?`Working…`:he===`oauth2`?`Connect`:`Add`})]})]}),m&&(0,u.jsx)(`p`,{className:`error small`,children:m}),g&&(0,u.jsx)(`p`,{className:`muted small`,children:g}),(0,u.jsx)(o,{open:v!==null,title:`Remove connector?`,message:`This removes the binding and its stored credential. Synced files stay on disk.`,confirmLabel:`Remove`,danger:!0,onConfirm:()=>{v&&de(v)},onCancel:()=>x(null)})]})}export{j as ProjectConnectionsTab};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-BPraLwsh.js";import{n as i,t as a}from"./relative-time-B2kBaekd.js";import{t as o}from"./ConfirmDialog-Dt1ed4Fh.js";import{r as s}from"./new-project-meta-_f9sfcRX.js";import{Z as c}from"./index-C0DYtvfg.js";var l=e(t(),1),u=n();function d(e,t){return`connector-${e}-${t}`.replace(/[^a-zA-Z0-9_-]/g,`-`)}function f(e){return e&&/^https:\/\//i.test(e)?e:void 0}function p({required:e}){return e?(0,u.jsx)(`span`,{className:`gz-connector-field-requirement`,"aria-hidden":`true`,children:`Required`}):null}function m({id:e,description:t,helpUrl:n,helpLabel:r}){let i=f(n);return!t&&!i?null:(0,u.jsxs)(`span`,{id:e,className:`gz-connector-field-help`,children:[t,t&&i?` `:``,i&&(0,u.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,children:r??`Learn more`})]})}function h({connectorId:e,fieldKey:t,property:n,required:r,value:i,onChange:a}){let o=d(e,t),s=`${o}-label`,c=`${o}-help`,l=n.title??t,f=n.description?c:void 0;return(0,u.jsxs)(`div`,{className:`gz-connector-field`,children:[(0,u.jsxs)(`label`,{id:s,className:`gz-connector-field-label`,htmlFor:o,children:[(0,u.jsx)(`span`,{children:l}),(0,u.jsx)(p,{required:r})]}),(0,u.jsxs)(`span`,{className:`gz-connector-field-control`,children:[n.type===`boolean`?(0,u.jsx)(`input`,{id:o,type:`checkbox`,"aria-label":l,checked:i===!0,onChange:e=>a(e.target.checked),"aria-describedby":f}):(0,u.jsx)(`input`,{id:o,type:n.type===`integer`||n.type===`number`?`number`:`text`,value:typeof i==`string`?i:``,onChange:e=>a(e.target.value),placeholder:n.type===`array`?`comma,separated`:``,min:n.minimum,max:n.maximum,step:n.type===`integer`?1:void 0,required:r,"aria-label":l,"aria-describedby":f}),(0,u.jsx)(m,{id:c,description:n.description})]})]})}function g({connectorId:e,fieldKey:t,label:n,value:r,onChange:i,required:a=!1,secret:o=!1,description:s,helpUrl:c,helpLabel:l,placeholder:h}){let g=d(e,t),_=`${g}-help`,v=!!(s||f(c));return(0,u.jsxs)(`div`,{className:`gz-connector-field`,children:[(0,u.jsxs)(`label`,{className:`gz-connector-field-label`,htmlFor:g,children:[(0,u.jsx)(`span`,{children:n}),(0,u.jsx)(p,{required:a})]}),(0,u.jsxs)(`span`,{className:`gz-connector-field-control`,children:[(0,u.jsx)(`input`,{id:g,type:o?`password`:`text`,value:r,onChange:e=>i(e.target.value),required:a,autoComplete:o?`off`:void 0,placeholder:h,"aria-label":n,"aria-describedby":v?_:void 0}),(0,u.jsx)(m,{id:_,description:s,helpUrl:c,helpLabel:l})]})]})}function _({connectorId:e,fieldKey:t,label:n,checked:r,onChange:i}){let a=d(e,t);return(0,u.jsxs)(`div`,{className:`gz-connector-field`,children:[(0,u.jsx)(`label`,{className:`gz-connector-field-label`,htmlFor:a,children:(0,u.jsx)(`span`,{children:n})}),(0,u.jsx)(`span`,{className:`gz-connector-field-control gz-connector-checkbox-control`,children:(0,u.jsx)(`input`,{id:a,type:`checkbox`,"aria-label":n,checked:r,onChange:e=>i(e.target.checked)})})]})}function v({title:e,children:t}){return(0,u.jsxs)(`section`,{className:`gz-connector-field-group`,"aria-label":e,children:[(0,u.jsx)(`div`,{className:`gz-connector-field-group-heading`,children:e}),t]})}function y(e){let t={};for(let[n,r]of Object.entries(e.configSchema?.properties??{}))r.default!==void 0&&(t[n]=r.type===`boolean`?r.default===!0:String(r.default));return t}function b({connector:e,config:t,onConfigChange:n,displayName:r,onDisplayNameChange:i,credential:a,onCredentialChange:o,imapHost:s,onImapHostChange:c,imapPort:l,onImapPortChange:d,imapSecure:p,onImapSecureChange:m}){let y=e.secretShape?.kind,b=new Set(e.configSchema?.required??[]),x=Object.entries(e.configSchema?.properties??{}).filter(([,e])=>e.const===void 0),S=([e,t])=>b.has(e)||t[`x-gezel-priority`]===`primary`,C=x.filter(S),w=x.filter(e=>!S(e)),T=e.secretShape?.required===!0||e.secretShape?.[`x-gezel-priority`]===`primary`,E=([r,i])=>(0,u.jsx)(h,{connectorId:e.id,fieldKey:r,property:i,required:b.has(r),value:t[r],onChange:e=>n(r,e)},r),D=y!==`oauth2`&&y!==`imap`&&(0,u.jsx)(g,{connectorId:e.id,fieldKey:`credential`,label:e.secretShape?.label??`API key / token`,value:a,onChange:o,required:e.secretShape?.required===!0,secret:!0,description:e.secretShape?.description,helpUrl:e.secretShape?.helpUrl,helpLabel:e.secretShape?.helpLabel},`credential`),O=y===`imap`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(g,{connectorId:e.id,fieldKey:`imap-host`,label:`IMAP host`,value:s,onChange:c,required:!0,placeholder:`imap.example.com`}),(0,u.jsx)(g,{connectorId:e.id,fieldKey:`credential`,label:`Password / app password`,value:a,onChange:o,required:!0,secret:!0,description:e.secretShape?.description,helpUrl:e.secretShape?.helpUrl,helpLabel:e.secretShape?.helpLabel})]}),k=C.length>0||T||y===`imap`||y===`oauth2`;return(0,u.jsxs)(u.Fragment,{children:[e.setupInstructions&&(0,u.jsxs)(`aside`,{className:`gz-connector-setup-instructions`,children:[(0,u.jsx)(`strong`,{children:e.setupInstructions.title}),e.setupInstructions.description&&(0,u.jsx)(`p`,{children:e.setupInstructions.description}),e.setupInstructions.steps&&e.setupInstructions.steps.length>0&&(0,u.jsx)(`ol`,{children:e.setupInstructions.steps.map(e=>(0,u.jsx)(`li`,{children:e},e))}),f(e.setupInstructions.url)&&(0,u.jsx)(`a`,{href:e.setupInstructions.url,target:`_blank`,rel:`noreferrer`,children:e.setupInstructions.urlLabel??`Open setup instructions`})]}),(0,u.jsxs)(`div`,{className:`gz-connector-config-fields`,children:[k&&(0,u.jsxs)(v,{title:`Connection details`,children:[C.map(E),y===`oauth2`?(0,u.jsx)(`p`,{className:`muted small gz-connector-oauth-note`,children:`You'll authorize this connector in your browser after you click Connect.`}):y===`imap`?O:T?D:null]}),(0,u.jsxs)(v,{title:`Additional settings`,children:[w.map(E),y===`imap`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(g,{connectorId:e.id,fieldKey:`imap-port`,label:`Port`,value:l,onChange:d,placeholder:`993`}),(0,u.jsx)(_,{connectorId:e.id,fieldKey:`imap-tls`,label:`Use TLS`,checked:p,onChange:m})]}),!T&&D,(0,u.jsx)(g,{connectorId:e.id,fieldKey:`display-name`,label:`Display name`,value:r,onChange:i})]})]})]})}var x=/^GEZEL_[A-Z0-9_]{1,120}$/,S=8;function C(e,t){if(!t||typeof t!=`object`)return null;let n=t;if(n.kind!==`oauth2`)return null;let r=typeof n.clientIdEnv==`string`?n.clientIdEnv:``;if(!x.test(r))return null;let i=typeof n.clientSecretEnv==`string`&&n.clientSecretEnv.length>0,a=n.clientSetup&&typeof n.clientSetup==`object`?n.clientSetup:{},o=typeof a.providerLabel==`string`&&a.providerLabel.trim()?a.providerLabel.trim():e,s=typeof a.docsUrl==`string`&&/^https:\/\//.test(a.docsUrl)?a.docsUrl:void 0,c=typeof a.redirectPort==`number`&&Number.isInteger(a.redirectPort)&&a.redirectPort>=1024&&a.redirectPort<=65535?a.redirectPort:void 0,l=typeof a.appTypeNote==`string`&&a.appTypeNote.trim()?a.appTypeNote.trim():void 0,u=typeof a.redirectNote==`string`&&a.redirectNote.trim()?a.redirectNote.trim():void 0,d=Array.isArray(a.steps)?a.steps.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,S):[];return{clientKey:r,hasSecretField:i,secretRequired:i&&a.secretRequired===!0,providerLabel:o,...s?{docsUrl:s}:{},...l?{appTypeNote:l}:{},...c===void 0?{}:{redirectPort:c},...u?{redirectNote:u}:{},...d.length>0?{steps:d}:{}}}function w(e){return`http://127.0.0.1:${e}/callback`}function T(e){let t=e instanceof Error?e.message:typeof e==`string`?e:``;return/oauth is not configured/i.test(t)}function E({requirement:e,registered:t,forceOpenNonce:n,busy:r,onSave:i}){let[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(``),[d,f]=(0,l.useState)(``),[p,m]=(0,l.useState)(``),[h,g]=(0,l.useState)(!1),_=(0,l.useRef)(t);_.current=t;let v=()=>{c(_.current?.clientId??``),f(``),m(``),o(!0)};(0,l.useEffect)(()=>{n&&v()},[n]);let y=e.redirectPort===void 0?null:w(e.redirectPort),b=async()=>{if(y)try{await navigator.clipboard.writeText(y),g(!0),setTimeout(()=>g(!1),1500)}catch{}},x=async()=>{let n=s.trim(),r=d.trim();if(!n){m(`Client ID is required.`);return}if(e.secretRequired&&!r&&!t?.hasSecret){m(`${e.providerLabel} requires a client secret.`);return}m(``);try{await i({clientId:n,...r?{clientSecret:r}:{}})}catch{return}f(``),o(!1)};return a?(0,u.jsxs)(`div`,{className:`gz-oauth-app`,"aria-label":`${e.providerLabel} OAuth app setup`,children:[(0,u.jsxs)(`strong`,{className:`gz-oauth-app-heading`,children:[`Your `,e.providerLabel,` app`]}),(0,u.jsx)(`p`,{className:`muted small`,children:e.appTypeNote??`Create an OAuth app in your ${e.providerLabel} developer settings and paste its client ID here. It is stored on this machine only.`}),e.steps&&(0,u.jsx)(`ol`,{className:`gz-oauth-app-steps`,children:e.steps.map(e=>(0,u.jsx)(`li`,{children:e},e))}),e.docsUrl&&(0,u.jsxs)(`a`,{className:`gz-oauth-app-docs`,href:e.docsUrl,target:`_blank`,rel:`noreferrer`,children:[`Open the `,e.providerLabel,` developer console`]}),(0,u.jsxs)(`div`,{className:`gz-oauth-app-redirect`,children:[(0,u.jsx)(`span`,{children:`Redirect URI to register`}),y?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`span`,{className:`gz-oauth-app-redirect-row`,children:[(0,u.jsx)(`code`,{children:y}),(0,u.jsx)(`button`,{type:`button`,onClick:()=>void b(),title:`Copy the redirect URI`,children:h?`Copied`:`Copy`})]}),e.redirectNote&&(0,u.jsx)(`span`,{className:`muted small`,children:e.redirectNote})]}):(0,u.jsx)(`span`,{className:`muted small`,children:e.redirectNote??`${e.providerLabel} accepts any 127.0.0.1 port, so there is no fixed URI to register — Gezel picks a free port when you connect.`})]}),(0,u.jsxs)(`div`,{className:`gz-oauth-app-fields`,children:[(0,u.jsxs)(`label`,{children:[`Client ID`,(0,u.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),autoComplete:`off`,spellCheck:!1})]}),e.hasSecretField&&(0,u.jsxs)(`label`,{children:[`Client secret`,` `,!e.secretRequired&&(0,u.jsx)(`span`,{className:`muted`,children:`(optional — PKCE public clients don't need one)`}),(0,u.jsx)(`input`,{type:`password`,value:d,onChange:e=>f(e.target.value),autoComplete:`off`,placeholder:t?.hasSecret?`leave blank to keep the saved secret`:``})]})]}),p&&(0,u.jsx)(`p`,{className:`error small`,children:p}),(0,u.jsxs)(`div`,{className:`gz-oauth-app-actions`,children:[(0,u.jsx)(`button`,{type:`button`,onClick:()=>o(!1),disabled:r,children:`Cancel`}),(0,u.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void x(),disabled:r,children:r?`Working…`:`Save & connect`})]})]}):(0,u.jsxs)(`div`,{className:`gz-oauth-app gz-oauth-app-summary`,children:[(0,u.jsx)(`div`,{className:`gz-oauth-app-summary-text`,children:t?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`span`,{children:[`Connects through your `,e.providerLabel,` app`]}),(0,u.jsx)(`code`,{title:t.clientId,children:t.clientId}),t.hasSecret&&(0,u.jsx)(`span`,{children:`· secret saved`})]}):(0,u.jsxs)(`span`,{children:[`Gezel ships no built-in `,e.providerLabel,` client — connecting uses an app you register once on this machine.`]})}),(0,u.jsx)(`button`,{type:`button`,onClick:v,disabled:r,children:t?`Edit`:`Use your own ${e.providerLabel} app`})]})}async function D(e,t,n,i,a){let o=window.__GEZEL__;if(!o?.mailOAuthListen||!o.mailOAuthAwait)throw Error(`Connecting this source needs the Gezel desktop app.`);let{requestId:s,redirectUri:c}=await o.mailOAuthListen(a?.redirectPort===void 0?void 0:{port:a.redirectPort}),{authUrl:l,state:u}=await r.startConnectorOAuth(e,{type:t,redirectUri:c,config:n,...i?{displayName:i}:{}}),d=await o.mailOAuthAwait(s,l);if(`error`in d)throw Error(d.error);await r.completeConnectorOAuth(e,{state:d.state||u,code:d.code})}function O(e){let t=`${e.id} ${(e.tags??[]).join(` `)}`.toLowerCase();return t.includes(`wiki`)?`sheet`:t.includes(`calendar`)?`calendar`:/(mail|gmail|imap|email)/.test(t)?`envelope`:/(github|git)/.test(t)?`branch`:/(issue|linear)/.test(t)?`bubbles`:/(airtable|record|data)/.test(t)?`chart`:`dots`}function k(e){let t=e.secretShape?.kind;return t===`oauth2`?`OAuth`:t===`imap`?`Mail login`:e.secretShape?.required?e.secretShape?.label??`API token`:`Optional token`}function ee({tables:e}){return(0,u.jsx)(`ul`,{className:`gz-connector-tables`,children:e.map(e=>{let t=e.earliestPartition&&e.latestPartition?e.earliestPartition===e.latestPartition?e.earliestPartition:`${e.earliestPartition} → ${e.latestPartition}`:null;return(0,u.jsxs)(`li`,{className:`small muted`,children:[(0,u.jsx)(`strong`,{children:e.table}),` · `,e.rows.toLocaleString(),` `,e.rows===1?`row`:`rows`,t?` · ${t}`:``,e.retentionDays?` · keeps ${e.retentionDays} days`:``,e.schemaInferred?` · schema inferred`:``,e.pendingParts>0?` · tidying up tonight`:``]},e.table)})})}function A(e){return e.completeness===`window`?`Recent window`:`Full mirror`}function j({project:e,onProjectChange:t}){let[n,d]=(0,l.useState)(null),[f,p]=(0,l.useState)(null),[m,h]=(0,l.useState)(``),[g,_]=(0,l.useState)(``),[v,x]=(0,l.useState)(null),[S,w]=(0,l.useState)([]),[j,te]=(0,l.useState)(!1),[ne,re]=(0,l.useState)(!1),[M,N]=(0,l.useState)([]),[P,F]=(0,l.useState)(null),[I,L]=(0,l.useState)({}),[R,z]=(0,l.useState)(``),[B,V]=(0,l.useState)(``),[H,U]=(0,l.useState)(``),[W,G]=(0,l.useState)(``),[K,q]=(0,l.useState)(!0),[ie,ae]=(0,l.useState)({}),[oe,J]=(0,l.useState)(0),Y=(0,l.useCallback)(async()=>{try{let[t,n]=await Promise.all([r.listConnectors(e.id),r.listConnectorActions(e.id)]);d(t),w(n.pending)}catch(e){h(e instanceof Error?e.message:String(e))}},[e.id]),se=(0,l.useCallback)(async t=>{p(t),h(``),_(``);try{let n=await r.commitConnectorAction(e.id,t);_(n.status===`queued-night-shift`?`Held for daytime approval (night shift).`:`Action committed.`),await Y()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null)}},[e.id,Y]),ce=(0,l.useCallback)(async t=>{p(t);try{await r.discardConnectorAction(e.id,t),await Y()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null)}},[e.id,Y]);(0,l.useEffect)(()=>{Y()},[Y]);let X=(0,l.useCallback)(()=>{te(!1),F(null),L({}),z(``),V(``),U(``),G(``),q(!0),J(0)},[]),Z=(0,l.useCallback)(async()=>{let e=await r.listOAuthClients();ae(Object.fromEntries((e.clients??[]).map(e=>[e.key,{clientId:e.clientId,hasSecret:e.hasSecret}])))},[]),le=(0,l.useCallback)(async()=>{te(!0),re(!0),N([]),F(null),h(``),_(``),Z().catch(()=>{});try{let e=await r.listConnectorTypes();N(e.items.map(e=>({...e.manifest,...e.iconSvg?{iconSvg:e.iconSvg}:{},...e.logoUrl?{logoUrl:e.logoUrl}:{}})))}catch(e){h(e instanceof Error?e.message:String(e))}finally{re(!1)}},[Z]),ue=(0,l.useCallback)(async t=>{p(t),h(``),_(``);try{let n=(await r.syncConnector(e.id,t)).result;_(n.error?`Sync error: ${n.error}`:`Synced ${(n.written??0)+(n.quarantined??0)} new record(s).`),await Y()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null)}},[e.id,Y]),de=(0,l.useCallback)(async t=>{p(t);try{await r.unbindConnector(e.id,t),await Y()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null),x(null)}},[e.id,Y]),fe=(0,l.useCallback)(()=>{let e=P?.configSchema?.properties??{},t={};for(let[n,r]of Object.entries(e))if(r.const!==void 0)t[n]=r.const;else if(r.type===`array`){let e=typeof I[n]==`string`?I[n].trim():``;e&&(t[n]=e.split(`,`).map(e=>e.trim()).filter(Boolean))}else if(r.type===`boolean`)typeof I[n]==`boolean`&&(t[n]=I[n]);else if(r.type===`integer`||r.type===`number`){let e=typeof I[n]==`string`?I[n].trim():``;e&&(t[n]=Number(e))}else{let e=typeof I[n]==`string`?I[n].trim():``;e&&(t[n]=e)}return t},[P,I]),Q=(0,l.useMemo)(()=>P?.secretShape?.kind===`oauth2`?C(P.name,P.secretShape):null,[P]),$=(0,l.useCallback)(async()=>{if(!P)return;h(``),_(``);let n=fe(),i=P.secretShape?.kind,a=(P.configSchema?.required??[]).find(e=>{let t=n[e];return t===void 0||t===``||Array.isArray(t)&&t.length===0});if(a){let e=P.configSchema?.properties?.[a]?.title??a;h(`${e} is required.`);return}if(i!==`oauth2`&&i!==`imap`&&P.secretShape?.required&&!B.trim()){h(`${P.secretShape.label??`API key / token`} is required.`);return}p(`add`);try{if(i===`oauth2`)await D(e.id,P.id,n,R.trim()||void 0,Q?.redirectPort===void 0?void 0:{redirectPort:Q.redirectPort});else{let t;i===`imap`?t={host:H.trim(),...W.trim()?{port:Number(W.trim())}:{},secure:K,user:String(n.address??``),pass:B}:B.trim()&&(t=B.trim()),await r.bindConnector(e.id,{type:P.id,...R.trim()?{displayName:R.trim()}:{},config:n,...t===void 0?{}:{credential:t}})}_(`Connector added.`),X(),await Y();try{let n=await r.getProject(e.id);n&&t?.(n)}catch{}}catch(e){let t=e instanceof Error?e.message:String(e);T(t)&&J(e=>e+1),h(t)}finally{p(null)}},[P,e.id,fe,R,B,H,W,K,X,Y,t,Q]),pe=(0,l.useCallback)(async e=>{if(Q){h(``),p(`oauth-app`);try{await r.putOAuthClient(Q.clientKey,e),await Z().catch(()=>{ae(t=>({...t,[Q.clientKey]:{clientId:e.clientId,hasSecret:!!e.clientSecret||(t[Q.clientKey]?.hasSecret??!1)}}))}),J(0)}catch(e){throw h(e instanceof Error?e.message:String(e)),e}finally{p(null)}await $()}},[Q,Z,$]),me=n?.bindings??[],he=P?.secretShape?.kind,ge=e=>{e.id!==P?.id&&(F(e),L(y(e)),z(``),V(``),U(``),G(``),q(!0),h(``),J(0))};return(0,u.jsxs)(`div`,{className:`settings-section`,children:[(0,u.jsxs)(`div`,{className:`gz-mail-header`,children:[(0,u.jsx)(`h3`,{children:`Connections`}),!j&&(0,u.jsx)(`button`,{type:`button`,onClick:()=>void le(),children:`Add connection`})]}),me.length===0&&!j?(0,u.jsx)(`p`,{className:`muted`,children:`No connectors yet. Add one to mirror an external source (email, issues, a data source) into this project as searchable files.`}):(0,u.jsx)(`ul`,{className:`settings-list`,children:me.map(e=>(0,u.jsxs)(`li`,{children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`strong`,{children:e.displayName||e.type}),(0,u.jsxs)(`span`,{className:`muted small`,children:[` · `,e.type]}),(0,u.jsx)(`div`,{className:`small`,children:e.lastError?(0,u.jsxs)(`span`,{className:`error`,children:[`Error: `,e.lastError]}):e.lastSyncedAt?(0,u.jsxs)(`span`,{className:`muted`,title:a(e.lastSyncedAt),children:[`Last synced `,i(e.lastSyncedAt)]}):(0,u.jsx)(`span`,{className:`muted`,children:`Not synced yet`})}),e.tables&&e.tables.length>0?(0,u.jsx)(ee,{tables:e.tables}):null]}),(0,u.jsxs)(`div`,{className:`gz-mail-link-actions`,children:[(0,u.jsx)(`button`,{type:`button`,onClick:()=>void ue(e.id),disabled:f===e.id,children:f===e.id?`Working…`:`Sync now`}),(0,u.jsx)(`button`,{type:`button`,className:`danger`,onClick:()=>x(e.id),disabled:f===e.id,children:`Remove`})]})]},e.id))}),S.length>0&&(0,u.jsxs)(`div`,{className:`settings-subsection`,children:[(0,u.jsx)(`h4`,{children:`Pending actions`}),(0,u.jsx)(`p`,{className:`muted small`,children:`Drafted by a gezel — review, then commit (the live write). You commit; the gezel can't.`}),(0,u.jsx)(`ul`,{className:`settings-list`,children:S.map(e=>(0,u.jsxs)(`li`,{children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`strong`,{children:e.action}),(0,u.jsxs)(`span`,{className:`muted small`,children:[` · `,e.connectorType]}),e.status===`queued`&&(0,u.jsx)(`span`,{className:`badge`,children:` held for daytime`})]}),(0,u.jsxs)(`div`,{className:`gz-mail-link-actions`,children:[(0,u.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void se(e.draftId),disabled:f===e.draftId,children:f===e.draftId?`Working…`:`Commit`}),(0,u.jsx)(`button`,{type:`button`,onClick:()=>void ce(e.draftId),disabled:f===e.draftId,children:`Discard`})]})]},e.draftId))})]}),j&&(0,u.jsxs)(`div`,{className:`gz-connector-picker`,children:[(0,u.jsxs)(`div`,{className:`gz-connector-picker-heading`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`strong`,{children:`Choose a connector`}),(0,u.jsx)(`p`,{className:`muted small`,children:`Pick a source to mirror into this project's searchable files.`})]}),(0,u.jsx)(`span`,{className:`gz-connector-picker-count`,children:ne?`Loading…`:`${M.length} available`})]}),ne?(0,u.jsx)(`div`,{className:`gz-connector-picker-empty muted small`,children:`Gathering connectors…`}):M.length===0?(0,u.jsx)(`div`,{className:`gz-connector-picker-empty muted small`,children:`No connector types are available.`}):(0,u.jsx)(`div`,{className:`gz-connector-grid`,role:`radiogroup`,"aria-label":`Connector type`,children:M.map((e,t)=>(0,u.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":P?.id===e.id,"aria-label":e.name,className:`gz-npd-card gz-connector-card${P?.id===e.id?` active`:``}`,onClick:()=>ge(e),style:{"--card-i":Math.min(t,11)},children:[(0,u.jsx)(`span`,{className:`gz-npd-card-mark`,children:(0,u.jsx)(c,{iconSvg:e.iconSvg,logoUrl:e.logoUrl,svgClassName:`gz-npd-card-mark-svg`,fallback:(0,u.jsx)(s,{glyph:O(e),size:19})})}),(0,u.jsx)(`span`,{className:`gz-npd-card-name`,children:e.name}),(0,u.jsx)(`span`,{className:`gz-npd-card-description`,children:e.description}),(0,u.jsxs)(`span`,{className:`gz-connector-card-meta`,"aria-hidden":`true`,children:[(0,u.jsx)(`span`,{children:k(e)}),(0,u.jsx)(`span`,{children:A(e)})]})]},e.id))}),P&&(0,u.jsxs)(`div`,{className:`gz-mail-link-form gz-connector-config`,"aria-label":`${P.name} setup`,children:[(0,u.jsxs)(`div`,{className:`gz-connector-config-heading`,children:[(0,u.jsx)(`span`,{className:`gz-connector-config-mark`,children:(0,u.jsx)(c,{iconSvg:P.iconSvg,logoUrl:P.logoUrl,svgClassName:`gz-npd-card-mark-svg`,fallback:(0,u.jsx)(s,{glyph:O(P),size:19})})}),(0,u.jsxs)(`div`,{children:[(0,u.jsxs)(`strong`,{children:[`Set up `,P.name]}),(0,u.jsxs)(`div`,{className:`small muted`,children:[k(P),` · `,A(P)]})]})]}),(0,u.jsx)(b,{connector:P,config:I,onConfigChange:(e,t)=>L(n=>({...n,[e]:t})),displayName:R,onDisplayNameChange:z,credential:B,onCredentialChange:V,imapHost:H,onImapHostChange:U,imapPort:W,onImapPortChange:G,imapSecure:K,onImapSecureChange:q}),Q&&(0,u.jsx)(E,{requirement:Q,registered:ie[Q.clientKey]??null,forceOpenNonce:oe,busy:f===`oauth-app`||f===`add`,onSave:pe},P.id)]}),(0,u.jsxs)(`div`,{className:`gz-mail-link-actions gz-connector-picker-actions`,children:[(0,u.jsx)(`button`,{type:`button`,onClick:X,disabled:f===`add`,children:`Cancel`}),P&&(0,u.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void $(),disabled:f===`add`,children:f===`add`?`Working…`:he===`oauth2`?`Connect`:`Add`})]})]}),m&&(0,u.jsx)(`p`,{className:`error small`,children:m}),g&&(0,u.jsx)(`p`,{className:`muted small`,children:g}),(0,u.jsx)(o,{open:v!==null,title:`Remove connector?`,message:`This removes the binding and its stored credential. Synced files stay on disk.`,confirmLabel:`Remove`,danger:!0,onConfirm:()=>{v&&de(v)},onCancel:()=>x(null)})]})}export{j as ProjectConnectionsTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-BPraLwsh.js";import{_ as i,a,d as o,g as ee,i as s,l as c,m as l,p as u,r as d,s as f,t as te,v as ne,y as re}from"./primitives-CWrGZpPI.js";import{n as ie,t as ae}from"./relative-time-B2kBaekd.js";import{s as oe}from"./gitCopy-Dcjz17cJ.js";import{r as se,t as ce}from"./useGitSync-BCTptQsp.js";var p=e(t(),1),m=n(),le=`Active — the Meester nudges the voorman, phase handoffs auto-start, and scheduled tasks tick. Read-only or Inactive — ambient gezel work pauses. Chat still works.`,ue=`Whether Gezel-managed tools and background work may create, edit, and delete files in this project's workspace. Internal workspaces default to on; a project opened from an existing folder defaults to off (turning it on asks for confirmation first). Provider-native access such as Codex is shown separately.`,h=[{value:`plan`,label:`Plan`,hint:`Read and reason without changing workspace files.`},{value:`edit`,label:`Edit`,hint:`Edit inside the workspace; deny boundary crossings.`},{value:`reviewed`,label:`Reviewed`,hint:`Edit in the workspace; send boundary crossings to an independent Codex reviewer.`},{value:`full`,label:`Full`,hint:`Run without Codex sandboxing or approvals. Gezel still blocks a narrow set of unmistakably destructive commands.`}],de=[{value:`plan`,label:`Plan`,hint:`Read and reason without changing workspace files.`},{value:`default`,label:`Ask`,hint:`Let Claude request permission for tool use.`},{value:`acceptEdits`,label:`Edit`,hint:`Auto-approve file edits; gate shell commands.`},{value:`bypassPermissions`,label:`Full`,hint:`Bypass Claude permission prompts, including for shell commands.`}];function fe(e){let t=h.find(t=>t.value===e);return`Codex ${t?.label??e}: ${t?.hint??``}`}function pe(e){if(e===`mixed`)return`Claude: assigned gezels currently use different permission modes.`;let t=de.find(t=>t.value===e);return`Claude ${t?.label??e}: ${t?.hint??``}`}var me=[{value:`active`,label:`Active`},{value:`stable`,label:`Stable`},{value:`readonly`,label:`Read-only`},{value:`inactive`,label:`Inactive`}];function g({unlocked:e=!1}){return(0,m.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,focusable:`false`,children:[(0,m.jsx)(`rect`,{x:`3`,y:`7`,width:`10`,height:`7`,rx:`1.25`,stroke:`currentColor`,strokeWidth:`1.5`}),e?(0,m.jsx)(`path`,{d:`M5 7V5a3 3 0 0 1 5.75-1.2`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`}):(0,m.jsx)(`path`,{d:`M5 7V5a3 3 0 0 1 6 0v2`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function he(){return(0,m.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,focusable:`false`,children:[(0,m.jsx)(`rect`,{x:`3`,y:`1.75`,width:`10`,height:`12.5`,rx:`1.5`,stroke:`currentColor`,strokeWidth:`1.1`}),(0,m.jsx)(`line`,{x1:`5.2`,y1:`5`,x2:`10.8`,y2:`5`,stroke:`currentColor`,strokeWidth:`1`,strokeLinecap:`round`,opacity:`0.35`}),(0,m.jsx)(`line`,{x1:`5.2`,y1:`7.5`,x2:`10.8`,y2:`7.5`,stroke:`currentColor`,strokeWidth:`1`,strokeLinecap:`round`,opacity:`0.35`}),(0,m.jsx)(`line`,{x1:`5.2`,y1:`10`,x2:`9.4`,y2:`10`,stroke:`currentColor`,strokeWidth:`1`,strokeLinecap:`round`,opacity:`0.35`}),(0,m.jsx)(`line`,{className:`project-index-scanline`,x1:`4.4`,y1:`4.2`,x2:`11.6`,y2:`4.2`,strokeWidth:`1.3`,strokeLinecap:`round`})]})}function ge(){return(0,m.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,focusable:`false`,children:[(0,m.jsxs)(`g`,{className:`project-index-quill-feather`,children:[(0,m.jsx)(`path`,{d:`M13 2.5C10.2 3.4 7.4 5.7 6 8.7L5.1 10.9L7.3 10C10.3 8.6 12.1 5.4 13 2.5Z`,stroke:`currentColor`,strokeWidth:`1.1`,strokeLinejoin:`round`}),(0,m.jsx)(`path`,{d:`M11.6 3.9L6.6 9.4`,stroke:`currentColor`,strokeWidth:`0.9`,opacity:`0.45`}),(0,m.jsx)(`path`,{d:`M5.1 10.9L4.2 12.1`,stroke:`currentColor`,strokeWidth:`1.1`,strokeLinecap:`round`})]}),(0,m.jsx)(`path`,{className:`project-index-quill-line`,d:`M3.4 13.9H12.4`,strokeWidth:`1.3`,strokeLinecap:`round`})]})}function _e({projectStatus:e,statusLocked:t,onStatusChange:n,managedWritesOn:r,onManagedWorkspaceWritesChange:a,codexMode:o,onCodexModeChange:s,claudeMode:c,onClaudeModeChange:l}){let[u,d]=(0,p.useState)(!1);return!n&&!s&&!l&&(!a||r)?null:(0,m.jsx)(`div`,{className:`project-controls-overflow`,children:(0,m.jsxs)(i,{open:u,onOpenChange:d,children:[(0,m.jsx)(ne,{asChild:!0,children:(0,m.jsx)(`button`,{type:`button`,className:`project-controls-overflow-trigger`,title:`More project controls`,"aria-label":`More project controls`,children:`…`})}),(0,m.jsx)(ee,{className:`project-controls-overflow-popover`,side:`top`,align:`end`,children:(0,m.jsxs)(`fieldset`,{className:`project-controls-overflow-fieldset`,children:[(0,m.jsx)(`legend`,{className:`sr-only`,children:`Project controls overflow`}),n&&(0,m.jsxs)(`section`,{className:`project-controls-overflow-section`,children:[(0,m.jsx)(`span`,{className:`project-controls-overflow-label`,children:`Project status`}),(0,m.jsx)(`div`,{className:`project-controls-overflow-options`,children:me.map(r=>(0,m.jsxs)(`button`,{type:`button`,className:`project-controls-overflow-item project-status-select-${r.value}`,"aria-pressed":e===r.value,disabled:t,onClick:()=>{n(r.value),d(!1)},children:[(0,m.jsx)(`span`,{className:`project-status-select-dot`,"aria-hidden":!0}),(0,m.jsx)(`span`,{children:r.label})]},r.value))})]}),a&&!r&&(0,m.jsxs)(`section`,{className:`project-controls-overflow-section`,children:[(0,m.jsx)(`span`,{className:`project-controls-overflow-label`,children:`Built-in tools`}),(0,m.jsxs)(`button`,{type:`button`,className:`project-controls-overflow-item`,onClick:()=>{a(!0),d(!1)},children:[(0,m.jsx)(`span`,{className:`project-writes-select-icon`,"aria-hidden":!0,children:(0,m.jsx)(g,{unlocked:!0})}),(0,m.jsx)(`span`,{children:`Allow workspace edits`})]})]}),o&&s&&(0,m.jsxs)(`section`,{className:`project-controls-overflow-section`,children:[(0,m.jsx)(`span`,{className:`project-controls-overflow-label`,children:`Codex access`}),(0,m.jsx)(`div`,{className:`project-controls-overflow-options`,children:h.map(e=>(0,m.jsx)(`button`,{type:`button`,className:`project-controls-overflow-item`,"aria-pressed":o===e.value,title:e.hint,onClick:()=>{s(e.value),d(!1)},children:e.label},e.value))})]}),c&&l&&(0,m.jsxs)(`section`,{className:`project-controls-overflow-section`,children:[(0,m.jsx)(`span`,{className:`project-controls-overflow-label`,children:`Claude access`}),(0,m.jsx)(`div`,{className:`project-controls-overflow-options`,children:de.map(e=>(0,m.jsx)(`button`,{type:`button`,className:`project-controls-overflow-item`,"aria-pressed":c===e.value,title:e.hint,onClick:()=>{l(e.value),d(!1)},children:e.label},e.value))})]})]})})]})})}function _({projectId:e,compact:t=!1,managedWorkspaceWritable:n=!0,onManagedWorkspaceWritesChange:_,codexMode:v,onCodexModeChange:Se,claudeMode:y,onClaudeModeChange:b,onOpenGitHub:x,onAddBoekwachter:S,status:C,statusLocked:w=!1,onStatusChange:T}){let[E,Ce]=(0,p.useState)(null),[D,we]=(0,p.useState)(null),[O,Te]=(0,p.useState)(null),[k,A]=(0,p.useState)(!1),[Ee,De]=(0,p.useState)(!1),[Oe,ke]=(0,p.useState)(``),[Ae,j]=(0,p.useState)(``),[M,je]=(0,p.useState)(null),[Me,Ne]=(0,p.useState)(!1),[N,Pe]=(0,p.useState)(!1),[Fe,P]=(0,p.useState)(null),[F,I]=(0,p.useState)(`idle`),[L,R]=(0,p.useState)(`idle`),[z,B]=(0,p.useState)(null),[V,Ie]=(0,p.useState)(!1),H=(0,p.useRef)(null),U=n,W=(0,p.useCallback)(async()=>{try{let t=await r.getProjectGitStatus(e);Ce(t)}catch{}},[e]),G=(0,p.useCallback)(async()=>{try{we(await r.getProjectIndexStatus(e))}catch{}},[e]);(0,p.useEffect)(()=>{W(),G();let e=window.setInterval(()=>{W(),G()},3e4);return()=>window.clearInterval(e)},[W,G]);let Le=D?.aiDrive!=null||F!==`idle`;(0,p.useEffect)(()=>{if(!Le)return;let e=window.setInterval(()=>void G(),5e3);return()=>window.clearInterval(e)},[Le,G]),(0,p.useEffect)(()=>{let t=t=>{t.detail?.projectId===e&&W()};return window.addEventListener(ce,t),()=>window.removeEventListener(ce,t)},[e,W]);let K=(0,p.useRef)(null),[Re,ze]=(0,p.useState)(!1);(0,p.useEffect)(()=>{let e=D?.enrichment?.pending;if(e===void 0||e<=0||D?.aiDrive){K.current=null,ze(!1);return}let t=K.current;if(K.current={pending:e,at:Date.now()},!t)return;let n=Date.now()-t.at;if(n<2e4)return;let r=t.pending-e,i=r>0?r/n:5/12e4;ze(e/i>1440*60*1e3)},[D]);let Be=(0,p.useCallback)(async()=>{if(!(N||D===null||D.state===`disabled`||D.state===`indexing`)){Pe(!0),P(null);try{await r.refreshProjectIndex(e),we(e=>e?{...e,state:`indexing`}:{state:`indexing`}),window.setTimeout(()=>void G(),800)}catch{P(`Couldn’t start the index update. Try again.`)}finally{Pe(!1)}}},[N,D,e,G]),Ve=(0,p.useRef)(null),He=(0,p.useCallback)(async()=>{if(!(F!==`idle`||D===null||D.state===`disabled`||D.aiDrive!=null)){I(`starting`),B(null),Ve.current=D;try{let t=await r.driveIndexEnrichment(e,{intensity:`full`});if(t.mode===`embed-only`){B({code:`boekwachter-required`,message:t.hint??``}),I(`idle`),window.setTimeout(()=>void G(),800);return}I(`running`),window.setTimeout(()=>void G(),800)}catch(e){let t=e&&typeof e==`object`&&`details`in e?e.details:void 0;B({code:t?.error,message:t?.message??`Couldn’t start the full scan. Try again.`}),I(`idle`)}}},[F,D,e,G]),Ue=(0,p.useCallback)(async()=>{if(L===`idle`){R(`requesting`),B(null);try{await r.stopIndexEnrichment(e),R(`stopping`),window.setTimeout(()=>void G(),800)}catch{R(`idle`),B({message:`Couldn’t stop the scan. Try again.`})}}},[L,e,G]),We=(0,p.useCallback)(async()=>{if(!(!S||V)){Ie(!0);try{await S(),B(null)}catch(e){B({message:e instanceof Error?e.message:`Couldn’t add the Boekwachter. Try again.`})}finally{Ie(!1)}}},[V,S]);(0,p.useEffect)(()=>{F===`running`&&D!==Ve.current&&D!==null&&D.aiDrive==null&&I(`idle`)},[F,D]),(0,p.useEffect)(()=>{L!==`idle`&&D!==null&&D.aiDrive==null&&R(`idle`)},[L,D]),(0,p.useEffect)(()=>{if(!k)return;let e=e=>{H.current&&!H.current.contains(e.target)&&(A(!1),De(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[k]),(0,p.useEffect)(()=>{!k||O||r.listProjectGitBranches(e).then(Te).catch(()=>Te({local:[],remote:[]}))},[k,O,e]);let q=(0,p.useCallback)((e,t)=>{je({kind:e,text:t}),window.setTimeout(()=>je(null),4e3)},[]),{sync:Ge,syncing:Ke}=se(e,{onToast:q,onNeedsSave:()=>{q(`err`,`Save your changes first — they’re waiting in the GitHub tab.`),x?.()},onConflicts:()=>x?.(),onAuth:()=>x?.()}),qe=(0,p.useCallback)(async()=>{await Ge(),await W()},[Ge,W]),Je=(0,p.useCallback)(async t=>{A(!1),j(`branch`);try{await r.setProjectGitBranch(e,t),await W(),q(`ok`,`Switched to ${t}.`)}catch(e){q(`err`,`Couldn’t switch: ${e instanceof Error?e.message:String(e)}`)}finally{j(``)}},[e,W,q]),Ye=(0,p.useCallback)(async t=>{t.preventDefault();let n=Oe.trim();if(n){A(!1),De(!1),ke(``),j(`branch`);try{await r.createProjectGitBranch(e,n),Te(null),await W(),q(`ok`,`Created and switched to ${n}.`)}catch(e){q(`err`,`Couldn’t create: ${e instanceof Error?e.message:String(e)}`)}finally{j(``)}}},[Oe,e,W,q]),Xe=!!E?.github,Ze=E?.branch,J=E?.github?.lastSyncedAt,Y=D?.state??`never`,X=D?.aiScanPending===!0,Qe=D?.embeddings?.status,$e=Qe===`disabled`||Qe===`unavailable`||D?.enrichment?.vectorsAvailable===!1,et=D?.embeddings?.reason??(D?.enrichment?.vectorsAvailable===!1?`the vector extension failed to load`:`the embedding model could not be loaded`),tt=Y===`disabled`?`disabled`:Y===`indexing`?`indexing`:Y===`fresh`?X||$e?`scan`:`fresh`:`stale`,Z=D?.enrichment,nt=Z?.searchReady??Z?.embedded??0;Z&&ve(nt,Z.eligible);let rt=Z?.skipped??0,it=Z?.skippedFiles??[],at=Math.max(0,rt-it.length),ot=Z?`${Z.summarized} of ${Z.eligible} files${rt>0?` · ${rt} skipped after repeated failures`:``}`:``,Q=Z?ye(Z):null,$=D?.aiDrive??null,st=D===null?`Checking workspace index`:Y===`disabled`?`Workspace indexing is off`:Y===`indexing`?`Scanning workspace`:Y===`never`?`Workspace not indexed`:Y===`stale`?`Workspace scan is out of date`:X?Q===null?`AI indexing is pending`:`AI indexing ${Q}% complete`:`Workspace index is ready`,ct=`Indexing status: ${st}`,lt=D===null||Y===`disabled`||Y===`indexing`||N,ut=E?oe({mergeInProgress:E.mergeInProgress,changesCount:E.changesCount,ahead:E.ahead,behind:E.behind,syncStale:E.syncStale}):``,dt=E?.mergeInProgress===!0||(E?.changesCount??0)>0||(E?.ahead??0)>0||(E?.behind??0)>0||E?.syncStale===!0,ft=E?.syncStale===!0||(E?.ahead??0)>0||(E?.behind??0)>0;return(0,m.jsxs)(`div`,{className:`project-git-status-bar${t?` is-compact`:``}`,children:[(0,m.jsxs)(`div`,{className:`project-git-status-bar-left`,children:[Xe&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`project-git-branch-picker`,ref:H,children:[(0,m.jsxs)(`button`,{type:`button`,className:`project-git-branch-chip`,onClick:()=>A(e=>!e),disabled:!E?.exists,title:`Switch branch`,children:[(0,m.jsx)(`span`,{className:`project-git-icon`,"aria-hidden":!0,children:`⎇`}),(0,m.jsx)(`span`,{className:`project-git-branch-name`,children:Ze??`(detached)`}),(0,m.jsx)(re,{className:`project-git-chevron`})]}),k&&(0,m.jsxs)(`div`,{className:`project-git-branch-menu`,role:`menu`,children:[O===null?(0,m.jsx)(`div`,{className:`project-git-branch-loading muted small`,children:`Loading branches…`}):(0,m.jsxs)(m.Fragment,{children:[O.local.length>0&&(0,m.jsxs)(`div`,{className:`project-git-branch-group`,children:[(0,m.jsx)(`div`,{className:`project-git-branch-group-label muted small`,children:`Local`}),O.local.map(e=>(0,m.jsx)(`button`,{type:`button`,className:`project-git-branch-item${e===Ze?` is-current`:``}`,onClick:()=>void Je(e),children:e},`local-${e}`))]}),O.remote.length>0&&(0,m.jsxs)(`div`,{className:`project-git-branch-group`,children:[(0,m.jsx)(`div`,{className:`project-git-branch-group-label muted small`,children:`Remote`}),O.remote.map(e=>(0,m.jsx)(`button`,{type:`button`,className:`project-git-branch-item`,onClick:()=>void Je(e),children:e},`remote-${e}`))]})]}),(0,m.jsx)(`div`,{className:`project-git-branch-divider`}),Ee?(0,m.jsxs)(`form`,{className:`project-git-new-branch-form`,onSubmit:Ye,children:[(0,m.jsx)(`input`,{value:Oe,onChange:e=>ke(e.target.value),placeholder:`new-branch-name`,autoFocus:!0}),(0,m.jsx)(`button`,{type:`submit`,className:`primary`,children:`Create`})]}):(0,m.jsx)(`button`,{type:`button`,className:`project-git-branch-item project-git-new-branch-trigger`,onClick:()=>De(!0),children:`+ new branch`})]})]}),E&&!t&&(0,m.jsxs)(`button`,{type:`button`,className:`project-git-status-chip${dt?` has-attention`:``}${E.mergeInProgress?` has-conflict`:``}`,onClick:x,title:`Open the GitHub tab`,children:[ut,!dt&&J&&(0,m.jsxs)(`span`,{className:`muted small`,title:ae(J),children:[` `,`· synced `,ie(J,{seconds:!0})]})]})]}),(0,m.jsxs)(i,{open:Me,onOpenChange:e=>{Ne(e),e&&(P(null),G())},children:[(0,m.jsx)(ne,{asChild:!0,children:(0,m.jsxs)(`button`,{type:`button`,className:`project-index-chip project-index-chip-${tt}`,"aria-label":ct,title:`Open indexing status`,children:[(0,m.jsxs)(`svg`,{className:`project-index-icon`,width:`14`,height:`14`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:[(0,m.jsx)(`rect`,{x:`3`,y:`2`,width:`10.5`,height:`12`,rx:`1.3`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`}),(0,m.jsx)(`line`,{x1:`6`,y1:`2`,x2:`6`,y2:`14`,stroke:`currentColor`,strokeWidth:`1.2`}),(0,m.jsx)(`line`,{x1:`8`,y1:`5.5`,x2:`11.5`,y2:`5.5`,stroke:`currentColor`,strokeWidth:`1.1`,strokeLinecap:`round`}),(0,m.jsx)(`line`,{x1:`8`,y1:`8`,x2:`11.5`,y2:`8`,stroke:`currentColor`,strokeWidth:`1.1`,strokeLinecap:`round`}),(0,m.jsx)(`line`,{x1:`8`,y1:`10.5`,x2:`10.5`,y2:`10.5`,stroke:`currentColor`,strokeWidth:`1.1`,strokeLinecap:`round`})]}),(0,m.jsx)(`span`,{className:`project-index-dot`,"aria-hidden":!0})]})}),(0,m.jsx)(ee,{className:`project-index-popover`,side:`top`,align:`center`,"aria-label":`Indexing status`,children:(0,m.jsxs)(`div`,{className:`project-index-panel`,children:[(0,m.jsxs)(`div`,{className:`project-index-panel-heading`,children:[(0,m.jsx)(`span`,{className:`project-index-panel-dot project-index-panel-dot-${tt}`,"aria-hidden":!0}),(0,m.jsx)(`strong`,{children:st}),Y===`indexing`||N?(0,m.jsx)(`span`,{className:`project-index-phase-spinner`,role:`img`,"aria-label":`File scan running`,title:`Reading the workspace file by file`,children:(0,m.jsx)(he,{})}):$!==null||F===`running`?(0,m.jsx)(`span`,{className:`project-index-phase-spinner`,role:`img`,"aria-label":`AI scan running`,title:`Studying files — summaries, reviews, and media`,children:(0,m.jsx)(ge,{})}):null]}),$e&&(0,m.jsxs)(`p`,{className:`project-index-panel-warning`,children:[`Semantic search is off — `,et,`. Results are keyword-only`,Qe===`unavailable`?`; retrying automatically`:``,`.`]}),Z&&Z.eligible>0&&Q!==null&&(0,m.jsxs)(`div`,{className:`project-index-panel-progress`,children:[(0,m.jsxs)(`div`,{className:`project-index-panel-progress-label`,children:[(0,m.jsx)(`span`,{children:`Indexing progress`}),(0,m.jsxs)(`strong`,{children:[Q,`%`]})]}),(0,m.jsx)(`div`,{className:`project-index-panel-progress-track`,role:`progressbar`,"aria-label":`Indexing progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Q,tabIndex:-1,children:(0,m.jsx)(`span`,{style:{width:`${Q}%`}})}),(0,m.jsxs)(`span`,{className:`project-index-panel-caption`,children:[nt,` of `,Z.eligible,` files searchable`,Z.pending>0?` · ${Z.pending} waiting`:``]})]}),(0,m.jsxs)(`dl`,{className:`project-index-panel-details`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{children:`File scan`}),(0,m.jsx)(`dd`,{children:be(Y)})]}),D?.meta&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{children:`Indexed`}),(0,m.jsxs)(`dd`,{children:[D.meta.fileCount,` file`,D.meta.fileCount===1?``:`s`]})]}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{children:`Last scan`}),(0,m.jsxs)(`dd`,{title:ae(D.meta.scannedAt),children:[ie(D.meta.scannedAt,{seconds:!0}),` ·`,` `,xe(D.meta.durationMs)]})]})]}),$&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{children:`AI scan`}),(0,m.jsx)(`dd`,{children:$===`full`?`Running at full speed`:`Running quietly in background`})]}),Z&&(Z.shadowsPending??0)>0&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{children:`Media scan`}),(0,m.jsxs)(`dd`,{children:[Z.shadowsPending,` waiting`]})]}),Z&&Z.eligible>0&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{children:`AI summaries`}),(0,m.jsx)(`dd`,{children:it.length>0?(0,m.jsx)(d,{delayDuration:150,children:(0,m.jsxs)(s,{children:[(0,m.jsx)(a,{asChild:!0,children:(0,m.jsx)(`button`,{type:`button`,className:`project-index-skipped-trigger`,children:ot})}),(0,m.jsx)(te,{side:`left`,children:(0,m.jsxs)(`div`,{className:`project-index-skipped-tip`,children:[(0,m.jsx)(`strong`,{children:`Skipped after repeated failures`}),(0,m.jsx)(`ul`,{children:it.map(e=>(0,m.jsxs)(`li`,{children:[(0,m.jsx)(`span`,{className:`project-index-skipped-path`,children:e.path}),e.reason&&(0,m.jsx)(`span`,{className:`project-index-skipped-reason`,children:e.reason})]},e.path))}),at>0&&(0,m.jsxs)(`span`,{className:`project-index-skipped-more`,children:[`and `,at,` more`]}),(0,m.jsx)(`span`,{className:`project-index-skipped-note`,children:`Each retries once its content changes.`})]})})]})}):ot})]}),Z?.reviews&&Z.reviews.eligible>0&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{children:`Quality review`}),(0,m.jsxs)(`dd`,{children:[Z.reviews.reviewed,` of `,Z.reviews.eligible,Z.reviews.pending>0?` · ${Z.reviews.pending} waiting`:``,Z.reviews.stale>0?` · ${Z.reviews.stale} to refresh`:``]})]})]}),(0,m.jsxs)(`div`,{className:`project-index-panel-footer`,children:[(0,m.jsx)(`span`,{className:`project-index-panel-note`,children:Y===`disabled`?(0,m.jsxs)(m.Fragment,{children:[`Workspace indexing is off.`,` `,(0,m.jsx)(`button`,{type:`button`,className:`project-index-panel-link`,onClick:()=>window.dispatchEvent(new CustomEvent(`gezel:open-project-settings`,{detail:{projectId:e}})),children:`Turn it on in Project Settings`}),`.`]}):$===`full`?`Full scan in progress — it shares the model with chat, so counts move as calls finish.`:$===`background`?`Background scan in progress — it politely waits while you chat.`:Y===`indexing`?`The status updates automatically while the scan runs.`:X&&Re?(0,m.jsxs)(m.Fragment,{children:[`At the idle pace this will take more than a day.`,` `,(0,m.jsx)(`button`,{type:`button`,className:`project-index-panel-link`,onClick:()=>window.dispatchEvent(new CustomEvent(`gezel:open-night-shift`)),children:`Set up Night Shift`}),` `,`or use “Start full AI scan” to finish sooner.`]}):X?`AI indexing continues while the app is idle.`:`Refresh the index whenever you need the latest workspace state.`}),(0,m.jsxs)(`div`,{className:`project-index-panel-actions`,children:[$!==null||F===`running`?(0,m.jsx)(`button`,{type:`button`,className:`project-index-update-button`,disabled:L!==`idle`,onClick:()=>void Ue(),title:`Stop the running scan at its next step. Everything indexed so far is kept.`,children:L===`idle`?`Stop updating index`:`Stopping…`}):(0,m.jsx)(`button`,{type:`button`,className:`project-index-update-button`,disabled:lt,onClick:()=>void Be(),children:Y===`indexing`||N?`Updating index…`:`Update index`}),Y!==`disabled`&&(0,m.jsx)(`button`,{type:`button`,className:`project-index-update-button project-index-full-scan-button`,disabled:F!==`idle`||$!==null||D===null,onClick:()=>void He(),title:`Bring the whole index up to date at full speed — file scan plus AI summaries, rollups, and reviews, run to completion. Shares the model with chat while it works.`,children:F===`starting`?`Starting full scan…`:F===`running`||$===`full`?`Full scan running…`:$===`background`?`Background scan running…`:`Start full AI scan`})]}),Fe&&(0,m.jsx)(`span`,{className:`project-index-panel-error`,role:`alert`,children:Fe}),z&&(0,m.jsx)(`span`,{className:`project-index-panel-error`,role:`alert`,children:z.code===`boekwachter-required`&&S?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`button`,{type:`button`,className:`project-index-panel-error-link`,disabled:V,onClick:()=>void We(),children:V?`Adding Boekwachter…`:`Add a Boekwachter to this project crew`}),` `,`to enable AI summaries, reviews, and semantic enrichment.`]}):z.message})]})]})})]}),(0,m.jsxs)(`div`,{className:`project-controls-inline`,children:[T&&(0,m.jsxs)(o,{value:C??`active`,disabled:w,onValueChange:e=>T(e),children:[(0,m.jsxs)(u,{className:`project-status-select project-status-select-${C??`active`}`,title:w?`Archived projects are inactive. Restore this project to change its status.`:le,"aria-label":`Project status`,children:[(0,m.jsx)(`span`,{className:`project-status-select-dot`,"aria-hidden":!0}),(0,m.jsx)(l,{})]}),(0,m.jsx)(f,{children:me.map(e=>(0,m.jsx)(c,{value:e.value,children:e.label},e.value))})]}),_&&(!t||!U)&&(0,m.jsxs)(o,{value:U?`on`:`off`,onValueChange:e=>_(e===`on`),children:[(0,m.jsxs)(u,{className:`project-writes-select project-writes-select-${U?`on`:`off`}`,title:ue,"aria-label":`Built-in tool workspace access for this project`,children:[(0,m.jsx)(`span`,{className:`project-writes-select-icon`,"aria-hidden":!0,children:(0,m.jsx)(g,{unlocked:U})}),(0,m.jsx)(l,{})]}),(0,m.jsxs)(f,{children:[(0,m.jsx)(c,{value:`on`,children:`Can edit`}),(0,m.jsx)(c,{value:`off`,children:`Read-only`})]})]}),v&&Se&&(0,m.jsxs)(o,{value:v,onValueChange:e=>Se(e),children:[(0,m.jsxs)(u,{className:`project-writes-select project-codex-mode project-codex-mode-${v}`,title:fe(v),"aria-label":`Codex execution mode for this project`,children:[(0,m.jsx)(`span`,{className:`project-writes-select-icon`,"aria-hidden":!0,children:(0,m.jsx)(g,{unlocked:v!==`plan`})}),(0,m.jsx)(`span`,{className:`project-permission-scope`,children:`Codex:`}),(0,m.jsx)(l,{})]}),(0,m.jsx)(f,{children:h.map(e=>(0,m.jsx)(c,{value:e.value,textValue:e.label,children:e.label},e.value))})]}),y&&b&&(0,m.jsxs)(o,{value:y,onValueChange:e=>{e!==`mixed`&&b(e)},children:[(0,m.jsxs)(u,{className:`project-writes-select project-claude-mode project-claude-mode-${y}`,title:pe(y),"aria-label":`Claude execution mode for this project`,children:[(0,m.jsx)(`span`,{className:`project-writes-select-icon`,"aria-hidden":!0,children:(0,m.jsx)(g,{unlocked:y!==`plan`&&y!==`mixed`})}),(0,m.jsx)(`span`,{className:`project-permission-scope`,children:`Claude:`}),(0,m.jsx)(l,{})]}),(0,m.jsxs)(f,{children:[y===`mixed`&&(0,m.jsx)(c,{value:`mixed`,disabled:!0,children:`Mixed`}),de.map(e=>(0,m.jsx)(c,{value:e.value,textValue:e.label,children:e.label},e.value))]})]})]}),t&&(0,m.jsx)(_e,{projectStatus:C??`active`,statusLocked:w,onStatusChange:T,managedWritesOn:U,onManagedWorkspaceWritesChange:_,codexMode:v,onCodexModeChange:Se,claudeMode:y,onClaudeModeChange:b}),!_&&!U&&(0,m.jsxs)(`span`,{className:`project-lockdown-chip`,title:`Managed workspace edits are off for this project. Enable "Allow built-in tools and background work to modify the workspace" in Project → Settings.`,"aria-label":`Built-in tool workspace access is read-only for this project.`,children:[(0,m.jsx)(`span`,{className:`project-lockdown-chip-icon`,"aria-hidden":!0,children:(0,m.jsx)(g,{})}),(0,m.jsx)(`span`,{className:`project-lockdown-chip-label`,children:`edits off`})]})]}),!t&&(0,m.jsx)(`div`,{className:`project-git-status-bar-right`,children:Xe&&(0,m.jsx)(`button`,{type:`button`,className:`project-git-action${ft?` primary`:``}`,onClick:()=>void qe(),disabled:Ke||Ae!==``,title:`Get new changes from GitHub and send yours`,children:Ke?`Syncing…`:`Sync`})}),M&&(0,m.jsx)(`output`,{className:`project-git-toast project-git-toast-${M.kind}`,children:M.text})]})}function ve(e,t){return t<=0?null:Math.round(Math.min(Math.max(e,0),t)/t*100)}function ye(e){let t=[[e.summarized,e.eligible],[e.embedded,e.eligible]];e.reviews&&t.push([e.reviews.reviewed,e.reviews.eligible]);let n=0,r=0;for(let[e,i]of t)i<=0||(n+=Math.min(Math.max(e,0),i),r+=i);return r>0?Math.round(n/r*100):null}function be(e){switch(e){case`fresh`:return`Up to date`;case`stale`:return`Needs a rescan`;case`indexing`:return`Scanning now`;case`never`:return`Not scanned yet`;case`disabled`:return`Off for this project`}}function xe(e){if(e<1e3)return`${Math.max(1,Math.round(e))}ms`;if(e<6e4)return`${(e/1e3).toFixed(+(e<1e4))}s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return n>0?`${t}m ${n}s`:`${t}m`}export{_ as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{i as r,n as i,r as a}from"./Tabs-BAY1Q79B.js";import"./primitives-DEsn1shf.js";import{t as o}from"./dist-D5aoNQwk.js";import{t as s}from"./api-BX5xXiFs.js";import{n as c,t as l}from"./relative-time-B2kBaekd.js";import{t as u}from"./ConfirmDialog-BHFs6vmJ.js";import{r as d,t as f}from"./GitDiffView-DrDrSeBb.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./gitCopy-Dcjz17cJ.js";import{t as y}from"./MarkdownField-D-0Zw7gM.js";import{n as b,r as x,t as S}from"./useGitSync-DWxX5-7K.js";import{t as C}from"./GithubSignInChip-CnlTCG8G.js";var w=e(t(),1),T=n();function E({review:e,onCancel:t,disabled:n}){let[r,i]=(0,w.useState)(!1),a=e.needsAttention===!0,o=e.assigneeName??`A reviewer`,s=e.stepsTotal&&e.stepsTotal>0?`step ${Math.min((e.stepsComplete??0)+1,e.stepsTotal)} of ${e.stepsTotal}`:void 0;return(0,T.jsxs)(`div`,{className:`gh-review-status-card ${a?`gh-review-status-attention`:`gh-review-status-running`}`,children:[(0,T.jsxs)(`div`,{className:`gh-review-status-main`,children:[(0,T.jsxs)(`strong`,{children:[g(e.kind),` · `,e.branch]}),(0,T.jsx)(`span`,{children:a?v.reviewNeedsAttention:(0,T.jsxs)(T.Fragment,{children:[o,` `,v.reviewRunning]})}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(e.createdAt),children:[p(e.filesChanged,`file`),s?` · ${s}`:``,e.activeStepName?` · ${e.activeStepName}`:``,` · started ${m(e.createdAt)}`]})]}),(0,T.jsx)(`button`,{type:`button`,className:`gh-review-stop small`,onClick:()=>i(!0),disabled:n,children:v.reviewStop}),(0,T.jsx)(u,{open:r,title:v.reviewStopTitle,message:v.reviewStopBody,confirmLabel:v.reviewStopConfirm,danger:!0,onConfirm:()=>{i(!1),t(e.id)},onCancel:()=>i(!1)})]})}var D=()=>{};function O({projectId:e,reviews:t,busy:n,changesCount:r,branch:i,defaultBranch:a,onStart:o,onCancel:c}){let u=t.filter(e=>e.status===`running`),d=t.filter(e=>e.status!==`running`),f=u.some(e=>e.kind===`commit`),h=u.some(e=>e.kind===`pr`),[_,b]=(0,w.useState)(null),x=(0,w.useMemo)(()=>d.find(e=>e.id===_)??d.find(e=>e.status===`complete`)??null,[d,_]),[S,C]=(0,w.useState)(null);(0,w.useEffect)(()=>{if(!x||x.status!==`complete`){C(null);return}let t=!1;return s.readProjectArtifact(e,x.reportPath).then(e=>{t||C({id:x.id,content:e.content})}).catch(()=>{t||C({id:x.id,content:null})}),()=>{t=!0}},[e,x]);let O=a?`Checks everything on ${i??`this branch`} against ${a}.`:v.reviewPrHint;return(0,T.jsxs)(`div`,{className:`gh-review-layout`,children:[(0,T.jsxs)(`div`,{className:`gh-review-rail`,children:[(0,T.jsxs)(`div`,{className:`gh-review-kickoff-row`,children:[(0,T.jsxs)(`div`,{className:`gh-review-card`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:()=>o(`commit`),disabled:n!==``||f||r===0,children:n===`start-commit`?`Starting…`:`✨ ${v.reviewCommitButton}`}),(0,T.jsx)(`p`,{className:`muted small`,children:r===0?v.reviewNothingCommit:v.reviewCommitHint})]}),(0,T.jsxs)(`div`,{className:`gh-review-card`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:()=>o(`pr`),disabled:n!==``||h,children:n===`start-pr`?`Starting…`:`✨ ${v.reviewPrButton}`}),(0,T.jsx)(`p`,{className:`muted small`,children:O})]})]}),u.map(e=>(0,T.jsx)(E,{review:e,onCancel:c,disabled:n!==``},e.id)),(0,T.jsxs)(`div`,{className:`gh-review-history`,children:[d.length===0&&u.length===0&&(0,T.jsx)(`p`,{className:`muted`,children:v.reviewHistoryEmpty}),d.map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`gh-review-history-item${x?.id===e.id?` is-selected`:``}`,onClick:()=>b(e.id),children:[(0,T.jsx)(`span`,{className:`gh-review-outcome-chip gh-review-outcome-${e.status}`,children:e.status===`complete`?`Reviewed`:e.status===`canceled`?`Stopped`:`Issue`}),(0,T.jsxs)(`span`,{className:`gh-review-history-title`,children:[g(e.kind),` · `,e.branch]}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(e.settledAt??e.createdAt),children:[p(e.filesChanged,`file`),` · `,m(e.settledAt??e.createdAt)]})]},e.id))]})]}),(0,T.jsx)(`div`,{className:`gh-review-report`,children:x&&x.status===`complete`?S?.id===x.id?S.content===null?(0,T.jsx)(`p`,{className:`muted`,children:v.reviewReportMissing}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`gh-review-report-header`,children:[(0,T.jsx)(`code`,{className:`gh-changes-diff-path`,title:x.reportPath,children:x.reportPath}),(0,T.jsx)(`button`,{type:`button`,className:`small`,onClick:()=>window.dispatchEvent(new CustomEvent(`gezel:open-file`,{detail:{projectId:e,path:x.reportPath,source:`artifacts`}})),children:v.reviewOpenInArtifacts})]}),(0,T.jsx)(y,{value:S.content,readOnly:!0,onCommit:D},`${x.id}:${x.reportPath}`)]}):(0,T.jsx)(`p`,{className:`muted`,children:v.reviewReportLoading}):(0,T.jsx)(`p`,{className:`placeholder`,children:u.length>0?`The report will appear here when the review finishes.`:`Pick a finished review to read its report.`})})]})}function k({projectId:e,path:t,kind:n,busy:r,onResolve:i}){let[a,o]=(0,w.useState)(null),[c,l]=(0,w.useState)(null),[u,d]=(0,w.useState)({step:`idle`});(0,w.useEffect)(()=>{o(null),l(null),d({step:`idle`});let n=!1;return s.getProjectGitConflictVersions(e,t).then(e=>{n||o(e)}).catch(e=>{n||l(e instanceof Error?e.message:String(e))}),()=>{n=!0}},[e,t]);let f=async()=>{d({step:`combining`});try{let n=await s.aiResolveProjectGitConflict(e,t);d({step:`preview`,content:n.merged})}catch(e){l(e instanceof Error?e.message:String(e)),d({step:`idle`})}};if(c)return(0,T.jsx)(`p`,{className:`error gh-conflict-error`,children:c});if(!a)return(0,T.jsx)(`p`,{className:`muted gh-conflict-loading`,children:`Loading…`});let p=!a.binary&&!a.tooLarge&&a.ours!==void 0&&a.theirs!==void 0;return u.step===`combining`?(0,T.jsx)(`p`,{className:`muted gh-conflict-loading`,children:v.conflictAiBusy}):u.step===`preview`||u.step===`editing`?(0,T.jsxs)(`div`,{className:`gh-conflict-ai-preview`,children:[(0,T.jsx)(`h4`,{children:v.conflictAiPreviewTitle}),u.step===`editing`?(0,T.jsx)(`textarea`,{className:`gh-conflict-ai-editor`,value:u.content,onChange:e=>d({step:`editing`,content:e.target.value}),"aria-label":`Edit the combined version`}):(0,T.jsx)(`pre`,{className:`gh-conflict-content`,children:u.content}),(0,T.jsxs)(`div`,{className:`gh-conflict-actions`,children:[(0,T.jsx)(`button`,{type:`button`,className:`primary`,disabled:r,onClick:()=>void i(`custom`,u.content),children:v.conflictAiUse}),u.step===`preview`?(0,T.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>d({step:`editing`,content:u.content}),children:v.conflictAiEdit}):null,(0,T.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>d({step:`idle`}),children:v.conflictAiBack})]})]}):(0,T.jsxs)(`div`,{className:`gh-conflict-file`,children:[(a.binary||a.tooLarge)&&(0,T.jsx)(`p`,{className:`muted small`,children:a.binary?`This file isn't text, so it can't be combined — pick one version.`:`This file is too large to preview — pick one version.`}),(0,T.jsxs)(`section`,{className:`gh-conflict-card`,children:[(0,T.jsxs)(`header`,{children:[(0,T.jsx)(`strong`,{children:v.conflictMineTitle}),n===`deleted-by-us`&&(0,T.jsx)(`span`,{className:`muted small`,children:`You deleted this file`})]}),a.ours!==void 0&&!a.binary&&!a.tooLarge&&(0,T.jsx)(`pre`,{className:`gh-conflict-content`,children:a.ours}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,disabled:r,onClick:()=>void i(`mine`),children:n===`deleted-by-us`?`Keep my version (stays deleted)`:v.conflictMineButton})]}),(0,T.jsxs)(`section`,{className:`gh-conflict-card`,children:[(0,T.jsxs)(`header`,{children:[(0,T.jsx)(`strong`,{children:v.conflictTheirsTitle}),n===`deleted-by-them`&&(0,T.jsx)(`span`,{className:`muted small`,children:`GitHub deleted this file`})]}),a.theirs!==void 0&&!a.binary&&!a.tooLarge&&(0,T.jsx)(`pre`,{className:`gh-conflict-content`,children:a.theirs}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,disabled:r,onClick:()=>void i(`theirs`),children:n===`deleted-by-them`?`Keep GitHub's version (deletes it)`:v.conflictTheirsButton})]}),p&&(0,T.jsx)(`div`,{className:`gh-conflict-ai-cta`,children:(0,T.jsxs)(`button`,{type:`button`,className:`gh-conflict-ai-button`,disabled:r,onClick:f,children:[`✨ `,v.conflictAiButton]})})]})}var A={mine:`Kept yours`,theirs:`Kept GitHub's`,combined:`Combined`};function j({projectId:e,resumed:t,showToast:n,onFinished:r,onExited:i}){let[a,o]=(0,w.useState)(null),[c,l]=(0,w.useState)(new Map),[d,f]=(0,w.useState)(null),[m,h]=(0,w.useState)(``),[g,_]=(0,w.useState)(!1);(0,w.useEffect)(()=>{let t=!1;return s.getProjectGitMergeState(e).then(e=>{if(!t){if(!e.inMerge){i();return}o(e.conflicts),f(e.conflicts[0]?.path??null)}}).catch(()=>{t||i()}),()=>{t=!0}},[e,i]);let y=(0,w.useCallback)(async(t,r,i)=>{h(`resolve`);try{await s.resolveProjectGitConflict(e,{path:t,choice:r,...i===void 0?{}:{content:i}}),l(e=>{let n=new Map(e);return n.set(t,r===`custom`?`combined`:r),n}),f(()=>(a??[]).filter(e=>e.path!==t&&!c.has(e.path))[0]?.path??null),b(e)}catch(e){n(`err`,e instanceof Error?e.message:String(e))}finally{h(``)}},[e,a,c,n]),x=(0,w.useCallback)(async()=>{h(`finish`);try{await s.completeProjectGitMerge(e),b(e),n(`ok`,v.conflictFinishToast),r()}catch(e){n(`err`,e instanceof Error?e.message:String(e)),h(``)}},[e,n,r]),S=(0,w.useCallback)(async()=>{h(`cancel`);try{await s.abandonProjectGitMerge(e),b(e),i()}catch(e){n(`err`,e instanceof Error?e.message:String(e)),h(``)}},[e,n,i]);if(a===null)return(0,T.jsx)(`p`,{className:`muted gh-conflict-loading`,children:`Loading…`});let C=a.filter(e=>c.has(e.path)).length,E=C===a.length,D=a.find(e=>e.path===d)??null;return(0,T.jsxs)(`div`,{className:`gh-conflicts`,children:[(0,T.jsxs)(`header`,{className:`gh-conflicts-header`,children:[(0,T.jsxs)(`h3`,{children:[`Your changes and GitHub's changes overlap in `,p(a.length,`file`)]}),(0,T.jsx)(`p`,{className:`muted`,children:t?v.conflictResume:v.conflictSub})]}),(0,T.jsxs)(`div`,{className:`gh-conflicts-body`,children:[(0,T.jsx)(`ul`,{className:`gh-conflicts-rail`,children:a.map(e=>{let t=c.get(e.path);return(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{type:`button`,className:`gh-conflicts-rail-item${e.path===d?` is-selected`:``}`,onClick:()=>f(e.path),children:[(0,T.jsx)(`span`,{className:`gh-conflicts-dot${t?` is-resolved`:``}`,"aria-hidden":!0,children:t?`✓`:`○`}),(0,T.jsx)(`span`,{className:`gh-conflicts-rail-path`,title:e.path,children:e.path.split(`/`).pop()}),t&&(0,T.jsx)(`span`,{className:`muted small`,children:A[t]})]})},e.path)})}),(0,T.jsx)(`div`,{className:`gh-conflicts-detail`,children:D?c.has(D.path)?(0,T.jsxs)(`p`,{className:`muted gh-conflict-settled`,children:[A[c.get(D.path)],` for `,(0,T.jsx)(`code`,{children:D.path}),`. To change your mind, cancel the sync and start over.`]}):(0,T.jsx)(k,{projectId:e,path:D.path,kind:D.kind,busy:m!==``,onResolve:(e,t)=>void y(D.path,e,t)}):(0,T.jsx)(`p`,{className:`muted gh-conflict-settled`,children:E?`All files are sorted out — press Finish sync.`:`Pick a file on the left.`})})]}),(0,T.jsxs)(`footer`,{className:`gh-conflicts-footer`,children:[(0,T.jsxs)(`span`,{className:`muted small`,children:[C,` of `,a.length,` sorted out`]}),(0,T.jsxs)(`div`,{className:`gh-conflicts-footer-actions`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:()=>_(!0),disabled:m!==``,children:v.conflictCancel}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void x(),disabled:!E||m!==``,children:m===`finish`?`Finishing…`:v.conflictFinish})]})]}),(0,T.jsx)(u,{open:g,title:v.conflictCancelTitle,message:v.conflictCancelBody,confirmLabel:v.conflictCancelConfirm,cancelLabel:v.conflictCancelKeep,danger:!0,onConfirm:async()=>{_(!1),await S()},onCancel:()=>_(!1)})]})}var M={modified:`M`,added:`A`,deleted:`D`,renamed:`R`,conflicted:`!`};function N({changes:e,selectedPath:t,onSelect:n,onDiscard:r,disabled:i}){return(0,T.jsx)(`ul`,{className:`gh-changes-list`,children:e.map(e=>{let a=e.path.split(`/`),o=a.pop()??e.path,s=a.join(`/`);return(0,T.jsxs)(`li`,{className:e.path===t?`is-selected`:``,children:[(0,T.jsxs)(`button`,{type:`button`,className:`gh-changes-row`,onClick:()=>n(e.path),disabled:i,children:[(0,T.jsx)(`span`,{className:`gh-change-kind gh-change-kind-${e.kind}`,title:_(e.kind),"aria-label":_(e.kind),children:M[e.kind]??`M`}),(0,T.jsxs)(`span`,{className:`gh-change-name`,title:e.path,children:[o,s&&(0,T.jsx)(`span`,{className:`gh-change-dir`,children:s})]}),e.binary?(0,T.jsx)(`span`,{className:`gh-change-counts muted small`,children:`binary`}):(e.additions!==void 0||e.deletions!==void 0)&&(0,T.jsxs)(`span`,{className:`gh-change-counts small`,children:[(e.additions??0)>0&&(0,T.jsxs)(`span`,{className:`gh-change-add`,children:[`+`,e.additions]}),(e.deletions??0)>0&&(0,T.jsxs)(`span`,{className:`gh-change-rem`,children:[`−`,e.deletions]})]})]}),(0,T.jsx)(`button`,{type:`button`,className:`gh-change-discard`,title:`Undo changes to ${o}`,"aria-label":`Undo changes to ${o}`,onClick:()=>r(e),disabled:i,children:`↩`})]},e.path)})})}var P=`gezel:git-also-sync`;function F({projectId:e,changes:t,busy:n,onSave:r}){let[i,a]=(0,w.useState)(``),[o,c]=(0,w.useState)(!1),[l,u]=(0,w.useState)(()=>{try{return window.localStorage.getItem(P)!==`false`}catch{return!0}}),d=(0,w.useRef)(!1),f=(0,w.useRef)(0),p=(0,w.useMemo)(()=>t.map(e=>`${e.path}:${e.additions??``}/${e.deletions??``}`).join(`;`),[t]),m=(0,w.useCallback)(async n=>{if(t.length===0||!n&&d.current)return;let r=++f.current;c(!0);try{let t=await s.suggestProjectGitMessage(e);if(r!==f.current||!n&&d.current)return;t.message&&(a(t.message),d.current=!1)}catch{}finally{r===f.current&&c(!1)}},[e,t.length]);(0,w.useEffect)(()=>{if(t.length===0){a(e=>d.current?e:``);return}let e=window.setTimeout(()=>void m(!1),800);return()=>window.clearTimeout(e)},[p,t.length,m]);let g=(0,w.useCallback)(async()=>{await r(i.trim()||h(t),l),a(``),d.current=!1},[i,t,l,r]),_=(0,w.useCallback)(e=>{u(e);try{window.localStorage.setItem(P,String(e))}catch{}},[]);return(0,T.jsxs)(`div`,{className:`gh-save-box`,children:[(0,T.jsxs)(`div`,{className:`gh-save-textarea-wrap`,children:[(0,T.jsx)(`textarea`,{className:`gh-save-message${o?` is-suggesting`:``}`,value:i,placeholder:o?`Writing a description…`:v.savePlaceholder,rows:2,onChange:e=>{a(e.target.value),d.current=e.target.value.trim().length>0},disabled:n,"aria-label":`Describe what you changed`}),(0,T.jsx)(`button`,{type:`button`,className:`gh-save-suggest`,title:`Let AI write the description`,"aria-label":`Let AI write the description`,onClick:()=>void m(!0),disabled:n||o||t.length===0,children:`✨`})]}),(0,T.jsxs)(`label`,{className:`gh-save-also-sync small`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>_(e.target.checked),disabled:n}),v.saveAlsoSync]}),(0,T.jsx)(`button`,{type:`button`,className:`gh-save-button primary`,onClick:()=>void g(),disabled:n||t.length===0,children:n?`Saving…`:l?v.saveAndSyncButton:v.saveButton})]})}function I({projectId:e,onSyncRequested:t,syncing:n,lastSyncedAt:r,showToast:i,onReviewRequested:a,onBranchReviewRequested:o,reviewBusy:c}){let[d,h]=(0,w.useState)(null),[g,y]=(0,w.useState)(!1),[x,C]=(0,w.useState)(null),[E,D]=(0,w.useState)(null),[O,k]=(0,w.useState)(``),[A,j]=(0,w.useState)(null),[M,P]=(0,w.useState)(!1),I=(0,w.useRef)(new Map),L=(0,w.useCallback)(async()=>{try{let t=await s.getProjectGitChanges(e);I.current.clear(),h(t.changes),y(t.truncated),C(e=>e&&t.changes.some(t=>t.path===e)?e:t.changes[0]?.path??null)}catch{}},[e]);(0,w.useEffect)(()=>{L();let t=window.setInterval(()=>void L(),15e3),n=t=>{t.detail?.projectId===e&&L()};return window.addEventListener(S,n),()=>{window.clearInterval(t),window.removeEventListener(S,n)}},[L,e]),(0,w.useEffect)(()=>{if(!x){D(null);return}let t=I.current.get(x);if(t){D(t);return}let n=!1;return D(null),s.getProjectGitFileDiff(e,x).then(e=>{I.current.set(x,e),n||D(e)}).catch(()=>{n||D({path:x,kind:`modified`,binary:!1,truncated:!1,diff:``})}),()=>{n=!0}},[e,x]);let R=(0,w.useCallback)(async(n,r)=>{k(`save`);try{await s.commitProjectGit(e,n),i(`ok`,v.saveToast),await L(),b(e),r&&t()}catch(e){i(`err`,`Save failed: ${e instanceof Error?e.message:String(e)}`)}finally{k(``)}},[e,L,i,t]),z=(0,w.useCallback)(async t=>{k(`discard`);try{i(`ok`,`Undid ${p((await s.discardProjectGitChanges(e,t)).discarded,`change`)}.`),await L(),b(e)}catch(e){i(`err`,`Undo failed: ${e instanceof Error?e.message:String(e)}`)}finally{k(``)}},[e,L,i]),B=d?.find(e=>e.path===x)??null;return d===null?(0,T.jsx)(`p`,{className:`muted gh-changes-loading`,children:`Loading changes…`}):d.length===0?(0,T.jsxs)(`div`,{className:`gh-changes-empty`,children:[(0,T.jsx)(`div`,{className:`gh-changes-empty-title`,children:v.changesEmptyTitle}),(0,T.jsx)(`p`,{className:`muted`,children:v.changesEmptyBody}),(0,T.jsx)(`button`,{type:`button`,onClick:t,disabled:n,children:n?`Syncing…`:`Sync`}),o&&(0,T.jsxs)(`button`,{type:`button`,onClick:o,disabled:c===!0,children:[`✨ `,v.reviewPrButton]}),r&&(0,T.jsxs)(`p`,{className:`muted small`,title:l(r),children:[`Last synced `,m(r)]})]}):(0,T.jsxs)(`div`,{className:`gh-changes-layout`,children:[(0,T.jsxs)(`div`,{className:`gh-changes-rail`,children:[(0,T.jsxs)(`div`,{className:`gh-changes-rail-header`,children:[(0,T.jsx)(`strong`,{children:p(d.length,`changed file`)}),a&&(0,T.jsx)(`button`,{type:`button`,className:`gh-review-rail-button small`,onClick:a,disabled:O!==``||c===!0,title:v.reviewCommitHint,children:v.reviewRailButton}),(0,T.jsx)(`button`,{type:`button`,className:`gh-changes-discard-all small`,onClick:()=>P(!0),disabled:O!==``,children:`Undo all…`})]}),g&&(0,T.jsxs)(`p`,{className:`muted small gh-changes-truncated`,children:[`Showing the first `,d.length,` files.`]}),(0,T.jsx)(`div`,{className:`gh-changes-rail-list`,children:(0,T.jsx)(N,{changes:d,selectedPath:x,onSelect:C,onDiscard:j,disabled:O!==``})}),(0,T.jsx)(F,{projectId:e,changes:d,busy:O===`save`,onSave:R})]}),(0,T.jsx)(`div`,{className:`gh-changes-diff-pane`,children:B?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`gh-changes-diff-header`,children:[(0,T.jsx)(`code`,{className:`gh-changes-diff-path`,title:B.path,children:B.path}),(0,T.jsx)(`span`,{className:`muted small`,children:_(B.kind)}),!B.binary&&(B.additions!==void 0||B.deletions!==void 0)&&(0,T.jsxs)(`span`,{className:`small`,children:[(0,T.jsxs)(`span`,{className:`gh-change-add`,children:[`+`,B.additions??0]}),` `,(0,T.jsxs)(`span`,{className:`gh-change-rem`,children:[`−`,B.deletions??0]})]})]}),E?(0,T.jsx)(f,{diff:E.diff,kind:E.kind,oldPath:E.oldPath,binary:E.binary,truncated:E.truncated}):(0,T.jsx)(`p`,{className:`muted gh-changes-loading`,children:`Loading…`})]}):(0,T.jsx)(`p`,{className:`placeholder`,children:`Pick a file to see what changed.`})}),(0,T.jsx)(u,{open:A!==null,title:`Undo changes to ${A?(e=>e.split(`/`).pop()??e)(A.path):``}?`,message:`This puts the file back to how it was at your last save. This can't be undone.`,confirmLabel:`Undo changes`,danger:!0,onConfirm:async()=>{let e=A;j(null),e&&await z({paths:[e.path]})},onCancel:()=>j(null)}),(0,T.jsx)(u,{open:M,title:`Undo all changes?`,message:`This puts all ${p(d.length,`file`)} back to how they were at your last save. This can't be undone.`,confirmLabel:`Undo everything`,danger:!0,onConfirm:async()=>{P(!1),await z({all:!0})},onCancel:()=>P(!1)})]})}var L=50;function R({projectId:e}){let[t,n]=(0,w.useState)(null),[r,i]=(0,w.useState)(!1),[a,o]=(0,w.useState)(null),[c,u]=(0,w.useState)(null),[h,g]=(0,w.useState)(!1),_=(0,w.useCallback)(async t=>{let r=await s.getProjectGitLog(e,{limit:L,skip:t});i(r.hasMore),n(e=>t===0?r.commits:[...e??[],...r.commits])},[e]);if((0,w.useEffect)(()=>{n(null),o(null),u(null),_(0).catch(()=>n([]))},[_]),(0,w.useEffect)(()=>{if(!a){u(null);return}let t=!1;return u(null),s.getProjectGitCommit(e,a).then(e=>{t||u(e)}).catch(()=>{t||u(null)}),()=>{t=!0}},[e,a]),t===null)return(0,T.jsx)(`p`,{className:`muted gh-timeline-loading`,children:`Loading…`});if(t.length===0)return(0,T.jsx)(`p`,{className:`muted gh-timeline-empty`,children:v.timelineEmpty});let y=c?.diff?d(c.diff):[];return(0,T.jsxs)(`div`,{className:`gh-timeline-layout`,children:[(0,T.jsxs)(`div`,{className:`gh-timeline-rail`,children:[(0,T.jsx)(`ul`,{className:`gh-timeline-list`,children:t.map(e=>(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{type:`button`,className:`gh-timeline-item${e.sha===a?` is-selected`:``}`,onClick:()=>o(e.sha),children:[(0,T.jsx)(`span`,{className:`gh-timeline-subject`,children:e.subject}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(e.date),children:[e.author,` saved `,p(e.filesChanged,`file`),` · `,m(e.date)]})]})},e.sha))}),r&&(0,T.jsx)(`button`,{type:`button`,className:`gh-timeline-more`,disabled:h,onClick:()=>{g(!0),_(t.length).finally(()=>g(!1))},children:h?`Loading…`:`Show earlier saves`})]}),(0,T.jsx)(`div`,{className:`gh-timeline-detail`,children:a===null?(0,T.jsx)(`p`,{className:`placeholder`,children:`Pick a save to see what changed.`}):c===null?(0,T.jsx)(`p`,{className:`muted gh-timeline-loading`,children:`Loading…`}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`gh-timeline-detail-header`,children:[(0,T.jsx)(`strong`,{children:c.subject}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(c.date),children:[c.author,` · `,m(c.date)]})]}),y.length===0?(0,T.jsx)(`p`,{className:`muted`,children:`Sync point — this save combined changes that are each shown separately.`}):y.map(e=>(0,T.jsxs)(`div`,{className:`gh-timeline-file`,children:[e.path&&(0,T.jsx)(`div`,{className:`gh-timeline-file-path`,children:(0,T.jsx)(`code`,{children:e.path})}),(0,T.jsx)(f,{diff:e.diff})]},e.path||`diff`)),c.truncated&&(0,T.jsx)(`p`,{className:`muted small`,children:v.diffBig})]})})]})}function z({projectId:e}){let[t,n]=(0,w.useState)(null),[r,i]=(0,w.useState)(null),[a,o]=(0,w.useState)(null);return(0,w.useEffect)(()=>{n(null),i(null),o(null);let t=!1;return s.listProjectGitHubPulls(e).then(e=>{t||n(e.pulls)}).catch(e=>{t||(n([]),o(e instanceof Error?e.message:String(e)))}),()=>{t=!0}},[e]),(0,T.jsxs)(`div`,{className:`project-files-layout`,children:[(0,T.jsxs)(`div`,{className:`file-tree-panel`,children:[a&&(0,T.jsx)(`p`,{className:`error`,style:{padding:`0.5rem`},children:a}),t===null&&(0,T.jsx)(`p`,{className:`muted`,style:{padding:`0.5rem`},children:`Loading…`}),t&&t.length===0&&!a&&(0,T.jsx)(`p`,{className:`muted`,style:{padding:`0.5rem`},children:`No open pull requests.`}),t&&t.length>0&&(0,T.jsx)(`ul`,{className:`pr-list`,style:{listStyle:`none`,padding:0,margin:0},children:t.map(e=>(0,T.jsx)(`li`,{style:{borderBottom:`1px solid var(--border-color, #eee)`},children:(0,T.jsxs)(`button`,{type:`button`,className:r===e.number?`active`:``,onClick:()=>i(e.number),style:{display:`block`,width:`100%`,textAlign:`left`,padding:`0.5rem 0.6rem`,background:`transparent`,border:`none`,cursor:`pointer`},children:[(0,T.jsxs)(`div`,{style:{fontWeight:500},children:[`#`,e.number,` `,e.title,` `,e.draft&&(0,T.jsx)(`em`,{className:`muted`,children:`(draft)`})]}),(0,T.jsxs)(`div`,{className:`muted small`,children:[`by `,e.author,` — `,e.headRef,` → `,e.baseRef]})]})},e.number))})]}),(0,T.jsx)(`div`,{className:`file-viewer-panel`,children:r===null?(0,T.jsx)(`p`,{className:`placeholder`,style:{padding:`2rem`},children:`Select a pull request to view its details.`}):(0,T.jsx)(B,{projectId:e,num:r})})]})}function B({projectId:e,num:t}){let[n,r]=(0,w.useState)(null),[i,a]=(0,w.useState)(null),[o,u]=(0,w.useState)(null),[d,f]=(0,w.useState)(null);return(0,w.useEffect)(()=>{r(null),a(null),u(null),f(null);let n=!1;return(async()=>{try{let[i,o,c]=await Promise.all([s.getProjectGitHubPull(e,t),V(e,t),s.listProjectGitHubPullComments(e,t)]);if(n)return;r(i),a(o),u(c.comments)}catch(e){n||f(e.message)}})(),()=>{n=!0}},[e,t]),d?(0,T.jsx)(`p`,{className:`error`,style:{padding:`1rem`},children:d}):n?(0,T.jsxs)(`div`,{style:{padding:`0.5rem 0.75rem`,overflow:`auto`,height:`calc(100vh - 320px)`},children:[(0,T.jsxs)(`h3`,{style:{marginTop:0},children:[`#`,n.number,` `,n.title]}),(0,T.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`by `,n.author,` — `,n.headRef,` → `,n.baseRef,` —`,` `,(0,T.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,children:`view on GitHub`})]}),(0,T.jsxs)(`p`,{className:`muted small`,children:[n.merged?`merged`:n.state,` · `,n.changedFiles,` files · +`,n.additions,` −`,n.deletions]}),n.body&&(0,T.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`,background:`var(--code-bg, #f6f8fa)`,padding:`0.5rem`,borderRadius:4},children:n.body}),(0,T.jsx)(`h4`,{children:`Files changed`}),i&&i.length===0&&(0,T.jsx)(`p`,{className:`muted small`,children:`No files.`}),i&&i.length>0&&(0,T.jsx)(`ul`,{style:{listStyle:`none`,padding:0},children:i.map(e=>(0,T.jsx)(`li`,{style:{marginBottom:`0.5rem`},children:(0,T.jsxs)(`details`,{children:[(0,T.jsxs)(`summary`,{children:[(0,T.jsx)(`code`,{children:e.filename}),` `,(0,T.jsxs)(`span`,{className:`muted small`,children:[e.status,` +`,e.additions,` −`,e.deletions]})]}),e.patch?(0,T.jsx)(`pre`,{style:{background:`var(--code-bg, #f6f8fa)`,padding:`0.5rem`,overflow:`auto`,fontSize:`0.8rem`},children:e.patch}):(0,T.jsx)(`p`,{className:`muted small`,children:`No patch returned (binary or too large).`})]})},e.filename))}),(0,T.jsx)(`h4`,{children:`Comments`}),o&&o.length===0&&(0,T.jsx)(`p`,{className:`muted small`,children:`No comments yet.`}),o&&o.length>0&&(0,T.jsx)(`ul`,{style:{listStyle:`none`,padding:0},children:o.map(e=>(0,T.jsxs)(`li`,{style:{marginBottom:`0.75rem`,borderLeft:`3px solid var(--border-color, #ddd)`,paddingLeft:`0.5rem`},children:[(0,T.jsxs)(`div`,{className:`muted small`,children:[(0,T.jsx)(`strong`,{children:e.author}),` · `,e.kind,e.path&&(0,T.jsxs)(T.Fragment,{children:[` `,`on `,(0,T.jsx)(`code`,{children:e.path})]}),` · `,(0,T.jsx)(`span`,{title:l(e.createdAt),children:c(e.createdAt)})]}),(0,T.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`,margin:0,fontFamily:`inherit`},children:e.body})]},e.id))})]}):(0,T.jsx)(`p`,{className:`muted`,style:{padding:`1rem`},children:`Loading…`})}async function V(e,t){let n=[],r=0;for(;;){let i=await s.listProjectGitHubPullFiles(e,t,{offset:r,limit:200,includePatch:!0});if(n.push(...i.files),!i.hasMore||i.nextOffset===void 0)return n;r=i.nextOffset}}var H=5e3,U=3e4;function W(e){let t=e instanceof Error?e.message:String(e);return t.includes(`REVIEW_IN_PROGRESS`)?v.reviewAlreadyRunning:t.includes(`NO_DEFAULT_BRANCH`)?v.reviewNoDefaultBranch:t.includes(`DETACHED_HEAD`)?v.reviewDetachedHead:t}function G(e,t){let[n,r]=(0,w.useState)([]),[i,a]=(0,w.useState)(``),o=(0,w.useRef)(n);o.current=n;let c=(0,w.useCallback)(async()=>{try{let t=await s.listProjectCodeReviews(e);r(t.reviews)}catch{}},[e]),l=n.some(e=>e.status===`running`);(0,w.useEffect)(()=>{c();let t=window.setInterval(()=>void c(),l?H:U),n=t=>{t.detail?.projectId===e&&c()};return window.addEventListener(S,n),()=>{window.clearInterval(t),window.removeEventListener(S,n)}},[c,e,l]);let u=(0,w.useCallback)(async n=>{a(n===`commit`?`start-commit`:`start-pr`);try{let i=await s.startProjectCodeReview(e,{kind:n});return r(e=>[i.review,...e.filter(e=>e.id!==i.review.id)]),t(`ok`,v.reviewStartedToast),!0}catch(e){return(e instanceof Error?e.message:String(e)).includes(`NOTHING_TO_REVIEW`)?t(`err`,n===`commit`?v.reviewNothingCommit:v.reviewNothingPr):t(`err`,W(e)),!1}finally{a(``)}},[e,t]),d=(0,w.useCallback)(async n=>{a(`cancel`);try{let i=await s.cancelProjectCodeReview(e,n);r(e=>e.map(e=>e.id===i.review.id?i.review:e)),t(`ok`,v.reviewCanceledToast)}catch(e){t(`err`,W(e))}finally{a(``)}},[e,t]);return{reviews:n,running:n.filter(e=>e.status===`running`),start:u,cancel:d,busy:i,refresh:c}}function K({project:e,onProjectChange:t}){let[n,o]=(0,w.useState)(`changes`),[c,l]=(0,w.useState)(null),[d,f]=(0,w.useState)(null),[p,m]=(0,w.useState)(``),[h,g]=(0,w.useState)(null),[_,y]=(0,w.useState)(!1),[b,E]=(0,w.useState)(!1),[D,k]=(0,w.useState)(!1),A=(0,w.useRef)(!1),M=(0,w.useCallback)((e,t)=>{g({kind:e,text:t}),window.setTimeout(()=>g(null),5e3)},[]),N=(0,w.useCallback)(async()=>{try{let t=await s.getProjectGitStatus(e.id);l(t)}catch(e){f(e.message)}},[e.id]),{reviews:P,running:F,start:L,cancel:B,busy:V}=G(e.id,M),H=(0,w.useCallback)(e=>{L(e).then(e=>{e&&o(`review`)})},[L]),{sync:U,syncing:W}=x(e.id,{onToast:M,onConflicts:()=>{o(`changes`),N()},onNeedsSave:()=>{o(`changes`),y(!0)},onAuth:()=>E(!0)}),K=(0,w.useCallback)(async()=>{A.current=!0,(await U())?.state===`synced`&&(E(!1),k(!1)),await N()},[U,N]),J=(0,w.useCallback)(e=>{e&&(E(!1),N())},[N]);(0,w.useEffect)(()=>{f(null),o(`changes`),E(!1),k(!1),A.current=!1,N()},[e.id,N]),(0,w.useEffect)(()=>{let t=window.setInterval(()=>void N(),3e4),n=t=>{t.detail?.projectId===e.id&&N()};return window.addEventListener(S,n),()=>{window.clearInterval(t),window.removeEventListener(S,n)}},[N,e.id]);let Y=c?.exists===!0;(0,w.useEffect)(()=>{if(!Y)return;let t=()=>s.fetchProjectGit(e.id).then(()=>N()).catch(e=>{q(e)&&E(!0)});t();let n=window.setInterval(()=>void t(),3e5);return()=>window.clearInterval(n)},[Y,e.id,N]);let X=(0,w.useCallback)(async()=>{m(`Downloading…`),f(null);try{await s.cloneProjectGit(e.id),t(await s.getProject(e.id)),await N()}catch(e){f(e.message)}finally{m(``)}},[e.id,N,t]),Z=c&&!c.exists,ee=c?(c.credentialSource??(c.hasPat?`pat`:`none`))===`none`:!1,Q=c?.mergeInProgress===!0,te=c?.behind??0,$=c?.changesCount??0;return(0,T.jsxs)(`div`,{className:`project-github`,children:[(0,T.jsxs)(`div`,{className:`github-toolbar`,children:[(0,T.jsx)(`strong`,{children:e.github?.url}),p&&(0,T.jsx)(`span`,{className:`status`,children:p})]}),(ee||b)&&(0,T.jsxs)(`div`,{className:`github-banner gh-banner-warn`,children:[b?`GitHub needs you to sign in again.`:`No GitHub sign-in found. Public repositories still work; sign in for private repositories, pull requests, and sending changes.`,` `,(0,T.jsx)(C,{onChange:J,compact:!0})]}),!Q&&te>0&&!D&&(0,T.jsxs)(`div`,{className:`github-banner gh-banner-nudge`,children:[(0,T.jsx)(`span`,{children:v.nudgeBanner}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void K(),disabled:W,children:W?`Syncing…`:`Sync`}),(0,T.jsx)(`button`,{type:`button`,className:`gh-banner-dismiss`,"aria-label":`Dismiss`,onClick:()=>k(!0),children:`✕`})]}),d&&(0,T.jsx)(`p`,{className:`error`,children:d}),Z?(0,T.jsxs)(`div`,{className:`gh-clone-state`,children:[(0,T.jsx)(`p`,{children:`This project lives on GitHub but isn't on this computer yet.`}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void X(),disabled:!!p,children:`Download project`})]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(a,{value:n,onValueChange:e=>o(e),children:(0,T.jsxs)(i,{children:[(0,T.jsxs)(r,{value:`changes`,children:[`Changes`,$>0&&(0,T.jsx)(`span`,{className:`gh-tab-badge`,children:$})]}),(0,T.jsx)(r,{value:`timeline`,children:`Timeline`}),(0,T.jsx)(r,{value:`prs`,children:`Pull requests`}),(0,T.jsxs)(r,{value:`review`,children:[v.reviewTabLabel,F.length>0&&(0,T.jsx)(`span`,{className:`gh-tab-badge`,children:F.length})]})]})}),n===`changes`&&(Q?(0,T.jsx)(j,{projectId:e.id,resumed:!A.current,showToast:M,onFinished:()=>{N(),K()},onExited:()=>void N()}):(0,T.jsx)(I,{projectId:e.id,onSyncRequested:()=>void K(),syncing:W,lastSyncedAt:c?.github?.lastSyncedAt,showToast:M,onReviewRequested:()=>H(`commit`),onBranchReviewRequested:()=>H(`pr`),reviewBusy:V!==``||F.some(e=>e.kind===`commit`)})),n===`timeline`&&(0,T.jsx)(R,{projectId:e.id}),n===`prs`&&(0,T.jsx)(z,{projectId:e.id}),n===`review`&&(0,T.jsx)(O,{projectId:e.id,reviews:P,busy:V,changesCount:$,branch:c?.branch,defaultBranch:c?.defaultBranch??c?.github?.defaultBranch,onStart:e=>void L(e),onCancel:e=>void B(e)})]}),h&&(0,T.jsx)(`output`,{className:`project-git-toast project-git-toast-${h.kind}`,children:h.text}),(0,T.jsx)(u,{open:_,title:v.needsSaveTitle,message:v.needsSaveBody,confirmLabel:v.needsSaveConfirm,cancelLabel:v.needsSaveCancel,onConfirm:()=>{y(!1),o(`changes`)},onCancel:()=>y(!1)})]})}function q(e){return!(e instanceof o)||!e.details||typeof e.details!=`object`?!1:`code`in e.details&&e.details.code===`MISSING_PAT`}export{K as ProjectGitHubView};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./dist-BaHut5iX.js";import{t as i}from"./api-BPraLwsh.js";import{i as a,n as o,r as s}from"./Tabs-jE0Z5Tzd.js";import"./primitives-CWrGZpPI.js";import{n as c,t as l}from"./relative-time-B2kBaekd.js";import{t as u}from"./ConfirmDialog-Dt1ed4Fh.js";import{r as d,t as f}from"./GitDiffView-DrDrSeBb.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./gitCopy-Dcjz17cJ.js";import{t as y}from"./MarkdownField-CK8K3fzj.js";import{n as b,r as x,t as S}from"./useGitSync-BCTptQsp.js";import{t as C}from"./GithubSignInChip-DjM3qZsL.js";var w=e(t(),1),T=n();function E({review:e,onCancel:t,disabled:n}){let[r,i]=(0,w.useState)(!1),a=e.needsAttention===!0,o=e.assigneeName??`A reviewer`,s=e.stepsTotal&&e.stepsTotal>0?`step ${Math.min((e.stepsComplete??0)+1,e.stepsTotal)} of ${e.stepsTotal}`:void 0;return(0,T.jsxs)(`div`,{className:`gh-review-status-card ${a?`gh-review-status-attention`:`gh-review-status-running`}`,children:[(0,T.jsxs)(`div`,{className:`gh-review-status-main`,children:[(0,T.jsxs)(`strong`,{children:[g(e.kind),` · `,e.branch]}),(0,T.jsx)(`span`,{children:a?v.reviewNeedsAttention:(0,T.jsxs)(T.Fragment,{children:[o,` `,v.reviewRunning]})}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(e.createdAt),children:[p(e.filesChanged,`file`),s?` · ${s}`:``,e.activeStepName?` · ${e.activeStepName}`:``,` · started ${m(e.createdAt)}`]})]}),(0,T.jsx)(`button`,{type:`button`,className:`gh-review-stop small`,onClick:()=>i(!0),disabled:n,children:v.reviewStop}),(0,T.jsx)(u,{open:r,title:v.reviewStopTitle,message:v.reviewStopBody,confirmLabel:v.reviewStopConfirm,danger:!0,onConfirm:()=>{i(!1),t(e.id)},onCancel:()=>i(!1)})]})}var D=()=>{};function O({projectId:e,reviews:t,busy:n,changesCount:r,branch:a,defaultBranch:o,onStart:s,onCancel:c}){let u=t.filter(e=>e.status===`running`),d=t.filter(e=>e.status!==`running`),f=u.some(e=>e.kind===`commit`),h=u.some(e=>e.kind===`pr`),[_,b]=(0,w.useState)(null),x=(0,w.useMemo)(()=>d.find(e=>e.id===_)??d.find(e=>e.status===`complete`)??null,[d,_]),[S,C]=(0,w.useState)(null);(0,w.useEffect)(()=>{if(!x||x.status!==`complete`){C(null);return}let t=!1;return i.readProjectArtifact(e,x.reportPath).then(e=>{t||C({id:x.id,content:e.content})}).catch(()=>{t||C({id:x.id,content:null})}),()=>{t=!0}},[e,x]);let O=o?`Checks everything on ${a??`this branch`} against ${o}.`:v.reviewPrHint;return(0,T.jsxs)(`div`,{className:`gh-review-layout`,children:[(0,T.jsxs)(`div`,{className:`gh-review-rail`,children:[(0,T.jsxs)(`div`,{className:`gh-review-kickoff-row`,children:[(0,T.jsxs)(`div`,{className:`gh-review-card`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:()=>s(`commit`),disabled:n!==``||f||r===0,children:n===`start-commit`?`Starting…`:`✨ ${v.reviewCommitButton}`}),(0,T.jsx)(`p`,{className:`muted small`,children:r===0?v.reviewNothingCommit:v.reviewCommitHint})]}),(0,T.jsxs)(`div`,{className:`gh-review-card`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:()=>s(`pr`),disabled:n!==``||h,children:n===`start-pr`?`Starting…`:`✨ ${v.reviewPrButton}`}),(0,T.jsx)(`p`,{className:`muted small`,children:O})]})]}),u.map(e=>(0,T.jsx)(E,{review:e,onCancel:c,disabled:n!==``},e.id)),(0,T.jsxs)(`div`,{className:`gh-review-history`,children:[d.length===0&&u.length===0&&(0,T.jsx)(`p`,{className:`muted`,children:v.reviewHistoryEmpty}),d.map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`gh-review-history-item${x?.id===e.id?` is-selected`:``}`,onClick:()=>b(e.id),children:[(0,T.jsx)(`span`,{className:`gh-review-outcome-chip gh-review-outcome-${e.status}`,children:e.status===`complete`?`Reviewed`:e.status===`canceled`?`Stopped`:`Issue`}),(0,T.jsxs)(`span`,{className:`gh-review-history-title`,children:[g(e.kind),` · `,e.branch]}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(e.settledAt??e.createdAt),children:[p(e.filesChanged,`file`),` · `,m(e.settledAt??e.createdAt)]})]},e.id))]})]}),(0,T.jsx)(`div`,{className:`gh-review-report`,children:x&&x.status===`complete`?S?.id===x.id?S.content===null?(0,T.jsx)(`p`,{className:`muted`,children:v.reviewReportMissing}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`gh-review-report-header`,children:[(0,T.jsx)(`code`,{className:`gh-changes-diff-path`,title:x.reportPath,children:x.reportPath}),(0,T.jsx)(`button`,{type:`button`,className:`small`,onClick:()=>window.dispatchEvent(new CustomEvent(`gezel:open-file`,{detail:{projectId:e,path:x.reportPath,source:`artifacts`}})),children:v.reviewOpenInArtifacts})]}),(0,T.jsx)(y,{value:S.content,readOnly:!0,onCommit:D},`${x.id}:${x.reportPath}`)]}):(0,T.jsx)(`p`,{className:`muted`,children:v.reviewReportLoading}):(0,T.jsx)(`p`,{className:`placeholder`,children:u.length>0?`The report will appear here when the review finishes.`:`Pick a finished review to read its report.`})})]})}function k({projectId:e,path:t,kind:n,busy:r,onResolve:a}){let[o,s]=(0,w.useState)(null),[c,l]=(0,w.useState)(null),[u,d]=(0,w.useState)({step:`idle`});(0,w.useEffect)(()=>{s(null),l(null),d({step:`idle`});let n=!1;return i.getProjectGitConflictVersions(e,t).then(e=>{n||s(e)}).catch(e=>{n||l(e instanceof Error?e.message:String(e))}),()=>{n=!0}},[e,t]);let f=async()=>{d({step:`combining`});try{let n=await i.aiResolveProjectGitConflict(e,t);d({step:`preview`,content:n.merged})}catch(e){l(e instanceof Error?e.message:String(e)),d({step:`idle`})}};if(c)return(0,T.jsx)(`p`,{className:`error gh-conflict-error`,children:c});if(!o)return(0,T.jsx)(`p`,{className:`muted gh-conflict-loading`,children:`Loading…`});let p=!o.binary&&!o.tooLarge&&o.ours!==void 0&&o.theirs!==void 0;return u.step===`combining`?(0,T.jsx)(`p`,{className:`muted gh-conflict-loading`,children:v.conflictAiBusy}):u.step===`preview`||u.step===`editing`?(0,T.jsxs)(`div`,{className:`gh-conflict-ai-preview`,children:[(0,T.jsx)(`h4`,{children:v.conflictAiPreviewTitle}),u.step===`editing`?(0,T.jsx)(`textarea`,{className:`gh-conflict-ai-editor`,value:u.content,onChange:e=>d({step:`editing`,content:e.target.value}),"aria-label":`Edit the combined version`}):(0,T.jsx)(`pre`,{className:`gh-conflict-content`,children:u.content}),(0,T.jsxs)(`div`,{className:`gh-conflict-actions`,children:[(0,T.jsx)(`button`,{type:`button`,className:`primary`,disabled:r,onClick:()=>void a(`custom`,u.content),children:v.conflictAiUse}),u.step===`preview`?(0,T.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>d({step:`editing`,content:u.content}),children:v.conflictAiEdit}):null,(0,T.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>d({step:`idle`}),children:v.conflictAiBack})]})]}):(0,T.jsxs)(`div`,{className:`gh-conflict-file`,children:[(o.binary||o.tooLarge)&&(0,T.jsx)(`p`,{className:`muted small`,children:o.binary?`This file isn't text, so it can't be combined — pick one version.`:`This file is too large to preview — pick one version.`}),(0,T.jsxs)(`section`,{className:`gh-conflict-card`,children:[(0,T.jsxs)(`header`,{children:[(0,T.jsx)(`strong`,{children:v.conflictMineTitle}),n===`deleted-by-us`&&(0,T.jsx)(`span`,{className:`muted small`,children:`You deleted this file`})]}),o.ours!==void 0&&!o.binary&&!o.tooLarge&&(0,T.jsx)(`pre`,{className:`gh-conflict-content`,children:o.ours}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,disabled:r,onClick:()=>void a(`mine`),children:n===`deleted-by-us`?`Keep my version (stays deleted)`:v.conflictMineButton})]}),(0,T.jsxs)(`section`,{className:`gh-conflict-card`,children:[(0,T.jsxs)(`header`,{children:[(0,T.jsx)(`strong`,{children:v.conflictTheirsTitle}),n===`deleted-by-them`&&(0,T.jsx)(`span`,{className:`muted small`,children:`GitHub deleted this file`})]}),o.theirs!==void 0&&!o.binary&&!o.tooLarge&&(0,T.jsx)(`pre`,{className:`gh-conflict-content`,children:o.theirs}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,disabled:r,onClick:()=>void a(`theirs`),children:n===`deleted-by-them`?`Keep GitHub's version (deletes it)`:v.conflictTheirsButton})]}),p&&(0,T.jsx)(`div`,{className:`gh-conflict-ai-cta`,children:(0,T.jsxs)(`button`,{type:`button`,className:`gh-conflict-ai-button`,disabled:r,onClick:f,children:[`✨ `,v.conflictAiButton]})})]})}var A={mine:`Kept yours`,theirs:`Kept GitHub's`,combined:`Combined`};function j({projectId:e,resumed:t,showToast:n,onFinished:r,onExited:a}){let[o,s]=(0,w.useState)(null),[c,l]=(0,w.useState)(new Map),[d,f]=(0,w.useState)(null),[m,h]=(0,w.useState)(``),[g,_]=(0,w.useState)(!1);(0,w.useEffect)(()=>{let t=!1;return i.getProjectGitMergeState(e).then(e=>{if(!t){if(!e.inMerge){a();return}s(e.conflicts),f(e.conflicts[0]?.path??null)}}).catch(()=>{t||a()}),()=>{t=!0}},[e,a]);let y=(0,w.useCallback)(async(t,r,a)=>{h(`resolve`);try{await i.resolveProjectGitConflict(e,{path:t,choice:r,...a===void 0?{}:{content:a}}),l(e=>{let n=new Map(e);return n.set(t,r===`custom`?`combined`:r),n}),f(()=>(o??[]).filter(e=>e.path!==t&&!c.has(e.path))[0]?.path??null),b(e)}catch(e){n(`err`,e instanceof Error?e.message:String(e))}finally{h(``)}},[e,o,c,n]),x=(0,w.useCallback)(async()=>{h(`finish`);try{await i.completeProjectGitMerge(e),b(e),n(`ok`,v.conflictFinishToast),r()}catch(e){n(`err`,e instanceof Error?e.message:String(e)),h(``)}},[e,n,r]),S=(0,w.useCallback)(async()=>{h(`cancel`);try{await i.abandonProjectGitMerge(e),b(e),a()}catch(e){n(`err`,e instanceof Error?e.message:String(e)),h(``)}},[e,n,a]);if(o===null)return(0,T.jsx)(`p`,{className:`muted gh-conflict-loading`,children:`Loading…`});let C=o.filter(e=>c.has(e.path)).length,E=C===o.length,D=o.find(e=>e.path===d)??null;return(0,T.jsxs)(`div`,{className:`gh-conflicts`,children:[(0,T.jsxs)(`header`,{className:`gh-conflicts-header`,children:[(0,T.jsxs)(`h3`,{children:[`Your changes and GitHub's changes overlap in `,p(o.length,`file`)]}),(0,T.jsx)(`p`,{className:`muted`,children:t?v.conflictResume:v.conflictSub})]}),(0,T.jsxs)(`div`,{className:`gh-conflicts-body`,children:[(0,T.jsx)(`ul`,{className:`gh-conflicts-rail`,children:o.map(e=>{let t=c.get(e.path);return(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{type:`button`,className:`gh-conflicts-rail-item${e.path===d?` is-selected`:``}`,onClick:()=>f(e.path),children:[(0,T.jsx)(`span`,{className:`gh-conflicts-dot${t?` is-resolved`:``}`,"aria-hidden":!0,children:t?`✓`:`○`}),(0,T.jsx)(`span`,{className:`gh-conflicts-rail-path`,title:e.path,children:e.path.split(`/`).pop()}),t&&(0,T.jsx)(`span`,{className:`muted small`,children:A[t]})]})},e.path)})}),(0,T.jsx)(`div`,{className:`gh-conflicts-detail`,children:D?c.has(D.path)?(0,T.jsxs)(`p`,{className:`muted gh-conflict-settled`,children:[A[c.get(D.path)],` for `,(0,T.jsx)(`code`,{children:D.path}),`. To change your mind, cancel the sync and start over.`]}):(0,T.jsx)(k,{projectId:e,path:D.path,kind:D.kind,busy:m!==``,onResolve:(e,t)=>void y(D.path,e,t)}):(0,T.jsx)(`p`,{className:`muted gh-conflict-settled`,children:E?`All files are sorted out — press Finish sync.`:`Pick a file on the left.`})})]}),(0,T.jsxs)(`footer`,{className:`gh-conflicts-footer`,children:[(0,T.jsxs)(`span`,{className:`muted small`,children:[C,` of `,o.length,` sorted out`]}),(0,T.jsxs)(`div`,{className:`gh-conflicts-footer-actions`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:()=>_(!0),disabled:m!==``,children:v.conflictCancel}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void x(),disabled:!E||m!==``,children:m===`finish`?`Finishing…`:v.conflictFinish})]})]}),(0,T.jsx)(u,{open:g,title:v.conflictCancelTitle,message:v.conflictCancelBody,confirmLabel:v.conflictCancelConfirm,cancelLabel:v.conflictCancelKeep,danger:!0,onConfirm:async()=>{_(!1),await S()},onCancel:()=>_(!1)})]})}var M={modified:`M`,added:`A`,deleted:`D`,renamed:`R`,conflicted:`!`};function N({changes:e,selectedPath:t,onSelect:n,onDiscard:r,disabled:i}){return(0,T.jsx)(`ul`,{className:`gh-changes-list`,children:e.map(e=>{let a=e.path.split(`/`),o=a.pop()??e.path,s=a.join(`/`);return(0,T.jsxs)(`li`,{className:e.path===t?`is-selected`:``,children:[(0,T.jsxs)(`button`,{type:`button`,className:`gh-changes-row`,onClick:()=>n(e.path),disabled:i,children:[(0,T.jsx)(`span`,{className:`gh-change-kind gh-change-kind-${e.kind}`,title:_(e.kind),"aria-label":_(e.kind),children:M[e.kind]??`M`}),(0,T.jsxs)(`span`,{className:`gh-change-name`,title:e.path,children:[o,s&&(0,T.jsx)(`span`,{className:`gh-change-dir`,children:s})]}),e.binary?(0,T.jsx)(`span`,{className:`gh-change-counts muted small`,children:`binary`}):(e.additions!==void 0||e.deletions!==void 0)&&(0,T.jsxs)(`span`,{className:`gh-change-counts small`,children:[(e.additions??0)>0&&(0,T.jsxs)(`span`,{className:`gh-change-add`,children:[`+`,e.additions]}),(e.deletions??0)>0&&(0,T.jsxs)(`span`,{className:`gh-change-rem`,children:[`−`,e.deletions]})]})]}),(0,T.jsx)(`button`,{type:`button`,className:`gh-change-discard`,title:`Undo changes to ${o}`,"aria-label":`Undo changes to ${o}`,onClick:()=>r(e),disabled:i,children:`↩`})]},e.path)})})}var P=`gezel:git-also-sync`;function F({projectId:e,changes:t,busy:n,onSave:r}){let[a,o]=(0,w.useState)(``),[s,c]=(0,w.useState)(!1),[l,u]=(0,w.useState)(()=>{try{return window.localStorage.getItem(P)!==`false`}catch{return!0}}),d=(0,w.useRef)(!1),f=(0,w.useRef)(0),p=(0,w.useMemo)(()=>t.map(e=>`${e.path}:${e.additions??``}/${e.deletions??``}`).join(`;`),[t]),m=(0,w.useCallback)(async n=>{if(t.length===0||!n&&d.current)return;let r=++f.current;c(!0);try{let t=await i.suggestProjectGitMessage(e);if(r!==f.current||!n&&d.current)return;t.message&&(o(t.message),d.current=!1)}catch{}finally{r===f.current&&c(!1)}},[e,t.length]);(0,w.useEffect)(()=>{if(t.length===0){o(e=>d.current?e:``);return}let e=window.setTimeout(()=>void m(!1),800);return()=>window.clearTimeout(e)},[p,t.length,m]);let g=(0,w.useCallback)(async()=>{await r(a.trim()||h(t),l),o(``),d.current=!1},[a,t,l,r]),_=(0,w.useCallback)(e=>{u(e);try{window.localStorage.setItem(P,String(e))}catch{}},[]);return(0,T.jsxs)(`div`,{className:`gh-save-box`,children:[(0,T.jsxs)(`div`,{className:`gh-save-textarea-wrap`,children:[(0,T.jsx)(`textarea`,{className:`gh-save-message${s?` is-suggesting`:``}`,value:a,placeholder:s?`Writing a description…`:v.savePlaceholder,rows:2,onChange:e=>{o(e.target.value),d.current=e.target.value.trim().length>0},disabled:n,"aria-label":`Describe what you changed`}),(0,T.jsx)(`button`,{type:`button`,className:`gh-save-suggest`,title:`Let AI write the description`,"aria-label":`Let AI write the description`,onClick:()=>void m(!0),disabled:n||s||t.length===0,children:`✨`})]}),(0,T.jsxs)(`label`,{className:`gh-save-also-sync small`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>_(e.target.checked),disabled:n}),v.saveAlsoSync]}),(0,T.jsx)(`button`,{type:`button`,className:`gh-save-button primary`,onClick:()=>void g(),disabled:n||t.length===0,children:n?`Saving…`:l?v.saveAndSyncButton:v.saveButton})]})}function I({projectId:e,onSyncRequested:t,syncing:n,lastSyncedAt:r,showToast:a,onReviewRequested:o,onBranchReviewRequested:s,reviewBusy:c}){let[d,h]=(0,w.useState)(null),[g,y]=(0,w.useState)(!1),[x,C]=(0,w.useState)(null),[E,D]=(0,w.useState)(null),[O,k]=(0,w.useState)(``),[A,j]=(0,w.useState)(null),[M,P]=(0,w.useState)(!1),I=(0,w.useRef)(new Map),L=(0,w.useCallback)(async()=>{try{let t=await i.getProjectGitChanges(e);I.current.clear(),h(t.changes),y(t.truncated),C(e=>e&&t.changes.some(t=>t.path===e)?e:t.changes[0]?.path??null)}catch{}},[e]);(0,w.useEffect)(()=>{L();let t=window.setInterval(()=>void L(),15e3),n=t=>{t.detail?.projectId===e&&L()};return window.addEventListener(S,n),()=>{window.clearInterval(t),window.removeEventListener(S,n)}},[L,e]),(0,w.useEffect)(()=>{if(!x){D(null);return}let t=I.current.get(x);if(t){D(t);return}let n=!1;return D(null),i.getProjectGitFileDiff(e,x).then(e=>{I.current.set(x,e),n||D(e)}).catch(()=>{n||D({path:x,kind:`modified`,binary:!1,truncated:!1,diff:``})}),()=>{n=!0}},[e,x]);let R=(0,w.useCallback)(async(n,r)=>{k(`save`);try{await i.commitProjectGit(e,n),a(`ok`,v.saveToast),await L(),b(e),r&&t()}catch(e){a(`err`,`Save failed: ${e instanceof Error?e.message:String(e)}`)}finally{k(``)}},[e,L,a,t]),z=(0,w.useCallback)(async t=>{k(`discard`);try{a(`ok`,`Undid ${p((await i.discardProjectGitChanges(e,t)).discarded,`change`)}.`),await L(),b(e)}catch(e){a(`err`,`Undo failed: ${e instanceof Error?e.message:String(e)}`)}finally{k(``)}},[e,L,a]),B=d?.find(e=>e.path===x)??null;return d===null?(0,T.jsx)(`p`,{className:`muted gh-changes-loading`,children:`Loading changes…`}):d.length===0?(0,T.jsxs)(`div`,{className:`gh-changes-empty`,children:[(0,T.jsx)(`div`,{className:`gh-changes-empty-title`,children:v.changesEmptyTitle}),(0,T.jsx)(`p`,{className:`muted`,children:v.changesEmptyBody}),(0,T.jsx)(`button`,{type:`button`,onClick:t,disabled:n,children:n?`Syncing…`:`Sync`}),s&&(0,T.jsxs)(`button`,{type:`button`,onClick:s,disabled:c===!0,children:[`✨ `,v.reviewPrButton]}),r&&(0,T.jsxs)(`p`,{className:`muted small`,title:l(r),children:[`Last synced `,m(r)]})]}):(0,T.jsxs)(`div`,{className:`gh-changes-layout`,children:[(0,T.jsxs)(`div`,{className:`gh-changes-rail`,children:[(0,T.jsxs)(`div`,{className:`gh-changes-rail-header`,children:[(0,T.jsx)(`strong`,{children:p(d.length,`changed file`)}),o&&(0,T.jsx)(`button`,{type:`button`,className:`gh-review-rail-button small`,onClick:o,disabled:O!==``||c===!0,title:v.reviewCommitHint,children:v.reviewRailButton}),(0,T.jsx)(`button`,{type:`button`,className:`gh-changes-discard-all small`,onClick:()=>P(!0),disabled:O!==``,children:`Undo all…`})]}),g&&(0,T.jsxs)(`p`,{className:`muted small gh-changes-truncated`,children:[`Showing the first `,d.length,` files.`]}),(0,T.jsx)(`div`,{className:`gh-changes-rail-list`,children:(0,T.jsx)(N,{changes:d,selectedPath:x,onSelect:C,onDiscard:j,disabled:O!==``})}),(0,T.jsx)(F,{projectId:e,changes:d,busy:O===`save`,onSave:R})]}),(0,T.jsx)(`div`,{className:`gh-changes-diff-pane`,children:B?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`gh-changes-diff-header`,children:[(0,T.jsx)(`code`,{className:`gh-changes-diff-path`,title:B.path,children:B.path}),(0,T.jsx)(`span`,{className:`muted small`,children:_(B.kind)}),!B.binary&&(B.additions!==void 0||B.deletions!==void 0)&&(0,T.jsxs)(`span`,{className:`small`,children:[(0,T.jsxs)(`span`,{className:`gh-change-add`,children:[`+`,B.additions??0]}),` `,(0,T.jsxs)(`span`,{className:`gh-change-rem`,children:[`−`,B.deletions??0]})]})]}),E?(0,T.jsx)(f,{diff:E.diff,kind:E.kind,oldPath:E.oldPath,binary:E.binary,truncated:E.truncated}):(0,T.jsx)(`p`,{className:`muted gh-changes-loading`,children:`Loading…`})]}):(0,T.jsx)(`p`,{className:`placeholder`,children:`Pick a file to see what changed.`})}),(0,T.jsx)(u,{open:A!==null,title:`Undo changes to ${A?(e=>e.split(`/`).pop()??e)(A.path):``}?`,message:`This puts the file back to how it was at your last save. This can't be undone.`,confirmLabel:`Undo changes`,danger:!0,onConfirm:async()=>{let e=A;j(null),e&&await z({paths:[e.path]})},onCancel:()=>j(null)}),(0,T.jsx)(u,{open:M,title:`Undo all changes?`,message:`This puts all ${p(d.length,`file`)} back to how they were at your last save. This can't be undone.`,confirmLabel:`Undo everything`,danger:!0,onConfirm:async()=>{P(!1),await z({all:!0})},onCancel:()=>P(!1)})]})}var L=50;function R({projectId:e}){let[t,n]=(0,w.useState)(null),[r,a]=(0,w.useState)(!1),[o,s]=(0,w.useState)(null),[c,u]=(0,w.useState)(null),[h,g]=(0,w.useState)(!1),_=(0,w.useCallback)(async t=>{let r=await i.getProjectGitLog(e,{limit:L,skip:t});a(r.hasMore),n(e=>t===0?r.commits:[...e??[],...r.commits])},[e]);if((0,w.useEffect)(()=>{n(null),s(null),u(null),_(0).catch(()=>n([]))},[_]),(0,w.useEffect)(()=>{if(!o){u(null);return}let t=!1;return u(null),i.getProjectGitCommit(e,o).then(e=>{t||u(e)}).catch(()=>{t||u(null)}),()=>{t=!0}},[e,o]),t===null)return(0,T.jsx)(`p`,{className:`muted gh-timeline-loading`,children:`Loading…`});if(t.length===0)return(0,T.jsx)(`p`,{className:`muted gh-timeline-empty`,children:v.timelineEmpty});let y=c?.diff?d(c.diff):[];return(0,T.jsxs)(`div`,{className:`gh-timeline-layout`,children:[(0,T.jsxs)(`div`,{className:`gh-timeline-rail`,children:[(0,T.jsx)(`ul`,{className:`gh-timeline-list`,children:t.map(e=>(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{type:`button`,className:`gh-timeline-item${e.sha===o?` is-selected`:``}`,onClick:()=>s(e.sha),children:[(0,T.jsx)(`span`,{className:`gh-timeline-subject`,children:e.subject}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(e.date),children:[e.author,` saved `,p(e.filesChanged,`file`),` · `,m(e.date)]})]})},e.sha))}),r&&(0,T.jsx)(`button`,{type:`button`,className:`gh-timeline-more`,disabled:h,onClick:()=>{g(!0),_(t.length).finally(()=>g(!1))},children:h?`Loading…`:`Show earlier saves`})]}),(0,T.jsx)(`div`,{className:`gh-timeline-detail`,children:o===null?(0,T.jsx)(`p`,{className:`placeholder`,children:`Pick a save to see what changed.`}):c===null?(0,T.jsx)(`p`,{className:`muted gh-timeline-loading`,children:`Loading…`}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`gh-timeline-detail-header`,children:[(0,T.jsx)(`strong`,{children:c.subject}),(0,T.jsxs)(`span`,{className:`muted small`,title:l(c.date),children:[c.author,` · `,m(c.date)]})]}),y.length===0?(0,T.jsx)(`p`,{className:`muted`,children:`Sync point — this save combined changes that are each shown separately.`}):y.map(e=>(0,T.jsxs)(`div`,{className:`gh-timeline-file`,children:[e.path&&(0,T.jsx)(`div`,{className:`gh-timeline-file-path`,children:(0,T.jsx)(`code`,{children:e.path})}),(0,T.jsx)(f,{diff:e.diff})]},e.path||`diff`)),c.truncated&&(0,T.jsx)(`p`,{className:`muted small`,children:v.diffBig})]})})]})}function z({projectId:e}){let[t,n]=(0,w.useState)(null),[r,a]=(0,w.useState)(null),[o,s]=(0,w.useState)(null);return(0,w.useEffect)(()=>{n(null),a(null),s(null);let t=!1;return i.listProjectGitHubPulls(e).then(e=>{t||n(e.pulls)}).catch(e=>{t||(n([]),s(e instanceof Error?e.message:String(e)))}),()=>{t=!0}},[e]),(0,T.jsxs)(`div`,{className:`project-files-layout`,children:[(0,T.jsxs)(`div`,{className:`file-tree-panel`,children:[o&&(0,T.jsx)(`p`,{className:`error`,style:{padding:`0.5rem`},children:o}),t===null&&(0,T.jsx)(`p`,{className:`muted`,style:{padding:`0.5rem`},children:`Loading…`}),t&&t.length===0&&!o&&(0,T.jsx)(`p`,{className:`muted`,style:{padding:`0.5rem`},children:`No open pull requests.`}),t&&t.length>0&&(0,T.jsx)(`ul`,{className:`pr-list`,style:{listStyle:`none`,padding:0,margin:0},children:t.map(e=>(0,T.jsx)(`li`,{style:{borderBottom:`1px solid var(--border-color, #eee)`},children:(0,T.jsxs)(`button`,{type:`button`,className:r===e.number?`active`:``,onClick:()=>a(e.number),style:{display:`block`,width:`100%`,textAlign:`left`,padding:`0.5rem 0.6rem`,background:`transparent`,border:`none`,cursor:`pointer`},children:[(0,T.jsxs)(`div`,{style:{fontWeight:500},children:[`#`,e.number,` `,e.title,` `,e.draft&&(0,T.jsx)(`em`,{className:`muted`,children:`(draft)`})]}),(0,T.jsxs)(`div`,{className:`muted small`,children:[`by `,e.author,` — `,e.headRef,` → `,e.baseRef]})]})},e.number))})]}),(0,T.jsx)(`div`,{className:`file-viewer-panel`,children:r===null?(0,T.jsx)(`p`,{className:`placeholder`,style:{padding:`2rem`},children:`Select a pull request to view its details.`}):(0,T.jsx)(B,{projectId:e,num:r})})]})}function B({projectId:e,num:t}){let[n,r]=(0,w.useState)(null),[a,o]=(0,w.useState)(null),[s,u]=(0,w.useState)(null),[d,f]=(0,w.useState)(null);return(0,w.useEffect)(()=>{r(null),o(null),u(null),f(null);let n=!1;return(async()=>{try{let[a,s,c]=await Promise.all([i.getProjectGitHubPull(e,t),V(e,t),i.listProjectGitHubPullComments(e,t)]);if(n)return;r(a),o(s),u(c.comments)}catch(e){n||f(e.message)}})(),()=>{n=!0}},[e,t]),d?(0,T.jsx)(`p`,{className:`error`,style:{padding:`1rem`},children:d}):n?(0,T.jsxs)(`div`,{style:{padding:`0.5rem 0.75rem`,overflow:`auto`,height:`calc(100vh - 320px)`},children:[(0,T.jsxs)(`h3`,{style:{marginTop:0},children:[`#`,n.number,` `,n.title]}),(0,T.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`by `,n.author,` — `,n.headRef,` → `,n.baseRef,` —`,` `,(0,T.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,children:`view on GitHub`})]}),(0,T.jsxs)(`p`,{className:`muted small`,children:[n.merged?`merged`:n.state,` · `,n.changedFiles,` files · +`,n.additions,` −`,n.deletions]}),n.body&&(0,T.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`,background:`var(--code-bg, #f6f8fa)`,padding:`0.5rem`,borderRadius:4},children:n.body}),(0,T.jsx)(`h4`,{children:`Files changed`}),a&&a.length===0&&(0,T.jsx)(`p`,{className:`muted small`,children:`No files.`}),a&&a.length>0&&(0,T.jsx)(`ul`,{style:{listStyle:`none`,padding:0},children:a.map(e=>(0,T.jsx)(`li`,{style:{marginBottom:`0.5rem`},children:(0,T.jsxs)(`details`,{children:[(0,T.jsxs)(`summary`,{children:[(0,T.jsx)(`code`,{children:e.filename}),` `,(0,T.jsxs)(`span`,{className:`muted small`,children:[e.status,` +`,e.additions,` −`,e.deletions]})]}),e.patch?(0,T.jsx)(`pre`,{style:{background:`var(--code-bg, #f6f8fa)`,padding:`0.5rem`,overflow:`auto`,fontSize:`0.8rem`},children:e.patch}):(0,T.jsx)(`p`,{className:`muted small`,children:`No patch returned (binary or too large).`})]})},e.filename))}),(0,T.jsx)(`h4`,{children:`Comments`}),s&&s.length===0&&(0,T.jsx)(`p`,{className:`muted small`,children:`No comments yet.`}),s&&s.length>0&&(0,T.jsx)(`ul`,{style:{listStyle:`none`,padding:0},children:s.map(e=>(0,T.jsxs)(`li`,{style:{marginBottom:`0.75rem`,borderLeft:`3px solid var(--border-color, #ddd)`,paddingLeft:`0.5rem`},children:[(0,T.jsxs)(`div`,{className:`muted small`,children:[(0,T.jsx)(`strong`,{children:e.author}),` · `,e.kind,e.path&&(0,T.jsxs)(T.Fragment,{children:[` `,`on `,(0,T.jsx)(`code`,{children:e.path})]}),` · `,(0,T.jsx)(`span`,{title:l(e.createdAt),children:c(e.createdAt)})]}),(0,T.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`,margin:0,fontFamily:`inherit`},children:e.body})]},e.id))})]}):(0,T.jsx)(`p`,{className:`muted`,style:{padding:`1rem`},children:`Loading…`})}async function V(e,t){let n=[],r=0;for(;;){let a=await i.listProjectGitHubPullFiles(e,t,{offset:r,limit:200,includePatch:!0});if(n.push(...a.files),!a.hasMore||a.nextOffset===void 0)return n;r=a.nextOffset}}var H=5e3,U=3e4;function W(e){let t=e instanceof Error?e.message:String(e);return t.includes(`REVIEW_IN_PROGRESS`)?v.reviewAlreadyRunning:t.includes(`NO_DEFAULT_BRANCH`)?v.reviewNoDefaultBranch:t.includes(`DETACHED_HEAD`)?v.reviewDetachedHead:t}function G(e,t){let[n,r]=(0,w.useState)([]),[a,o]=(0,w.useState)(``),s=(0,w.useRef)(n);s.current=n;let c=(0,w.useCallback)(async()=>{try{let t=await i.listProjectCodeReviews(e);r(t.reviews)}catch{}},[e]),l=n.some(e=>e.status===`running`);(0,w.useEffect)(()=>{c();let t=window.setInterval(()=>void c(),l?H:U),n=t=>{t.detail?.projectId===e&&c()};return window.addEventListener(S,n),()=>{window.clearInterval(t),window.removeEventListener(S,n)}},[c,e,l]);let u=(0,w.useCallback)(async n=>{o(n===`commit`?`start-commit`:`start-pr`);try{let a=await i.startProjectCodeReview(e,{kind:n});return r(e=>[a.review,...e.filter(e=>e.id!==a.review.id)]),t(`ok`,v.reviewStartedToast),!0}catch(e){return(e instanceof Error?e.message:String(e)).includes(`NOTHING_TO_REVIEW`)?t(`err`,n===`commit`?v.reviewNothingCommit:v.reviewNothingPr):t(`err`,W(e)),!1}finally{o(``)}},[e,t]),d=(0,w.useCallback)(async n=>{o(`cancel`);try{let a=await i.cancelProjectCodeReview(e,n);r(e=>e.map(e=>e.id===a.review.id?a.review:e)),t(`ok`,v.reviewCanceledToast)}catch(e){t(`err`,W(e))}finally{o(``)}},[e,t]);return{reviews:n,running:n.filter(e=>e.status===`running`),start:u,cancel:d,busy:a,refresh:c}}function K({project:e,onProjectChange:t}){let[n,r]=(0,w.useState)(`changes`),[c,l]=(0,w.useState)(null),[d,f]=(0,w.useState)(null),[p,m]=(0,w.useState)(``),[h,g]=(0,w.useState)(null),[_,y]=(0,w.useState)(!1),[b,E]=(0,w.useState)(!1),[D,k]=(0,w.useState)(!1),A=(0,w.useRef)(!1),M=(0,w.useCallback)((e,t)=>{g({kind:e,text:t}),window.setTimeout(()=>g(null),5e3)},[]),N=(0,w.useCallback)(async()=>{try{let t=await i.getProjectGitStatus(e.id);l(t)}catch(e){f(e.message)}},[e.id]),{reviews:P,running:F,start:L,cancel:B,busy:V}=G(e.id,M),H=(0,w.useCallback)(e=>{L(e).then(e=>{e&&r(`review`)})},[L]),{sync:U,syncing:W}=x(e.id,{onToast:M,onConflicts:()=>{r(`changes`),N()},onNeedsSave:()=>{r(`changes`),y(!0)},onAuth:()=>E(!0)}),K=(0,w.useCallback)(async()=>{A.current=!0,(await U())?.state===`synced`&&(E(!1),k(!1)),await N()},[U,N]),J=(0,w.useCallback)(e=>{e&&(E(!1),N())},[N]);(0,w.useEffect)(()=>{f(null),r(`changes`),E(!1),k(!1),A.current=!1,N()},[e.id,N]),(0,w.useEffect)(()=>{let t=window.setInterval(()=>void N(),3e4),n=t=>{t.detail?.projectId===e.id&&N()};return window.addEventListener(S,n),()=>{window.clearInterval(t),window.removeEventListener(S,n)}},[N,e.id]);let Y=c?.exists===!0;(0,w.useEffect)(()=>{if(!Y)return;let t=()=>i.fetchProjectGit(e.id).then(()=>N()).catch(e=>{q(e)&&E(!0)});t();let n=window.setInterval(()=>void t(),3e5);return()=>window.clearInterval(n)},[Y,e.id,N]);let X=(0,w.useCallback)(async()=>{m(`Downloading…`),f(null);try{await i.cloneProjectGit(e.id),t(await i.getProject(e.id)),await N()}catch(e){f(e.message)}finally{m(``)}},[e.id,N,t]),Z=c&&!c.exists,ee=c?(c.credentialSource??(c.hasPat?`pat`:`none`))===`none`:!1,Q=c?.mergeInProgress===!0,te=c?.behind??0,$=c?.changesCount??0;return(0,T.jsxs)(`div`,{className:`project-github`,children:[(0,T.jsxs)(`div`,{className:`github-toolbar`,children:[(0,T.jsx)(`strong`,{children:e.github?.url}),p&&(0,T.jsx)(`span`,{className:`status`,children:p})]}),(ee||b)&&(0,T.jsxs)(`div`,{className:`github-banner gh-banner-warn`,children:[b?`GitHub needs you to sign in again.`:`No GitHub sign-in found. Public repositories still work; sign in for private repositories, pull requests, and sending changes.`,` `,(0,T.jsx)(C,{onChange:J,compact:!0})]}),!Q&&te>0&&!D&&(0,T.jsxs)(`div`,{className:`github-banner gh-banner-nudge`,children:[(0,T.jsx)(`span`,{children:v.nudgeBanner}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void K(),disabled:W,children:W?`Syncing…`:`Sync`}),(0,T.jsx)(`button`,{type:`button`,className:`gh-banner-dismiss`,"aria-label":`Dismiss`,onClick:()=>k(!0),children:`✕`})]}),d&&(0,T.jsx)(`p`,{className:`error`,children:d}),Z?(0,T.jsxs)(`div`,{className:`gh-clone-state`,children:[(0,T.jsx)(`p`,{children:`This project lives on GitHub but isn't on this computer yet.`}),(0,T.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void X(),disabled:!!p,children:`Download project`})]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(s,{value:n,onValueChange:e=>r(e),children:(0,T.jsxs)(o,{children:[(0,T.jsxs)(a,{value:`changes`,children:[`Changes`,$>0&&(0,T.jsx)(`span`,{className:`gh-tab-badge`,children:$})]}),(0,T.jsx)(a,{value:`timeline`,children:`Timeline`}),(0,T.jsx)(a,{value:`prs`,children:`Pull requests`}),(0,T.jsxs)(a,{value:`review`,children:[v.reviewTabLabel,F.length>0&&(0,T.jsx)(`span`,{className:`gh-tab-badge`,children:F.length})]})]})}),n===`changes`&&(Q?(0,T.jsx)(j,{projectId:e.id,resumed:!A.current,showToast:M,onFinished:()=>{N(),K()},onExited:()=>void N()}):(0,T.jsx)(I,{projectId:e.id,onSyncRequested:()=>void K(),syncing:W,lastSyncedAt:c?.github?.lastSyncedAt,showToast:M,onReviewRequested:()=>H(`commit`),onBranchReviewRequested:()=>H(`pr`),reviewBusy:V!==``||F.some(e=>e.kind===`commit`)})),n===`timeline`&&(0,T.jsx)(R,{projectId:e.id}),n===`prs`&&(0,T.jsx)(z,{projectId:e.id}),n===`review`&&(0,T.jsx)(O,{projectId:e.id,reviews:P,busy:V,changesCount:$,branch:c?.branch,defaultBranch:c?.defaultBranch??c?.github?.defaultBranch,onStart:e=>void L(e),onCancel:e=>void B(e)})]}),h&&(0,T.jsx)(`output`,{className:`project-git-toast project-git-toast-${h.kind}`,children:h.text}),(0,T.jsx)(u,{open:_,title:v.needsSaveTitle,message:v.needsSaveBody,confirmLabel:v.needsSaveConfirm,cancelLabel:v.needsSaveCancel,onConfirm:()=>{y(!1),r(`changes`)},onCancel:()=>y(!1)})]})}function q(e){return!(e instanceof r)||!e.details||typeof e.details!=`object`?!1:`code`in e.details&&e.details.code===`MISSING_PAT`}export{K as ProjectGitHubView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-BPraLwsh.js";import{n as i,t as a}from"./relative-time-B2kBaekd.js";import{i as o,n as s,r as c,t as l}from"./mail-link-DXkmCd5b.js";var u=e(t(),1),d=n(),f=e=>e.type.startsWith(`mail-`);function p({project:e,onProjectChange:t}){let[n,p]=(0,u.useState)(null),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(``),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(!1),[S,C]=(0,u.useState)(`imap`),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(``),[O,k]=(0,u.useState)(``),[A,j]=(0,u.useState)(``),[M,N]=(0,u.useState)(!0),P=(0,u.useCallback)(async()=>{try{p(await r.listConnectors(e.id))}catch(e){_(e instanceof Error?e.message:String(e))}},[e.id]);(0,u.useEffect)(()=>{P()},[P]);let F=(0,u.useCallback)(()=>{C(`imap`),T(``),D(``),k(``),j(``),N(!0)},[]),I=(0,u.useCallback)(async()=>{h(!0),_(``),y(``);try{let t=(n?.bindings??[]).filter(f),i=(await Promise.all(t.map(t=>r.syncConnector(e.id,t.id).then(e=>e.result).catch(()=>({}))))).reduce((e,t)=>e+(t.written??0)+(t.quarantined??0),0);y(i>0?`Synced ${i} new message(s).`:`Synced — no new mail.`),await P()}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}},[e.id,n,P]),L=(0,u.useCallback)(async()=>{_(``),y(``);let n=w.trim();if(!o(n)){_(`Enter a valid email address.`);return}if(S===`imap`&&(!E.trim()||!A)){_(`IMAP needs a host and a password.`);return}h(!0);try{S===`imap`?await c(e.id,{address:n,host:E.trim(),...O.trim()?{port:Number(O.trim())}:{},secure:M,pass:A}):await s(e.id,S,n),y(`Mailbox linked.`),x(!1),F(),await P();try{let n=await r.getProject(e.id);n&&t?.(n)}catch{}}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}},[e.id,S,w,E,O,A,M,P,t,F]),R=(n?.bindings??[]).filter(f);return(0,d.jsxs)(`div`,{className:`gz-mail-tab`,children:[(0,d.jsxs)(`div`,{className:`gz-mail-header`,children:[(0,d.jsx)(`h3`,{children:`Mail`}),R.length>0&&(0,d.jsx)(`button`,{type:`button`,onClick:()=>void I(),disabled:m,children:m?`Working…`:`Sync now`})]}),R.length===0?(0,d.jsx)(`p`,{className:`muted`,children:`No mailbox linked yet. Connect one to start syncing mail into this project as searchable files.`}):(0,d.jsx)(`ul`,{className:`gz-mail-accounts`,children:R.map(e=>(0,d.jsxs)(`li`,{className:`gz-mail-account`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`strong`,{children:e.displayName??e.id}),(0,d.jsxs)(`span`,{className:`muted small`,children:[` · `,e.type.replace(/^mail-/,``)]})]}),(0,d.jsx)(`div`,{className:`small`,children:e.lastError?(0,d.jsxs)(`span`,{className:`error`,children:[`Error: `,e.lastError]}):e.lastSyncedAt?(0,d.jsxs)(`span`,{className:`muted`,title:a(e.lastSyncedAt),children:[`Last synced `,i(e.lastSyncedAt)]}):(0,d.jsx)(`span`,{className:`muted`,children:`Not synced yet`})})]},e.id))}),b?(0,d.jsxs)(`div`,{className:`gz-mail-link-form`,children:[(0,d.jsxs)(`div`,{className:`gz-type-field`,children:[(0,d.jsx)(`span`,{className:`gz-type-field-label`,children:`Provider`}),(0,d.jsx)(`div`,{className:`gz-type-picker`,role:`radiogroup`,"aria-label":`Mail provider`,children:l.map(e=>(0,d.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.id===S,className:`gz-type-chip${e.id===S?` active`:``}`,onClick:()=>C(e.id),children:e.label},e.id))})]}),(0,d.jsxs)(`label`,{children:[`Email address`,(0,d.jsx)(`input`,{type:`email`,value:w,onChange:e=>T(e.target.value),placeholder:`you@example.com`,autoComplete:`email`})]}),S===`imap`?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`label`,{children:[`IMAP host`,(0,d.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),placeholder:`imap.example.com`})]}),(0,d.jsxs)(`div`,{className:`gz-imap-row`,children:[(0,d.jsxs)(`label`,{className:`gz-imap-port`,children:[`Port `,(0,d.jsx)(`span`,{className:`muted`,children:`(optional)`}),(0,d.jsx)(`input`,{value:O,onChange:e=>k(e.target.value),placeholder:`993`,inputMode:`numeric`})]}),(0,d.jsxs)(`label`,{className:`gz-imap-tls`,children:[(0,d.jsx)(`input`,{type:`checkbox`,checked:M,onChange:e=>N(e.target.checked)}),`Use TLS`]})]}),(0,d.jsxs)(`label`,{children:[`Password / app password`,(0,d.jsx)(`input`,{type:`password`,value:A,onChange:e=>j(e.target.value),autoComplete:`off`})]})]}):(0,d.jsxs)(`p`,{className:`muted small`,children:[`You'll authorize `,l.find(e=>e.id===S)?.label,` in your browser — a window opens when you click Connect.`]}),(0,d.jsxs)(`div`,{className:`gz-mail-link-actions`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>{x(!1),F(),_(``)},disabled:m,children:`Cancel`}),(0,d.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void L(),disabled:m,children:m?`Connecting…`:S===`imap`?`Link`:`Connect`})]})]}):(0,d.jsx)(`button`,{type:`button`,className:`gz-mail-connect`,onClick:()=>{x(!0),_(``),y(``)},children:`Connect a mailbox`}),g&&(0,d.jsx)(`p`,{className:`error small`,children:g}),v&&(0,d.jsx)(`p`,{className:`muted small`,children:v})]})}export{p as ProjectMailTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{an as r,et as i}from"./dist-BqGwkOe5.js";import{t as a}from"./api-BPraLwsh.js";import{t as o}from"./ConfirmDialog-Dt1ed4Fh.js";import{l as s}from"./index-C0DYtvfg.js";import{t as c}from"./MarkdownField-CK8K3fzj.js";import{a as l,i as u}from"./WorkspaceIndexPane-fpDz4MwZ.js";var d=e(t(),1),f=n();function p({projectId:e}){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(null),[s,c]=(0,d.useState)(``),[u,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(null),g=(0,d.useCallback)(async()=>{try{n(await a.listPeople(e))}catch{n(null)}},[e]);(0,d.useEffect)(()=>{g()},[g]);let _=(0,d.useCallback)(t=>a.fetchProjectWorkspaceBlob(e,t),[e]),v=(0,d.useCallback)(async t=>{let n=s.trim();if(i(null),!(!n||n===t.label)){h(null);try{await a.renamePerson(e,t.entityId,n),await g()}catch(e){h(e instanceof Error?e.message:String(e))}}},[s,e,g]),y=(0,d.useCallback)(async()=>{if(u){h(null);try{await a.forgetPerson(e,u.entityId),p(null),await g()}catch(e){h(e instanceof Error?e.message:String(e))}}},[u,e,g]);return!t?.available||t.people.length===0?null:(0,f.jsxs)(`section`,{className:`people-panel`,children:[(0,f.jsx)(`h3`,{children:`People`}),(0,f.jsx)(`p`,{className:`muted small`,children:`Recognized locally from photos in this project. Name someone once and search can find them everywhere.`}),(0,f.jsx)(`div`,{className:`people-grid`,children:t.people.map(e=>(0,f.jsxs)(`div`,{className:`people-card`,children:[(0,f.jsx)(`div`,{className:`people-card-photo`,children:e.exemplar?(0,f.jsx)(l,{path:e.exemplar.path,fetchBlob:_,alt:e.label}):(0,f.jsx)(`span`,{className:`similar-thumb-fallback`,children:e.label.slice(0,1)})}),r===e.entityId?(0,f.jsx)(`input`,{className:`people-card-rename`,value:s,ref:e=>e?.focus(),onChange:e=>c(e.target.value),onBlur:()=>void v(e),onKeyDown:t=>{t.key===`Enter`&&v(e),t.key===`Escape`&&i(null)},"aria-label":`Name for ${e.label}`}):(0,f.jsx)(`button`,{type:`button`,className:`people-card-name`,title:`Who is this?`,onClick:()=>{c(/^Person \d+$/.test(e.label)?``:e.label),i(e.entityId)},children:e.label}),(0,f.jsxs)(`span`,{className:`muted small`,children:[e.count,` photo`,e.count===1?``:`s`]}),(0,f.jsx)(`button`,{type:`button`,className:`people-card-forget`,onClick:()=>p(e),children:`Forget`})]},e.entityId))}),m&&(0,f.jsx)(`p`,{className:`error small`,children:m}),(0,f.jsx)(o,{open:u!==null,title:`Forget ${u?.label??`this person`}?`,message:`They disappear from People and search, and new photos of them stay unlisted. This does not delete any photos. To erase all face data instead, use Settings.`,confirmLabel:`Forget`,danger:!0,onConfirm:y,onCancel:()=>p(null)})]})}function m({label:e,hint:t,children:n,testId:r}){return(0,f.jsxs)(`section`,{"data-testid":r,children:[(0,f.jsxs)(`div`,{className:`home-workshop-rail-head`,children:[(0,f.jsx)(`div`,{className:`home-workshop-eyebrow`,style:{whiteSpace:`nowrap`},children:e}),t&&(0,f.jsx)(`div`,{className:`home-workshop-rail-hint`,children:t})]}),n]})}var h=()=>void 0;function g(e){let t=e.filter(e=>!e.isDirectory&&/^reports\/digest-\d{4}-W\d{2}\.md$/.test(e.path)).map(e=>e.path).sort();return t[t.length-1]??null}function _({projectId:e,project:t}){let[n,o]=(0,d.useState)(null),[l,_]=(0,d.useState)(null),[v,y]=(0,d.useState)([]),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)([]);(0,d.useEffect)(()=>{let t=!1;return o(null),x(null),C([]),a.toolMapRepo(e,{}).then(e=>{t||o(e)}).catch(()=>{t||o(null)}),a.getProjectIndexStatus(e).then(e=>{t||_(e)}).catch(()=>void 0),a.listHistory({projectId:e,limit:8}).then(e=>{t||y(e.entries)}).catch(()=>void 0),a.toolListTables(e).then(e=>{t||C(e.tables)}).catch(()=>void 0),a.listProjectArtifacts(e,`reports`,!0).then(async n=>{let r=g(n.files);if(!r||t)return;let i=await a.readProjectArtifact(e,r);t||x({path:r,content:i.content})}).catch(()=>void 0),()=>{t=!0}},[e]);let w=r(t),T=w?i(w)?.label??w:null,E=(n?.areas??[]).filter(e=>e.purpose),D=l?.state===`indexing`,O=l?.state===`disabled`,k=l?.aiScanPending===!0,A=l?.enrichment?.reviews?.pending??0;return(0,f.jsxs)(`div`,{className:`project-overview`,children:[(0,f.jsxs)(`div`,{className:`project-overview-head`,children:[(0,f.jsxs)(`div`,{className:`project-overview-title`,children:[(0,f.jsx)(s,{project:t,size:24,className:`project-overview-icon`}),(0,f.jsx)(`h2`,{children:t.name})]}),(0,f.jsxs)(`div`,{className:`project-overview-meta`,children:[T&&(0,f.jsx)(`span`,{className:`project-overview-chip`,children:T}),n?.indexed&&(0,f.jsxs)(`span`,{className:`project-overview-chip muted`,children:[n.fileCount,` files indexed`]}),(D||k)&&(0,f.jsx)(`span`,{className:`project-overview-chip pending`,children:u(l)})]})]}),!n?.indexed&&O&&(0,f.jsxs)(`p`,{className:`muted`,children:[`Workspace indexing is off for this project.`,` `,(0,f.jsx)(`button`,{type:`button`,className:`project-index-panel-link`,onClick:()=>window.dispatchEvent(new CustomEvent(`gezel:open-project-settings`,{detail:{projectId:e}})),children:`Turn it on in Project Settings`}),`.`]}),!n?.indexed&&!O&&(0,f.jsx)(`p`,{className:`muted`,children:`The boekwachter hasn't scanned this workspace yet. The map, folder notes, and architecture summary appear here once indexing runs.`}),n?.architecture&&(0,f.jsx)(m,{label:`Architecture`,testId:`overview-architecture`,children:(0,f.jsx)(`p`,{className:`project-overview-architecture`,children:n.architecture})}),n?.indexed&&!n.architecture&&(0,f.jsx)(m,{label:`Architecture`,children:(0,f.jsx)(`p`,{className:`muted small`,children:`Not written yet — the boekwachter distills an architecture note after it has summarized the files (idle time or Night Shift).`})}),n?.health&&(0,f.jsxs)(m,{label:`Health`,testId:`overview-health`,children:[(0,f.jsxs)(`div`,{className:`project-overview-chips`,children:[(0,f.jsxs)(`span`,{className:`project-overview-chip`,children:[`avg `,n.health.avgHealth,`/10`]}),(0,f.jsxs)(`span`,{className:`project-overview-chip muted`,children:[n.health.reviewedFiles,`/`,n.health.eligibleFiles,` files reviewed`]}),n.health.majorIssues>0&&(0,f.jsxs)(`span`,{className:`project-overview-chip pending`,children:[n.health.majorIssues,` major issue`,n.health.majorIssues===1?``:`s`]}),n.health.minorIssues>0&&(0,f.jsxs)(`span`,{className:`project-overview-chip muted`,children:[n.health.minorIssues,` minor`]})]}),A>0&&(0,f.jsxs)(`p`,{className:`muted small`,children:[`The boekwachter is still reviewing — `,A,` file`,A===1?``:`s`,` to go. Scores are its opinion, not a verdict.`]}),n.health.worstFiles.length>0&&(0,f.jsx)(`ul`,{className:`project-overview-areas`,children:n.health.worstFiles.map(t=>(0,f.jsxs)(`li`,{children:[(0,f.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>window.dispatchEvent(new CustomEvent(`gezel:open-file`,{detail:{projectId:e,path:t.path,source:`workspace`}})),children:(0,f.jsx)(`code`,{children:t.path})}),(0,f.jsxs)(`span`,{className:`muted small`,children:[` `,t.health,`/10`]}),t.reason&&(0,f.jsx)(`div`,{className:`muted small`,children:t.reason})]},t.path))})]}),E.length>0&&(0,f.jsx)(m,{label:`Areas`,testId:`overview-areas`,children:(0,f.jsx)(`ul`,{className:`project-overview-areas`,children:E.slice(0,10).map(e=>(0,f.jsxs)(`li`,{children:[(0,f.jsx)(`code`,{children:e.path===`.`?`(root)`:`${e.path}/`}),(0,f.jsxs)(`span`,{className:`muted small`,children:[` `,e.fileCount,` files`]}),(0,f.jsx)(`div`,{children:e.purpose})]},e.path))})}),n&&(n.languages.length>0||n.entryPoints.length>0)&&(0,f.jsxs)(m,{label:`Shape`,children:[n.languages.length>0&&(0,f.jsx)(`div`,{className:`project-overview-chips`,children:n.languages.slice(0,8).map(e=>(0,f.jsxs)(`span`,{className:`project-overview-chip muted`,children:[e.lang,` · `,e.fileCount]},e.lang))}),n.entryPoints.length>0&&(0,f.jsxs)(`p`,{className:`small`,children:[`Entry points:`,` `,n.entryPoints.slice(0,6).map((e,t)=>(0,f.jsxs)(`span`,{children:[t>0&&`, `,(0,f.jsx)(`code`,{children:e})]},e))]})]}),(0,f.jsx)(p,{projectId:e}),v.length>0&&(0,f.jsx)(m,{label:`Recent activity`,testId:`overview-activity`,children:(0,f.jsx)(`ul`,{className:`project-overview-activity`,children:v.map(e=>(0,f.jsxs)(`li`,{children:[(0,f.jsx)(`span`,{className:`muted small`,children:(e.entryType===`event`?e.at:e.lastActivityAt).slice(0,10)}),` `,e.entryType===`event`?e.summary:`Chat: ${e.title}`]},e.id))})}),S.length>0&&(0,f.jsx)(m,{label:`Data tables`,hint:`${S.length} table${S.length===1?``:`s`}`,children:(0,f.jsx)(`ul`,{className:`project-overview-tables`,children:S.map(e=>(0,f.jsxs)(`li`,{className:`small`,children:[(0,f.jsx)(`strong`,{children:e.table}),` `,(0,f.jsxs)(`span`,{className:`muted`,children:[e.rows.toLocaleString(),` `,e.rows===1?`row`:`rows`,` · `,e.columns,` columns`,e.origin===`workspace`?` · from ${e.source}`:` · ${e.source}`,e.schemaInferred?` · schema inferred`:``]})]},`${e.origin}:${e.table}`))})}),b&&(0,f.jsxs)(m,{label:`Latest weekly digest`,hint:b.path,children:[(0,f.jsx)(`div`,{className:`project-overview-digest`,children:(0,f.jsx)(c,{value:b.content,readOnly:!0,onCommit:h},b.path)}),(0,f.jsx)(`button`,{type:`button`,className:`project-overview-open-digest`,onClick:()=>window.dispatchEvent(new CustomEvent(`gezel:open-file`,{detail:{projectId:e,path:b.path,source:`artifacts`}})),children:`Open in artifacts`})]})]})}export{_ as ProjectOverviewView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{Ft as r}from"./dist-BqGwkOe5.js";import{t as i}from"./api-BPraLwsh.js";import{zt as a}from"./index-C0DYtvfg.js";import{t as o}from"./ChatTimelineView-CQ4Sf4Ip.js";var s=e(t(),1),c=750,l=15e3;function u({projectId:e,refreshKey:t}){let[n,r]=(0,s.useState)([]),[o,u]=(0,s.useState)([]),[d,f]=(0,s.useState)(!0),p=(0,s.useCallback)(async()=>{try{let t=await i.listProjectTasks(e,{status:`active`});r(t.tasks),u(t.waiting??[])}catch{}finally{f(!1)}},[e]);(0,s.useEffect)(()=>{f(!0),p()},[p,t]);let m=(0,s.useRef)(null);(0,s.useEffect)(()=>{let t=new AbortController,n=()=>{m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>{m.current=null,p()},c)};return(async()=>{try{for await(let r of a({url:i.projectEventsUrl(e),headers:i.authHeader(),signal:t.signal,fetch:i.getFetch()}))r.event.type===`task_event`&&n()}catch{}})(),()=>{t.abort(),m.current!==null&&(window.clearTimeout(m.current),m.current=null)}},[e,p]);let h=o.length>0;return(0,s.useEffect)(()=>{if(!h)return;let e=window.setInterval(()=>void p(),l);return()=>window.clearInterval(e)},[h,p]),{tasks:n,waiting:o,loading:d}}function d(e){let{tasks:t,waiting:n,gezelId:r,taskRef:i}=e;if(n.length===0)return[];let a=new Map(t.map(e=>[e.ref,e])),o=[];for(let e of n){if(i&&e.ref!==i||r&&e.gezelId!==r)continue;let t=a.get(e.ref);t&&o.push({task:t,wait:e})}return o.sort((e,t)=>Date.parse(e.wait.since)-Date.parse(t.wait.since)),o}var f=n();function p({projectId:e,gezelId:t,taskRef:n,activeSessionId:a,onFocusSession:c,onToolActivity:l,onArtifactReference:p,onArtifactSeen:h,onWorkspaceReference:g,onWorkspaceSeen:_,onOpenReference:v,onTaskReference:y,emptyPlaceholder:b,onTerminalWorkingDirChanged:x,terminalRefreshKey:S,terminalSubmission:C,terminalFocusRequest:w,sessionFocusRequest:T}){let E=(0,s.useCallback)(r=>i.listProjectTimeline(e,{...r,...t?{gezelId:t}:{},...n?{taskRef:n}:{}}),[e,t,n]),D=(0,s.useCallback)(()=>t?i.gezelEventsUrl(t):i.projectEventsUrl(e),[e,t]),O=(0,s.useCallback)(()=>i.terminalEventsUrl(e),[e]),k=(0,s.useMemo)(()=>t?{projectId:e,gezelId:t}:{projectId:e},[e,t]),[A,j]=(0,s.useState)(m),[M,N]=(0,s.useState)(0);(0,s.useEffect)(()=>{if(!n){j(m);return}let e=r(n);if(!e){j(m);return}let t=!1;return i.listTaskSessions(e.projectId,e.num).then(e=>{t||j(new Set(e.sessions.filter(e=>!e.archived).map(e=>e.id)))}).catch(()=>{}),()=>{t=!0}},[n,M]);let P=(0,s.useMemo)(()=>{if(n)return!a||A.has(a)?A:new Set([...A,a])},[n,A,a]),F=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{F.current!==null&&(window.clearTimeout(F.current),F.current=null)},[]);let I=(0,s.useCallback)(()=>{F.current===null&&(F.current=window.setTimeout(()=>{F.current=null,N(e=>e+1)},500))},[]),{tasks:L,waiting:R}=u({projectId:e}),z=(0,s.useMemo)(()=>d({tasks:L,waiting:R,gezelId:t,taskRef:n}),[L,R,t,n]);return(0,f.jsx)(o,{scopeKey:n?`project:${e}:task:${n}`:t?`project:${e}:gezel:${t}`:`project:${e}`,activeSessionId:a,onFocusSession:c,onToolActivity:l,onArtifactReference:p,onArtifactSeen:h,onWorkspaceReference:g,onWorkspaceSeen:_,onOpenReference:v,...y?{onTaskReference:y}:{},queuedTasks:z,emptyPlaceholder:b,loadTimeline:E,streamUrl:D,...t||n?{}:{terminalStreamUrl:O},...S===void 0?{}:{terminalRefreshKey:S},...C?{terminalSubmission:C}:{},...w?{terminalFocusRequest:w}:{},...T?{sessionFocusRequest:T}:{},...t||n||!x?{}:{onTerminalWorkingDirChanged:x},inflightScope:k,...P?{scopedSessionIds:P,onUnknownSession:I}:{}})}var m=new Set;export{u as n,p as t};
|