specrails-desktop 2.30.2 → 2.31.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/README.md +28 -24
- package/client/dist/assets/{ActivityFeedPage-9DZOvIcY.js → ActivityFeedPage-CAhFRUO4.js} +1 -1
- package/client/dist/assets/{AgentBrowserCapture-DqyHbzk7.js → AgentBrowserCapture-Ct4G5lsE.js} +1 -1
- package/client/dist/assets/AgentModeCodePane-DQt9WIvu.js +2 -0
- package/client/dist/assets/{AgentModeJobsPane-CTIHMUKN.js → AgentModeJobsPane-podaJVl9.js} +1 -1
- package/client/dist/assets/AgentsPage-DTZdbW80.js +87 -0
- package/client/dist/assets/AnalyticsPage-BskgGPm0.js +1 -0
- package/client/dist/assets/CodePage-CvtYo1DU.js +2 -0
- package/client/dist/assets/{DesktopAnalyticsPage-CkXUFj3F.js → DesktopAnalyticsPage-Dnf99E8e.js} +1 -1
- package/client/dist/assets/{DocsDialog-PhdCJNVj.js → DocsDialog-DHi36rZ4.js} +1 -1
- package/client/dist/assets/{DocsPage-BY-wDthx.js → DocsPage-DIdVrQz1.js} +1 -1
- package/client/dist/assets/{InteractiveJobComposer-C9I0A4KR.js → InteractiveJobComposer-BHeB2inv.js} +1 -1
- package/client/dist/assets/{JobDetailModal-I_RoQJV4.js → JobDetailModal-CF1SKUHH.js} +1 -1
- package/client/dist/assets/JobDetailPage-De3rY18h.js +1 -0
- package/client/dist/assets/{JobsPage-DcllM4Ip.js → JobsPage-CfAqqJTx.js} +1 -1
- package/client/dist/assets/{LoopBuilderPage-DGm_iuff.js → LoopBuilderPage-DSBMuTb3.js} +2 -2
- package/client/dist/assets/{LoopPreviewModal-BC-TeFdD.js → LoopPreviewModal-B-c37kA0.js} +1 -1
- package/client/dist/assets/LoopsPage-DjnNXdmm.js +1 -0
- package/client/dist/assets/{MinimizedChatsContext-Cs34FPTz.js → MinimizedChatsContext-DIsnQMVz.js} +1 -1
- package/client/dist/assets/PluginsPage-DA5pQ_6u.js +2 -0
- package/client/dist/assets/{ProjectSettingsDialog-nEs-ENrE.js → ProjectSettingsDialog-DA23PSi6.js} +1 -1
- package/client/dist/assets/{TemplatePreviewModal-D4qW-J9B.js → TemplatePreviewModal-Cp7IQ-g2.js} +1 -1
- package/client/dist/assets/TicketDetailModal-BPD2i_0R.js +14 -0
- package/client/dist/assets/{Trans-CPISVji8.js → Trans-cWtExGkC.js} +1 -1
- package/client/dist/assets/addspec-4WmLJmBG.js +1 -0
- package/client/dist/assets/addspec-BRlk8jON.js +1 -0
- package/client/dist/assets/addspec-C7XRejU4.js +1 -0
- package/client/dist/assets/addspec-CHW9xf_X.js +1 -0
- package/client/dist/assets/addspec-DTmRrWrF.js +1 -0
- package/client/dist/assets/addspec-DhmnXER8.js +1 -0
- package/client/dist/assets/addspec-Di41DpYV.js +1 -0
- package/client/dist/assets/addspec-x3mizDxc.js +1 -0
- package/client/dist/assets/agent-BKsuIgIT.js +1 -0
- package/client/dist/assets/agent-Bs9NilfI.js +1 -0
- package/client/dist/assets/agent-C23h684q.js +1 -0
- package/client/dist/assets/agent-CqEjy3Z2.js +1 -0
- package/client/dist/assets/agent-D5DZTks1.js +1 -0
- package/client/dist/assets/agent-DE8hUYPl.js +1 -0
- package/client/dist/assets/agent-DsTuJGSc.js +1 -0
- package/client/dist/assets/agent-DwZM05-x.js +1 -0
- package/client/dist/assets/agents-45GbINfh.js +1 -0
- package/client/dist/assets/agents-BHp0_FQt.js +1 -0
- package/client/dist/assets/agents-Bvyi3y6R.js +1 -0
- package/client/dist/assets/agents-DMKFStHL.js +1 -0
- package/client/dist/assets/agents-DaYcxAr1.js +1 -0
- package/client/dist/assets/agents-IUOgqT5t.js +1 -0
- package/client/dist/assets/agents-ms7TwG16.js +1 -0
- package/client/dist/assets/agents-rzPnqoBR.js +1 -0
- package/client/dist/assets/agentstudio-8TQqBenW.js +1 -0
- package/client/dist/assets/agentstudio-B8Z_mmEX.js +1 -0
- package/client/dist/assets/agentstudio-BZR9YmLs.js +1 -0
- package/client/dist/assets/agentstudio-Bge9pAWb.js +1 -0
- package/client/dist/assets/agentstudio-Bz169Vzt.js +1 -0
- package/client/dist/assets/agentstudio-D6L2jpNi.js +1 -0
- package/client/dist/assets/agentstudio-K2-Z7CL0.js +1 -0
- package/client/dist/assets/agentstudio-Zmgzthv8.js +1 -0
- package/client/dist/assets/analytics-B8Qtptbl.js +1 -0
- package/client/dist/assets/analytics-BHqUazhP.js +1 -0
- package/client/dist/assets/analytics-BPptRY4f.js +1 -0
- package/client/dist/assets/analytics-BxDGOIwf.js +1 -0
- package/client/dist/assets/analytics-C9RaQcE3.js +1 -0
- package/client/dist/assets/analytics-CJIwqrEl.js +1 -0
- package/client/dist/assets/analytics-D_OZdQ9O.js +1 -0
- package/client/dist/assets/analytics-We6lUMI8.js +1 -0
- package/client/dist/assets/builder-3bygQtZi.js +1 -0
- package/client/dist/assets/builder-BiUG9Z5K.js +1 -0
- package/client/dist/assets/builder-CGRz_-zP.js +1 -0
- package/client/dist/assets/builder-CWYPw7Cw.js +1 -0
- package/client/dist/assets/builder-CX1437hF.js +1 -0
- package/client/dist/assets/{builder-CwA4T7gP.js → builder-Cowk9jtL.js} +1 -1
- package/client/dist/assets/builder-DwDexYRE.js +1 -0
- package/client/dist/assets/builder-skfnZ1uC.js +1 -0
- package/client/dist/assets/code-B0O8-p8k.js +1 -0
- package/client/dist/assets/code-B1VLZDhS.js +1 -0
- package/client/dist/assets/code-B86IMAfz.js +1 -0
- package/client/dist/assets/code-Bpj4Ddml.js +1 -0
- package/client/dist/assets/code-BykBZ5-e.js +1 -0
- package/client/dist/assets/code-CHPkOkDS.js +1 -0
- package/client/dist/assets/code-CkUuW4m9.js +1 -0
- package/client/dist/assets/code-cAqaqMTx.js +1 -0
- package/client/dist/assets/{dashboard-Dy2Um-US.js → dashboard-BVq6kRJe.js} +1 -1
- package/client/dist/assets/{dashboard-CHCEkds4.js → dashboard-BaKPPmLH.js} +1 -1
- package/client/dist/assets/{dashboard-CrlTV1ms.js → dashboard-Bm8e4zYG.js} +1 -1
- package/client/dist/assets/{dashboard-WhzOQw1S.js → dashboard-Bt6IesnM.js} +1 -1
- package/client/dist/assets/{dashboard-Cslu_GCH.js → dashboard-C_NQZle_.js} +1 -1
- package/client/dist/assets/{dashboard-DweT3Y4R.js → dashboard-CyZKoGoI.js} +1 -1
- package/client/dist/assets/{dashboard-DUU8-_Rg.js → dashboard-HIUdUBQ0.js} +1 -1
- package/client/dist/assets/{dashboard-Cqmmbh3l.js → dashboard-pm4Mr229.js} +1 -1
- package/client/dist/assets/{dist-js-jwoXo0YD.js → dist-js-BaP-xLOy.js} +1 -1
- package/client/dist/assets/{dist-js-Dj72W6qo.js → dist-js-CLlgOa5a.js} +1 -1
- package/client/dist/assets/format-command-C0D9IPmV.js +1 -0
- package/client/dist/assets/{formatDistanceToNow-ByKli7Q_.js → formatDistanceToNow-DUyzS4rr.js} +1 -1
- package/client/dist/assets/{getTimezoneOffsetInMilliseconds-qrcBaLW1.js → getTimezoneOffsetInMilliseconds-BCIwmmTj.js} +1 -1
- package/client/dist/assets/{i18n-Bf9Ckd10.js → i18n-D21Pr8Sj.js} +2 -2
- package/client/dist/assets/index-BdSDUFnA.css +2 -0
- package/client/dist/assets/index-Ci4-JKDr.js +77 -0
- package/client/dist/assets/{jobs-CVFD8rar.js → jobs-BAls3bWq.js} +1 -1
- package/client/dist/assets/{jobs-DoSaFzAa.js → jobs-B_TeSQxb.js} +1 -1
- package/client/dist/assets/jobs-Bgq-PZkC.js +1 -0
- package/client/dist/assets/jobs-Bpks6doU.js +1 -0
- package/client/dist/assets/jobs-CN_zv4Gr.js +1 -0
- package/client/dist/assets/jobs-DUlWSYq2.js +1 -0
- package/client/dist/assets/{jobs-B-sDHEay.js → jobs-DhxKgWFq.js} +1 -1
- package/client/dist/assets/{jobs-lk1_Dq1U.js → jobs-SwYS2M-B.js} +1 -1
- package/client/dist/assets/nav-BHDiSIVu.js +1 -0
- package/client/dist/assets/nav-CMiYAq4i.js +1 -0
- package/client/dist/assets/nav-CqS7NrDW.js +1 -0
- package/client/dist/assets/nav-D-0M7xfv.js +1 -0
- package/client/dist/assets/nav-D65O6u9I.js +1 -0
- package/client/dist/assets/nav-D_LKYvBr.js +1 -0
- package/client/dist/assets/nav-FDTJmU79.js +1 -0
- package/client/dist/assets/nav-VaB-C4k5.js +1 -0
- package/client/dist/assets/provider-capabilities-BvoExILy.js +1 -0
- package/client/dist/assets/settings-BveOJoaI.js +1 -0
- package/client/dist/assets/settings-Cj1C6F5k.js +1 -0
- package/client/dist/assets/settings-CuVwOpe0.js +1 -0
- package/client/dist/assets/settings-D5X4DfRc.js +1 -0
- package/client/dist/assets/settings-DXwxe-BW.js +1 -0
- package/client/dist/assets/settings-Di81Ba_V.js +1 -0
- package/client/dist/assets/settings-jbLjCYC_.js +1 -0
- package/client/dist/assets/settings-wIZNPFnn.js +1 -0
- package/client/dist/assets/setup-BBiHEO7h.js +1 -0
- package/client/dist/assets/setup-BlTWhNIQ.js +1 -0
- package/client/dist/assets/setup-Bp2L_oiP.js +1 -0
- package/client/dist/assets/setup-CInYXp1-.js +1 -0
- package/client/dist/assets/{setup-CITtPjed.js → setup-CYH3bP6K.js} +1 -1
- package/client/dist/assets/setup-DwcQ921P.js +1 -0
- package/client/dist/assets/setup-PBLjuDSs.js +1 -0
- package/client/dist/assets/setup-bx6FtoBp.js +1 -0
- package/client/dist/assets/{spending-DMnCXy84.js → spending-BCyUxoOI.js} +1 -1
- package/client/dist/assets/{tickets-B8BuAaj5.js → tickets-BL9r1G0e.js} +1 -1
- package/client/dist/assets/{tickets-DpmdE8tv.js → tickets-B_NyHJ8f.js} +1 -1
- package/client/dist/assets/{tickets-B_yh4qQk.js → tickets-BarF1wuG.js} +1 -1
- package/client/dist/assets/{tickets-pAUJkDTu.js → tickets-CclVhpQA.js} +1 -1
- package/client/dist/assets/{tickets-D_yDquEw.js → tickets-CqqOHbli.js} +1 -1
- package/client/dist/assets/{tickets-CFk2n2Or.js → tickets-DCkFSiqt.js} +1 -1
- package/client/dist/assets/{tickets-DQp7JS2R.js → tickets-Djn3ccfT.js} +1 -1
- package/client/dist/assets/{tickets-Bs37scwY.js → tickets-MiHBPsy_.js} +1 -1
- package/client/dist/assets/{useBrowserCaptureSession-CkBJShUw.js → useBrowserCaptureSession-CkVCDzer.js} +1 -1
- package/client/dist/assets/{useDesktop-B4pSBIDd.js → useDesktop-DCP_MHp9.js} +1 -1
- package/client/dist/index.html +25 -24
- package/docs/README.md +7 -3
- package/docs/cli.md +3 -3
- package/docs/codex.md +51 -64
- package/docs/creating-specs.md +36 -4
- package/docs/customizing.md +5 -5
- package/docs/gemini.md +35 -47
- package/docs/getting-started.md +15 -9
- package/docs/guide/de/agents/2-profiles-and-the-balanced-default.md +5 -1
- package/docs/guide/de/agents/4-custom-agents-catalog.md +7 -4
- package/docs/guide/de/getting-started/1-what-is-specrails.md +1 -0
- package/docs/guide/de/getting-started/2-installing-and-first-run.md +1 -0
- package/docs/guide/de/getting-started/4-the-dashboard-tour.md +4 -4
- package/docs/guide/de/integrations/1-ai-providers.md +29 -18
- package/docs/guide/de/integrations/2-plugins.md +3 -3
- package/docs/guide/de/integrations/6-agent-chat.md +8 -1
- package/docs/guide/de/pipeline/1-rails-and-jobs.md +9 -6
- package/docs/guide/de/pipeline/2-the-job-detail-view.md +3 -1
- package/docs/guide/de/pipeline/3-batch-implement-and-multi-feature.md +1 -1
- package/docs/guide/de/pipeline/4-picking-an-engine-per-rail.md +13 -13
- package/docs/guide/de/pipeline/5-the-loop-builder.md +6 -2
- package/docs/guide/de/specs/2-add-spec-quick-mode.md +6 -1
- package/docs/guide/en/agents/2-profiles-and-the-balanced-default.md +7 -1
- package/docs/guide/en/agents/4-custom-agents-catalog.md +17 -4
- package/docs/guide/en/getting-started/1-what-is-specrails.md +2 -1
- package/docs/guide/en/getting-started/2-installing-and-first-run.md +2 -1
- package/docs/guide/en/getting-started/4-the-dashboard-tour.md +5 -5
- package/docs/guide/en/insights/3-code-explorer.md +5 -0
- package/docs/guide/en/integrations/1-ai-providers.md +63 -22
- package/docs/guide/en/integrations/2-plugins.md +3 -3
- package/docs/guide/en/integrations/6-agent-chat.md +14 -2
- package/docs/guide/en/pipeline/1-rails-and-jobs.md +19 -7
- package/docs/guide/en/pipeline/2-the-job-detail-view.md +3 -1
- package/docs/guide/en/pipeline/3-batch-implement-and-multi-feature.md +1 -1
- package/docs/guide/en/pipeline/4-picking-an-engine-per-rail.md +25 -11
- package/docs/guide/en/pipeline/5-the-loop-builder.md +7 -2
- package/docs/guide/en/specs/2-add-spec-quick-mode.md +10 -1
- package/docs/guide/es/agents/2-profiles-and-the-balanced-default.md +5 -1
- package/docs/guide/es/agents/4-custom-agents-catalog.md +7 -4
- package/docs/guide/es/getting-started/1-what-is-specrails.md +1 -0
- package/docs/guide/es/getting-started/2-installing-and-first-run.md +1 -0
- package/docs/guide/es/getting-started/4-the-dashboard-tour.md +4 -4
- package/docs/guide/es/integrations/1-ai-providers.md +30 -18
- package/docs/guide/es/integrations/2-plugins.md +3 -3
- package/docs/guide/es/integrations/6-agent-chat.md +8 -1
- package/docs/guide/es/pipeline/1-rails-and-jobs.md +9 -6
- package/docs/guide/es/pipeline/2-the-job-detail-view.md +3 -1
- package/docs/guide/es/pipeline/3-batch-implement-and-multi-feature.md +1 -1
- package/docs/guide/es/pipeline/4-picking-an-engine-per-rail.md +15 -13
- package/docs/guide/es/pipeline/5-the-loop-builder.md +6 -2
- package/docs/guide/es/specs/2-add-spec-quick-mode.md +6 -1
- package/docs/guide/fr/agents/2-profiles-and-the-balanced-default.md +5 -1
- package/docs/guide/fr/agents/4-custom-agents-catalog.md +7 -4
- package/docs/guide/fr/getting-started/1-what-is-specrails.md +1 -0
- package/docs/guide/fr/getting-started/2-installing-and-first-run.md +1 -0
- package/docs/guide/fr/getting-started/4-the-dashboard-tour.md +4 -4
- package/docs/guide/fr/integrations/1-ai-providers.md +29 -18
- package/docs/guide/fr/integrations/2-plugins.md +3 -3
- package/docs/guide/fr/integrations/6-agent-chat.md +8 -1
- package/docs/guide/fr/pipeline/1-rails-and-jobs.md +9 -6
- package/docs/guide/fr/pipeline/2-the-job-detail-view.md +3 -1
- package/docs/guide/fr/pipeline/3-batch-implement-and-multi-feature.md +1 -1
- package/docs/guide/fr/pipeline/4-picking-an-engine-per-rail.md +15 -13
- package/docs/guide/fr/pipeline/5-the-loop-builder.md +6 -2
- package/docs/guide/fr/specs/2-add-spec-quick-mode.md +6 -1
- package/docs/guide/it/agents/2-profiles-and-the-balanced-default.md +5 -1
- package/docs/guide/it/agents/4-custom-agents-catalog.md +7 -4
- package/docs/guide/it/getting-started/1-what-is-specrails.md +1 -0
- package/docs/guide/it/getting-started/2-installing-and-first-run.md +1 -0
- package/docs/guide/it/getting-started/4-the-dashboard-tour.md +4 -4
- package/docs/guide/it/integrations/1-ai-providers.md +28 -18
- package/docs/guide/it/integrations/2-plugins.md +3 -3
- package/docs/guide/it/integrations/6-agent-chat.md +8 -1
- package/docs/guide/it/pipeline/1-rails-and-jobs.md +9 -6
- package/docs/guide/it/pipeline/2-the-job-detail-view.md +3 -1
- package/docs/guide/it/pipeline/3-batch-implement-and-multi-feature.md +1 -1
- package/docs/guide/it/pipeline/4-picking-an-engine-per-rail.md +13 -13
- package/docs/guide/it/pipeline/5-the-loop-builder.md +6 -2
- package/docs/guide/it/specs/2-add-spec-quick-mode.md +6 -1
- package/docs/guide/ja/agents/2-profiles-and-the-balanced-default.md +6 -1
- package/docs/guide/ja/agents/4-custom-agents-catalog.md +7 -4
- package/docs/guide/ja/getting-started/1-what-is-specrails.md +1 -0
- package/docs/guide/ja/getting-started/2-installing-and-first-run.md +1 -0
- package/docs/guide/ja/getting-started/4-the-dashboard-tour.md +4 -4
- package/docs/guide/ja/integrations/1-ai-providers.md +28 -18
- package/docs/guide/ja/integrations/2-plugins.md +3 -3
- package/docs/guide/ja/integrations/6-agent-chat.md +7 -1
- package/docs/guide/ja/pipeline/1-rails-and-jobs.md +9 -6
- package/docs/guide/ja/pipeline/2-the-job-detail-view.md +3 -1
- package/docs/guide/ja/pipeline/3-batch-implement-and-multi-feature.md +1 -1
- package/docs/guide/ja/pipeline/4-picking-an-engine-per-rail.md +14 -13
- package/docs/guide/ja/pipeline/5-the-loop-builder.md +6 -2
- package/docs/guide/ja/specs/2-add-spec-quick-mode.md +6 -1
- package/docs/guide/pt/agents/2-profiles-and-the-balanced-default.md +5 -1
- package/docs/guide/pt/agents/4-custom-agents-catalog.md +7 -4
- package/docs/guide/pt/getting-started/1-what-is-specrails.md +1 -0
- package/docs/guide/pt/getting-started/2-installing-and-first-run.md +1 -0
- package/docs/guide/pt/getting-started/4-the-dashboard-tour.md +4 -4
- package/docs/guide/pt/integrations/1-ai-providers.md +28 -18
- package/docs/guide/pt/integrations/2-plugins.md +3 -3
- package/docs/guide/pt/integrations/6-agent-chat.md +7 -1
- package/docs/guide/pt/pipeline/1-rails-and-jobs.md +9 -6
- package/docs/guide/pt/pipeline/2-the-job-detail-view.md +2 -1
- package/docs/guide/pt/pipeline/3-batch-implement-and-multi-feature.md +1 -1
- package/docs/guide/pt/pipeline/4-picking-an-engine-per-rail.md +14 -13
- package/docs/guide/pt/pipeline/5-the-loop-builder.md +6 -2
- package/docs/guide/pt/specs/2-add-spec-quick-mode.md +6 -1
- package/docs/guide/zh/agents/2-profiles-and-the-balanced-default.md +4 -1
- package/docs/guide/zh/agents/4-custom-agents-catalog.md +7 -4
- package/docs/guide/zh/getting-started/1-what-is-specrails.md +1 -0
- package/docs/guide/zh/getting-started/2-installing-and-first-run.md +1 -0
- package/docs/guide/zh/getting-started/4-the-dashboard-tour.md +4 -4
- package/docs/guide/zh/integrations/1-ai-providers.md +26 -18
- package/docs/guide/zh/integrations/2-plugins.md +3 -3
- package/docs/guide/zh/integrations/6-agent-chat.md +6 -1
- package/docs/guide/zh/pipeline/1-rails-and-jobs.md +9 -6
- package/docs/guide/zh/pipeline/2-the-job-detail-view.md +2 -1
- package/docs/guide/zh/pipeline/3-batch-implement-and-multi-feature.md +1 -1
- package/docs/guide/zh/pipeline/4-picking-an-engine-per-rail.md +12 -12
- package/docs/guide/zh/pipeline/5-the-loop-builder.md +6 -2
- package/docs/guide/zh/specs/2-add-spec-quick-mode.md +6 -1
- package/docs/internals/README.md +4 -1
- package/docs/internals/adding-a-provider.md +32 -28
- package/docs/internals/api-reference.md +37 -13
- package/docs/internals/architecture.md +5 -5
- package/docs/internals/bundled-framework-build-plan.md +3 -3
- package/docs/internals/code-explorer-story.md +4 -0
- package/docs/internals/configuration.md +17 -5
- package/docs/internals/global-artifacts-alignment-contract.md +1 -1
- package/docs/internals/operations-runbook.md +1 -1
- package/docs/internals/profiles.md +37 -45
- package/docs/internals/project-builder.md +16 -0
- package/docs/kimi.md +291 -0
- package/docs/mcp.md +9 -2
- package/docs/platforms/macos.md +17 -7
- package/docs/platforms/windows.md +9 -4
- package/docs/running-pipelines.md +46 -12
- package/docs/terminal.md +1 -1
- package/docs/tracking-cost.md +25 -6
- package/package.json +4 -2
- package/server/dist/agent-chat-manager.js +74 -32
- package/server/dist/agent-chat-router.js +40 -17
- package/server/dist/agent-cwd-manager.js +14 -7
- package/server/dist/agent-generator.js +69 -85
- package/server/dist/agent-mcp-config.js +17 -11
- package/server/dist/agent-operator-prompt.js +29 -20
- package/server/dist/agent-refine-manager.js +58 -38
- package/server/dist/ai-invocations.js +65 -20
- package/server/dist/attachment-manager.js +49 -15
- package/server/dist/blueprint-chat-manager.js +41 -16
- package/server/dist/blueprint-router.js +40 -6
- package/server/dist/chat-manager.js +165 -89
- package/server/dist/code-explorer-router.js +26 -7
- package/server/dist/contract-refine-runner.js +146 -113
- package/server/dist/core-compat.js +57 -2
- package/server/dist/core-package.js +3 -3
- package/server/dist/core-update-manager.js +17 -1
- package/server/dist/db.js +60 -5
- package/server/dist/desktop-analytics.js +44 -6
- package/server/dist/desktop-router.js +127 -11
- package/server/dist/explore-cwd-manager.js +19 -3
- package/server/dist/feature-flags.js +1 -1
- package/server/dist/file-story-manager.js +3 -3
- package/server/dist/file-summary-generator.js +21 -15
- package/server/dist/file-summary-manager.js +6 -6
- package/server/dist/framework-manager.js +19 -2
- package/server/dist/framework-migration.js +27 -12
- package/server/dist/install-config-path.js +1 -1
- package/server/dist/interactive-job-session.js +8 -6
- package/server/dist/loop-command-catalog.js +27 -10
- package/server/dist/loop-executors.js +59 -27
- package/server/dist/loop-factory.js +2 -2
- package/server/dist/loop-run-manager.js +100 -39
- package/server/dist/loops-router.js +1 -1
- package/server/dist/mcp/guide.js +23 -16
- package/server/dist/mcp/tools/agents.js +47 -41
- package/server/dist/mcp/tools/analytics.js +2 -2
- package/server/dist/mcp/tools/loops.js +2 -2
- package/server/dist/mcp/tools/plugins.js +14 -9
- package/server/dist/mcp/tools/rails.js +12 -13
- package/server/dist/mcp/tools/support.js +1 -1
- package/server/dist/mobile/mobile-router.js +5 -1
- package/server/dist/offline-assemble.js +13 -1
- package/server/dist/path-resolver.js +2 -2
- package/server/dist/plugin-manager.js +391 -106
- package/server/dist/plugins/claude-md-mutation.js +5 -4
- package/server/dist/plugins/drift.js +32 -29
- package/server/dist/plugins/rail-integration.js +13 -2
- package/server/dist/plugins/serena/install.js +25 -17
- package/server/dist/plugins/serena/manifest.js +22 -5
- package/server/dist/plugins/serena/verify.js +46 -16
- package/server/dist/plugins-router.js +59 -8
- package/server/dist/profile-manager.js +148 -36
- package/server/dist/profiles-router.js +311 -82
- package/server/dist/project-registry.js +2 -2
- package/server/dist/project-router-chat.js +17 -8
- package/server/dist/project-router-helpers.js +93 -5
- package/server/dist/project-router-jobs.js +76 -12
- package/server/dist/project-router-loop-runs.js +42 -14
- package/server/dist/project-router-settings.js +31 -10
- package/server/dist/project-router-setup.js +4 -5
- package/server/dist/project-router-spending.js +15 -3
- package/server/dist/project-router-tickets.js +187 -181
- package/server/dist/project-router.js +1 -0
- package/server/dist/proposal-manager.js +125 -85
- package/server/dist/providers/claude-adapter.js +14 -0
- package/server/dist/providers/codex-adapter.js +20 -0
- package/server/dist/providers/gemini-adapter.js +14 -0
- package/server/dist/providers/index.js +18 -1
- package/server/dist/providers/kimi-adapter.js +361 -0
- package/server/dist/providers/kimi-skill-prompt.js +332 -0
- package/server/dist/providers/runtime.js +137 -0
- package/server/dist/queue-manager.js +103 -78
- package/server/dist/rail-isolated-launch.js +1 -1
- package/server/dist/rails-router.js +51 -38
- package/server/dist/result-event.js +5 -0
- package/server/dist/schemas/profile.v1.json +3 -4
- package/server/dist/setup-manager.js +222 -101
- package/server/dist/setup-prerequisites.js +7 -1
- package/server/dist/smash-runner.js +104 -57
- package/server/dist/spawn-lifecycle.js +18 -14
- package/server/dist/spec-launcher-manager.js +66 -54
- package/server/dist/spec-models.js +15 -6
- package/server/dist/spending.js +110 -17
- package/server/dist/util/cli-prompt.js +142 -5
- package/server/dist/util/stream-display.js +46 -0
- package/server/dist/workspace-manager.js +100 -37
- package/server/dist/worktree-manager.js +4 -0
- package/server/dist/worktree-overlay.js +12 -3
- package/client/dist/assets/AgentModeCodePane-BAYyFRmY.js +0 -2
- package/client/dist/assets/AgentsPage-DuyJuaFs.js +0 -86
- package/client/dist/assets/AnalyticsPage-BY7gtCx6.js +0 -1
- package/client/dist/assets/CodePage-vyQr40Vl.js +0 -2
- package/client/dist/assets/JobDetailPage-CU4FEnUC.js +0 -1
- package/client/dist/assets/LoopsPage-SqglnXlp.js +0 -1
- package/client/dist/assets/PluginsPage-B89S8o1a.js +0 -2
- package/client/dist/assets/TicketDetailModal-CI47Dq9E.js +0 -14
- package/client/dist/assets/addspec-BXjvkh5q.js +0 -1
- package/client/dist/assets/addspec-C4bwrmpi.js +0 -1
- package/client/dist/assets/addspec-CArHXUDM.js +0 -1
- package/client/dist/assets/addspec-DTKJcXiR.js +0 -1
- package/client/dist/assets/addspec-DbNBbrha.js +0 -1
- package/client/dist/assets/addspec-Rw8uVBC1.js +0 -1
- package/client/dist/assets/addspec-htHGZHOe.js +0 -1
- package/client/dist/assets/addspec-lr_LP6jk.js +0 -1
- package/client/dist/assets/agent-BABjRt0P.js +0 -1
- package/client/dist/assets/agent-BuUpgqVx.js +0 -1
- package/client/dist/assets/agent-CCDZesgU.js +0 -1
- package/client/dist/assets/agent-CVn64zWH.js +0 -1
- package/client/dist/assets/agent-CWeOny0E.js +0 -1
- package/client/dist/assets/agent-DOysmad_.js +0 -1
- package/client/dist/assets/agent-DSsjTBhn.js +0 -1
- package/client/dist/assets/agent-DlZMxfM9.js +0 -1
- package/client/dist/assets/agents-6ZOJXWVk.js +0 -1
- package/client/dist/assets/agents-BZ0XQKjg.js +0 -1
- package/client/dist/assets/agents-BqWklnHR.js +0 -1
- package/client/dist/assets/agents-Bz-thHkB.js +0 -1
- package/client/dist/assets/agents-CJclElx6.js +0 -1
- package/client/dist/assets/agents-D_l9L0VA.js +0 -1
- package/client/dist/assets/agents-DhG7mg6-.js +0 -1
- package/client/dist/assets/agents-u_C0jPB5.js +0 -1
- package/client/dist/assets/agentstudio-BF19hbXj.js +0 -1
- package/client/dist/assets/agentstudio-BIUe1Im2.js +0 -1
- package/client/dist/assets/agentstudio-BLGvxWBx.js +0 -1
- package/client/dist/assets/agentstudio-D9UKiWTj.js +0 -1
- package/client/dist/assets/agentstudio-Drs37nIM.js +0 -1
- package/client/dist/assets/agentstudio-nEnKkcXM.js +0 -1
- package/client/dist/assets/agentstudio-pyFcSBKy.js +0 -1
- package/client/dist/assets/agentstudio-zfTzQh3U.js +0 -1
- package/client/dist/assets/analytics-BC7mwR4s.js +0 -1
- package/client/dist/assets/analytics-BiNg8edP.js +0 -1
- package/client/dist/assets/analytics-C0s_T2GN.js +0 -1
- package/client/dist/assets/analytics-CdsAPAwZ.js +0 -1
- package/client/dist/assets/analytics-Cr1_q-lC.js +0 -1
- package/client/dist/assets/analytics-DZ8Aoq3I.js +0 -1
- package/client/dist/assets/analytics-IEsKZvpW.js +0 -1
- package/client/dist/assets/analytics-SRPf84OT.js +0 -1
- package/client/dist/assets/builder-BH8Fua-g.js +0 -1
- package/client/dist/assets/builder-BoV7DgKd.js +0 -1
- package/client/dist/assets/builder-Cc_Lf79C.js +0 -1
- package/client/dist/assets/builder-CwZ7Bme2.js +0 -1
- package/client/dist/assets/builder-CxW-JFsR.js +0 -1
- package/client/dist/assets/builder-D94lrV7x.js +0 -1
- package/client/dist/assets/builder-cqHpCyGa.js +0 -1
- package/client/dist/assets/code-76gS0IdL.js +0 -1
- package/client/dist/assets/code-BDXEM4ml.js +0 -1
- package/client/dist/assets/code-C1VwxlML.js +0 -1
- package/client/dist/assets/code-CnMZyJpr.js +0 -1
- package/client/dist/assets/code-D20ef9Cf.js +0 -1
- package/client/dist/assets/code-DdOXaWRY.js +0 -1
- package/client/dist/assets/code-Duohuf9l.js +0 -1
- package/client/dist/assets/code-geHmknB9.js +0 -1
- package/client/dist/assets/format-command-Dfa1o2d-.js +0 -1
- package/client/dist/assets/index-Dh9i4CnN.css +0 -2
- package/client/dist/assets/index-F9r8mWP_.js +0 -76
- package/client/dist/assets/jobs-BCtGfgUA.js +0 -1
- package/client/dist/assets/jobs-BHR_EnDI.js +0 -1
- package/client/dist/assets/jobs-BMbZJjJJ.js +0 -1
- package/client/dist/assets/jobs-DzSIR8V6.js +0 -1
- package/client/dist/assets/nav-BRJBxaGt.js +0 -1
- package/client/dist/assets/nav-CAGKv3_F.js +0 -1
- package/client/dist/assets/nav-CNskRJKQ.js +0 -1
- package/client/dist/assets/nav-DY93irBL.js +0 -1
- package/client/dist/assets/nav-DhjvYgqt.js +0 -1
- package/client/dist/assets/nav-Gb-r4wop.js +0 -1
- package/client/dist/assets/nav-TvumAFD2.js +0 -1
- package/client/dist/assets/nav-myFaXRHD.js +0 -1
- package/client/dist/assets/settings-B0ypw9uw.js +0 -1
- package/client/dist/assets/settings-B9ilOSYO.js +0 -1
- package/client/dist/assets/settings-BqlWHRHA.js +0 -1
- package/client/dist/assets/settings-D8dlqt4d.js +0 -1
- package/client/dist/assets/settings-DAZqjX2a.js +0 -1
- package/client/dist/assets/settings-DRh39v1S.js +0 -1
- package/client/dist/assets/settings-Mj1OJbfd.js +0 -1
- package/client/dist/assets/settings-lRReaSYm.js +0 -1
- package/client/dist/assets/setup-3832BJCo.js +0 -1
- package/client/dist/assets/setup-B8J-gECe.js +0 -1
- package/client/dist/assets/setup-BCIOxVsc.js +0 -1
- package/client/dist/assets/setup-BciLj_tU.js +0 -1
- package/client/dist/assets/setup-CTkE3cfh.js +0 -1
- package/client/dist/assets/setup-ajB4rYm-.js +0 -1
- package/client/dist/assets/setup-xFO1wNl0.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor.main-DxrmGfoq.js","assets/rolldown-runtime-CNC7AqOf.js","assets/preload-helper-Czpn1I53.js","assets/editor.api2-4ndOupAA.js","assets/editor-Br_kD0ds.css","assets/monaco.contribution-Bt92R3Vw.js","assets/workers-uOo7WLaa.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{d as a,l as o}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{n as s,t as c}from"./createLucideIcon-Bjbbp_KS.js";import{n as l}from"./dist-bVqfYmby.js";import{m as u}from"./useBrowserCaptureSession-CkBJShUw.js";import{c as d,l as f}from"./MinimizedChatsContext-Cs34FPTz.js";import{t as p}from"./external-link-BcU5EWZp.js";import{t as m}from"./chevron-right-CViMxucY.js";import{L as h,R as g,o as _,z as v}from"./TicketDetailModal-CI47Dq9E.js";import{t as y}from"./file-text-CFT-xXKN.js";import{t as b}from"./sparkles-DrY8hb0X.js";import{t as x}from"./x-CBMI9ejn.js";import{n as S}from"./useSharedWebSocket-DaPh7QBL.js";import{t as C}from"./api-B2M7CtDw.js";import{i as w,r as ee}from"./useDesktop-B4pSBIDd.js";import{t as T}from"./utils-BC4DHlz2.js";import{c as te,s as E}from"./dialog-CzIekCw0.js";import{n as D,t as O}from"./lib-CGdyxIWg.js";import{St as k,b as A,wt as j,xt as M}from"./index-F9r8mWP_.js";var N=c(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),P=e(t(),1),F=e(r(),1);function I(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function L(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function ne(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var re=(e,t)=>Math.abs(e-t)<1.01,ie=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},R,z=()=>{if(R!==void 0)return R;if(typeof navigator>`u`)return R=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return R=!0;let e=navigator.maxTouchPoints;return R=navigator.platform===`MacIntel`&&e!==void 0&&e>0},B=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},V=e=>e,H=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},ae=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(B(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(B(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},U={passive:!0},W=typeof window>`u`||`onscrollend`in window,G=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&W,o=0,s=a?null:ie(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,U),a&&r.addEventListener(`scrollend`,u,U),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},K=(e,t)=>G(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),q=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},J=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},oe=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:V,rangeExtractor:H,onChange:()=>{},measureElement:q,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}this.options=t},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=L(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!z()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,U),e.addEventListener(`touchend`,n,U),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=L(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=L(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=I(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=L(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?se({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=L(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);o!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this))&&(z()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0})),(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,this.notify(!1))},this.getVirtualItems=L(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return ne(t[Y(0,t.length-1,r?e=>n[e*2]:e=>ne(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&re(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Y=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function se({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=Y(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var ce=typeof document<`u`?P.useLayoutEffect:P.useEffect;function le({useFlushSync:e=!0,...t}){let n=P.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,F.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=P.useState(()=>new oe(r));return i.setOptions(r),ce(()=>i._didMount(),[]),ce(()=>i._willUpdate()),i}function ue(e){return le({observeElementRect:ae,observeElementOffset:K,scrollToFn:J,...e})}var X=n(),Z=e=>`specrails-desktop:code-tree-filter:${e}`,de=e=>`specrails-desktop:code-tree-collapsed:${e}`;function fe(e){return e.split(`/`).length-1}function pe(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function me(e){return e?e.length>10?e.slice(0,10):e:null}function he(e){return e===`created`?`added`:e===`modified`?`changed`:e===`deleted`?`deleted`:null}function ge(e,t){if(t.size===0)return!1;let n=e.split(`/`);for(let e=1;e<n.length;e++)if(t.has(n.slice(0,e).join(`/`)))return!0;return!1}function _e({onOpenFile:e,selectedPath:t,filterJobId:n,filterTicketId:r}){let{t:i}=s(`code`),{activeProjectId:a}=ee(),{openTicketDetail:o}=_(),{registerHandler:c,unregisterHandler:l}=S(),[u,d]=(0,P.useState)(()=>{if(!a)return`touched-by-ai`;try{let e=localStorage.getItem(Z(a));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`touched-by-ai`});(0,P.useEffect)(()=>{if(a)try{localStorage.setItem(Z(a),u)}catch{}},[u,a]);let[p,g]=(0,P.useState)(()=>{if(!a)return new Set;try{let e=localStorage.getItem(de(a));if(!e)return new Set;let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>typeof e==`string`))}catch{}return new Set});(0,P.useEffect)(()=>{if(a)try{localStorage.setItem(de(a),JSON.stringify([...p]))}catch{}},[p,a]);let v=(0,P.useCallback)(e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),y=(0,P.useCallback)(()=>{g(new Set)},[]),{data:b,refresh:x,isFirstLoad:te}=w({namespace:`code-tree:${u}:${u===`touched-by-ai`?`${n??`all-jobs`}:${r??`all-specs`}`:`all`}`,projectId:a,initialValue:[],fetcher:(0,P.useCallback)(async()=>{let e=[],t=null;for(let i=0;i<100;i+=1){let i=new URLSearchParams({withProvenance:`1`,filter:u});u===`touched-by-ai`&&n&&i.set(`jobId`,n),u===`touched-by-ai`&&typeof r==`number`&&i.set(`ticketId`,String(r)),t&&i.set(`cursor`,t);let a=await fetch(`${C()}/code/tree?${i.toString()}`);if(!a.ok)break;let o=await a.json().catch(()=>({}));if(Array.isArray(o.entries)&&e.push(...o.entries),!o.nextCursor)break;t=o.nextCursor}return e},[u,n,r])}),E=(0,P.useRef)(a);(0,P.useEffect)(()=>{E.current=a},[a]),(0,P.useEffect)(()=>{if(!a)return;let e=`code-tree-${a}`;return c(e,e=>{let t=e;t.projectId===E.current&&t.type===`file.provenance_updated`&&x()}),()=>l(e)},[a,c,l,x]);let D=(0,P.useRef)(null),O=(0,P.useMemo)(()=>(b??[]).filter(e=>!ge(e.path,p)),[b,p]),A=(0,P.useCallback)(()=>{g(new Set((b??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[b]),N=ue({count:O.length,getScrollElement:()=>D.current,estimateSize:()=>28,overscan:12,initialRect:{width:320,height:600},observeElementRect:(e,t)=>{let n=e.scrollElement;if(!n)return()=>{};let r=()=>{let e=n.getBoundingClientRect(),r=e.height||n.clientHeight||600;t({width:e.width||n.clientWidth||320,height:r})};if(r(),typeof ResizeObserver<`u`){let e=new ResizeObserver(r);return e.observe(n),()=>e.disconnect()}return()=>{}}}),F=O.length===0,I=(0,P.useMemo)(()=>(b??[]).filter(e=>e.kind===`file`).length,[b]);return(0,X.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`file-tree`,children:[(0,X.jsxs)(`div`,{className:`px-2 py-2 border-b border-border text-xs space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>d(`touched-by-ai`),className:T(`px-2 py-1 rounded-md transition-colors`,u===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":u===`touched-by-ai`,children:i(n?`tree.jobFiles`:r?`tree.specFiles`:`tree.touchedByAi`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>d(`all`),className:T(`px-2 py-1 rounded-md transition-colors`,u===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":u===`all`,children:i(`tree.allFiles`)}),(0,X.jsx)(`div`,{className:`flex-1`}),(0,X.jsx)(`button`,{type:`button`,onClick:A,title:i(`tree.collapseAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":i(`tree.collapseAll`),children:(0,X.jsx)(m,{className:`w-3.5 h-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:y,title:i(`tree.expandAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":i(`tree.expandAll`),children:(0,X.jsx)(f,{className:`w-3.5 h-3.5`})})]}),u===`touched-by-ai`&&I>0&&(0,X.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,X.jsx)(`span`,{children:i(`tree.touchedCount`,{count:I})})})]}),F&&te?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center px-4 text-center`,"data-testid":`file-tree-loading`,children:(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground animate-pulse`,children:i(`tree.loadingFiles`)})}):F&&u===`touched-by-ai`?(0,X.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-4 text-center gap-3`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`tree.emptyTouched`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>d(`all`),className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30`,children:i(`tree.showAllFiles`)})]}):F?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:i(`tree.noFiles`)}):(0,X.jsx)(`div`,{ref:D,className:`flex-1 overflow-auto`,"data-testid":`file-tree-scroller`,children:(0,X.jsx)(`div`,{style:{height:N.getTotalSize(),position:`relative`,width:`100%`},children:N.getVirtualItems().map(n=>{let r=O[n.index],a=fe(r.path)*12,s=r.kind===`file`&&r.path===t,c=r.provenance?.createdByTicketId,l=r.provenance?.modifiedByTicketIds??[],u=r.provenance?.latest??null,d=me(u?.jobId),g=he(u?.kind),_=r.kind===`dir`,y=_&&p.has(r.path),b=r.provenance?.touchedFileCount??0;return(0,X.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateY(${n.start}px)`,height:n.size,width:`100%`},className:T(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,s&&`bg-muted text-foreground`),onClick:()=>{_?v(r.path):e(r.path)},onKeyDown:t=>{t.target===t.currentTarget&&(t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),_?v(r.path):e(r.path)))},role:`button`,tabIndex:0,"aria-expanded":_?!y:void 0,"data-testid":`file-tree-row-${r.path}`,children:[(0,X.jsxs)(`span`,{style:{paddingLeft:a},className:`flex items-center gap-1 min-w-0 flex-1`,children:[_?(0,X.jsxs)(X.Fragment,{children:[y?(0,X.jsx)(m,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,X.jsx)(f,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),y?(0,X.jsx)(M,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,X.jsx)(k,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`w-3 flex-shrink-0`}),(0,X.jsx)(j,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,X.jsx)(`span`,{className:`truncate ml-0.5`,children:pe(r.path)})]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[_&&b>0&&(0,X.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground`,title:i(`tree.folderTouched`,{count:b}),children:b}),!_&&g&&(0,X.jsx)(`span`,{className:T(`text-[10px] px-1.5 py-0.5 rounded`,u?.kind===`created`&&`bg-accent-success/15 text-accent-success`,u?.kind===`modified`&&`bg-accent-info/15 text-accent-info`,u?.kind===`deleted`&&`bg-destructive/15 text-destructive`),title:u?.kind===`created`?i(`tree.latestTitleCreated`):u?.kind===`deleted`?i(`tree.latestTitleDeleted`):i(`tree.latestTitleModified`),children:i(`action.${g}`)}),!_&&d&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground font-mono`,title:i(`tree.jobTitle`,{jobId:u?.jobId??``}),children:[(0,X.jsx)(h,{className:`h-3 w-3`}),d]}),!_&&typeof c==`number`&&(0,X.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o(c)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,"data-testid":`provenance-chip-created-${c}`,title:i(`tree.createdBySpec`,{id:c}),children:[`#`,c]}),!_&&l.slice(0,2).map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),o(e)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,"data-testid":`provenance-chip-modified-${e}`,title:i(`tree.modifiedBySpec`,{id:e}),children:[`#`,e]},e))]})]},r.path)})})})]})}function ve(e){return new Worker(`/assets/editor.worker-tytyn86m.js`,{name:e?.name})}function ye(e){return new Worker(`/assets/json.worker-Oa9UrkKE.js`,{name:e?.name})}function be(e){return new Worker(`/assets/css.worker-yKcq13f2.js`,{name:e?.name})}function xe(e){return new Worker(`/assets/html.worker-DSJ9zmd7.js`,{name:e?.name})}function Se(e){return new Worker(`/assets/ts.worker-BtjBFNHX.js`,{name:e?.name})}var Ce=!1;function we(e){let t=e.trim().match(/^hsl\(\s*([-\d.]+)[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*\)$/i);return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}function Q(e,t=`#1e1e1e`){if(e.startsWith(`#`))return e;let n=we(e);if(!n)return t;let[r,i,a]=n,o=i/100,s=a/100,c=(1-Math.abs(2*s-1))*o,l=(r%360+360)%360/60,u=c*(1-Math.abs(l%2-1)),d=0,f=0,p=0;l<1?(d=c,f=u):l<2?(d=u,f=c):l<3?(f=c,p=u):l<4?(f=u,p=c):l<5?(d=u,p=c):(d=c,p=u);let m=s-c/2,h=e=>Math.round((e+m)*255).toString(16).padStart(2,`0`);return`#${h(d)}${h(f)}${h(p)}`}function Te(e){return`specrails-${e}`}function Ee(e,t){let n=Te(t.id),r=t.xterm,i=Q(r.background),a=Q(r.foreground),o=Q(r.brightBlack),s=Q(r.magenta),c=Q(r.yellow),l=Q(r.cyan),u=Q(r.blue),d=Q(r.green),f=Q(r.brightBlack),p=Q(r.brightCyan),m=Q(r.red),h=Q(r.selectionBackground);return e.editor.defineTheme(n,{base:t.scheme===`light`?`vs`:`vs-dark`,inherit:!0,rules:[{token:``,foreground:a.slice(1)},{token:`comment`,foreground:f.slice(1),fontStyle:`italic`},{token:`keyword`,foreground:s.slice(1)},{token:`string`,foreground:c.slice(1)},{token:`number`,foreground:l.slice(1)},{token:`constant`,foreground:p.slice(1)},{token:`constant.numeric`,foreground:l.slice(1)},{token:`type`,foreground:d.slice(1)},{token:`type.identifier`,foreground:d.slice(1)},{token:`identifier`,foreground:a.slice(1)},{token:`function`,foreground:u.slice(1)},{token:`tag`,foreground:m.slice(1)},{token:`attribute.name`,foreground:p.slice(1)},{token:`attribute.value`,foreground:c.slice(1)},{token:`delimiter`,foreground:o.slice(1)},{token:`operator`,foreground:o.slice(1)}],colors:{"editor.background":i,"editor.foreground":a,"editorLineNumber.foreground":o,"editorLineNumber.activeForeground":a,"editorCursor.foreground":Q(r.cursor),"editor.selectionBackground":h,"editor.inactiveSelectionBackground":h,"editor.lineHighlightBackground":Q(r.black),"editor.lineHighlightBorder":Q(r.black),"editorGutter.background":i,"editorWhitespace.foreground":o,"editorIndentGuide.background1":Q(r.black),"editorIndentGuide.activeBackground1":o,"scrollbarSlider.background":`${o}55`,"scrollbarSlider.hoverBackground":`${o}88`,"scrollbarSlider.activeBackground":`${o}bb`,"minimap.background":i}}),n}function De(){Ce||=(self.MonacoEnvironment={getWorker(e,t){switch(t){case`json`:return new ye;case`css`:case`scss`:case`less`:return new be;case`html`:case`handlebars`:case`razor`:return new xe;case`typescript`:case`javascript`:return new Se;default:return new ve}}},!0)}function Oe({content:e,language:t,readOnly:n,onChange:r}){let{t:a}=s(`code`),o=A(),c=(0,P.useRef)(null),l=(0,P.useRef)(null),u=(0,P.useRef)(null),[d,f]=(0,P.useState)(!1),p=(0,P.useRef)(e),m=(0,P.useRef)(t),h=(0,P.useRef)(o),g=(0,P.useRef)(n),_=(0,P.useRef)(r);return(0,P.useEffect)(()=>{p.current=e},[e]),(0,P.useEffect)(()=>{m.current=t},[t]),(0,P.useEffect)(()=>{h.current=o},[o]),(0,P.useEffect)(()=>{g.current=n},[n]),(0,P.useEffect)(()=>{_.current=r},[r]),(0,P.useEffect)(()=>{let e=!1;return De(),i(()=>import(`./editor.main-DxrmGfoq.js`).then(t=>{if(e||!c.current)return;u.current=t;let n=Ee(t,h.current),r=t.editor.create(c.current,{value:p.current,language:m.current,readOnly:g.current,theme:n,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,fontSize:13});r.onDidChangeModelContent(()=>{_.current?.(r.getValue())}),l.current=r}),__vite__mapDeps([0,1,2,3,4,5,6])).catch(()=>{e||f(!0)}),()=>{e=!0,l.current?.dispose?.(),l.current=null}},[]),(0,P.useEffect)(()=>{let t=l.current;t&&t.getValue?.()!==e&&t.setValue?.(e)},[e]),(0,P.useEffect)(()=>{l.current?.updateOptions?.({readOnly:n})},[n]),(0,P.useEffect)(()=>{let e=u.current,n=l.current;if(!e||!n)return;let r=n.getModel?.();r&&e.editor.setModelLanguage(r,t)},[t]),(0,P.useEffect)(()=>{let e=u.current;if(!e)return;let t=Ee(e,o);e.editor.setTheme(t)},[o]),d?(0,X.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center gap-2 text-sm text-muted-foreground`,"data-testid":`monaco-load-error`,children:[(0,X.jsx)(`span`,{children:a(`monaco.loadFailed`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`rounded-md bg-accent-primary/15 px-3 py-1 text-xs text-accent-primary hover:bg-accent-primary/25`,children:a(`monaco.reload`)})]}):(0,X.jsx)(`div`,{ref:c,className:`w-full h-full`,"data-testid":`monaco-host`})}var ke=(0,P.lazy)(async()=>({default:Oe}));function Ae({content:e,language:t,readOnly:n=!0,onChange:r}){let{t:i}=s(`code`);return(0,X.jsx)(P.Suspense,{fallback:(0,X.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:i(`monaco.loadingEditor`)}),children:(0,X.jsx)(ke,{content:e,language:t,readOnly:n,onChange:r})})}function je(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=Math.round((n-Date.now())/1e3),i=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),a=Math.abs(r);return a<60?i.format(r,`second`):a<3600?i.format(Math.round(r/60),`minute`):a<86400?i.format(Math.round(r/3600),`hour`):i.format(Math.round(r/86400),`day`)}function Me({path:e,summary:t,stale:n,regenerating:r,generateDisabledReason:i,onCollapse:a}){let{t:o,i18n:c}=s(`code`),{openTicketDetail:l}=_();if(!t)return(0,X.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header-empty`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?o(`summary.unavailable`,{reason:i}):o(`summary.empty`)})]}),a&&(0,X.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(d,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})});let u=je(t.generatedAt,c.language),f=t.triggeredBy?.ticketId,p=t.triggeredBy?.modifiedTicketIds??[];return(0,X.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),n&&(0,X.jsx)(`span`,{className:T(`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning font-medium`),"data-testid":`summary-stale-badge`,children:o(`summary.stale`)}),r&&(0,X.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent-primary animate-pulse`,"aria-hidden":!0})]}),(0,X.jsx)(`p`,{className:`text-sm text-foreground mt-1`,children:t.summary}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 flex-wrap`,children:[typeof f==`number`&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>l(f),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,f]}),p.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>l(e),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,children:[`#`,e]},e)),u&&(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:u})]})]}),a&&(0,X.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(d,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})})}function Ne({content:e}){return(0,X.jsx)(D,{remarkPlugins:[O],children:e})}var Pe={done:`bg-accent-success/15 text-accent-success`,in_progress:`bg-accent-info/15 text-accent-info`,on_review:`bg-accent-warning/15 text-accent-warning`,todo:`bg-muted/60 text-muted-foreground`,draft:`bg-accent-secondary/15 text-accent-secondary`};function Fe(e){return e===`created`?g:e===`deleted`?v:y}function Ie({relPath:e,height:t,onOpenTicket:n,onFilterJob:r}){let{t:i}=s(`code`),{activeProjectId:a}=ee(),{registerHandler:o,unregisterHandler:c}=S(),[u,d]=(0,P.useState)(null),[f,p]=(0,P.useState)(!1),[m,h]=(0,P.useState)({}),g=(0,P.useRef)(a);(0,P.useEffect)(()=>{g.current=a},[a]);let _=(0,P.useRef)(e);(0,P.useEffect)(()=>{_.current=e},[e]);let v=(0,P.useRef)(0),y=(0,P.useCallback)(async()=>{let t=++v.current;try{let n=await fetch(`${C()}/code/file/story?path=${encodeURIComponent(e)}`);if(t!==v.current)return;if(!n.ok){d([]),p(!0);return}let r=await n.json();if(t!==v.current)return;d(Array.isArray(r.story)?r.story:[]),p(!1)}catch{t===v.current&&(d([]),p(!0))}},[e,a]);(0,P.useEffect)(()=>{d(null),h({}),y()},[y]),(0,P.useEffect)(()=>{if(!a)return;let e=`code-story-${a}`;return o(e,e=>{let t=e;t.projectId===g.current&&t.path===_.current&&(t.type===`file.story_updated`||t.type===`file.provenance_updated`)&&y()}),()=>c(e)},[a,o,c,y]);let b=(0,P.useCallback)(async(t,n)=>{h(e=>({...e,[t.provenanceId]:`busy`}));try{let r=await fetch(`${C()}/code/file/story/explain?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provenanceId:t.provenanceId,overrideBudget:n})}),a=await r.json().catch(()=>({}));if(a.skipped===`budget`){h(e=>({...e,[t.provenanceId]:`budget`}));return}if(!r.ok||!a.ok){l.error(i(`story.explainFailed`)),h(e=>{let n={...e};return delete n[t.provenanceId],n});return}await y(),h(e=>{let n={...e};return delete n[t.provenanceId],n})}catch{l.error(i(`story.explainFailed`)),h(e=>{let n={...e};return delete n[t.provenanceId],n})}},[y,e,i]);return(0,X.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:t},"data-testid":`construction-story`,children:(0,X.jsx)(`div`,{className:`h-full overflow-auto`,children:u===null?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground animate-pulse py-2`,children:i(`story.loading`)}):f?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-failed`,children:i(`story.loadFailed`)}):u.length===0?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-empty`,children:i(`story.empty`)}):(0,X.jsx)(`ol`,{className:`relative ml-1.5 border-l border-border/60 space-y-3 py-1`,children:u.map(e=>(0,X.jsx)(Le,{entry:e,state:m[e.provenanceId],onOpenTicket:n,onFilterJob:r,onExplain:t=>{b(e,t)}},e.provenanceId))})})})}function Le({entry:e,state:t,onOpenTicket:n,onFilterJob:r,onExplain:i}){let{t:a}=s(`code`),o=Fe(e.kind),c=e.ticket?.status??null,l=e.ticket?.title?`#${e.ticket.id} · ${e.ticket.title}`:e.ticketId==null?null:a(`story.spec`,{ticketId:e.ticketId}),u=e.ticketId==null?`${e.kind}NoSpec`:e.kind;return(0,X.jsxs)(`li`,{className:`relative pl-4`,"data-testid":`story-card`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`absolute -left-[5px] top-2 h-2.5 w-2.5 rounded-full border-2 border-background ${e.kind===`created`?`bg-accent-success`:e.kind===`deleted`?`bg-destructive`:`bg-accent-info`}`}),(0,X.jsxs)(`article`,{className:`rounded-lg border border-border/60 bg-card/60 px-3 py-2.5 backdrop-blur-sm transition-colors hover:border-border`,children:[(0,X.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(o,{className:`h-3.5 w-3.5 shrink-0`}),a(`story.kindLabel.${e.kind}`)]}),l!=null&&e.ticketId!=null&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>n(e.ticketId),className:`min-w-0 max-w-full truncate rounded bg-accent-primary/15 px-1.5 py-0.5 text-left text-[11px] font-medium text-accent-primary hover:bg-accent-primary/25`,title:a(`story.openSpec`,{ticketId:e.ticketId}),children:l}),l==null&&(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:a(`story.unknownSpec`)}),c&&(0,X.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] ${Pe[c]??`bg-muted/60 text-muted-foreground`}`,"data-testid":`story-status-pill`,children:c}),(0,X.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-2`,children:[e.addedLines!=null&&e.addedLines>0&&(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-accent-success`,title:a(`story.linesAdded`),children:[`+`,e.addedLines]}),e.removedLines!=null&&e.removedLines>0&&(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-destructive`,title:a(`story.linesRemoved`),children:[`−`,e.removedLines]}),(0,X.jsx)(`time`,{className:`text-[10px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]})]}),(0,X.jsx)(`div`,{className:`mt-1.5`,children:e.summary?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-foreground/90`,"data-testid":`story-contribution`,children:e.summary}),e.summaryModel&&(0,X.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/80`,children:a(`story.explainedBy`,{model:e.summaryModel})})]}):(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`story-fallback`,children:a(`story.fallback.${u}`)}),t===`budget`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[10px] text-accent-warning`,children:a(`story.budgetReached`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`rounded bg-accent-warning/15 px-1.5 py-0.5 text-[10px] text-accent-warning hover:bg-accent-warning/25`,children:a(`story.generateAnyway`)})]}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),disabled:t===`busy`,className:`inline-flex items-center gap-1 rounded bg-accent-primary/10 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/20 disabled:opacity-60`,"data-testid":`story-explain`,children:[(0,X.jsx)(b,{className:t===`busy`?`h-3 w-3 animate-pulse`:`h-3 w-3`}),a(t===`busy`?`story.explaining`:`story.explain`)]})]})}),e.jobId&&r&&(0,X.jsx)(`footer`,{className:`mt-1.5`,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(e.jobId),className:`font-mono text-[10px] text-muted-foreground hover:text-foreground`,title:a(`history.filterByJob`,{jobId:e.jobId}),children:e.jobId.length>12?e.jobId.slice(0,12):e.jobId})})]})]})}function Re(e,t){return t===`markdown`||t===`md`||/\.(md|mdx|markdown)$/i.test(e)}var ze=180,Be=120,Ve=240;function He(e){return e?`specrails-desktop:code-summary-collapsed:${e}`:null}function Ue(e){return e?`specrails-desktop:code-history-height:${e}`:null}function We(e){return e?`specrails-desktop:code-history-collapsed:${e}`:null}function Ge(e){return e?`specrails-desktop:code-history-mode:${e}`:null}function Ke(e){let t=Ge(e);if(!t)return`story`;try{return localStorage.getItem(t)===`log`?`log`:`story`}catch{return`story`}}function qe(e,t){let n=Ge(e);if(n)try{localStorage.setItem(n,t)}catch{}}function Je(e){let t=Ue(e);if(!t)return ze;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:ze}catch{return ze}}function Ye(e,t){let n=Ue(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function Xe(e){let t=He(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function Ze(e,t){let n=He(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function Qe(e){let t=We(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function $e(e,t){let n=We(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function et(e,t){let n=Math.max(Be,t-Ve);return Math.min(Math.max(e,Be),n)}function tt({relPath:e,onFilterJob:t,onSummaryActionChange:n,onCopyPathActionChange:r}){let{t:i}=s(`code`),{activeProjectId:a}=ee(),{openTicketDetail:o}=_(),{registerHandler:c,unregisterHandler:u}=S(),p=te({allowMove:!1}),m=(0,P.useRef)(null),[h,g]=(0,P.useState)(null),[v,y]=(0,P.useState)(!0),[b,x]=(0,P.useState)(!1),[w,T]=(0,P.useState)(!1),[D,O]=(0,P.useState)(()=>Xe(a)),[k,A]=(0,P.useState)(()=>Je(a)),[j,M]=(0,P.useState)(()=>Qe(a)),[N,F]=(0,P.useState)(()=>Ke(a)),I=(0,P.useRef)(a);(0,P.useEffect)(()=>{I.current=a},[a]);let L=(0,P.useRef)(e);(0,P.useEffect)(()=>{L.current=e},[e]),(0,P.useEffect)(()=>{let e=m.current?.clientHeight||window.innerHeight;O(Xe(a)),A(et(Je(a),e)),M(Qe(a)),F(Ke(a))},[a]);let ne=(0,P.useCallback)(e=>{let t=e.clientY,n=k,r=m.current?.clientHeight||window.innerHeight,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function o(e){A(et(n+(t-e.clientY),r))}function s(){window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),A(e=>{let t=et(e,r);return Ye(a,t),t})}window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[a,k]),re=(0,P.useCallback)(()=>{let e=et(ze,m.current?.clientHeight||window.innerHeight);A(e),Ye(a,e)},[a]),ie=(0,P.useCallback)(()=>{O(e=>{let t=!e;return Ze(a,t),t})},[a]),R=(0,P.useCallback)(()=>{M(e=>{let t=!e;return $e(a,t),t})},[a]),z=(0,P.useCallback)(e=>{F(e),qe(a,e)},[a]);(0,P.useEffect)(()=>{x(!1),T(!1),G(`preview`),q(!1)},[e]);let B=(0,P.useRef)(0),V=(0,P.useCallback)(async()=>{let t=++B.current;y(!0);try{let n=await fetch(`${C()}/code/file?path=${encodeURIComponent(e)}`);if(t!==B.current)return;if(!n.ok){g(null);return}let r=await n.json();if(t!==B.current)return;g(r)}catch{t===B.current&&g(null)}finally{t===B.current&&y(!1)}},[e,a]);(0,P.useEffect)(()=>{V()},[V]),(0,P.useEffect)(()=>{if(!a)return;let e=`code-file-${a}`;return c(e,e=>{let t=e;t.projectId===I.current&&(t.type===`file.summary_updated`&&t.path===L.current?(x(!1),V()):t.type===`file.summary_failed`&&t.path===L.current?(l.error(t.reason??i(`summary.generationFailed`)),x(!1)):t.type===`file.summary_skipped`&&t.path===L.current&&(t.reason&&l(i(`summary.skipped`,{reason:t.reason})),x(!1)))}),()=>u(e)},[a,c,u,V,i]);let H=(0,P.useCallback)(async t=>{x(!0);try{let n=await fetch(`${C()}/code/file/regenerate-summary?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({overrideBudget:t})}),r=await n.json().catch(()=>({}));if(!n.ok){x(!1);let e=typeof r.skipped==`string`?r.skipped:null;l.error(e?i(`summary.skipped`,{reason:e}):i(`summary.generationFailed`));return}if(r.skipped===`budget`){x(!1),T(!0);return}if(r.skipped){x(!1),l(i(`summary.skipped`,{reason:r.skipped}));return}await V(),x(!1)}catch{x(!1),l.error(i(`summary.generationFailed`))}},[V,e,i]),ae=(0,P.useCallback)(async()=>{let t=h?.absolutePath??e;try{await navigator.clipboard?.writeText(t),l.success(i(`viewer.pathCopied`))}catch{l.error(i(`viewer.copyPathFailed`))}},[h,e,i]),U=(0,P.useMemo)(()=>Re(e,h?.language),[e,h?.language]),[W,G]=(0,P.useState)(`preview`),[K,q]=(0,P.useState)(!1),[J,oe]=(0,P.useState)(``),[Y,se]=(0,P.useState)(!1),ce=h?.content!==void 0&&!h.binary&&!h.tooLarge&&h.reason!==`not-found`,le=(0,P.useCallback)(()=>{oe(h?.content??``),G(`raw`),q(!0)},[h]),ue=(0,P.useCallback)(async()=>{se(!0);try{let t=await fetch(`${C()}/code/file`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e,content:J})});if(!t.ok){let e=await t.json().catch(()=>({}));l.error(e.error??i(`viewer.saveFailed`));return}l.success(i(`viewer.saved`)),q(!1),V()}catch{l.error(i(`viewer.saveFailed`))}finally{se(!1)}},[e,J,i,V]),Z=h?.summary??null,de=!!h?.summaryStale,fe=h?.provenance??[],pe=h?.reason===`not-found`,me=pe?i(`summary.reason.missing`):h?.binary?i(`summary.reason.binary`):h?.tooLarge?i(`summary.reason.tooLarge`):null;return(0,P.useEffect)(()=>{if(n){if(v&&!h){n(null);return}return n({hasSummary:!!Z,regenerating:b,disabledReason:me,onClick:()=>H(!1)}),()=>n(null)}},[h,H,v,n,b,Z,me]),(0,P.useEffect)(()=>{if(r){if(v&&!h){r(null);return}return r({onClick:ae}),()=>r(null)}},[ae,h,v,r]),v&&!h?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:i(`viewer.loadingFile`)}):(0,X.jsxs)(`div`,{ref:m,className:`flex flex-col h-full`,"data-testid":`file-viewer`,children:[D?(0,X.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center justify-between border-b border-border bg-surface px-4`,"data-testid":`summary-header-collapsed`,children:[(0,X.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,X.jsxs)(`button`,{type:`button`,onClick:ie,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(f,{className:`h-3.5 w-3.5`}),i(`viewer.showSummary`)]})]}):(0,X.jsx)(Me,{path:e,summary:Z,stale:de,regenerating:b,generateDisabledReason:me,onCollapse:ie}),(0,X.jsxs)(`div`,{className:`px-4 py-1 border-b border-border flex items-center justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:U&&h?.content!==void 0&&!h.binary&&!h.tooLarge&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,role:`group`,"aria-label":i(`viewer.markdownViewMode`),children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>G(`preview`),"aria-pressed":W===`preview`,className:W===`preview`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:i(`viewer.preview`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>G(`raw`),"aria-pressed":W===`raw`,className:W===`raw`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:i(`viewer.raw`)})]})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] shrink-0`,children:[ce&&!K&&(0,X.jsx)(`button`,{type:`button`,onClick:le,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:i(`viewer.edit`)}),K&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>q(!1),disabled:Y,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 disabled:opacity-50`,children:i(`actions.cancel`,{ns:`common`})}),(0,X.jsx)(`button`,{type:`button`,onClick:ue,disabled:Y,className:`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-50`,children:i(Y?`viewer.saving`:`viewer.save`)})]})]})]}),(0,X.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:pe?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-missing`,children:i(`viewer.missingFile`)}):h?.binary?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-binary`,children:i(`viewer.binaryFile`)}):h?.tooLarge?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-too-large`,children:i(`viewer.tooLarge`,{size:Math.round((h.sizeBytes??0)/1024/1024)})}):h?.content===void 0?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:i(`viewer.noContent`)}):K?(0,X.jsx)(Ae,{content:J,language:h.language??`plaintext`,readOnly:!1,onChange:oe}):U&&W===`preview`?(0,X.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4 prose prose-invert prose-sm max-w-none prose-p:my-2 prose-headings:mt-4 prose-headings:mb-2 prose-pre:bg-muted/40 prose-pre:rounded-md prose-code:before:content-none prose-code:after:content-none`,"data-testid":`markdown-preview`,children:(0,X.jsx)(Ne,{content:h.content})}):(0,X.jsx)(Ae,{content:h.content,language:h.language??`plaintext`})}),fe.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":i(`history.resize`),onPointerDown:j?void 0:ne,onDoubleClick:j?void 0:re,className:j?`flex h-8 shrink-0 items-center justify-between border-t border-border bg-card/35 px-4`:`flex h-8 shrink-0 cursor-row-resize items-center justify-between border-y border-border/40 bg-card/35 px-4 hover:bg-accent-primary/10`,title:j?void 0:i(`resizer.hint`),"data-testid":`code-history-resizer`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:i(N===`story`?`story.title`:`history.title`,{count:fe.length})}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[!j&&(0,X.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-md bg-muted/40 p-0.5`,role:`group`,"aria-label":i(`story.viewMode`),onPointerDown:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>z(`story`),"aria-pressed":N===`story`,className:N===`story`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:i(`story.modeStory`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>z(`log`),"aria-pressed":N===`log`,className:N===`log`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:i(`story.modeLog`)})]}),(0,X.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:R,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[j?(0,X.jsx)(d,{className:`h-3.5 w-3.5`}):(0,X.jsx)(f,{className:`h-3.5 w-3.5`}),i(j?`history.show`:`history.hide`)]})]})]}),!j&&(N===`story`?(0,X.jsx)(Ie,{relPath:e,height:k,onOpenTicket:o,onFilterJob:t}):(0,X.jsx)(nt,{rows:fe,onOpenTicket:o,onFilterJob:t,height:k}))]}),w&&(0,X.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,role:`dialog`,"aria-modal":`true`,"data-testid":`budget-prompt`,onClick:p.guardBackdrop(()=>T(!1)),children:[(0,X.jsxs)(`div`,{ref:p.panelRef,onClick:e=>e.stopPropagation(),className:`bg-card border border-border rounded-lg p-4 w-80 flex flex-col gap-3`,style:p.panelStyle,children:[(0,X.jsx)(`p`,{className:`text-sm text-foreground`,children:i(`viewer.budgetPrompt`)}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>T(!1),className:`text-xs px-3 py-1.5 rounded-md text-muted-foreground hover:text-foreground`,children:i(`common:actions.cancel`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{T(!1),H(!0)},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white`,children:i(`common:actions.confirm`)})]})]}),(0,X.jsx)(E,{handles:p.resizeHandles})]})]})}function nt({rows:e,onOpenTicket:t,onFilterJob:n,height:r}){let{t:i}=s(`code`),[a,o]=(0,P.useState)(null),[c,l]=(0,P.useState)({});if(e.length===0)return null;async function u(e,t){if(a===t){o(null);return}if(o(t),!(!e.jobId||c[t])){l(e=>({...e,[t]:`loading`}));try{let n=new URLSearchParams({jobId:e.jobId,path:e.path}),r=await fetch(`${C()}/code/diff?${n.toString()}`);if(r.status===404){l(e=>({...e,[t]:`missing`}));return}if(!r.ok)throw Error(`diff failed`);let i=await r.json();l(e=>({...e,[t]:{patch:i.patch??``,truncated:i.truncated===!0}}))}catch{l(e=>({...e,[t]:`missing`}))}}}return(0,X.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:r},"data-testid":`file-provenance-timeline`,children:(0,X.jsx)(`div`,{className:`h-full overflow-auto space-y-1`,children:e.map((e,r)=>{let o=e.kind===`created`?g:e.kind===`deleted`?v:y,s=e.jobId?e.jobId.length>12?e.jobId.slice(0,12):e.jobId:i(`history.unknownJob`),l=`${e.jobId??`job`}:${e.path}:${e.at}:${r}`,d=c[l];return(0,X.jsxs)(`div`,{className:`rounded-md hover:bg-muted/40`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-[minmax(72px,auto)_minmax(0,1fr)_auto] items-center gap-2 text-xs px-2 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,X.jsx)(o,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,X.jsx)(`span`,{className:`capitalize`,children:i(`kind.${e.kind}`)})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0 text-muted-foreground`,children:[(0,X.jsx)(h,{className:`h-3.5 w-3.5 shrink-0`}),e.jobId&&n?(0,X.jsx)(`button`,{type:`button`,onClick:()=>n(e.jobId),className:`font-mono truncate hover:text-foreground`,title:i(`history.filterByJob`,{jobId:e.jobId}),children:s}):(0,X.jsx)(`span`,{className:`font-mono truncate`,title:e.jobId??void 0,children:s}),e.jobId&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(e,l),className:`shrink-0 rounded bg-muted/60 px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground`,children:i(`history.diff`)}),typeof e.ticketId==`number`&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>t(e.ticketId),className:`shrink-0 rounded bg-accent-primary/15 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/25`,title:i(`history.openSpec`,{ticketId:e.ticketId}),children:i(`history.specChip`,{ticketId:e.ticketId})})]}),(0,X.jsx)(`time`,{className:`text-[11px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]}),a===l&&(0,X.jsx)(`div`,{className:`px-2 pb-2`,children:d===`loading`?(0,X.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:i(`history.loadingDiff`)}):d===`missing`||!d?(0,X.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:i(`history.diffUnavailable`)}):(0,X.jsxs)(`pre`,{className:`max-h-72 overflow-auto rounded-md bg-muted/50 px-2 py-2 font-mono text-[11px] leading-relaxed text-foreground/85`,children:[d.patch,d.truncated?`\n${i(`history.diffTruncated`)}`:``]})})]},l)})})})}var rt=320,it=240,at=520;function ot(e){return e?`specrails-desktop:code-tree-width:${e}`:null}function st(e){let t=ot(e);if(!t)return rt;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:rt}catch{return rt}}function ct(e,t){let n=ot(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function $(e,t){let n=Math.max(it,t-at);return Math.min(Math.max(e,it),n)}function lt({embedded:e=!1,initialPath:t=null,onSelectedPathChange:n}={}){let{t:r}=s(`code`),{activeProjectId:i}=ee(),[c]=a(),l=o(),u=(0,P.useRef)(null),[d,f]=(0,P.useState)(e?t:c.get(`path`)),p=(0,P.useCallback)(e=>{f(e),n?.(e)},[n]),[m,h]=(0,P.useState)(null),[g,_]=(0,P.useState)(null),[v,y]=(0,P.useState)(()=>st(i)),[b,x]=(0,P.useState)(null),[S,C]=(0,P.useState)(null),w=e?b:c.get(`jobId`),T=(0,P.useMemo)(()=>{if(e)return S;let t=c.get(`ticketId`);if(!t)return null;let n=Number(t);return Number.isInteger(n)&&n>0?n:null},[e,S,c]),[te,E]=(0,P.useState)(T==null?``:String(T));(0,P.useEffect)(()=>{if(e)return;let t=c.get(`path`);t!==d&&f(t)},[c,e]),(0,P.useEffect)(()=>{E(T==null?``:String(T))},[T]),(0,P.useEffect)(()=>{let e=u.current?.clientWidth||window.innerWidth;y($(st(i),e))},[i]),(0,P.useEffect)(()=>{let e=u.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&y(e=>$(e,t))});return t.observe(e),()=>t.disconnect()},[]);let D=(0,P.useCallback)(e=>{let t=e.clientX,n=v,r=u.current?.clientWidth||window.innerWidth,a=e.currentTarget;try{a.setPointerCapture(e.pointerId)}catch{}function o(e){y($(n+(e.clientX-t),r))}function s(){window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),y(e=>{let t=$(e,r);return ct(i,t),t})}window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[i,v]),O=(0,P.useCallback)(()=>{let e=$(rt,u.current?.clientWidth||window.innerWidth);y(e),ct(i,e)},[i]),k=(0,P.useCallback)(t=>{if(p(t),e)return;let n=new URLSearchParams(c);n.set(`path`,t),l({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,l,c,p]),A=(0,P.useCallback)(t=>{if(e){x(t),C(null);return}let n=new URLSearchParams(c);n.set(`jobId`,t),n.delete(`ticketId`),l({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,l,c]),j=(0,P.useCallback)(()=>{if(e){x(null),C(null);return}let t=new URLSearchParams(c);t.delete(`jobId`),t.delete(`ticketId`),l({pathname:`/code`,search:t.toString()?`?${t.toString()}`:``},{replace:!0})},[e,l,c]),M=(0,P.useCallback)(t=>{let n=Number(t.trim());if(!Number.isInteger(n)||n<=0){j();return}if(e){C(n),x(null);return}let r=new URLSearchParams(c);r.set(`ticketId`,String(n)),r.delete(`jobId`),l({pathname:`/code`,search:`?${r.toString()}`},{replace:!0})},[j,e,l,c]);return(0,X.jsxs)(`div`,{ref:u,className:`flex h-full w-full`,"data-testid":`code-page`,children:[(0,X.jsx)(`aside`,{className:`overflow-hidden flex flex-col shrink-0`,style:{width:v},children:(0,X.jsx)(_e,{onOpenFile:k,selectedPath:d,filterJobId:w,filterTicketId:T},i??`no-project`)}),(0,X.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r(`page.resizeFileTree`),onPointerDown:D,onDoubleClick:O,className:`relative w-1.5 shrink-0 cursor-col-resize select-none touch-none border-x border-border/40 hover:bg-accent-primary/20 focus-visible:outline-none focus-visible:bg-accent-primary/30`,title:r(`resizer.hint`),"data-testid":`code-tree-resizer`}),(0,X.jsxs)(`main`,{className:`flex-1 overflow-hidden flex flex-col`,children:[(0,X.jsx)(ut,{jobId:w,ticketId:T,ticketInput:te,onTicketInputChange:E,onApplyTicket:M,onClear:j,summaryAction:m,copyPathAction:g}),(w||T)&&(0,X.jsx)(dt,{jobId:w,ticketId:T,onOpenFile:k}),d?(0,X.jsx)(tt,{relPath:d,onFilterJob:A,onSummaryActionChange:h,onCopyPathActionChange:_}):(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:r(`page.selectFile`)})]})]})}function ut({jobId:e,ticketId:t,ticketInput:n,onTicketInputChange:r,onApplyTicket:i,onClear:a,summaryAction:o,copyPathAction:c}){let{t:l}=s(`code`),d=t?`spec`:e?`job-context`:`all`;return(0,X.jsx)(`div`,{className:`border-b border-border bg-background/80 px-4 py-2`,"data-testid":`code-provenance-toolbar`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,X.jsx)(N,{className:`h-3.5 w-3.5`}),l(`toolbar.scope`)]}),(0,X.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":d===`all`,className:d===`all`?`rounded-md bg-accent-primary/20 px-2 py-1 text-xs text-accent-primary`:`rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.allAi`)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/70 bg-card/40 px-1 py-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>i(n),"aria-pressed":d===`spec`,className:d===`spec`?`rounded bg-accent-success/20 px-2 py-0.5 text-xs text-accent-success`:`rounded px-2 py-0.5 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.spec`)}),(0,X.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i(n)},placeholder:l(`toolbar.ticketIdPlaceholder`),inputMode:`numeric`,className:`h-6 w-20 bg-transparent px-1 font-mono text-xs outline-none placeholder:text-muted-foreground/60`})]}),(0,X.jsx)(`div`,{className:`flex-1`}),c&&(0,X.jsx)(`button`,{type:`button`,onClick:c.onClick,className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.copyFilePath`)}),o&&(0,X.jsxs)(`button`,{type:`button`,onClick:o.onClick,disabled:o.regenerating||!!o.disabledReason,"aria-label":o.hasSummary?l(`toolbar.regenerateSummary`):l(`toolbar.generateSummary`),className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary/15 px-2.5 py-1 text-xs text-accent-primary hover:bg-accent-primary/25 disabled:opacity-50`,title:o.disabledReason?l(`toolbar.summaryUnavailable`,{reason:o.disabledReason}):void 0,children:[(0,X.jsx)(u,{className:o.regenerating?`h-3.5 w-3.5 animate-spin`:`h-3.5 w-3.5`}),o.hasSummary?o.regenerating?l(`toolbar.regenerating`):l(`toolbar.regenerateSummary`):o.regenerating?l(`toolbar.generating`):l(`toolbar.generateSummary`)]}),d===`job-context`&&(0,X.jsx)(`span`,{className:`rounded-md bg-accent-info/15 px-2 py-1 text-xs text-accent-info`,children:l(`toolbar.jobContext`)}),(e||t)&&(0,X.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(x,{className:`h-3.5 w-3.5`}),l(`toolbar.clear`)]})]})})}function dt({jobId:e,ticketId:t,onOpenFile:n}){let{t:r}=s(`code`),[i,a]=(0,P.useState)(null);(0,P.useEffect)(()=>{let n=!1,r=new URLSearchParams;return e&&r.set(`jobId`,e),t&&r.set(`ticketId`,String(t)),fetch(`${C()}/code/provenance?${r.toString()}`).then(e=>e.ok?e.json():[]).then(e=>{n||a(Array.isArray(e)?e:[])}).catch(()=>{n||a([])}),()=>{n=!0}},[e,t]);let o=(0,P.useMemo)(()=>{let e=i??[];return{created:e.filter(e=>e.kind===`created`),modified:e.filter(e=>e.kind===`modified`),deleted:e.filter(e=>e.kind===`deleted`)}},[i]),c=i?.length??0;return(0,X.jsx)(`section`,{className:`border-b border-border bg-card/35 px-4 py-3`,"data-testid":`provenance-result-panel`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:e?r(`provenancePanel.jobTitle`,{jobId:e}):r(`provenancePanel.specTitle`,{ticketId:t})}),(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r(`provenancePanel.touchedFiles`,{count:c})})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,X.jsx)(ft,{label:r(`action.added`),rows:o.created,icon:`created`,onOpenFile:n}),(0,X.jsx)(ft,{label:r(`action.changed`),rows:o.modified,icon:`modified`,onOpenFile:n}),(0,X.jsx)(ft,{label:r(`action.deleted`),rows:o.deleted,icon:`deleted`,onOpenFile:n})]})]}),(0,X.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:e&&(0,X.jsxs)(`a`,{href:`/jobs/${encodeURIComponent(e)}`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(p,{className:`h-3.5 w-3.5`}),r(`provenancePanel.log`)]})})]})})}function ft({label:e,rows:t,icon:n,onOpenFile:r}){return(0,X.jsxs)(`details`,{className:`group min-w-[180px] max-w-[320px]`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-1.5 rounded-md bg-muted/35 px-2 py-1 text-xs hover:bg-muted/55`,children:[(0,X.jsx)(n===`created`?g:n===`deleted`?v:y,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:t.length})]}),t.length>0&&(0,X.jsx)(`div`,{className:`mt-1 max-h-28 overflow-auto rounded-md border border-border/60 bg-background/60 p-1`,children:t.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(e.path),className:`block w-full truncate rounded px-1.5 py-1 text-left font-mono text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,title:e.path,children:e.path},`${e.path}-${e.jobId??`job`}-${e.at}-${t}`))})]})}export{lt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r,n as i,u as a}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{a as o}from"./i18n-Bf9Ckd10.js";import{n as s}from"./createLucideIcon-Bjbbp_KS.js";import{n as c}from"./dist-bVqfYmby.js";import{c as l,l as u}from"./MinimizedChatsContext-Cs34FPTz.js";import{t as d}from"./chevron-right-CViMxucY.js";import{i as f,n as p,r as ee,t as te}from"./InteractiveJobComposer-C9I0A4KR.js";import{o as m}from"./TicketDetailModal-CI47Dq9E.js";import{t as ne}from"./circle-x-CMYsN4ZH.js";import{t as h}from"./download-CFHyyHcw.js";import{t as g}from"./loader-circle-DcygOQpC.js";import{n as _}from"./useSharedWebSocket-DaPh7QBL.js";import{t as v}from"./api-B2M7CtDw.js";import{r as y}from"./useDesktop-B4pSBIDd.js";import{t as b}from"./button-BUIIBQPT.js";import{t as x}from"./utils-BC4DHlz2.js";import{t as re}from"./formatDistanceToNow-ByKli7Q_.js";import{C as S,Dt as C,I as w,L as T,N as E,P as D,S as O,kt as k,n as A,st as j,vt as M}from"./index-F9r8mWP_.js";import{n as N}from"./job-time-BCL7wee9.js";import{t as P}from"./format-command-Dfa1o2d-.js";var F=e(t(),1),I=n();function L(e,t){let n=N(e),r=(typeof t==`number`?t:N(t)?.getTime()??NaN)-(n?.getTime()??NaN);if(!Number.isFinite(r)||r<0)return`—`;let i=Math.round(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60),o=i%60;return a<60?`${a}m ${o}s`:`${Math.floor(a/60)}h ${a%60}m`}function R(e){let t=new Set;for(let n of e)if(n.event_type===`log`)try{let e=(JSON.parse(n.payload).line??``).match(/(?:Writing|Editing|Created?|Updated?)\s+(?:file:\s*)?([\w./\-]+\.\w+)/i);e&&t.add(e[1])}catch{}return Array.from(t).slice(0,20)}var z={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function B(e,t){if(t.type===`reset`)return z;if(t.type===`consume`){let{events:n}=t,r=e.lastSeenIdx>n.length?n.length:e.lastSeenIdx;if(n.length<=r)return r===e.lastSeenIdx?e:{...e,lastSeenIdx:r};let{steps:i,actionKey:a,actionArg:o}=e;for(let e=r;e<n.length;e++){let t=S(n[e]);t.step&&(i+=t.stepCount??1),t.actionKey&&(a=t.actionKey,o=t.actionArg??``)}return{steps:i,actionKey:a,actionArg:o,lastSeenIdx:n.length}}return e}function ie({job:e,events:t,defaultOpen:n=!0,pipelineTotals:r,phases:i,phaseDefinitions:a}){let{t:o}=s(`jobs`),[c,l]=(0,F.useState)(n),d=(0,F.useMemo)(()=>R(t),[t]),f=e.status===`running`,p=e.status===`completed`,[ee,te]=(0,F.useState)(()=>Date.now());(0,F.useEffect)(()=>{if(!f)return;let e=window.setInterval(()=>te(Date.now()),1e3);return()=>window.clearInterval(e)},[f]);let[m,h]=(0,F.useReducer)(B,z),_=(0,F.useRef)(e.id);(0,F.useEffect)(()=>{_.current!==e.id&&(_.current=e.id,h({type:`reset`})),h({type:`consume`,events:t})},[e.id,t]);let[v,y]=(0,F.useState)(!0);(0,F.useEffect)(()=>{if(!f)return;y(!0);let e=window.setTimeout(()=>y(!1),8e3);return()=>window.clearTimeout(e)},[f,e.id]);let b=e.finished_at?L(e.started_at,e.finished_at):f?L(e.started_at,ee):`—`,re=!!e.total_cost_usd_estimated,S=e.total_cost_usd==null?null:`${re?`~`:``}$${e.total_cost_usd.toFixed(4)}`,C=e.num_turns==null?null:String(e.num_turns),w=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),T=w==null?null:`${(w/1e3).toFixed(1)}k`,E=(0,F.useMemo)(()=>!i||!a?null:a.find(e=>i[e.key]===`running`)?.label??null,[i,a]),D=f&&m.steps===0?`connecting`:m.actionKey||`thinking`,A=O.has(D)&&m.actionArg!==``,j=O.has(D)&&!A?`working`:D,M=A?o(`statusPanel.activity.${j}`,{arg:m.actionArg}):o(`statusPanel.activity.${j}`),N=E??(f&&m.steps===0?o(`statusPanel.activity.starting`):null),P=m.steps>0?o(`statusPanel.steps`,{count:m.steps}):null,ie=o(f?`statusPanel.inProgress`:p?`statusPanel.completed`:`statusPanel.failed`),W=f?`border-accent-info/20 bg-accent-info/5`:p?`border-emerald-500/20 aurora-light:border-accent-success/30 bg-emerald-500/5 aurora-light:bg-accent-success/5`:`border-red-500/20 aurora-light:border-destructive/30 bg-red-500/5 aurora-light:bg-destructive/5`,ae=f?g:p?k:ne,G=f?`w-4 h-4 text-accent-info shrink-0 animate-spin`:p?`w-4 h-4 text-emerald-400 aurora-light:text-accent-success shrink-0`:`w-4 h-4 text-red-400 aurora-light:text-destructive shrink-0`;return(0,I.jsxs)(`div`,{className:x(`mx-4 my-2 rounded-xl border transition-colors duration-500`,W),children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>l(!c),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,I.jsx)(ae,{className:G,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:ie}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,I.jsx)(`span`,{className:`tabular-nums`,children:b}),f?P&&(0,I.jsx)(`span`,{className:`tabular-nums`,children:P}):(0,I.jsxs)(I.Fragment,{children:[S&&(0,I.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:S}),d.length>0&&(0,I.jsx)(`span`,{children:o(`statusPanel.filesCount`,{count:d.length})})]})]}),(0,I.jsx)(u,{className:x(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,c&&`rotate-180`)})]}),c&&(0,I.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:f?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneInProgress`)}),(0,I.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[o(`statusPanel.duration`),(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,title:o(`statusPanel.liveTooltip`),"aria-label":o(`statusPanel.liveTooltip`)})]}),(0,I.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:b})]}),(0,I.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,I.jsx)(g,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),N&&(0,I.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:N}),(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:M}),P&&(0,I.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,P]})]})]}),v&&(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:o(`statusPanel.explainer`)}),(0,I.jsx)(`p`,{className:`pt-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider border-t border-accent-info/10 mt-1`,children:o(`statusPanel.zoneFinalPending`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,I.jsx)(U,{label:o(`statusPanel.cost`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.costTooltip`)}),(0,I.jsx)(U,{label:o(`statusPanel.turns`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)}),(0,I.jsx)(U,{label:o(`statusPanel.tokens`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)})]})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneFinal`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,I.jsx)(V,{label:o(`statusPanel.duration`),value:b}),(0,I.jsx)(H,{label:o(`statusPanel.cost`),value:S,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:o(`statusPanel.notAvailable`)}),(0,I.jsx)(H,{label:o(`statusPanel.turns`),value:C,naCaption:o(`statusPanel.notAvailable`)}),(0,I.jsx)(H,{label:o(`statusPanel.tokens`),value:T,naCaption:o(`statusPanel.notAvailable`)})]}),r&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.pipelineTotal`,{count:r.jobCount})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsx)(V,{label:o(`statusPanel.totalCost`),value:`${r.costEstimated?`~`:``}${r.hasNullCost?`≥`:``}$${r.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,I.jsx)(V,{label:o(`statusPanel.totalTokens`),value:`${((r.totalTokensIn+r.totalTokensOut+r.totalTokensCacheRead+r.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]}),r.hasNullCost&&(0,I.jsx)(`p`,{"data-testid":`pipeline-partial-hint`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,title:o(`statusPanel.pipelinePartialTooltip`),children:o(`statusPanel.pipelinePartial`,{count:r.nullCostCount??0})})]}),d.length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.filesModified`)}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>(0,I.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80 aurora-light:text-accent-info`,children:e},e))})]})]})})]})}function V({label:e,value:t,valueClass:n}){return(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,I.jsx)(`p`,{className:x(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function H({label:e,value:t,valueClass:n,naCaption:r}){return(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,I.jsx)(`p`,{className:x(`text-sm font-semibold tabular-nums mt-0.5`,t==null?`text-muted-foreground`:n),children:t??`—`}),t==null&&(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:r})]})}function U({label:e,caption:t,tooltip:n}){return(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,I.jsx)(C,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,I.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var W=4;function ae({tickets:e,onTicketClick:t}){let{t:n}=s(`jobs`),[r,i]=(0,F.useState)(!1);if(e.length===0)return null;let a=e.length>=W&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,I.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[a.map(e=>(0,I.jsx)(G,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showMore`,{count:o}),(0,I.jsx)(u,{className:`w-3 h-3`})]}),r&&e.length>=W&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showLess`),(0,I.jsx)(l,{className:`w-3 h-3`})]})]})}function G({ticket:e,onClick:t}){let{t:n}=s(`jobs`),r=e.title==null,i=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return r?(0,I.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,I.jsx)(`span`,{className:x(i,`text-muted-foreground bg-muted/20 select-none`),title:n(`ticketHeader.deletedTooltip`),children:n(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,I.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 min-w-0 w-full text-left group`,title:e.title??void 0,children:[(0,I.jsxs)(`span`,{className:x(i,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,I.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}var oe={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.completed`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queued`}};function K(){let{t:e}=s(`jobs`),{id:t}=a(),{activeProjectId:n,projects:l}=y(),u=l.find(e=>e.id===n)?.provider,ne=r(),{openTicketDetail:g}=m(),[S,C]=(0,F.useState)(null),[O,k]=(0,F.useState)([]),[N,L]=(0,F.useState)([]),[R,z]=(0,F.useState)({}),[B,V]=(0,F.useState)([]),[H,U]=(0,F.useState)(!0),[W,G]=(0,F.useState)(!1),[K,se]=(0,F.useState)(!1),q=(0,F.useRef)(!1),J=(0,F.useRef)(null);(0,F.useEffect)(()=>{if(!t)return;let e=new AbortController;C(null),k([]),L([]),z({}),U(!0),G(!1);async function n(){try{let n=await fetch(`${v()}/jobs/${t}`,{signal:e.signal});if(n.status===404){G(!0);return}if(!n.ok)throw Error(`Failed to fetch job`);let r=await n.json();C(r.job),k(r.events)}catch(e){if(e.name===`AbortError`)return;G(!0)}finally{e.signal.aborted||U(!1)}}return n(),()=>e.abort()},[t,n]),(0,F.useEffect)(()=>{if(!S?.pipeline_id){V([]);return}let e=S.pipeline_id;fetch(`${v()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&V(e.jobs)}).catch(()=>{})},[S?.pipeline_id,S?.status]);let Y=(0,F.useRef)(n);Y.current=n;let ce=(0,F.useRef)(null);ce.current=S?.status??null;let X=(0,F.useRef)([]),Z=(0,F.useRef)(null),le=(0,F.useCallback)(()=>{Z.current=null;let e=X.current;e.length!==0&&(X.current=[],k(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),Q=(0,F.useCallback)(e=>{let t=X.current;t.push(e),t.length>1e4&&(X.current=t.slice(-8e3)),Z.current||=requestAnimationFrame(le)},[le]);(0,F.useEffect)(()=>()=>{Z.current&&cancelAnimationFrame(Z.current)},[]);let ue=(0,F.useCallback)(e=>{let n=e;if(!(Y.current&&n.projectId&&n.projectId!==Y.current)){if(n.type===`init`){let e=n.phaseDefinitions??[];L(e);let t={};for(let r of e)t[r.key]=n.phases?.[r.key]??`idle`;z(t)}else if(n.type===`event`&&n.jobId===t){let e={id:Date.now(),job_id:t??``,seq:n.seq??0,event_type:n.event_type,source:n.source,payload:n.payload,timestamp:n.timestamp};Q(e)}else if(n.type===`log`&&n.processId===t){let e={id:Date.now(),job_id:t??``,seq:0,event_type:`log`,source:n.source,payload:JSON.stringify({line:n.line}),timestamp:n.timestamp};Q(e)}else if(n.type===`job.finalized`&&n.jobId===t||n.type===`job.interactive`&&n.jobId===t||(n.type===`loop.run_paused`||n.type===`loop.run_resumed`)&&n.loopRunId===t)fetch(`${v()}/jobs/${t}`).then(e=>e.json()).then(e=>C(e.job)).catch(()=>{});else if(n.type===`phase`){let e=n.phase,t=n.state;z(n=>({...n,[e]:t}))}else if(n.type===`queue`){let e=n.jobs?.find(e=>e.id===t);if(e){let n=e.status,r=ce.current;C(e=>e&&{...e,status:n}),(n===`completed`||n===`failed`||n===`canceled`||n===`running`&&r!==`running`)&&fetch(`${v()}/jobs/${t}`).then(e=>e.json()).then(e=>C(e.job)).catch(()=>{})}}}},[t,Q]),{registerHandler:de,unregisterHandler:fe}=_();(0,F.useEffect)(()=>(de(`job-detail-${t}`,ue),()=>fe(`job-detail-${t}`)),[t,ue,de,fe]),(0,F.useEffect)(()=>{if(!t||!S||S.status!==`running`||S.hasTelemetry)return;let e=setInterval(()=>{fetch(`${v()}/jobs/${t}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&C(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[t,S?.status,S?.hasTelemetry]);async function pe(){if(!t)return;let n=await A({projectId:null,jobId:t});n.ok?c.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)}):n.httpStatus===null?c.error(e(`detail.toast.networkError`)):c.error(e(`detail.toast.failed`),{description:n.error})}async function me(){if(S)try{let t=await fetch(`${v()}/jobs/${S.id}/diagnostic`);if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n.error??e(`detail.toast.exportFailedHttp`,{status:t.status}))}let n=await t.blob(),r=URL.createObjectURL(n),i=new Date().toISOString().slice(0,10),a=document.createElement(`a`);a.href=r,a.download=`specrails-diagnostic-${S.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){c.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function he(){if(!(!S||q.current)){q.current=!0,se(!0),J.current||=typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`rerun-${S.id}-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{let t=await fetch(`${v()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":J.current},body:JSON.stringify({command:S.command})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));J.current=null,c.success(e(`detail.toast.jobRequeued`)),ne(`/jobs/${n.jobId}`)}catch(e){c.error(e.message)}finally{q.current=!1,se(!1)}}}if(H)return(0,I.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,I.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,I.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(W||!S)return(0,I.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,I.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:t})}),(0,I.jsx)(b,{asChild:!0,variant:`outline`,size:`sm`,children:(0,I.jsxs)(i,{to:`/`,children:[(0,I.jsx)(M,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let $=oe[S.status]??oe.queued,ge=S.status===`running`,_e=S.status===`completed`||S.status===`failed`,ve=!!S.interactive,ye=ve&&ge,be=(S.tickets?.length??0)>0,xe=S.command.startsWith(`loop:`),Se=B.length>1?{totalCostUsd:B.reduce((e,t)=>e+(t.total_cost_usd??0),0),hasNullCost:B.some(e=>e.total_cost_usd==null),costEstimated:B.some(e=>!!e.total_cost_usd_estimated),nullCostCount:B.filter(e=>e.total_cost_usd==null).length,totalTokensIn:B.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:B.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:B.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:B.reduce((e,t)=>e+(t.tokens_cache_create??0),0),jobCount:B.length}:null;return(0,I.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,I.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,I.jsxs)(i,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,I.jsx)(M,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,I.jsx)(d,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:t?.slice(0,8)})})]}),be&&(0,I.jsx)(ae,{tickets:S.tickets??[],onTicketClick:g}),(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,I.jsxs)(E,{children:[(0,I.jsx)(w,{asChild:!0,children:(0,I.jsx)(`div`,{children:(0,I.jsx)(T,{variant:$.variant,children:e($.labelKey)})})}),(0,I.jsx)(D,{children:e($.tooltipKey)})]}),(0,I.jsx)(`code`,{className:x(`font-mono text-foreground/90 truncate`,be?`text-xs text-muted-foreground`:`text-sm`),children:P(S.command,u)})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,I.jsx)(`span`,{children:S.started_at?e(`detail.startedAgo`,{timeAgo:re(new Date(S.started_at),{addSuffix:!0,locale:o()})}):e(`detail.queuedWaiting`)}),S.model&&(0,I.jsx)(`span`,{className:`text-muted-foreground/40`,children:S.model})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[S.hasTelemetry&&(0,I.jsxs)(E,{children:[(0,I.jsx)(w,{asChild:!0,children:(0,I.jsxs)(b,{variant:`outline`,size:`sm`,className:`h-7`,onClick:me,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,I.jsx)(h,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,I.jsx)(D,{children:e(`detail.exportDiagnosticTooltip`)})]}),_e&&(0,I.jsxs)(E,{children:[(0,I.jsx)(w,{asChild:!0,children:(0,I.jsxs)(b,{variant:`outline`,size:`sm`,onClick:he,disabled:K,"aria-busy":K,className:`h-7`,children:[(0,I.jsx)(j,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,I.jsx)(D,{children:e(`detail.reExecuteTooltip`)})]}),ge&&(0,I.jsxs)(E,{children:[(0,I.jsx)(w,{asChild:!0,children:(0,I.jsx)(b,{variant:`outline`,size:`sm`,onClick:pe,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(ve?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,I.jsx)(D,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,I.jsx)(f,{phases:R,phaseDefinitions:N})]}),(S.status===`running`||S.status===`completed`||S.status===`failed`)&&(0,I.jsx)(ie,{job:S,events:O,defaultOpen:S.status===`completed`||S.status===`running`,pipelineTotals:Se??void 0,phases:R,phaseDefinitions:N}),(0,I.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:xe?(0,I.jsx)(p,{events:O,jobStatus:S.status,variant:`page`}):(0,I.jsx)(ee,{events:O})}),ye&&(0,I.jsx)(te,{jobId:S.id,settleMode:S.interactiveSettleMode,initialAcceptingTurns:S.interactiveAcceptingTurns,kind:S.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`page`})]})}export{K as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{n as o}from"./dist-bVqfYmby.js";import{t as s}from"./download-CFHyyHcw.js";import{t as c}from"./pencil-C9RkrIPZ.js";import{t as l}from"./play-DNlrawbS.js";import{t as u}from"./plus-CsnjfkmX.js";import{t as d}from"./sparkles-DrY8hb0X.js";import{t as f}from"./trash-2-BOU3WdZZ.js";import{t as p}from"./upload-DYMjAQ6M.js";import{n as m,r as h}from"./useDesktop-B4pSBIDd.js";import{t as g}from"./button-BUIIBQPT.js";import{t as _}from"./utils-BC4DHlz2.js";import{a as v,i as ee,n as te,o as ne,r as y,t as b}from"./dialog-CzIekCw0.js";import{D as x,E as S,Et as C,M as w,O as T,T as E,Tt as D,X as O,w as k}from"./index-F9r8mWP_.js";import{n as re}from"./TemplatePreviewModal-D4qW-J9B.js";var ie=a(`file-down`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]),ae=a(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),A=e(t(),1);function oe(e){return{specrailsLoops:1,loops:e.map(e=>({name:e.name,description:e.description,graph:e.graph}))}}function j(e){let t=e;return!!t&&typeof t.name==`string`&&!!t.graph&&typeof t.graph==`object`}function se(e){let t;try{t=JSON.parse(e)}catch{throw Error(`invalid-json`)}let n=(Array.isArray(t)?t:Array.isArray(t?.loops)?t.loops:j(t)?[t]:[]).filter(j);if(n.length===0)throw Error(`no-loops`);return n.map(e=>({name:e.name,description:e.description??null,graph:e.graph}))}function ce(e){return e.length===1?`${e[0].name.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`loop`}.loop.json`:`specrails-loops-${e.length}.json`}var le=[`API`,`Automation`,`CI`,`Database`,`Debugging`,`DevOps`,`Docs`,`Git`,`Maintenance`,`Performance`,`Planning`,`Quality`,`Review`,`Security`,`Testing`];function ue(e,t){let n=t.query.trim().toLowerCase(),r=t.categories;return e.filter(e=>r.length>0&&!(e.category&&r.includes(e.category))?!1:!n||`${e.name} ${e.description} ${e.tags.join(` `)} ${e.category??``} ${e.searchTerms??``}`.toLowerCase().includes(n))}function de(e){let t=new Map;for(let n of e)n.category&&t.set(n.category,(t.get(n.category)??0)+1);let n=[];for(let e of le){let r=t.get(e);r&&(n.push({category:e,count:r}),t.delete(e))}for(let e of[...t.keys()].sort())n.push({category:e,count:t.get(e)});return n}var M=n();function fe({loop:e,projects:t,onClose:n,onExecute:r}){let{t:a}=i(`loops`),o=e!==null,[s,c]=(0,A.useState)(``),[u,d]=(0,A.useState)(``),[f,p]=(0,A.useState)(``),[m,h]=(0,A.useState)(`medium`),_=t.find(e=>e.id===(s||t[0]?.id)),x=(0,A.useMemo)(()=>_?.providers??(_?.provider?[_.provider]:[]),[_]),S=u||x[0]||``,C=(0,A.useMemo)(()=>E(S),[S]),T=f||k(S),D=S?w(S):!1;return(0,M.jsx)(b,{open:o,onOpenChange:e=>{e||n()},children:(0,M.jsx)(te,{movableResizable:!0,className:`max-w-sm`,children:e&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(v,{children:[(0,M.jsx)(ne,{children:a(`run.title`,{name:e.name})}),(0,M.jsx)(y,{children:a(`run.subtitle`)})]}),(0,M.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.project`)}),t.length===0?(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`run.noProjects`)}):(0,M.jsx)(`select`,{"aria-label":a(`run.project`),"data-testid":`run-project-select`,value:s||t[0]?.id,onChange:e=>{c(e.target.value),d(``),p(``)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:t.map(e=>(0,M.jsx)(`option`,{value:e.id,children:e.name},e.id))}),x.length>1&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.provider`)}),(0,M.jsx)(`select`,{"aria-label":a(`run.provider`),value:S,onChange:e=>{d(e.target.value),p(``)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:x.map(e=>(0,M.jsx)(`option`,{value:e,children:e},e))})]}),C.length>0&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.model`)}),(0,M.jsx)(`select`,{"aria-label":a(`run.model`),"data-testid":`run-model-select`,value:T,onChange:e=>p(e.target.value),className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:C.map(e=>(0,M.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),D&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.effort`)}),(0,M.jsxs)(`select`,{"aria-label":a(`run.effort`),value:m,onChange:e=>h(e.target.value),className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:[(0,M.jsx)(`option`,{value:`low`,children:`low`}),(0,M.jsx)(`option`,{value:`medium`,children:`medium`}),(0,M.jsx)(`option`,{value:`high`,children:`high`})]})]}),(0,M.jsxs)(ee,{children:[(0,M.jsx)(g,{variant:`ghost`,onClick:n,children:a(`common:actions.cancel`)}),(0,M.jsxs)(g,{onClick:()=>{let e=s||t[0]?.id;e&&r({projectId:e,provider:x.length>1?S:void 0,model:C.length>0?T:void 0,effort:D?m:void 0})},disabled:t.length===0,children:[(0,M.jsx)(l,{className:`w-3.5 h-3.5 mr-1.5`}),a(`run.execute`)]})]})]})})})}var N={draft:`bg-accent-secondary/15 text-accent-secondary ring-accent-secondary/40`,published:`bg-accent-success/15 text-accent-success ring-accent-success/40`};function P({status:e}){let{t}=i(`loops`);return(0,M.jsx)(`span`,{className:_(`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium ring-1 ring-inset`,N[e]),children:t(`status.${e}`)})}function F(){let{t:e}=i(`loops`),t=r(),n=(0,A.useCallback)(e=>e.replace(/:/g,`_`),[]),a=(0,A.useCallback)((t,r)=>e(`catalog.${n(t)}.name`,{defaultValue:r}),[e,n]),c=(0,A.useCallback)((t,r)=>e(`catalog.${n(t)}.description`,{defaultValue:r}),[e,n]),[l,p]=(0,A.useState)([]),[w,E]=(0,A.useState)([]),[k,j]=(0,A.useState)([]),[le,N]=(0,A.useState)(!0),[P,F]=(0,A.useState)(null),[R,z]=(0,A.useState)(null),[B,V]=(0,A.useState)(`use`),[H,U]=(0,A.useState)(null),[W,pe]=(0,A.useState)(new Set),me=`specrails-desktop:loop-template-filter`,he=(()=>{try{let e=localStorage.getItem(me),t=e?JSON.parse(e):null;return{query:typeof t?.query==`string`?t.query:``,categories:Array.isArray(t?.categories)?t.categories:[]}}catch{return{query:``,categories:[]}}})(),[G,ge]=(0,A.useState)(he.query),[K,_e]=(0,A.useState)(he.categories);(0,A.useEffect)(()=>{try{localStorage.setItem(me,JSON.stringify({query:G,categories:K}))}catch{}},[G,K]);let ve=(0,A.useCallback)(e=>{_e(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),ye=(0,A.useCallback)(()=>{ge(``),_e([])},[]),be=(0,A.useRef)(null),{projects:xe,setActiveProjectId:Se}=h(),Ce=(0,A.useCallback)(e=>{pe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),q=(0,A.useCallback)(e=>{if(e.length===0)return;let t=new Blob([JSON.stringify(oe(e),null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=ce(e),r.click(),URL.revokeObjectURL(n)},[]),J=(0,A.useCallback)(async()=>{try{let[e,t]=await Promise.all([T.list(),T.templates()]);p(e),E(t)}catch{o.error(e(`errors.load`))}finally{N(!1)}try{j(await T.factoryLoops())}catch{j([])}},[e]);(0,A.useEffect)(()=>{J()},[J]);let we=(0,A.useCallback)(async t=>{try{let n=se(await t.text()),{imported:r,skipped:i}=await T.importLoops(n);await J(),r.length&&o.success(e(`import.done`,{count:r.length})),i.length&&o.warning(e(`import.skipped`,{count:i.length,names:i.join(`, `)})),!r.length&&!i.length&&o.warning(e(`import.invalid`))}catch(t){let n=t instanceof Error?t.message:``;o.error(e(n===`invalid-json`||n===`no-loops`?`import.invalid`:`errors.save`))}},[J,e]),Y=(0,A.useCallback)(e=>t(`/loops/${e}/edit`),[t]),Te=(0,A.useCallback)(async()=>{try{let t=await T.create({name:e(`newLoopName`)});Y(t.id)}catch{o.error(e(`errors.save`))}},[e,Y]),Ee=(0,A.useCallback)(async t=>{try{let e=await T.fromTemplate(t);Y(e.id)}catch{o.error(e(`errors.save`))}},[e,Y]),De=(0,A.useCallback)(async t=>{try{let e=await T.forkFactory(t);Y(e.id)}catch{o.error(e(`errors.save`))}},[e,Y]),Oe=(0,A.useCallback)(async({projectId:n,provider:r,model:i,effort:a})=>{let s=H;if(s){U(null);try{let{loopRunId:c}=await T.runStandalone(n,s.id,{aiEngine:r,model:i,reasoning_effort:a});Se(n),t(`/jobs/${c}`),o.success(e(`run.launched`,{name:s.name}))}catch{o.error(e(`errors.save`))}}},[H,t,Se,e]),ke=(0,A.useCallback)(e=>{V(`fork`),z({id:e.id,name:a(e.id,e.name),description:c(e.id,e.description),tags:e.claudeOnly?[`claude-only`]:[],graph:e.graph})},[a,c]),Ae=(0,A.useCallback)(async t=>{try{await T.publish(t),await J()}catch(t){t instanceof x?o.error(e(`errors.publishInvalid`)):o.error(e(`errors.save`))}},[e,J]),je=(0,A.useCallback)(async t=>{try{await T.unpublish(t),await J()}catch{o.error(e(`errors.save`))}},[e,J]),X=(0,A.useCallback)(async t=>{try{await T.duplicate(t),await J()}catch{o.error(e(`errors.save`))}},[e,J]),Me=(0,A.useCallback)(e=>F(e),[]),Ne=(0,A.useCallback)(async()=>{let t=P;if(t){F(null);try{await T.remove(t),await J()}catch{o.error(e(`errors.save`))}}},[P,e,J]),Z=l.filter(e=>e.status===`draft`),Q=l.filter(e=>e.status===`published`),Pe=de(w),$=ue(w.map(t=>({...t,searchTerms:`${a(t.id,t.name)} ${c(t.id,t.description)} ${t.category?e(`categories.${t.category}`,{defaultValue:t.category}):``}`})),{query:G,categories:K}),Fe=G.trim()!==``||K.length>0;return(0,M.jsxs)(`div`,{className:`h-full overflow-y-auto`,children:[(0,M.jsxs)(`div`,{className:`max-w-5xl mx-auto px-6 py-6`,children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,M.jsx)(O,{className:`w-5 h-5 text-accent-primary`}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:e(`title`)}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`subtitle`)})]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[W.size>0&&(0,M.jsxs)(`button`,{type:`button`,onClick:()=>q(l.filter(e=>W.has(e.id))),className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium border border-border text-foreground hover:bg-muted`,children:[(0,M.jsx)(ie,{className:`w-3.5 h-3.5`}),e(`actions.export`),` (`,W.size,`)`]}),(0,M.jsxs)(`button`,{type:`button`,onClick:()=>be.current?.click(),className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium border border-border text-foreground hover:bg-muted`,children:[(0,M.jsx)(ae,{className:`w-3.5 h-3.5`}),e(`actions.import`)]}),(0,M.jsx)(`input`,{ref:be,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&we(t),e.target.value=``}}),(0,M.jsxs)(`button`,{type:`button`,onClick:Te,className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium bg-accent-primary text-white hover:bg-accent-primary/90`,children:[(0,M.jsx)(u,{className:`w-3.5 h-3.5`}),e(`newLoop`)]})]})]}),le?(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`…`}):(0,M.jsxs)(`div`,{className:`space-y-8`,children:[Z.length===0&&Q.length===0&&(0,M.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-8 text-center`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e(`empty.title`)}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e(`empty.body`)})]}),Q.length>0&&(0,M.jsx)(I,{title:e(`sections.published`),children:Q.map(e=>(0,M.jsx)(L,{loop:e,selected:W.has(e.id),onToggleSelect:()=>Ce(e.id),onEdit:()=>Y(e.id),onUnpublish:()=>je(e.id),onDuplicate:()=>X(e.id),onExport:()=>q([e]),onDelete:()=>Me(e.id),onRun:S(e.graph)?void 0:()=>U(e)},e.id))}),Z.length>0&&(0,M.jsx)(I,{title:e(`sections.drafts`),children:Z.map(e=>(0,M.jsx)(L,{loop:e,selected:W.has(e.id),onToggleSelect:()=>Ce(e.id),onEdit:()=>Y(e.id),onPublish:()=>Ae(e.id),onDuplicate:()=>X(e.id),onExport:()=>q([e]),onDelete:()=>Me(e.id)},e.id))}),k.length>0&&(0,M.jsx)(I,{title:e(`sections.builtIn`),children:k.map(t=>(0,M.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`factory-loop-card`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(O,{className:`w-3.5 h-3.5 text-accent-primary`}),(0,M.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:a(t.id,t.name)}),(0,M.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e(`builtInBadge`)})]}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:c(t.id,t.description)}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,M.jsxs)(`button`,{type:`button`,onClick:()=>ke(t),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,M.jsx)(D,{className:`w-3 h-3`}),e(`actions.preview`)]}),(0,M.jsxs)(`button`,{type:`button`,onClick:()=>void De(t.id),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,M.jsx)(C,{className:`w-3 h-3`}),e(`actions.fork`)]})]})]},t.id))}),w.length>0&&(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-2 flex-wrap`,children:[(0,M.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e(`sections.templates`)}),(0,M.jsx)(`input`,{type:`search`,value:G,onChange:e=>ge(e.target.value),placeholder:e(`gallery.search`),"aria-label":e(`gallery.search`),"data-testid":`template-search`,className:`h-7 w-48 max-w-full rounded-md border border-border bg-surface/40 px-2.5 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:ring-1 focus:ring-accent-primary`})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-3`,"data-testid":`category-chips`,children:[Pe.map(({category:t,count:n})=>{let r=K.includes(t);return(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>ve(t),className:_(`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] border transition-colors`,r?`border-accent-primary bg-accent-primary/15 text-accent-primary`:`border-border bg-surface/40 text-muted-foreground hover:text-foreground hover:bg-muted`),children:[e(`categories.${t}`,{defaultValue:t}),(0,M.jsx)(`span`,{className:`opacity-60 tabular-nums`,children:n})]},t)}),Fe&&(0,M.jsx)(`button`,{type:`button`,onClick:ye,className:`inline-flex items-center h-6 px-2 rounded-full text-[11px] text-accent-primary hover:underline`,children:e(`gallery.clearFilter`)})]}),$.length===0?(0,M.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-6 text-center`,"data-testid":`template-empty`,children:[(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`gallery.noResults`)}),(0,M.jsx)(`button`,{type:`button`,onClick:ye,className:`mt-2 text-xs text-accent-primary hover:underline`,children:e(`gallery.clearFilter`)})]}):(0,M.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:$.map(t=>(0,M.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`template-card`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(d,{className:`w-3.5 h-3.5 text-accent-highlight flex-shrink-0`}),(0,M.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:a(t.id,t.name)}),t.category&&(0,M.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info flex-shrink-0`,children:e(`categories.${t.category}`,{defaultValue:t.category})})]}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:c(t.id,t.description)}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[S(t.graph)?(0,M.jsx)(`span`,{title:e(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:e(`gallery.needsSpec`)}):(0,M.jsx)(`span`,{title:e(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:e(`gallery.standalone`)}),t.tags.map(e=>(0,M.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,M.jsxs)(`button`,{type:`button`,onClick:()=>{V(`use`),z({...t,name:a(t.id,t.name),description:c(t.id,t.description)})},className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,M.jsx)(D,{className:`w-3 h-3`}),e(`actions.preview`)]}),(0,M.jsxs)(`button`,{type:`button`,onClick:()=>Ee(t.id),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,M.jsx)(s,{className:`w-3 h-3`}),e(`actions.use`)]})]})]},t.id))})]})]})]}),(0,M.jsx)(b,{open:P!==null,onOpenChange:e=>{e||F(null)},children:(0,M.jsxs)(te,{className:`max-w-sm`,children:[(0,M.jsxs)(v,{children:[(0,M.jsxs)(ne,{className:`flex items-center gap-2`,children:[(0,M.jsx)(f,{className:`w-4 h-4 text-destructive`}),l.find(e=>e.id===P)?.name??e(`actions.delete`)]}),(0,M.jsx)(y,{children:e(`confirmDelete`)})]}),(0,M.jsxs)(ee,{children:[(0,M.jsx)(g,{variant:`ghost`,onClick:()=>F(null),children:e(`common:actions.cancel`)}),(0,M.jsx)(g,{variant:`destructive`,onClick:()=>void Ne(),children:e(`common:actions.delete`)})]})]})}),(0,M.jsx)(re,{template:R,mode:B,onClose:()=>z(null),onUse:e=>{z(null),B===`fork`?De(e):Ee(e)}}),(0,M.jsx)(fe,{loop:H?{id:H.id,name:H.name}:null,projects:xe.map(e=>({id:e.id,name:e.name,providers:m(e)})),onClose:()=>U(null),onExecute:Oe})]})}function I({title:e,children:t}){return(0,M.jsxs)(`section`,{children:[(0,M.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2`,children:e}),(0,M.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t})]})}function L({loop:e,selected:t,onToggleSelect:n,onEdit:r,onPublish:a,onUnpublish:o,onDuplicate:u,onExport:d,onDelete:m,onRun:h}){let{t:g}=i(`loops`),_=e.graph?.nodes?.length??0;return(0,M.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`loop-card`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:t,onChange:n,"aria-label":g(`actions.select`,{name:e.name}),className:`accent-accent-primary flex-shrink-0`}),(0,M.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:e.name})]}),(0,M.jsx)(P,{status:e.status})]}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:g(`card.nodes`,{count:_})}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[h&&(0,M.jsx)(R,{icon:l,label:g(`actions.run`),onClick:h}),(0,M.jsx)(R,{icon:c,label:g(`actions.edit`),onClick:r}),a&&(0,M.jsx)(R,{icon:p,label:g(`actions.publish`),onClick:a}),o&&(0,M.jsx)(R,{icon:s,label:g(`actions.unpublish`),onClick:o}),(0,M.jsx)(R,{icon:C,label:g(`actions.duplicate`),onClick:u}),(0,M.jsx)(R,{icon:ie,label:g(`actions.export`),onClick:d}),(0,M.jsx)(R,{icon:f,label:g(`actions.delete`),onClick:m,danger:!0})]})]})}function R({icon:e,label:t,onClick:n,danger:r}){return(0,M.jsx)(`button`,{type:`button`,onClick:n,title:t,"aria-label":t,className:_(`inline-flex items-center justify-center w-7 h-7 rounded-md transition-colors`,r?`text-muted-foreground hover:text-destructive hover:bg-destructive/10`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:(0,M.jsx)(e,{className:`w-3.5 h-3.5`})})}export{F as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r,t as i}from"./createLucideIcon-Bjbbp_KS.js";import{n as a}from"./dist-bVqfYmby.js";import{t as o}from"./download-CFHyyHcw.js";import{t as s}from"./loader-circle-DcygOQpC.js";import{t as c}from"./search-Cq_gE3Ik.js";import{t as l}from"./trash-2-BOU3WdZZ.js";import{t as u}from"./triangle-alert-H9T4jAmh.js";import{a as d}from"./auth-D_5bQv5W.js";import{n as f}from"./useSharedWebSocket-DaPh7QBL.js";import{n as p,r as m}from"./useDesktop-B4pSBIDd.js";import{t as h}from"./button-BUIIBQPT.js";import{t as g}from"./utils-BC4DHlz2.js";import{a as _,n as v,o as y,r as b,t as x}from"./dialog-CzIekCw0.js";import{t as S}from"./jira-api-BgFIr8eD.js";import{at as C,jt as w,kt as T,nt as ee,rt as te,tt as ne,u as E,ut as D}from"./index-F9r8mWP_.js";var O=i(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),re=i(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),k=i(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),A=i(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),ie=i(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),j=e(t(),1),M=n(),N=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],ae={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function P({state:e,onChanged:t,apiBase:n}){let{t:i}=r(`jira`),o=e.connection,[s,c]=(0,j.useState)(o.enabled),[l,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)([]),[g,_]=(0,j.useState)([]),[v,y]=(0,j.useState)(o.discardStatus??``),[b,x]=(0,j.useState)(o.statusMap??{}),C=e.outbox??{pending:0,inflight:0,done:0,dead:0},w=(0,j.useCallback)(async()=>{try{let{ops:e}=n?await S.listOutbox(`dead`,n):await S.listOutbox(`dead`);m(e)}catch{m([])}},[n]);(0,j.useEffect)(()=>{w()},[w]),(0,j.useEffect)(()=>{let e=!1;return S.listStatuses(n).then(({statuses:t})=>{e||_(t)}).catch(()=>{e||_([])}),()=>{e=!0}},[n]);async function T(e){let r=v;y(e);try{n?await S.patchConnection({discardStatus:e||null},n):await S.patchConnection({discardStatus:e||null}),t()}catch(e){y(r),a.error(I(e,i))}}async function ee(e,r){let o=b,s={...b,[e]:r||void 0};x(s);let c=Object.fromEntries(Object.entries(s).filter(([,e])=>e));try{n?await S.patchConnection({statusMap:Object.keys(c).length?c:null},n):await S.patchConnection({statusMap:Object.keys(c).length?c:null}),t()}catch(e){x(o),a.error(I(e,i))}}async function te(){let e=!s;c(e),f(!0);try{n?await S.setEnabled(e,n):await S.setEnabled(e)}catch(t){c(!e),a.error(I(t,i))}finally{f(!1)}}async function ne(){u(!0);try{let e=n?await S.syncNow(n):await S.syncNow();a.success(i(`status.syncedToast`,{count:e.upserted}))}catch(e){a.error(I(e,i))}finally{u(!1)}}async function E(){if(window.confirm(i(`status.disconnectConfirm`))){f(!0);try{n?await S.disconnect(n):await S.disconnect(),a.success(i(`status.disconnectedToast`)),t()}catch(e){a.error(I(e,i))}finally{f(!1)}}}async function D(e){try{n?await S.retryOutbox(e,n):await S.retryOutbox(e),await w()}catch(e){a.error(I(e,i))}}let O=C.pending+C.inflight;return(0,M.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:i(`status.connected`,{key:o.jiraProjectKey})}),(0,M.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[o.baseUrl,` · `,o.deployment===`cloud`?i(`review.cloud`):i(`review.dc`)]})]}),(0,M.jsx)(`a`,{href:`${o.baseUrl}/browse/${o.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:i(`badge.openInJira`)})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:i(`status.enabledLabel`)}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(s?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,M.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":s,"aria-label":i(`status.enabledLabel`),disabled:d,onClick:te,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${s?`bg-accent-success`:`bg-input`}`,children:(0,M.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${s?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,M.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:i(`wizard.step3Title`)}),(0,M.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:i(`mapping.intro`)}),(0,M.jsx)(`div`,{className:`space-y-2`,children:N.map(e=>(0,M.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`mapping.${ae[e]}`)}),(0,M.jsxs)(`select`,{value:b[e]??``,onChange:t=>void ee(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,M.jsx)(`option`,{value:``,children:i(`mapping.auto`)}),g.map(e=>(0,M.jsx)(`option`,{value:e.name,children:e.name},e.id)),b[e]&&!g.some(t=>t.name===b[e])&&(0,M.jsx)(`option`,{value:b[e],children:b[e]})]})]},e))})]}),(0,M.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:i(`discard.configLabel`)}),(0,M.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:i(`discard.configHelp`)}),(0,M.jsxs)(`select`,{value:v,onChange:e=>void T(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,M.jsx)(`option`,{value:``,children:i(`discard.configNone`)}),g.map(e=>(0,M.jsx)(`option`,{value:e.name,children:e.name},e.id)),v&&!g.some(e=>e.name===v)&&(0,M.jsx)(`option`,{value:v,children:v})]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(h,{variant:`outline`,size:`sm`,onClick:ne,disabled:l,children:i(l?`status.syncing`:`status.syncNow`)}),(0,M.jsx)(h,{variant:`ghost`,size:`sm`,onClick:E,disabled:d,className:`text-destructive`,children:i(`status.disconnect`)})]}),(0,M.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:i(`outbox.title`)}),C.dead>0?(0,M.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:i(`outbox.dead`,{count:C.dead})}):O>0?(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`outbox.pending`,{count:O})}):(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`outbox.allSynced`)}),p.length>0&&(0,M.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`outbox.deadHelp`)}),p.map(e=>(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,M.jsxs)(`span`,{className:`truncate text-xs`,children:[F(e,i),` · `,e.deadReason??e.lastError??``]}),(0,M.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>D(e.id),children:i(`outbox.retry`)})]},e.id))]})]})]})}function F(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function I(e,t){return e instanceof Error?e.message:t(`errors.generic`)}function L(e){return{provider:e,label:e===`codex`?`Codex`:`Claude`,active:!1,available:!1,detectedRoute:!1,requests:0,inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0,outputSavingsPercent:0,outputSavingsMethod:`none`,outputSavingsAllocated:!1}}function R(){return{updatedAt:null,proxyStatsAvailable:!1,durableSavingsAvailable:!1,outputSavingsAvailable:!1,outputSavingsMethod:null,outputConfidence:null,providers:{codex:L(`codex`),claude:L(`claude`)},lastIssue:null}}var z={installed:!1,installSource:null,version:null,executablePath:null,uvPath:null,port:8787,phase:`idle`,activeProviders:{codex:!1,claude:!1},availableProviders:{codex:!1,claude:!1},detectedRoutes:{codex:!1,claude:!1},proxyRunning:!1,proxyPid:null,learning:{enabled:!1,baselineReady:!1,baselineSamples:0,updatedAt:null,lastIssue:null},metrics:R(),lastIssue:null,updatedAt:null};function B(e){let t=e?.metrics??R();return{...z,...e,activeProviders:{...z.activeProviders,...e?.activeProviders},availableProviders:{...z.availableProviders,...e?.availableProviders},detectedRoutes:{...z.detectedRoutes,...e?.detectedRoutes},learning:{...z.learning,...e?.learning},metrics:{...R(),...t,providers:{codex:{...L(`codex`),...t.providers?.codex},claude:{...L(`claude`),...t.providers?.claude}}}}}async function V(e){let t=await e.text(),n=t?JSON.parse(t):{};if(!e.ok){let t=n.issue;throw Object.assign(Error(t?.title??n.error??`HTTP ${e.status}`),{payload:n})}return n}function H(e){return`${d}/api/projects/${e}`}function U(e,t=`en`){if(!Number.isFinite(e))return`0`;try{return Intl.NumberFormat(t,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}catch{return Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}}function W(e,t,n){return`${U(e,t)} ${n}`}function G(){let{t:e}=r(`integrations`),{projects:t}=m(),{registerHandler:n,unregisterHandler:i}=f(),[a,o]=(0,j.useState)(``),[s,l]=(0,j.useState)(`all`),[u,p]=(0,j.useState)(z),[h,S]=(0,j.useState)(!0),[C,w]=(0,j.useState)(null),[T,E]=(0,j.useState)([]),[O,A]=(0,j.useState)(!1),[ie,N]=(0,j.useState)(!1),[ae,P]=(0,j.useState)(null),[F,I]=(0,j.useState)({jira:0,serena:0,projects:0}),L=(0,j.useCallback)(async()=>{try{let e=await fetch(`${d}/api/global-plugins/headroom`).then(e=>V(e));p(B(e.state))}finally{S(!1)}},[]);(0,j.useEffect)(()=>{L()},[L]),(0,j.useEffect)(()=>(n(`plugins-page`,e=>{let t=e;t.type===`plugin.headroom_progress`&&(t.line&&E(e=>[...e.slice(-80),t.line]),L())}),()=>i(`plugins-page`)),[n,i,L]),(0,j.useEffect)(()=>{let e=!1;async function n(){let n=await Promise.all(t.map(async e=>{let[t,n]=await Promise.all([fetch(`${H(e.id)}/jira/connection`).then(e=>V(e)).catch(()=>({connected:!1})),fetch(`${H(e.id)}/plugins`).then(e=>V(e)).catch(()=>({plugins:[]}))]),r=n.plugins.find(e=>e.name===`serena`);return{jira:+!!t.connected,serena:r&&r.status!==`not-installed`&&r.status!==`orphan`?1:0}}));e||I({jira:n.reduce((e,t)=>e+t.jira,0),serena:n.reduce((e,t)=>e+t.serena,0),projects:t.length})}return n(),()=>{e=!0}},[t]);async function R(e,t){w(e),E([]);try{let e=(await t()).state;e&&p(B(e))}catch(e){let t=e.payload;t?.state&&p(B(t.state))}finally{w(null),L()}}let U=(0,j.useMemo)(()=>[{id:`headroom-ai`,title:`Headroom AI`,scope:`global`,icon:k,description:e(`plugins.catalog.headroom.description`),installed:u.installed,status:u.lastIssue?`attention`:u.installed?u.activeProviders.codex||u.activeProviders.claude?u.installSource===`system`?`external-active`:`active`:u.installSource===`system`?`external`:`installed`:`available`,statusLabel:u.lastIssue?e(`plugins.status.attention`):u.installed?u.activeProviders.codex||u.activeProviders.claude?u.installSource===`system`?e(`plugins.status.externalActive`):e(`plugins.status.active`):u.installSource===`system`?e(`plugins.status.external`):e(`plugins.status.installed`):e(`plugins.status.available`),actionKind:u.lastIssue?`review`:u.installed?`manage`:`install`,actionLabel:u.lastIssue?e(`plugins.actions.review`):u.installed?e(`plugins.actions.manage`):e(`plugins.actions.install`),busy:C===`install`,action:()=>{if(u.lastIssue||u.installed){A(!0);return}R(`install`,()=>fetch(`${d}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>V(e)))}}],[u,C,e]),W=(0,j.useMemo)(()=>[{id:`jira`,title:`Jira`,scope:`project`,icon:re,description:e(`plugins.catalog.jira.description`),installed:F.jira>0,status:F.jira>0?`configured`:`available`,statusLabel:F.jira>0?e(`plugins.status.configuredCount`,{count:F.jira}):e(`plugins.status.available`),actionKind:F.jira>0?`manage`:`install`,actionLabel:F.jira>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>P(`jira`)},{id:`serena`,title:`Serena`,scope:`project`,icon:ne,description:e(`plugins.catalog.serena.description`),installed:F.serena>0,status:F.serena>0?`installed`:`available`,statusLabel:F.serena>0?e(`plugins.status.installedCount`,{count:F.serena}):e(`plugins.status.available`),actionKind:F.serena>0?`manage`:`install`,actionLabel:F.serena>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>P(`serena`)}],[F,e]),G=a.trim().toLowerCase(),K=t=>`${t.title} ${t.description} ${t.statusLabel} ${e(`plugins.scope.${t.scope}`)}`.toLowerCase().includes(G),q=[...U,...W].filter(e=>s!==`all`&&e.scope!==s?!1:K(e)),J=q.filter(e=>e.scope===`global`&&e.installed),Y=q.filter(e=>e.scope===`project`&&e.installed),X=q.filter(e=>e.scope===`global`&&!e.installed),Z=q.filter(e=>e.scope===`project`&&!e.installed),Q=J.length>0||Y.length>0,le=X.length>0||Z.length>0,$=[u.installed,F.jira>0,F.serena>0].filter(Boolean).length;return(0,M.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[(0,M.jsxs)(`div`,{className:`border-b border-border px-6 py-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,M.jsx)(`div`,{className:`grid h-9 w-9 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,M.jsx)(D,{className:`h-4 w-4`})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`h1`,{className:`text-lg font-semibold tracking-normal`,children:e(`plugins.page.title`)}),(0,M.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`plugins.page.subtitle`)})]}),(0,M.jsxs)(`div`,{className:`mr-12 flex items-center gap-2 rounded-lg border border-border bg-card/60 px-3 py-2 text-xs`,children:[(0,M.jsx)(te,{className:`h-3.5 w-3.5 text-accent-success`}),(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:e(`plugins.page.readyCount`,{count:$})})]})]}),(0,M.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 md:flex-row md:items-center`,children:[(0,M.jsxs)(`label`,{className:`relative flex-1`,children:[(0,M.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,M.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:e(`plugins.search.placeholder`),className:`h-9 w-full rounded-lg border border-border bg-background pl-9 pr-3 text-sm outline-none transition-colors focus:border-accent-primary/60`})]}),(0,M.jsx)(`div`,{className:`inline-flex h-9 rounded-lg border border-border bg-card p-1`,children:[`all`,`global`,`project`].map(t=>(0,M.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:g(`rounded-md px-3 text-xs capitalize transition-colors`,s===t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:e(`plugins.filters.${t}`)},t))})]})]}),(0,M.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-5`,children:[(0,M.jsxs)(`section`,{className:`mb-6`,children:[(0,M.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,M.jsx)(ee,{className:`h-3.5 w-3.5`}),e(`plugins.sections.installed`)]}),Q?(0,M.jsx)(oe,{globalPlugins:J,projectPlugins:Y}):(0,M.jsx)(se,{text:e(G?`plugins.empty.installedSearch`:`plugins.empty.installed`)})]}),(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,M.jsx)(D,{className:`h-3.5 w-3.5`}),e(`plugins.sections.available`)]}),le?(0,M.jsx)(oe,{globalPlugins:X,projectPlugins:Z}):(0,M.jsx)(se,{text:e(G?`plugins.empty.availableSearch`:`plugins.empty.allInstalled`)})]})]}),(0,M.jsx)(x,{open:O,onOpenChange:A,children:(0,M.jsxs)(v,{className:`w-[calc(100vw-2rem)] max-w-xl overflow-x-hidden p-4 sm:p-6`,children:[(0,M.jsxs)(_,{children:[(0,M.jsx)(y,{children:e(`plugins.headroom.title`)}),(0,M.jsx)(b,{children:e(`plugins.headroom.dialogDescription`)})]}),(0,M.jsx)(ce,{state:u,loading:h,busy:C,logs:T,onInstall:()=>R(`install`,()=>fetch(`${d}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>V(e))),onToggleProvider:(e,t)=>R(`${t?`deactivate`:`activate`}-${e}`,()=>fetch(`${d}/api/global-plugins/headroom/${t?`deactivate`:`activate`}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).then(e=>V(e))),onDeactivateAll:()=>R(`deactivate-all`,async()=>{let e={state:u};for(let t of[`codex`,`claude`])u.activeProviders[t]&&(e=await fetch(`${d}/api/global-plugins/headroom/deactivate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:t})}).then(e=>V(e)));return e}),onUninstall:()=>R(`uninstall`,()=>fetch(`${d}/api/global-plugins/headroom/uninstall`,{method:`POST`}).then(e=>V(e))),onSetPort:e=>R(`port`,()=>fetch(`${d}/api/global-plugins/headroom/port`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({port:e})}).then(e=>V(e))),onOpenDiagnostics:()=>N(!0)})]})}),(0,M.jsx)(ue,{plugin:ae,projects:t,onClose:()=>P(null)}),(0,M.jsx)(pe,{open:ie,onClose:()=>N(!1)})]})}function oe({globalPlugins:e,projectPlugins:t}){let{t:n}=r(`integrations`);return(0,M.jsxs)(`div`,{className:g(`grid grid-cols-1 gap-4`,e.length>0&&t.length>0&&`xl:grid-cols-2`),children:[e.length>0&&(0,M.jsxs)(`section`,{children:[(0,M.jsx)(q,{title:n(`plugins.groups.global.title`),detail:n(`plugins.groups.global.detail`),scope:`global`}),(0,M.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:e.map(e=>(0,M.jsx)(J,{plugin:e},e.id))})]}),t.length>0&&(0,M.jsxs)(`section`,{children:[(0,M.jsx)(q,{title:n(`plugins.groups.project.title`),detail:n(`plugins.groups.project.detail`),scope:`project`}),(0,M.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:t.map(e=>(0,M.jsx)(J,{plugin:e},e.id))})]})]})}function se({text:e}){return(0,M.jsx)(`div`,{className:`flex h-[74px] max-w-[320px] items-center rounded-lg border border-dashed border-border bg-card/35 px-3 text-xs text-muted-foreground`,children:e})}function K({scope:e}){let{t}=r(`integrations`);return(0,M.jsx)(`span`,{className:g(`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wide`,e===`global`?`bg-accent-primary/10 text-accent-primary`:`bg-accent-info/10 text-accent-info`),children:t(`plugins.scope.${e}`)})}function q({title:e,detail:t,scope:n}){return(0,M.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,M.jsx)(`div`,{className:g(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card/70 px-2 py-1`,children:[(0,M.jsx)(K,{scope:n}),(0,M.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,M.jsx)(`span`,{className:`hidden text-[11px] text-muted-foreground sm:inline`,children:t})]}),(0,M.jsx)(`div`,{className:g(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)})]})}function J({plugin:e}){let{t}=r(`integrations`),n=e.icon,i=e.scope===`global`,a=e.status===`attention`,c=e.busy?s:e.actionKind===`install`?o:e.actionKind===`review`?u:C,l=g(`shrink-0 rounded border px-1.5 py-0.5 text-[10px] leading-none`,a?`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`:e.installed?`border-accent-success/25 bg-accent-success/10 text-accent-success`:`border-border bg-muted text-muted-foreground`);return(0,M.jsxs)(`article`,{className:`grid h-[88px] w-full grid-cols-[38px_minmax(0,1fr)_auto] items-center gap-3 rounded-lg border border-border bg-card/70 px-3 transition-colors hover:border-accent-primary/35 hover:bg-card`,children:[(0,M.jsx)(`div`,{className:g(`grid h-[38px] w-[38px] shrink-0 place-items-center rounded-lg border`,i?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-accent-info/25 bg-accent-info/10 text-accent-info`),children:(0,M.jsx)(n,{className:`h-4 w-4`})}),(0,M.jsxs)(`div`,{className:`min-w-0`,children:[(0,M.jsx)(`h2`,{className:`truncate text-sm font-semibold leading-5`,children:e.title}),(0,M.jsx)(`p`,{className:`mt-1 truncate text-[11px] leading-4 text-muted-foreground`,children:e.description}),(0,M.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,M.jsx)(K,{scope:e.scope}),(0,M.jsx)(`span`,{className:l,children:e.statusLabel})]})]}),(0,M.jsxs)(`button`,{type:`button`,disabled:e.busy,onClick:e.action,className:`flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-xs font-medium transition-colors hover:bg-muted disabled:opacity-50`,children:[(0,M.jsx)(c,{className:g(`h-3.5 w-3.5`,e.busy&&`animate-spin`)}),e.busy?t(`plugins.actions.installing`):e.actionLabel]})]})}function ce({state:e,loading:t,busy:n,logs:i,onInstall:a,onToggleProvider:c,onDeactivateAll:u,onUninstall:d,onSetPort:f,onOpenDiagnostics:p}){let{t:m}=r(`integrations`),[h,g]=(0,j.useState)(String(e.port)),[_,v]=(0,j.useState)(!1);(0,j.useEffect)(()=>g(String(e.port)),[e.port]),(0,j.useEffect)(()=>{e.installed||v(!1)},[e.installed]);let y=e.activeProviders.codex||e.activeProviders.claude,b=e.installSource===`system`;return(0,M.jsxs)(`aside`,{className:`w-full min-w-0 overflow-hidden rounded-lg border border-border bg-card/80 p-4`,children:[(0,M.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,M.jsx)(`div`,{className:`grid h-10 w-10 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,M.jsx)(k,{className:`h-4 w-4`})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold`,children:m(`plugins.headroom.title`)}),(0,M.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:m(`plugins.headroom.panelDescription`)})]})]}),(0,M.jsxs)(`div`,{className:`mb-4 grid grid-cols-3 gap-2 text-xs`,children:[(0,M.jsx)(Y,{label:m(`plugins.headroom.metrics.install`),value:t?m(`plugins.headroom.metrics.checking`):e.installed?m(`plugins.headroom.metrics.ready`):m(`plugins.headroom.metrics.missing`),good:e.installed}),(0,M.jsx)(Y,{label:m(`plugins.headroom.metrics.source`),value:e.installSource===`system`?m(`plugins.headroom.metrics.system`):e.installSource===`managed`?m(`plugins.headroom.metrics.specrails`):m(`plugins.headroom.metrics.none`),good:e.installed}),(0,M.jsx)(Y,{label:m(`plugins.headroom.metrics.proxy`),value:e.proxyRunning?`:${e.port}`:m(y?`plugins.headroom.metrics.starting`:`plugins.headroom.metrics.off`),good:e.proxyRunning||!y})]}),e.lastIssue&&(0,M.jsx)(X,{issue:e.lastIssue}),e.installed?(0,M.jsxs)(`div`,{className:`mb-4 space-y-2`,children:[(0,M.jsx)($,{provider:`codex`,active:e.activeProviders.codex,available:e.availableProviders.codex,detectedRoute:e.detectedRoutes.codex,busy:n===`activate-codex`||n===`deactivate-codex`,onClick:()=>c(`codex`,e.activeProviders.codex)}),(0,M.jsx)($,{provider:`claude`,active:e.activeProviders.claude,available:e.availableProviders.claude,detectedRoute:e.detectedRoutes.claude,busy:n===`activate-claude`||n===`deactivate-claude`,onClick:()=>c(`claude`,e.activeProviders.claude)}),y&&(0,M.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:u,className:`flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border bg-background/45 text-xs hover:bg-muted/50 disabled:opacity-50`,children:[n===`deactivate-all`?(0,M.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(A,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.disableAllRoutes`)]})]}):(0,M.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:a,className:`mb-3 flex h-9 w-full items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 text-xs font-medium text-white disabled:opacity-50`,children:[n===`install`?(0,M.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(o,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.installWithUv`)]}),e.installed&&(0,M.jsx)(Z,{state:e}),(0,M.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,M.jsx)(`label`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:m(`plugins.headroom.port.label`)}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),className:`h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-sm`}),(0,M.jsx)(`button`,{type:`button`,disabled:!!n||Number(h)===e.port,onClick:()=>f(Number(h)),className:`rounded-md border border-border px-2 text-xs hover:bg-muted disabled:opacity-50`,children:m(`plugins.headroom.port.apply`)})]})]}),i.length>0&&(0,M.jsx)(`pre`,{className:`mb-3 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background/60 p-2 text-[10px] text-muted-foreground`,children:i.join(`
|
|
2
|
-
`)}),(0,M.jsxs)(`button`,{type:`button`,onClick:p,className:`mb-2 flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border text-xs hover:bg-muted/50`,children:[(0,M.jsx)(ie,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.viewDiagnostics`)]}),e.installed&&(0,M.jsx)(`div`,{className:`rounded-lg border border-destructive/25 bg-destructive/5 p-3`,children:_?(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:m(b?`plugins.headroom.confirmDetach`:`plugins.headroom.confirmUninstall`)}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,disabled:!!n,onClick:()=>v(!1),className:`h-8 rounded-md border border-border text-xs hover:bg-muted/50 disabled:opacity-50`,children:m(`plugins.actions.cancel`)}),(0,M.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:d,className:`flex h-8 items-center justify-center gap-2 rounded-md bg-destructive px-2 text-xs font-medium text-destructive-foreground disabled:opacity-50`,children:[n===`uninstall`?(0,M.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(l,{className:`h-3.5 w-3.5`}),m(b?`plugins.headroom.actions.detach`:`plugins.headroom.actions.uninstall`)]})]})]}):(0,M.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:()=>v(!0),className:`flex h-8 w-full items-center justify-center gap-2 rounded-md text-xs font-medium text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:[(0,M.jsx)(l,{className:`h-3.5 w-3.5`}),m(b?`plugins.headroom.actions.detachHeadroom`:`plugins.headroom.actions.uninstallHeadroom`)]})})]})}function Y({label:e,value:t,good:n}){return(0,M.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-2`,children:[(0,M.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e}),(0,M.jsx)(`div`,{className:g(`mt-0.5 font-medium`,n?`text-foreground`:`text-accent-warning`),children:t})]})}function X({issue:e}){let{t}=r(`integrations`),n=`plugins.headroom.issues.${e.code}`,i=t(`${n}.title`,{defaultValue:e.title}),a=t(`${n}.guidance`,{defaultValue:e.guidance});return(0,M.jsx)(`div`,{className:`mb-3 rounded-lg border border-accent-warning/35 bg-accent-warning/10 p-3`,children:(0,M.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,M.jsx)(u,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-warning`}),(0,M.jsxs)(`div`,{className:`min-w-0`,children:[(0,M.jsx)(`div`,{className:`text-xs font-medium`,children:i}),(0,M.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:a}),(0,M.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:t(`plugins.headroom.issueCode`,{code:e.code})})]})]})})}function Z({state:e}){let{t,i18n:n}=r(`integrations`),i=e.metrics,a=i.outputSavingsAvailable,o=[`codex`,`claude`].map(e=>({provider:e,metric:i.providers[e]})),s=t(`plugins.headroom.savings.tokens`),c=o.reduce((e,{metric:t})=>({inputTokens:e.inputTokens+t.inputTokens,inputTokensSaved:e.inputTokensSaved+t.inputTokensSaved,outputTokens:e.outputTokens+t.outputTokens,outputTokensSaved:e.outputTokensSaved+t.outputTokensSaved}),{inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0}),l=o.some(({metric:e})=>e.inputTokensSaved>0),u=o.some(({metric:e})=>e.active),d=t(a?`plugins.headroom.savings.statusInputOutput`:l?`plugins.headroom.savings.statusInputOnly`:u?`plugins.headroom.savings.statusRouting`:`plugins.headroom.savings.statusInactive`),f=a||l;return(0,M.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,M.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(w,{className:`h-3.5 w-3.5 text-accent-primary`}),(0,M.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t(`plugins.headroom.savings.title`)})]}),(0,M.jsx)(`span`,{className:g(`shrink-0 rounded border px-1.5 py-0.5 text-[10px]`,f?`border-accent-success/25 bg-accent-success/10 text-accent-success`:u?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-border bg-muted text-muted-foreground`),children:d})]}),(0,M.jsxs)(`div`,{className:`mb-2 rounded-md bg-muted/35 px-2.5 py-2`,children:[(0,M.jsx)(`div`,{className:`mb-1.5 text-[10px] font-medium uppercase text-muted-foreground`,children:t(`plugins.headroom.savings.totals`)}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,M.jsx)(Q,{label:t(`plugins.headroom.savings.input`),processed:c.inputTokens>0?W(c.inputTokens,n.language,s):t(`plugins.headroom.savings.noData`),saved:W(c.inputTokensSaved,n.language,s)}),(0,M.jsx)(Q,{align:`right`,label:t(`plugins.headroom.savings.output`),processed:c.outputTokens>0?W(c.outputTokens,n.language,s):t(`plugins.headroom.savings.noData`),saved:a?W(c.outputTokensSaved,n.language,s):t(`plugins.headroom.savings.noData`)})]})]}),(0,M.jsx)(`div`,{className:`grid gap-2`,children:o.map(({provider:e,metric:t})=>(0,M.jsx)(le,{metric:t,outputAvailable:i.outputSavingsAvailable},e))}),(0,M.jsx)(`div`,{className:`mt-2 flex items-center justify-end gap-2 text-[10px] text-muted-foreground`,children:i.updatedAt?t(`plugins.headroom.savings.updatedLive`):t(`plugins.headroom.savings.baselineSamples`,{count:e.learning.baselineSamples})})]})}function Q({label:e,processed:t,saved:n,detail:i,align:a=`left`}){let{t:o}=r(`integrations`);return(0,M.jsxs)(`div`,{className:g(`min-w-0`,a===`right`&&`text-right`),children:[(0,M.jsx)(`div`,{className:`text-[10px] font-medium uppercase text-muted-foreground`,children:e}),(0,M.jsxs)(`div`,{className:`mt-1 space-y-0.5 text-[11px]`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,M.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:o(`plugins.headroom.savings.processed`)}),(0,M.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:t})]}),(0,M.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,M.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:o(`plugins.headroom.savings.saved`)}),(0,M.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:n})]})]}),i&&(0,M.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,children:i})]})}function le({metric:e,outputAvailable:t}){let{t:n,i18n:i}=r(`integrations`),a=!e.available,o=a||!e.active,s=n(`plugins.headroom.savings.tokens`),c=e.inputTokens>0?W(e.inputTokens,i.language,s):n(`plugins.headroom.savings.noData`),l=W(e.inputTokensSaved,i.language,s),u=e.outputTokens>0?W(e.outputTokens,i.language,s):n(`plugins.headroom.savings.noData`),d=t?W(e.outputTokensSaved,i.language,s):e.active?n(`plugins.headroom.savings.noData`):n(`plugins.headroom.savings.off`),f=e.requests>0?n(`plugins.headroom.savings.requestCount`,{count:U(e.requests,i.language)}):a?n(`plugins.headroom.provider.noProjectUsesProvider`):e.active?n(`plugins.headroom.savings.inputSavingsActive`):n(`plugins.headroom.savings.routeDisabled`);return(0,M.jsxs)(`div`,{className:g(`rounded-md border border-border bg-card/45 px-2.5 py-2`,o&&`opacity-70`),children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`text-xs font-medium`,children:e.label}),e.detectedRoute&&(0,M.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-0.5 text-[9px] uppercase text-accent-primary`,children:n(`plugins.headroom.savings.detected`)})]}),(0,M.jsx)(`div`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:f}),(0,M.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-3`,children:[(0,M.jsx)(Q,{label:n(`plugins.headroom.savings.input`),processed:c,saved:l}),(0,M.jsx)(Q,{align:`right`,label:n(`plugins.headroom.savings.output`),processed:u,saved:d})]})]})}function $({provider:e,active:t,available:n,detectedRoute:i,busy:a,onClick:o}){let{t:c}=r(`integrations`),l=c(n?t?`plugins.headroom.provider.routedThroughHeadroom`:i?`plugins.headroom.provider.detectedExternalRoute`:`plugins.headroom.provider.notRouted`:`plugins.headroom.provider.noProjectUsesProvider`);return(0,M.jsxs)(`button`,{type:`button`,onClick:o,disabled:a||!n,className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background/45 p-3 text-left hover:bg-muted/35 disabled:opacity-50`,children:[(0,M.jsx)(`div`,{className:g(`grid h-8 w-8 place-items-center rounded-md`,t?`bg-accent-success/15 text-accent-success`:`bg-muted text-muted-foreground`),children:a?(0,M.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(O,{className:`h-3.5 w-3.5`})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`div`,{className:`text-xs font-medium capitalize`,children:e}),(0,M.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:l})]}),(0,M.jsx)(`span`,{className:g(`h-5 w-9 rounded-full p-0.5 transition-colors`,t?`bg-accent-success`:`bg-muted`),children:(0,M.jsx)(`span`,{className:g(`block h-4 w-4 rounded-full bg-white shadow transition-transform`,t&&`translate-x-4`)})})]})}function ue({plugin:e,projects:t,onClose:n}){let{t:i}=r(`integrations`),[a,o]=(0,j.useState)(``);(0,j.useEffect)(()=>o(``),[e]);let s=t.find(e=>e.id===a)??null;return(0,M.jsx)(x,{open:!!e,onOpenChange:e=>{e||n()},children:(0,M.jsxs)(v,{className:`w-[calc(100vw-2rem)] max-w-3xl overflow-x-hidden p-4 sm:p-6`,children:[(0,M.jsxs)(_,{children:[(0,M.jsx)(y,{children:i(e===`jira`?`plugins.projectWizard.configureJira`:`plugins.projectWizard.installSerena`)}),(0,M.jsx)(b,{children:i(`plugins.projectWizard.description`)})]}),(0,M.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[260px_minmax(0,1fr)]`,children:[(0,M.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/70 p-3`,children:[(0,M.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:i(`plugins.projectWizard.chooseProject`)}),(0,M.jsx)(`div`,{className:`max-h-[52vh] space-y-1 overflow-auto`,children:t.map(t=>{let n=e===`serena`&&!p(t).includes(`claude`);return(0,M.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>o(t.id),className:g(`w-full rounded-md px-2 py-2 text-left transition-colors`,t.id===a?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/45 hover:text-foreground`,n&&`cursor-not-allowed opacity-45`),children:[(0,M.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t.name}),(0,M.jsx)(`div`,{className:`truncate text-[10px]`,children:n?i(`plugins.projectWizard.requiresClaudeProvider`):t.path})]},t.id)})})]}),(0,M.jsx)(`div`,{className:`min-h-[360px] rounded-lg border border-border bg-card/70 p-4`,children:s?e===`jira`?(0,M.jsx)(de,{project:s,onDone:n}):(0,M.jsx)(fe,{project:s,onDone:n}):(0,M.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:i(`plugins.projectWizard.selectProjectToContinue`)})})]})]})})}function de({project:e,onDone:t}){let{t:n}=r(`integrations`),i=H(e.id),[a,o]=(0,j.useState)(null),[c,l]=(0,j.useState)(!0),[u,d]=(0,j.useState)(null),f=(0,j.useCallback)(async()=>{l(!0),d(null);try{let e=await fetch(`${i}/jira/connection`).then(e=>V(e));o(e)}catch(e){o({connected:!1}),d(e.message)}finally{l(!1)}},[i]);return(0,j.useEffect)(()=>{f()},[f]),c?(0,M.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,M.jsx)(s,{className:`mr-2 h-4 w-4 animate-spin`}),n(`plugins.jira.loading`,{defaultValue:`Loading Jira...`})]}):a?.connected&&a.connection?(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`plugins.jira.configuredDescription`,{defaultValue:`Manage the Jira project, status mapping, discard status, sync, and connection state.`})})]}),(0,M.jsx)(P,{state:a,apiBase:i,onChanged:()=>{f()}})]}):(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:u?n(`plugins.jira.loadFailed`,{message:u,defaultValue:`Could not load the current Jira configuration: ${u}`}):n(`plugins.jira.notConfiguredDescription`,{defaultValue:`Connect this project to Jira.`})})]}),(0,M.jsx)(E,{apiBase:i,onConnected:()=>{f()},onSkip:t})]})}function fe({project:e,onDone:t}){let{t:n}=r(`integrations`),[i,a]=(0,j.useState)(null),[c,l]=(0,j.useState)(null),[d,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(null),h=(0,j.useCallback)(async()=>{m(null);let t=(await fetch(`${H(e.id)}/plugins`).then(e=>V(e))).plugins.find(e=>e.name===`serena`)??null;if(a(t),t?.status===`not-installed`){let t=await fetch(`${H(e.id)}/plugins/serena/preview-install`).then(e=>V(e));l(t)}},[e.id]);(0,j.useEffect)(()=>{h().catch(e=>m(e.message))},[h]);async function g(){f(!0),m(null);try{await fetch(`${H(e.id)}/plugins/serena/install`,{method:`POST`}).then(e=>V(e)),await h(),t()}catch(e){m(e.message)}finally{f(!1)}}let _=(c?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum),v=i?n(`plugins.projectStatus.${i.status}`,{defaultValue:i.status}):``,y=i?.name===`serena`?n(`plugins.catalog.serena.description`):i?.description;return!i&&!p?(0,M.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,M.jsx)(s,{className:`mr-2 h-4 w-4 animate-spin`}),` `,n(`plugins.serena.loading`)]}):(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.serena.titleForProject`,{name:e.name})}),(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`plugins.serena.description`)})]}),i&&(0,M.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-3`,children:[(0,M.jsx)(`div`,{className:`text-xs font-medium`,children:n(`plugins.serena.status`,{status:v})}),y&&(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:y})]}),c&&(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.files`)}),(0,M.jsx)(`ul`,{className:`space-y-1 text-xs font-mono`,children:c.files.map(e=>(0,M.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path]},e.path))})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.prerequisites`)}),(0,M.jsx)(`ul`,{className:`space-y-1 text-xs`,children:c.requirements.map(e=>(0,M.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.installed&&e.executable&&e.meetsMinimum?(0,M.jsx)(T,{className:`h-3 w-3 text-accent-success`}):(0,M.jsx)(u,{className:`h-3 w-3 text-accent-warning`}),(0,M.jsxs)(`span`,{children:[e.name,e.minVersion?` >= ${e.minVersion}`:``]}),e.version&&(0,M.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]})]},e.name))})]})]}),p&&(0,M.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-xs text-destructive`,children:p}),(0,M.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md border border-border px-3 py-1.5 text-xs`,children:n(`plugins.actions.cancel`)}),(0,M.jsxs)(`button`,{type:`button`,disabled:d||i?.status!==`not-installed`||!_,onClick:g,className:`flex items-center gap-2 rounded-md bg-accent-primary px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:[d?(0,M.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(o,{className:`h-3.5 w-3.5`}),n(`plugins.actions.install`)]})]})]})}function pe({open:e,onClose:t}){let{t:n}=r(`integrations`),[i,a]=(0,j.useState)(null);return(0,j.useEffect)(()=>{e&&fetch(`${d}/api/global-plugins/headroom/diagnostics`).then(e=>V(e)).then(a).catch(e=>a({error:e.message}))},[e]),(0,M.jsx)(x,{open:e,onOpenChange:e=>{e||t()},children:(0,M.jsxs)(v,{className:`max-w-3xl`,children:[(0,M.jsxs)(_,{children:[(0,M.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,M.jsx)(C,{className:`h-4 w-4`}),` `,n(`plugins.diagnostics.title`)]}),(0,M.jsx)(b,{children:n(`plugins.diagnostics.description`)})]}),(0,M.jsx)(`pre`,{className:`max-h-[62vh] overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background p-3 text-xs`,children:JSON.stringify(i,null,2)})]})})}export{G as default};
|