specrails-desktop 2.36.0 → 2.42.2
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 +94 -247
- package/client/dist/assets/ActivityFeedPage-DoEMumQS.js +1 -0
- package/client/dist/assets/AgentBrowserCapture-DIh4K0gh.js +1 -0
- package/client/dist/assets/AgentModeAnalyticsPane-mbq4WEoO.js +2 -0
- package/client/dist/assets/AgentModeCodePane-CKh7zuA4.js +2 -0
- package/client/dist/assets/AgentModeJobsPane-BDokPiLJ.js +1 -0
- package/client/dist/assets/AgentsPage-BFVAZbBj.js +87 -0
- package/client/dist/assets/AnalyticsPage-3Y9LuWwz.js +1 -0
- package/client/dist/assets/CodePage-C9KyuV_C.js +3 -0
- package/client/dist/assets/DesktopAnalyticsPage-Bhi54bXQ.js +1 -0
- package/client/dist/assets/{DocsDialog-C76VdBJC.js → DocsDialog-Dj6mt4ga.js} +2 -2
- package/client/dist/assets/{DocsPage-ziMlj6B6.js → DocsPage-24yWglNI.js} +1 -1
- package/client/dist/assets/ExportDropdown-ophapHrT.js +1 -0
- package/client/dist/assets/InteractiveJobComposer-C1ucmxQh.js +19 -0
- package/client/dist/assets/JobDetailModal-DNWmgVHD.js +1 -0
- package/client/dist/assets/JobDetailPage-BcajZyuu.js +1 -0
- package/client/dist/assets/JobsPage-B9nTZw6e.js +1 -0
- package/client/dist/assets/LoopBuilderPage-Oc48iOFW.js +7 -0
- package/client/dist/assets/LoopPreviewModal-ae0Fr6SU.js +1 -0
- package/client/dist/assets/LoopsPage-CUEqzUBI.js +1 -0
- package/client/dist/assets/MinimizedChatsContext-Deg39peL.js +1 -0
- package/client/dist/assets/PluginsPage-C1xtARIx.js +2 -0
- package/client/dist/assets/ProjectSettingsDialog-JZzrXFBN.js +1 -0
- package/client/dist/assets/RepositoryDeliveries-CSDsiVUz.js +5 -0
- package/client/dist/assets/RepositoryScopeSelector-D-RCaknl.js +1 -0
- package/client/dist/assets/ReviewPacketPage-x5EfGTiL.js +1 -0
- package/client/dist/assets/TemplatePreviewModal-BSyuZxGq.js +1 -0
- package/client/dist/assets/TicketDetailModalContext-DqyF0so-.js +14 -0
- package/client/dist/assets/Trans-SnMX4MhW.js +1 -0
- package/client/dist/assets/agent-BdT0SB1D.js +1 -0
- package/client/dist/assets/agent-Bh9K7iEt.js +1 -0
- package/client/dist/assets/agent-C4ibdFk9.js +1 -0
- package/client/dist/assets/agent-CSFY22Zo.js +1 -0
- package/client/dist/assets/agent-DAnqxUn8.js +1 -0
- package/client/dist/assets/agent-DTQiu0Mi.js +1 -0
- package/client/dist/assets/agent-T54WuR_Y.js +1 -0
- package/client/dist/assets/agent-i75WDZOA.js +1 -0
- package/client/dist/assets/browser-05vRDg_y.js +1 -0
- package/client/dist/assets/browser-Bulb-cB1.js +1 -0
- package/client/dist/assets/browser-C7f-Jsg1.js +1 -0
- package/client/dist/assets/browser-CG0PE1j_.js +1 -0
- package/client/dist/assets/browser-CMzaqAjo.js +1 -0
- package/client/dist/assets/browser-DMajYdNX.js +1 -0
- package/client/dist/assets/browser-DxcOHrdP.js +1 -0
- package/client/dist/assets/browser-ObE7xVo3.js +1 -0
- package/client/dist/assets/builder-765NeYTp.js +1 -0
- package/client/dist/assets/builder-8MG3V6ea.js +1 -0
- package/client/dist/assets/builder-B-1UBs5K.js +1 -0
- package/client/dist/assets/builder-BTiGnPT0.js +1 -0
- package/client/dist/assets/builder-Cx9Rz-7u.js +1 -0
- package/client/dist/assets/builder-DKFMELBl.js +1 -0
- package/client/dist/assets/builder-OcmKrC0h.js +1 -0
- package/client/dist/assets/builder-P9qVBXFZ.js +1 -0
- package/client/dist/assets/{button-CJqFnUOL.js → button-DCBqEaZl.js} +1 -1
- package/client/dist/assets/{code-CkUuW4m9.js → code-B37GRg9C.js} +1 -1
- package/client/dist/assets/{code-B0O8-p8k.js → code-BBOEZbf9.js} +1 -1
- package/client/dist/assets/{code-B1VLZDhS.js → code-BRm-jcyx.js} +1 -1
- package/client/dist/assets/{code-Bpj4Ddml.js → code-CF7w62CR.js} +1 -1
- package/client/dist/assets/{code-BykBZ5-e.js → code-CLuvJt2r.js} +1 -1
- package/client/dist/assets/{code-B86IMAfz.js → code-D0RCm59f.js} +1 -1
- package/client/dist/assets/code-DaZ-ZwCT.js +1 -0
- package/client/dist/assets/{code-cAqaqMTx.js → code-iIHkGaCL.js} +1 -1
- package/client/dist/assets/commands-0XjAftla.js +1 -0
- package/client/dist/assets/commands-BAWSYHjQ.js +1 -0
- package/client/dist/assets/commands-BBwowgiE.js +1 -0
- package/client/dist/assets/commands-BacjIZLN.js +1 -0
- package/client/dist/assets/commands-Bs62IAZ3.js +1 -0
- package/client/dist/assets/commands-CLPdh-Hh.js +1 -0
- package/client/dist/assets/commands-DlbFzgrp.js +1 -0
- package/client/dist/assets/commands-LjPSsi5F.js +1 -0
- package/client/dist/assets/common-B5AZNYMH.js +1 -0
- package/client/dist/assets/common-BFZ0c_vN.js +1 -0
- package/client/dist/assets/common-BrlwEnL7.js +1 -0
- package/client/dist/assets/common-BttQx3z4.js +1 -0
- package/client/dist/assets/common-CM65k_-e.js +1 -0
- package/client/dist/assets/common-D4mvFFlu.js +1 -0
- package/client/dist/assets/common-TZ9Ny96S.js +1 -0
- package/client/dist/assets/common-nFpSF4GC.js +1 -0
- package/client/dist/assets/dashboard-B14uYXkG.js +1 -0
- package/client/dist/assets/dashboard-BK_mez-z.js +1 -0
- package/client/dist/assets/dashboard-BfBir_6o.js +1 -0
- package/client/dist/assets/dashboard-Bt0cCzeG.js +1 -0
- package/client/dist/assets/dashboard-BwkjxI6H.js +1 -0
- package/client/dist/assets/{dashboard-C8WOEiPu.js → dashboard-C3bDKf7s.js} +1 -1
- package/client/dist/assets/dashboard-CdvjGfog.js +1 -0
- package/client/dist/assets/dashboard-fRrP0Kv0.js +1 -0
- package/client/dist/assets/dialog-SRw01_QU.js +45 -0
- package/client/dist/assets/dist-js-CJ_2XX1Y.js +1 -0
- package/client/dist/assets/formatDistanceToNow-DSj5DprF.js +1 -0
- package/client/dist/assets/getTimezoneOffsetInMilliseconds-YhD8rIEs.js +1 -0
- package/client/dist/assets/index-DwAmL7m5.css +2 -0
- package/client/dist/assets/index-EzrkUb8B.js +76 -0
- package/client/dist/assets/{jira-api-B1-MUehg.js → jira-api-CSCqGr-Q.js} +1 -1
- package/client/dist/assets/{jobs-CN_zv4Gr.js → jobs-B8rrzfyZ.js} +1 -1
- package/client/dist/assets/{jobs-DUlWSYq2.js → jobs-BS6RTurf.js} +1 -1
- package/client/dist/assets/{jobs-Bpks6doU.js → jobs-BTT0Bsks.js} +1 -1
- package/client/dist/assets/{jobs-Bgq-PZkC.js → jobs-CezU69AE.js} +1 -1
- package/client/dist/assets/{jobs-SwYS2M-B.js → jobs-ClFJae0s.js} +1 -1
- package/client/dist/assets/{jobs-BAls3bWq.js → jobs-DJSFIFVy.js} +1 -1
- package/client/dist/assets/{jobs-DhxKgWFq.js → jobs-DhgGr8vm.js} +1 -1
- package/client/dist/assets/{jobs-B_TeSQxb.js → jobs-DzMjUcaN.js} +1 -1
- package/client/dist/assets/mcp-6rMoZfEO.js +1 -0
- package/client/dist/assets/mcp-BD8sL5mP.js +1 -0
- package/client/dist/assets/mcp-BkcA3I5s.js +1 -0
- package/client/dist/assets/mcp-CCpSelOh.js +1 -0
- package/client/dist/assets/mcp-CUAN6ORK.js +1 -0
- package/client/dist/assets/mcp-CqbRxRTE.js +1 -0
- package/client/dist/assets/mcp-DP2YfVhO.js +1 -0
- package/client/dist/assets/mcp-DUVQamDz.js +1 -0
- package/client/dist/assets/narration-B-ynWTpn.js +1 -0
- package/client/dist/assets/narration-Bj_laZwg.js +1 -0
- package/client/dist/assets/narration-BxHpmMv_.js +1 -0
- package/client/dist/assets/narration-C1Px0-0j.js +1 -0
- package/client/dist/assets/narration-CAXhGbzM.js +1 -0
- package/client/dist/assets/narration-DQ1l_Kq6.js +1 -0
- package/client/dist/assets/narration-XISXwqZd.js +1 -0
- package/client/dist/assets/narration-kwzfglQo.js +1 -0
- package/client/dist/assets/nav-1-Hh2kOz.js +1 -0
- package/client/dist/assets/nav-B34QkESm.js +1 -0
- package/client/dist/assets/nav-Bap_UXAq.js +1 -0
- package/client/dist/assets/{nav-pYuXq7sf.js → nav-BwxXIB24.js} +1 -1
- package/client/dist/assets/nav-Ch-zHBG5.js +1 -0
- package/client/dist/assets/nav-CygC_WN-.js +1 -0
- package/client/dist/assets/{nav-iwjCg5FR.js → nav-KnnLQtOQ.js} +1 -1
- package/client/dist/assets/nav-m00uxYUG.js +1 -0
- package/client/dist/assets/packet-BQ2tXfJI.js +1 -0
- package/client/dist/assets/packet-BdpOJ1Cy.js +1 -0
- package/client/dist/assets/packet-C3Ievb9R.js +1 -0
- package/client/dist/assets/packet-C4zJIG0Y.js +1 -0
- package/client/dist/assets/packet-Cx-zRuWn.js +1 -0
- package/client/dist/assets/packet-DUTGX52M.js +1 -0
- package/client/dist/assets/packet-DhsKtUPB.js +1 -0
- package/client/dist/assets/packet-z3LJ8Zyy.js +1 -0
- package/client/dist/assets/project-repositories-DYhTvwQ1.js +1 -0
- package/client/dist/assets/provider-capabilities-B-wOHfLP.js +1 -0
- package/client/dist/assets/settings-BBt2xtDQ.js +1 -0
- package/client/dist/assets/settings-BJB9RKJj.js +1 -0
- package/client/dist/assets/settings-CHwQR2rB.js +1 -0
- package/client/dist/assets/settings-CrMi3kSi.js +1 -0
- package/client/dist/assets/settings-DKyhDGD1.js +1 -0
- package/client/dist/assets/settings-Deupji9c.js +1 -0
- package/client/dist/assets/settings-DqRMmwAM.js +1 -0
- package/client/dist/assets/settings-J4rj6vo-.js +1 -0
- package/client/dist/assets/setup-2xGgu4Sk.js +1 -0
- package/client/dist/assets/setup-Ba11l2JA.js +1 -0
- package/client/dist/assets/setup-BzW4kMok.js +1 -0
- package/client/dist/assets/setup-COzwYhkJ.js +1 -0
- package/client/dist/assets/setup-CRVULhtF.js +1 -0
- package/client/dist/assets/setup-DgvlxwpE.js +1 -0
- package/client/dist/assets/setup-Dw_wYeEY.js +1 -0
- package/client/dist/assets/setup-ZPtEeJPW.js +1 -0
- package/client/dist/assets/spending-BqbdPm_4.js +1 -0
- package/client/dist/assets/square-Ci-PFcFe.js +1 -0
- package/client/dist/assets/{terminal-BFRZnMPP.js → terminal-BAzpHtpY.js} +1 -1
- package/client/dist/assets/{terminal-IahE4LW9.js → terminal-C7dHeR3x.js} +1 -1
- package/client/dist/assets/{terminal-tITa81iz.js → terminal-CMla5Qsz.js} +1 -1
- package/client/dist/assets/{terminal-BZiIu3rf.js → terminal-CdNXH-n9.js} +1 -1
- package/client/dist/assets/{terminal-ScjyXNxQ.js → terminal-Cw5bZsmV.js} +1 -1
- package/client/dist/assets/{terminal-C2NAd7BW.js → terminal-DFUP4eNv.js} +1 -1
- package/client/dist/assets/{terminal-d7GadXbN.js → terminal-DGqljeK_.js} +1 -1
- package/client/dist/assets/{terminal-QpXZU2Bn.js → terminal-cU70NodO.js} +1 -1
- package/client/dist/assets/useDesktop-RSMTyy7V.js +1 -0
- package/client/dist/assets/useSharedWebSocket-BOdS5_Iz.js +2 -0
- package/client/dist/index.html +34 -35
- package/docs/README.md +3 -0
- package/docs/agent-live-steering.md +57 -0
- package/docs/ci-cd.md +57 -0
- package/docs/code-explorer.md +48 -0
- package/docs/codex.md +12 -1
- package/docs/features/detachable-mission-windows.md +59 -0
- package/docs/guide/de/integrations/5-mcp-server.md +13 -9
- package/docs/guide/de/integrations/6-agent-chat.md +1 -0
- package/docs/guide/en/integrations/5-mcp-server.md +13 -9
- package/docs/guide/en/integrations/6-agent-chat.md +1 -0
- package/docs/guide/es/integrations/5-mcp-server.md +13 -9
- package/docs/guide/es/integrations/6-agent-chat.md +1 -0
- package/docs/guide/fr/integrations/5-mcp-server.md +13 -9
- package/docs/guide/fr/integrations/6-agent-chat.md +1 -0
- package/docs/guide/it/integrations/5-mcp-server.md +13 -9
- package/docs/guide/it/integrations/6-agent-chat.md +1 -0
- package/docs/guide/ja/integrations/5-mcp-server.md +13 -9
- package/docs/guide/ja/integrations/6-agent-chat.md +1 -0
- package/docs/guide/pt/integrations/5-mcp-server.md +13 -9
- package/docs/guide/pt/integrations/6-agent-chat.md +1 -0
- package/docs/guide/zh/integrations/5-mcp-server.md +13 -9
- package/docs/guide/zh/integrations/6-agent-chat.md +1 -0
- package/docs/internals/README.md +1 -0
- package/docs/internals/browser-capture-performance.md +55 -3
- package/docs/internals/browser-login-popups.md +45 -0
- package/docs/internals/browser-native-retina-audit.md +39 -0
- package/docs/internals/ci-cd-audit.md +39 -0
- package/docs/internals/core-runtime-updates.md +68 -0
- package/docs/internals/embedded-browser-native-webview-evaluation.md +2 -0
- package/docs/internals/implementation-reliability-audit.md +93 -0
- package/docs/internals/interactive-jobs.md +110 -6
- package/docs/internals/mcp-mission-audit.md +76 -0
- package/docs/internals/project-builder.md +404 -42
- package/docs/internals/safe-pr-review-flow.md +52 -10
- package/docs/internals/startup-recovery-audit.md +58 -0
- package/docs/mcp.md +74 -41
- package/docs/mission-processes.md +59 -0
- package/docs/multi-repo-projects.md +51 -0
- package/docs/platforms/windows-parity.md +70 -0
- package/docs/platforms/windows.md +13 -11
- package/docs/running-pipelines.md +14 -0
- package/mcp-bridge/dist/specrails-mcp.js +7186 -0
- package/package.json +9 -4
- package/server/dist/agent-chat-manager.js +537 -68
- package/server/dist/agent-chat-router.js +87 -6
- package/server/dist/agent-context-resolver.js +129 -25
- package/server/dist/agent-defaults.js +19 -11
- package/server/dist/agent-input-store.js +206 -0
- package/server/dist/agent-mcp-config.js +54 -15
- package/server/dist/agent-operator-prompt.js +255 -65
- package/server/dist/agent-spec-framing.js +202 -0
- package/server/dist/agent-steering.js +218 -0
- package/server/dist/agent-store.js +153 -0
- package/server/dist/api-not-found.js +8 -0
- package/server/dist/background-process-control.js +164 -0
- package/server/dist/background-process-service.js +61 -0
- package/server/dist/background-process-store.js +242 -0
- package/server/dist/background-windows-bootstrap.js +238 -0
- package/server/dist/blueprint-chat-manager.js +476 -62
- package/server/dist/blueprint-commit.js +21 -1
- package/server/dist/blueprint-draft-parser.js +122 -17
- package/server/dist/blueprint-generation.js +238 -0
- package/server/dist/blueprint-operator-prompt.js +91 -63
- package/server/dist/blueprint-router.js +55 -3
- package/server/dist/blueprint-spec-fixtures.js +85 -0
- package/server/dist/blueprint-spec-quality.js +57 -16
- package/server/dist/blueprint-store.js +92 -1
- package/server/dist/browser-capture-manager.js +86 -30
- package/server/dist/browser-playwright.js +168 -45
- package/server/dist/browser-viewport.js +26 -0
- package/server/dist/chat-manager.js +23 -15
- package/server/dist/chromium-archive.cjs +83 -0
- package/server/dist/chromium-resolver.js +72 -64
- package/server/dist/code-activity.js +145 -0
- package/server/dist/code-explorer-router.js +714 -114
- package/server/dist/core-compat.js +28 -1
- package/server/dist/core-execution.js +111 -0
- package/server/dist/core-package.js +4 -16
- package/server/dist/core-runtime.js +202 -0
- package/server/dist/core-update-manager.js +161 -60
- package/server/dist/core-update-state.js +29 -0
- package/server/dist/db.js +66 -35
- package/server/dist/delivery-evidence.js +142 -39
- package/server/dist/desktop-db.js +239 -43
- package/server/dist/desktop-router.js +109 -9
- package/server/dist/dev-ports.js +8 -3
- package/server/dist/file-provenance.js +34 -22
- package/server/dist/file-story-manager.js +62 -64
- package/server/dist/file-story.js +118 -35
- package/server/dist/file-summary-generator.js +46 -5
- package/server/dist/file-summary-manager.js +355 -106
- package/server/dist/framework-manager.js +98 -110
- package/server/dist/framework-reseed.js +76 -10
- package/server/dist/git-diagnostics.js +2 -2
- package/server/dist/headroom-manager.js +38 -3
- package/server/dist/host-control.js +52 -0
- package/server/dist/index.js +43 -2
- package/server/dist/interactive-job-session.js +149 -16
- package/server/dist/internal-api.js +48 -0
- package/server/dist/jira/jira-materializer.js +1 -0
- package/server/dist/json-tolerant.js +174 -0
- package/server/dist/legacy-migration.js +4 -2
- package/server/dist/loop-command-catalog.js +83 -21
- package/server/dist/loop-constants.js +6 -1
- package/server/dist/loop-decider.js +11 -1
- package/server/dist/loop-executors.js +194 -45
- package/server/dist/loop-factory.js +11 -4
- package/server/dist/loop-graph.js +90 -4
- package/server/dist/loop-run-manager.js +301 -69
- package/server/dist/loop-shell-invocation.js +21 -0
- package/server/dist/loop-step-idle.js +55 -0
- package/server/dist/loop-templates.js +31 -7
- package/server/dist/mcp/agent-capability.js +37 -4
- package/server/dist/mcp/guide.js +149 -36
- package/server/dist/mcp/mcp-admin-router.js +20 -4
- package/server/dist/mcp/mcp-server.js +89 -43
- package/server/dist/mcp/mcp-tiers.js +6 -5
- package/server/dist/mcp/mcp-token.js +3 -1
- package/server/dist/mcp/resources.js +5 -4
- package/server/dist/mcp/tools/catalog.js +4 -0
- package/server/dist/mcp/tools/code.js +125 -14
- package/server/dist/mcp/tools/context.js +153 -0
- package/server/dist/mcp/tools/git.js +15 -5
- package/server/dist/mcp/tools/jobs.js +84 -71
- package/server/dist/mcp/tools/loops.js +17 -6
- package/server/dist/mcp/tools/meta.js +74 -27
- package/server/dist/mcp/tools/mission.js +29 -0
- package/server/dist/mcp/tools/projects.js +22 -6
- package/server/dist/mcp/tools/rails.js +48 -11
- package/server/dist/mcp/tools/specs.js +86 -14
- package/server/dist/mcp/tools/support.js +1 -1
- package/server/dist/mcp/tools/types.js +117 -43
- package/server/dist/mcp/tools/watch.js +144 -51
- package/server/dist/milestone-chain-store.js +164 -0
- package/server/dist/milestone-chain.js +487 -0
- package/server/dist/milestone-progress.js +348 -0
- package/server/dist/mobile/mobile-devices.js +10 -7
- package/server/dist/mobile/mobile-gateway.js +2 -0
- package/server/dist/mobile/mobile-missions.js +214 -0
- package/server/dist/mobile/mobile-redact.js +17 -3
- package/server/dist/mobile/mobile-router.js +46 -4
- package/server/dist/mobile/mobile-ws.js +49 -4
- package/server/dist/multi-repo-bases.js +56 -0
- package/server/dist/multi-repo-checkout.js +101 -0
- package/server/dist/multi-repo-delivery.js +100 -0
- package/server/dist/multi-repo-execution-store.js +65 -0
- package/server/dist/multi-repo-execution.js +453 -0
- package/server/dist/offline-assemble.js +10 -8
- package/server/dist/openspec-runtime-plugin-commands.json +18 -0
- package/server/dist/openspec-runtime-plugin.js +120 -0
- package/server/dist/plugins/codex-spawn.js +49 -0
- package/server/dist/plugins/serena/manifest.js +2 -2
- package/server/dist/plugins/serena/templates/instructions.md +16 -0
- package/server/dist/pr-publisher.js +1 -1
- package/server/dist/profiles-router.js +3 -18
- package/server/dist/project-code-discovery.js +142 -0
- package/server/dist/project-git.js +19 -21
- package/server/dist/project-registry.js +272 -20
- package/server/dist/project-repositories.js +157 -0
- package/server/dist/project-repository-provenance.js +31 -0
- package/server/dist/project-router-background-processes.js +105 -0
- package/server/dist/project-router-git.js +75 -16
- package/server/dist/project-router-jobs.js +2 -126
- package/server/dist/project-router-loop-runs.js +72 -2
- package/server/dist/project-router-tickets.js +53 -8
- package/server/dist/project-router.js +239 -38
- package/server/dist/provider-detection.js +18 -6
- package/server/dist/provider-limit.js +64 -0
- package/server/dist/providers/claude-adapter.js +26 -1
- package/server/dist/providers/claude-background-tasks.js +18 -0
- package/server/dist/providers/claude-live-session.js +383 -0
- package/server/dist/providers/codex-adapter.js +19 -0
- package/server/dist/providers/codex-live-session.js +545 -0
- package/server/dist/providers/gemini-adapter.js +1 -0
- package/server/dist/providers/live-session-types.js +12 -0
- package/server/dist/providers/live-session.js +13 -0
- package/server/dist/providers/terminal-result.js +24 -0
- package/server/dist/queue-manager.js +2 -0
- package/server/dist/rail-isolated-launch.js +141 -16
- package/server/dist/rail-pr-decision.js +364 -99
- package/server/dist/rail-pr-store.js +24 -10
- package/server/dist/rail-worktree-release.js +34 -2
- package/server/dist/rail-worktrees-store.js +4 -4
- package/server/dist/rails-router.js +249 -55
- package/server/dist/repo-lock.js +92 -17
- package/server/dist/review-packet.js +23 -13
- package/server/dist/schemas/file-summary.v1.json +59 -59
- package/server/dist/schemas/profile.v1.json +137 -137
- package/server/dist/setup-manager.js +52 -8
- package/server/dist/shell-integration/bash-shim.bash +45 -0
- package/server/dist/shell-integration/fish-shim.fish +36 -0
- package/server/dist/shell-integration/powershell-shim.ps1 +48 -0
- package/server/dist/shell-integration/zsh-shim.zsh +47 -0
- package/server/dist/smash-runner.js +1 -0
- package/server/dist/spawn-lifecycle.js +44 -27
- package/server/dist/spec-contract-prompt.js +143 -0
- package/server/dist/spec-draft-parser.js +6 -1
- package/server/dist/spec-models.js +1 -0
- package/server/dist/stuck-run-detector.js +1 -0
- package/server/dist/terminal-manager.js +21 -1
- package/server/dist/terminal-shell-integration.js +4 -1
- package/server/dist/transient-children.js +619 -230
- package/server/dist/util/cli-prompt.js +78 -5
- package/server/dist/util/sqlite-migrations.js +20 -0
- package/server/dist/util/win-spawn.js +18 -3
- package/server/dist/util/windows-provider-shell.js +29 -0
- package/server/dist/verification-sentinel.js +14 -0
- package/server/dist/vitest-setup.js +2 -0
- package/server/dist/windows-job-supervisor.js +133 -0
- package/server/dist/workspace-manager.js +9 -30
- package/server/dist/worktree-manager.js +17 -2
- package/server/dist/worktree-overlay.js +3 -1
- package/client/dist/assets/ActivityFeedPage-tAQcWs1R.js +0 -1
- package/client/dist/assets/AgentBrowserCapture-BX8BNae5.js +0 -1
- package/client/dist/assets/AgentModeAnalyticsPane-BVAqCL0K.js +0 -2
- package/client/dist/assets/AgentModeCodePane-9XfqQc9c.js +0 -2
- package/client/dist/assets/AgentModeJobsPane-BCjLsPhc.js +0 -1
- package/client/dist/assets/AgentsPage-C8J_42sm.js +0 -87
- package/client/dist/assets/AnalyticsPage-BtQuyfJm.js +0 -1
- package/client/dist/assets/CodePage-BZ2MwdCu.js +0 -2
- package/client/dist/assets/DesktopAnalyticsPage-Bh_29V4g.js +0 -1
- package/client/dist/assets/ExportDropdown-BrtfWzEG.js +0 -1
- package/client/dist/assets/InteractiveJobComposer-BCZiSfzc.js +0 -19
- package/client/dist/assets/JobDetailModal-NAJmuYIT.js +0 -1
- package/client/dist/assets/JobDetailPage-fE0ZycUX.js +0 -1
- package/client/dist/assets/JobsPage-z5M_HVJG.js +0 -1
- package/client/dist/assets/LoopBuilderPage-j1FQS47c.js +0 -7
- package/client/dist/assets/LoopPreviewModal-DhDJjdCe.js +0 -1
- package/client/dist/assets/LoopsPage-Ll7zORZb.js +0 -1
- package/client/dist/assets/MinimizedChatsContext-Bd3OqR_S.js +0 -1
- package/client/dist/assets/PluginsPage-DN4kGvJt.js +0 -2
- package/client/dist/assets/ProjectSettingsDialog-OgsgxjzF.js +0 -1
- package/client/dist/assets/ReviewPacketPage-DFog4sXn.js +0 -1
- package/client/dist/assets/TemplatePreviewModal-L2XxqiOD.js +0 -1
- package/client/dist/assets/TicketDetailModal-CsF-AWZX.js +0 -14
- package/client/dist/assets/Trans-Bsz9_gyq.js +0 -1
- package/client/dist/assets/agent-BQgKv_2F.js +0 -1
- package/client/dist/assets/agent-C1NRDJqL.js +0 -1
- package/client/dist/assets/agent-CLNleiy6.js +0 -1
- package/client/dist/assets/agent-CmceArkQ.js +0 -1
- package/client/dist/assets/agent-D3UxQ3SR.js +0 -1
- package/client/dist/assets/agent-DB1JeE64.js +0 -1
- package/client/dist/assets/agent-DXkHcQ-D.js +0 -1
- package/client/dist/assets/agent-DjJJJ2M8.js +0 -1
- package/client/dist/assets/auth-D_5bQv5W.js +0 -1
- package/client/dist/assets/ban-E4EaZe3a.js +0 -1
- package/client/dist/assets/bot-DzuuuC5R.js +0 -1
- package/client/dist/assets/browser-BgqHDMXP.js +0 -1
- package/client/dist/assets/browser-CsKJtrpv.js +0 -1
- package/client/dist/assets/browser-Cu58EpZU.js +0 -1
- package/client/dist/assets/browser-CvXOJm-j.js +0 -1
- package/client/dist/assets/browser-DOrFh1c7.js +0 -1
- package/client/dist/assets/browser-DQv_Jo7x.js +0 -1
- package/client/dist/assets/browser-LPgxvJu2.js +0 -1
- package/client/dist/assets/browser-eL-3MIEI.js +0 -1
- package/client/dist/assets/builder-0IWtosUm.js +0 -1
- package/client/dist/assets/builder-Bf2N6XWn.js +0 -1
- package/client/dist/assets/builder-BnqaaBkT.js +0 -1
- package/client/dist/assets/builder-BxxfGgAO.js +0 -1
- package/client/dist/assets/builder-C5IIgWsq.js +0 -1
- package/client/dist/assets/builder-CHuahItu.js +0 -1
- package/client/dist/assets/builder-CjWosXL_.js +0 -1
- package/client/dist/assets/builder-CpCIOoKj.js +0 -1
- package/client/dist/assets/code-CHPkOkDS.js +0 -1
- package/client/dist/assets/commands-6tYQih5m.js +0 -1
- package/client/dist/assets/commands-BK2QinXN.js +0 -1
- package/client/dist/assets/commands-C2Nca76h.js +0 -1
- package/client/dist/assets/commands-CKdLihNX.js +0 -1
- package/client/dist/assets/commands-CYIBTAlc.js +0 -1
- package/client/dist/assets/commands-CjUtYJIM.js +0 -1
- package/client/dist/assets/commands-Cq_u_8y9.js +0 -1
- package/client/dist/assets/commands-D_ZHYQug.js +0 -1
- package/client/dist/assets/common-6MLbD-jM.js +0 -1
- package/client/dist/assets/common-BKGEu4rm.js +0 -1
- package/client/dist/assets/common-BNbnv8cE.js +0 -1
- package/client/dist/assets/common-BqGWtDbt.js +0 -1
- package/client/dist/assets/common-DBtTzeYm.js +0 -1
- package/client/dist/assets/common-DEW3Nr8n.js +0 -1
- package/client/dist/assets/common-DHsv9N5d.js +0 -1
- package/client/dist/assets/common-mkrEcW-Y.js +0 -1
- package/client/dist/assets/dashboard-B9GhC5ku.js +0 -1
- package/client/dist/assets/dashboard-CBnv6zOI.js +0 -1
- package/client/dist/assets/dashboard-CaP0fU87.js +0 -1
- package/client/dist/assets/dashboard-D4ZZ4x84.js +0 -1
- package/client/dist/assets/dashboard-DmuTQBX8.js +0 -1
- package/client/dist/assets/dashboard-DynLYj3d.js +0 -1
- package/client/dist/assets/dashboard-zj4gGFJ1.js +0 -1
- package/client/dist/assets/dialog-CdWCb02j.js +0 -45
- package/client/dist/assets/dist-bVqfYmby.js +0 -1
- package/client/dist/assets/dist-js-CWeUdf5Z.js +0 -1
- package/client/dist/assets/formatDistanceToNow-DQCvMgUc.js +0 -1
- package/client/dist/assets/getTimezoneOffsetInMilliseconds-C16cxSe1.js +0 -1
- package/client/dist/assets/git-refresh-wTW0rO0Z.js +0 -1
- package/client/dist/assets/i18n-hnX2DPmo.js +0 -2
- package/client/dist/assets/index-DIhMEAVw.js +0 -66
- package/client/dist/assets/index-DwygcU7s.css +0 -2
- package/client/dist/assets/mcp-B8X8wBLu.js +0 -1
- package/client/dist/assets/mcp-C2AojZZN.js +0 -1
- package/client/dist/assets/mcp-D8BT78_L.js +0 -1
- package/client/dist/assets/mcp-Df5RWBNk.js +0 -1
- package/client/dist/assets/mcp-Dj7BgMQW.js +0 -1
- package/client/dist/assets/mcp-Q7iT7rcz.js +0 -1
- package/client/dist/assets/mcp-YlvNvJbW.js +0 -1
- package/client/dist/assets/mcp-mKFpTSRb.js +0 -1
- package/client/dist/assets/narration-4Z2VUhZw.js +0 -1
- package/client/dist/assets/narration-BGuiEDj3.js +0 -1
- package/client/dist/assets/narration-BuSoqRmv.js +0 -1
- package/client/dist/assets/narration-CB9t29fy.js +0 -1
- package/client/dist/assets/narration-CU3x8FHD.js +0 -1
- package/client/dist/assets/narration-CWeXhfP5.js +0 -1
- package/client/dist/assets/narration-DRaDnhT5.js +0 -1
- package/client/dist/assets/narration-DtEbQgCw.js +0 -1
- package/client/dist/assets/nav-ApJVg3xu.js +0 -1
- package/client/dist/assets/nav-BKNky1Bg.js +0 -1
- package/client/dist/assets/nav-C6vWWKYx.js +0 -1
- package/client/dist/assets/nav-CXJ6Aw89.js +0 -1
- package/client/dist/assets/nav-CsmFBIDf.js +0 -1
- package/client/dist/assets/nav-DjkmQJjd.js +0 -1
- package/client/dist/assets/packet-B1IxaL5f.js +0 -1
- package/client/dist/assets/packet-Bh5kkbiB.js +0 -1
- package/client/dist/assets/packet-By8fqYxW.js +0 -1
- package/client/dist/assets/packet-CZdvA44E.js +0 -1
- package/client/dist/assets/packet-CrjHRQCP.js +0 -1
- package/client/dist/assets/packet-Dwi2pTtx.js +0 -1
- package/client/dist/assets/packet-_-ZIa0IR.js +0 -1
- package/client/dist/assets/packet-n0W6E1Hn.js +0 -1
- package/client/dist/assets/play-DNlrawbS.js +0 -1
- package/client/dist/assets/provider-capabilities-Doej9lfa.js +0 -1
- package/client/dist/assets/settings-Bd0x4TBa.js +0 -1
- package/client/dist/assets/settings-C1-7cXzC.js +0 -1
- package/client/dist/assets/settings-CAFaT38b.js +0 -1
- package/client/dist/assets/settings-Ct3v1nW2.js +0 -1
- package/client/dist/assets/settings-DHh7_IF5.js +0 -1
- package/client/dist/assets/settings-DQXAmdcv.js +0 -1
- package/client/dist/assets/settings-guzlhpup.js +0 -1
- package/client/dist/assets/settings-sZfTPMEH.js +0 -1
- package/client/dist/assets/setup-3jWaoVUO.js +0 -1
- package/client/dist/assets/setup-BjgRneb2.js +0 -1
- package/client/dist/assets/setup-BzFIjv-f.js +0 -1
- package/client/dist/assets/setup-C4VfQsxE.js +0 -1
- package/client/dist/assets/setup-DfUkpDbN.js +0 -1
- package/client/dist/assets/setup-ECe90Pmu.js +0 -1
- package/client/dist/assets/setup-dlqC4Jmm.js +0 -1
- package/client/dist/assets/setup-jwfLMiM2.js +0 -1
- package/client/dist/assets/spending-EC9xqio-.js +0 -1
- package/client/dist/assets/useDesktop-BQVt8lFd.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{f as a,u as o}from"./chunk-KS7C4IRE-DEKu087k.js";import{w as s}from"./i18n-hnX2DPmo.js";import{n as c,t as l}from"./createLucideIcon-Bjbbp_KS.js";import{n as u}from"./dist-bVqfYmby.js";import{X as d,et as f,nt as p,o as m,tt as h}from"./TicketDetailModal-CsF-AWZX.js";import{c as g,l as _,u as v}from"./MinimizedChatsContext-Bd3OqR_S.js";import{n as y,t as b}from"./file-text-BcLCfcWZ.js";import{t as x}from"./sparkles-DrY8hb0X.js";import{t as S}from"./x-CBMI9ejn.js";import{a as C,i as w,r as T}from"./useDesktop-BQVt8lFd.js";import{c as E,s as D}from"./dialog-CdWCb02j.js";import{t as O}from"./utils-BC4DHlz2.js";import{c as k}from"./provider-capabilities-Doej9lfa.js";import{n as A,t as j}from"./lib-CGdyxIWg.js";import{Ct as M,bt as N,v as P,xt as F}from"./index-DIhMEAVw.js";var I=l(`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`}]]),L=e(t(),1),R=e(r(),1);function z(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 B(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 V(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var ee=(e,t)=>Math.abs(e-t)<1.01,te=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},H,ne=()=>{if(H!==void 0)return H;if(typeof navigator>`u`)return H=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return H=!0;let e=navigator.maxTouchPoints;return H=navigator.platform===`MacIntel`&&e!==void 0&&e>0},re=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},ie=e=>e,ae=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},oe=(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(re(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(re(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:te(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)}},se=(e,t)=>G(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),ce=(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`]},K=(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})},q=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:ie,rangeExtractor:ae,onChange:()=>{},measureElement:ce,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=B(()=>(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,!(!ne()||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=B(()=>[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=B(()=>[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=z(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=B(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Y({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=B(()=>{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))&&(ne()&&(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=B(()=>[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 V(t[J(0,t.length-1,r?e=>n[e*2]:e=>V(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&&ee(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()}},J=(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 Y({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=J(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 X=typeof document<`u`?L.useLayoutEffect:L.useEffect;function le({useFlushSync:e=!0,...t}){let n=L.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,R.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=L.useState(()=>new q(r));return i.setOptions(r),X(()=>i._didMount(),[]),X(()=>i._willUpdate()),i}function ue(e){return le({observeElementRect:oe,observeElementOffset:se,scrollToFn:K,...e})}var Z=n(),de=e=>`specrails-desktop:code-tree-filter:${e}`,fe=e=>`specrails-desktop:code-tree-collapsed:${e}`;function pe(e){return e.split(`/`).length-1}function me(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function he(e){return e?e.length>10?e.slice(0,10):e:null}function ge(e){return e===`created`?`added`:e===`modified`?`changed`:e===`deleted`?`deleted`:null}function _e(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 ve({onOpenFile:e,selectedPath:t,filterJobId:n,filterTicketId:r}){let{t:i}=c(`code`),{activeProjectId:a}=T(),{openTicketDetail:o}=m(),{registerHandler:l,unregisterHandler:u}=s(),[d,p]=(0,L.useState)(()=>{if(!a)return`touched-by-ai`;try{let e=localStorage.getItem(de(a));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`touched-by-ai`});(0,L.useEffect)(()=>{if(a)try{localStorage.setItem(de(a),d)}catch{}},[d,a]);let[h,g]=(0,L.useState)(()=>{if(!a)return new Set;try{let e=localStorage.getItem(fe(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,L.useEffect)(()=>{if(a)try{localStorage.setItem(fe(a),JSON.stringify([...h]))}catch{}},[h,a]);let _=(0,L.useCallback)(e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),b=(0,L.useCallback)(()=>{g(new Set)},[]),{data:x,refresh:S,isFirstLoad:E}=w({namespace:`code-tree:${d}:${d===`touched-by-ai`?`${n??`all-jobs`}:${r??`all-specs`}`:`all`}`,projectId:a,initialValue:[],fetcher:(0,L.useCallback)(async()=>{let e=[],t=null;for(let i=0;i<100;i+=1){let i=new URLSearchParams({withProvenance:`1`,filter:d});d===`touched-by-ai`&&n&&i.set(`jobId`,n),d===`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},[d,n,r])}),D=(0,L.useRef)(a);(0,L.useEffect)(()=>{D.current=a},[a]),(0,L.useEffect)(()=>{if(!a)return;let e=`code-tree-${a}`;return l(e,e=>{let t=e;t.projectId===D.current&&t.type===`file.provenance_updated`&&S()}),()=>u(e)},[a,l,u,S]);let k=(0,L.useRef)(null),A=(0,L.useMemo)(()=>(x??[]).filter(e=>!_e(e.path,h)),[x,h]),j=(0,L.useCallback)(()=>{g(new Set((x??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[x]),P=ue({count:A.length,getScrollElement:()=>k.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()=>{}}}),I=A.length===0,R=(0,L.useMemo)(()=>(x??[]).filter(e=>e.kind===`file`).length,[x]);return(0,Z.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`file-tree`,children:[(0,Z.jsxs)(`div`,{className:`px-2 py-2 border-b border-border text-xs space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>p(`touched-by-ai`),className:O(`px-2 py-1 rounded-md transition-colors`,d===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":d===`touched-by-ai`,children:i(n?`tree.jobFiles`:r?`tree.specFiles`:`tree.touchedByAi`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>p(`all`),className:O(`px-2 py-1 rounded-md transition-colors`,d===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":d===`all`,children:i(`tree.allFiles`)}),(0,Z.jsx)(`div`,{className:`flex-1`}),(0,Z.jsx)(`button`,{type:`button`,onClick:j,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,Z.jsx)(y,{className:`w-3.5 h-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:b,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,Z.jsx)(v,{className:`w-3.5 h-3.5`})})]}),d===`touched-by-ai`&&R>0&&(0,Z.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,Z.jsx)(`span`,{children:i(`tree.touchedCount`,{count:R})})})]}),I&&E?(0,Z.jsx)(`div`,{className:`flex-1 flex items-center justify-center px-4 text-center`,"data-testid":`file-tree-loading`,children:(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground animate-pulse`,children:i(`tree.loadingFiles`)})}):I&&d===`touched-by-ai`?(0,Z.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-4 text-center gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`tree.emptyTouched`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>p(`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`)})]}):I?(0,Z.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:i(`tree.noFiles`)}):(0,Z.jsx)(`div`,{ref:k,className:`flex-1 overflow-auto`,"data-testid":`file-tree-scroller`,children:(0,Z.jsx)(`div`,{style:{height:P.getTotalSize(),position:`relative`,width:`100%`},children:P.getVirtualItems().map(n=>{let r=A[n.index],a=pe(r.path)*12,s=r.kind===`file`&&r.path===t,c=r.provenance?.createdByTicketId,l=r.provenance?.modifiedByTicketIds??[],u=r.provenance?.latest??null,d=he(u?.jobId),p=ge(u?.kind),m=r.kind===`dir`,g=m&&h.has(r.path),b=r.provenance?.touchedFileCount??0;return(0,Z.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateY(${n.start}px)`,height:n.size,width:`100%`},className:O(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,s&&`bg-muted text-foreground`),onClick:()=>{m?_(r.path):e(r.path)},onKeyDown:t=>{t.target===t.currentTarget&&(t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),m?_(r.path):e(r.path)))},role:`button`,tabIndex:0,"aria-expanded":m?!g:void 0,"data-testid":`file-tree-row-${r.path}`,children:[(0,Z.jsxs)(`span`,{style:{paddingLeft:a},className:`flex items-center gap-1 min-w-0 flex-1`,children:[m?(0,Z.jsxs)(Z.Fragment,{children:[g?(0,Z.jsx)(y,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,Z.jsx)(v,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),g?(0,Z.jsx)(N,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,Z.jsx)(F,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`w-3 flex-shrink-0`}),(0,Z.jsx)(M,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,Z.jsx)(`span`,{className:`truncate ml-0.5`,children:me(r.path)})]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[m&&b>0&&(0,Z.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}),!m&&p&&(0,Z.jsx)(`span`,{className:O(`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.${p}`)}),!m&&d&&(0,Z.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,Z.jsx)(f,{className:`h-3 w-3`}),d]}),!m&&typeof c==`number`&&(0,Z.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]}),!m&&l.slice(0,2).map(e=>(0,Z.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 ye(e){return new Worker(`/assets/editor.worker-tytyn86m.js`,{name:e?.name})}function be(e){return new Worker(`/assets/json.worker-Oa9UrkKE.js`,{name:e?.name})}function xe(e){return new Worker(`/assets/css.worker-yKcq13f2.js`,{name:e?.name})}function Se(e){return new Worker(`/assets/html.worker-DSJ9zmd7.js`,{name:e?.name})}function Ce(e){return new Worker(`/assets/ts.worker-BtjBFNHX.js`,{name:e?.name})}var we=!1;function Te(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=Te(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 Ee(e){return`specrails-${e}`}function De(e,t){let n=Ee(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 Oe(){we||=(self.MonacoEnvironment={getWorker(e,t){switch(t){case`json`:return new be;case`css`:case`scss`:case`less`:return new xe;case`html`:case`handlebars`:case`razor`:return new Se;case`typescript`:case`javascript`:return new Ce;default:return new ye}}},!0)}function ke({content:e,language:t,readOnly:n,onChange:r}){let{t:a}=c(`code`),o=P(),s=(0,L.useRef)(null),l=(0,L.useRef)(null),u=(0,L.useRef)(null),[d,f]=(0,L.useState)(!1),p=(0,L.useRef)(e),m=(0,L.useRef)(t),h=(0,L.useRef)(o),g=(0,L.useRef)(n),_=(0,L.useRef)(r);return(0,L.useEffect)(()=>{p.current=e},[e]),(0,L.useEffect)(()=>{m.current=t},[t]),(0,L.useEffect)(()=>{h.current=o},[o]),(0,L.useEffect)(()=>{g.current=n},[n]),(0,L.useEffect)(()=>{_.current=r},[r]),(0,L.useEffect)(()=>{let e=!1;return Oe(),i(()=>import(`./editor.main-DxrmGfoq.js`).then(t=>{if(e||!s.current)return;u.current=t;let n=De(t,h.current),r=t.editor.create(s.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,L.useEffect)(()=>{let t=l.current;t&&t.getValue?.()!==e&&t.setValue?.(e)},[e]),(0,L.useEffect)(()=>{l.current?.updateOptions?.({readOnly:n})},[n]),(0,L.useEffect)(()=>{let e=u.current,n=l.current;if(!e||!n)return;let r=n.getModel?.();r&&e.editor.setModelLanguage(r,t)},[t]),(0,L.useEffect)(()=>{let e=u.current;if(!e)return;let t=De(e,o);e.editor.setTheme(t)},[o]),d?(0,Z.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,Z.jsx)(`span`,{children:a(`monaco.loadFailed`)}),(0,Z.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,Z.jsx)(`div`,{ref:s,className:`w-full h-full`,"data-testid":`monaco-host`})}var Ae=(0,L.lazy)(async()=>({default:ke}));function je({content:e,language:t,readOnly:n=!0,onChange:r}){let{t:i}=c(`code`);return(0,Z.jsx)(L.Suspense,{fallback:(0,Z.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,Z.jsx)(Ae,{content:e,language:t,readOnly:n,onChange:r})})}function Me(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 Ne({path:e,summary:t,stale:n,regenerating:r,generateDisabledReason:i,onCollapse:a}){let{t:o,i18n:s}=c(`code`),{openTicketDetail:l}=m();if(!t)return(0,Z.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header-empty`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?o(`summary.unavailable`,{reason:i}):o(`summary.empty`)})]}),a&&(0,Z.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,Z.jsx)(_,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})});let u=Me(t.generatedAt,s.language),d=t.triggeredBy?.ticketId,f=t.triggeredBy?.modifiedTicketIds??[];return(0,Z.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),n&&(0,Z.jsx)(`span`,{className:O(`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,Z.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent-primary animate-pulse`,"aria-hidden":!0})]}),(0,Z.jsx)(`p`,{className:`text-sm text-foreground mt-1`,children:t.summary}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 flex-wrap`,children:[typeof d==`number`&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>l(d),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,d]}),f.map(e=>(0,Z.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,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:u})]})]}),a&&(0,Z.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,Z.jsx)(_,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})})}function Pe({content:e}){return(0,Z.jsx)(A,{remarkPlugins:[j],children:e})}var Fe={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 Ie(e){return e===`created`?h:e===`deleted`?p:b}function Le({relPath:e,height:t,onOpenTicket:n,onFilterJob:r}){let{t:i}=c(`code`),{activeProjectId:a,projects:o}=T(),l=o.find(e=>e.id===a)?.provider,d=k(l),{registerHandler:f,unregisterHandler:p}=s(),[m,h]=(0,L.useState)(null),[g,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)({}),b=(0,L.useRef)(a);(0,L.useEffect)(()=>{b.current=a},[a]);let x=(0,L.useRef)(e);(0,L.useEffect)(()=>{x.current=e},[e]);let S=(0,L.useRef)(0),w=(0,L.useCallback)(async()=>{let t=++S.current;try{let n=await fetch(`${C()}/code/file/story?path=${encodeURIComponent(e)}`);if(t!==S.current)return;if(!n.ok){h([]),_(!0);return}let r=await n.json();if(t!==S.current)return;h(Array.isArray(r.story)?r.story:[]),_(!1)}catch{t===S.current&&(h([]),_(!0))}},[e,a]);(0,L.useEffect)(()=>{h(null),y({}),w()},[w]),(0,L.useEffect)(()=>{if(!a)return;let e=`code-story-${a}`;return f(e,e=>{let t=e;t.projectId===b.current&&t.path===x.current&&(t.type===`file.story_updated`||t.type===`file.provenance_updated`)&&w()}),()=>p(e)},[a,f,p,w]);let E=(0,L.useCallback)(async(t,n)=>{if(d){y(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`){y(e=>({...e,[t.provenanceId]:`budget`}));return}if(!r.ok||!a.ok){u.error(i(`story.explainFailed`)),y(e=>{let n={...e};return delete n[t.provenanceId],n});return}await w(),y(e=>{let n={...e};return delete n[t.provenanceId],n})}catch{u.error(i(`story.explainFailed`)),y(e=>{let n={...e};return delete n[t.provenanceId],n})}}},[d,w,e,i]);return(0,Z.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,Z.jsx)(`div`,{className:`h-full overflow-auto`,children:m===null?(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground animate-pulse py-2`,children:i(`story.loading`)}):g?(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-failed`,children:i(`story.loadFailed`)}):m.length===0?(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-empty`,children:i(`story.empty`)}):(0,Z.jsx)(`ol`,{className:`relative ml-1.5 border-l border-border/60 space-y-3 py-1`,children:m.map(e=>(0,Z.jsx)(Re,{entry:e,state:v[e.provenanceId],canExplain:d,onOpenTicket:n,onFilterJob:r,onExplain:t=>{E(e,t)}},e.provenanceId))})})})}function Re({entry:e,state:t,canExplain:n,onOpenTicket:r,onFilterJob:i,onExplain:a}){let{t:o}=c(`code`),s=Ie(e.kind),l=e.ticket?.status??null,u=e.ticket?.title?`#${e.ticket.id} · ${e.ticket.title}`:e.ticketId==null?null:o(`story.spec`,{ticketId:e.ticketId}),d=e.ticketId==null?`${e.kind}NoSpec`:e.kind;return(0,Z.jsxs)(`li`,{className:`relative pl-4`,"data-testid":`story-card`,children:[(0,Z.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,Z.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,Z.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(s,{className:`h-3.5 w-3.5 shrink-0`}),o(`story.kindLabel.${e.kind}`)]}),u!=null&&e.ticketId!=null&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>r(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:o(`story.openSpec`,{ticketId:e.ticketId}),children:u}),u==null&&(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:o(`story.unknownSpec`)}),l&&(0,Z.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] ${Fe[l]??`bg-muted/60 text-muted-foreground`}`,"data-testid":`story-status-pill`,children:l}),(0,Z.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-2`,children:[e.addedLines!=null&&e.addedLines>0&&(0,Z.jsxs)(`span`,{className:`font-mono text-[10px] text-accent-success`,title:o(`story.linesAdded`),children:[`+`,e.addedLines]}),e.removedLines!=null&&e.removedLines>0&&(0,Z.jsxs)(`span`,{className:`font-mono text-[10px] text-destructive`,title:o(`story.linesRemoved`),children:[`−`,e.removedLines]}),(0,Z.jsx)(`time`,{className:`text-[10px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]})]}),(0,Z.jsx)(`div`,{className:`mt-1.5`,children:e.summary?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-foreground/90`,"data-testid":`story-contribution`,children:e.summary}),e.summaryModel&&(0,Z.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/80`,children:o(`story.explainedBy`,{model:e.summaryModel})})]}):(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`story-fallback`,children:o(`story.fallback.${d}`)}),n?t===`budget`?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] text-accent-warning`,children:o(`story.budgetReached`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`rounded bg-accent-warning/15 px-1.5 py-0.5 text-[10px] text-accent-warning hover:bg-accent-warning/25`,children:o(`story.generateAnyway`)})]}):(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>a(!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,Z.jsx)(x,{className:t===`busy`?`h-3 w-3 animate-pulse`:`h-3 w-3`}),o(t===`busy`?`story.explaining`:`story.explain`)]}):(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,"data-testid":`story-explain-unavailable`,children:o(`story.explainUnavailable`)})]})}),e.jobId&&i&&(0,Z.jsx)(`footer`,{className:`mt-1.5`,children:(0,Z.jsx)(`button`,{type:`button`,onClick:()=>i(e.jobId),className:`font-mono text-[10px] text-muted-foreground hover:text-foreground`,title:o(`history.filterByJob`,{jobId:e.jobId}),children:e.jobId.length>12?e.jobId.slice(0,12):e.jobId})})]})]})}function ze(e,t){return t===`markdown`||t===`md`||/\.(md|mdx|markdown)$/i.test(e)}var Be=180,Ve=120,He=240;function Ue(e){return e?`specrails-desktop:code-summary-collapsed:${e}`:null}function We(e){return e?`specrails-desktop:code-history-height:${e}`:null}function Ge(e){return e?`specrails-desktop:code-history-collapsed:${e}`:null}function Ke(e){return e?`specrails-desktop:code-history-mode:${e}`:null}function qe(e){let t=Ke(e);if(!t)return`story`;try{return localStorage.getItem(t)===`log`?`log`:`story`}catch{return`story`}}function Je(e,t){let n=Ke(e);if(n)try{localStorage.setItem(n,t)}catch{}}function Ye(e){let t=We(e);if(!t)return Be;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:Be}catch{return Be}}function Xe(e,t){let n=We(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function Ze(e){let t=Ue(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function Qe(e,t){let n=Ue(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function $e(e){let t=Ge(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function et(e,t){let n=Ge(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function tt(e,t){let n=Math.max(Ve,t-He);return Math.min(Math.max(e,Ve),n)}function nt({relPath:e,onFilterJob:t,onSummaryActionChange:n,onCopyPathActionChange:r}){let{t:i}=c(`code`),{activeProjectId:a,projects:o}=T(),l=o.find(e=>e.id===a)?.provider,d=k(l),{openTicketDetail:f}=m(),{registerHandler:p,unregisterHandler:h}=s(),g=E({allowMove:!1}),y=(0,L.useRef)(null),[b,x]=(0,L.useState)(null),[S,w]=(0,L.useState)(!0),[O,A]=(0,L.useState)(!1),[j,M]=(0,L.useState)(!1),[N,P]=(0,L.useState)(()=>Ze(a)),[F,I]=(0,L.useState)(()=>Ye(a)),[z,B]=(0,L.useState)(()=>$e(a)),[V,ee]=(0,L.useState)(()=>qe(a)),te=(0,L.useRef)(a);(0,L.useEffect)(()=>{te.current=a},[a]);let H=(0,L.useRef)(e);(0,L.useEffect)(()=>{H.current=e},[e]),(0,L.useEffect)(()=>{let e=y.current?.clientHeight||window.innerHeight;P(Ze(a)),I(tt(Ye(a),e)),B($e(a)),ee(qe(a))},[a]);let ne=(0,L.useCallback)(e=>{let t=e.clientY,n=F,r=y.current?.clientHeight||window.innerHeight,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function o(e){I(tt(n+(t-e.clientY),r))}function s(){window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),I(e=>{let t=tt(e,r);return Xe(a,t),t})}window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[a,F]),re=(0,L.useCallback)(()=>{let e=tt(Be,y.current?.clientHeight||window.innerHeight);I(e),Xe(a,e)},[a]),ie=(0,L.useCallback)(()=>{P(e=>{let t=!e;return Qe(a,t),t})},[a]),ae=(0,L.useCallback)(()=>{B(e=>{let t=!e;return et(a,t),t})},[a]),oe=(0,L.useCallback)(e=>{ee(e),Je(a,e)},[a]);(0,L.useEffect)(()=>{A(!1),M(!1),q(`preview`),Y(!1)},[e]);let U=(0,L.useRef)(0),W=(0,L.useCallback)(async()=>{let t=++U.current;w(!0);try{let n=await fetch(`${C()}/code/file?path=${encodeURIComponent(e)}`);if(t!==U.current)return;if(!n.ok){x(null);return}let r=await n.json();if(t!==U.current)return;x(r)}catch{t===U.current&&x(null)}finally{t===U.current&&w(!1)}},[e,a]);(0,L.useEffect)(()=>{W()},[W]),(0,L.useEffect)(()=>{if(!a)return;let e=`code-file-${a}`;return p(e,e=>{let t=e;t.projectId===te.current&&(t.type===`file.summary_updated`&&t.path===H.current?(A(!1),W()):t.type===`file.summary_failed`&&t.path===H.current?(u.error(t.reason??i(`summary.generationFailed`)),A(!1)):t.type===`file.summary_skipped`&&t.path===H.current&&(t.reason&&u(i(`summary.skipped`,{reason:t.reason})),A(!1)))}),()=>h(e)},[a,p,h,W,i]);let G=(0,L.useCallback)(async t=>{if(d){A(!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){A(!1);let e=typeof r.skipped==`string`?r.skipped:null;u.error(e?i(`summary.skipped`,{reason:e}):i(`summary.generationFailed`));return}if(r.skipped===`budget`){A(!1),M(!0);return}if(r.skipped){A(!1),u(i(`summary.skipped`,{reason:r.skipped}));return}await W(),A(!1)}catch{A(!1),u.error(i(`summary.generationFailed`))}}},[d,W,e,i]),se=(0,L.useCallback)(async()=>{let t=b?.absolutePath??e;try{await navigator.clipboard?.writeText(t),u.success(i(`viewer.pathCopied`))}catch{u.error(i(`viewer.copyPathFailed`))}},[b,e,i]),ce=(0,L.useMemo)(()=>ze(e,b?.language),[e,b?.language]),[K,q]=(0,L.useState)(`preview`),[J,Y]=(0,L.useState)(!1),[X,le]=(0,L.useState)(``),[ue,de]=(0,L.useState)(!1),fe=b?.content!==void 0&&!b.binary&&!b.tooLarge&&b.reason!==`not-found`,pe=(0,L.useCallback)(()=>{le(b?.content??``),q(`raw`),Y(!0)},[b]),me=(0,L.useCallback)(async()=>{de(!0);try{let t=await fetch(`${C()}/code/file`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e,content:X})});if(!t.ok){let e=await t.json().catch(()=>({}));u.error(e.error??i(`viewer.saveFailed`));return}u.success(i(`viewer.saved`)),Y(!1),W()}catch{u.error(i(`viewer.saveFailed`))}finally{de(!1)}},[e,X,i,W]),he=b?.summary??null,ge=!!b?.summaryStale,_e=b?.provenance??[],ve=b?.reason===`not-found`,ye=d?ve?i(`summary.reason.missing`):b?.binary?i(`summary.reason.binary`):b?.tooLarge?i(`summary.reason.tooLarge`):null:i(`summary.reason.providerNoPureOutput`);return(0,L.useEffect)(()=>{if(n){if(S&&!b){n(null);return}return n({hasSummary:!!he,regenerating:O,disabledReason:ye,onClick:()=>G(!1)}),()=>n(null)}},[b,G,S,n,O,he,ye]),(0,L.useEffect)(()=>{if(r){if(S&&!b){r(null);return}return r({onClick:se}),()=>r(null)}},[se,b,S,r]),S&&!b?(0,Z.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:i(`viewer.loadingFile`)}):(0,Z.jsxs)(`div`,{ref:y,className:`flex flex-col h-full`,"data-testid":`file-viewer`,children:[N?(0,Z.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,Z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,Z.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,Z.jsx)(v,{className:`h-3.5 w-3.5`}),i(`viewer.showSummary`)]})]}):(0,Z.jsx)(Ne,{path:e,summary:he,stale:ge,regenerating:O,generateDisabledReason:ye,onCollapse:ie}),(0,Z.jsxs)(`div`,{className:`px-4 py-1 border-b border-border flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:ce&&b?.content!==void 0&&!b.binary&&!b.tooLarge&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,role:`group`,"aria-label":i(`viewer.markdownViewMode`),children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>q(`preview`),"aria-pressed":K===`preview`,className:K===`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,Z.jsx)(`button`,{type:`button`,onClick:()=>q(`raw`),"aria-pressed":K===`raw`,className:K===`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,Z.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] shrink-0`,children:[fe&&!J&&(0,Z.jsx)(`button`,{type:`button`,onClick:pe,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:i(`viewer.edit`)}),J&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>Y(!1),disabled:ue,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,Z.jsx)(`button`,{type:`button`,onClick:me,disabled:ue,className:`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-50`,children:i(ue?`viewer.saving`:`viewer.save`)})]})]})]}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:ve?(0,Z.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-missing`,children:i(`viewer.missingFile`)}):b?.binary?(0,Z.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-binary`,children:i(`viewer.binaryFile`)}):b?.tooLarge?(0,Z.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((b.sizeBytes??0)/1024/1024)})}):b?.content===void 0?(0,Z.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:i(`viewer.noContent`)}):J?(0,Z.jsx)(je,{content:X,language:b.language??`plaintext`,readOnly:!1,onChange:le}):ce&&K===`preview`?(0,Z.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,Z.jsx)(Pe,{content:b.content})}):(0,Z.jsx)(je,{content:b.content,language:b.language??`plaintext`})}),_e.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":i(`history.resize`),onPointerDown:z?void 0:ne,onDoubleClick:z?void 0:re,className:z?`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:z?void 0:i(`resizer.hint`),"data-testid":`code-history-resizer`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:i(V===`story`?`story.title`:`history.title`,{count:_e.length})}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[!z&&(0,Z.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,Z.jsx)(`button`,{type:`button`,onClick:()=>oe(`story`),"aria-pressed":V===`story`,className:V===`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,Z.jsx)(`button`,{type:`button`,onClick:()=>oe(`log`),"aria-pressed":V===`log`,className:V===`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,Z.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:ae,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:[z?(0,Z.jsx)(_,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(v,{className:`h-3.5 w-3.5`}),i(z?`history.show`:`history.hide`)]})]})]}),!z&&(V===`story`?(0,Z.jsx)(Le,{relPath:e,height:F,onOpenTicket:f,onFilterJob:t}):(0,Z.jsx)(rt,{rows:_e,onOpenTicket:f,onFilterJob:t,height:F}))]}),j&&(0,R.createPortal)((0,Z.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:g.guardBackdrop(()=>M(!1)),children:[(0,Z.jsxs)(`div`,{ref:g.panelRef,onClick:e=>e.stopPropagation(),className:`bg-card border border-border rounded-lg p-4 w-80 flex flex-col gap-3`,style:g.panelStyle,children:[(0,Z.jsx)(`p`,{className:`text-sm text-foreground`,children:i(`viewer.budgetPrompt`)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>M(!1),className:`text-xs px-3 py-1.5 rounded-md text-muted-foreground hover:text-foreground`,children:i(`common:actions.cancel`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{M(!1),G(!0)},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white`,children:i(`common:actions.confirm`)})]})]}),(0,Z.jsx)(D,{handles:g.resizeHandles})]}),document.body)]})}function rt({rows:e,onOpenTicket:t,onFilterJob:n,height:r}){let{t:i}=c(`code`),[a,o]=(0,L.useState)(null),[s,l]=(0,L.useState)({});if(e.length===0)return null;async function u(e,t){if(a===t){o(null);return}if(o(t),!(!e.jobId||s[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,Z.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,Z.jsx)(`div`,{className:`h-full overflow-auto space-y-1`,children:e.map((e,r)=>{let o=e.kind===`created`?h:e.kind===`deleted`?p:b,c=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=s[l];return(0,Z.jsxs)(`div`,{className:`rounded-md hover:bg-muted/40`,children:[(0,Z.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,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,Z.jsx)(o,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Z.jsx)(`span`,{className:`capitalize`,children:i(`kind.${e.kind}`)})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0 text-muted-foreground`,children:[(0,Z.jsx)(f,{className:`h-3.5 w-3.5 shrink-0`}),e.jobId&&n?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>n(e.jobId),className:`font-mono truncate hover:text-foreground`,title:i(`history.filterByJob`,{jobId:e.jobId}),children:c}):(0,Z.jsx)(`span`,{className:`font-mono truncate`,title:e.jobId??void 0,children:c}),e.jobId&&(0,Z.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,Z.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,Z.jsx)(`time`,{className:`text-[11px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]}),a===l&&(0,Z.jsx)(`div`,{className:`px-2 pb-2`,children:d===`loading`?(0,Z.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,Z.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:i(`history.diffUnavailable`)}):(0,Z.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 it=320,at=240,ot=520;function st(e){return e?`specrails-desktop:code-tree-width:${e}`:null}function ct(e){let t=st(e);if(!t)return it;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:it}catch{return it}}function lt(e,t){let n=st(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function $(e,t){let n=Math.max(at,t-ot);return Math.min(Math.max(e,at),n)}function ut({embedded:e=!1,initialPath:t=null,onSelectedPathChange:n}={}){let{t:r}=c(`code`),{activeProjectId:i}=T(),[s]=a(),l=o(),u=(0,L.useRef)(null),[d,f]=(0,L.useState)(e?t:s.get(`path`)),p=(0,L.useCallback)(e=>{f(e),n?.(e)},[n]),[m,h]=(0,L.useState)(null),[g,_]=(0,L.useState)(null),[v,y]=(0,L.useState)(()=>ct(i)),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(null),w=e?b:s.get(`jobId`),E=(0,L.useMemo)(()=>{if(e)return S;let t=s.get(`ticketId`);if(!t)return null;let n=Number(t);return Number.isInteger(n)&&n>0?n:null},[e,S,s]),[D,O]=(0,L.useState)(E==null?``:String(E));(0,L.useEffect)(()=>{if(e)return;let t=s.get(`path`);t!==d&&f(t)},[s,e]),(0,L.useEffect)(()=>{O(E==null?``:String(E))},[E]),(0,L.useEffect)(()=>{let e=u.current?.clientWidth||window.innerWidth;y($(ct(i),e))},[i]),(0,L.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 k=(0,L.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 lt(i,t),t})}window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[i,v]),A=(0,L.useCallback)(()=>{let e=$(it,u.current?.clientWidth||window.innerWidth);y(e),lt(i,e)},[i]),j=(0,L.useCallback)(t=>{if(p(t),e)return;let n=new URLSearchParams(s);n.set(`path`,t),l({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,l,s,p]),M=(0,L.useCallback)(t=>{if(e){x(t),C(null);return}let n=new URLSearchParams(s);n.set(`jobId`,t),n.delete(`ticketId`),l({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,l,s]),N=(0,L.useCallback)(()=>{if(e){x(null),C(null);return}let t=new URLSearchParams(s);t.delete(`jobId`),t.delete(`ticketId`),l({pathname:`/code`,search:t.toString()?`?${t.toString()}`:``},{replace:!0})},[e,l,s]),P=(0,L.useCallback)(t=>{let n=Number(t.trim());if(!Number.isInteger(n)||n<=0){N();return}if(e){C(n),x(null);return}let r=new URLSearchParams(s);r.set(`ticketId`,String(n)),r.delete(`jobId`),l({pathname:`/code`,search:`?${r.toString()}`},{replace:!0})},[N,e,l,s]);return(0,Z.jsxs)(`div`,{ref:u,className:`flex h-full w-full`,"data-testid":`code-page`,children:[(0,Z.jsx)(`aside`,{className:`overflow-hidden flex flex-col shrink-0`,style:{width:v},children:(0,Z.jsx)(ve,{onOpenFile:j,selectedPath:d,filterJobId:w,filterTicketId:E},i??`no-project`)}),(0,Z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r(`page.resizeFileTree`),onPointerDown:k,onDoubleClick:A,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,Z.jsxs)(`main`,{className:`flex-1 overflow-hidden flex flex-col`,children:[(0,Z.jsx)(dt,{jobId:w,ticketId:E,ticketInput:D,onTicketInputChange:O,onApplyTicket:P,onClear:N,summaryAction:m,copyPathAction:g}),(w||E)&&(0,Z.jsx)(ft,{jobId:w,ticketId:E,onOpenFile:j}),d?(0,Z.jsx)(nt,{relPath:d,onFilterJob:M,onSummaryActionChange:h,onCopyPathActionChange:_}):(0,Z.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:r(`page.selectFile`)})]})]})}function dt({jobId:e,ticketId:t,ticketInput:n,onTicketInputChange:r,onApplyTicket:i,onClear:a,summaryAction:o,copyPathAction:s}){let{t:l}=c(`code`),u=t?`spec`:e?`job-context`:`all`;return(0,Z.jsx)(`div`,{className:`border-b border-border bg-background/80 px-4 py-2`,"data-testid":`code-provenance-toolbar`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(I,{className:`h-3.5 w-3.5`}),l(`toolbar.scope`)]}),(0,Z.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":u===`all`,className:u===`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,Z.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/70 bg-card/40 px-1 py-1`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>i(n),"aria-pressed":u===`spec`,className:u===`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,Z.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,Z.jsx)(`div`,{className:`flex-1`}),s&&(0,Z.jsx)(`button`,{type:`button`,onClick:s.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,Z.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,Z.jsx)(d,{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`)]}),u===`job-context`&&(0,Z.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,Z.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,Z.jsx)(S,{className:`h-3.5 w-3.5`}),l(`toolbar.clear`)]})]})})}function ft({jobId:e,ticketId:t,onOpenFile:n}){let{t:r}=c(`code`),[i,a]=(0,L.useState)(null);(0,L.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,L.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]),s=i?.length??0;return(0,Z.jsx)(`section`,{className:`border-b border-border bg-card/35 px-4 py-3`,"data-testid":`provenance-result-panel`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:e?r(`provenancePanel.jobTitle`,{jobId:e}):r(`provenancePanel.specTitle`,{ticketId:t})}),(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r(`provenancePanel.touchedFiles`,{count:s})})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,Z.jsx)(pt,{label:r(`action.added`),rows:o.created,icon:`created`,onOpenFile:n}),(0,Z.jsx)(pt,{label:r(`action.changed`),rows:o.modified,icon:`modified`,onOpenFile:n}),(0,Z.jsx)(pt,{label:r(`action.deleted`),rows:o.deleted,icon:`deleted`,onOpenFile:n})]})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:e&&(0,Z.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,Z.jsx)(g,{className:`h-3.5 w-3.5`}),r(`provenancePanel.log`)]})})]})})}function pt({label:e,rows:t,icon:n,onOpenFile:r}){return(0,Z.jsxs)(`details`,{className:`group min-w-[180px] max-w-[320px]`,children:[(0,Z.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,Z.jsx)(n===`created`?h:n===`deleted`?p:b,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:t.length})]}),t.length>0&&(0,Z.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,Z.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{ut 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{a as r,w as i}from"./i18n-hnX2DPmo.js";import{n as a,t as o}from"./createLucideIcon-Bjbbp_KS.js";import{t as s}from"./clsx-CjueKrWZ.js";import{t as c}from"./utils-BC4DHlz2.js";import{ct as l,v as u,y as d}from"./index-DIhMEAVw.js";import{$ as f,A as p,B as m,E as h,F as g,H as _,K as v,L as y,N as b,O as x,P as S,Q as C,R as w,S as T,T as ee,U as E,W as D,X as O,Y as te,Z as k,_ as ne,_t as A,a as re,c as ie,d as ae,dt as j,et as M,ft as oe,g as se,gt as ce,h as le,ht as ue,i as de,it as N,j as fe,k as pe,l as P,lt as F,mt as me,n as he,nt as I,o as ge,pt as L,q as R,r as z,rt as B,s as _e,t as ve,u as ye,ut as V,v as be,w as H,z as xe}from"./BarChart-nBOMNfiy.js";var Se=o(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),U=e(t());function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},W.apply(null,arguments)}var G=e=>{var{cx:t,cy:n,r,className:i}=e,a=s(`recharts-dot`,i);return j(t)&&j(n)&&j(r)?U.createElement(`circle`,W({},ce(e),N(e),{className:a,cx:t,cy:n,r})):null},Ce=[`points`];function K(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?K(Object(n),!0).forEach(function(t){we(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):K(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function we(e,t,n){return(t=Te(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Te(e){var t=Ee(e,`string`);return typeof t==`symbol`?t:t+``}function Ee(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J.apply(null,arguments)}function De(e,t){if(e==null)return{};var n,r,i=Oe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Oe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ke(e){var{option:t,dotProps:n,className:r}=e;if((0,U.isValidElement)(t))return(0,U.cloneElement)(t,n);if(typeof t==`function`)return t(n);var i=s(r,typeof t==`boolean`?``:t.className),a=n??{},{points:o}=a,c=De(a,Ce);return U.createElement(G,J({},c,{className:i}))}function Ae(e,t){return e==null?!1:t?!0:e.length===1}function je(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=y.scatter}=e;if(!Ae(t,n))return null;var u=H(n),d=ue(n),f=t.map((e,r)=>{var s=q(q(q({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return U.createElement(ke,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),m={};return s&&c!=null&&(m.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),U.createElement(p,{zIndex:l},U.createElement(L,J({className:r},m),f))}function Me(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Y(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Me(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Me(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return(t=Pe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Pe(e){var t=Fe(e,`string`);return typeof t==`symbol`?t:t+``}function Fe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Ie=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=Y(Y(Y({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),A(i)),N(i)),c=(0,U.isValidElement)(i)?(0,U.cloneElement)(i,s):typeof i==`function`?i(s):U.createElement(G,s);return U.createElement(L,{className:`recharts-active-dot`,clipPath:o},c)};function Le(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=y.activeDot}=e,s=I(fe),c=ye();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return V(l)?null:U.createElement(p,{zIndex:o},U.createElement(Ie,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var Re=(e,t,n,r)=>b(e,`xAxis`,t,r),ze=(e,t,n,r)=>S(e,`xAxis`,t,r),Be=(e,t,n,r)=>b(e,`yAxis`,n,r),Ve=(e,t,n,r)=>S(e,`yAxis`,n,r),He=M([E,Re,Be,ze,Ve],(e,t,n,r,i)=>f(e,`xAxis`)?te(t,r,!1):te(n,i,!1)),Ue=(e,t,n,r,i)=>i;function We(e){return e.type===`line`}var Ge=M([E,Re,Be,ze,Ve,M([g,Ue],(e,t)=>e.filter(We).find(e=>e.id===t)),He,w],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return gt({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Ke(e){var t=A(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var qe=[`id`],Je=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Ye=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function X(){return X=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(null,arguments)}function Xe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Xe(Object(n),!0).forEach(function(t){Ze(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xe(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ze(e,t,n){return(t=Qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qe(e){var t=$e(e,`string`);return typeof t==`symbol`?t:t+``}function $e(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Q(e,t){if(e==null)return{};var n,r,i=et(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function et(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var tt=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:k(n,t),payload:e}]},nt=U.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:oe,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:k(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return U.createElement(be,{tooltipEntrySettings:d})}),rt=(e,t)=>`${t}px ${e}px`;function it(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var at=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return rt(t,e);for(var i=Math.floor(e/r),a=e%r,o=[],s=0,c=0;s<n.length;c+=(l=n[s])??0,++s){var l,u=n[s];if(u!=null&&c+u>a){o=[...n.slice(0,s),a-c];break}}var d=o.length%2==0?[0,t]:[t];return[...it(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function ot(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=ce(Q(r,qe));return U.createElement(je,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function st(e){var{showLabels:t,children:n,points:r}=e,i=(0,U.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return U.createElement(ee,{value:t?i:void 0},n)}function ct(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=Z(Z({},me(Q(a,Je))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return U.createElement(U.Fragment,null,r?.length>1&&U.createElement(T,X({shapeType:`curve`,option:u},d,{pathRef:n})),U.createElement(ot,{points:r,clipPathId:t,props:a}))}function lt(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function ut(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:g,onAnimationEnd:_,onAnimationStart:v}=n,y=i.current,b=xe(o,`recharts-line-`),x=(0,U.useRef)(b),[S,C]=(0,U.useState)(!1),w=!S,T=(0,U.useCallback)(()=>{typeof _==`function`&&_(),C(!1)},[_]),ee=(0,U.useCallback)(()=>{typeof v==`function`&&v(),C(!0)},[v]),E=lt(r.current),D=(0,U.useRef)(0);x.current!==b&&(D.current=a.current,x.current=b);var O=D.current;return U.createElement(st,{points:o,showLabels:w},n.children,U.createElement(m,{animationId:b,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:T,onAnimationStart:ee,key:b},e=>{var l=F(O,E+O,e),u=Math.min(l,E),d=c?s?at(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):rt(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),y){var m=y.length/o.length,h=e===1?o:o.map((t,n)=>{var r=Math.floor(n*m);if(y[r]){var i=y[r];return Z(Z({},t),{},{x:F(i.x,t.x,e),y:F(i.y,t.y,e)})}return f?Z(Z({},t),{},{x:F(p*2,t.x,e),y:F(g/2,t.y,e)}):Z(Z({},t),{},{x:t.x,y:t.y})});return i.current=h,U.createElement(ct,{props:n,points:h,clipPathId:t,pathRef:r,strokeDasharray:d})}return U.createElement(ct,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),U.createElement(h,{label:n.label}))}function dt(e){var{clipPathId:t,props:n}=e,r=(0,U.useRef)(null),i=(0,U.useRef)(0),a=(0,U.useRef)(null);return U.createElement(ut,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var ft=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:C(e.payload,t)}),pt=class extends U.Component{render(){var{hide:e,dot:t,points:n,className:r,xAxisId:i,yAxisId:a,top:o,left:c,width:l,height:u,id:d,needClip:f,zIndex:m}=this.props;if(e)return null;var h=s(`recharts-line`,r),g=d,{r:_,strokeWidth:v}=Ke(t),y=H(t),b=_*2+v,x=f?`url(#clipPath-${y?``:`dots-`}${g})`:void 0;return U.createElement(p,{zIndex:m},U.createElement(L,{className:h},f&&U.createElement(`defs`,null,U.createElement(ge,{clipPathId:g,xAxisId:i,yAxisId:a}),!y&&U.createElement(`clipPath`,{id:`clipPath-dots-${g}`},U.createElement(`rect`,{x:c-b/2,y:o-b/2,width:l+b,height:u+b}))),U.createElement(ie,{xAxisId:i,yAxisId:a,data:n,dataPointFormatter:ft,errorBarOffset:0},U.createElement(dt,{props:this.props,clipPathId:g}))),U.createElement(Le,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}},mt={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:y.line,type:`linear`};function ht(e){var t=B(e,mt),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=Q(t,Ye),{needClip:_}=_e(p,m),v=ae(),y=D(),b=R(),x=I(e=>Ge(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:C,x:w,y:T}=v;return U.createElement(pt,X({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:S,width:C,left:w,top:T,needClip:_}))}function gt(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=C(e,o);if(t===`horizontal`)return{x:O({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(V(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=V(l)?null:n.scale.map(l),d=O({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function _t(e){var t=B(e,mt),n=R();return U.createElement(se,{id:t.id,type:`line`},e=>U.createElement(U.Fragment,null,U.createElement(ne,{legendPayload:tt(t)}),U.createElement(nt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),U.createElement(le,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),U.createElement(ht,X({},t,{id:e}))))}var vt=U.memo(_t,_);vt.displayName=`Line`;var yt=[`axis`],bt=(0,U.forwardRef)((e,t)=>U.createElement(he,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:yt,tooltipPayloadSearcher:pe,categoricalChartProps:e,ref:t})),$=n(),xt=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`},{value:`custom`,labelKey:`periods.custom`}];function St({period:e,from:t,to:n,onChange:r}){let{t:i}=a(`analytics`);function o(e){e===`custom`?r(`custom`,t,n):r(e)}function s(e){r(`custom`,e,n)}function l(e){r(`custom`,t,e)}return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:xt.map(t=>(0,$.jsx)(`button`,{onClick:()=>o(t.value),className:c(`h-7 px-3 rounded-md text-xs font-medium transition-colors`,e===t.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent`),children:i(t.labelKey)},t.value))}),e===`custom`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`date`,value:t,onChange:e=>s(e.target.value),"aria-label":i(`periods.startDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`periods.to`)}),(0,$.jsx)(`input`,{type:`date`,value:n,onChange:e=>l(e.target.value),"aria-label":i(`periods.endDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]})]})}function Ct({kpi:e,windowLabel:t}){let{t:n}=a(`analytics`),r=e.estimatedCostUsd??0,i=e.estimatedCostToday??0,o=e.includesEstimated??r>0,s=r>0,c=i>0,l=typeof e.pricedRuns==`number`||typeof e.unpricedRuns==`number`,u=e.unpricedRuns??0,d=e.pricedRuns??(l?Math.max(0,e.totalJobs-u):e.totalJobs),f=l&&e.totalCostUsd===0&&u>0&&d===0,p=u>0&&(d>0||e.totalCostUsd>0),m=e.unpricedTodayRuns??0,h=e.pricedTodayRuns??(l?Math.max(0,e.jobsToday-m):e.jobsToday),g=l&&e.costToday===0&&m>0&&h===0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{key:`totalCost`,label:n(`desktop.totalCost`),value:f?`—`:`${s?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:g?n(`desktop.costTodayUnavailable`):n(`desktop.costToday`,{value:`${c?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:s,window:t},{key:`totalJobs`,label:n(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:n(`desktop.jobsToday`,{n:e.jobsToday}),estimated:!1},{key:`successRate`,label:n(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:n(`desktop.acrossAllProjects`),estimated:!1},{key:`avgCostPerJob`,label:n(`desktop.avgCostPerJob`),value:e.totalJobs>0&&u===0?`${s?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:n(u>0?`desktop.averageUnavailable`:`desktop.periodAverage`),estimated:s&&e.totalJobs>0}].map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,"data-estimated":e.estimated?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-1`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.label}),`window`in e&&e.window&&(0,$.jsx)(`span`,{"data-testid":`kpi-window-label`,className:`text-[10px] text-muted-foreground/70 whitespace-nowrap`,children:e.window})]}),(0,$.jsx)(`p`,{className:`text-xl font-semibold font-mono`,children:e.value}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.sub})]},e.key))}),o&&(0,$.jsx)(`p`,{"data-testid":`kpi-estimated-footnote`,className:`text-[10px] text-muted-foreground/70 italic`,title:n(`desktop.includesEstimatedTooltip`,{amount:`$${r.toFixed(4)}`}),children:n(`desktop.includesEstimated`,{amount:`$${r.toFixed(4)}`})}),(f||p)&&(0,$.jsx)(`p`,{"data-testid":`kpi-cost-coverage-note`,className:`text-[10px] text-muted-foreground/70 italic`,children:f?n(`desktop.costUnavailable`):n(`desktop.costPartiallyUnavailable`,{count:u})})]})}function wt({data:e}){let{t}=a(`analytics`),n=u(),i=e.length>0&&e.some(e=>e.costUsd>0),o=e.reduce((e,t)=>e+(t.unpricedCount??0),0),s=!i&&o>0,c=i&&o>0,l=Math.max(1,Math.floor(e.length/7)),f=e.filter((e,t)=>t%l===0).map(e=>e.date),p=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),m=e.some(e=>(e.estimatedCostUsd??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`desktop.costOverTime`)}),m&&(0,$.jsx)(`span`,{"data-testid":`timeline-estimated-note`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.timelineEstimatedTooltip`),children:t(`desktop.includesEstimatedShort`)}),c&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 italic`,children:t(`desktop.costPartiallyUnavailable`,{count:o})})]}),s?(0,$.jsx)(`div`,{"data-testid":`desktop-timeline-cost-unavailable`,className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.costUnavailable`)}):i?(0,$.jsx)(v,{width:`100%`,height:200,children:(0,$.jsxs)(bt,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`date`,ticks:f,tickFormatter:e=>{try{return d(new Date(e),`MMM d`,{locale:r()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>{if(!e||!t?.length)return null;let r=(p.get(n)??0)>0;return(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[r?`~`:``,`$`,t[0].value.toFixed(4)]})]})}}),(0,$.jsx)(vt,{type:`monotone`,dataKey:`costUsd`,stroke:n.chart[0],strokeWidth:2,dot:!1,activeDot:{r:3,fill:n.chart[0]}})]})}):(0,$.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.noCostData`)})]})}function Tt({projects:e}){let{t}=a(`analytics`),n=u();if(e.length===0)return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`desktop.noProjects`)})]});let r=Math.max(...e.map(e=>e.totalCostUsd),1e-4);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-4`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`div`,{className:`space-y-3`,children:e.map((e,i)=>{let a=e.estimatedCostUsd??0,o=a>0,s=e.unpricedRuns??0,c=e.pricedRuns??Math.max(0,e.totalJobs-s),l=s>0&&c===0,u=s>0&&c>0;return(0,$.jsxs)(`div`,{className:`space-y-1`,"data-estimated":o?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsxs)(`span`,{className:`font-medium truncate max-w-[160px] flex items-center gap-1`,title:e.projectName,children:[e.projectName,o&&(0,$.jsx)(`span`,{"data-testid":`project-estimated-badge`,className:`text-[9px] uppercase tracking-wide text-muted-foreground/70 not-italic border border-border/40 rounded px-1`,title:t(`desktop.projectEstimatedTooltip`,{amount:`$${a.toFixed(4)}`}),children:t(`desktop.estimatedBadge`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:t(`desktop.jobsCount`,{count:e.totalJobs})}),(0,$.jsx)(`span`,{children:t(`desktop.successPct`,{pct:(e.successRate*100).toFixed(0)})}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,title:u?t(`desktop.costPartiallyUnavailable`,{count:s}):void 0,children:l?t(`desktop.costUnavailableShort`):`${o?`~`:``}$${e.totalCostUsd.toFixed(4)}`})]})]}),(0,$.jsx)(`div`,{className:`h-1.5 rounded-full bg-border/30 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${e.totalCostUsd/r*100}%`,backgroundColor:n.chart[i%n.chart.length]}})})]},e.projectId)})})]})}function Et({projects:e}){let{t}=a(`analytics`),n=u();if(e.length===0)return null;let r=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd})),i=e.some(e=>e.totalCostUsd>0),o=e.some(e=>(e.unpricedRuns??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.costByProject`)}),!i&&o?(0,$.jsx)(`div`,{"data-testid":`desktop-project-cost-unavailable`,className:`h-[180px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.costUnavailable`)}):(0,$.jsx)(v,{width:`100%`,height:180,children:(0,$.jsxs)(ve,{data:r,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,$.jsx)(re,{dataKey:`costUsd`,fill:n.chart[1],radius:[3,3,0,0]})]})})]})}function Dt(){let{t:e}=a(`analytics`),[t,n]=(0,U.useState)(`7d`),[r,o]=(0,U.useState)(``),[s,c]=(0,U.useState)(``),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!0),[m,h]=(0,U.useState)(null),{registerHandler:g,unregisterHandler:_}=i(),v=(0,U.useCallback)(e=>{let n=e;(n.type===`spending.invalidated`||n.type===`rail.job_completed`)&&y(t,r,s)},[t,r,s]);(0,U.useEffect)(()=>(g(`desktop-analytics`,v),()=>_(`desktop-analytics`)),[v,g,_]);async function y(e,t,n){p(!0),h(null);try{let r=new URLSearchParams({period:e});e===`custom`&&t&&n&&(r.set(`from`,t),r.set(`to`,n));let i=await fetch(`/api/analytics?${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();d(a)}catch(e){h(e.message)}finally{p(!1)}}(0,U.useEffect)(()=>{y(t,r,s)},[t,r,s]);function b(e,t,r){n(e),t!==void 0&&o(t),r!==void 0&&c(r)}return(0,$.jsx)(`div`,{className:`flex flex-col h-full overflow-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Se,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`desktop.title`)}),u&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mr-8`,children:[(0,$.jsx)(St,{period:t,from:r,to:s,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,r,s),disabled:f,className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,"aria-label":e(`desktop.refreshAria`),children:(0,$.jsx)(l,{className:`w-3 h-3 ${f?`animate-spin`:``}`})})]})]}),m&&(0,$.jsx)(`div`,{className:`rounded-lg border border-red-400/30 aurora-light:border-destructive/30 bg-red-400/10 aurora-light:bg-destructive/10 p-3 text-xs text-red-400 aurora-light:text-destructive`,children:e(`desktop.failedToLoad`,{error:m})}),f&&!u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:Array.from({length:2}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-[220px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))})]}),u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Ct,{kpi:u.kpi,windowLabel:t===`custom`?u.period.label:e(`windowLabels.${t}`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(wt,{data:u.costTimeline}),(0,$.jsx)(Et,{projects:u.projectBreakdown})]}),(0,$.jsx)(Tt,{projects:u.projectBreakdown})]})]})})}export{Dt 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{n as r}from"./createLucideIcon-Bjbbp_KS.js";import{n as i}from"./dist-bVqfYmby.js";import{t as a}from"./download-CFHyyHcw.js";var o=e(t(),1),s=n(),c=[{labelKey:`export.summaryCsv`,format:`csv`,mode:`summary`},{labelKey:`export.rawCsv`,format:`csv`,mode:`raw`},{labelKey:`export.summaryJson`,format:`json`,mode:`summary`},{labelKey:`export.rawJson`,format:`json`,mode:`raw`}];function l(e){if(!e)return null;let t=e.match(/filename="?([^"]+)"?/);return t?t[1]:null}function u({baseUrl:e,params:t,label:n,disabled:u}){let{t:d}=r(`analytics`),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(!1),g=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!f)return;function e(e){g.current&&!g.current.contains(e.target)&&p(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[f]);let _=(0,o.useCallback)(n=>`${e}?${new URLSearchParams({format:n.format,mode:n.mode,...t}).toString()}`,[e,t]),v=(0,o.useCallback)(async e=>{p(!1),h(!0);try{let t=await fetch(_(e));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r;let a=l(t.headers.get(`Content-Disposition`)),o=`analytics-${e.mode}.${e.format}`;i.download=a??o,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}catch(e){console.warn(`[ExportDropdown] download failed:`,e),i.error(d(`export.failed`))}finally{h(!1)}},[_,d]);return(0,s.jsxs)(`div`,{ref:g,className:`relative`,children:[(0,s.jsxs)(`button`,{type:`button`,"aria-haspopup":`true`,"aria-expanded":f,disabled:m||u,onClick:()=>p(e=>!e),title:u?d(`export.noData`):void 0,className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs font-medium border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:[(0,s.jsx)(a,{className:`w-3 h-3`}),m?d(`export.downloading`):n??d(`common:actions.export`)]}),f&&(0,s.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-50 mt-1 min-w-[180px] rounded-md border border-border/60 bg-popover shadow-md text-xs overflow-hidden`,children:c.map(e=>(0,s.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>v(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,s.jsx)(a,{className:`w-3 h-3 shrink-0`}),(0,s.jsx)(`span`,{className:`flex-1`,children:d(e.labelKey)}),e.mode===`raw`&&(0,s.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:`≤10k`})]},`${e.format}-${e.mode}`))})]})}export{u as t};
|
|
@@ -1,19 +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{o as r,w as i}from"./i18n-hnX2DPmo.js";import{n as a,t as o}from"./createLucideIcon-Bjbbp_KS.js";import{n as s}from"./dist-bVqfYmby.js";import{X as c,at as l,it as u}from"./TicketDetailModal-CsF-AWZX.js";import{d,u as f}from"./MinimizedChatsContext-Bd3OqR_S.js";import{t as p}from"./brain-DI9lHkKY.js";import{n as m}from"./file-text-BcLCfcWZ.js";import{t as h}from"./circle-x-CMYsN4ZH.js";import{t as g}from"./git-branch-BRM0F5GN.js";import{t as _}from"./loader-circle-DcygOQpC.js";import{t as v}from"./play-DNlrawbS.js";import{t as y}from"./search-Cq_gE3Ik.js";import{t as b}from"./triangle-alert-H9T4jAmh.js";import{t as x}from"./x-CBMI9ejn.js";import{a as S}from"./auth-D_5bQv5W.js";import{a as C,r as w}from"./useDesktop-BQVt8lFd.js";import{t as T}from"./button-CJqFnUOL.js";import{t as E}from"./utils-BC4DHlz2.js";import{n as D,t as O}from"./lib-CGdyxIWg.js";import{C as k,Et as A,I as j,N as M,Ot as N,P,Q as F,S as ee,St as te,Tt as I,_ as L,at as R,c as z,et as ne,gt as re,l as ie,o as ae,ot as oe,s as se,st as ce}from"./index-DIhMEAVw.js";import{t as le}from"./lib-C7Mhm-gT.js";var ue=o(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),de=o(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),fe=o(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),pe=o(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),B=n();function me({phases:e,phaseDefinitions:t}){return t.length===0?null:(0,B.jsx)(`div`,{className:`flex items-center`,children:t.map((n,r)=>{let i=e[n.key]??`idle`,a=r<t.length-1?e[t[r+1].key]??`idle`:null;return(0,B.jsxs)(`div`,{className:`flex items-center`,children:[(0,B.jsxs)(M,{children:[(0,B.jsx)(j,{asChild:!0,children:(0,B.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,B.jsx)(he,{state:i}),(0,B.jsx)(`span`,{className:E(`text-xs font-medium transition-colors`,i===`running`?`text-blue-400 aurora-light:text-accent-info`:i===`done`?`text-emerald-400 aurora-light:text-accent-success`:i===`error`?`text-red-400 aurora-light:text-destructive`:`text-muted-foreground/40`),children:n.label})]})}),(0,B.jsxs)(P,{side:`bottom`,className:`max-w-[200px]`,children:[(0,B.jsx)(`p`,{className:`font-medium`,children:n.label}),(0,B.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:n.description})]})]}),a!==null&&(0,B.jsx)(`div`,{className:E(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,a===`done`||i===`done`?`bg-emerald-500/30 aurora-light:bg-accent-success/40`:a===`running`?`bg-blue-400/40 aurora-light:bg-accent-info/40`:`bg-border/30`)})]},n.key)})})}function he({state:e}){return(0,B.jsxs)(`div`,{className:E(`flex items-center justify-center w-10 h-10 rounded-full transition-all duration-300`,e===`running`?`bg-blue-500/10 aurora-light:bg-accent-info/10 ring-1 ring-blue-400/30 aurora-light:ring-accent-info/30 animate-pulse`:e===`done`?`bg-emerald-500/10 aurora-light:bg-accent-success/10`:e===`error`?`bg-red-500/10 aurora-light:bg-destructive/10`:`bg-muted/20`),children:[e===`running`&&(0,B.jsx)(_,{className:`w-6 h-6 text-blue-400 aurora-light:text-accent-info animate-spin`}),e===`done`&&(0,B.jsx)(N,{className:`w-6 h-6 text-emerald-400 aurora-light:text-accent-success`}),e===`error`&&(0,B.jsx)(h,{className:`w-6 h-6 text-red-400 aurora-light:text-destructive`}),e===`idle`&&(0,B.jsx)(u,{className:`w-6 h-6 text-muted-foreground/20`})]})}var V=e(t(),1);function ge(e){let t=e.trimStart();return!!(/^#{1,6}\s/.test(t)||/^[-*+]\s/.test(t)||/^\d+\.\s/.test(t)||/^\|.+\|/.test(t)||t.startsWith("```")||t.startsWith(`> `)||/\*\*[^*]+\*\*/.test(e)||/`[^`]+`/.test(e)||/\[.+\]\(.+\)/.test(e)||/^(-{3,}|_{3,}|\*{3,})$/.test(t)||/^- \[[ x]\]\s/.test(t))}var _e=new Set;function ve({ticketId:e,onOpen:t,children:n}){let{t:r}=a(`agent`),i=r(`refs.openTicket`,{id:e});return(0,B.jsx)(`button`,{type:`button`,"data-testid":`log-ticket-ref`,onClick:n=>{n.stopPropagation(),t(e)},title:i,"aria-label":i,className:`inline cursor-pointer p-0 align-baseline text-accent-primary/90 underline decoration-accent-primary/50 decoration-dotted underline-offset-2 transition-colors hover:text-accent-primary hover:decoration-solid`,children:n})}function ye(e){if(!e.includes(`#`))return null;let t=z(e,_e);return t.some(e=>e.kind===`ticket`)?t:null}function be(e,t){let n=ye(e);return n?n.map((e,n)=>e.kind===`ticket`?(0,B.jsx)(ve,{ticketId:e.ticketId,onOpen:t,children:e.label},n):(0,B.jsx)(V.Fragment,{children:e.kind===`text`?e.text:e.label},n)):e}var xe=new Set([`code`,`inlineCode`,`link`,`linkReference`,`image`,`imageReference`,`definition`,`html`]);function Se(e){return e.kind===`ticket`?{type:`link`,url:ae({kind:`ticket`,ticketId:e.ticketId}),children:[{type:`text`,value:e.label}]}:{type:`text`,value:e.kind===`text`?e.text:e.label}}function Ce(e){let t=e.children;if(t)for(let e=t.length-1;e>=0;e--){let n=t[e];if(!xe.has(n.type))if(n.type===`text`&&typeof n.value==`string`){let r=z(n.value,_e);r.some(e=>e.kind===`ticket`)&&t.splice(e,1,...r.map(Se))}else Ce(n)}}function we(){return e=>Ce(e)}function Te(e){let{activeProjectId:t}=w(),{openRef:n}=ie(),r=e??t??void 0;return(0,V.useMemo)(()=>r?e=>{n(r,{kind:`ticket`,ticketId:e})}:void 0,[r,n])}function H(e,t){let n=`${e.id??t}`,i=e.timestamp;if(e.event_type===`log`)try{let t=JSON.parse(e.payload).line??``;return t.trim()?t.startsWith(`▸`)||t.match(/^(architect|developer|reviewer|ship|analyst)\s*:/i)?{id:n,content:t,type:`phase`,timestamp:i}:e.source===`stderr`?{id:n,content:t,type:`stderr`,timestamp:i}:ge(t)?{id:n,content:t,type:`assistant`,timestamp:i}:{id:n,content:t,type:`plain`,timestamp:i}:null}catch{return null}if(e.event_type!==`log`&&e.event_type!==`result`)return null;if(e.event_type===`result`)try{let t=JSON.parse(e.payload),a=[];return t.duration_ms&&a.push(`${(t.duration_ms/1e3).toFixed(1)}s`),t.total_cost_usd&&a.push(`$${t.total_cost_usd.toFixed(4)}`),t.num_turns&&a.push(r.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${r.t(`jobs:logViewer.completed`)}${a.length?` — ${a.join(` · `)}`:``}`,type:`result`,timestamp:i}}catch{return null}return null}function Ee(e){let t=`none`,n=[];for(let r of e){let e=r.type;if(e!==`plain`&&e!==`log`){t=`none`,n.push(r);continue}let i=r.content;i.startsWith(`--- `)?(t=`saw_minus`,n.push({...r,type:`diff-meta`})):t===`saw_minus`&&i.startsWith(`+++ `)?(t=`active`,n.push({...r,type:`diff-meta`})):t===`active`&&i.startsWith(`@@ `)?n.push({...r,type:`diff-hunk`}):t===`active`&&i.startsWith(`+`)&&!i.startsWith(`+++`)?n.push({...r,type:`diff-add`}):t===`active`&&i.startsWith(`-`)&&!i.startsWith(`---`)?n.push({...r,type:`diff-remove`}):(t===`active`&&(i.startsWith(` `)||i===``)||(t=`none`),n.push(r))}return n}function De(e){let t=[];for(let n of e){let e=t.length>0?t[t.length-1]:null;n.type===`assistant`&&e?.type===`assistant`?e.content+=`
|
|
2
|
-
`+n.content:t.push({...n})}return t}function Oe(e){let t=[{key:`__preamble__`,header:null,lines:[]}];for(let n of e)n.type===`phase`?t.push({key:n.id,header:n,lines:[]}):t[t.length-1].lines.push(n);return t.filter(e=>e.header!==null||e.lines.length>0)}function ke({events:e,isLoading:t,projectId:n}){let{t:r,i18n:i}=a(`jobs`),[o,c]=(0,V.useState)(``),[l,u]=(0,V.useState)(!0),[d,p]=(0,V.useState)(new Set),m=(0,V.useRef)(null),h=(0,V.useRef)(null),g=Te(n),{processedLines:_,groups:v,totalLines:b}=(0,V.useMemo)(()=>{let t=Ee(De(e.map((e,t)=>H(e,t)).filter(e=>e!==null)));return{processedLines:t,groups:Oe(t),totalLines:t.length}},[e,i.language]),x=(0,V.useMemo)(()=>{if(!o)return b;let e=o.toLowerCase();return _.filter(t=>t.content.toLowerCase().includes(e)).length},[o,_,b]),S=(0,V.useCallback)(()=>{let e=h.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,V.useEffect)(()=>{l&&S()},[e.length,l,S]);function C(){let e=h.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<50;u(t)}function w(e){p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return t?(0,B.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`logViewer.loading`)})}):b===0?(0,B.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`logViewer.empty`)})}):(0,B.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,B.jsxs)(`div`,{className:`px-4 py-2 border-b border-border flex items-center gap-2`,children:[(0,B.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,B.jsx)(y,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,B.jsx)(L,{placeholder:r(`logViewer.filterPlaceholder`),value:o,onChange:e=>c(e.target.value),className:`pl-7 h-7`})]}),(0,B.jsx)(T,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:()=>{let e=_.map(e=>e.content).join(`
|
|
3
|
-
`);navigator.clipboard.writeText(e).then(()=>{s.success(r(`logViewer.copySuccess`))}).catch(()=>{s.error(r(`logViewer.copyFailed`))})},children:(0,B.jsx)(I,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`logViewer.lineCount`,{filtered:x,total:b})})]}),(0,B.jsxs)(`div`,{ref:h,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:C,children:[v.map(e=>(0,B.jsx)(Ae,{group:e,filter:o,collapsed:d.has(e.key),onToggle:()=>w(e.key),onOpenTicket:g},e.key)),(0,B.jsx)(`div`,{ref:m})]}),!l&&(0,B.jsxs)(T,{size:`sm`,variant:`secondary`,onClick:()=>{u(!0),S()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,B.jsx)(f,{className:`w-3 h-3`}),r(`logViewer.jumpToBottom`)]})]})}var Ae=(0,V.memo)(function({group:e,filter:t,collapsed:n,onToggle:r,onOpenTicket:i}){let{t:o}=a(`jobs`),s=t?e.lines.filter(e=>e.content.toLowerCase().includes(t.toLowerCase())):e.lines;if(e.header===null)return s.length===0?null:(0,B.jsx)(`div`,{children:s.map((e,t)=>(0,B.jsx)(U,{line:e,even:t%2==0,onOpenTicket:i},e.id))});let c=e.header.content;return(0,B.jsxs)(`div`,{className:`mt-3 rounded-md overflow-hidden border border-border/20`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:r,className:E(`flex items-center gap-2 w-full text-left px-3 py-2`,`bg-primary/5 border-b border-primary/20`,`hover:bg-primary/10 transition-colors duration-150 cursor-pointer`),children:[(0,B.jsx)(m,{className:E(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,B.jsx)(`span`,{className:`flex-1 text-[12px] font-semibold text-foreground leading-none`,children:c}),e.header.timestamp&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 font-mono tabular-nums shrink-0`,children:new Date(e.header.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:o(`logViewer.phaseLines`,{count:e.lines.length})})]}),!n&&(0,B.jsx)(`div`,{className:`bg-muted/5`,children:s.length===0?(0,B.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:o(t?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):s.map((e,t)=>(0,B.jsx)(U,{line:e,even:t%2==0,onOpenTicket:i},e.id))})]})}),je=[le],Me=[O],Ne=[O,we],U=(0,V.memo)(function({line:e,even:t,onOpenTicket:n}){let r=e.type===`assistant`,i=e.type===`diff-add`,a=e.type===`diff-remove`,o=e.type===`diff-meta`,s=e.type===`diff-hunk`,c=i||a||o||s,l=n!=null&&(e.type===`plain`||e.type===`log`),u=(0,V.useMemo)(()=>l&&n?be(e.content,n):e.content,[l,n,e.content]),d=r&&n?Ne:Me,f=(0,V.useMemo)(()=>n?{a:({href:e,children:t})=>{let r=se(e);return r?.kind===`ticket`?(0,B.jsx)(ve,{ticketId:r.ticketId,onOpen:n,children:t}):(0,B.jsx)(`a`,{href:e,children:t})}}:void 0,[n]);return(0,B.jsxs)(`div`,{className:E(`flex items-start gap-2 group px-2 py-0.5 rounded-sm`,!c&&(t?`bg-muted/20`:`bg-transparent`),e.type===`result`&&`bg-emerald-500/5 aurora-light:bg-accent-success/10 border-l-2 border-emerald-500/40 aurora-light:border-accent-success/40 mt-2 py-2`,i&&`bg-emerald-500/8 aurora-light:bg-accent-success/10 border-l-2 border-emerald-500/50 aurora-light:border-accent-success/50`,a&&`bg-red-500/8 aurora-light:bg-destructive/10 border-l-2 border-red-500/50 aurora-light:border-destructive/50`,o&&`bg-accent-primary/5 border-l-2 border-accent-primary/30`,s&&`bg-accent-info/5 border-l-2 border-accent-info/30`),children:[e.timestamp&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0 mt-0.5 w-[52px] font-mono tabular-nums`,children:new Date(e.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),r?(0,B.jsx)(`div`,{className:`flex-1 min-w-0 prose prose-invert prose-xs max-w-none
|
|
4
|
-
prose-p:my-1 prose-p:leading-relaxed
|
|
5
|
-
prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold
|
|
6
|
-
prose-ul:my-1 prose-ol:my-1 prose-li:my-0
|
|
7
|
-
prose-code:text-cyan-300 prose-code:text-[11px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded
|
|
8
|
-
prose-pre:my-1 prose-pre:bg-muted/30 prose-pre:rounded-md prose-pre:p-2 prose-pre:text-[11px]
|
|
9
|
-
prose-strong:text-foreground prose-em:text-foreground/70
|
|
10
|
-
prose-a:text-blue-400 prose-a:no-underline hover:prose-a:underline
|
|
11
|
-
prose-table:my-2 prose-table:text-[11px]
|
|
12
|
-
prose-thead:border-border prose-thead:bg-muted/30
|
|
13
|
-
prose-th:px-3 prose-th:py-1.5 prose-th:text-left prose-th:font-semibold prose-th:text-foreground/90
|
|
14
|
-
prose-td:px-3 prose-td:py-1.5 prose-td:border-border
|
|
15
|
-
prose-tr:border-border
|
|
16
|
-
text-foreground/80`,children:(0,B.jsx)(D,{remarkPlugins:d,rehypePlugins:je,components:f,children:e.content})}):(0,B.jsx)(`span`,{className:E(`flex-1 break-all leading-relaxed whitespace-pre-wrap font-mono`,e.type===`tool-use`&&`text-cyan-400/80 aurora-light:text-accent-info text-[11px]`,e.type===`stderr`&&`text-orange-400 aurora-light:text-accent-warning`,e.type===`result`&&`text-emerald-400 aurora-light:text-accent-success font-medium`,e.type===`log`&&`text-foreground/60`,e.type===`plain`&&`text-foreground/70`,e.type===`tool-result`&&`text-muted-foreground/50`,i&&`text-emerald-400 aurora-light:text-accent-success`,a&&`text-red-400 aurora-light:text-destructive`,o&&`text-accent-primary/80`,s&&`text-accent-info/80`),children:u})]})});function W(e){try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t}catch{}return null}var Pe=/^\s*━+\s*Step\s+\d+\s*·/,Fe=/\s*\(iteration\s+\d+\)\s*$/i;function G(e){return e.replace(/^[\s\uFE0F\p{Extended_Pictographic}]+/u,``).trim()||e.trim()}function K(e){let t=G(e.title);return e.iteration==null?t:t.replace(Fe,``)}function Ie(e){return e.meta.nodeId??`${e.meta.kind}::${G(e.meta.title).replace(Fe,``)}`}function Le(e){let t=null,n=0,r=[[]],i=[];for(let a=0;a<e.length;a++){let o=e[a];if(o.event_type===`loop_graph`){let e=W(o.payload);e&&e.graph&&typeof e.graph==`object`&&!Array.isArray(e.graph)&&(t={graph:e.graph,loopId:typeof e.loopId==`string`?e.loopId:void 0,loopName:typeof e.loopName==`string`?e.loopName:void 0,provider:typeof e.provider==`string`?e.provider:void 0,model:typeof e.model==`string`?e.model:void 0,iterationLimit:typeof e.iterationLimit==`number`?e.iterationLimit:void 0});continue}if(o.event_type===`loop_step`){let e=W(o.payload);if(!e||typeof e.index!=`number`)continue;let t=typeof e.iteration==`number`?e.iteration:null;t!=null&&t>n&&(n=t),i.push({meta:{index:e.index,kind:typeof e.kind==`string`?e.kind:`ai-step`,title:typeof e.title==`string`?e.title:``,nodeId:typeof e.nodeId==`string`?e.nodeId:null,iteration:t,template:typeof e.template==`string`&&e.template?e.template:void 0,command:typeof e.command==`string`&&e.command?e.command:void 0},end:null,lastActivity:null}),r.push([]);continue}if(o.event_type===`loop_step_end`){let e=W(o.payload);if(!e||typeof e.index!=`number`)continue;for(let t=i.length-1;t>=0;t--)if(i[t].meta.index===e.index){i[t].end={index:e.index,nodeId:typeof e.nodeId==`string`?e.nodeId:null,status:e.status===`failed`?`failed`:`ok`,exitCode:typeof e.exitCode==`number`?e.exitCode:null,durationMs:typeof e.durationMs==`number`?e.durationMs:null,decision:e.decision===`continue`||e.decision===`stop`?e.decision:void 0};break}continue}let s=i.length>0,c=H(o,a);if(c&&!(s&&Pe.test(c.content))&&r[r.length-1].push(c),s){let e=k(o);e.step&&e.actionKey&&(i[i.length-1].lastActivity={actionKey:e.actionKey,actionArg:e.actionArg})}}let a=e=>Ee(De(e)),o=a(r[0]),s=i.map((e,t)=>({key:`step-${t}-${e.meta.index}`,meta:e.meta,lines:a(r[t+1]),end:e.end,lastActivity:e.lastActivity})),c=o.length+s.reduce((e,t)=>e+t.lines.length,0);return{graphMeta:t,setup:o,segments:s,maxIteration:n,totalLines:c}}function Re(e,t){return e.end?e.end.status:t.isLast?t.jobSettled?`interrupted`:`running`:`unknown`}function ze(e){return e===`continue`?0:e===`stop`?2:1}function Be(e){let t=new Map(e.nodes.map(e=>[e.id,e])),n=new Set,r=[],i=a=>{if(n.has(a))return;let o=t.get(a);if(!o)return;n.add(a),r.push(o);let s=e.edges.filter(e=>e.source===a).slice().sort((e,t)=>ze(e.branch)-ze(t.branch));for(let e of s)i(e.target)},a=e.nodes.find(e=>e.type===`start`);a&&i(a.id);for(let t of e.nodes)i(t.id);return r}function q(e){let t=e.data?.label;return typeof t==`string`&&t.trim()?t.trim():null}function Ve(e,t){let n=e.segments.length-1,r=new Map,i=new Map;e.segments.forEach((e,t)=>{let n=Ie(e);r.set(n,{seg:e,idx:t}),e.meta.kind===`decider`&&e.end?.decision&&i.set(n,e.end.decision)});let a=e=>{let r=Re(e.seg,{isLast:e.idx===n,jobSettled:t.jobSettled});return r===`unknown`?`ok`:r};if(e.graphMeta)return Be(e.graphMeta.graph).map(e=>{if(e.type===`start`)return{key:e.id,kind:`start`,label:q(e),state:`ok`,latestSegmentKey:null};if(e.type===`end`)return{key:e.id,kind:`end`,label:q(e),state:t.jobSettled?t.jobFailed?`failed`:`ok`:`pending`,latestSegmentKey:null};let n=r.get(e.id);return n?{key:e.id,kind:e.type,label:q(e)??K(n.seg.meta),state:a(n),decision:e.type===`decider`?i.get(e.id):void 0,latestSegmentKey:n.seg.key}:{key:e.id,kind:e.type,label:q(e),state:`pending`,latestSegmentKey:null}});let o=[],s=new Map;return e.segments.forEach((e,t)=>{let n=Ie(e),r={seg:e,idx:t},c=s.get(n),l=e.meta.kind===`decider`?i.get(n):void 0;if(c!=null){let t=o[c];t.state=a(r),t.decision=l,t.latestSegmentKey=e.key}else s.set(n,o.length),o.push({key:n,kind:e.meta.kind,label:K(e.meta)||null,state:a(r),decision:l,latestSegmentKey:e.key})}),o}function He(e){if(!Number.isFinite(e)||e<0)return`—`;if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}var Ue={start:v,"ai-step":p,shell:F,decider:g,condition:g,end:te},We=ne,Ge={start:`text-accent-success`,"ai-step":`text-accent-primary`,shell:`text-accent-warning`,decider:`text-accent-highlight`,condition:`text-accent-info`,end:`text-accent-secondary`},Ke={start:`border-accent-success/60`,"ai-step":`border-accent-primary/60`,shell:`border-accent-warning/60`,decider:`border-accent-highlight/60`,condition:`border-accent-info/60`,end:`border-accent-secondary/60`};function qe(e){return Ue[e]??We}function Je({chips:e,iteration:t,onChipClick:n,variant:r}){let{t:i}=a(`jobs`);return e.length===0&&!t?null:(0,B.jsxs)(`div`,{"data-testid":`loop-overview-strip`,role:`list`,"aria-label":i(`loopExplorer.stepMapAria`),className:E(`flex items-center gap-1 overflow-x-auto border-b border-border/30 bg-surface/20`,r===`glass`?`px-3 py-1.5`:`px-4 py-2`),children:[e.map((e,t)=>{let r=qe(e.kind),a=Ge[e.kind]??`text-foreground`,o=Ke[e.kind]??`border-border/40`,s=e.label??i(`loops:builder.nodes.${e.kind}`,{defaultValue:e.kind}),u=e.latestSegmentKey!=null;return(0,B.jsxs)(V.Fragment,{children:[t>0&&(0,B.jsx)(m,{className:`w-3 h-3 text-muted-foreground/30 shrink-0`}),(0,B.jsxs)(`button`,{type:`button`,role:`listitem`,"data-testid":`loop-node-chip`,"data-state":e.state,"data-kind":e.kind,"data-decision":e.decision,"aria-label":`${s} — ${e.state}`,disabled:!u,onClick:()=>e.latestSegmentKey&&n(e.latestSegmentKey),className:E(`relative flex items-center gap-1.5 shrink-0 rounded-full border bg-surface/40 px-2.5 py-1 text-[11px] transition-colors`,o,e.state===`pending`&&`opacity-45 border-border/40`,e.state===`interrupted`&&`border-dashed border-accent-warning/50`,u?`cursor-pointer hover:bg-surface/70`:`cursor-default`),children:[e.state===`running`&&(0,B.jsx)(`span`,{"aria-hidden":!0,className:`absolute -inset-px rounded-full ring-2 ring-accent-primary/50 motion-safe:animate-pulse pointer-events-none`}),(0,B.jsx)(r,{className:E(`w-3 h-3 shrink-0`,a)}),(0,B.jsx)(`span`,{className:E(`max-w-[120px] truncate font-medium text-foreground/90`,e.state===`running`&&`title-shimmer`),children:s}),e.state===`ok`&&(0,B.jsx)(d,{className:`w-3 h-3 text-accent-success shrink-0`}),e.state===`failed`&&(0,B.jsx)(x,{className:`w-3 h-3 text-destructive shrink-0`}),e.decision===`continue`&&(0,B.jsx)(c,{className:`w-3 h-3 text-accent-highlight shrink-0`}),e.decision===`stop`&&(0,B.jsx)(l,{className:`w-3 h-3 text-accent-success shrink-0`})]})]},e.key)}),t&&(0,B.jsxs)(`span`,{"data-testid":`loop-iteration-chip`,className:`ml-auto flex items-center gap-1.5 shrink-0 rounded-full border border-accent-highlight/40 bg-accent-highlight/10 px-2.5 py-1 text-[10px] font-medium text-accent-highlight tabular-nums`,children:[(0,B.jsx)(ce,{className:`w-3 h-3`}),t.limit==null?i(`loopExplorer.iterationBadge`,{count:t.current}):i(`loopExplorer.iteration`,{current:t.current,limit:t.limit})]})]})}var Ye=(0,V.memo)(Je);function Xe({className:e}){return(0,B.jsxs)(`span`,{className:E(`relative flex h-2 w-2 shrink-0`,e),children:[(0,B.jsx)(`span`,{className:`motion-safe:animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-60`}),(0,B.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-accent-primary`})]})}function Ze(e,t){if(!t)return e;let n=t.toLowerCase();return e.filter(e=>e.content.toLowerCase().includes(n))}function Qe(e,t,n,r){return e.length===0?(0,B.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:n(t?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):e.map((e,t)=>(0,B.jsx)(U,{line:e,even:t%2==0,onOpenTicket:r},e.id))}function $e({label:e,value:t,copyLabel:n}){let[r,i]=(0,V.useState)(!1),a=async()=>{try{await navigator.clipboard.writeText(t),i(!0),window.setTimeout(()=>i(!1),1500)}catch{}};return(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(`span`,{className:`text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/50`,children:e}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void a(),"aria-label":`${n} — ${e}`,title:n,className:`p-0.5 text-muted-foreground/40 hover:text-foreground transition-colors cursor-pointer`,children:r?(0,B.jsx)(d,{className:`w-2.5 h-2.5 text-accent-success`}):(0,B.jsx)(I,{className:`w-2.5 h-2.5`})})]}),(0,B.jsx)(`pre`,{className:`mt-0.5 text-[10px] font-mono leading-relaxed text-foreground/75 whitespace-pre-wrap break-words`,children:t})]})}function et({segment:e,status:t,collapsed:n,filter:r,onToggle:i,onCopy:o,setRef:s,onOpenTicket:c}){let{t:l}=a(`jobs`),{meta:u,lines:f,end:p,lastActivity:h}=e,g=qe(u.kind),_=Ge[u.kind]??`text-foreground`,v=Ze(f,r),y=t===`running`,b=!!(u.template||u.command),[S,C]=(0,V.useState)(!1);return(0,B.jsxs)(`div`,{ref:t=>s(e.key,t),"data-testid":`loop-step-section`,"data-status":t,"data-step-index":u.index,className:E(`mt-3 rounded-md overflow-hidden border animate-in fade-in duration-200`,t===`running`&&`border-accent-primary/40`,t===`failed`&&`border-destructive/30`,t===`interrupted`&&`border-dashed border-accent-warning/40`,(t===`ok`||t===`unknown`)&&`border-border/20`),children:[(0,B.jsxs)(`div`,{className:E(`flex items-stretch bg-primary/5 border-b`,t===`failed`?`border-destructive/20`:`border-primary/20`),children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>i(e.key),className:`flex items-center gap-2 flex-1 min-w-0 text-left px-3 py-2 hover:bg-primary/10 transition-colors duration-150 cursor-pointer`,children:[(0,B.jsx)(m,{className:E(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,B.jsx)(`span`,{className:`text-[10px] font-mono tabular-nums text-muted-foreground/60 shrink-0 w-5 text-right`,children:u.index}),(0,B.jsx)(g,{className:E(`w-3.5 h-3.5 shrink-0`,_)}),(0,B.jsx)(`span`,{className:`text-[12px] font-semibold text-foreground leading-none truncate`,children:K(u)}),u.iteration!=null&&u.iteration>=1&&(0,B.jsx)(`span`,{className:`shrink-0 rounded-full bg-muted/60 px-1.5 py-0.5 text-[9px] font-medium text-muted-foreground tabular-nums`,children:l(`loopExplorer.iterationBadge`,{count:u.iteration})}),y&&(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 min-w-0 shrink-0 max-w-[40%]`,children:[(0,B.jsx)(Xe,{}),h&&(0,B.jsx)(`span`,{className:`title-shimmer text-[10px] truncate`,children:l(`statusPanel.activity.${h.actionKey}`,{arg:h.actionArg??``})})]}),t===`ok`&&(0,B.jsx)(d,{className:`w-3.5 h-3.5 text-accent-success shrink-0`}),t===`failed`&&(0,B.jsx)(x,{className:`w-3.5 h-3.5 text-destructive shrink-0`}),t===`interrupted`&&(0,B.jsx)(`span`,{className:`shrink-0 rounded border border-dashed border-accent-warning/50 px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wide text-accent-warning`,children:l(`loopExplorer.interrupted`)}),(0,B.jsx)(`span`,{className:`flex-1`}),p?.durationMs!=null&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 font-mono tabular-nums shrink-0`,children:He(p.durationMs)}),t===`failed`&&p?.exitCode!=null&&p.exitCode!==0&&(0,B.jsx)(`span`,{className:`text-[10px] text-destructive/70 font-mono shrink-0`,children:l(`activeJob.exitCode`,{code:p.exitCode})}),(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:l(`logViewer.phaseLines`,{count:f.length})})]}),b&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>C(e=>!e),"aria-label":l(`loopExplorer.stepDetail`),"aria-expanded":S,title:l(`loopExplorer.stepDetail`),className:E(`px-2 flex items-center transition-colors cursor-pointer`,S?`text-foreground bg-primary/10`:`text-muted-foreground/40 hover:text-foreground hover:bg-primary/10`),children:(0,B.jsx)(re,{className:`w-3 h-3`})}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>o(e.key),"aria-label":l(`loopExplorer.copyStep`),title:l(`loopExplorer.copyStep`),className:`px-2.5 flex items-center text-muted-foreground/40 hover:text-foreground hover:bg-primary/10 transition-colors cursor-pointer`,children:(0,B.jsx)(I,{className:`w-3 h-3`})})]}),S&&b&&(0,B.jsxs)(`div`,{"data-testid":`loop-step-detail`,className:E(`px-4 py-2.5 space-y-2.5 bg-muted/10 border-b animate-in fade-in duration-150`,t===`failed`?`border-destructive/20`:`border-primary/10`),children:[u.template&&(0,B.jsx)($e,{label:l(`loopExplorer.stepDetailTemplate`),value:u.template,copyLabel:l(`loopExplorer.copyCommand`)}),u.command&&(0,B.jsx)($e,{label:l(`loopExplorer.stepDetailCommand`),value:u.command,copyLabel:l(`loopExplorer.copyCommand`)})]}),!n&&(0,B.jsx)(`div`,{className:`bg-muted/5`,children:Qe(v,r,l,c)})]})}var tt=(0,V.memo)(et,(e,t)=>e.segment.key===t.segment.key&&e.segment.lines.length===t.segment.lines.length&&e.segment.lines[e.segment.lines.length-1]?.content===t.segment.lines[t.segment.lines.length-1]?.content&&e.segment.meta.template===t.segment.meta.template&&e.segment.meta.command===t.segment.meta.command&&e.segment.end?.status===t.segment.end?.status&&e.segment.end?.durationMs===t.segment.end?.durationMs&&e.segment.end?.decision===t.segment.end?.decision&&e.segment.end?.exitCode===t.segment.end?.exitCode&&e.segment.lastActivity?.actionKey===t.segment.lastActivity?.actionKey&&e.segment.lastActivity?.actionArg===t.segment.lastActivity?.actionArg&&e.status===t.status&&e.collapsed===t.collapsed&&e.filter===t.filter&&e.onOpenTicket===t.onOpenTicket),J=`__setup__`;function nt({lines:e,collapsed:t,filter:n,onToggle:r,setRef:i,onOpenTicket:o}){let{t:s}=a(`jobs`),c=Ze(e,n);return(0,B.jsxs)(`div`,{ref:e=>i(J,e),"data-testid":`loop-setup-section`,className:`rounded-md overflow-hidden border border-border/20`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(J),className:`flex items-center gap-2 w-full text-left px-3 py-2 bg-muted/10 border-b border-border/20 hover:bg-muted/20 transition-colors duration-150 cursor-pointer`,children:[(0,B.jsx)(m,{className:E(`w-3 h-3 text-muted-foreground/60 shrink-0 transition-transform duration-150`,!t&&`rotate-90`)}),(0,B.jsx)(v,{className:`w-3.5 h-3.5 text-accent-success/70 shrink-0`}),(0,B.jsx)(`span`,{className:`text-[11px] font-semibold text-muted-foreground leading-none uppercase tracking-wide`,children:s(`loopExplorer.setup`)}),(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:s(`logViewer.phaseLines`,{count:e.length})})]}),!t&&(0,B.jsx)(`div`,{className:`bg-muted/5`,children:Qe(c,n,s,o)})]})}var rt=(0,V.memo)(nt,(e,t)=>e.lines.length===t.lines.length&&e.lines[e.lines.length-1]?.content===t.lines[t.lines.length-1]?.content&&e.collapsed===t.collapsed&&e.filter===t.filter&&e.onOpenTicket===t.onOpenTicket);function Y(){return(0,B.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5 shrink-0`,children:[(0,B.jsx)(`span`,{className:`motion-safe:animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-60`}),(0,B.jsx)(`span`,{className:`relative inline-flex rounded-full h-1.5 w-1.5 bg-accent-primary`})]})}function it({events:e,jobStatus:t,isLoading:n,variant:r=`page`,projectId:i}){let{t:o,i18n:c}=a(`jobs`),[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)(`follow`),[p,m]=(0,V.useState)(new Set),h=(0,V.useRef)(null),g=(0,V.useRef)(new Map),_=Te(i),v=(0,V.useMemo)(()=>Le(e),[e,c.language]),b=t!=null&&t!==`running`&&t!==`queued`,x=t===`running`,S=(0,V.useMemo)(()=>v.segments.map((e,t)=>Re(e,{isLast:t===v.segments.length-1,jobSettled:b})),[v,b]),C=(0,V.useMemo)(()=>{let e=v.segments.map(e=>e.key);return v.setup.length>0&&e.push(J),e},[v]),w=v.segments.length>0?v.segments[v.segments.length-1].key:J,D=(0,V.useMemo)(()=>l?new Set(C):d===`follow`?new Set([w]):p,[l,d,w,p,C]),O=(0,V.useRef)(D);O.current=D;let k=(0,V.useRef)(v);k.current=v;let A=(0,V.useCallback)(e=>{let t=new Set(O.current);e?.(t),m(t),f(`manual`)},[]),j=(0,V.useCallback)(e=>{A(t=>{t.has(e)?t.delete(e):t.add(e)})},[A]),M=(0,V.useCallback)(e=>{A(t=>t.add(e)),requestAnimationFrame(()=>{g.current.get(e)?.scrollIntoView?.({behavior:`smooth`,block:`start`})})},[A]),N=(0,V.useCallback)(()=>{let e=h.current;e&&(e.scrollTop=e.scrollHeight)},[]),P=(0,V.useCallback)(()=>{f(`follow`),requestAnimationFrame(N)},[N]),F=(0,V.useCallback)(()=>{m(new Set(C)),f(`manual`)},[C]),ee=(0,V.useCallback)(()=>{m(new Set),f(`manual`)},[]);(0,V.useEffect)(()=>{d===`follow`&&!l&&N()},[v.totalLines,v.segments.length,d,l,N]);let te=(0,V.useCallback)(()=>{let e=h.current;!e||d!==`follow`||e.scrollHeight-e.scrollTop-e.clientHeight>80&&A()},[d,A]),R=(0,V.useCallback)((e,t)=>{t?g.current.set(e,t):g.current.delete(e)},[]),z=(0,V.useCallback)(e=>{let t=k.current.segments.find(t=>t.key===e),n=e===`__setup__`?k.current.setup.map(e=>e.content).join(`
|
|
17
|
-
`):(t?.lines??[]).map(e=>e.content).join(`
|
|
18
|
-
`);navigator.clipboard.writeText(n).then(()=>s.success(o(`loopExplorer.copied`))).catch(()=>s.error(o(`logViewer.copyFailed`)))},[o]),ne=(0,V.useCallback)(()=>{let e=k.current,t=e.setup.map(e=>e.content);for(let n of e.segments){t.push(`── Step ${n.meta.index} · ${G(n.meta.title)} ──`);for(let e of n.lines)t.push(e.content)}navigator.clipboard.writeText(t.join(`
|
|
19
|
-
`)).then(()=>s.success(o(`logViewer.copySuccess`))).catch(()=>s.error(o(`logViewer.copyFailed`)))},[o]),re=(0,V.useMemo)(()=>Ve(v,{jobSettled:b,jobFailed:t===`failed`}),[v,b,t]),ie=v.graphMeta?.iterationLimit??v.graphMeta?.graph.config.maxIterations??null,ae=v.maxIteration>0?{current:v.maxIteration,limit:ie}:null,oe=(0,V.useMemo)(()=>{if(!l)return v.totalLines;let e=l.toLowerCase(),t=v.setup.filter(t=>t.content.toLowerCase().includes(e)).length;for(let n of v.segments)t+=n.lines.filter(t=>t.content.toLowerCase().includes(e)).length;return t},[l,v]),se=v.segments[v.segments.length-1],ce=x&&(v.segments.length===0||se?.end!=null);return n?(0,B.jsx)(`div`,{className:`flex-1 flex items-center justify-center h-full`,children:(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`logViewer.loading`)})}):v.totalLines===0&&v.segments.length===0?(0,B.jsx)(`div`,{"data-testid":`loop-step-explorer`,className:`flex-1 flex items-center justify-center h-full`,children:(0,B.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-2`,children:[x&&(0,B.jsx)(Y,{}),o(x?`loopExplorer.waiting`:`logViewer.empty`)]})}):(0,B.jsxs)(`div`,{"data-testid":`loop-step-explorer`,className:`relative flex flex-col h-full`,children:[(0,B.jsxs)(`div`,{className:E(`border-b border-border flex items-center gap-2`,r===`glass`?`px-3 py-1.5`:`px-4 py-2`),children:[(0,B.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,B.jsx)(y,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,B.jsx)(L,{placeholder:o(`logViewer.filterPlaceholder`),value:l,onChange:e=>u(e.target.value),className:`pl-7 h-7`})]}),(0,B.jsx)(T,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:F,"aria-label":o(`loopExplorer.expandAll`),title:o(`loopExplorer.expandAll`),children:(0,B.jsx)(de,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(T,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:ee,"aria-label":o(`loopExplorer.collapseAll`),title:o(`loopExplorer.collapseAll`),children:(0,B.jsx)(ue,{className:`w-3.5 h-3.5`})}),d===`follow`&&x&&(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] text-accent-primary shrink-0`,children:[(0,B.jsx)(Y,{}),o(`loopExplorer.follow`)]}),(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsx)(T,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:ne,"aria-label":o(`logViewer.copySuccess`),children:(0,B.jsx)(I,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:o(`logViewer.lineCount`,{filtered:oe,total:v.totalLines})})]}),(0,B.jsx)(Ye,{chips:re,iteration:ae,onChipClick:M,variant:r}),(0,B.jsxs)(`div`,{ref:h,onScroll:te,className:`flex-1 overflow-y-auto p-2 text-xs`,children:[v.setup.length>0&&(0,B.jsx)(rt,{lines:v.setup,collapsed:!D.has(`__setup__`),filter:l,onToggle:j,setRef:R,onOpenTicket:_}),v.segments.map((e,t)=>(0,B.jsx)(tt,{segment:e,status:S[t],collapsed:!D.has(e.key),filter:l,onToggle:j,onCopy:z,setRef:R,onOpenTicket:_},e.key)),ce&&(0,B.jsxs)(`div`,{"data-testid":`loop-waiting-row`,className:`mt-3 flex items-center gap-2 px-3 py-2 text-[11px] text-muted-foreground/70 italic`,children:[(0,B.jsx)(Y,{}),o(`loopExplorer.waiting`)]})]}),d===`manual`&&x&&!l&&(0,B.jsxs)(`button`,{type:`button`,"data-testid":`resume-follow-pill`,onClick:P,className:`absolute bottom-4 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 rounded-full glass-card border border-accent-primary/30 px-3 py-1.5 text-[11px] font-medium text-foreground shadow-lg hover:border-accent-primary/60 transition-colors cursor-pointer animate-in fade-in slide-in-from-bottom-2 duration-200`,children:[(0,B.jsx)(Y,{}),o(`loopExplorer.resumeFollow`)]})]})}var at=new Set(`grep.rg.ag.ack.find.fd.ls.cat.head.tail.sed.awk.cut.sort.uniq.wc.jq.yq.tr.xargs.tee.column.less.more.cd.pwd.echo.printf.which.type.test.true.false.env.export.set.source.date.basename.dirname.realpath.readlink.stat.file.tree.diff.sleep.seq.hostname.whoami.uname.mkdir.rmdir.cp.mv.rm.touch.ln.chmod.chown.install.[[.[.]].].for.while.until.if.then.else.elif.fi.do.done.case.esac.exec.eval.trap.read.shift.wait`.split(`.`)),ot=new Set([`status`,`diff`,`log`,`show`,`branch`,`rev-parse`,`ls-files`,`blame`,`describe`]),st=new Set([...ot,`commit`,`add`,`stage`,`push`,`pull`,`fetch`,`checkout`,`switch`,`merge`,`rebase`,`reset`,`stash`,`tag`,`clone`,`worktree`,`cherry-pick`,`restore`,`apply`,`init`,`remote`,`config`,`update-ref`,`for-each-ref`]),ct=new Set([`run`,`run-script`,`test`,`install`,`ci`,`i`,`add`,`exec`,`start`,`dlx`]),lt=[[/^(test|tests|test:.*|vitest|jest|spec)$/,`activity.testing`],[/^(build|compile|bundle|dist)$/,`activity.building`],[/^(typecheck|tsc|types?)$/,`activity.typechecking`],[/^(lint|lint:.*|eslint|format|fmt|prettier)$/,`activity.linting`]],ut=new Set([`vitest`,`jest`,`pytest`,`mocha`,`ava`,`rspec`,`phpunit`]);function dt(e){for(let[t,n]of lt)if(t.test(e))return n;return null}function ft(e){return e.split(/\s+/).map(e=>e.replace(/^['"`]+/,``).replace(/['"`]+$/,``)).filter(e=>e.length>0&&!e.startsWith(`-`))}function pt(e){let t=ft(e);if(t.length===0)return{kind:`plumbing`};let n=t[0].split(`/`).pop()??t[0],r=t.slice(1);if(at.has(n))return{kind:`plumbing`};if(ut.has(n))return{kind:`intent`,code:`activity.testing`};if((n===`npx`||n===`pnpm`||n===`yarn`||n===`bunx`)&&r.length>0){let e=r[0]===`dlx`||r[0]===`exec`?r[1]??``:r[0];if(ut.has(e))return{kind:`intent`,code:`activity.testing`};let t=dt(e===`run`?r[r.indexOf(`run`)+1]??``:e);if(t)return{kind:`intent`,code:t};if(e===`tsc`)return{kind:`intent`,code:`activity.typechecking`}}if(n===`npm`||n===`yarn`||n===`pnpm`||n===`bun`){let e=r.findIndex(e=>ct.has(e)),t=e===-1?``:r[e];if(t===`install`||t===`ci`||t===`i`||t===`add`)return{kind:`intent`,code:`activity.installing`};let i=dt(t===`run`||t===`run-script`?r[e+1]??``:t);return i?{kind:`intent`,code:i}:{kind:`named`,tool:n}}if(n===`git`){let e=r.find(e=>st.has(e))??``;return ot.has(e)?{kind:`plumbing`}:e===`commit`||e===`add`||e===`stage`?{kind:`intent`,code:`activity.savingWork`}:{kind:`named`,tool:n}}if(n===`cargo`||n===`go`||n===`dotnet`||n===`mvn`||n===`gradle`){let e=r.find(e=>e===`test`||e===`build`||e===`compile`)??``;return e===`test`?{kind:`intent`,code:`activity.testing`}:e===`build`||e===`compile`?{kind:`intent`,code:`activity.building`}:{kind:`named`,tool:n}}return n===`tsc`?{kind:`intent`,code:`activity.typechecking`}:n===`openspec`?{kind:`intent`,code:`activity.checkingSpec`}:{kind:`named`,tool:n}}function mt(e){try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function ht(e,t){return e&&/^main-\d+$/.test(e)?`step.role.work`:e===`verify`?`step.role.verify`:e===`decide`||t===`decider`?`step.role.decide`:e===`fix`?`step.role.fix`:null}function gt(e){return e.replace(/^[^\p{L}\p{N}(]+/u,``).trim()}var X=e=>typeof e==`number`&&Number.isFinite(e)?e:null,Z=e=>typeof e==`string`&&e.length>0?e:null,_t=new Set([`thinking`,`reasoning`]),vt=/^(MEMORY\.md|confidence-score\.json|design-confidence\.json|\d{4}-\d{2}-\d{2}-.+|feedback_.+)$/,yt=/^(proposal|design|tasks|spec|context-bundle)\.md$/,bt=new Set([`reading`,`writing`,`editing`]);function Q(e,t,n,r,i){for(let t=e.length-1;t>=0;t--){let a=e[t];if(a.kind!==`activity`){if(a.stepIndex!==n)break;continue}if(a.stepIndex!==n)break;if(a.values.action===r&&a.values.target===i){a.values.repeats=Number(a.values.repeats??1)+1;return}}e.push({seq:t,kind:`activity`,code:r===`intent`?i:i?`activity.${r}`:`activity.${r}Bare`,values:{action:r,target:i,repeats:1},stepIndex:n,tone:`neutral`})}var xt=3;function St(e,t,n,r,i){for(let t=e.length-1;t>=0;t--){let a=e[t];if(a.stepIndex!==n)break;if(a.kind!==`activity`||a.values.action!==r||a.values.fileGroup!==1)continue;let o=String(a.values.allNames??``).split(`\0`).filter(Boolean),s=!!i&&!o.includes(i);s&&o.push(i),a.values.allNames=o.join(`\0`),a.values.files=o.length;let c=String(a.values.names??``).split(`, `).filter(Boolean);s&&c.length<xt&&(c.push(i),a.values.names=c.join(`, `)),a.code=o.length>1?`activity.${r}Files`:i?`activity.${r}`:`activity.${r}Bare`,a.values.repeats=o.length>1?1:Number(a.values.repeats??1)+1;return}e.push({seq:t,kind:`activity`,code:i?`activity.${r}`:`activity.${r}Bare`,values:{action:r,target:i,names:i,allNames:i,files:+!!i,fileGroup:1,repeats:1},stepIndex:n,tone:`neutral`})}function Ct({events:e,settled:t}){let n=[],r=new Map,i=null,a=!1;for(let t of e){if(t.event_type===`loop_graph`){a=!0;continue}if(t.event_type===`loop_step`){let e=mt(t.payload),o=X(e.index);if(o===null)continue;a=!0;let s=Z(e.kind)??`ai-step`,c={index:o,title:gt(Z(e.title)??``),roleCode:ht(Z(e.nodeId),s),kind:s,iteration:X(e.iteration),ended:!1};r.set(o,c),i=o,n.push({seq:t.seq,kind:`step-start`,code:c.iteration&&c.iteration>1?`step.startRetry`:`step.start`,values:{step:o,title:c.title,iteration:c.iteration??1,...c.roleCode?{roleCode:c.roleCode}:{}},stepIndex:o,tone:`neutral`});continue}if(t.event_type===`loop_step_end`){let e=mt(t.payload),i=X(e.index);if(i===null)continue;let a=i===null?void 0:r.get(i);a&&(a.ended=!0);let o=Z(e.status),s=X(e.durationMs),c=X(e.exitCode),l=o===`failed`;n.push({seq:t.seq,kind:`step-end`,code:l?`step.failed`:s===null?`step.done`:s>=9e4?`step.doneTimedMin`:`step.doneTimed`,values:{step:i,title:a?.title??``,seconds:s===null?0:Math.max(1,Math.round(s/1e3)),minutes:s===null?0:Math.max(1,Math.round(s/6e4)),...a?.roleCode?{roleCode:a.roleCode}:{},...c===null?{}:{exitCode:c}},stepIndex:i,tone:l?`bad`:`good`});let u=Z(e.decision);(u===`continue`||u===`stop`)&&n.push({seq:t.seq,kind:`decision`,code:u===`continue`?`decision.another`:`decision.satisfied`,values:{step:i},stepIndex:i,tone:u===`continue`?`neutral`:`good`});continue}let e=k(t);if(!(!e.step||!e.actionKey)&&!_t.has(e.actionKey)){if(e.actionKey===`running`){let r=ee(t),a=r?pt(r):{kind:`named`,tool:e.actionArg??``};if(a.kind===`plumbing`){Q(n,t.seq,i,`exploring`,``);continue}if(a.kind===`intent`){Q(n,t.seq,i,`intent`,a.code);continue}Q(n,t.seq,i,`running`,a.tool);continue}if(bt.has(e.actionKey)){let r=e.actionArg??``;if(vt.test(r)){Q(n,t.seq,i,`intent`,`activity.bookkeeping`);continue}if(yt.test(r)){Q(n,t.seq,i,`intent`,`activity.writingSpec`);continue}St(n,t.seq,i,e.actionKey,r);continue}Q(n,t.seq,i,e.actionKey,e.actionArg??``)}}if(t)for(let e of r.values())e.ended||n.push({seq:2**53-1-(1e3-e.index),kind:`step-interrupted`,code:`step.interrupted`,values:{step:e.index,title:e.title},stepIndex:e.index,tone:`bad`});return{milestones:n,stepCount:r.size,plainJob:!a}}var wt={"step-start":fe,"step-end":d,"step-interrupted":b,decision:oe,activity:fe},Tt={neutral:`text-muted-foreground`,good:`text-accent-success`,bad:`text-accent-warning`};function Et({events:e,settled:t,durationRange:n,elapsedMs:r,variant:i=`page`}){let{t:o}=a(`narration`),s=(0,V.useMemo)(()=>Ct({events:e,settled:t}),[e,t]),c=(0,V.useMemo)(()=>[...s.milestones].sort((e,t)=>e.seq-t.seq),[s.milestones]);return(0,B.jsxs)(`div`,{className:i===`glass`?`flex h-full flex-col overflow-hidden`:`flex flex-col`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b border-border/50 px-3 py-2 text-[11px] text-muted-foreground`,children:[typeof r==`number`&&r>0?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,B.jsx)(A,{className:`size-3`,"aria-hidden":!0}),o(`waiting.elapsed`,{minutes:Math.max(1,Math.round(r/6e4))})]}):null,n?(0,B.jsx)(`span`,{"data-testid":`narration-range`,children:o(`waiting.range`,{low:Math.max(1,Math.round(n.p25Ms/6e4)),high:Math.max(1,Math.round(n.p75Ms/6e4)),count:n.sampleCount})}):null,(0,B.jsx)(`span`,{className:`ml-auto italic opacity-70`,children:o(`aiNote`)})]}),(0,B.jsx)(`ol`,{className:`flex-1 space-y-1 px-3 py-2 ${i===`glass`?`overflow-y-auto`:``}`,"data-testid":`narration-list`,children:c.length===0?(0,B.jsx)(`li`,{className:`py-6 text-center text-xs text-muted-foreground`,children:o(t?`emptySettled`:`emptyLive`)}):c.map((e,t)=>{let n=wt[e.kind],r=e.kind===`step-start`||e.kind===`step-end`||e.kind===`step-interrupted`,i=Number(e.values.files??0)>1?1:Number(e.values.repeats??1);return(0,B.jsxs)(`li`,{className:`flex items-start gap-2 text-sm ${r?`font-medium text-foreground`:`text-muted-foreground`} ${e.kind===`step-start`&&t>0?`pt-2`:``}`,children:[(0,B.jsx)(n,{className:`mt-0.5 size-3.5 shrink-0 ${Tt[e.tone]}`,"aria-hidden":!0}),(0,B.jsxs)(`span`,{children:[e.kind===`step-start`&&typeof e.values.roleCode==`string`?o(e.code,{...e.values,title:o(e.values.roleCode),defaultValue:e.code}):o(e.code,{...e.values,defaultValue:e.code}),i>1?(0,B.jsx)(`span`,{className:`ml-1.5 text-[11px] opacity-70`,children:o(`repeats`,{count:i})}):null]})]},`${e.seq}-${e.code}-${t}`)})})]})}var $=`specrails-desktop:job-log-mode`;function Dt(){try{let e=localStorage.getItem($);return e===`log`||e===`narrated`?e:`narrated`}catch{return`narrated`}}function Ot(e){try{localStorage.setItem($,e)}catch{}}function kt(e,t){switch(t.type){case`turn-user`:return{...e,streaming:!0,accepting:!0,queued:t.queued?e.queued+1:e.queued};case`turn-done`:{let n=Math.max(0,e.queued-1);return{...e,totals:t.totals,queued:n,streaming:e.queued>0}}case`finalized`:return{...e,streaming:!1,finalizing:!1,accepting:!1,queued:0,totals:t.totals??e.totals};case`accepting`:return t.accepting?{...e,accepting:!0}:{...e,accepting:!1,streaming:!1,queued:0};case`finalize-request`:return{...e,finalizing:!0};case`finalize-reject`:return{...e,finalizing:!1};case`blocked`:return{...e,accepting:!1,streaming:!1};default:return e}}function At(){try{return i()}catch{return null}}function jt({jobId:e,projectId:t,settleMode:n,initialAcceptingTurns:r,kind:i=`job`,variant:o=`page`,onFinalized:c}){let{t:l}=a(`jobs`),u=n??`finalize`,d=()=>t?`${S}/api/projects/${t}`:C(),[f,p]=(0,V.useReducer)(kt,{streaming:!1,queued:0,totals:null,accepting:r??!0,finalizing:!1}),[m,h]=(0,V.useState)(``),[g,v]=(0,V.useState)(!1),y=(0,V.useRef)(null);(0,V.useEffect)(()=>{r!==void 0&&p({type:`accepting`,accepting:r})},[r]);let b=(0,V.useRef)(c);b.current=c;let x=At(),w=(0,V.useId)();(0,V.useEffect)(()=>{if(!x)return;let t=`interactive-composer-${e}-${w}`;return x.registerHandler(t,t=>{let n=t;n.jobId===e&&(n.type===`job.turn_user`?p({type:`turn-user`,queued:!!n.queued}):n.type===`job.turn_done`?p({type:`turn-done`,totals:n.totals}):n.type===`job.finalized`?(p({type:`finalized`,totals:n.totals??null}),b.current?.()):n.type===`job.interactive`&&p({type:`accepting`,accepting:!!n.acceptingTurns}))}),()=>x.unregisterHandler(t)},[x,e,w]);let D=i===`loop-step`&&!f.accepting;async function O(){let t=m.trim();if(!(!t||g||D)){v(!0);try{let n=await fetch(`${d()}/jobs/${e}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t})});if(n.ok)h(``),requestAnimationFrame(()=>y.current?.focus());else if(n.status===409&&i===`loop-step`)p({type:`blocked`});else{let e=await n.json().catch(()=>({}));s.error(l(`detail.toast.sendFailed`),{description:e.error})}}catch{s.error(l(`detail.toast.networkError`))}finally{v(!1)}}}async function k(){if(!f.finalizing){p({type:`finalize-request`});try{let t=await fetch(`${d()}/jobs/${e}/finalize`,{method:`POST`});if(t.ok)s.success(l(u===`finalize`?`detail.toast.finalizeScheduled`:i===`loop-step`?`detail.toast.wrapUpStepScheduled`:`detail.toast.wrapUpScheduled`));else if(t.status===409&&i===`loop-step`)p({type:`blocked`}),p({type:`finalize-reject`});else{let e=await t.json().catch(()=>({}));s.error(l(`detail.toast.finalizeFailed`),{description:e.error}),p({type:`finalize-reject`})}}catch{s.error(l(`detail.toast.networkError`)),p({type:`finalize-reject`})}}}let A=g||D||!m.trim(),F=l(`detail.interactive.working`);return(0,B.jsxs)(`div`,{"data-testid":`interactive-job-composer`,className:E(`shrink-0 border-t px-3 py-2 space-y-1.5`,`motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-2 motion-safe:duration-300`,o===`glass`?`border-border/30 bg-surface/30`:`border-border/40 bg-surface/40`),children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-[11px] text-muted-foreground`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[D?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(pe,{className:`h-3 w-3 motion-safe:animate-pulse`}),l(`detail.interactive.waitingForStepShort`)]}):f.streaming?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(_,{className:`h-3 w-3 animate-spin text-accent-primary`}),(0,B.jsxs)(`span`,{className:`relative`,children:[F,(0,B.jsx)(`span`,{"aria-hidden":!0,className:`title-shimmer pointer-events-none absolute inset-0`,children:F})]})]}):(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent-success motion-safe:animate-pulse`}),l(`detail.interactive.ready`)]}),f.queued>0&&(0,B.jsx)(`span`,{className:`rounded-full border border-accent-info/30 bg-accent-info/10 px-1.5 py-px text-[10px] tabular-nums text-accent-info motion-safe:animate-in motion-safe:fade-in`,children:l(`detail.interactive.queued`,{count:f.queued})})]}),(0,B.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[f.totals&&(0,B.jsx)(`span`,{className:`tabular-nums`,children:l(`detail.interactive.liveTotals`,{turns:f.totals.num_turns,cost:f.totals.total_cost_usd.toFixed(4)})}),u===`finalize`?(0,B.jsxs)(M,{children:[(0,B.jsx)(j,{asChild:!0,children:(0,B.jsxs)(T,{variant:`outline`,size:`sm`,onClick:()=>void k(),disabled:f.finalizing,className:`h-7 border-accent-success/40 text-accent-success hover:bg-accent-success/10`,children:[(0,B.jsx)(N,{className:`mr-1.5 h-3.5 w-3.5`}),f.finalizing?l(`detail.finalizing`):l(`detail.finalizeJob`)]})}),(0,B.jsx)(P,{children:l(`detail.finalizeJobTooltip`)})]}):(0,B.jsxs)(M,{children:[(0,B.jsx)(j,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,onClick:()=>void k(),disabled:f.finalizing||D,className:E(`text-[11px] underline-offset-2 transition-colors`,D?`cursor-not-allowed text-muted-foreground/40`:`text-muted-foreground hover:text-accent-success hover:underline`),children:f.finalizing?l(`detail.interactive.wrappingUp`):l(i===`loop-step`?`detail.interactive.wrapUpStep`:`detail.interactive.wrapUp`)})}),(0,B.jsx)(P,{children:l(i===`loop-step`?`detail.interactive.wrapUpStepTooltip`:`detail.interactive.wrapUpTooltip`)})]})]})]}),u===`auto`&&(0,B.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground/60`,children:l(D?`detail.interactive.waitingForStep`:`detail.interactive.autoHint`)}),(0,B.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,B.jsx)(`textarea`,{ref:y,value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(!e.shiftKey||e.metaKey||e.ctrlKey)&&(e.preventDefault(),O())},rows:2,placeholder:l(D?`detail.interactive.waitingForStepShort`:`detail.interactive.placeholder`),"aria-label":l(`detail.interactive.placeholder`),disabled:D,className:E(`flex-1 resize-none rounded-md border border-border/50 bg-background px-2.5 py-1.5 text-sm transition-opacity focus:outline-none focus:ring-2 focus:ring-ring`,D&&`opacity-60`)}),(0,B.jsxs)(M,{children:[(0,B.jsx)(j,{asChild:!0,children:(0,B.jsx)(`span`,{className:`shrink-0`,children:(0,B.jsxs)(T,{size:`sm`,onClick:()=>void O(),disabled:A,className:`h-9`,children:[(0,B.jsx)(R,{className:`mr-1.5 h-3.5 w-3.5`}),l(`detail.interactive.send`)]})})}),A&&!g&&(0,B.jsx)(P,{children:l(D?`detail.interactive.sendDisabledWaiting`:`detail.interactive.sendDisabledEmpty`)})]})]})]})}export{it as a,Et as i,Dt as n,ke as o,Ot as r,me as s,jt as t};
|
|
@@ -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{t as r}from"./react-dom-DiWzBDP9.js";import{a as i}from"./i18n-hnX2DPmo.js";import{n as a}from"./createLucideIcon-Bjbbp_KS.js";import{n as o}from"./dist-bVqfYmby.js";import{C as s,R as c}from"./TicketDetailModal-CsF-AWZX.js";import{a as l,i as ee,n as te,o as u,r as d,s as f,t as p}from"./InteractiveJobComposer-BCZiSfzc.js";import{t as ne}from"./loader-circle-DcygOQpC.js";import{t as re}from"./x-CBMI9ejn.js";import{a as ie,n as m}from"./auth-D_5bQv5W.js";import{a as ae}from"./useDesktop-BQVt8lFd.js";import{c as oe,s as se}from"./dialog-CdWCb02j.js";import{t as h}from"./button-CJqFnUOL.js";import{t as g}from"./formatDistanceToNow-DQCvMgUc.js";import{F as _,I as ce,L as v,N as y,P as le,i as ue,r as de}from"./index-DIhMEAVw.js";import{n as b,t as x}from"./job-time-BCL7wee9.js";var S=e(r(),1),C=e(t(),1),w=[1e3,2e3,4e3,8e3,16e3];function fe(e,t){let[n,r]=(0,C.useState)(`connecting`),i=(0,C.useRef)(null),a=(0,C.useRef)(0),o=(0,C.useRef)(null),s=(0,C.useRef)(t);s.current=t;let c=(0,C.useCallback)(()=>{let t=m(),n=t?new WebSocket(e,[`specrails-desktop`,t]):new WebSocket(e);i.current=n,r(`connecting`),n.onopen=()=>{a.current=0,r(`connected`)},n.onmessage=e=>{try{let t=JSON.parse(e.data);s.current(t)}catch{}},n.onclose=()=>{i.current=null;let e=a.current;if(e>=w.length){r(`disconnected`);return}let t=w[e];a.current+=1,o.current=setTimeout(c,t)}},[e]);return(0,C.useEffect)(()=>(c(),()=>{o.current&&clearTimeout(o.current);let e=i.current;e&&(e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null,e.close()),i.current=null}),[c]),{connectionStatus:n}}var T=n();function pe(e,t){let n=b(e),r=b(t);if(!n||!r)return`—`;let i=r.getTime()-n.getTime();if(i<0)return`—`;let a=Math.round(i/1e3);if(a<60)return`${a}s`;let o=Math.floor(a/60),s=a%60;return o<60?`${o}m ${s}s`:`${Math.floor(o/60)}h ${o%60}m`}var E={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`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`}};function D({jobId:e,onClose:t,projectId:n}){let{t:r}=a(`jobs`),{t:m}=a(`narration`),w=(0,C.useCallback)(()=>n?`${ie}/api/projects/${n}`:ae(),[n]),[D,O]=(0,C.useState)(te),k=(0,C.useCallback)(e=>{O(e),d(e)},[]),[A,j]=(0,C.useState)(null),[M,N]=(0,C.useState)([]),[P,F]=(0,C.useState)([]),[I,L]=(0,C.useState)({}),[R,z]=(0,C.useState)(!0),[B,V]=(0,C.useState)(!1),[H,U]=(0,C.useState)(!1),[W,G]=(0,C.useState)(!1);(0,C.useEffect)(()=>{async function t(){try{let t=await fetch(`${w()}/jobs/${e}`);if(t.status===404){V(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();if(j(n.job),N(n.events),n.phaseDefinitions){F(n.phaseDefinitions);let e={};for(let t of n.phaseDefinitions)e[t.key]=`idle`;L(e)}}catch{V(!0)}finally{z(!1)}}t()},[e,w]);let K=(0,C.useCallback)(()=>{fetch(`${w()}/jobs/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.job&&j(e.job)}).catch(()=>{})},[e,w]),q=(0,C.useRef)([]),J=(0,C.useRef)(null),Y=(0,C.useCallback)(()=>{J.current=null;let e=q.current;e.length!==0&&(q.current=[],N(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]);(0,C.useEffect)(()=>()=>{J.current&&cancelAnimationFrame(J.current)},[]),fe(s,(0,C.useCallback)(t=>{let n=t;if(n.type===`event`&&n.jobId===e){let t={id:Date.now(),job_id:e,seq:0,event_type:n.event_type,source:n.source,payload:n.payload,timestamp:n.timestamp};q.current.push(t),J.current||=requestAnimationFrame(Y)}else if(n.type===`log`&&n.processId===e){let t={id:Date.now(),job_id:e,seq:0,event_type:`log`,source:n.source,payload:JSON.stringify({line:n.line}),timestamp:n.timestamp};q.current.push(t),J.current||=requestAnimationFrame(Y)}else if(n.type===`job.finalized`&&n.jobId===e||n.type===`job.interactive`&&n.jobId===e||(n.type===`loop.run_paused`||n.type===`loop.run_resumed`)&&n.loopRunId===e)K();else if(n.type===`phase`){let e=n.phase,t=n.state;L(n=>({...n,[e]:t}))}else if(n.type===`queue`){let t=n.jobs?.find(t=>t.id===e);t&&A&&j(e=>e&&{...e,status:t.status})}},[e,A,Y,K])),(0,C.useEffect)(()=>{function e(e){if(e.key===`Escape`){if(H){U(!1);return}t()}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,H]);let X=A?ue(A):`job`,Z=X===`loop-run`;async function me(){G(!0);try{let t=await de({projectId:n??null,jobId:e,kind:X});t.ok?(o.success(r(Z?`modal.toast.stopSignalSent`:`modal.toast.cancelSignalSent`),{description:r(Z?`modal.toast.stopSignalSentDescription`:`modal.toast.cancelSignalSentDescription`)}),K()):o.error(r(`modal.toast.cancelFailed`),{description:t.error})}finally{G(!1)}}let Q=A?E[A.status]??E.queued:E.queued,he=A?.status===`running`,$=A?b(x(A)):null,{panelRef:ge,panelStyle:_e,headerHandleProps:ve,resizeHandles:ye,isFloating:be,guardBackdrop:xe}=oe();return(0,S.createPortal)((0,T.jsx)(_,{delayDuration:400,children:(0,T.jsxs)(`div`,{className:`fixed inset-0 z-[65] flex items-stretch justify-center`,children:[(0,T.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:xe(t)}),(0,T.jsxs)(`div`,{ref:ge,className:`relative w-full m-3 rounded-xl glass-card border border-border/30 flex flex-col animate-in fade-in zoom-in-95 duration-200 overflow-hidden`,style:_e,children:[(0,T.jsxs)(`div`,{...ve,className:`flex items-center justify-between px-4 py-3 border-b border-border/30${be?` cursor-grab active:cursor-grabbing`:``}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[A&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(y,{children:[(0,T.jsx)(ce,{asChild:!0,children:(0,T.jsx)(`div`,{children:(0,T.jsx)(v,{variant:Q.variant,children:r(Q.labelKey)})})}),(0,T.jsx)(le,{children:r(Q.tooltipKey)})]}),(0,T.jsx)(`code`,{className:`text-xs font-mono text-foreground/80 truncate`,children:A.command}),(0,T.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:$?g($,{addSuffix:!0,locale:i()}):`—`}),A.total_cost_usd!=null&&A.total_cost_usd>0&&(0,T.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`$`,A.total_cost_usd.toFixed(4)]}),A.started_at&&A.finished_at&&(0,T.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:pe(A.started_at,A.finished_at)})]}),R&&(0,T.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`common:states.loading`)})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[P.length>0&&(0,T.jsx)(`div`,{className:`mr-3`,children:(0,T.jsx)(f,{phases:I,phaseDefinitions:P})}),he&&(0,T.jsxs)(h,{variant:`ghost`,size:`sm`,onClick:()=>U(!0),disabled:W,className:`h-7 text-destructive hover:text-destructive hover:bg-destructive/10`,children:[W&&(0,T.jsx)(ne,{className:`w-3.5 h-3.5 mr-1.5 animate-spin`,"aria-hidden":!0}),r(Z?`dashboard:railControls.stop`:X===`interactive`?`common:actions.discard`:`common:actions.cancel`)]}),(0,T.jsx)(`button`,{onClick:t,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors cursor-pointer`,children:(0,T.jsx)(re,{className:`w-4 h-4`})})]})]}),(0,T.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:B?(0,T.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`modal.notFound`)})}):c&&A?(0,T.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,T.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/40 px-3 py-1.5`,children:[`narrated`,`log`].map(e=>(0,T.jsx)(`button`,{type:`button`,onClick:()=>k(e),"aria-pressed":D===e,"data-testid":`modal-narration-mode-${e}`,className:`rounded-md px-2 py-0.5 text-[11px] font-medium transition-colors ${D===e?`bg-accent-primary/15 text-accent-primary`:`text-muted-foreground hover:bg-surface/60`}`,children:m(e===`narrated`?`modeNarrated`:`modeLog`)},e))}),(0,T.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:D===`narrated`?(0,T.jsx)(ee,{events:M,settled:A.status!==`running`&&A.status!==`queued`,elapsedMs:A.duration_ms??null,variant:`glass`}):A.command.startsWith(`loop:`)?(0,T.jsx)(l,{events:M,jobStatus:A.status,isLoading:R,variant:`glass`,projectId:n}):(0,T.jsx)(u,{events:M,isLoading:R,projectId:n})})]}):A?.command.startsWith(`loop:`)?(0,T.jsx)(l,{events:M,jobStatus:A.status,isLoading:R,variant:`glass`,projectId:n}):(0,T.jsx)(u,{events:M,isLoading:R,projectId:n})}),!!A?.interactive&&A.status===`running`&&(0,T.jsx)(p,{jobId:e,projectId:n,settleMode:A.interactiveSettleMode,initialAcceptingTurns:A.interactiveAcceptingTurns,kind:A.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`glass`,onFinalized:K})]}),(0,T.jsx)(se,{handles:ye}),H&&(0,T.jsxs)(`div`,{"data-testid":`job-cancel-confirm`,className:`absolute inset-0 z-10 flex items-center justify-center p-4`,children:[(0,T.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>U(!1)}),(0,T.jsxs)(`div`,{className:`relative w-full max-w-sm rounded-xl glass-card border border-border/30 p-5 shadow-xl animate-in fade-in zoom-in-95 duration-150`,children:[(0,T.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:r(Z?`modal.stopRunConfirmTitle`:`modal.cancelConfirmTitle`)}),(0,T.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:r(Z?`modal.stopRunConfirmDescription`:`modal.cancelConfirmDescription`)}),(0,T.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,T.jsx)(h,{variant:`ghost`,size:`sm`,onClick:()=>U(!1),children:r(`modal.keepRunning`)}),(0,T.jsx)(h,{variant:`destructive`,size:`sm`,onClick:()=>{U(!1),me()},children:r(Z?`modal.stopRun`:X===`interactive`?`common:actions.discard`:`modal.cancelJob`)})]})]})]})]})}),document.body)}export{D as JobDetailModal};
|
|
@@ -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{d as r,n as i,u as a}from"./chunk-KS7C4IRE-DEKu087k.js";import{a as o,w as s}from"./i18n-hnX2DPmo.js";import{n as c}from"./createLucideIcon-Bjbbp_KS.js";import{n as l}from"./dist-bVqfYmby.js";import{R as u,o as d}from"./TicketDetailModal-CsF-AWZX.js";import{l as f,u as p}from"./MinimizedChatsContext-Bd3OqR_S.js";import{n as ee}from"./file-text-BcLCfcWZ.js";import{a as m,i as h,n as g,o as _,r as te,s as v,t as y}from"./InteractiveJobComposer-BCZiSfzc.js";import{t as ne}from"./circle-x-CMYsN4ZH.js";import{t as re}from"./download-CFHyyHcw.js";import{t as b}from"./loader-circle-DcygOQpC.js";import{a as x,r as ie}from"./useDesktop-BQVt8lFd.js";import{t as S}from"./button-CJqFnUOL.js";import{t as C}from"./utils-BC4DHlz2.js";import{t as ae}from"./formatDistanceToNow-DQCvMgUc.js";import{C as w,Et as T,I as E,L as D,N as O,Ot as k,P as A,_t as j,ot as oe,r as se,x as M}from"./index-DIhMEAVw.js";import{n as N}from"./job-time-BCL7wee9.js";import{t as ce}from"./format-command-C0D9IPmV.js";var P=e(t(),1),F=n();function I(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 L(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 R={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function z(e,t){if(t.type===`reset`)return R;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=w(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 le({job:e,events:t,defaultOpen:n=!0,pipelineTotals:r,phases:i,phaseDefinitions:a}){let{t:o}=c(`jobs`),[s,l]=(0,P.useState)(n),u=(0,P.useMemo)(()=>L(t),[t]),d=e.status===`running`,f=e.status===`completed`,[ee,m]=(0,P.useState)(()=>Date.now());(0,P.useEffect)(()=>{if(!d)return;let e=window.setInterval(()=>m(Date.now()),1e3);return()=>window.clearInterval(e)},[d]);let[h,g]=(0,P.useReducer)(z,R),_=(0,P.useRef)(e.id);(0,P.useEffect)(()=>{_.current!==e.id&&(_.current=e.id,g({type:`reset`})),g({type:`consume`,events:t})},[e.id,t]);let[te,v]=(0,P.useState)(!0);(0,P.useEffect)(()=>{if(!d)return;v(!0);let e=window.setTimeout(()=>v(!1),8e3);return()=>window.clearTimeout(e)},[d,e.id]);let y=e.finished_at?I(e.started_at,e.finished_at):d?I(e.started_at,ee):`—`,re=!!e.total_cost_usd_estimated,x=e.total_cost_usd==null?null:`${re?`~`:``}$${e.total_cost_usd.toFixed(4)}`,ie=e.num_turns==null?null:String(e.num_turns),S=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),ae=S==null?null:`${(S/1e3).toFixed(1)}k`,w=(0,P.useMemo)(()=>!i||!a?null:a.find(e=>i[e.key]===`running`)?.label??null,[i,a]),T=d&&h.steps===0?`connecting`:h.actionKey||`thinking`,E=M.has(T)&&h.actionArg!==``,D=M.has(T)&&!E?`working`:T,O=E?o(`statusPanel.activity.${D}`,{arg:h.actionArg}):o(`statusPanel.activity.${D}`),A=w??(d&&h.steps===0?o(`statusPanel.activity.starting`):null),j=h.steps>0?o(`statusPanel.steps`,{count:h.steps}):null,oe=o(d?`statusPanel.inProgress`:f?`statusPanel.completed`:`statusPanel.failed`),se=d?`border-accent-info/20 bg-accent-info/5`:f?`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`,N=d?b:f?k:ne,ce=d?`w-4 h-4 text-accent-info shrink-0 animate-spin`:f?`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,F.jsxs)(`div`,{className:C(`mx-4 my-2 rounded-xl border transition-colors duration-500`,se),children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>l(!s),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,F.jsx)(N,{className:ce,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:oe}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,F.jsx)(`span`,{className:`tabular-nums`,children:y}),d?j&&(0,F.jsx)(`span`,{className:`tabular-nums`,children:j}):(0,F.jsxs)(F.Fragment,{children:[x&&(0,F.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:x}),u.length>0&&(0,F.jsx)(`span`,{children:o(`statusPanel.filesCount`,{count:u.length})})]})]}),(0,F.jsx)(p,{className:C(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,s&&`rotate-180`)})]}),s&&(0,F.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:d?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneInProgress`)}),(0,F.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,F.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,F.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[o(`statusPanel.duration`),(0,F.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,F.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:y})]}),(0,F.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,F.jsx)(b,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),A&&(0,F.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:A}),(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:O}),j&&(0,F.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,j]})]})]}),te&&(0,F.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:o(`statusPanel.explainer`)}),(0,F.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,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,F.jsx)(H,{label:o(`statusPanel.cost`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.costTooltip`)}),(0,F.jsx)(H,{label:o(`statusPanel.turns`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)}),(0,F.jsx)(H,{label:o(`statusPanel.tokens`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)})]})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneFinal`)}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,F.jsx)(B,{label:o(`statusPanel.duration`),value:y}),(0,F.jsx)(V,{label:o(`statusPanel.cost`),value:x,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:o(`statusPanel.notAvailable`)}),(0,F.jsx)(V,{label:o(`statusPanel.turns`),value:ie,naCaption:o(`statusPanel.notAvailable`)}),(0,F.jsx)(V,{label:o(`statusPanel.tokens`),value:ae,naCaption:o(`statusPanel.notAvailable`)})]}),r&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.pipelineTotal`,{count:r.jobCount})}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,F.jsx)(B,{label:o(`statusPanel.totalCost`),value:r.costUnavailable?`—`:`${r.costEstimated?`~`:``}${r.hasNullCost?`≥`:``}$${r.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,F.jsx)(B,{label:o(`statusPanel.totalTokens`),value:r.tokensUnavailable?`—`:`${(r.nullTokenCount??0)>0?`≥`:``}${((r.totalTokensIn+r.totalTokensOut+r.totalTokensCacheRead+r.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]}),r.hasNullCost&&!r.costUnavailable&&(0,F.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})}),r.costUnavailable&&(0,F.jsx)(`p`,{"data-testid":`pipeline-cost-unavailable`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,children:o(`statusPanel.pipelineCostUnavailable`)}),(r.nullTokenCount??0)>0&&(0,F.jsx)(`p`,{"data-testid":`pipeline-usage-coverage-hint`,className:`text-[10px] text-muted-foreground/70 mt-1`,title:o(`statusPanel.pipelineUsageTooltip`),children:r.tokensUnavailable?o(`statusPanel.pipelineUsageUnavailable`):o(`statusPanel.pipelineUsagePartial`,{count:r.nullTokenCount??0})})]}),u.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.filesModified`)}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u.map(e=>(0,F.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 B({label:e,value:t,valueClass:n}){return(0,F.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,F.jsx)(`p`,{className:C(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function V({label:e,value:t,valueClass:n,naCaption:r}){return(0,F.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,F.jsx)(`p`,{className:C(`text-sm font-semibold tabular-nums mt-0.5`,t==null?`text-muted-foreground`:n),children:t??`—`}),t==null&&(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:r})]})}function H({label:e,caption:t,tooltip:n}){return(0,F.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,F.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,F.jsx)(T,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,F.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var U=4;function ue({tickets:e,onTicketClick:t}){let{t:n}=c(`jobs`),[r,i]=(0,P.useState)(!1);if(e.length===0)return null;let a=e.length>=U&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,F.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,F.jsx)(de,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,F.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,F.jsx)(p,{className:`w-3 h-3`})]}),r&&e.length>=U&&(0,F.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,F.jsx)(f,{className:`w-3 h-3`})]})]})}function de({ticket:e,onClick:t}){let{t:n}=c(`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,F.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,F.jsx)(`span`,{className:C(i,`text-muted-foreground bg-muted/20 select-none`),title:n(`ticketHeader.deletedTooltip`),children:n(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,F.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,F.jsxs)(`span`,{className:C(i,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,F.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}var fe={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 W(){let{t:e}=c(`jobs`),{t}=c(`narration`),{id:n}=r(),{activeProjectId:f,projects:p}=ie(),ne=p.find(e=>e.id===f)?.provider,b=a(),{openTicketDetail:w}=d(),[T,k]=(0,P.useState)(null),[M,N]=(0,P.useState)([]),[I,L]=(0,P.useState)([]),[R,z]=(0,P.useState)({}),[B,V]=(0,P.useState)([]),[H,U]=(0,P.useState)(!0),[de,W]=(0,P.useState)(!1),[G,pe]=(0,P.useState)(g),[me,K]=(0,P.useState)(null),he=(0,P.useCallback)(e=>{pe(e),te(e)},[]),q=T?.command??null;(0,P.useEffect)(()=>{if(!u||G!==`narrated`||!f||!q)return;let e=!1,t=`command=${encodeURIComponent(q)}`;try{Promise.resolve(fetch(`${x()}/run-duration-range?${t}`)).then(e=>e&&e.ok?e.json():null).then(t=>{e||K(t?.range??null)}).catch(()=>{e||K(null)})}catch{K(null)}return()=>{e=!0}},[f,q,G]);let[ge,J]=(0,P.useState)(!1),Y=(0,P.useRef)(!1),X=(0,P.useRef)(null);(0,P.useEffect)(()=>{Y.current=!1,X.current=null,J(!1)},[n]),(0,P.useEffect)(()=>{if(!n)return;let e=new AbortController;k(null),N([]),L([]),z({}),U(!0),W(!1);async function t(){try{let t=await fetch(`${x()}/jobs/${n}`,{signal:e.signal});if(t.status===404){W(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let r=await t.json();k(r.job),N(r.events)}catch(e){if(e.name===`AbortError`)return;W(!0)}finally{e.signal.aborted||U(!1)}}return t(),()=>e.abort()},[n,f]),(0,P.useEffect)(()=>{if(!T?.pipeline_id){V([]);return}let e=T.pipeline_id;fetch(`${x()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&V(e.jobs)}).catch(()=>{})},[T?.pipeline_id,T?.status]);let Z=(0,P.useRef)(f);Z.current=f;let _e=(0,P.useRef)(null);_e.current=T?.status??null;let Q=(0,P.useRef)([]),$=(0,P.useRef)(null),ve=(0,P.useCallback)(()=>{$.current=null;let e=Q.current;e.length!==0&&(Q.current=[],N(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),ye=(0,P.useCallback)(e=>{let t=Q.current;t.push(e),t.length>1e4&&(Q.current=t.slice(-8e3)),$.current||=requestAnimationFrame(ve)},[ve]);(0,P.useEffect)(()=>()=>{$.current&&cancelAnimationFrame($.current)},[]);let be=(0,P.useCallback)(e=>{let t=e;if(!(Z.current&&t.projectId&&t.projectId!==Z.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];L(e);let n={};for(let r of e)n[r.key]=t.phases?.[r.key]??`idle`;z(n)}else if(t.type===`event`&&t.jobId===n){let e={id:Date.now(),job_id:n??``,seq:t.seq??0,event_type:t.event_type,source:t.source,payload:t.payload,timestamp:t.timestamp};ye(e)}else if(t.type===`log`&&t.processId===n){let e={id:Date.now(),job_id:n??``,seq:0,event_type:`log`,source:t.source,payload:JSON.stringify({line:t.line}),timestamp:t.timestamp};ye(e)}else if(t.type===`job.finalized`&&t.jobId===n||t.type===`job.interactive`&&t.jobId===n||(t.type===`loop.run_paused`||t.type===`loop.run_resumed`)&&t.loopRunId===n)fetch(`${x()}/jobs/${n}`).then(e=>e.json()).then(e=>k(e.job)).catch(()=>{});else if(t.type===`phase`){let e=t.phase,n=t.state;z(t=>({...t,[e]:n}))}else if(t.type===`queue`){let e=t.jobs?.find(e=>e.id===n);if(e){let t=e.status,r=_e.current;k(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`||t===`running`&&r!==`running`)&&fetch(`${x()}/jobs/${n}`).then(e=>e.json()).then(e=>k(e.job)).catch(()=>{})}}}},[n,ye]),{registerHandler:xe,unregisterHandler:Se}=s();(0,P.useEffect)(()=>(xe(`job-detail-${n}`,be),()=>Se(`job-detail-${n}`)),[n,be,xe,Se]),(0,P.useEffect)(()=>{if(!n||!T||T.status!==`running`||T.hasTelemetry)return;let e=setInterval(()=>{fetch(`${x()}/jobs/${n}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&k(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[n,T?.status,T?.hasTelemetry]);async function Ce(){if(!n)return;let t=await se({projectId:null,jobId:n});t.ok?l.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)}):t.httpStatus===null?l.error(e(`detail.toast.networkError`)):l.error(e(`detail.toast.failed`),{description:t.error})}async function we(){if(T)try{let t=await fetch(`${x()}/jobs/${T.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-${T.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){l.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function Te(){if(!(!T||Y.current)){Y.current=!0,J(!0),X.current||=typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`rerun-${T.id}-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{let t=await fetch(`${x()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":X.current},body:JSON.stringify({rerunOfJobId:T.id})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));X.current=null,l.success(e(`detail.toast.jobRequeued`)),b(`/jobs/${n.jobId}`)}catch(e){l.error(e.message)}finally{Y.current=!1,J(!1)}}}if(H)return(0,F.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,F.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,F.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(de||!T)return(0,F.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,F.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:n})}),(0,F.jsx)(S,{asChild:!0,variant:`outline`,size:`sm`,children:(0,F.jsxs)(i,{to:`/`,children:[(0,F.jsx)(j,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let Ee=fe[T.status]??fe.queued,De=T.status===`running`,Oe=T.status===`completed`||T.status===`failed`,ke=!!T.interactive,Ae=ke&&De,je=(T.tickets?.length??0)>0,Me=T.command.startsWith(`loop:`),Ne=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,costUnavailable:B.every(e=>e.total_cost_usd==null),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),nullTokenCount:B.filter(e=>e.tokens_in==null&&e.tokens_out==null&&e.tokens_cache_read==null&&e.tokens_cache_create==null).length,tokensUnavailable:B.every(e=>e.tokens_in==null&&e.tokens_out==null&&e.tokens_cache_read==null&&e.tokens_cache_create==null),jobCount:B.length}:null;return(0,F.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,F.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,F.jsxs)(i,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,F.jsx)(j,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,F.jsx)(ee,{className:`w-3 h-3`}),(0,F.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:n?.slice(0,8)})})]}),je&&(0,F.jsx)(ue,{tickets:T.tickets??[],onTicketClick:w}),(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,F.jsxs)(O,{children:[(0,F.jsx)(E,{asChild:!0,children:(0,F.jsx)(`div`,{children:(0,F.jsx)(D,{variant:Ee.variant,children:e(Ee.labelKey)})})}),(0,F.jsx)(A,{children:e(Ee.tooltipKey)})]}),(0,F.jsx)(`code`,{className:C(`font-mono text-foreground/90 truncate`,je?`text-xs text-muted-foreground`:`text-sm`),children:ce(T.command,ne)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,F.jsx)(`span`,{children:T.started_at?e(`detail.startedAgo`,{timeAgo:ae(new Date(T.started_at),{addSuffix:!0,locale:o()})}):e(`detail.queuedWaiting`)}),T.model&&(0,F.jsx)(`span`,{className:`text-muted-foreground/40`,children:T.model})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[T.hasTelemetry&&(0,F.jsxs)(O,{children:[(0,F.jsx)(E,{asChild:!0,children:(0,F.jsxs)(S,{variant:`outline`,size:`sm`,className:`h-7`,onClick:we,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,F.jsx)(re,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,F.jsx)(A,{children:e(`detail.exportDiagnosticTooltip`)})]}),Oe&&(0,F.jsxs)(O,{children:[(0,F.jsx)(E,{asChild:!0,children:(0,F.jsxs)(S,{variant:`outline`,size:`sm`,onClick:Te,disabled:ge,"aria-busy":ge,className:`h-7`,children:[(0,F.jsx)(oe,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,F.jsx)(A,{children:e(`detail.reExecuteTooltip`)})]}),De&&(0,F.jsxs)(O,{children:[(0,F.jsx)(E,{asChild:!0,children:(0,F.jsx)(S,{variant:`outline`,size:`sm`,onClick:Ce,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(ke?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,F.jsx)(A,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,F.jsx)(v,{phases:R,phaseDefinitions:I})]}),(T.status===`running`||T.status===`completed`||T.status===`failed`)&&(0,F.jsx)(le,{job:T,events:M,defaultOpen:T.status===`completed`||T.status===`running`,pipelineTotals:Ne??void 0,phases:R,phaseDefinitions:I}),(0,F.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:u?(0,F.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,F.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/50 px-3 py-1.5`,children:[`narrated`,`log`].map(e=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>he(e),"aria-pressed":G===e,"data-testid":`job-narration-mode-${e}`,className:`rounded-md px-2 py-0.5 text-[11px] font-medium transition-colors ${G===e?`bg-accent-primary/15 text-accent-primary`:`text-muted-foreground hover:bg-surface`}`,children:t(e===`narrated`?`modeNarrated`:`modeLog`)},e))}),(0,F.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:G===`narrated`?(0,F.jsx)(h,{events:M,settled:T.status!==`running`&&T.status!==`queued`,durationRange:me,elapsedMs:T.duration_ms??null,variant:`page`}):Me?(0,F.jsx)(m,{events:M,jobStatus:T.status,variant:`page`}):(0,F.jsx)(_,{events:M})})]}):Me?(0,F.jsx)(m,{events:M,jobStatus:T.status,variant:`page`}):(0,F.jsx)(_,{events:M})}),Ae&&(0,F.jsx)(y,{jobId:T.id,settleMode:T.interactiveSettleMode,initialAcceptingTurns:T.interactiveAcceptingTurns,kind:T.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`page`})]})}export{W 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{u as r}from"./chunk-KS7C4IRE-DEKu087k.js";import{a as i}from"./i18n-hnX2DPmo.js";import{n as a,t as o}from"./createLucideIcon-Bjbbp_KS.js";import{n as s}from"./dist-bVqfYmby.js";import{t as c}from"./circle-x-CMYsN4ZH.js";import{t as l}from"./trash-2-BOU3WdZZ.js";import{t as u}from"./triangle-alert-H9T4jAmh.js";import{t as d}from"./x-CBMI9ejn.js";import{a as f}from"./auth-D_5bQv5W.js";import{a as p,i as m,r as h}from"./useDesktop-BQVt8lFd.js";import{a as g,c as _,i as v,n as y,o as b,r as x,s as S,t as ee}from"./dialog-CdWCb02j.js";import{t as C}from"./button-CJqFnUOL.js";import{n as te,t as ne}from"./lib-CGdyxIWg.js";import{t as w}from"./formatDistanceToNow-DQCvMgUc.js";import{Dt as T,I as E,L as re,N as D,Ot as O,P as k,ht as ie,t as A}from"./index-DIhMEAVw.js";import{n as j,t as M}from"./job-time-BCL7wee9.js";import{t as ae}from"./format-command-C0D9IPmV.js";import{t as N}from"./ExportDropdown-BrtfWzEG.js";var oe=o(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),P=e(t(),1),F=n();function I(e){if(e==null)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function L(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function R(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function z({label:e,a:t,b:n,highlight:r}){return(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,F.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,F.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,F.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function B(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function se({jobIds:e,onClose:t}){let{t:n}=a(`jobs`),[r,i]=(0,P.useState)(null),[o,s]=(0,P.useState)(!0),[l,u]=(0,P.useState)(null),{panelRef:f,panelStyle:m,headerHandleProps:h,resizeHandles:g,isFloating:v,guardBackdrop:y}=_();(0,P.useEffect)(()=>{let t=new AbortController;return fetch(`${p()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i(e),s(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),s(!1))}),()=>t.abort()},[e]);function b(e,t){return(0,F.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,F.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,F.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,F.jsx)(O,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,F.jsx)(c,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,F.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,F.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:y(t),children:[(0,F.jsxs)(`div`,{ref:f,className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),style:m,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between ${v?`cursor-grab active:cursor-grabbing`:``}`,...h,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,F.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,F.jsx)(d,{className:`w-4 h-4`})})]}),o&&(0,F.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,F.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),l&&(0,F.jsx)(`p`,{className:`text-xs text-red-400 aurora-light:text-destructive`,children:n(`comparison.loadFailed`,{error:l})}),r&&(()=>{let[e,t]=r.jobs,i=B(e.durationMs,t.durationMs,!0),a=B(e.totalCostUsd,t.totalCostUsd,!0),o=B(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,F.jsx)(`div`,{}),b(e,0),b(t,1)]}),(0,F.jsx)(z,{label:n(`comparison.duration`),a:I(e.durationMs),b:I(t.durationMs),highlight:i}),(0,F.jsx)(z,{label:n(`comparison.cost`),a:L(e.totalCostUsd),b:L(t.totalCostUsd),highlight:a}),(0,F.jsx)(z,{label:n(`comparison.tokensOut`),a:R(e.tokensOut),b:R(t.tokensOut),highlight:o}),(0,F.jsx)(z,{label:n(`comparison.tokensIn`),a:R(e.tokensIn),b:R(t.tokensIn),highlight:null}),(0,F.jsx)(z,{label:n(`comparison.cacheRead`),a:R(e.tokensCacheRead),b:R(t.tokensCacheRead),highlight:null}),(0,F.jsx)(z,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,F.jsx)(z,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),r&&(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]}),(0,F.jsx)(S,{handles:g})]})}var ce={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.done`,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.queuedToRun`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`},skipped:{variant:`warning`,labelKey:`statusLabel.skipped`,tooltipKey:`statusTooltip.skipped`}},le=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],ue={critical:{className:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,labelKey:`recent.priority.critical`},high:{className:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,labelKey:`recent.priority.high`},normal:{className:``,labelKey:`recent.priority.normal`},low:{className:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`,labelKey:`recent.priority.low`}};function de(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function fe(e,t){let n=j(e),r=j(t);if(!n||!r)return null;let i=r.getTime()-n.getTime();if(i<0)return null;let a=Math.round(i/1e3);if(a<60)return`${a}s`;let o=Math.floor(a/60),s=a%60;return o<60?`${o}m ${s}s`:`${Math.floor(o/60)}h ${o%60}m`}function pe(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function me(e){let t=j(e);return t?w(t,{addSuffix:!0,locale:i()}):`—`}function he(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).getTime()}function ge(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r+1).getTime()-1}function _e(e,t,n){if(!t&&!n)return!0;let r=j(e);if(!r)return!0;let i=r.getTime();return!(t&&i<he(t)||n&&i>ge(n))}var V=10;function H({jobs:e,isLoading:t,error:n,onRetry:i,onJobsCleared:o,onProposalClick:c,onProposalDelete:d}){let{t:f}=a(`jobs`),m=r(),{activeProjectId:te,projects:ne}=h(),w=ne.find(e=>e.id===te)?.provider,[O,A]=(0,P.useState)(null),[j,N]=(0,P.useState)(``),[I,L]=(0,P.useState)(``),[R,z]=(0,P.useState)(!1),[B,H]=(0,P.useState)(``),[U,W]=(0,P.useState)(``),[G,ve]=(0,P.useState)(!1),[K,q]=(0,P.useState)(null),[J,ye]=(0,P.useState)(V),[Y,be]=(0,P.useState)(!1),[X,Z]=(0,P.useState)([]),[xe,Q]=(0,P.useState)(null),{panelRef:Se,panelStyle:Ce,headerHandleProps:we,resizeHandles:Te,isFloating:Ee,guardBackdrop:De}=_();(0,P.useEffect)(()=>{ye(V)},[e.length]);function Oe(){be(e=>!e),Z([])}function ke(e){Z(t=>{if(t.includes(e))return t.filter(t=>t!==e);if(t.length>=2)return t;let n=[...t,e];return n.length===2&&Q(n),n})}let $=e.filter(e=>O&&e.status!==O?!1:_e(M(e),j,I)),Ae=e.filter(e=>_e(M(e),B,U)).length;async function je(e){ve(!0);try{let t={};e===`range`&&(B&&(t.from=new Date(he(B)).toISOString()),U&&(t.to=new Date(ge(U)).toISOString()));let n=await fetch(`${p()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(n.ok){let e=await n.json();s.success(f(`recent.toast.cleared`,{count:e.deleted})),z(!1),H(``),W(``),o?.()}else s.error(f(`recent.toast.clearFailed`))}catch{s.error(f(`recent.toast.networkError`))}finally{ve(!1)}}let Me=n?(0,F.jsxs)(`div`,{role:`alert`,"data-testid":`jobs-load-error`,className:`flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,F.jsx)(u,{className:`h-4 w-4 shrink-0`}),(0,F.jsx)(`span`,{className:`flex-1`,children:f(`recent.loadFailed`)}),i&&(0,F.jsx)(C,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,onClick:i,disabled:t,children:f(`common:actions.retry`)})]}):null;return n&&e.length===0?(0,F.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:Me}):t&&e.length===0?(0,F.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,F.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,F.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,F.jsx)(T,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:f(`recent.emptyTitle`)}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:f(`recent.emptyDescription`)})]}):(0,F.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[Me,(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>A(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${O===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:f(`recent.filterAll`,{count:e.length})}),le.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,F.jsx)(`button`,{type:`button`,onClick:()=>A(O===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${O===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:f(`recent.filterStatus`,{status:f(`statusName.${t}`),count:n})},t)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`input`,{type:`date`,value:j,onChange:e=>N(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:f(`recent.fromDate`)}),(0,F.jsx)(`input`,{type:`date`,value:I,onChange:e=>L(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:f(`recent.toDate`)}),(j||I)&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>{N(``),L(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:f(`recent.clear`)}),(0,F.jsxs)(D,{children:[(0,F.jsx)(E,{asChild:!0,children:(0,F.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${Y?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:Oe,children:(0,F.jsx)(oe,{className:`w-3.5 h-3.5`})})}),(0,F.jsx)(k,{children:f(Y?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,F.jsxs)(D,{children:[(0,F.jsx)(E,{asChild:!0,children:(0,F.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>z(!0),children:(0,F.jsx)(l,{className:`w-3.5 h-3.5`})})}),(0,F.jsx)(k,{children:f(`recent.clearJobs`)})]})]})]}),Y&&(0,F.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-accent/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,F.jsxs)(`span`,{children:[X.length===0&&f(`recent.selectTwoToCompare`),X.length===1&&f(`recent.selectOneMore`),X.length===2&&f(`recent.readyToCompare`)]}),X.length===2&&(0,F.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Q(X),children:f(`recent.compareAction`)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,F.jsx)(`span`,{className:`w-14`,children:f(`recent.colStatus`)}),(0,F.jsx)(`span`,{className:`flex-1 min-w-0`,children:f(`recent.colCommand`)}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,F.jsx)(`span`,{className:`w-14 text-right`,children:f(`recent.colDuration`)}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colTokens`)}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colCost`)}),(0,F.jsx)(`span`,{className:`w-20 text-right`,children:f(`recent.colStarted`)})]})]}),(0,F.jsx)(`div`,{className:`space-y-0.5`,children:$.slice(0,J).map(e=>{let t=ce[e.status]??ce.queued,n=de(e.total_cost_usd),r=fe(e.started_at,e.finished_at),i=pe((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),a=e.id.startsWith(`proposal:`),o=a?e.id.replace(`proposal:`,``):null,s=X.includes(e.id),u=Y&&!a&&X.length===2&&!s,d=()=>{if(Y&&!a){ke(e.id);return}a&&o?c?.(o):m(`/jobs/${e.id}`)};return(0,F.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${s?`bg-accent/70 ring-1 ring-border`:u?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:d,onKeyDown:e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),d()))},children:[(0,F.jsxs)(D,{children:[(0,F.jsx)(E,{asChild:!0,children:(0,F.jsx)(`div`,{children:(0,F.jsx)(re,{variant:t.variant,children:f(t.labelKey)})})}),(0,F.jsx)(k,{children:f(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,F.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${ue[e.priority].className}`,children:f(ue[e.priority].labelKey)}),e.profile_name&&(0,F.jsxs)(D,{children:[(0,F.jsx)(E,{asChild:!0,children:(0,F.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border border-accent-primary/40 bg-accent-primary/10 text-accent-primary/90`,children:e.profile_name})}),(0,F.jsx)(k,{children:f(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,F.jsxs)(D,{children:[(0,F.jsx)(E,{asChild:!0,children:(0,F.jsx)(ie,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,F.jsxs)(k,{children:[f(`recent.pipelinePart`),e.depends_on_job_id&&` ${f(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,F.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:ae(e.command,w)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,F.jsx)(`span`,{className:`w-14 text-right`,children:r??`—`}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:i?`${i}`:`—`}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,F.jsx)(`span`,{className:`w-20 text-right`,children:e.status===`queued`?`—`:me(e.started_at)}),a&&o&&(0,F.jsx)(`button`,{type:`button`,className:`w-4 h-4 md:opacity-0 md:group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all`,onClick:e=>{e.stopPropagation(),q(o)},title:f(`recent.deleteProposal`),children:(0,F.jsx)(l,{className:`w-3 h-3`})})]})]},e.id)})}),$.length>J&&(0,F.jsx)(`div`,{className:`pt-1 text-center`,children:(0,F.jsx)(`button`,{type:`button`,onClick:()=>ye(e=>e+V),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:f(`recent.loadMore`,{count:$.length-J})})}),R&&(0,F.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:De(()=>z(!1)),children:[(0,F.jsxs)(`div`,{ref:Se,className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),style:Ce,children:[(0,F.jsxs)(`div`,{...we,className:Ee?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,F.jsx)(`h3`,{className:`text-sm font-semibold`,children:f(`recent.clearModal.title`)}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:f(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,F.jsx)(C,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:G,onClick:()=>je(`all`),children:f(`recent.clearModal.clearAll`,{count:e.length})}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f(`recent.clearModal.orByRange`)}),(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(`input`,{type:`date`,value:B,onChange:e=>H(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:f(`recent.clearModal.fromPlaceholder`)}),(0,F.jsx)(`input`,{type:`date`,value:U,onChange:e=>W(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:f(`recent.clearModal.toPlaceholder`)})]}),(0,F.jsx)(C,{variant:`outline`,size:`sm`,className:`w-full`,disabled:G||!B&&!U,onClick:()=>je(`range`),children:B||U?f(`recent.clearModal.clearInRange`,{count:Ae}):f(`recent.clearModal.clearRange`)})]}),(0,F.jsx)(C,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>z(!1),children:f(`common:actions.cancel`)})]}),(0,F.jsx)(S,{handles:Te})]}),(0,F.jsx)(ee,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,F.jsxs)(y,{className:`max-w-sm`,children:[(0,F.jsxs)(g,{children:[(0,F.jsx)(b,{children:f(`recent.deleteProposalConfirm.title`)}),(0,F.jsx)(x,{children:f(`recent.deleteProposalConfirm.description`)})]}),(0,F.jsxs)(v,{children:[(0,F.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>q(null),children:f(`common:actions.cancel`)}),(0,F.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{K&&d?.(K),q(null)},children:f(`common:actions.delete`)})]})]})}),xe&&(0,F.jsx)(se,{jobIds:xe,onClose:()=>{Q(null),Z([]),be(!1)}})]})}var U={input:`page.proposal.status.input`,exploring:`page.proposal.status.exploring`,review:`page.proposal.status.review`,refining:`page.proposal.status.refining`,creating_issue:`page.proposal.status.creatingIssue`,created:`page.proposal.status.created`,cancelled:`page.proposal.status.cancelled`};function W(e){return`${f}/api/projects/${encodeURIComponent(e)}`}function G(){let{t:e}=a(`jobs`),{activeProjectId:t}=h(),{recentJobs:n}=A(t),{data:r,isFirstLoad:i,isLoading:o,error:c,refresh:l}=m({namespace:`jobs`,projectId:t,initialValue:n,fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${W(e)}/jobs?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch jobs: ${n.status}`);return(await n.json()).jobs},pollInterval:1e4}),{data:u,isFirstLoad:d,isLoading:f,error:_,refresh:x}=m({namespace:`proposals`,projectId:t,initialValue:[],fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${W(e)}/propose?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch proposals: ${n.status}`);return(await n.json()).proposals},pollInterval:1e4}),S={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},w=u.map(e=>({id:`proposal:${e.id}`,command:`/specrails:propose-feature ${e.idea.length>60?e.idea.slice(0,57)+`...`:e.idea}`,started_at:e.created_at,enqueued_at:e.created_at,status:S[e.status]??`queued`})),T=[...r,...w].sort((e,t)=>(j(M(t))?.getTime()??0)-(j(M(e))?.getTime()??0)),[E,D]=(0,P.useState)(null),O=(0,P.useCallback)(async e=>{try{let t=await fetch(`${p()}/propose/${e}`);if(!t.ok)return;let n=await t.json();D(n.proposal)}catch{}},[]),k=(0,P.useCallback)(async t=>{try{(await fetch(`${p()}/propose/${t}`,{method:`DELETE`})).ok&&(s.success(e(`page.proposalDeleted`)),await x())}catch{}},[x,e]);return(0,F.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,F.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,F.jsx)(N,{baseUrl:`${p()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,F.jsx)(H,{jobs:T,isLoading:i||d||o||f,error:c??_,onRetry:()=>{Promise.all([l(),x()])},onJobsCleared:l,onProposalClick:O,onProposalDelete:k}),(0,F.jsx)(ee,{open:E!==null,onOpenChange:e=>!e&&D(null),children:(0,F.jsx)(y,{className:`max-w-3xl glass-card`,children:E&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(g,{children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(b,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,F.jsx)(re,{variant:E.status===`created`?`success`:E.status===`cancelled`?`destructive`:`secondary`,children:e(U[E.status]??`page.proposal.status.unknown`,{status:E.status})})]})}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:E.idea}),E.result_markdown?(0,F.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,F.jsx)(`div`,{className:`prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-code:text-cyan-300 prose-code:text-[10px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded text-foreground/80`,children:(0,F.jsx)(te,{remarkPlugins:[ne],children:E.result_markdown})})}):(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),E.issue_url&&(0,F.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,F.jsx)(`a`,{href:E.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:E.issue_url})]}),(0,F.jsxs)(v,{children:[(0,F.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{k(E.id),D(null)},children:e(`common:actions.delete`)}),(0,F.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>D(null),children:e(`common:actions.close`)})]})]})})})]})}export{G as default};
|