factory-factory 0.5.5 → 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +5 -4
  2. package/dist/client/assets/{DotsThree.es-3R3Ey_3J.js → DotsThree.es-6Y3ru9Fr.js} +1 -1
  3. package/dist/client/assets/{abnfDiagram-WEYOIA3C-Bee0noBy.js → abnfDiagram-WEYOIA3C-Bz-2NjrY.js} +1 -1
  4. package/dist/client/assets/{admin-page-DfuRxjZu.js → admin-page-N8bqsl_U.js} +1 -1
  5. package/dist/client/assets/{agent-authoring-DisJfxVO.js → agent-authoring-C33uSQgC.js} +1 -1
  6. package/dist/client/assets/{agents-CfdFfTgO.js → agents-BNAsXKbn.js} +1 -1
  7. package/dist/client/assets/{agents-Dk3H1TXr.js → agents-MwqMFVNs.js} +1 -1
  8. package/dist/client/assets/{architectureDiagram-ZHVYKT53-BLmWRglN.js → architectureDiagram-ZHVYKT53-CpoGyKeM.js} +1 -1
  9. package/dist/client/assets/{chat-k4KrNKEG.js → chat-B7u27d-i.js} +6 -6
  10. package/dist/client/assets/{chunk-2E7WHVMD-w7vgcqiS.js → chunk-2E7WHVMD-Baod-BdE.js} +1 -1
  11. package/dist/client/assets/{chunk-NQOKRVIF-KtzgEnyd.js → chunk-NQOKRVIF-LCflra3k.js} +1 -1
  12. package/dist/client/assets/{classDiagram-v2-4MYWR3UA-CEW1Tyc1.js → classDiagram-v2-4MYWR3UA-MRjV_MIA.js} +1 -1
  13. package/dist/client/assets/client-modules.json +1 -1
  14. package/dist/client/assets/{codex-accounts-DneS5v9d.js → codex-accounts-DP-Tb-tZ.js} +1 -1
  15. package/dist/client/assets/{cynefinDiagram-WF24UDRP-D1ROISR-.js → cynefinDiagram-WF24UDRP-bzsiqTUL.js} +1 -1
  16. package/dist/client/assets/{data-import-button-_xEBb5se.js → data-import-button-BqRlwClc.js} +1 -1
  17. package/dist/client/assets/detail-BXmaqHTp.js +2 -0
  18. package/dist/client/assets/{diagram-CBK3MWTC-DmmdvgW0.js → diagram-CBK3MWTC-DjtO1Qi7.js} +1 -1
  19. package/dist/client/assets/{diagram-I5XIIV2D-DWcHOCm7.js → diagram-I5XIIV2D-EW0H2MNl.js} +1 -1
  20. package/dist/client/assets/{diagram-ODIL2UCW-CCjV8NYE.js → diagram-ODIL2UCW-DSWSmg75.js} +1 -1
  21. package/dist/client/assets/{diagram-RJA3I4VV-CPsIPBHP.js → diagram-RJA3I4VV-DGCPPXy9.js} +1 -1
  22. package/dist/client/assets/{diagram-TYUNFSNR-DfiCPVDZ.js → diagram-TYUNFSNR-BRE0O5UU.js} +1 -1
  23. package/dist/client/assets/{diff-viewer-B3Gavo18.js → diff-viewer-B2pMcSUo.js} +1 -1
  24. package/dist/client/assets/{ebnfDiagram-V4P3TTPT-DFgHqp_A.js → ebnfDiagram-V4P3TTPT-LN1BHyLk.js} +1 -1
  25. package/dist/client/assets/{erDiagram-KYQIGQAA-3CMf47Oo.js → erDiagram-KYQIGQAA-BagoNO7h.js} +1 -1
  26. package/dist/client/assets/{event-agent-workspace-form-BRo9-ant.js → event-agent-workspace-form-D6EZQxOA.js} +1 -1
  27. package/dist/client/assets/{file-viewer-j5Jpwj03.js → file-viewer-ByqeZE0U.js} +1 -1
  28. package/dist/client/assets/{flowDiagram-IUGLLWBU-BibxWOGu.js → flowDiagram-IUGLLWBU-D263u80I.js} +1 -1
  29. package/dist/client/assets/{highlighted-body-JLMTFACH-CTYCDAzZ.js → highlighted-body-JLMTFACH-CMb21a0T.js} +1 -1
  30. package/dist/client/assets/{home-JqvALE6e.js → home-9nWsYf3c.js} +1 -1
  31. package/dist/client/assets/index-ClP2IiKy.css +2 -0
  32. package/dist/client/assets/index-GmSorqXd.js +12 -0
  33. package/dist/client/assets/{infoDiagram-MVDRKAX5-DSWdrt8D.js → infoDiagram-MVDRKAX5-DqtZTfKx.js} +1 -1
  34. package/dist/client/assets/{inline-workspace-form-Bz5l2APT.js → inline-workspace-form-DTOd1_IQ.js} +1 -1
  35. package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-FSgsA2AR.js → ishikawaDiagram-HPEHV2GE-S--AK0b5.js} +1 -1
  36. package/dist/client/assets/{issue-launch-sheet-BRDwvTJ4.js → issue-launch-sheet-Cmq9AmXu.js} +1 -1
  37. package/dist/client/assets/{kanban-BdZGeiS3.js → kanban-DFqdaBrr.js} +1 -1
  38. package/dist/client/assets/{kanban-card-rSBlZkVU.js → kanban-card-CKNGUrJa.js} +1 -1
  39. package/dist/client/assets/{kanban-definition-FNSA4HC5-tMB1t3DY.js → kanban-definition-FNSA4HC5-BstZV_2x.js} +1 -1
  40. package/dist/client/assets/{legacy-BTW92e33.js → legacy-BK7U5o2y.js} +1 -1
  41. package/dist/client/assets/{legacy-V_60vIE-.js → legacy-D010j6qa.js} +1 -1
  42. package/dist/client/assets/{list-BmKFMI74.js → list-C2HYpkqg.js} +1 -1
  43. package/dist/client/assets/{list-DsaPNjwB.js → list-DG7Grxw5.js} +1 -1
  44. package/dist/client/assets/{logs-BOc2McRY.js → logs-C5_FYDNK.js} +1 -1
  45. package/dist/client/assets/mermaid-WFAXDIZX-ClIEnuTo.js +1 -0
  46. package/dist/client/assets/{mermaid-diagram-xMTMF9cZ.js → mermaid-diagram-7d3eG33H.js} +4 -4
  47. package/dist/client/assets/{mindmap-definition-6OY57UG3-j7CA3P01.js → mindmap-definition-6OY57UG3-flOx3ZeG.js} +1 -1
  48. package/dist/client/assets/{mobile-baseline-L5CeIxdL.js → mobile-baseline-oXH_VGTz.js} +1 -1
  49. package/dist/client/assets/new-C8WYrcew.js +1 -0
  50. package/dist/client/assets/{new-D7tQEfVC.js → new-COoW_By1.js} +1 -1
  51. package/dist/client/assets/{pegDiagram-ECIUJNBX-DEegjstG.js → pegDiagram-ECIUJNBX-BrDIK58N.js} +1 -1
  52. package/dist/client/assets/{pieDiagram-GNMPY74T-dwwO6W-b.js → pieDiagram-GNMPY74T-BMzBw5t-.js} +1 -1
  53. package/dist/client/assets/{pr-inbox-item-B5bRWOFi.js → pr-inbox-item-vHdTaoxd.js} +1 -1
  54. package/dist/client/assets/project-CBrecHcv.js +1 -0
  55. package/dist/client/assets/project-header-BG9_VlHh.js +1 -0
  56. package/dist/client/assets/{project-repo-form-auALDtmF.js → project-repo-form-6aODqQni.js} +1 -1
  57. package/dist/client/assets/{provider-cli-warning-zS21ocrg.js → provider-cli-warning-Bcg15rKf.js} +1 -1
  58. package/dist/client/assets/{query-state-CXtAqj2j.js → query-state-BVQj0phN.js} +1 -1
  59. package/dist/client/assets/{railroadDiagram-Y72NRBL7-D7Uog2Fm.js → railroadDiagram-Y72NRBL7-3Eck62Bi.js} +1 -1
  60. package/dist/client/assets/{requirementDiagram-EQYSW5RA-B3wNTb-Q.js → requirementDiagram-EQYSW5RA-rbuIMTLU.js} +1 -1
  61. package/dist/client/assets/{reviews-CDcqIqww.js → reviews-Dbotug95.js} +1 -1
  62. package/dist/client/assets/{right-panel-Da3HBtP9.js → right-panel-DaLnLjFu.js} +3 -3
  63. package/dist/client/assets/{sequenceDiagram-BLEHNHQU-DP_HwtCk.js → sequenceDiagram-BLEHNHQU-CvP7tfWl.js} +1 -1
  64. package/dist/client/assets/{settings-page-layout-GGXQVcn2.js → settings-page-layout-DWVd1wTJ.js} +1 -1
  65. package/dist/client/assets/{setup-terminal-modal-BkWxwfcM.js → setup-terminal-modal--e19kzCo.js} +2 -2
  66. package/dist/client/assets/{startup-script-form-C-ML7N9W.js → startup-script-form-BX-97uzx.js} +1 -1
  67. package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-DJI19fIo.js → stateDiagram-v2-A6IESKWZ-DPQNuXMb.js} +1 -1
  68. package/dist/client/assets/{swimlanesDiagram-AYQRV4AK-B9lsGgJz.js → swimlanesDiagram-AYQRV4AK-DBayrG3m.js} +1 -1
  69. package/dist/client/assets/{terminal-instance-Bj45VPmw.js → terminal-instance-Bhh6-6sl.js} +1 -1
  70. package/dist/client/assets/{timeline-definition-JXYKGLGB-CW_cFL5m.js → timeline-definition-JXYKGLGB-C14nrPRo.js} +1 -1
  71. package/dist/client/assets/{transcript-scroll-fixture-CRCDh-Wd.js → transcript-scroll-fixture-CLt6Bmfz.js} +1 -1
  72. package/dist/client/assets/use-project-header-navigation-D_Gx1LQ9.js +1 -0
  73. package/dist/client/assets/{use-workspace-creation-draft-CofTBRfu.js → use-workspace-creation-draft-BcIClFw-.js} +1 -1
  74. package/dist/client/assets/{use-workspace-project-navigation-B3bveEA4.js → use-workspace-project-navigation-D6kEMUHY.js} +1 -1
  75. package/dist/client/assets/{usecaseDiagram-WPOLBNNX-MCJs1VFk.js → usecaseDiagram-WPOLBNNX-CC_KUwpc.js} +1 -1
  76. package/dist/client/assets/{vennDiagram-Q3Y3IDCW-DV_BPr8T.js → vennDiagram-Q3Y3IDCW-BKPUQxLZ.js} +1 -1
  77. package/dist/client/assets/{wardleyDiagram-IVAIDKWA-E_U6VORQ.js → wardleyDiagram-IVAIDKWA-pZxWIAfq.js} +1 -1
  78. package/dist/client/assets/{websocket-DW_R60Td.js → websocket-Q9XnceTt.js} +1 -1
  79. package/dist/client/assets/{workspace-creation-drop-drain-Dk5pygZx.js → workspace-creation-drop-drain-6HaYe14j.js} +1 -1
  80. package/dist/client/assets/{xychartDiagram-4URNHDU4-BBqR12LO.js → xychartDiagram-4URNHDU4-v1OTdqDZ.js} +1 -1
  81. package/dist/client/index.html +2 -2
  82. package/dist/src/backend/services/workspace/service/query/workspace-query.service.d.ts +4 -0
  83. package/dist/src/backend/services/workspace/service/query/workspace-query.service.d.ts.map +1 -1
  84. package/dist/src/backend/services/workspace/service/query/workspace-query.service.js +7 -0
  85. package/dist/src/backend/services/workspace/service/query/workspace-query.service.js.map +1 -1
  86. package/dist/src/backend/services/workspace/service/query/workspace-query.service.test.js +15 -0
  87. package/dist/src/backend/services/workspace/service/query/workspace-query.service.test.js.map +1 -1
  88. package/dist/src/backend/services/workspace/service/worktree/git-ops.service.d.ts.map +1 -1
  89. package/dist/src/backend/services/workspace/service/worktree/git-ops.service.js +3 -3
  90. package/dist/src/backend/services/workspace/service/worktree/git-ops.service.js.map +1 -1
  91. package/dist/src/backend/services/workspace/service/worktree/git-ops.service.test.js +30 -6
  92. package/dist/src/backend/services/workspace/service/worktree/git-ops.service.test.js.map +1 -1
  93. package/dist/src/backend/services/workspace/service/worktree/git-ops.symlink.integration.test.js +1 -4
  94. package/dist/src/backend/services/workspace/service/worktree/git-ops.symlink.integration.test.js.map +1 -1
  95. package/dist/src/backend/services/workspace-git-state.concurrency.test.js +6 -1
  96. package/dist/src/backend/services/workspace-git-state.concurrency.test.js.map +1 -1
  97. package/dist/src/backend/services/workspace-git-state.linux.test.d.ts +2 -0
  98. package/dist/src/backend/services/workspace-git-state.linux.test.d.ts.map +1 -0
  99. package/dist/src/backend/services/workspace-git-state.linux.test.js +68 -0
  100. package/dist/src/backend/services/workspace-git-state.linux.test.js.map +1 -0
  101. package/dist/src/backend/services/workspace-git-state.service.d.ts +4 -0
  102. package/dist/src/backend/services/workspace-git-state.service.d.ts.map +1 -1
  103. package/dist/src/backend/services/workspace-git-state.service.js +39 -7
  104. package/dist/src/backend/services/workspace-git-state.service.js.map +1 -1
  105. package/dist/src/backend/services/workspace-git-state.service.test.js +104 -3
  106. package/dist/src/backend/services/workspace-git-state.service.test.js.map +1 -1
  107. package/dist/src/backend/services/workspace-git-state.untracked.test.d.ts +2 -0
  108. package/dist/src/backend/services/workspace-git-state.untracked.test.d.ts.map +1 -0
  109. package/dist/src/backend/services/workspace-git-state.untracked.test.js +32 -0
  110. package/dist/src/backend/services/workspace-git-state.untracked.test.js.map +1 -0
  111. package/dist/src/backend/testing/npm-publish-workflow.test.js +8 -9
  112. package/dist/src/backend/testing/npm-publish-workflow.test.js.map +1 -1
  113. package/dist/src/backend/trpc/index.d.ts +10 -8
  114. package/dist/src/backend/trpc/index.d.ts.map +1 -1
  115. package/dist/src/backend/trpc/project.router.test.js +34 -0
  116. package/dist/src/backend/trpc/project.router.test.js.map +1 -1
  117. package/dist/src/backend/trpc/project.trpc.d.ts +10 -8
  118. package/dist/src/backend/trpc/project.trpc.d.ts.map +1 -1
  119. package/dist/src/backend/trpc/project.trpc.js +19 -1
  120. package/dist/src/backend/trpc/project.trpc.js.map +1 -1
  121. package/dist/tsconfig.backend.tsbuildinfo +1 -1
  122. package/package.json +46 -46
  123. package/scripts/postinstall.mjs +16 -50
  124. package/dist/client/assets/detail-nvqdqAi4.js +0 -2
  125. package/dist/client/assets/index-CsEmj4uI.js +0 -12
  126. package/dist/client/assets/index-Dv7JoSz4.css +0 -2
  127. package/dist/client/assets/mermaid-WFAXDIZX-BEvuy0OL.js +0 -1
  128. package/dist/client/assets/new-BQd-dhG6.js +0 -1
  129. package/dist/client/assets/project-Dsu4tgVT.js +0 -1
  130. package/dist/client/assets/project-header-HAvaNT0j.js +0 -1
  131. package/dist/client/assets/use-project-header-navigation-D1btSafx.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "factory-factory",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "description": "Workspace-based coding environment for running multiple Claude Code and Codex sessions in parallel",
5
5
  "private": false,
6
6
  "license": "MIT",
@@ -110,47 +110,15 @@
110
110
  "@agentclientprotocol/codex-acp": "2.5.0",
111
111
  "@agentclientprotocol/sdk": "2.2.0",
112
112
  "@anthropic-ai/claude-agent-sdk": "0.3.316",
113
- "@daypicker/react": "^10.0.2",
114
113
  "@linear/sdk": "^100.0.0",
115
- "@phosphor-icons/react": "^2.1.10",
116
114
  "@prisma/adapter-better-sqlite3": "7.10.1",
117
115
  "@prisma/client": "7.10.1",
118
- "@radix-ui/react-alert-dialog": "^1.2.1",
119
- "@radix-ui/react-checkbox": "^1.4.1",
120
- "@radix-ui/react-collapsible": "^1.2.1",
121
- "@radix-ui/react-context-menu": "^2.4.1",
122
- "@radix-ui/react-dialog": "^1.3.1",
123
- "@radix-ui/react-dropdown-menu": "^2.2.1",
124
- "@radix-ui/react-label": "^2.1.17",
125
- "@radix-ui/react-popover": "^1.3.1",
126
- "@radix-ui/react-progress": "^1.2.1",
127
- "@radix-ui/react-radio-group": "^1.5.1",
128
- "@radix-ui/react-scroll-area": "^1.4.0",
129
- "@radix-ui/react-select": "^2.4.1",
130
- "@radix-ui/react-separator": "^1.2.0",
131
- "@radix-ui/react-slider": "^1.6.1",
132
- "@radix-ui/react-slot": "^1.5.0",
133
- "@radix-ui/react-switch": "^1.4.1",
134
- "@radix-ui/react-tabs": "^1.2.1",
135
- "@radix-ui/react-toggle": "^1.2.1",
136
- "@radix-ui/react-tooltip": "^1.4.1",
137
- "@tanstack/react-query": "^5.105.1",
138
- "@tanstack/react-virtual": "^3.14.25",
139
- "@trpc/client": "^11.22.1",
140
- "@trpc/react-query": "^11.22.1",
141
116
  "@trpc/server": "^11.22.1",
142
- "@xterm/addon-fit": "^0.11.0",
143
- "@xterm/xterm": "^6.0.0",
144
117
  "better-sqlite3": "^13.0.3",
145
118
  "chalk": "^6.0.1",
146
- "class-variance-authority": "^0.7.1",
147
- "clsx": "^2.1.1",
148
- "cmdk": "^1.1.1",
149
119
  "commander": "^15.0.0",
150
- "date-fns": "^4.4.0",
151
120
  "dotenv": "^18.0.9",
152
121
  "express": "^5.3.0",
153
- "mermaid": "^12.2.0",
154
122
  "node-pty": "^1.1.0",
155
123
  "open": "^11.0.4",
156
124
  "p-limit": "^7.3.3",
@@ -158,21 +126,8 @@
158
126
  "prisma": "7.10.1",
159
127
  "qrcode": "^1.5.4",
160
128
  "re2js": "2.9.1",
161
- "react": "^19.3.1",
162
- "react-dom": "^19.3.1",
163
- "react-markdown": "^10.1.0",
164
- "react-resizable-panels": "^4.16.0",
165
- "react-router": "^8.5.1",
166
- "react-syntax-highlighter": "^16.1.2",
167
- "refractor": "^5.0.0",
168
- "rehype-raw": "^7.0.0",
169
- "rehype-sanitize": "^6.0.0",
170
- "remark-gfm": "^4.0.1",
171
129
  "smol-toml": "1.9.1",
172
- "sonner": "^2.0.8",
173
- "streamdown": "2.7.1",
174
130
  "superjson": "^2.2.6",
175
- "tailwind-merge": "^3.7.0",
176
131
  "tree-kill": "^1.2.2",
177
132
  "ws": "^8.22.1",
178
133
  "zod": "^4.6.7"
@@ -197,8 +152,29 @@
197
152
  },
198
153
  "devDependencies": {
199
154
  "@biomejs/biome": "2.6.4",
155
+ "@daypicker/react": "^10.0.2",
200
156
  "@electron/rebuild": "^4.2.1",
157
+ "@phosphor-icons/react": "^2.1.10",
201
158
  "@playwright/test": "^1.64.1",
159
+ "@radix-ui/react-alert-dialog": "^1.2.1",
160
+ "@radix-ui/react-checkbox": "^1.4.1",
161
+ "@radix-ui/react-collapsible": "^1.2.1",
162
+ "@radix-ui/react-context-menu": "^2.4.1",
163
+ "@radix-ui/react-dialog": "^1.3.1",
164
+ "@radix-ui/react-dropdown-menu": "^2.2.1",
165
+ "@radix-ui/react-label": "^2.1.17",
166
+ "@radix-ui/react-popover": "^1.3.1",
167
+ "@radix-ui/react-progress": "^1.2.1",
168
+ "@radix-ui/react-radio-group": "^1.5.1",
169
+ "@radix-ui/react-scroll-area": "^1.4.0",
170
+ "@radix-ui/react-select": "^2.4.1",
171
+ "@radix-ui/react-separator": "^1.2.0",
172
+ "@radix-ui/react-slider": "^1.6.1",
173
+ "@radix-ui/react-slot": "^1.5.0",
174
+ "@radix-ui/react-switch": "^1.4.1",
175
+ "@radix-ui/react-tabs": "^1.2.1",
176
+ "@radix-ui/react-toggle": "^1.2.1",
177
+ "@radix-ui/react-tooltip": "^1.4.1",
202
178
  "@storybook/addon-a11y": "10.6.5",
203
179
  "@storybook/addon-docs": "10.6.5",
204
180
  "@storybook/addon-themes": "10.6.5",
@@ -207,6 +183,10 @@
207
183
  "@storybook/react-vite": "10.6.5",
208
184
  "@tailwindcss/typography": "^0.5.20",
209
185
  "@tailwindcss/vite": "^4.3.3",
186
+ "@tanstack/react-query": "^5.105.1",
187
+ "@tanstack/react-virtual": "^3.14.25",
188
+ "@trpc/client": "^11.22.1",
189
+ "@trpc/react-query": "^11.22.1",
210
190
  "@types/better-sqlite3": "^9.6.0",
211
191
  "@types/express": "^5.0.6",
212
192
  "@types/node": "^26.6.6",
@@ -221,7 +201,13 @@
221
201
  "@vitejs/plugin-react": "^6.1.2",
222
202
  "@vitest/browser-playwright": "5.0.5",
223
203
  "@vitest/coverage-v8": "5.0.5",
204
+ "@xterm/addon-fit": "^0.11.0",
205
+ "@xterm/xterm": "^6.0.0",
206
+ "class-variance-authority": "^0.7.1",
207
+ "clsx": "^2.1.1",
208
+ "cmdk": "^1.1.1",
224
209
  "concurrently": "^10.0.6",
210
+ "date-fns": "^4.4.0",
225
211
  "dependency-cruiser": "^18.7.0",
226
212
  "electron": "^45.2.1",
227
213
  "electron-builder": "^26.18.0",
@@ -229,13 +215,27 @@
229
215
  "jsdom": "^30.1.3",
230
216
  "knip": "^6.44.1",
231
217
  "lint-staged": "^17.6.0",
218
+ "mermaid": "^12.2.0",
232
219
  "next-themes": "^0.4.6",
233
220
  "opentype.js": "^2.0.0",
234
221
  "oxfmt": "0.75.0",
235
222
  "oxlint": "1.90.0",
236
223
  "oxlint-tsgolint": "7.0.2005",
224
+ "react": "^19.3.1",
225
+ "react-dom": "^19.3.1",
226
+ "react-markdown": "^10.1.0",
227
+ "react-resizable-panels": "^4.16.0",
228
+ "react-router": "^8.5.1",
229
+ "react-syntax-highlighter": "^16.1.2",
230
+ "refractor": "^5.0.0",
231
+ "rehype-raw": "^7.0.0",
232
+ "rehype-sanitize": "^6.0.0",
233
+ "remark-gfm": "^4.0.1",
234
+ "sonner": "^2.0.8",
237
235
  "storybook": "10.6.5",
236
+ "streamdown": "2.7.1",
238
237
  "supertest": "^7.3.1",
238
+ "tailwind-merge": "^3.7.0",
239
239
  "tailwindcss": "^4.3.3",
240
240
  "tsc-alias": "^1.9.10",
241
241
  "tsx": "^4.23.15",
@@ -9,9 +9,9 @@
9
9
  */
10
10
 
11
11
  import { execFileSync } from 'node:child_process';
12
- import { existsSync, chmodSync, readdirSync } from 'node:fs';
12
+ import { existsSync, chmodSync, lstatSync, realpathSync } from 'node:fs';
13
13
  import { createRequire } from 'node:module';
14
- import { join, dirname } from 'node:path';
14
+ import { join, dirname, relative, isAbsolute, sep } from 'node:path';
15
15
  import { fileURLToPath } from 'node:url';
16
16
 
17
17
  const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -38,58 +38,24 @@ if (isSourceCheckout && existsSync(schemaPath)) {
38
38
  }
39
39
  }
40
40
 
41
- // Fix node-pty spawn-helper permissions (Unix only)
42
- // This handles both local node_modules and npx cache installations
41
+ // node-pty 1.1.0 publishes Darwin helpers without executable permission.
42
+ // Resolve the actual dependency rather than searching unrelated ancestor trees.
43
43
  if (process.platform !== 'win32') {
44
- /**
45
- * Fix spawn-helper permissions in a given prebuilds directory
46
- */
47
- function fixSpawnHelperPermissions(prebuildsDir) {
48
- if (!existsSync(prebuildsDir)) {
49
- return false;
50
- }
51
-
52
- let fixed = false;
53
- for (const platform of readdirSync(prebuildsDir)) {
54
- const spawnHelper = join(prebuildsDir, platform, 'spawn-helper');
55
- if (existsSync(spawnHelper)) {
56
- try {
57
- chmodSync(spawnHelper, 0o755);
58
- fixed = true;
59
- } catch {
60
- // Ignore permission errors
61
- }
62
- }
63
- }
64
- return fixed;
65
- }
66
-
67
- // 1. Fix in local node_modules (standard install)
68
44
  try {
69
- const localPrebuilds = join(projectRoot, 'node_modules', 'node-pty', 'prebuilds');
70
- fixSpawnHelperPermissions(localPrebuilds);
71
- } catch {
72
- // Ignore if node-pty doesn't exist locally
73
- }
74
-
75
- // 2. Fix in the directory where this script is running from (npx case)
76
- // When run via npx, the module is in a different location
77
- try {
78
- // Walk up from __dirname to find node_modules/node-pty
79
- let searchDir = __dirname;
80
- for (let i = 0; i < 10; i++) {
81
- const candidate = join(searchDir, 'node_modules', 'node-pty', 'prebuilds');
82
- if (existsSync(candidate)) {
83
- fixSpawnHelperPermissions(candidate);
84
- break;
85
- }
86
- const parent = dirname(searchDir);
87
- if (parent === searchDir) {
88
- break;
45
+ const nativeRoot = realpathSync(dirname(require.resolve('node-pty/package.json')));
46
+ const helper = join(
47
+ nativeRoot,
48
+ 'prebuilds',
49
+ `${process.platform}-${process.arch}`,
50
+ 'spawn-helper'
51
+ );
52
+ if (lstatSync(helper).isFile()) {
53
+ const location = relative(nativeRoot, realpathSync(helper));
54
+ if (location !== '..' && !location.startsWith(`..${sep}`) && !isAbsolute(location)) {
55
+ chmodSync(helper, 0o755);
89
56
  }
90
- searchDir = parent;
91
57
  }
92
58
  } catch {
93
- // Ignore errors
59
+ // No prebuilt helper on this platform, or the installation is read-only.
94
60
  }
95
61
  }
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-viewer-B3Gavo18.js","assets/rolldown-runtime-COiEfhsA.js","assets/jsx-runtime-CldxteV5.js","assets/dist-DxBCWJgX.js","assets/trpc-D9WuCSM1.js","assets/utils-DQeSPVda.js","assets/bundle-mjs-CdK3cBzO.js","assets/button-Dslj7pht.js","assets/loading-SklnwAL1.js","assets/spinner-BxeSV-Bb.js","assets/use-persistent-scroll-DMRAfhA7.js","assets/schemas-cLRPP1ma.js","assets/use-workspace-drawer-D5BHCzpQ.js","assets/use-mobile-Di9JSXG3.js","assets/chat-k4KrNKEG.js","assets/react-dom-BNtzwOHF.js","assets/background-task-2TNZSSC3.js","assets/CheckCircle.es-WUl0_Fqk.js","assets/status-indicators-Dvz22Kk_.js","assets/Warning.es-BRY0GI4S.js","assets/es2015-CDGxiYHE.js","assets/dist-B1Zs6lmy.js","assets/dialog-LD_zPUYD.js","assets/dist-y4SI7xsk.js","assets/dist-DmRbNcLV.js","assets/ArrowClockwise.es-CucFsYLg.js","assets/CaretDown.es-Dad3vS2k.js","assets/pending-request-presentation-BqY92kUN.js","assets/ShieldWarning.es-CuA46yPp.js","assets/WarningCircle.es-D-X961df.js","assets/workspace-cache-reconciler-TKQHxUsu.js","assets/preload-helper-BLdHbfdN.js","assets/MagnifyingGlass.es-BlNhc0fx.js","assets/attachment-file-conversion-BG03_iix.js","assets/formatters-CbVS7bYs.js","assets/input-uo3fNc4V.js","assets/Plus.es-wnPcLFe1.js","assets/dist-CLSCCiF9.js","assets/github-pr-preview-B2sd2tDg.js","assets/date-time-DaFd7tnC.js","assets/use-websocket-channel-BApRAMMz.js","assets/index-CsEmj4uI.js","assets/hooks-CZYZW9i_.js","assets/components-Be4xRGcU.js","assets/lib-D-JAPasO.js","assets/queryClient-DaT6C6i7.js","assets/image-drop-zone-NvcW7wXO.js","assets/appearance-DsbwoDTa.js","assets/appearance-D7nkDMex.js","assets/dist-D8Wfxh48.js","assets/index-Dv7JoSz4.css","assets/lib-BF21T6dw.js","assets/FileText.es-C3zlL7Ja.js","assets/SlidersHorizontal.es-DWmgkQAH.js","assets/Folder.es-BA68BESp.js","assets/agent-definition.schema-DaZC-6OB.js","assets/codex-accounts-DneS5v9d.js","assets/card-D16by-Fq.js","assets/websocket-DW_R60Td.js","assets/popover-DjYf9lKZ.js","assets/Terminal.es-DXk70l2n.js","assets/list-keys-CmT9WnL5.js","assets/agent-authoring-DisJfxVO.js","assets/collapsible-dJ6oDAH6.js","assets/CaretLeft.es-CZp1Z1Qg.js","assets/radio-group-FNSEl1BJ.js","assets/styles-B5GgyFSq.js","assets/use-diff-highlighting-CLJSy52c.js","assets/file-viewer-j5Jpwj03.js","assets/file-viewer-DVd46AFa.css"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{f as r,l as i,s as a}from"./hooks-CZYZW9i_.js";import{i as o}from"./lib-D-JAPasO.js";import{n as s}from"./trpc-D9WuCSM1.js";import{r as c,t as l}from"./background-task-2TNZSSC3.js";import{r as u,t as d}from"./utils-DQeSPVda.js";import{t as f}from"./CheckCircle.es-WUl0_Fqk.js";import{c as p,s as m,u as h,y as g}from"./status-indicators-Dvz22Kk_.js";import{n as _,t as v}from"./spinner-BxeSV-Bb.js";import{t as y}from"./Warning.es-BRY0GI4S.js";import{t as b}from"./CaretDown.es-Dad3vS2k.js";import{t as x}from"./pending-request-presentation-BqY92kUN.js";import{t as S}from"./button-Dslj7pht.js";import{i as C,n as w,t as T}from"./image-drop-zone-NvcW7wXO.js";import{t as E}from"./loading-SklnwAL1.js";import{k as D,l as O,o as k,p as A,v as j,w as M,x as N,y as P}from"./schemas-cLRPP1ma.js";import{d as F,n as ee,r as te}from"./use-persistent-scroll-DMRAfhA7.js";import{b as ne,v as re,x as ie,y as ae}from"./workspace-cache-reconciler-TKQHxUsu.js";import{p as oe}from"./es2015-CDGxiYHE.js";import{t as se}from"./preload-helper-BLdHbfdN.js";import{t as ce}from"./input-uo3fNc4V.js";import{a as le}from"./dist-y4SI7xsk.js";import{a as I,n as L,r as R}from"./Plus.es-wnPcLFe1.js";import{r as z,t as B}from"./use-websocket-channel-BApRAMMz.js";import{n as ue}from"./use-workspace-drawer-D5BHCzpQ.js";import{C as V,F as H,G as de,H as fe,I as U,N as pe,P as me,S as he,U as ge,V as _e,W as ve,X as ye,b as be,c as W,d as xe,f as Se,i as Ce,j as we,l as Te,m as Ee,n as De,r as Oe,t as ke,u as Ae,v as je,y as Me}from"./chat-k4KrNKEG.js";import{$ as Ne,$t as Pe,Dt as Fe,F as Ie,J as Le,Jt as Re,M as ze,Ot as Be,P as Ve,Q as He,U as Ue,Y as We,Yt as Ge,Z as Ke,b as qe,ct as Je,et as Ye,g as Xe,it as G,j as Ze,kt as Qe,lt as $e,on as et,t as tt,u as nt,y as rt}from"./index-CsEmj4uI.js";import{i as it}from"./websocket-DW_R60Td.js";import{n as at,r as K,t as ot}from"./popover-DjYf9lKZ.js";import{c as st,i as ct,l as lt,n as ut,o as dt,r as q,s as J,u as ft}from"./DotsThree.es-3R3Ey_3J.js";import{t as pt}from"./list-keys-CmT9WnL5.js";import{a as mt,d as ht,f as gt,i as Y,n as _t,o as X,r as vt}from"./CaretLeft.es-CZp1Z1Qg.js";import{n as yt,t as bt}from"./endOfMonth-DC74gC1p.js";import{t as xt}from"./live-session-control-B9Xbg14T.js";import{t as St}from"./voice-vad-ChMQMgBS.js";import{t as Ct}from"./Microphone.es-Dtdzh_vQ.js";import{a as wt,c as Tt,i as Et,n as Dt,o as Ot,r as kt,s as At,t as jt}from"./right-panel-Da3HBtP9.js";function Mt(e,t){return+X(e)-X(t)}function Nt(e,t){let n=X(e,t?.in);return n.setHours(23,59,59,999),n}function Pt(e,t){let n=X(e,t?.in);return+Nt(n,t)==+bt(n,t)}function Ft(e,t,n){let[r,i,a]=vt(n?.in,e,e,t),o=U(i,a),s=Math.abs(yt(i,a));if(s<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-o*s);let c=U(i,a)===-o;Pt(r)&&s===1&&U(r,a)===1&&(c=!1);let l=o*(s-+c);return l===0?0:l}function It(e,t,n){let r=Mt(e,t)/1e3;return me(n?.roundingMethod)(r)}function Lt(e,t,n){let r=mt(),i=n?.locale??r.locale??_t,a=U(e,t);if(isNaN(a))throw RangeError(`Invalid time value`);let o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a}),[s,c]=vt(n?.in,...a>0?[t,e]:[e,t]),l=It(c,s),u=(Y(c)-Y(s))/1e3,d=Math.round((l-u)/60),f;if(d<2)return n?.includeSeconds?l<5?i.formatDistance(`lessThanXSeconds`,5,o):l<10?i.formatDistance(`lessThanXSeconds`,10,o):l<20?i.formatDistance(`lessThanXSeconds`,20,o):l<40?i.formatDistance(`halfAMinute`,0,o):l<60?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,1,o):d===0?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,d,o);if(d<45)return i.formatDistance(`xMinutes`,d,o);if(d<90)return i.formatDistance(`aboutXHours`,1,o);if(d<1440){let e=Math.round(d/60);return i.formatDistance(`aboutXHours`,e,o)}if(d<2520)return i.formatDistance(`xDays`,1,o);if(d<43200){let e=Math.round(d/ht);return i.formatDistance(`xDays`,e,o)}if(d<86400)return f=Math.round(d/gt),i.formatDistance(`aboutXMonths`,f,o);if(f=Ft(c,s),f<12){let e=Math.round(d/gt);return i.formatDistance(`xMonths`,e,o)}{let e=f%12,t=Math.trunc(f/12);return e<3?i.formatDistance(`aboutXYears`,t,o):e<9?i.formatDistance(`overXYears`,t,o):i.formatDistance(`almostXYears`,t+1,o)}}function Rt(e,t){return Lt(e,H(e),t)}var Z=e(t(),1);function zt(e){return e.replace(/(?::\d+){1,2}$/,``)}function Bt(e,t,n){if(t&&t!==`.`){if(t===`..`){let r=e[e.length-1];e.length>0&&r!==`..`?e.pop():n||e.push(t)}else e.push(t)}}function Vt(e,t){let n=t?e.replace(/\\/g,`/`):e,r=n.startsWith(`/`)||t&&/^[A-Za-z]:\//.test(n),i=[];for(let e of n.split(`/`))Bt(i,e,r);return`${r?`/`:``}${i.join(`/`)}`.replace(/\/+$/,``)||(r?`/`:`.`)}function Ht(e){try{return decodeURIComponent(e)}catch{return e}}function Ut(e,t){let n=e.trim();if(!n)return null;if(/^[A-Za-z]:(?:[\\/]|%5C)/i.test(n))return Ht(n.split(/[?#]/,1)[0]??n);try{let e=new URL(n,t??`http://localhost`);return e.protocol!==`http:`&&e.protocol!==`https:`&&e.protocol!==`file:`||t&&e.origin!==t&&e.protocol!==`file:`?null:decodeURIComponent(e.pathname)}catch{return Ht(n)}}function Wt(e,t,n=typeof window<`u`?window.location.origin:void 0){if(!(e&&t))return null;let r=Ut(e,n);if(!r)return null;let i=/^[A-Za-z]:[\\/]/.test(t),a=Vt(zt(r),i),o=Vt(t,i),s=i?a.toLowerCase():a,c=i?o.toLowerCase():o;if(!(s===c||s.startsWith(`${c}/`)))return null;let l=a.slice(o.length).replace(/^\/+/,``);return l.length>0?l:null}var Gt=j({filePath:N(),ownerId:N(),ownerLabel:N().optional(),acquiredAt:N(),expiresAt:N(),metadata:P(N(),M()).optional()});j({version:A(1),workspaceId:N(),locks:k(Gt)});var Kt=k(N());P(N(),k(N()));var qt=`ff_resume_workspace_ids`;function Jt(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(qt);if(!e)return[];let t=JSON.parse(e);return Kt.parse(t)}catch{return[]}}function Yt(e){if(typeof window<`u`)try{window.localStorage.setItem(qt,JSON.stringify(e))}catch{}}function Xt(e){Yt(Jt().filter(t=>t!==e))}function Zt(e){return Jt().includes(e)}var Qt=[];function $t(){let{mutate:e,isPending:t}=s.workspace.openInIde.useMutation({onError:e=>c.error(e.message)}),{data:n}=s.workspace.getAvailableIdes.useQuery();return{openInIde:(0,Z.useMemo)(()=>({mutate:e,isPending:t}),[e,t]),availableIdes:n?.ides??Qt,preferredIde:n?.preferredIde??`cursor`}}function en(e,t){if(lt(e)){t();return}let n=typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`?e.message:`Couldn't archive workspace.`;c.error(n||`Couldn't archive workspace.`)}function tn({workspaceId:e}){let t=s.useUtils(),{data:n,isLoading:r}=wt(e),i=(0,Z.useCallback)(()=>{l(t.workspace.get.invalidate({id:e}),`Couldn't refresh data.`)},[t,e]),a=s.workspace.syncPRStatus.useMutation({meta:{errorToast:`Couldn't sync pull request status.`},onSuccess:()=>{l(t.workspace.get.invalidate({id:e}),`Couldn't refresh data.`)}}),o=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{n?.prs.length&&!o.current&&!a.isPending&&(o.current=!0,a.mutate({workspaceId:e,force:!1}))},[n?.prs.length,e,a]);let{data:c,isLoading:u}=s.session.listSessions.useQuery({workspaceId:e},{refetchInterval:1e4,staleTime:0,refetchOnWindowFocus:!1}),{data:d}=s.session.getMaxSessionsPerWorkspace.useQuery();return{workspace:n,workspaceLoading:r,sessions:c,sessionsLoading:u,initialDbSessionId:c?.[0]?.id,maxSessions:d,invalidateWorkspace:i}}function nn({workspaceId:e,slug:t,sessions:n,inputRef:r,selectedDbSessionId:a,setSelectedDbSessionId:o,onArchiveGitIndexLocked:c}){let l=i(),u=s.useUtils(),d=(0,Z.useRef)(e);(0,Z.useLayoutEffect)(()=>{d.current=e},[e]);let{createSession:f,deleteSession:p,createChat:m,createQuickActionAsync:h}=De({workspaceId:e,sessions:n,onCreated:(e,t,n)=>{d.current===t&&(o(e.id),n===`chat`&&setTimeout(()=>r.current?.focus(),0))}}),g=w(m),_=w(h),v=(0,Z.useRef)(null);(0,Z.useLayoutEffect)(()=>(v.current=Symbol(`${e}/${t}`),()=>{v.current=null}),[e,t]);let y=(e,t,n)=>{en(e,t?c:()=>void 0),t&&n?.(e)},b=nt(),x=w((e,n)=>{let r=v.current,i=u.workspace.get.getData({id:e.id})?.projectId;b.archiveWorkspace({...e,projectId:i}).then(e=>{let i=e[0];if(!i)return;let a=v.current===r;if(i.success){if(!a)return;l(t?`/projects/${t}/workspaces`:`/projects`,{replace:!0}),n?.onSuccess?.(void 0)}else y(i.error,a,n?.onError)})}),S=(0,Z.useMemo)(()=>({isPending:b.isArchiving,mutate:x}),[b.isArchiving,x]),{openInIde:C,availableIdes:T,preferredIde:E}=$t();return{createSession:f,deleteSession:p,archiveWorkspace:S,openInIde:C,availableIdes:T,preferredIde:E,handleSelectSession:(0,Z.useCallback)(e=>{o(e),setTimeout(()=>r.current?.focus(),0)},[r,o]),handleCloseSession:w(e=>{if(!n||n.length===0)return;let t=n.findIndex(t=>t.id===e);if(t===-1)return;let r=e===a;p.mutate({id:e}),r&&n.length>1?o((n[t+1]??n[t-1])?.id??null):n.length===1&&o(null)}),handleNewChat:g,handleQuickAction:_}}var rn=`ff_setup_warning_dismissed:`;function an(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function on(e){return`${rn}${e}`}function sn(e,t){if(!t)return!1;try{return an()?.getItem(on(e))===t}catch{return!1}}function cn(e,t){if(t)try{an()?.setItem(on(e),t)}catch{}}function ln(e){try{an()?.removeItem(on(e))}catch{}}function un(e,t,n,r){let i=t?.hasHadSessions===!0&&t.prState===`NONE`,{data:a}=s.workspace.hasChanges.useQuery({workspaceId:e},{enabled:i}),o=(0,Z.useRef)({workspaceId:e,running:n});return(0,Z.useEffect)(()=>{let t=o.current;i&&t.workspaceId===e&&t.running&&!n&&r.workspace.hasChanges.invalidate({workspaceId:e}),o.current={workspaceId:e,running:n}},[n,i,r,e]),a}function dn(e,t,n){let{data:r,isPending:i,isError:a}=s.workspace.getInitStatus.useQuery({id:e},{refetchInterval:e=>{let t=e.state.data?.status,n=e.state.data?.retryAvailability;return e.state.status===`error`||!n||n?.status===`BLOCKED`&&![`NOT_RETRYABLE`,`RETRY_LIMIT`].includes(n.reason)?1e3:t===`READY`||t===`FAILED`||t===`ARCHIVING`||t===`ARCHIVED`?!1:1e3}}),o=(0,Z.useMemo)(()=>r&&a?{...r,retryAvailability:{status:`BLOCKED`,reason:`AUTHORITY_UNAVAILABLE`,explanation:`Setup retry availability could not be checked. Refresh and try again.`}}:r,[r,a]),c=(0,Z.useRef)(void 0),u=(0,Z.useRef)(!1),d=o?.hasWorktreePath??!1;(0,Z.useEffect)(()=>{let r=o?.status,i=c.current;if(d&&!u.current&&l(n.workspace.get.invalidate({id:e}),`Couldn't refresh data.`),u.current=d,r===`READY`){let r=i!==void 0&&i!==`READY`,a=i===void 0&&!t?.worktreePath;(r||a)&&l(n.workspace.get.invalidate({id:e}),`Couldn't refresh data.`)}c.current=r},[o?.status,d,e,n,t?.worktreePath]);let f=o?.status,p=o?.initErrorMessage??null,m=f===`FAILED`&&d||f===`READY`&&!!p,[h,g]=(0,Z.useState)(null),_=h?.workspaceId===e&&h.initErrorMessage===p?h.dismissed:null;return(0,Z.useEffect)(()=>{o&&(p?o.chatBanner?.showDismiss===!0?g({workspaceId:e,initErrorMessage:p,dismissed:sn(e,p)}):g({workspaceId:e,initErrorMessage:p,dismissed:!1}):(ln(e),g({workspaceId:e,initErrorMessage:p,dismissed:!1})))},[e,o,p]),{workspaceInitStatus:o,isInitStatusPending:i,isScriptFailed:m,setupWarningDismissed:_,dismissSetupWarning:(0,Z.useCallback)(()=>{cn(e,p),g({workspaceId:e,initErrorMessage:p,dismissed:!0})},[e,p])}}var fn=`workspace-selected-session-`,pn=5e3;function mn({currentSelectedDbSessionId:e,persistedSessionId:t,initialDbSessionId:n,sessionIds:r,pendingSelectionId:i,pendingSelectionSetAtMs:a,nowMs:o=Date.now()}){return r.length===0||i!=null&&e===i&&!r.includes(i)&&a!=null&&o-a<pn||e&&r.includes(e)?e:t&&r.includes(t)?t:n&&r.includes(n)?n:r[0]??null}function hn(e,t,n,r=null,i,a){let o=`${fn}${e}`,s=(0,Z.useRef)(null),c=r?`${a??``}:${r}`:null,l=(0,Z.useRef)({id:null,setAtMs:null}),[u,d]=(0,Z.useState)(()=>{let e=localStorage.getItem(o);return r??e??t});return(0,Z.useEffect)(()=>{if(r||(s.current=null),r&&c!==s.current&&n.includes(r)){s.current=c,l.current={id:null,setAtMs:null},localStorage.setItem(o,r),d(r),i?.();return}let e=l.current;e.id&&n.includes(e.id)&&(l.current={id:null,setAtMs:null});let a=localStorage.getItem(o),f=mn({currentSelectedDbSessionId:u,persistedSessionId:a,initialDbSessionId:t,sessionIds:n,pendingSelectionId:l.current.id,pendingSelectionSetAtMs:l.current.setAtMs});f!==u&&d(f)},[t,u,n,o,r,i,c]),{selectedDbSessionId:u,setSelectedDbSessionId:(0,Z.useCallback)(e=>{l.current={id:e,setAtMs:e?Date.now():null},d(e),e?localStorage.setItem(o,e):localStorage.removeItem(o)},[o])}}function gn({workspaceLoading:e,workspace:t,selectedDbSessionId:n,activeTabId:r,loadingSession:i,inputRef:a}){let o=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{!(o.current||e)&&t&&n&&r===`chat`&&!i&&(o.current=!0,setTimeout(()=>a.current?.focus(),0))},[n,r,i,e,t,a])}function _n({status:e,slug:t,archivePending:n}){let r=i(),a=(0,Z.useRef)(n),o=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let i=a.current&&!n;a.current=n,!n&&(e===`ARCHIVING`?i&&(o.current=!0):o.current=!1,!(o.current||e!==`ARCHIVING`&&e!==`ARCHIVED`)&&r(t?`/projects/${t}/workspaces`:`/projects`,{replace:!0}))},[n,e,t,r])}var Q=n();function vn(e){return(0,Q.jsx)(T,{dropIdentity:`${e.workspaceId}/${e.sessionId??`none`}/${e.inputDraftGeneration??0}`,disabled:!(e.sessionId&&e.connected)||e.sessionStatus.phase===`loading`||!e.chatCapabilities.attachments.enabled||!e.chatCapabilities.attachments.kinds.includes(`image`),label:`Drop images to attach to your message`,onAttachments:t=>{e.setInputAttachments(e=>[...e,...t]),e.inputRef.current?.focus()},children:e.children})}var yn=.02,bn=2;function xn(e){if(e.length===0)return 0;let t=0;for(let n of e){let e=n/32768;t+=e*e}return Math.sqrt(t/e.length)}var Sn=class{sustainedFramesToTrigger;loudFrameStreak=0;speaking=!1;constructor(e=bn){this.sustainedFramesToTrigger=e}observe(e){return xn(e)>=yn?this.loudFrameStreak+=1:(this.loudFrameStreak=0,this.speaking=!1),!this.speaking&&this.loudFrameStreak>=this.sustainedFramesToTrigger&&(this.speaking=!0,!0)}isSpeaking(){return this.speaking}reset(){this.loudFrameStreak=0,this.speaking=!1}},Cn=`wss://api.deepgram.com/v1/listen`,wn=16e3,Tn=`/audio-worklets/pcm-capture-processor.js`,En=128/wn*1e3,Dn=[`please stop`,`hold on`,`cancel that`];function On(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var kn=Dn.map(e=>RegExp(`\\b${On(e)}\\b`));function An(e){let t=e.trim().toLowerCase();return kn.some(e=>e.test(t))}var jn=new Set([`Results`,`UtteranceEnd`]);function Mn(e){if(typeof e!=`string`)return null;try{let t=JSON.parse(e);if(t&&typeof t==`object`&&jn.has(t.type))return t}catch{}return null}function Nn({workletNode:e,silentGain:t,audioContext:n,mediaStream:r,socket:i}){e&&(e.port.onmessage=null,e.port.close(),e.disconnect()),t?.disconnect(),n?.close().catch(()=>void 0);for(let e of r?.getTracks()??[])e.stop();i&&(i.onclose=null,i.onmessage=null,i.readyState===WebSocket.OPEN&&i.send(JSON.stringify({type:`CloseStream`})),i.close())}function Pn(e){return new Promise((t,n)=>{e.addEventListener(`open`,()=>t(),{once:!0}),e.addEventListener(`close`,e=>{n(Error(`Couldn't connect to Deepgram (WebSocket closed, code ${e.code}${e.reason?`: ${e.reason}`:``}). Check the browser Network tab for the actual handshake response.`))},{once:!0})})}function Fn(e,t){let n=new URLSearchParams({model:`nova-3`,language:`en`,encoding:`linear16`,sample_rate:String(wn),channels:`1`,interim_results:`true`,smart_format:`true`,vad_events:`true`,utterance_end_ms:String(t)});return new WebSocket(`${Cn}?${n.toString()}`,[`bearer`,e])}async function In(e,t){await e.audioWorklet.addModule(Tn);let n=e.createMediaStreamSource(t),r=new AudioWorkletNode(e,`pcm-capture-processor`,{processorOptions:{targetSampleRate:wn}}),i=e.createGain();return i.gain.value=0,n.connect(r),r.connect(i),i.connect(e.destination),{workletNode:r,silentGain:i}}function Ln(){let e=``;return{appendFinal(t){return e=e?`${e} ${t}`:t,e},preview(t){return e?`${e} ${t}`:t},flush(){let t=e.trim();return e=``,t}}}function Rn(e,t,n,r){let i=e.channel?.alternatives?.[0]?.transcript;if(i){if(n.runningRef.current&&An(i))t.flush(),r.current=!0,n.onSoftStop?.();else if(!r.current){if(e.is_final){let e=t.appendFinal(i);n.onInterimTranscript?.(e)}else n.onInterimTranscript?.(t.preview(i))}}}function zn(e,t){let n=Ln(),r={current:!1};e.onmessage=e=>{let i=Mn(e.data);if(i?.type===`UtteranceEnd`){let e=n.flush(),i=r.current;r.current=!1,!i&&e&&t.onFinalTranscript(e)}else i?.type===`Results`&&Rn(i,n,t,r)}}function Bn(e,t){e.port.onmessage=e=>{t.socketRef.current?.readyState===WebSocket.OPEN&&t.socketRef.current.send(e.data);let n=t.speechDetectorRef.current;if(!n)return;let r=n.isSpeaking();n.observe(new Int16Array(e.data))?t.onSpeechDetected?.():r&&!n.isSpeaking()&&t.onSpeechEnded?.()}}function Vn(e,t){e.onclose=e=>{t.isStale()||(t.cleanup(),t.setError(`Lost connection to Deepgram (code ${e.code}). Tap the microphone to reconnect.`))}}async function Hn(e){let t=null,n=null,r=new AudioContext({sampleRate:wn});r.resume().catch(()=>void 0);let i=null,a=null,o=()=>Nn({workletNode:i,silentGain:a,audioContext:r,mediaStream:n,socket:t});try{let{accessToken:s}=await e.mintGrantToken.mutateAsync();if(e.isStale()||(t=Fn(s,e.utteranceEndMs),zn(t,e),await Pn(t),e.isStale()))return o(),null;let c={current:null};if(t.addEventListener(`close`,e=>{c.current=e}),n=await navigator.mediaDevices.getUserMedia({audio:!0}),e.isStale())return o(),null;let l=await In(r,n);if(e.isStale())return o(),null;if(i=l.workletNode,a=l.silentGain,c.current)throw Error(`Lost connection to Deepgram (code ${c.current.code}) while starting capture. Tap the microphone to reconnect.`);let u=new Sn(Math.max(1,Math.round(e.bargeInSustainedMs/En)));return Bn(i,{...e,speechDetectorRef:{current:u}}),Vn(t,e),{socket:t,stream:n,audioContext:r,workletNode:i,silentGain:a,speechDetector:u}}catch(e){throw o(),e}}function Un({onFinalTranscript:e,onInterimTranscript:t,running:n,onSoftStop:r,onSpeechDetected:i,onSpeechEnded:a,utteranceEndMs:o=St,bargeInSustainedMs:c=16}){let[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),h=s.voice.mintGrantToken.useMutation({meta:{errorToast:!1}}),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useRef)(null),b=(0,Z.useRef)(null),x=(0,Z.useRef)(null),S=(0,Z.useRef)(n??!1);S.current=n??!1;let C=(0,Z.useRef)(0),w=(0,Z.useCallback)(()=>{Nn({workletNode:_.current,silentGain:v.current,audioContext:g.current,mediaStream:y.current,socket:b.current}),_.current=null,v.current=null,g.current=null,y.current=null,b.current=null,x.current=null,u(!1)},[]);return{isCapturing:l,isConnecting:d,error:p,start:(0,Z.useCallback)(async()=>{C.current+=1;let n=C.current,s=()=>C.current!==n;m(null),f(!0);try{let n=await Hn({mintGrantToken:h,isStale:s,runningRef:S,onSoftStop:r,onFinalTranscript:e,onInterimTranscript:t,onSpeechDetected:i,onSpeechEnded:a,socketRef:b,cleanup:w,setError:m,utteranceEndMs:o,bargeInSustainedMs:c});if(!n)return;b.current=n.socket,y.current=n.stream,g.current=n.audioContext,_.current=n.workletNode,v.current=n.silentGain,x.current=n.speechDetector,u(!0)}catch(e){s()||m(e instanceof Error?e.message:`Couldn't start voice capture`)}finally{s()||f(!1)}},[w,h,e,t,r,i,a,o,c]),stop:(0,Z.useCallback)(()=>{C.current+=1,w(),f(!1)},[w])}}O(`type`,[j({type:A(`soft_stop`)})]);var Wn=j({type:A(`audio_chunk`),data:N()}),Gn=j({type:A(`clear_playback`)}),Kn=O(`type`,[Wn,Gn]),qn=24e3,Jn=.3,Yn=120;function Xn(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new Int16Array(n.buffer)}function Zn({sessionId:e,enabled:t}){let[n,r]=(0,Z.useState)(!1),i=(0,Z.useRef)(null),a=(0,Z.useRef)(0),o=(0,Z.useRef)(new Set),s=(0,Z.useRef)(!1),c=(0,Z.useRef)(!1),l=(0,Z.useRef)([]),u=(0,Z.useRef)(null),d=(0,Z.useCallback)(()=>{u.current!==null&&(clearTimeout(u.current),u.current=null),l.current=[]},[]),f=(0,Z.useCallback)(e=>{let t=i.current;if(!t)return;t.state===`suspended`&&!s.current&&(s.current=!0,t.resume().catch(()=>void 0).finally(()=>{s.current=!1}));let n=new Float32Array(e.length);for(let t=0;t<e.length;t++)n[t]=(e[t]??0)/32768;let c=t.createBuffer(1,n.length,qn);c.copyToChannel(n,0);let l=t.createBufferSource();l.buffer=c,l.connect(t.destination);let u=a.current<=t.currentTime?t.currentTime+Jn:a.current;l.start(u),a.current=u+c.duration,o.current.add(l),r(!0),l.onended=()=>{o.current.delete(l),o.current.size===0&&r(!1)}},[]),p=(0,Z.useCallback)(()=>{u.current=null;let e=l.current;if(l.current=[],e.length===0)return;let t=e.reduce((e,t)=>e+t.length,0),n=new Int16Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;f(n)},[f]),m=(0,Z.useCallback)(e=>{l.current.push(e),u.current===null&&(u.current=setTimeout(p,Yn))},[p]),h=(0,Z.useCallback)(()=>{d();for(let e of o.current)try{e.stop()}catch{}o.current.clear(),a.current=i.current?.currentTime??0,r(!1)},[d]),g=(0,Z.useCallback)(()=>{i.current||(i.current=new AudioContext,a.current=0),i.current.resume().catch(()=>void 0)},[]),_=(0,Z.useCallback)(e=>{if(e.type===`audio_chunk`){if(c.current)return;m(Xn(e.data))}else e.type===`clear_playback`&&h()},[m,h]),v=(0,Z.useCallback)(()=>{c.current=!0,h()},[h]),y=(0,Z.useCallback)(()=>{c.current=!1},[]),b=t&&e?z(`/voice`,{sessionId:e}):null,{send:x}=B({url:b,schema:Kn,onMessage:_}),S=(0,Z.useCallback)(()=>{x({type:`soft_stop`})},[x]);return(0,Z.useEffect)(()=>{if(t&&e)return g(),()=>{d();for(let e of o.current)try{e.stop()}catch{}o.current.clear(),i.current?.close().catch(()=>void 0),i.current=null,a.current=0,c.current=!1,r(!1)}},[t,e,d,g]),{isSpeaking:n,sendSoftStop:S,stopPlayback:h,primeAudioContext:g,beginBargeIn:v,endBargeIn:y}}var Qn=new Map([[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M213.92,218.62l-160-176A8,8,0,0,0,42.08,53.38L80,95.09V128a48,48,0,0,0,69.11,43.12l11.1,12.2A63.41,63.41,0,0,1,128,192a64.07,64.07,0,0,1-64-64,8,8,0,0,0-16,0,80.11,80.11,0,0,0,72,79.6V240a8,8,0,0,0,16,0V207.59a78.83,78.83,0,0,0,35.16-12.22l30.92,34a8,8,0,1,0,11.84-10.76ZM128,160a32,32,0,0,1-32-32V112.69l41.66,45.82A32,32,0,0,1,128,160Zm57.52-3.91A63.32,63.32,0,0,0,192,128a8,8,0,0,1,16,0,79.16,79.16,0,0,1-8.11,35.12,8,8,0,0,1-7.19,4.49,7.88,7.88,0,0,1-3.51-.82A8,8,0,0,1,185.52,156.09ZM84,44.87A48,48,0,0,1,176,64v64a49.19,49.19,0,0,1-.26,5,8,8,0,0,1-8,7.17,8.13,8.13,0,0,1-.84,0,8,8,0,0,1-7.12-8.79c.11-1.1.17-2.24.17-3.36V64A32,32,0,0,0,98.64,51.25,8,8,0,1,1,84,44.87Z`}))]]),$n=Z.forwardRef((e,t)=>Z.createElement(u,{ref:t,...e,weights:Qn}));$n.displayName=`MicrophoneSlashIcon`;function er(e,t,n,r){return e||t?e?`connecting`:n?`speaking`:r?`thinking`:`listening`:`off`}function tr(e,t,n){return n?{label:t?`Voice on`:`Voice off`,title:n}:e?{label:`Connecting…`,title:`Connecting to Deepgram — speech is not captured yet. Click to cancel.`}:t?{label:`Voice on`,title:`Exit voice mode`}:{label:`Voice off`,title:`Enter voice mode`}}var nr={off:``,connecting:`Connecting`,speaking:`Speaking`,thinking:`Thinking`,listening:`Listening`};function rr({phase:e}){return e===`off`?null:(0,Q.jsxs)(`output`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:d(`h-1.5 w-1.5 rounded-full`,e===`connecting`&&`animate-pulse bg-muted-foreground`,e===`speaking`&&`animate-pulse bg-info`,e===`thinking`&&`animate-pulse bg-running`,e===`listening`&&`bg-success`)}),nr[e]]})}var ir=(0,Z.memo)(function({sessionId:e,onFinalTranscript:t,running:n,disabled:r}){let{data:i}=s.voice.getConfig.useQuery(),[a,o]=(0,Z.useState)(!1),{isSpeaking:l,sendSoftStop:u,primeAudioContext:d,beginBargeIn:f,endBargeIn:p}=Zn({sessionId:e,enabled:a}),{isCapturing:m,isConnecting:h,error:g,start:_,stop:y}=Un({onFinalTranscript:(0,Z.useCallback)(e=>t(e,{voiceMode:!0}),[t]),running:n,onSoftStop:u,onSpeechDetected:f,onSpeechEnded:p,utteranceEndMs:i?.utteranceEndMs,bargeInSustainedMs:i?.bargeInSustainedMs});(0,Z.useEffect)(()=>()=>y(),[y]);let b=(0,Z.useRef)(e);(0,Z.useEffect)(()=>{let t=b.current!==e;b.current=e,(!e||t)&&(m||h)&&(y(),o(!1))},[e,m,h,y]);let x=er(h,m,l,!!n&&!l),C=(0,Z.useRef)(`off`);(0,Z.useEffect)(()=>{C.current===`listening`&&x===`thinking`&&tt(`sounds/voice-thinking-start.mp3`,{volume:.3}),C.current=x},[x]),(0,Z.useEffect)(()=>(window.dispatchEvent(new CustomEvent(`voice-mode-changed`,{detail:{active:m}})),()=>{window.dispatchEvent(new CustomEvent(`voice-mode-changed`,{detail:{active:!1}}))}),[m]),(0,Z.useEffect)(()=>{g&&(c.error(g),o(!1))},[g]);let w=!!(i?.enabled&&i.hasApiKey);(0,Z.useEffect)(()=>{i!==void 0&&!w&&(m||h)&&(y(),o(!1))},[i,w,m,h,y]);let T=(0,Z.useCallback)(()=>{m||h?(y(),o(!1)):(d(),o(!0),_())},[m,h,_,y,d]);if(!w)return null;let E=tr(h,m,g);return(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsxs)(S,{type:`button`,variant:m?`default`:`outline`,size:`sm`,className:`shrink-0`,disabled:!(m||h)&&(r||!e),title:E.title,onClick:T,children:[h?(0,Q.jsx)(v,{"aria-hidden":`true`,className:`h-4 w-4`}):m?(0,Q.jsx)(Ct,{className:l?`h-4 w-4 animate-pulse`:`h-4 w-4`}):(0,Q.jsx)($n,{className:`h-4 w-4`}),E.label]}),(0,Q.jsx)(rr,{phase:x})]})});function ar(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(!(r?.source!==`user`||t.has(r.id))&&(r.text?.trim()||r.attachments?.length))return r}return null}function or({sessionId:e,sessionRuntime:t,messages:n,queuedMessageIds:r,connected:i,hasPendingMessages:a,sendMessage:o,restartSession:s}){let c=t.phase===`error`?re(t):null,l=c?`${e??``}\n${c}`:null,[u,d]=(0,Z.useState)(null);l===null&&u!==null&&d(null);let f=(0,Z.useMemo)(()=>c?ar(n,r):null,[c,n,r]),p=(0,Z.useCallback)(()=>{f&&o(f.text??``,{preserveInput:!0,attachments:f.attachments??[]})},[f,o]),m=(0,Z.useCallback)(()=>d(l),[l]);return!c||l===u?null:{message:c,onRetry:f?p:void 0,retryDisabled:!i||a,onRestart:s,onDismiss:m}}function sr(e,t){let n=s.useUtils(),r=s.workspace.retryInit.useMutation({onSettled:()=>{l(n.workspace.getInitStatus.invalidate({id:e}),`Couldn't refresh data.`)},onError:e=>{c.error(e.message)}}),{mutate:i,isPending:a}=r;return{retry:(0,Z.useCallback)(()=>{t?.status!==`AVAILABLE`||a||i({id:e,useExistingBranch:Zt(e)||void 0})},[i,a,e,t]),retryInit:r}}var cr={error:`danger`,warning:`warning`,info:`info`};function lr(e){return m(cr[e]).surface}var ur=(0,Z.memo)(function({banner:e,retryPending:t,retryAvailability:n,onRetry:r,onPlay:i}){let a=e.showRetry||e.showPlay;return(0,Q.jsx)(`div`,{className:`px-4 pt-4`,children:(0,Q.jsxs)(`div`,{className:[`rounded-md border p-3 text-sm flex items-start gap-3`,lr(e.kind)].join(` `),children:[e.kind===`info`?(0,Q.jsx)(_,{className:`h-4 w-4 mt-0.5 shrink-0 animate-spin`}):(0,Q.jsx)(y,{className:`h-4 w-4 mt-0.5 shrink-0`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{children:e.message}),e.showRetry&&n?.status!==`AVAILABLE`&&(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:n?.status===`BLOCKED`?n.explanation:`Checking setup retry availability…`}),a&&(0,Q.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[e.showRetry&&(0,Q.jsxs)(S,{size:`sm`,variant:`outline`,disabled:t||n?.status!==`AVAILABLE`,onClick:r,children:[t?(0,Q.jsx)(v,{className:`h-3.5 w-3.5 mr-1.5`,"aria-hidden":`true`}):(0,Q.jsx)(et,{className:`h-3.5 w-3.5 mr-1.5`}),t?`Retrying…`:`Retry setup`]}),e.showPlay&&(0,Q.jsxs)(S,{size:`sm`,onClick:i,children:[(0,Q.jsx)(Ze,{className:`h-3.5 w-3.5 mr-1.5`}),`Dispatch queued messages`]})]})]})]})})});function dr(e,t){return e===`starting`||t}function fr({loadingSession:e,stopping:t,displayStartingState:n,running:r,promptInFlight:i,pendingRequestType:a,sessionPhase:o,sessionRuntime:s,messageCount:c}){return e?`Loading session…`:t?`Stopping…`:n&&!r?`Agent is starting…`:s.phase===`error`?`Couldn't continue this chat. Type a message to retry…`:a&&s.phase===`running`?x(a).composerPlaceholder:i?`Message will be queued…`:o===`ready`&&c===0?`Type a message to start the agent…`:`Type a message…`}function pr(e,t){return e&&!t&&e.kind!==`info`?e:null}function mr(e,t){return e?(0,Q.jsx)(ur,{banner:e,...t}):void 0}function hr(e,t){let{sessionId:n,parentSessionName:r,onOpenSubagent:i}=e,{subagents:a,subagentListState:o}=t,s=(0,Z.useCallback)(e=>{let t=a.find(t=>t.id===e);n&&t&&i?.({parentSessionId:n,parentSessionName:r?.trim()||`Untitled session`,subagent:t})},[n,r,i,a]),c=a.filter(e=>e.status===`running`),l=c.length===1?c[0]?.id:void 0,u=(0,Z.useCallback)(()=>{l&&s(l)},[s,l]),d=!!i,f=(0,Z.useMemo)(()=>d?(0,Q.jsx)(dt,{activeOnly:!0,state:o,onSelect:e=>s(e.id)}):void 0,[d,o,s]);return{onOpenSubagent:d?s:void 0,onOpenSingleSubagent:d&&l?u:void 0,runningSubagentList:f}}var gr=(0,Z.memo)(function(e){let t=e.autoStartPending??!1,{retry:n,retryInit:r}=sr(e.workspaceId,e.retryAvailability),i=ut(e.messages,e.sessionId,e.connected,e.sessionStatus.phase===`loading`),a=Oe(i.messages,{filterDuplicateResults:!0,groupBoundaries:e.transcriptPageBoundaries}),o=hr(e,i),s=(0,Z.useMemo)(()=>new Set(e.queuedMessages.map(e=>e.id)),[e.queuedMessages]),{sendMessage:c,transcriptScroll:l}=ke(e.sendMessage,e.transcriptScroll),u=(0,Z.useCallback)(()=>c(`/compact`,{preserveInput:!0}),[c]),d=e.sessionStatus.phase===`running`,f=e.sessionRuntime.work?.promptInFlight??d,p=e.sessionStatus.phase===`stopping`,m=dr(e.sessionStatus.phase,t),h=e.sessionStatus.phase===`loading`,g=e.chatCapabilities.rewind.enabled,_=e.pendingRequest.type===`permission`?e.pendingRequest.request.requestId:null,v=Me(e.pendingRequest,e.sessionRuntime),y=v===`plan_approval`;(0,Z.useEffect)(()=>{if(!(y&&_))return;let t=document.activeElement;t&&t!==document.body||e.inputRef?.current?.focus()},[y,_,e.inputRef]);let b=fr({loadingSession:h,stopping:p,displayStartingState:m,running:d,promptInFlight:f,pendingRequestType:v,sessionPhase:e.sessionStatus.phase,sessionRuntime:e.sessionRuntime,messageCount:e.messages.length}),x=or({sessionId:e.sessionId,sessionRuntime:e.sessionRuntime,messages:e.messages,queuedMessageIds:s,connected:e.connected,hasPendingMessages:e.pendingMessages.size>0,sendMessage:c,restartSession:e.restartSession}),S=pr(e.initBanner,e.isScriptFailed),{retryAvailability:C,resumeQueuedMessages:w}=e,T=(0,Z.useMemo)(()=>mr(S,{retryAvailability:C,retryPending:r.isPending,onRetry:n,onPlay:w}),[S,C,r.isPending,n,w]);return(0,Q.jsxs)(`div`,{className:`relative flex h-full flex-col overflow-hidden`,children:[(0,Q.jsx)(V,{contentClassName:`mx-auto w-full max-w-4xl`,onViewSetupOutput:e.onViewSetupOutput,sessionId:e.sessionId,thinkingInFooter:!0,pendingRequestType:e.sessionRuntime.phase===`running`?v:null,header:T,workspaceId:e.workspaceId,messages:a,history:e.history,subagentTimelineError:i.error,runningSubagentIconIndices:i.runningSubagentIconIndices,...o,acpPlan:e.acpPlan,running:d,work:e.sessionRuntime.work,controlSessionId:xt(e.sessionId,e.connected&&e.controlsHydrated===!0,e.sessionRuntime),startingSession:m,loadingSession:h,latestThinking:e.latestThinking??null,scroll:l,queuedMessageIds:s,onRemoveQueuedMessage:e.removeQueuedMessage,onSteerQueuedMessage:e.connected&&f&&!p&&!e.isCompacting?e.steerQueuedMessage:void 0,isCompacting:e.isCompacting,getUuidForMessageId:e.getUuidForMessageId,onRewindToMessage:g?e.startRewindPreview:void 0,resolveWorkspaceFileLink:e.resolveWorkspaceFileLink,onWorkspaceFileLink:e.onWorkspaceFileLink,initBanner:e.initBanner}),(0,Q.jsxs)(`div`,{className:`z-20 flex max-h-full min-h-0 flex-col border-t bg-background pb-safe`,children:[x&&(0,Q.jsx)(de,{className:`shrink-0`,...x}),(0,Q.jsx)(je,{permission:e.pendingRequest.type===`permission`?e.pendingRequest.request:null,onApprove:e.approvePermission,className:`min-h-0 shrink overflow-y-auto`}),(0,Q.jsx)(`div`,{className:`min-h-0 shrink overflow-y-auto`,children:(0,Q.jsx)(Ee,{question:e.pendingRequest.type===`question`?e.pendingRequest.request:null,onAnswer:e.answerQuestion})}),(0,Q.jsx)(`div`,{className:`flex min-h-0 shrink items-stretch gap-2`,children:(0,Q.jsx)(be,{leadingControls:(0,Q.jsx)(ir,{sessionId:e.sessionId,onFinalTranscript:c,running:d,disabled:!e.connected||h}),className:`mx-auto w-full max-w-4xl flex-1 min-w-0`,onSend:c,onCompact:u,onStop:e.stopChat,disabled:!e.connected||h,running:d,promptInFlight:f,stopping:p,isCompacting:e.isCompacting,inputRef:e.inputRef,placeholder:b,settings:e.chatSettings,capabilities:e.chatCapabilities,capabilitiesLoaded:e.chatCapabilitiesLoaded,onSettingsChange:e.updateSettings,value:e.inputDraft,onChange:e.setInputDraft,attachments:e.inputAttachments,onAttachmentsChange:e.setInputAttachments,pendingMessageCount:e.pendingMessages.size,slashCommands:e.slashCommands,slashCommandsLoaded:e.slashCommandsLoaded,tokenStats:e.tokenStats,workspaceId:e.workspaceId,codexAccountId:e.codexAccountId,acpConfigOptions:e.acpConfigOptions,onSetConfigOption:e.setConfigOption,onRunQuickActionInNewChat:e.onRunQuickActionInNewChat,newChatUnavailableReason:e.newChatUnavailableReason})})]}),(0,Q.jsx)(Se,{rewindPreview:e.rewindPreview,onConfirm:e.confirmRewind,onCancel:e.cancelRewind})]})}),_r=(0,Z.createContext)(null),vr=_r.Provider;function yr(){let e=(0,Z.useContext)(_r);if(!e)throw Error(`ConnectedChatContent must be rendered inside ChatContentPropsProvider`);return(0,Q.jsx)(vn,{...e,children:(0,Q.jsx)(gr,{...e})})}var br=(0,Q.jsx)(yr,{});function xr(e){return!!e}function Sr(e,t){return!e||e.showDismiss===!0&&t!==!1?null:e}function Cr(e){let{workspaceSummaries:t,sessions:n,selectedSessionId:r,liveRuntime:i,chatConnected:a}=e,o=new Map((t??[]).map(e=>[e.sessionId,e]));if(!(r&&a&&e.runtimeSessionId===r))return o;let s=n?.find(e=>e.id===r);if(!s)return o;let c=o.get(r);return o.set(r,{sessionId:r,name:c?.name??s.name??null,workflow:c?.workflow??s.workflow??null,model:c?.model??s.model??null,provider:c?.provider??s.provider,persistedStatus:c?.persistedStatus??s.status,pendingRequestType:e.livePendingRequestType===void 0?c?.pendingRequestType??null:e.livePendingRequestType,runtimePhase:i.phase,processState:i.processState,activity:i.activity,updatedAt:i.updatedAt,lastExit:i.lastExit??c?.lastExit??null,errorMessage:i.errorMessage??c?.errorMessage??null}),o}function wr(e){let t=!1;for(let n of e){if(n.source===`agent`)return!1;n.source===`user`&&(t=!0)}return t}var Tr=new Map([[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M232.07,186.76a80,80,0,0,0-62.5-114.17A80,80,0,1,0,23.93,138.76l-7.27,24.71a16,16,0,0,0,19.87,19.87l24.71-7.27a80.39,80.39,0,0,0,25.18,7.35,80,80,0,0,0,108.34,40.65l24.71,7.27a16,16,0,0,0,19.87-19.86ZM62,159.5a8.28,8.28,0,0,0-2.26.32L32,168l8.17-27.76a8,8,0,0,0-.63-6,64,64,0,1,1,26.26,26.26A8,8,0,0,0,62,159.5Zm153.79,28.73L224,216l-27.76-8.17a8,8,0,0,0-6,.63,64.05,64.05,0,0,1-85.87-24.88A79.93,79.93,0,0,0,174.7,89.71a64,64,0,0,1,41.75,92.48A8,8,0,0,0,215.82,188.23Z`}))]]),Er=Z.forwardRef((e,t)=>Z.createElement(u,{ref:t,...e,weights:Tr}));Er.displayName=`ChatsCircleIcon`;var Dr=ve.transform((e,t)=>Array.isArray(e.messages)?{...e,messages:e.messages}:(t.issues.push({code:`custom`,message:`Expected a messages JSON array`,path:[`messages`],input:e.messages}),D));function Or(e){let t=JSON.parse(N().parse(e));return Dr.parse(t)}function $(e){if(e===void 0)throw Error(`Missing archive grouping trace value`);return e}function kr(e){let t=e.message?.message?.content,n=e.message?.event;return[...Array.isArray(t)?t.filter(ye):[],...n?.type===`content_block_start`&&ye(n.content_block)?[n.content_block]:[],...n?.type===`message_start`&&Array.isArray(n.message.content)?n.message.content.filter(ye):[]]}function Ar(e){let t=e.map(()=>[]),n=new Map,r=[],i=(e,n)=>$(t[$(e)]).push(n),a=()=>{if(r.length===0)return;let t=new Map,a=new Map,o=new Map,s=_e(r,{onToolCall:(e,n)=>t.set(n,e),onToolResult:(e,t)=>{let n=o.get(e)??new Set;n.add(t),o.set(e,n)},onToolSequence:(e,t)=>a.set(e,t)}),c=new Set,l=new Map,u=0;for(let e of r)l.set(e,u),kr(e).some(t=>!o.get(e)?.has(t))&&(c.add(e),u+=1);let d=e=>{let r=$(a.get(e)),o=$(r[0]),s=$(r.at(-1));if(l.get(o)===l.get(s)&&!c.has(s)){i(n.get(o),{kind:`rich`,value:e});return}let u,d;for(let r of e.pairedCalls){let a=$(t.get(r)),o=$(l.get(a));if(!u||d!==o){let t=$(n.get(a));u={type:`tool_sequence`,id:`${e.id}:archive:${t}`,pairedCalls:[]},i(t,{kind:`rich`,value:u}),d=o}u.pairedCalls.push(r)}};for(let e of s)fe(e)?d(e):i(n.get(e),{kind:`rich`,value:e});for(let t of c){let r=$(n.get(t));i(r,{kind:`fallback`,value:$(e[r]),sourceIndex:r})}r=[]};return e.forEach((e,t)=>{let o=ge.safeParse(e);o.success?(n.set(o.data,t),r.push(o.data)):(a(),i(t,{kind:`fallback`,value:e,sourceIndex:t}))}),a(),pt(t.flat(),e=>e.kind===`rich`?e.value.id:`fallback-${e.sourceIndex}`)}function jr({sessionId:e}){let t=(0,Z.useRef)(null),{data:n,isLoading:r,error:i,isFetching:a,refetch:o}=s.closedSessions.getTranscriptJson.useQuery({id:e},{select:Or,structuralSharing:!1});if((0,Z.useEffect)(()=>{if(n&&t.current){let e=t.current.querySelector(`[data-radix-scroll-area-viewport]`);e&&(e.scrollTop=e.scrollHeight)}},[n]),r)return(0,Q.jsx)(E,{message:`Loading transcript…`});if(i&&i.data?.code!==`NOT_FOUND`&&!n)return(0,Q.jsx)(Fe,{title:`Couldn't load transcript`,error:i,onRetry:()=>{o()},isRetrying:a,className:`h-full`});if(!n||i?.data?.code===`NOT_FOUND`)return(0,Q.jsx)(Be,{icon:Er,title:`Transcript not found`,description:`This session's history is no longer available.`,className:`h-full`});let c=i?(0,Q.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`shrink-0 border-b p-3 text-sm`,children:`Latest transcript read failed. Showing previously loaded history.`}):null;if(n.messages.length===0)return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[c,(0,Q.jsx)(Be,{icon:Er,title:`No messages in this session`,className:`min-h-0 flex-1`})]});let l=Ar(n.messages),u=(0,Q.jsx)(Pe,{ref:t,className:`min-h-0 flex-1`,children:(0,Q.jsx)(`div`,{className:`p-4 space-y-4`,children:l.map(({item:e,key:t})=>e.kind===`rich`?(0,Q.jsx)(we,{item:e.value},t):(0,Q.jsxs)(`section`,{"aria-label":`Archived message JSON`,children:[(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Archived message JSON`}),(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-sm`,children:JSON.stringify(e.value,null,2)})]},t))})});return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[c,u]})}function Mr({workspaceId:e,screenshotPath:t}){let{data:n,isLoading:r,error:i,isFetching:a,refetch:o}=s.workspace.readScreenshot.useQuery({workspaceId:e,path:t},{staleTime:6e4});return r?(0,Q.jsx)(E,{message:`Loading screenshot…`}):n?(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full p-4 overflow-auto`,children:(0,Q.jsx)(`img`,{src:`data:${n.mimeType};base64,${n.data}`,alt:n.name,className:`max-w-full max-h-full object-contain rounded-md`})}):(0,Q.jsx)(Fe,{title:`Couldn't load screenshot`,error:i,onRetry:()=>{o()},isRetrying:a,className:`h-full`})}var Nr=(0,Z.lazy)(()=>se(()=>import(`./diff-viewer-B3Gavo18.js`).then(e=>({default:e.DiffViewer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67]))),Pr=(0,Z.lazy)(()=>se(()=>import(`./file-viewer-j5Jpwj03.js`).then(e=>({default:e.FileViewer})),__vite__mapDeps([68,1,2,3,4,19,5,6,29,7,8,9,10,11,12,13,34,14,15,16,17,18,20,21,22,23,24,25,26,27,28,30,31,32,33,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,67,69])));function Fr({workspaceId:e,children:t,className:n}){let{tabs:r,activeTabId:i}=te(),a=r.find(e=>e.id===i),o=!a||a.type===`chat`,s=a?.type===`file`?a.path:void 0,c=a?.type===`diff`?a.path:void 0,l=a?.type===`screenshot`?a.path:void 0,u=a?.type===`closed-session`?a.closedSessionId:void 0,f=a?.type===`subagent`?a.subagentSelection:void 0,p=a?.id,m=qe({workspaceId:e,tabId:a?.type===`subagent`?a.id:null});return(0,Q.jsxs)(`div`,{className:d(`h-full`,n),children:[(0,Q.jsx)(`div`,{className:d(`h-full`,!o&&`hidden`),children:t}),(0,Q.jsx)(C,{variant:`compact`,title:`Couldn't load the viewer`,children:(0,Q.jsxs)(Z.Suspense,{fallback:(0,Q.jsx)(E,{size:`compact`,message:`Loading viewer…`}),children:[s&&p&&(0,Q.jsx)(Pr,{workspaceId:e,filePath:s,tabId:p},p),c&&p&&(0,Q.jsx)(Nr,{workspaceId:e,filePath:c,tabId:p},p)]})},`viewer-${p}`),l&&p&&(0,Q.jsx)(Mr,{workspaceId:e,screenshotPath:l,tabId:p}),u&&(0,Q.jsx)(jr,{sessionId:u}),f&&p&&(0,Q.jsx)(ct,{workspaceId:e,selection:f,scroll:{ready:m.ready,initialPosition:m.initialPosition,onPositionChange:m.onPositionChange}},p)]})}var Ir=new Map([[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M112,152a8,8,0,0,0-8,8v28.69L66.34,151A8,8,0,0,1,64,145.37V95a32,32,0,1,0-16,0v50.38a23.85,23.85,0,0,0,7,17L92.69,200H64a8,8,0,0,0,0,16h48a8,8,0,0,0,8-8V160A8,8,0,0,0,112,152ZM40,64A16,16,0,1,1,56,80,16,16,0,0,1,40,64Zm168,97V110.63a23.85,23.85,0,0,0-7-17L163.31,56H192a8,8,0,0,0,0-16H144a8,8,0,0,0-8,8V96a8,8,0,0,0,16,0V67.31L189.66,105a8,8,0,0,1,2.34,5.66V161a32,32,0,1,0,16,0Zm-8,47a16,16,0,1,1,16-16A16,16,0,0,1,200,208Z`}))]]),Lr=Z.forwardRef((e,t)=>Z.createElement(u,{ref:t,...e,weights:Ir}));Lr.displayName=`GitDiffIcon`;var Rr=new Map([[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128ZM128,72a12,12,0,1,0-12-12A12,12,0,0,0,128,72Zm0,112a12,12,0,1,0,12,12A12,12,0,0,0,128,184Z`}))]]),zr=Z.forwardRef((e,t)=>Z.createElement(u,{ref:t,...e,weights:Rr}));zr.displayName=`DotsThreeVerticalIcon`;function Br({chatLabel:e,onRestartSession:t,disabled:n=!1,onRename:r}){let i=(0,Z.useRef)(!1);return(0,Q.jsxs)(Ke,{children:[(0,Q.jsxs)(L,{children:[(0,Q.jsx)(I,{asChild:!0,children:(0,Q.jsx)(Je,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":`Chat actions`,children:(0,Q.jsx)(zr,{className:`h-4 w-4`})})})}),(0,Q.jsx)(R,{side:`bottom`,children:`Chat actions`})]}),(0,Q.jsxs)(He,{align:`end`,className:`w-64`,onCloseAutoFocus:e=>{i.current&&(i.current=!1,e.preventDefault(),r?.())},children:[(0,Q.jsx)(Ye,{className:`truncate`,children:e??`No chat selected`}),r&&(0,Q.jsxs)(Ne,{disabled:n||e===null,onSelect:()=>{i.current=!0},children:[(0,Q.jsx)(ze,{className:`h-4 w-4`}),` Rename chat`]}),(0,Q.jsxs)(Ne,{disabled:n||e===null,onSelect:t,className:`items-start`,children:[(0,Q.jsx)(et,{className:`mt-0.5 h-4 w-4`}),(0,Q.jsxs)(`span`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{children:`Restart agent`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Stop and restart the agent, resuming from where it left off`})]})]})]})]})}function Vr({workspaceId:e,onSelectClosedSession:t,disabled:n}){let[r,i]=(0,Z.useState)(!1),{data:a,isLoading:o}=s.closedSessions.list.useQuery({workspaceId:e,limit:20}),c=a&&a.length>0;return o||c?(0,Q.jsxs)(Ke,{open:r,onOpenChange:i,children:[(0,Q.jsxs)(L,{children:[(0,Q.jsx)(I,{asChild:!0,children:(0,Q.jsx)(Je,{asChild:!0,children:(0,Q.jsxs)(S,{variant:`ghost`,size:`sm`,disabled:n,className:d(`h-7 px-2 text-xs gap-1.5`,`text-muted-foreground hover:text-foreground`,`border border-input bg-background hover:bg-sidebar-accent`),children:[(0,Q.jsx)(Re,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:`Closed`})]})})}),(0,Q.jsx)(R,{children:`View closed session history`})]}),(0,Q.jsxs)(He,{align:`start`,className:`w-80`,children:[(0,Q.jsx)(Ye,{children:`Closed Sessions`}),(0,Q.jsx)(G,{}),o&&(0,Q.jsx)(E,{size:`compact`,message:`Loading closed sessions…`}),!(o||c)&&(0,Q.jsx)(`div`,{className:`py-6 px-2 text-center text-sm text-muted-foreground`,children:`No closed sessions yet. Ratchet sessions will appear here after they complete.`}),!o&&c&&(0,Q.jsx)(Pe,{className:`max-h-96`,children:a.map(e=>(0,Q.jsxs)(Ne,{onClick:()=>{t(e.id),i(!1)},className:`flex items-start gap-2 px-3 py-2 cursor-pointer`,children:[e.workflow===`periodic-task`?(0,Q.jsx)(Qe,{"aria-label":`Agent session`,className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}):(0,Q.jsx)(st,{className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium truncate`,children:W(e,`${e.workflow} session`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(h,{className:`h-3 w-3 shrink-0`}),(0,Q.jsx)(`span`,{children:Rt(new Date(e.completedAt),{addSuffix:!0})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`capitalize`,children:e.provider.toLowerCase()}),(0,Q.jsx)(`span`,{children:`•`}),(0,Q.jsx)(`span`,{children:e.model})]})]})]},e.id))})]})]}):null}function Hr(e,t){if(!e)return t===`RUNNING`;let n=ie(e);return n===`working`||n===`starting`||n===`awaiting-input`}function Ur({summary:e,persistedStatus:t,queuedMessageCount:n=0}){let r=Hr(e,t);return!r&&n<=0?null:{running:r,...e&&ie(e)===`awaiting-input`?{awaitingInput:!0}:{},queuedMessageCount:Math.max(0,n)}}function Wr(e){return`${e} queued message${e===1?``:`s`}`}function Gr(e,t){let n=t.queuedMessageCount>0?`its transcript moves to Closed sessions. You can read it there; discarded queued messages cannot be recovered.`:`its transcript moves to Closed sessions. You can read it there.`,r=Wr(t.queuedMessageCount),i=t.awaitingInput?`is waiting for your input`:`is still working`;return t.running&&t.queuedMessageCount>0?{title:`Stop and close ${e}?`,description:`${e} ${i} and has ${r}. Closing the tab stops the agent, discards the queued messages, and ${n}`,confirmText:`Stop and close`}:t.running?{title:`Stop and close ${e}?`,description:`${e} ${i}. Closing the tab stops the agent and ${n}`,confirmText:`Stop and close`}:{title:`Discard and close ${e}?`,description:`${e} has ${r} that ${t.queuedMessageCount===1?`has`:`have`} not been sent. Closing the tab discards ${t.queuedMessageCount===1?`it`:`them`} and ${n}`,confirmText:`Discard and close`}}function Kr({sessionId:e,workspaceId:t,name:n,onDone:r}){let i=(0,Z.useRef)(null),a=(0,Z.useRef)(!1);(0,Z.useLayoutEffect)(()=>(a.current=!0,i.current?.focus(),i.current?.select(),()=>{a.current=!1}),[]);let[o,c]=(0,Z.useState)(n),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),p=(0,Z.useRef)(!1),m=(0,Z.useRef)(!1),h=s.useUtils(),g=s.session.updateSession.useMutation({meta:{errorToast:!1}}),_=e=>{a.current&&e()},v=async()=>{if(p.current||m.current)return;let i=o.trim();if(!i||i===n)r();else{p.current=!0,f(!0),u(!1);try{await g.mutateAsync({id:e,name:i}),await h.session.listSessions.invalidate({workspaceId:t}),_(r)}catch{_(()=>u(!0))}finally{p.current=!1,_(()=>f(!1))}}};return(0,Q.jsxs)(ot,{open:l,children:[(0,Q.jsx)(at,{asChild:!0,children:(0,Q.jsx)(`div`,{className:`relative shrink-0 p-1`,children:(0,Q.jsx)(ce,{"aria-label":`Chat name`,value:o,readOnly:d,"aria-busy":d,"aria-invalid":l,ref:i,onChange:e=>c(e.target.value),onBlur:()=>{l||v()},onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),v()):e.key===`Escape`&&!e.nativeEvent.isComposing&&!d&&(e.preventDefault(),m.current=!0,r())},className:`h-7 w-40 text-sm`})})}),(0,Q.jsx)(K,{role:`alert`,"aria-label":`Chat rename error`,side:`bottom`,align:`end`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),className:`p-2 text-xs text-destructive`,children:`Couldn't rename chat. Press Enter to retry or Escape to cancel.`})]})}var qr={color:`text-muted-foreground`,pulse:!1,spin:!1,label:`Idle`,description:`Ready for input`,icon:le,isRunning:!1};function Jr(e){return e===`RUNNING`?{color:`text-running`,pulse:!0,spin:!1,label:`Running`,description:`Processing your request`,icon:p,isRunning:!0}:e===`PAUSED`?{color:`text-muted-foreground`,pulse:!1,spin:!1,label:`Paused`,description:`Session paused`,icon:J,isRunning:!1}:e===`COMPLETED`?{color:`text-success`,pulse:!1,spin:!1,label:`Completed`,description:`Session finished`,icon:f,isRunning:!1}:e===`FAILED`?{color:`text-destructive`,pulse:!1,spin:!1,label:`Failed`,description:`Session failed`,icon:g,isRunning:!1}:qr}function Yr(e,t){if(!e)return Jr(t);switch(ie(e)){case`loading`:return{color:`text-muted-foreground`,pulse:!1,spin:!0,label:`Loading`,description:`Loading session…`,icon:_,isRunning:!1};case`starting`:return{color:`text-muted-foreground`,pulse:!1,spin:!0,label:`Starting`,description:`Launching agent…`,icon:_,isRunning:!1};case`stopping`:return{color:`text-running`,pulse:!1,spin:!0,label:`Stopping`,description:`Finishing current request…`,icon:_,isRunning:!1};case`error`:return{color:`text-destructive`,pulse:!1,spin:!1,label:`Error`,description:ae(e)??`Session entered an error state`,icon:g,isRunning:!1};case`unexpected-exit`:return{color:`text-destructive`,pulse:!1,spin:!1,label:`Error`,description:ae(e)??`Exited unexpectedly${e.lastExit?.code==null?``:` (code ${e.lastExit.code})`}`,icon:g,isRunning:!1};case`stopped`:return{color:`text-muted-foreground`,pulse:!1,spin:!1,label:`Stopped`,description:`Send a message to start`,icon:J,isRunning:!1};case`awaiting-input`:{let t=x(e.pendingRequestType??`permission_request`);return{color:m(`attention`).text,pulse:!1,spin:!1,label:t.label,description:t.description,icon:t.icon,isRunning:!1,awaitingInput:!0}}case`working`:return{color:`text-running`,pulse:!0,spin:!1,label:`Running`,description:`Processing your request`,icon:p,isRunning:!0};case`idle`:return qr}}function Xr(e){switch(e){case`chat`:case`file`:return F;case`diff`:return Lr;case`screenshot`:return he;case`closed-session`:return Re;case`subagent`:return Qe}}function Zr(e,t){let n=e?.findIndex(e=>e.id===t)??-1,r=e?.[n];return r?W(r,`Chat ${n+1}`):null}function Qr({sessionSummary:e,isCIFix:t,isAgent:n,persistedStatus:r}){let i=Yr(e,r),a=i.icon;return t&&!i.awaitingInput?(0,Q.jsxs)(L,{children:[(0,Q.jsx)(I,{asChild:!0,children:(0,Q.jsx)(`span`,{className:`flex items-center justify-center`,children:(0,Q.jsx)(Ue,{enabled:!0,animated:i.isRunning,className:`h-3.5 w-3.5 rounded-[4px] shrink-0`,iconClassName:d(i.isRunning&&`animate-pulse text-running`,!i.isRunning&&`text-warning`)})})}),(0,Q.jsxs)(R,{side:`bottom`,className:`text-xs`,children:[(0,Q.jsxs)(`div`,{className:`font-medium`,children:[`CI Fix: `,i.label]}),(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:i.description})]})]}):(0,Q.jsxs)(L,{children:[(0,Q.jsx)(I,{asChild:!0,children:(0,Q.jsx)(`span`,{className:`flex items-center justify-center`,children:n?(0,Q.jsx)(xe,{label:i.label,icon:a,color:i.color,pulse:i.pulse,spin:i.spin}):(0,Q.jsx)(a,{role:`img`,"aria-label":i.label,className:d(`h-3.5 w-3.5 shrink-0`,i.color,i.pulse&&`animate-pulse`,i.spin&&`animate-spin`)})})}),(0,Q.jsxs)(R,{side:`bottom`,className:`text-xs`,children:[(0,Q.jsx)(`div`,{className:`font-medium`,children:i.label}),(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:i.description})]})]})}function $r({tab:e,isActive:t,tabStop:n,onSelect:r,onClose:i}){let a=Xr(e.type);return(0,Q.jsx)(Tt,{icon:(0,Q.jsx)(a,{className:`h-3.5 w-3.5 shrink-0`}),label:e.label,isActive:t,tabStop:n,onSelect:r,onClose:i,truncate:!0})}function ei({selection:e,label:t,isActive:n,tabStop:r,onSelect:i,onClose:a,onRefresh:o}){let{selection:s,iconIndex:c}=q(e),{parentSessionId:l,parentSessionName:u,subagent:f}=s;return(0,Z.useEffect)(()=>{f!==e.subagent&&o({parentSessionId:l,parentSessionName:u,subagent:f})},[l,u,f,o,e.subagent]),(0,Q.jsx)(Tt,{icon:(0,Q.jsx)(`span`,{role:`img`,"aria-label":`${f.status} subagent`,className:d(`inline-flex shrink-0`,(f.status===`starting`||f.status===`running`)&&`animate-pulse motion-reduce:animate-none`),children:(0,Q.jsx)(pe,{index:c,className:`h-3.5 w-3.5`})}),label:t,isActive:n,tabStop:r,onSelect:i,onClose:a,truncate:!0})}function ti({label:e,isActive:t,tabStop:n,sessionSummary:r,isCIFix:i,isAgent:a,persistedStatus:o,onSelect:s,onClose:c}){return(0,Q.jsx)(Tt,{icon:(0,Q.jsx)(Qr,{sessionSummary:r,isCIFix:i,isAgent:a,persistedStatus:o}),label:e,isActive:t,tabStop:n,onSelect:s,onClose:c,truncate:!0})}function ni({className:e,workspaceId:t,sessions:n,currentSessionId:r,queuedMessageCount:i,sessionSummariesById:a,onSelectSession:o,onCreateSession:s,onCloseSession:c,onSelectClosedSession:l,onRestartSession:u,disabled:f,maxSessions:p}){let m=Ae(),{tabs:h,activeTabId:g,selectTab:_,closeTab:v,updateSubagentTab:y}=te(),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(null),E=(e,t)=>{let n=Ur({summary:a?.get(e.id),persistedStatus:e.status,queuedMessageCount:i?.sessionId===e.id?i.count:0});n?(x({sessionId:e.id,label:t,risk:n}),C(!0)):c?.(e.id)},D=b?Gr(b.label,b.risk):null,O=h.filter(e=>e.type!==`chat`),k=O.some(e=>e.id===g),A=!!n?.some(e=>e.id===r),j=e=>{o?.(e),_(`chat`)},M=e=>{if(!n||n.length<2)return!1;let t=n.findIndex(e=>e.id===r),i=n[t<0?e===1?0:n.length-1:(t+e+n.length)%n.length];return i?(j(i.id),!0):!1},N=!f&&(n?.length??0)>1;Ge(`chat.next`,()=>M(1),N),Ge(`chat.previous`,()=>M(-1),N);let P=Ie(n,p),F=f||P||n===void 0,ee=Zr(n,r);return(0,Q.jsxs)(`div`,{ref:m,className:d(`flex items-center bg-shell`,e),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto p-1`,style:{scrollbarWidth:`none`,msOverflowStyle:`none`},children:[n&&n.length>0&&(0,Q.jsx)(`div`,{role:`tablist`,"aria-label":`Chats`,onKeyDown:Te,className:`flex shrink-0 items-center gap-0.5`,children:n.map((e,t)=>{let i=e.id===r,o=W(e,`Chat ${t+1}`);return(0,Q.jsx)(ti,{label:o,isActive:i&&g===`chat`,tabStop:i||!A&&t===0,sessionSummary:a?.get(e.id),isCIFix:e.workflow===`ci-fix`,isAgent:e.workflow===`periodic-task`,persistedStatus:e.status,onSelect:()=>j(e.id),onClose:n.length>1?()=>E(e,o):void 0},e.id)})}),l&&(0,Q.jsx)(`div`,{className:`ml-0.5 shrink-0`,children:(0,Q.jsx)(Vr,{workspaceId:t,onSelectClosedSession:l,disabled:f})}),O.length>0&&(0,Q.jsx)(`div`,{className:`h-4 w-px shrink-0 bg-border mx-1`}),O.length>0&&(0,Q.jsx)(`div`,{role:`tablist`,"aria-label":`Open tabs`,onKeyDown:Te,className:`flex shrink-0 items-center gap-0.5`,children:O.map((e,t)=>{let n=e.id===g,r=n||!k&&t===0;return e.type===`subagent`&&e.subagentSelection?(0,Q.jsx)(ei,{selection:e.subagentSelection,label:e.label,isActive:n,tabStop:r,onSelect:()=>_(e.id),onClose:()=>v(e.id),onRefresh:y},e.id):(0,Q.jsx)($r,{tab:e,isActive:n,tabStop:r,onSelect:()=>_(e.id),onClose:()=>v(e.id)},e.id)})})]}),n?.filter(e=>e.id===w).map(e=>(0,Q.jsx)(Kr,{sessionId:e.id,workspaceId:t,name:W(e,`Chat ${n.indexOf(e)+1}`),onDone:()=>T(t=>t===e.id?null:t)},e.id)),s&&(0,Q.jsx)(`div`,{className:`mx-1 flex shrink-0 items-center py-1`,children:(0,Q.jsxs)(L,{children:[(0,Q.jsx)(I,{asChild:!0,children:(0,Q.jsx)(`span`,{children:(0,Q.jsx)(it,{provider:n?.[0]?.provider,onCreate:s,disabled:F})})}),(0,Q.jsx)(R,{children:P?`Maximum ${p} sessions per workspace`:`New session`})]})}),u&&(0,Q.jsx)(`div`,{className:`shrink-0 pr-1`,children:(0,Q.jsx)(Br,{chatLabel:ee,onRename:()=>T(r??null),onRestartSession:u,disabled:f})}),(0,Q.jsx)(Xe,{open:S,onOpenChange:C,title:D?.title??``,description:D?.description??``,confirmText:D?.confirmText,variant:`destructive`,onConfirm:()=>{C(!1),b&&c?.(b.sessionId)}})]})}var ri=(0,Z.memo)(function({workspaceId:e,sessions:t,selectedSessionId:n,sessionSummariesById:r,queuedMessageCount:i,isCreatingSession:a,isDeletingSession:o,onSelectSession:s,onCreateSession:c,onCloseSession:l,onRestartSession:u,children:d,emptyState:f,maxSessions:p,hasWorktreePath:m}){let h=t&&t.length===0,{openTab:g}=te();return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full min-h-0`,children:[(0,Q.jsx)(`div`,{className:`border-b flex-shrink-0`,children:(0,Q.jsx)(ni,{workspaceId:e,sessions:t,currentSessionId:n,queuedMessageCount:i,sessionSummariesById:r,onSelectSession:s,onCreateSession:c,onCloseSession:l,onRestartSession:u,onSelectClosedSession:e=>{g(`closed-session`,e,`History`)},disabled:a||o||!m,maxSessions:p})}),h&&f,(0,Q.jsx)(Fr,{workspaceId:e,className:`flex-1 min-h-0`,children:h?f?null:(0,Q.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-8`,children:(0,Q.jsxs)(`div`,{className:`max-w-md w-full space-y-6 text-center`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`h2`,{className:`text-2xl font-semibold`,children:`Start a session`}),(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`Click the + button above to start a new chat session in this workspace.`})]}),!m&&(0,Q.jsx)(`div`,{className:[`border px-4 py-3 rounded-md text-sm`,lr(`warning`)].join(` `),children:`Workspace is initializing… Please wait for the worktree to be created.`})]})}):d})]})});function ii({workspaceId:e,banner:t,errorMessage:n,retryAvailability:r}){let{retry:i,retryInit:a}=sr(e,r);return(0,Q.jsx)(ur,{banner:{kind:`error`,message:t?.message??n??`Workspace setup failed`,showRetry:!0,showPlay:!1,showDismiss:!1},retryAvailability:r,retryPending:a.isPending,onRetry:i,onPlay:()=>void 0})}function ai({output:e,className:t,emptyMessage:n=`Waiting for output…`}){let r=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{r.current&&e!==null&&(r.current.scrollTop=r.current.scrollHeight)},[e]),(0,Q.jsx)(Pe,{viewportRef:r,className:t,children:(0,Q.jsx)(`pre`,{className:`p-2 text-xs font-mono text-foreground whitespace-pre-wrap break-words`,children:e||(0,Q.jsx)(`span`,{className:`text-foreground italic`,children:n})})})}function oi({workspaceId:e,retryAvailability:t,initErrorMessage:n,initOutput:r,hasStartupScript:i,showPlay:a=!1,onPlay:o,showDismiss:s=!1,onDismiss:c}){let[l,u]=(0,Z.useState)(!1),{retry:d,retryInit:f}=sr(e,t);return(0,Q.jsxs)(`div`,{className:`border-b bg-destructive/10 px-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2 text-sm text-destructive`,children:[(0,Q.jsx)(y,{className:`mt-0.5 h-3 w-3 shrink-0`}),(0,Q.jsxs)(`span`,{className:`min-w-0 break-words whitespace-normal`,children:[`Init script failed`,n?`: ${n}`:``,t?.status!==`AVAILABLE`&&(0,Q.jsx)(`span`,{className:`mt-1 block text-xs`,children:t?.status===`BLOCKED`?t.explanation:`Checking setup retry availability…`})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1 self-start sm:justify-end`,children:[i&&r&&(0,Q.jsxs)(S,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>u(!l),children:[l?(0,Q.jsx)(b,{className:`h-3 w-3 mr-1`}):(0,Q.jsx)($e,{className:`h-3 w-3 mr-1`}),l?`Hide output`:`Show output`]}),(0,Q.jsx)(S,{variant:`outline`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:d,disabled:f.isPending||t?.status!==`AVAILABLE`,children:f.isPending?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v,{"aria-hidden":`true`,className:`h-3 w-3 mr-1`}),`Retrying…`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(et,{className:`h-3 w-3 mr-1`}),`Retry`]})}),a&&(0,Q.jsxs)(S,{variant:`outline`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:o,disabled:!o,children:[(0,Q.jsx)(Ze,{className:`h-3 w-3 mr-1`}),`Dispatch queued messages`]}),s&&(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:c,"aria-label":`Dismiss`,children:(0,Q.jsx)(oe,{className:`h-3 w-3`})})]})]}),l&&i&&(0,Q.jsx)(ai,{output:r,className:`mt-2 h-32 w-full rounded-md border bg-background`})]})}function si(){return(0,Q.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-md`,children:(0,Q.jsxs)(`div`,{role:`status`,className:`flex items-center gap-3 p-8`,children:[(0,Q.jsx)(v,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Archiving…`})]})})}function ci(){return typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function li({visible:e,children:t}){let[n,r]=(0,Z.useState)(e),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(e),[c,l]=(0,Z.useState)(null),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null);if(e!==o){s(e);let t=!ci();a(t?e?`opening`:`closing`:null),r(e||t)}return(0,Z.useEffect)(()=>{if(!i){l(null);return}let e=requestAnimationFrame(()=>{let e=d.current?.parentElement,t=u.current;e&&t&&l(Math.round(e.offsetWidth*t.getSize().asPercentage/100))}),t=setTimeout(()=>{i===`closing`&&r(!1),a(null)},150);return()=>{cancelAnimationFrame(e),clearTimeout(t)}},[i]),n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Dt,{}),(0,Q.jsx)(kt,{id:`workspace-side`,defaultSize:`30%`,minSize:`15%`,maxSize:`50%`,panelRef:u,elementRef:d,"data-side-panel-motion":i??void 0,style:c?{minWidth:c}:void 0,children:(0,Q.jsx)(`div`,{className:`h-full border-l`,children:t})})]}):null}var ui=`Take a screenshot of the workspace dev app using Playwright MCP tools. Read factory-factory.json for the scripts.run command, pick a free port, replace {port}, and start the dev server in the background. Once ready, determine the most relevant screen and save a screenshot to .factory-factory/screenshots/ with a descriptive filename.`;function di({workspaceId:e,isScriptFailed:t,workspaceInitStatus:n,setupWarningDismissed:r,dismissSetupWarning:i,resumeQueuedMessages:a}){let o=Sr(n?.chatBanner,r);return t&&o?(0,Q.jsx)(oi,{retryAvailability:n?.retryAvailability,workspaceId:e,initErrorMessage:n?.initErrorMessage??null,initOutput:n?.initOutput??null,hasStartupScript:n?.hasStartupScript??!1,showPlay:o.showPlay,onPlay:a,showDismiss:o.showDismiss,onDismiss:i}):null}var fi=(0,Z.memo)(function({workspaceState:e,header:t,sessionTabs:n,resumeQueuedMessages:r,rightPanelVisible:i,setRightPanelVisible:a,archiveDialog:o}){let s=ue(),[c,l]=(0,Z.useState)(!1),u=n.sessions?.findIndex(e=>e.id===n.selectedDbSessionId)??-1,d=u>=0?n.sessions?.[u]:void 0,f=d?d.name?.trim()||`Session ${u+1}`:null,p=(0,Z.useCallback)(async()=>{l(!0);try{await t.handleQuickAction(`Take Screenshots`,ui)}catch{}finally{l(!1)}},[t.handleQuickAction]),m=(0,Z.useCallback)(e=>{f&&n.selectedDbSessionId&&e.parentSessionId===n.selectedDbSessionId&&(n.handleOpenSubagentTab({...e,parentSessionName:f}),s&&a(!1))},[s,f,a,n.handleOpenSubagentTab,n.selectedDbSessionId]);if(e.workspaceLoading)return(0,Q.jsx)(E,{message:`Loading workspace…`});if(!e.workspace)return(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-destructive`,children:`Workspace not found`}),(0,Q.jsx)(S,{variant:`outline`,onClick:e.handleBackToWorkspaces,children:`Workspaces`})]});let h=(0,Q.jsx)(`div`,{className:`h-full flex flex-col min-w-0`,children:(0,Q.jsx)(ri,{workspaceId:e.workspaceId,sessions:n.sessions,selectedSessionId:n.selectedDbSessionId,sessionSummariesById:n.sessionSummariesById,queuedMessageCount:n.queuedMessageCount,isCreatingSession:t.isCreatingSession,isDeletingSession:n.isDeletingSession,onSelectSession:n.handleSelectSession,onCreateSession:n.handleNewChat,onCloseSession:n.handleCloseChatSession,onRestartSession:n.handleRestartSession,maxSessions:n.maxSessions,hasWorktreePath:n.hasWorktreePath,emptyState:e.workspaceInitStatus?.phase===`BLOCKED_FAILED`?(0,Q.jsx)(ii,{retryAvailability:e.workspaceInitStatus.retryAvailability,workspaceId:e.workspaceId,banner:e.workspaceInitStatus.chatBanner,errorMessage:e.workspaceInitStatus.initErrorMessage}):void 0,children:br})}),g=(0,Q.jsx)(jt,{workspaceId:e.workspaceId,isTakingScreenshots:c,onTakeScreenshots:p,selectedSessionId:n.selectedDbSessionId,selectedSessionName:f,selectedSessionReady:n.selectedSessionReady,selectedSessionControlId:n.selectedSessionControlId,selectedSessionControlRuntimeId:n.selectedSessionControlRuntimeId,onOpenSubagent:m});return(0,Q.jsxs)(`div`,{className:`relative flex h-full flex-col overflow-hidden`,children:[t.archivePending&&(0,Q.jsx)(si,{}),(0,Q.jsx)(di,{workspaceId:e.workspaceId,isScriptFailed:e.isScriptFailed,workspaceInitStatus:e.workspaceInitStatus,setupWarningDismissed:e.setupWarningDismissed,dismissSetupWarning:e.dismissSetupWarning,resumeQueuedMessages:r}),s?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`flex-1 min-h-0`,children:h}),(0,Q.jsx)(Ot,{open:i,onOpenChange:a,children:g})]}):(0,Q.jsxs)(Et,{direction:`horizontal`,className:`flex-1 overflow-hidden`,autoSaveId:`workspace-main-panel`,children:[(0,Q.jsx)(kt,{id:`workspace-chat`,defaultSize:`70%`,minSize:`30%`,children:h}),(0,Q.jsx)(li,{visible:i,children:g})]}),(0,Q.jsx)(Le,{open:o.open,onOpenChange:o.setOpen,activeChildCount:o.activeChildCount,onConfirm:o.onConfirm})]})});function pi(){let{slug:e=``,id:t=``}=r(),n=i(),[c,u]=o(),{key:d}=a(),f=s.useUtils(),{workspace:p,workspaceLoading:m,sessions:h,initialDbSessionId:g,maxSessions:_}=tn({workspaceId:t}),{rightPanelVisible:v,setRightPanelVisible:y,setActiveBottomTab:b,activeTabId:x,selectTab:S,tabs:C,openTab:w,openSubagentTab:T}=te(),{workspaceInitStatus:E,isScriptFailed:D,setupWarningDismissed:O,dismissSetupWarning:k}=dn(t,p,f);(0,Z.useEffect)(()=>{let e=E?.phase;(e===`READY`||e===`ARCHIVED`)&&Xt(t)},[t,E?.phase]);let A=(0,Z.useMemo)(()=>h?.map(e=>e.id)??[],[h]),j=(0,Z.useCallback)(()=>S(`chat`),[S]),{selectedDbSessionId:M,setSelectedDbSessionId:N}=hn(t,g??null,A,c.get(`session`),j,d),P=(0,Z.useCallback)(e=>{N(e),c.has(`session`)&&u(e=>{let t=new URLSearchParams(e);return t.delete(`session`),t},{replace:!0})},[N,c,u]),[F,ee]=(0,Z.useState)(!1),[re,ie]=(0,Z.useState)(!1),ae=(0,Z.useCallback)(()=>ie(!0),[]),oe=p?.creationSource!==`CHILD_WORKSPACE`,se=ft(p),{data:ce}=s.workspace.listChildren.useQuery({parentWorkspaceId:t},{enabled:!se&&F&&oe}),le=ce?.length??0,{messages:I,transcriptHistory:L,transcriptPageBoundaries:R,connected:z,sessionStatus:B,processStatus:ue,sessionRuntime:V,runtimeSessionId:H,controlsHydrated:de,pendingRequest:fe,chatSettings:U,chatCapabilities:pe,chatCapabilitiesLoaded:me,inputDraft:he,inputAttachments:ge,inputDraftGeneration:_e,queuedMessages:ve,removeQueuedMessage:ye,steerQueuedMessage:be,resumeQueuedMessages:W,latestThinking:xe,pendingMessages:Se,isCompacting:we,slashCommands:Te,slashCommandsLoaded:Ee,tokenStats:De,rewindPreview:Oe,sendMessage:ke,stopChat:Ae,restartSession:je,approvePermission:Ne,answerQuestion:Pe,updateSettings:Fe,setInputDraft:Ie,setInputAttachments:Le,startRewindPreview:Re,confirmRewind:ze,cancelRewind:Be,getUuidForMessageId:He,acpConfigOptions:Ue,acpPlan:Ge,setConfigOption:Ke,inputRef:qe}=Ce({dbSessionId:M}),Je=B.phase===`loading`,Ye=p?.creationSource===`GITHUB_ISSUE`&&M!==null&&(B.phase===`loading`||B.phase===`ready`)&&ue.state===`unknown`&&wr(I),Xe=Me(fe),G=(0,Z.useMemo)(()=>Cr({workspaceSummaries:p?.sessionSummaries,sessions:h,selectedSessionId:M,liveRuntime:V,livePendingRequestType:Xe,runtimeSessionId:H,chatConnected:z}),[p?.sessionSummaries,h,M,V,Xe,H,z]),Ze=(0,Z.useMemo)(()=>H===null?null:{sessionId:H,count:ve.length},[H,ve.length]),Qe=(0,Z.useMemo)(()=>Array.from(G.values()).some(e=>ne(e)),[G]),$e=xt(M,z&&de&&H===M,V),et=V.work?.controlRuntimeId,tt=xr(M),nt=un(t,p,Qe,f),{createSession:it,deleteSession:at,archiveWorkspace:K,openInIde:ot,availableIdes:st,preferredIde:ct,handleSelectSession:lt,handleCloseSession:ut,handleNewChat:dt,handleQuickAction:q}=nn({workspaceId:t,slug:e,sessions:h,inputRef:qe,selectedDbSessionId:M,setSelectedDbSessionId:P,onArchiveGitIndexLocked:ae});_n({status:p?.status,slug:e,archivePending:K.isPending});let J=(0,Z.useCallback)((e=!1)=>{K.mutate(e?{id:t,removeGitIndexLock:!0}:{id:t})},[K,t]),pt=(0,Z.useCallback)(()=>{se?J():ee(!0)},[se,J]),mt=(0,Z.useCallback)(()=>{l(Promise.resolve(n(`/projects/${e}/workspaces`)),`Couldn't open workspace list.`)},[n,e]),ht=(0,Z.useCallback)(()=>J(),[J]),gt=(0,Z.useCallback)(()=>J(!0),[J]),Y=rt({workspaceId:t,sessionId:M}),_t=(0,Z.useCallback)(e=>{Y.clearSession(e),ut(e)},[Y.clearSession,ut]),X=C.find(e=>e.id===x),vt=!X||X.type===`chat`,yt=Sr(E?.chatBanner,O),bt=(0,Z.useCallback)(e=>Wt(e,p?.worktreePath),[p?.worktreePath]),St=(0,Z.useCallback)(e=>{w(`file`,e,e.split(`/`).pop()??e)},[w]);gn({workspaceLoading:m,workspace:p,selectedDbSessionId:M,activeTabId:x,loadingSession:Je,inputRef:qe});let Ct=`${t}/main/${M??`none`}`,wt=Y.ready&&M!==null&&H===M,Tt=(0,Z.useMemo)(()=>({identity:Ct,active:vt,ready:wt,initialIntent:`following`,initialPosition:Y.initialPosition,onPositionChange:Y.onPositionChange}),[Ct,vt,wt,Y.initialPosition,Y.onPositionChange]),Et=(0,Z.useCallback)((e,t)=>{l(q(e,t),`Couldn't run quick action.`)},[q]),Dt=Ve({sessions:h,maxSessions:_,isCreatingSession:it.isPending,isDeletingSession:at.isPending,hasWorktreePath:!!p?.worktreePath}),Ot={onViewSetupOutput:(0,Z.useCallback)(()=>{b(`setup-logs`),y(!0)},[b,y]),retryAvailability:E?.retryAvailability,workspaceId:t,sessionId:M,codexAccountId:h?.find(e=>e.id===M)?.codexAccountId,resolveWorkspaceFileLink:bt,onWorkspaceFileLink:St,onOpenSubagent:T,parentSessionName:h?.find(e=>e.id===M)?.name,messages:I,history:L,transcriptPageBoundaries:R,sessionStatus:B,sessionRuntime:V,transcriptScroll:Tt,pendingRequest:fe,approvePermission:Ne,answerQuestion:Pe,connected:z,controlsHydrated:de,sendMessage:ke,stopChat:Ae,restartSession:je,inputRef:qe,chatSettings:U,chatCapabilities:pe,chatCapabilitiesLoaded:me,updateSettings:Fe,inputDraft:he,setInputDraft:Ie,inputAttachments:ge,inputDraftGeneration:_e,setInputAttachments:Le,queuedMessages:ve,removeQueuedMessage:ye,steerQueuedMessage:be,resumeQueuedMessages:W,latestThinking:xe,pendingMessages:Se,isCompacting:we,slashCommands:Te,slashCommandsLoaded:Ee,tokenStats:De,rewindPreview:Oe,startRewindPreview:Re,confirmRewind:ze,cancelRewind:Be,getUuidForMessageId:He,acpConfigOptions:Ue,acpPlan:Ge,setConfigOption:Ke,autoStartPending:Ye,initBanner:yt,isScriptFailed:D,onRunQuickActionInNewChat:Et,newChatUnavailableReason:Dt},kt=(0,Z.useMemo)(()=>({workspaceLoading:m,workspace:p,workspaceId:t,handleBackToWorkspaces:mt,isScriptFailed:D,workspaceInitStatus:E,setupWarningDismissed:O,dismissSetupWarning:k}),[m,p,t,mt,D,E,O,k]),jt=(0,Z.useMemo)(()=>({archivePending:K.isPending,handleQuickAction:q,isCreatingSession:it.isPending}),[K.isPending,q,it.isPending]),Mt=!!p?.worktreePath,Nt=(0,Z.useMemo)(()=>({sessions:h,selectedDbSessionId:M,selectedSessionReady:tt,selectedSessionControlId:$e,selectedSessionControlRuntimeId:et,sessionSummariesById:G,queuedMessageCount:Ze,isDeletingSession:at.isPending,handleSelectSession:lt,handleNewChat:dt,handleCloseChatSession:_t,handleRestartSession:je,handleOpenSubagentTab:T,maxSessions:_,hasWorktreePath:Mt}),[h,M,tt,$e,et,G,Ze,at.isPending,lt,dt,_t,je,T,_,Mt]),Pt=(0,Z.useMemo)(()=>({open:F,setOpen:ee,activeChildCount:le,onConfirm:ht}),[F,le,ht]);return(0,Q.jsxs)(Q.Fragment,{children:[p&&(0,Q.jsx)(At,{workspace:p,workspaceId:t,availableIdes:st,preferredIde:ct,openInIde:ot,archivePending:K.isPending,onArchiveRequest:pt,handleQuickAction:q,running:Qe,isCreatingSession:it.isPending,hasChanges:nt}),(0,Q.jsx)(vr,{value:Ot,children:(0,Q.jsx)(fi,{workspaceState:kt,header:jt,sessionTabs:Nt,resumeQueuedMessages:W,rightPanelVisible:v,setRightPanelVisible:y,archiveDialog:Pt})}),(0,Q.jsx)(We,{open:re,onOpenChange:ie,onRetry:ht,onRemoveLockAndArchive:gt,isPending:K.isPending})]})}function mi(){let{id:e=``}=r(),[t]=o();return(0,Q.jsx)(ee,{workspaceId:e,initialActiveTabId:t.has(`session`)?`chat`:void 0,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(E,{message:`Loading chat…`}),children:(0,Q.jsx)(pi,{},e)})},e)}export{mi as default};