corporateai 0.0.1

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 (704) hide show
  1. package/.dockerignore +10 -0
  2. package/.env.example +3 -0
  3. package/.github/workflows/publish-cli.yml +49 -0
  4. package/.mailmap +1 -0
  5. package/AGENTS.md +148 -0
  6. package/CONTRIBUTING.md +75 -0
  7. package/Dockerfile +59 -0
  8. package/Dockerfile.onboard-smoke +42 -0
  9. package/LICENSE +21 -0
  10. package/README.md +93 -0
  11. package/cli/esbuild.config.mjs +11 -0
  12. package/cli/package.json +24 -0
  13. package/cli/scripts/build-cli.mjs +5 -0
  14. package/cli/src/index.ts +27 -0
  15. package/docker-compose.quickstart.yml +18 -0
  16. package/docker-compose.untrusted-review.yml +33 -0
  17. package/docker-compose.yml +38 -0
  18. package/package.json +56 -0
  19. package/patches/embedded-postgres@18.1.0-beta.16.patch +0 -0
  20. package/pnpm-workspace.yaml +4 -0
  21. package/releases/.gitkeep +0 -0
  22. package/releases/v0.0.1.md +36 -0
  23. package/releases/v0.2.7.md +15 -0
  24. package/releases/v0.3.0.md +54 -0
  25. package/releases/v0.3.1.md +55 -0
  26. package/releases/v2026.318.0.md +66 -0
  27. package/releases/v2026.325.0.md +78 -0
  28. package/report/2026-03-13-08-46-token-optimization-implementation.md +48 -0
  29. package/scripts/backup-db.sh +17 -0
  30. package/scripts/build-npm.sh +80 -0
  31. package/scripts/check-forbidden-tokens.mjs +115 -0
  32. package/scripts/clean-onboard-git.sh +14 -0
  33. package/scripts/clean-onboard-npm.sh +13 -0
  34. package/scripts/clean-onboard-ref.sh +86 -0
  35. package/scripts/create-github-release.sh +99 -0
  36. package/scripts/dev-runner-paths.mjs +38 -0
  37. package/scripts/dev-runner.mjs +606 -0
  38. package/scripts/docker-onboard-smoke.sh +306 -0
  39. package/scripts/ensure-plugin-build-deps.mjs +47 -0
  40. package/scripts/generate-company-assets.ts +365 -0
  41. package/scripts/generate-npm-package-json.mjs +113 -0
  42. package/scripts/generate-org-chart-images.ts +694 -0
  43. package/scripts/generate-org-chart-satori-comparison.ts +225 -0
  44. package/scripts/generate-ui-package-json.mjs +31 -0
  45. package/scripts/kill-dev.sh +71 -0
  46. package/scripts/migrate-inline-env-secrets.ts +126 -0
  47. package/scripts/prepare-server-ui-dist.sh +22 -0
  48. package/scripts/provision-worktree.sh +333 -0
  49. package/scripts/release-lib.sh +306 -0
  50. package/scripts/release-package-map.mjs +169 -0
  51. package/scripts/release.sh +312 -0
  52. package/scripts/rollback-latest.sh +111 -0
  53. package/scripts/smoke/openclaw-docker-ui.sh +329 -0
  54. package/scripts/smoke/openclaw-gateway-e2e.sh +954 -0
  55. package/scripts/smoke/openclaw-join.sh +295 -0
  56. package/scripts/smoke/openclaw-sse-standalone.sh +146 -0
  57. package/scripts/workspace-compat.mjs +60 -0
  58. package/server/CHANGELOG.md +130 -0
  59. package/server/package.json +96 -0
  60. package/server/scripts/copy-onboarding-assets.mjs +10 -0
  61. package/server/scripts/dev-watch.ts +33 -0
  62. package/server/src/__tests__/activity-routes.test.ts +70 -0
  63. package/server/src/__tests__/adapter-models.test.ts +105 -0
  64. package/server/src/__tests__/adapter-session-codecs.test.ts +194 -0
  65. package/server/src/__tests__/agent-auth-jwt.test.ts +79 -0
  66. package/server/src/__tests__/agent-instructions-routes.test.ts +318 -0
  67. package/server/src/__tests__/agent-instructions-service.test.ts +361 -0
  68. package/server/src/__tests__/agent-permissions-routes.test.ts +275 -0
  69. package/server/src/__tests__/agent-shortname-collision.test.ts +69 -0
  70. package/server/src/__tests__/agent-skill-contract.test.ts +50 -0
  71. package/server/src/__tests__/agent-skills-routes.test.ts +462 -0
  72. package/server/src/__tests__/app-hmr-port.test.ts +19 -0
  73. package/server/src/__tests__/approval-routes-idempotency.test.ts +110 -0
  74. package/server/src/__tests__/approvals-service.test.ts +107 -0
  75. package/server/src/__tests__/assets.test.ts +250 -0
  76. package/server/src/__tests__/attachment-types.test.ts +97 -0
  77. package/server/src/__tests__/board-mutation-guard.test.ts +105 -0
  78. package/server/src/__tests__/budgets-service.test.ts +311 -0
  79. package/server/src/__tests__/claude-local-adapter-environment.test.ts +92 -0
  80. package/server/src/__tests__/claude-local-adapter.test.ts +31 -0
  81. package/server/src/__tests__/claude-local-skill-sync.test.ts +111 -0
  82. package/server/src/__tests__/cli-auth-routes.test.ts +230 -0
  83. package/server/src/__tests__/codex-local-adapter-environment.test.ts +143 -0
  84. package/server/src/__tests__/codex-local-adapter.test.ts +253 -0
  85. package/server/src/__tests__/codex-local-execute.test.ts +391 -0
  86. package/server/src/__tests__/codex-local-skill-injection.test.ts +175 -0
  87. package/server/src/__tests__/codex-local-skill-sync.test.ts +123 -0
  88. package/server/src/__tests__/companies-route-path-guard.test.ts +56 -0
  89. package/server/src/__tests__/company-branding-route.test.ts +196 -0
  90. package/server/src/__tests__/company-portability-routes.test.ts +175 -0
  91. package/server/src/__tests__/company-portability.test.ts +2186 -0
  92. package/server/src/__tests__/company-skills-routes.test.ts +113 -0
  93. package/server/src/__tests__/company-skills.test.ts +229 -0
  94. package/server/src/__tests__/costs-service.test.ts +226 -0
  95. package/server/src/__tests__/cursor-local-adapter-environment.test.ts +196 -0
  96. package/server/src/__tests__/cursor-local-adapter.test.ts +406 -0
  97. package/server/src/__tests__/cursor-local-execute.test.ts +263 -0
  98. package/server/src/__tests__/cursor-local-skill-injection.test.ts +104 -0
  99. package/server/src/__tests__/cursor-local-skill-sync.test.ts +145 -0
  100. package/server/src/__tests__/dev-runner-paths.test.ts +25 -0
  101. package/server/src/__tests__/dev-server-status.test.ts +66 -0
  102. package/server/src/__tests__/dev-watch-ignore.test.ts +42 -0
  103. package/server/src/__tests__/documents.test.ts +29 -0
  104. package/server/src/__tests__/error-handler.test.ts +53 -0
  105. package/server/src/__tests__/execution-workspace-policy.test.ts +170 -0
  106. package/server/src/__tests__/forbidden-tokens.test.ts +77 -0
  107. package/server/src/__tests__/gemini-local-adapter-environment.test.ts +135 -0
  108. package/server/src/__tests__/gemini-local-adapter.test.ts +190 -0
  109. package/server/src/__tests__/gemini-local-execute.test.ts +172 -0
  110. package/server/src/__tests__/gemini-local-skill-sync.test.ts +90 -0
  111. package/server/src/__tests__/health.test.ts +16 -0
  112. package/server/src/__tests__/heartbeat-process-recovery.test.ts +256 -0
  113. package/server/src/__tests__/heartbeat-run-summary.test.ts +33 -0
  114. package/server/src/__tests__/heartbeat-workspace-session.test.ts +334 -0
  115. package/server/src/__tests__/helpers/embedded-postgres.ts +7 -0
  116. package/server/src/__tests__/hire-hook.test.ts +181 -0
  117. package/server/src/__tests__/instance-settings-routes.test.ts +156 -0
  118. package/server/src/__tests__/invite-accept-gateway-defaults.test.ts +119 -0
  119. package/server/src/__tests__/invite-accept-replay.test.ts +92 -0
  120. package/server/src/__tests__/invite-expiry.test.ts +10 -0
  121. package/server/src/__tests__/invite-join-grants.test.ts +57 -0
  122. package/server/src/__tests__/invite-join-manager.test.ts +33 -0
  123. package/server/src/__tests__/invite-onboarding-text.test.ts +116 -0
  124. package/server/src/__tests__/issue-comment-reopen-routes.test.ts +146 -0
  125. package/server/src/__tests__/issue-goal-fallback.test.ts +99 -0
  126. package/server/src/__tests__/issues-checkout-wakeup.test.ts +48 -0
  127. package/server/src/__tests__/issues-goal-context-routes.test.ts +187 -0
  128. package/server/src/__tests__/issues-service.test.ts +317 -0
  129. package/server/src/__tests__/issues-user-context.test.ts +113 -0
  130. package/server/src/__tests__/log-redaction.test.ts +74 -0
  131. package/server/src/__tests__/monthly-spend-service.test.ts +90 -0
  132. package/server/src/__tests__/normalize-agent-mention-token.test.ts +41 -0
  133. package/server/src/__tests__/openclaw-gateway-adapter.test.ts +626 -0
  134. package/server/src/__tests__/openclaw-invite-prompt-route.test.ts +192 -0
  135. package/server/src/__tests__/opencode-local-adapter-environment.test.ts +97 -0
  136. package/server/src/__tests__/opencode-local-adapter.test.ts +226 -0
  137. package/server/src/__tests__/opencode-local-skill-sync.test.ts +91 -0
  138. package/server/src/__tests__/paperclip-env.test.ts +58 -0
  139. package/server/src/__tests__/paperclip-skill-utils.test.ts +63 -0
  140. package/server/src/__tests__/pi-local-adapter-environment.test.ts +102 -0
  141. package/server/src/__tests__/pi-local-skill-sync.test.ts +95 -0
  142. package/server/src/__tests__/plugin-dev-watcher.test.ts +68 -0
  143. package/server/src/__tests__/plugin-worker-manager.test.ts +43 -0
  144. package/server/src/__tests__/private-hostname-guard.test.ts +56 -0
  145. package/server/src/__tests__/project-shortname-resolution.test.ts +45 -0
  146. package/server/src/__tests__/quota-windows-service.test.ts +56 -0
  147. package/server/src/__tests__/quota-windows.test.ts +1109 -0
  148. package/server/src/__tests__/redaction.test.ts +66 -0
  149. package/server/src/__tests__/routines-e2e.test.ts +276 -0
  150. package/server/src/__tests__/routines-routes.test.ts +271 -0
  151. package/server/src/__tests__/routines-service.test.ts +424 -0
  152. package/server/src/__tests__/storage-local-provider.test.ts +78 -0
  153. package/server/src/__tests__/ui-branding.test.ts +82 -0
  154. package/server/src/__tests__/work-products.test.ts +95 -0
  155. package/server/src/__tests__/workspace-runtime.test.ts +1131 -0
  156. package/server/src/__tests__/worktree-config.test.ts +426 -0
  157. package/server/src/adapters/codex-models.ts +105 -0
  158. package/server/src/adapters/cursor-models.ts +171 -0
  159. package/server/src/adapters/http/execute.ts +42 -0
  160. package/server/src/adapters/http/index.ts +21 -0
  161. package/server/src/adapters/http/test.ts +116 -0
  162. package/server/src/adapters/index.ts +18 -0
  163. package/server/src/adapters/process/execute.ts +77 -0
  164. package/server/src/adapters/process/index.ts +24 -0
  165. package/server/src/adapters/process/test.ts +89 -0
  166. package/server/src/adapters/registry.ts +225 -0
  167. package/server/src/adapters/server-utils-compat.ts +57 -0
  168. package/server/src/adapters/types.ts +30 -0
  169. package/server/src/adapters/utils.ts +48 -0
  170. package/server/src/agent-auth-jwt.ts +141 -0
  171. package/server/src/app.ts +321 -0
  172. package/server/src/attachment-types.ts +74 -0
  173. package/server/src/auth/better-auth.ts +148 -0
  174. package/server/src/board-claim.ts +150 -0
  175. package/server/src/config-file.ts +17 -0
  176. package/server/src/config.ts +260 -0
  177. package/server/src/dev-server-status.ts +103 -0
  178. package/server/src/dev-watch-ignore.ts +36 -0
  179. package/server/src/errors.ts +34 -0
  180. package/server/src/home-paths.ts +95 -0
  181. package/server/src/index.ts +799 -0
  182. package/server/src/log-redaction.ts +146 -0
  183. package/server/src/middleware/auth.ts +178 -0
  184. package/server/src/middleware/board-mutation-guard.ts +66 -0
  185. package/server/src/middleware/error-handler.ts +71 -0
  186. package/server/src/middleware/index.ts +3 -0
  187. package/server/src/middleware/logger.ts +90 -0
  188. package/server/src/middleware/private-hostname-guard.ts +92 -0
  189. package/server/src/middleware/validate.ts +9 -0
  190. package/server/src/onboarding-assets/ceo/AGENTS.md +54 -0
  191. package/server/src/onboarding-assets/ceo/HEARTBEAT.md +72 -0
  192. package/server/src/onboarding-assets/ceo/SOUL.md +33 -0
  193. package/server/src/onboarding-assets/ceo/TOOLS.md +3 -0
  194. package/server/src/onboarding-assets/default/AGENTS.md +3 -0
  195. package/server/src/paths.ts +34 -0
  196. package/server/src/realtime/live-events-ws.ts +274 -0
  197. package/server/src/redaction.ts +59 -0
  198. package/server/src/routes/access.ts +2888 -0
  199. package/server/src/routes/activity.ts +89 -0
  200. package/server/src/routes/agents.ts +2313 -0
  201. package/server/src/routes/approvals.ts +346 -0
  202. package/server/src/routes/assets.ts +341 -0
  203. package/server/src/routes/authz.ts +52 -0
  204. package/server/src/routes/companies.ts +343 -0
  205. package/server/src/routes/company-skills.ts +300 -0
  206. package/server/src/routes/costs.ts +335 -0
  207. package/server/src/routes/dashboard.ts +19 -0
  208. package/server/src/routes/execution-workspaces.ts +182 -0
  209. package/server/src/routes/goals.ts +107 -0
  210. package/server/src/routes/health.ts +94 -0
  211. package/server/src/routes/index.ts +17 -0
  212. package/server/src/routes/instance-settings.ts +95 -0
  213. package/server/src/routes/issues-checkout-wakeup.ts +14 -0
  214. package/server/src/routes/issues.ts +1680 -0
  215. package/server/src/routes/llms.ts +86 -0
  216. package/server/src/routes/org-chart-svg.ts +777 -0
  217. package/server/src/routes/plugin-ui-static.ts +497 -0
  218. package/server/src/routes/plugins.ts +2220 -0
  219. package/server/src/routes/projects.ts +295 -0
  220. package/server/src/routes/routines.ts +300 -0
  221. package/server/src/routes/secrets.ts +166 -0
  222. package/server/src/routes/sidebar-badges.ts +52 -0
  223. package/server/src/secrets/external-stub-providers.ts +32 -0
  224. package/server/src/secrets/local-encrypted-provider.ts +135 -0
  225. package/server/src/secrets/provider-registry.ts +31 -0
  226. package/server/src/secrets/types.ts +23 -0
  227. package/server/src/services/access.ts +381 -0
  228. package/server/src/services/activity-log.ts +95 -0
  229. package/server/src/services/activity.ts +164 -0
  230. package/server/src/services/agent-instructions.ts +735 -0
  231. package/server/src/services/agent-permissions.ts +27 -0
  232. package/server/src/services/agents.ts +694 -0
  233. package/server/src/services/approvals.ts +273 -0
  234. package/server/src/services/assets.ts +23 -0
  235. package/server/src/services/board-auth.ts +355 -0
  236. package/server/src/services/budgets.ts +959 -0
  237. package/server/src/services/companies.ts +313 -0
  238. package/server/src/services/company-export-readme.ts +173 -0
  239. package/server/src/services/company-portability.ts +4263 -0
  240. package/server/src/services/company-skills.ts +2356 -0
  241. package/server/src/services/costs.ts +365 -0
  242. package/server/src/services/cron.ts +373 -0
  243. package/server/src/services/dashboard.ts +110 -0
  244. package/server/src/services/default-agent-instructions.ts +27 -0
  245. package/server/src/services/documents.ts +434 -0
  246. package/server/src/services/execution-workspace-policy.ts +210 -0
  247. package/server/src/services/execution-workspaces.ts +100 -0
  248. package/server/src/services/finance.ts +135 -0
  249. package/server/src/services/goals.ts +81 -0
  250. package/server/src/services/heartbeat-run-summary.ts +35 -0
  251. package/server/src/services/heartbeat.ts +3863 -0
  252. package/server/src/services/hire-hook.ts +114 -0
  253. package/server/src/services/index.ts +32 -0
  254. package/server/src/services/instance-settings.ts +138 -0
  255. package/server/src/services/issue-approvals.ts +175 -0
  256. package/server/src/services/issue-assignment-wakeup.ts +48 -0
  257. package/server/src/services/issue-goal-fallback.ts +56 -0
  258. package/server/src/services/issues.ts +1828 -0
  259. package/server/src/services/live-events.ts +55 -0
  260. package/server/src/services/plugin-capability-validator.ts +450 -0
  261. package/server/src/services/plugin-config-validator.ts +55 -0
  262. package/server/src/services/plugin-dev-watcher.ts +339 -0
  263. package/server/src/services/plugin-event-bus.ts +413 -0
  264. package/server/src/services/plugin-host-service-cleanup.ts +59 -0
  265. package/server/src/services/plugin-host-services.ts +1132 -0
  266. package/server/src/services/plugin-job-coordinator.ts +261 -0
  267. package/server/src/services/plugin-job-scheduler.ts +753 -0
  268. package/server/src/services/plugin-job-store.ts +466 -0
  269. package/server/src/services/plugin-lifecycle.ts +822 -0
  270. package/server/src/services/plugin-loader.ts +1955 -0
  271. package/server/src/services/plugin-log-retention.ts +87 -0
  272. package/server/src/services/plugin-manifest-validator.ts +164 -0
  273. package/server/src/services/plugin-registry.ts +683 -0
  274. package/server/src/services/plugin-runtime-sandbox.ts +222 -0
  275. package/server/src/services/plugin-secrets-handler.ts +355 -0
  276. package/server/src/services/plugin-state-store.ts +238 -0
  277. package/server/src/services/plugin-stream-bus.ts +81 -0
  278. package/server/src/services/plugin-tool-dispatcher.ts +449 -0
  279. package/server/src/services/plugin-tool-registry.ts +450 -0
  280. package/server/src/services/plugin-worker-manager.ts +1343 -0
  281. package/server/src/services/projects.ts +860 -0
  282. package/server/src/services/quota-windows.ts +65 -0
  283. package/server/src/services/routines.ts +1269 -0
  284. package/server/src/services/run-log-store.ts +156 -0
  285. package/server/src/services/secrets.ts +370 -0
  286. package/server/src/services/sidebar-badges.ts +56 -0
  287. package/server/src/services/work-products.ts +124 -0
  288. package/server/src/services/workspace-operation-log-store.ts +156 -0
  289. package/server/src/services/workspace-operations.ts +262 -0
  290. package/server/src/services/workspace-runtime.ts +1565 -0
  291. package/server/src/startup-banner.ts +176 -0
  292. package/server/src/storage/index.ts +35 -0
  293. package/server/src/storage/local-disk-provider.ts +89 -0
  294. package/server/src/storage/provider-registry.ts +18 -0
  295. package/server/src/storage/s3-provider.ts +153 -0
  296. package/server/src/storage/service.ts +131 -0
  297. package/server/src/storage/types.ts +63 -0
  298. package/server/src/ui-branding.ts +217 -0
  299. package/server/src/version.ts +10 -0
  300. package/server/src/worktree-config.ts +468 -0
  301. package/server/tsconfig.json +9 -0
  302. package/server/vitest.config.ts +7 -0
  303. package/skills/paperclip/SKILL.md +365 -0
  304. package/skills/paperclip/references/api-reference.md +647 -0
  305. package/skills/paperclip/references/company-skills.md +193 -0
  306. package/skills/paperclip-create-agent/SKILL.md +142 -0
  307. package/skills/paperclip-create-agent/references/api-reference.md +105 -0
  308. package/skills/paperclip-create-plugin/SKILL.md +102 -0
  309. package/skills/para-memory-files/SKILL.md +104 -0
  310. package/skills/para-memory-files/references/schemas.md +35 -0
  311. package/tests/e2e/onboarding.spec.ts +142 -0
  312. package/tests/e2e/playwright.config.ts +35 -0
  313. package/tests/release-smoke/docker-auth-onboarding.spec.ts +141 -0
  314. package/tests/release-smoke/playwright.config.ts +28 -0
  315. package/tsconfig.base.json +18 -0
  316. package/tsconfig.json +18 -0
  317. package/ui/README.md +12 -0
  318. package/ui/components.json +21 -0
  319. package/ui/index.html +47 -0
  320. package/ui/package.json +73 -0
  321. package/ui/public/android-chrome-192x192.png +0 -0
  322. package/ui/public/android-chrome-512x512.png +0 -0
  323. package/ui/public/apple-touch-icon.png +0 -0
  324. package/ui/public/brands/opencode-logo-dark-square.svg +18 -0
  325. package/ui/public/brands/opencode-logo-light-square.svg +18 -0
  326. package/ui/public/favicon-16x16.png +0 -0
  327. package/ui/public/favicon-32x32.png +0 -0
  328. package/ui/public/favicon.ico +0 -0
  329. package/ui/public/favicon.svg +9 -0
  330. package/ui/public/site.webmanifest +30 -0
  331. package/ui/public/sprites/1-D-1.png +0 -0
  332. package/ui/public/sprites/1-D-2.png +0 -0
  333. package/ui/public/sprites/1-D-3.png +0 -0
  334. package/ui/public/sprites/1-L-1.png +0 -0
  335. package/ui/public/sprites/1-R-1.png +0 -0
  336. package/ui/public/sprites/10-D-1.png +0 -0
  337. package/ui/public/sprites/10-D-2.png +0 -0
  338. package/ui/public/sprites/10-D-3.png +0 -0
  339. package/ui/public/sprites/10-L-1.png +0 -0
  340. package/ui/public/sprites/10-R-1.png +0 -0
  341. package/ui/public/sprites/11-D-1.png +0 -0
  342. package/ui/public/sprites/11-D-2.png +0 -0
  343. package/ui/public/sprites/11-D-3.png +0 -0
  344. package/ui/public/sprites/11-L-1.png +0 -0
  345. package/ui/public/sprites/11-R-1.png +0 -0
  346. package/ui/public/sprites/12-D-1.png +0 -0
  347. package/ui/public/sprites/12-D-2.png +0 -0
  348. package/ui/public/sprites/12-D-3.png +0 -0
  349. package/ui/public/sprites/12-L-1.png +0 -0
  350. package/ui/public/sprites/12-R-1.png +0 -0
  351. package/ui/public/sprites/13-D-1.png +0 -0
  352. package/ui/public/sprites/13-D-2.png +0 -0
  353. package/ui/public/sprites/13-D-3.png +0 -0
  354. package/ui/public/sprites/13-L-1.png +0 -0
  355. package/ui/public/sprites/13-R-1.png +0 -0
  356. package/ui/public/sprites/14-D-1.png +0 -0
  357. package/ui/public/sprites/14-D-2.png +0 -0
  358. package/ui/public/sprites/14-D-3.png +0 -0
  359. package/ui/public/sprites/14-L-1.png +0 -0
  360. package/ui/public/sprites/14-R-1.png +0 -0
  361. package/ui/public/sprites/2-D-1.png +0 -0
  362. package/ui/public/sprites/2-D-2.png +0 -0
  363. package/ui/public/sprites/2-D-3.png +0 -0
  364. package/ui/public/sprites/2-L-1.png +0 -0
  365. package/ui/public/sprites/2-R-1.png +0 -0
  366. package/ui/public/sprites/3-D-1.png +0 -0
  367. package/ui/public/sprites/3-D-2.png +0 -0
  368. package/ui/public/sprites/3-D-3.png +0 -0
  369. package/ui/public/sprites/3-L-1.png +0 -0
  370. package/ui/public/sprites/3-R-1.png +0 -0
  371. package/ui/public/sprites/4-D-1.png +0 -0
  372. package/ui/public/sprites/4-D-2.png +0 -0
  373. package/ui/public/sprites/4-D-3.png +0 -0
  374. package/ui/public/sprites/4-L-1.png +0 -0
  375. package/ui/public/sprites/4-R-1.png +0 -0
  376. package/ui/public/sprites/5-D-1.png +0 -0
  377. package/ui/public/sprites/5-D-2.png +0 -0
  378. package/ui/public/sprites/5-D-3.png +0 -0
  379. package/ui/public/sprites/5-L-1.png +0 -0
  380. package/ui/public/sprites/5-R-1.png +0 -0
  381. package/ui/public/sprites/6-D-1.png +0 -0
  382. package/ui/public/sprites/6-D-2.png +0 -0
  383. package/ui/public/sprites/6-D-3.png +0 -0
  384. package/ui/public/sprites/6-L-1.png +0 -0
  385. package/ui/public/sprites/6-R-1.png +0 -0
  386. package/ui/public/sprites/7-D-1.png +0 -0
  387. package/ui/public/sprites/7-D-2.png +0 -0
  388. package/ui/public/sprites/7-D-3.png +0 -0
  389. package/ui/public/sprites/7-L-1.png +0 -0
  390. package/ui/public/sprites/7-R-1.png +0 -0
  391. package/ui/public/sprites/8-D-1.png +0 -0
  392. package/ui/public/sprites/8-D-2.png +0 -0
  393. package/ui/public/sprites/8-D-3.png +0 -0
  394. package/ui/public/sprites/8-L-1.png +0 -0
  395. package/ui/public/sprites/8-R-1.png +0 -0
  396. package/ui/public/sprites/9-D-1.png +0 -0
  397. package/ui/public/sprites/9-D-2.png +0 -0
  398. package/ui/public/sprites/9-D-3.png +0 -0
  399. package/ui/public/sprites/9-L-1.png +0 -0
  400. package/ui/public/sprites/9-R-1.png +0 -0
  401. package/ui/public/sprites/ceo-lobster.png +0 -0
  402. package/ui/public/sw.js +42 -0
  403. package/ui/public/worktree-favicon-16x16.png +0 -0
  404. package/ui/public/worktree-favicon-32x32.png +0 -0
  405. package/ui/public/worktree-favicon.ico +0 -0
  406. package/ui/public/worktree-favicon.svg +9 -0
  407. package/ui/src/App.tsx +354 -0
  408. package/ui/src/adapters/claude-local/config-fields.tsx +138 -0
  409. package/ui/src/adapters/claude-local/index.ts +13 -0
  410. package/ui/src/adapters/codex-local/config-fields.tsx +104 -0
  411. package/ui/src/adapters/codex-local/index.ts +13 -0
  412. package/ui/src/adapters/cursor/config-fields.tsx +49 -0
  413. package/ui/src/adapters/cursor/index.ts +13 -0
  414. package/ui/src/adapters/gemini-local/config-fields.tsx +51 -0
  415. package/ui/src/adapters/gemini-local/index.ts +13 -0
  416. package/ui/src/adapters/http/build-config.ts +9 -0
  417. package/ui/src/adapters/http/config-fields.tsx +38 -0
  418. package/ui/src/adapters/http/index.ts +12 -0
  419. package/ui/src/adapters/http/parse-stdout.ts +5 -0
  420. package/ui/src/adapters/index.ts +9 -0
  421. package/ui/src/adapters/local-workspace-runtime-fields.tsx +5 -0
  422. package/ui/src/adapters/openclaw-gateway/config-fields.tsx +237 -0
  423. package/ui/src/adapters/openclaw-gateway/index.ts +13 -0
  424. package/ui/src/adapters/opencode-local/config-fields.tsx +72 -0
  425. package/ui/src/adapters/opencode-local/index.ts +13 -0
  426. package/ui/src/adapters/pi-local/config-fields.tsx +49 -0
  427. package/ui/src/adapters/pi-local/index.ts +13 -0
  428. package/ui/src/adapters/process/build-config.ts +18 -0
  429. package/ui/src/adapters/process/config-fields.tsx +77 -0
  430. package/ui/src/adapters/process/index.ts +12 -0
  431. package/ui/src/adapters/process/parse-stdout.ts +5 -0
  432. package/ui/src/adapters/registry.ts +34 -0
  433. package/ui/src/adapters/runtime-json-fields.tsx +122 -0
  434. package/ui/src/adapters/transcript.test.ts +30 -0
  435. package/ui/src/adapters/transcript.ts +62 -0
  436. package/ui/src/adapters/types.ts +34 -0
  437. package/ui/src/api/access.ts +160 -0
  438. package/ui/src/api/activity.ts +37 -0
  439. package/ui/src/api/agents.ts +194 -0
  440. package/ui/src/api/approvals.ts +25 -0
  441. package/ui/src/api/assets.ts +30 -0
  442. package/ui/src/api/auth.ts +74 -0
  443. package/ui/src/api/budgets.ts +21 -0
  444. package/ui/src/api/client.ts +50 -0
  445. package/ui/src/api/companies.ts +59 -0
  446. package/ui/src/api/companySkills.ts +55 -0
  447. package/ui/src/api/costs.ts +60 -0
  448. package/ui/src/api/dashboard.ts +7 -0
  449. package/ui/src/api/execution-workspaces.ts +27 -0
  450. package/ui/src/api/goals.ts +12 -0
  451. package/ui/src/api/health.ts +41 -0
  452. package/ui/src/api/heartbeats.ts +62 -0
  453. package/ui/src/api/index.ts +18 -0
  454. package/ui/src/api/instanceSettings.ts +19 -0
  455. package/ui/src/api/issues.ts +115 -0
  456. package/ui/src/api/plugins.ts +424 -0
  457. package/ui/src/api/projects.ts +34 -0
  458. package/ui/src/api/routines.ts +59 -0
  459. package/ui/src/api/secrets.ts +26 -0
  460. package/ui/src/api/sidebarBadges.ts +7 -0
  461. package/ui/src/components/AccountingModelCard.tsx +69 -0
  462. package/ui/src/components/ActiveAgentsPanel.tsx +157 -0
  463. package/ui/src/components/ActivityCharts.tsx +264 -0
  464. package/ui/src/components/ActivityRow.tsx +147 -0
  465. package/ui/src/components/AgentActionButtons.tsx +51 -0
  466. package/ui/src/components/AgentConfigForm.tsx +1468 -0
  467. package/ui/src/components/AgentIconPicker.tsx +81 -0
  468. package/ui/src/components/AgentProperties.tsx +107 -0
  469. package/ui/src/components/ApprovalCard.tsx +107 -0
  470. package/ui/src/components/ApprovalPayload.tsx +134 -0
  471. package/ui/src/components/AsciiArtAnimation.tsx +355 -0
  472. package/ui/src/components/BillerSpendCard.tsx +146 -0
  473. package/ui/src/components/BreadcrumbBar.tsx +113 -0
  474. package/ui/src/components/BudgetIncidentCard.tsx +101 -0
  475. package/ui/src/components/BudgetPolicyCard.tsx +220 -0
  476. package/ui/src/components/BudgetSidebarMarker.tsx +13 -0
  477. package/ui/src/components/ClaudeSubscriptionPanel.tsx +141 -0
  478. package/ui/src/components/CodexSubscriptionPanel.tsx +158 -0
  479. package/ui/src/components/CommandPalette.tsx +239 -0
  480. package/ui/src/components/CommentThread.tsx +503 -0
  481. package/ui/src/components/CompanyPatternIcon.tsx +212 -0
  482. package/ui/src/components/CompanyRail.tsx +329 -0
  483. package/ui/src/components/CompanySwitcher.tsx +81 -0
  484. package/ui/src/components/CopyText.tsx +56 -0
  485. package/ui/src/components/DevRestartBanner.tsx +89 -0
  486. package/ui/src/components/EmptyState.tsx +27 -0
  487. package/ui/src/components/EntityRow.tsx +69 -0
  488. package/ui/src/components/FilterBar.tsx +39 -0
  489. package/ui/src/components/FinanceBillerCard.tsx +45 -0
  490. package/ui/src/components/FinanceKindCard.tsx +44 -0
  491. package/ui/src/components/FinanceTimelineCard.tsx +72 -0
  492. package/ui/src/components/GoalProperties.tsx +165 -0
  493. package/ui/src/components/GoalTree.tsx +118 -0
  494. package/ui/src/components/Identity.tsx +39 -0
  495. package/ui/src/components/InlineEditor.tsx +248 -0
  496. package/ui/src/components/InlineEntitySelector.tsx +206 -0
  497. package/ui/src/components/InstanceSidebar.tsx +53 -0
  498. package/ui/src/components/IssueDocumentsSection.tsx +892 -0
  499. package/ui/src/components/IssueProperties.tsx +621 -0
  500. package/ui/src/components/IssueRow.tsx +149 -0
  501. package/ui/src/components/IssueWorkspaceCard.tsx +404 -0
  502. package/ui/src/components/IssuesList.tsx +889 -0
  503. package/ui/src/components/JsonSchemaForm.tsx +1048 -0
  504. package/ui/src/components/KanbanBoard.tsx +275 -0
  505. package/ui/src/components/Layout.tsx +441 -0
  506. package/ui/src/components/LiveRunWidget.tsx +160 -0
  507. package/ui/src/components/MarkdownBody.test.tsx +50 -0
  508. package/ui/src/components/MarkdownBody.tsx +152 -0
  509. package/ui/src/components/MarkdownEditor.tsx +622 -0
  510. package/ui/src/components/MetricCard.tsx +53 -0
  511. package/ui/src/components/MobileBottomNav.tsx +123 -0
  512. package/ui/src/components/NewAgentDialog.tsx +223 -0
  513. package/ui/src/components/NewGoalDialog.tsx +283 -0
  514. package/ui/src/components/NewIssueDialog.tsx +1473 -0
  515. package/ui/src/components/NewProjectDialog.tsx +451 -0
  516. package/ui/src/components/OnboardingWizard.tsx +1392 -0
  517. package/ui/src/components/OpenCodeLogoIcon.tsx +22 -0
  518. package/ui/src/components/PackageFileTree.tsx +318 -0
  519. package/ui/src/components/PageSkeleton.tsx +180 -0
  520. package/ui/src/components/PageTabBar.tsx +45 -0
  521. package/ui/src/components/PathInstructionsModal.tsx +143 -0
  522. package/ui/src/components/PriorityIcon.tsx +77 -0
  523. package/ui/src/components/ProjectProperties.tsx +1127 -0
  524. package/ui/src/components/PropertiesPanel.tsx +29 -0
  525. package/ui/src/components/ProviderQuotaCard.tsx +417 -0
  526. package/ui/src/components/QuotaBar.tsx +65 -0
  527. package/ui/src/components/ReportsToPicker.tsx +127 -0
  528. package/ui/src/components/ScheduleEditor.tsx +344 -0
  529. package/ui/src/components/ScrollToBottom.tsx +79 -0
  530. package/ui/src/components/Sidebar.tsx +130 -0
  531. package/ui/src/components/SidebarAgents.tsx +146 -0
  532. package/ui/src/components/SidebarNavItem.tsx +92 -0
  533. package/ui/src/components/SidebarProjects.tsx +234 -0
  534. package/ui/src/components/SidebarSection.tsx +17 -0
  535. package/ui/src/components/StatusBadge.tsx +15 -0
  536. package/ui/src/components/StatusIcon.tsx +71 -0
  537. package/ui/src/components/SwipeToArchive.tsx +152 -0
  538. package/ui/src/components/ToastViewport.tsx +99 -0
  539. package/ui/src/components/WorktreeBanner.tsx +25 -0
  540. package/ui/src/components/agent-config-defaults.ts +31 -0
  541. package/ui/src/components/agent-config-primitives.tsx +476 -0
  542. package/ui/src/components/transcript/RunTranscriptView.test.tsx +84 -0
  543. package/ui/src/components/transcript/RunTranscriptView.tsx +1015 -0
  544. package/ui/src/components/transcript/useLiveRunTranscripts.ts +297 -0
  545. package/ui/src/components/ui/avatar.tsx +107 -0
  546. package/ui/src/components/ui/badge.tsx +48 -0
  547. package/ui/src/components/ui/breadcrumb.tsx +109 -0
  548. package/ui/src/components/ui/button.tsx +64 -0
  549. package/ui/src/components/ui/card.tsx +92 -0
  550. package/ui/src/components/ui/checkbox.tsx +32 -0
  551. package/ui/src/components/ui/collapsible.tsx +33 -0
  552. package/ui/src/components/ui/command.tsx +194 -0
  553. package/ui/src/components/ui/dialog.tsx +156 -0
  554. package/ui/src/components/ui/dropdown-menu.tsx +257 -0
  555. package/ui/src/components/ui/input.tsx +21 -0
  556. package/ui/src/components/ui/label.tsx +22 -0
  557. package/ui/src/components/ui/popover.tsx +88 -0
  558. package/ui/src/components/ui/scroll-area.tsx +56 -0
  559. package/ui/src/components/ui/select.tsx +188 -0
  560. package/ui/src/components/ui/separator.tsx +28 -0
  561. package/ui/src/components/ui/sheet.tsx +143 -0
  562. package/ui/src/components/ui/skeleton.tsx +13 -0
  563. package/ui/src/components/ui/tabs.tsx +89 -0
  564. package/ui/src/components/ui/textarea.tsx +18 -0
  565. package/ui/src/components/ui/tooltip.tsx +57 -0
  566. package/ui/src/components/visual-office/AgentAvatar.tsx +99 -0
  567. package/ui/src/components/visual-office/OfficeViewExact.tsx +417 -0
  568. package/ui/src/components/visual-office/i18n.ts +52 -0
  569. package/ui/src/components/visual-office/office-view/CliUsagePanel.tsx +240 -0
  570. package/ui/src/components/visual-office/office-view/VirtualPadOverlay.tsx +104 -0
  571. package/ui/src/components/visual-office/office-view/buildScene-break-room.ts +248 -0
  572. package/ui/src/components/visual-office/office-view/buildScene-ceo-hallway.ts +345 -0
  573. package/ui/src/components/visual-office/office-view/buildScene-department-agent.ts +242 -0
  574. package/ui/src/components/visual-office/office-view/buildScene-departments.ts +360 -0
  575. package/ui/src/components/visual-office/office-view/buildScene-final-layers.ts +113 -0
  576. package/ui/src/components/visual-office/office-view/buildScene-types.ts +91 -0
  577. package/ui/src/components/visual-office/office-view/buildScene.ts +232 -0
  578. package/ui/src/components/visual-office/office-view/drawing-core.ts +374 -0
  579. package/ui/src/components/visual-office/office-view/drawing-furniture-a.ts +338 -0
  580. package/ui/src/components/visual-office/office-view/drawing-furniture-b.ts +241 -0
  581. package/ui/src/components/visual-office/office-view/model.ts +301 -0
  582. package/ui/src/components/visual-office/office-view/officeTicker.ts +455 -0
  583. package/ui/src/components/visual-office/office-view/officeTickerRoomAndDelivery.ts +133 -0
  584. package/ui/src/components/visual-office/office-view/themes-locale.ts +460 -0
  585. package/ui/src/components/visual-office/office-view/useCliUsage.ts +37 -0
  586. package/ui/src/components/visual-office/office-view/useOfficeDeliveryEffects.ts +465 -0
  587. package/ui/src/components/visual-office/office-view/useOfficePixiRuntime.ts +282 -0
  588. package/ui/src/components/visual-office/types.ts +123 -0
  589. package/ui/src/context/BreadcrumbContext.tsx +44 -0
  590. package/ui/src/context/CompanyContext.tsx +151 -0
  591. package/ui/src/context/DialogContext.tsx +135 -0
  592. package/ui/src/context/LiveUpdatesProvider.test.ts +119 -0
  593. package/ui/src/context/LiveUpdatesProvider.tsx +760 -0
  594. package/ui/src/context/PanelContext.tsx +73 -0
  595. package/ui/src/context/SidebarContext.tsx +43 -0
  596. package/ui/src/context/ThemeContext.tsx +83 -0
  597. package/ui/src/context/ToastContext.tsx +172 -0
  598. package/ui/src/fixtures/runTranscriptFixtures.ts +226 -0
  599. package/ui/src/hooks/useAgentOrder.ts +105 -0
  600. package/ui/src/hooks/useAutosaveIndicator.ts +72 -0
  601. package/ui/src/hooks/useCompanyPageMemory.test.ts +90 -0
  602. package/ui/src/hooks/useCompanyPageMemory.ts +79 -0
  603. package/ui/src/hooks/useDateRange.ts +120 -0
  604. package/ui/src/hooks/useInboxBadge.ts +132 -0
  605. package/ui/src/hooks/useKeyboardShortcuts.ts +40 -0
  606. package/ui/src/hooks/useProjectOrder.ts +106 -0
  607. package/ui/src/index.css +770 -0
  608. package/ui/src/lib/agent-icons.ts +99 -0
  609. package/ui/src/lib/agent-order.ts +107 -0
  610. package/ui/src/lib/agent-skills-state.test.ts +90 -0
  611. package/ui/src/lib/agent-skills-state.ts +41 -0
  612. package/ui/src/lib/assignees.test.ts +92 -0
  613. package/ui/src/lib/assignees.ts +82 -0
  614. package/ui/src/lib/color-contrast.ts +107 -0
  615. package/ui/src/lib/company-export-selection.test.ts +41 -0
  616. package/ui/src/lib/company-export-selection.ts +57 -0
  617. package/ui/src/lib/company-page-memory.ts +65 -0
  618. package/ui/src/lib/company-portability-sidebar.test.ts +101 -0
  619. package/ui/src/lib/company-portability-sidebar.ts +62 -0
  620. package/ui/src/lib/company-routes.ts +88 -0
  621. package/ui/src/lib/company-selection.test.ts +34 -0
  622. package/ui/src/lib/company-selection.ts +18 -0
  623. package/ui/src/lib/groupBy.ts +11 -0
  624. package/ui/src/lib/inbox.test.ts +404 -0
  625. package/ui/src/lib/inbox.ts +292 -0
  626. package/ui/src/lib/instance-settings.test.ts +26 -0
  627. package/ui/src/lib/instance-settings.ts +25 -0
  628. package/ui/src/lib/issueDetailBreadcrumb.ts +24 -0
  629. package/ui/src/lib/legacy-agent-config.test.ts +40 -0
  630. package/ui/src/lib/legacy-agent-config.ts +17 -0
  631. package/ui/src/lib/mention-aware-link-node.test.ts +50 -0
  632. package/ui/src/lib/mention-aware-link-node.ts +67 -0
  633. package/ui/src/lib/mention-chips.ts +168 -0
  634. package/ui/src/lib/mention-deletion.test.ts +87 -0
  635. package/ui/src/lib/mention-deletion.ts +143 -0
  636. package/ui/src/lib/model-utils.ts +16 -0
  637. package/ui/src/lib/onboarding-goal.test.ts +22 -0
  638. package/ui/src/lib/onboarding-goal.ts +18 -0
  639. package/ui/src/lib/onboarding-launch.test.ts +131 -0
  640. package/ui/src/lib/onboarding-launch.ts +54 -0
  641. package/ui/src/lib/onboarding-route.test.ts +80 -0
  642. package/ui/src/lib/onboarding-route.ts +51 -0
  643. package/ui/src/lib/portable-files.ts +42 -0
  644. package/ui/src/lib/project-order.ts +71 -0
  645. package/ui/src/lib/queryKeys.ts +140 -0
  646. package/ui/src/lib/recent-assignees.ts +36 -0
  647. package/ui/src/lib/router.tsx +76 -0
  648. package/ui/src/lib/routine-trigger-patch.test.ts +72 -0
  649. package/ui/src/lib/routine-trigger-patch.ts +31 -0
  650. package/ui/src/lib/status-colors.ts +108 -0
  651. package/ui/src/lib/timeAgo.ts +31 -0
  652. package/ui/src/lib/utils.ts +168 -0
  653. package/ui/src/lib/worktree-branding.ts +65 -0
  654. package/ui/src/lib/zip.test.ts +289 -0
  655. package/ui/src/lib/zip.ts +284 -0
  656. package/ui/src/main.tsx +67 -0
  657. package/ui/src/pages/Activity.tsx +141 -0
  658. package/ui/src/pages/AgentDetail.tsx +4053 -0
  659. package/ui/src/pages/Agents.tsx +415 -0
  660. package/ui/src/pages/ApprovalDetail.tsx +369 -0
  661. package/ui/src/pages/Approvals.tsx +132 -0
  662. package/ui/src/pages/Auth.tsx +180 -0
  663. package/ui/src/pages/BoardClaim.tsx +125 -0
  664. package/ui/src/pages/CliAuth.tsx +184 -0
  665. package/ui/src/pages/Companies.tsx +297 -0
  666. package/ui/src/pages/CompanyExport.tsx +1019 -0
  667. package/ui/src/pages/CompanyImport.tsx +1355 -0
  668. package/ui/src/pages/CompanySettings.tsx +661 -0
  669. package/ui/src/pages/CompanySkills.tsx +1171 -0
  670. package/ui/src/pages/Costs.tsx +1103 -0
  671. package/ui/src/pages/Dashboard.tsx +388 -0
  672. package/ui/src/pages/DesignGuide.tsx +1330 -0
  673. package/ui/src/pages/ExecutionWorkspaceDetail.tsx +82 -0
  674. package/ui/src/pages/GoalDetail.tsx +197 -0
  675. package/ui/src/pages/Goals.tsx +63 -0
  676. package/ui/src/pages/Inbox.tsx +1291 -0
  677. package/ui/src/pages/InstanceExperimentalSettings.tsx +139 -0
  678. package/ui/src/pages/InstanceGeneralSettings.tsx +104 -0
  679. package/ui/src/pages/InstanceSettings.tsx +284 -0
  680. package/ui/src/pages/InviteLanding.tsx +320 -0
  681. package/ui/src/pages/IssueDetail.tsx +1201 -0
  682. package/ui/src/pages/Issues.tsx +116 -0
  683. package/ui/src/pages/MyIssues.tsx +72 -0
  684. package/ui/src/pages/NewAgent.tsx +353 -0
  685. package/ui/src/pages/NotFound.tsx +66 -0
  686. package/ui/src/pages/Org.tsx +132 -0
  687. package/ui/src/pages/OrgChart.tsx +447 -0
  688. package/ui/src/pages/PluginManager.tsx +510 -0
  689. package/ui/src/pages/PluginPage.tsx +156 -0
  690. package/ui/src/pages/PluginSettings.tsx +836 -0
  691. package/ui/src/pages/ProjectDetail.tsx +633 -0
  692. package/ui/src/pages/Projects.tsx +87 -0
  693. package/ui/src/pages/RoutineDetail.tsx +1022 -0
  694. package/ui/src/pages/Routines.tsx +661 -0
  695. package/ui/src/pages/RunTranscriptUxLab.tsx +334 -0
  696. package/ui/src/pages/VisualOffice.tsx +243 -0
  697. package/ui/src/plugins/bridge-init.ts +69 -0
  698. package/ui/src/plugins/bridge.ts +476 -0
  699. package/ui/src/plugins/launchers.tsx +834 -0
  700. package/ui/src/plugins/slots.tsx +855 -0
  701. package/ui/tsconfig.json +21 -0
  702. package/ui/vite.config.ts +23 -0
  703. package/ui/vitest.config.ts +14 -0
  704. package/vitest.config.ts +11 -0
@@ -0,0 +1,1201 @@
1
+ import { useEffect, useMemo, useRef, useState, type ChangeEvent, type DragEvent } from "react";
2
+ import { pickTextColorForPillBg } from "@/lib/color-contrast";
3
+ import { Link, useLocation, useNavigate, useParams } from "@/lib/router";
4
+ import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
5
+ import { issuesApi } from "../api/issues";
6
+ import { activityApi } from "../api/activity";
7
+ import { heartbeatsApi } from "../api/heartbeats";
8
+ import { agentsApi } from "../api/agents";
9
+ import { authApi } from "../api/auth";
10
+ import { projectsApi } from "../api/projects";
11
+ import { useCompany } from "../context/CompanyContext";
12
+ import { usePanel } from "../context/PanelContext";
13
+ import { useToast } from "../context/ToastContext";
14
+ import { useBreadcrumbs } from "../context/BreadcrumbContext";
15
+ import { assigneeValueFromSelection, suggestedCommentAssigneeValue } from "../lib/assignees";
16
+ import { queryKeys } from "../lib/queryKeys";
17
+ import { readIssueDetailBreadcrumb } from "../lib/issueDetailBreadcrumb";
18
+ import { useProjectOrder } from "../hooks/useProjectOrder";
19
+ import { relativeTime, cn, formatTokens, visibleRunCostUsd } from "../lib/utils";
20
+ import { InlineEditor } from "../components/InlineEditor";
21
+ import { CommentThread } from "../components/CommentThread";
22
+ import { IssueDocumentsSection } from "../components/IssueDocumentsSection";
23
+ import { IssueProperties } from "../components/IssueProperties";
24
+ import { IssueWorkspaceCard } from "../components/IssueWorkspaceCard";
25
+ import { LiveRunWidget } from "../components/LiveRunWidget";
26
+ import type { MentionOption } from "../components/MarkdownEditor";
27
+ import { ScrollToBottom } from "../components/ScrollToBottom";
28
+ import { StatusIcon } from "../components/StatusIcon";
29
+ import { PriorityIcon } from "../components/PriorityIcon";
30
+ import { StatusBadge } from "../components/StatusBadge";
31
+ import { Identity } from "../components/Identity";
32
+ import { PluginSlotMount, PluginSlotOutlet, usePluginSlots } from "@/plugins/slots";
33
+ import { PluginLauncherOutlet } from "@/plugins/launchers";
34
+ import { Separator } from "@/components/ui/separator";
35
+ import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover";
36
+ import { Button } from "@/components/ui/button";
37
+ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
38
+ import { Sheet, SheetContent, SheetHeader, SheetTitle } from "@/components/ui/sheet";
39
+ import { ScrollArea } from "@/components/ui/scroll-area";
40
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
41
+ import {
42
+ Activity as ActivityIcon,
43
+ Check,
44
+ ChevronDown,
45
+ ChevronRight,
46
+ Copy,
47
+ EyeOff,
48
+ Hexagon,
49
+ ListTree,
50
+ MessageSquare,
51
+ MoreHorizontal,
52
+ Paperclip,
53
+ Repeat,
54
+ SlidersHorizontal,
55
+ Trash2,
56
+ } from "lucide-react";
57
+ import type { ActivityEvent } from "@corporateai/shared";
58
+ import type { Agent, IssueAttachment } from "@corporateai/shared";
59
+
60
+ type CommentReassignment = {
61
+ assigneeAgentId: string | null;
62
+ assigneeUserId: string | null;
63
+ };
64
+
65
+ const ACTION_LABELS: Record<string, string> = {
66
+ "issue.created": "created the issue",
67
+ "issue.updated": "updated the issue",
68
+ "issue.checked_out": "checked out the issue",
69
+ "issue.released": "released the issue",
70
+ "issue.comment_added": "added a comment",
71
+ "issue.attachment_added": "added an attachment",
72
+ "issue.attachment_removed": "removed an attachment",
73
+ "issue.document_created": "created a document",
74
+ "issue.document_updated": "updated a document",
75
+ "issue.document_deleted": "deleted a document",
76
+ "issue.deleted": "deleted the issue",
77
+ "agent.created": "created an agent",
78
+ "agent.updated": "updated the agent",
79
+ "agent.paused": "paused the agent",
80
+ "agent.resumed": "resumed the agent",
81
+ "agent.terminated": "terminated the agent",
82
+ "heartbeat.invoked": "invoked a heartbeat",
83
+ "heartbeat.cancelled": "cancelled a heartbeat",
84
+ "approval.created": "requested approval",
85
+ "approval.approved": "approved",
86
+ "approval.rejected": "rejected",
87
+ };
88
+
89
+ function humanizeValue(value: unknown): string {
90
+ if (typeof value !== "string") return String(value ?? "none");
91
+ return value.replace(/_/g, " ");
92
+ }
93
+
94
+ function asRecord(value: unknown): Record<string, unknown> | null {
95
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
96
+ return value as Record<string, unknown>;
97
+ }
98
+
99
+ function usageNumber(usage: Record<string, unknown> | null, ...keys: string[]) {
100
+ if (!usage) return 0;
101
+ for (const key of keys) {
102
+ const value = usage[key];
103
+ if (typeof value === "number" && Number.isFinite(value)) return value;
104
+ }
105
+ return 0;
106
+ }
107
+
108
+ function truncate(text: string, max: number): string {
109
+ if (text.length <= max) return text;
110
+ return text.slice(0, max - 1) + "\u2026";
111
+ }
112
+
113
+ function isMarkdownFile(file: File) {
114
+ const name = file.name.toLowerCase();
115
+ return (
116
+ name.endsWith(".md") ||
117
+ name.endsWith(".markdown") ||
118
+ file.type === "text/markdown"
119
+ );
120
+ }
121
+
122
+ function fileBaseName(filename: string) {
123
+ return filename.replace(/\.[^.]+$/, "");
124
+ }
125
+
126
+ function slugifyDocumentKey(input: string) {
127
+ const slug = input
128
+ .trim()
129
+ .toLowerCase()
130
+ .replace(/[^a-z0-9]+/g, "-")
131
+ .replace(/^-+|-+$/g, "");
132
+ return slug || "document";
133
+ }
134
+
135
+ function titleizeFilename(input: string) {
136
+ return input
137
+ .split(/[-_ ]+/g)
138
+ .filter(Boolean)
139
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
140
+ .join(" ");
141
+ }
142
+
143
+ function formatAction(action: string, details?: Record<string, unknown> | null): string {
144
+ if (action === "issue.updated" && details) {
145
+ const previous = (details._previous ?? {}) as Record<string, unknown>;
146
+ const parts: string[] = [];
147
+
148
+ if (details.status !== undefined) {
149
+ const from = previous.status;
150
+ parts.push(
151
+ from
152
+ ? `changed the status from ${humanizeValue(from)} to ${humanizeValue(details.status)}`
153
+ : `changed the status to ${humanizeValue(details.status)}`
154
+ );
155
+ }
156
+ if (details.priority !== undefined) {
157
+ const from = previous.priority;
158
+ parts.push(
159
+ from
160
+ ? `changed the priority from ${humanizeValue(from)} to ${humanizeValue(details.priority)}`
161
+ : `changed the priority to ${humanizeValue(details.priority)}`
162
+ );
163
+ }
164
+ if (details.assigneeAgentId !== undefined || details.assigneeUserId !== undefined) {
165
+ parts.push(
166
+ details.assigneeAgentId || details.assigneeUserId
167
+ ? "assigned the issue"
168
+ : "unassigned the issue",
169
+ );
170
+ }
171
+ if (details.title !== undefined) parts.push("updated the title");
172
+ if (details.description !== undefined) parts.push("updated the description");
173
+
174
+ if (parts.length > 0) return parts.join(", ");
175
+ }
176
+ if (
177
+ (action === "issue.document_created" || action === "issue.document_updated" || action === "issue.document_deleted") &&
178
+ details
179
+ ) {
180
+ const key = typeof details.key === "string" ? details.key : "document";
181
+ const title = typeof details.title === "string" && details.title ? ` (${details.title})` : "";
182
+ return `${ACTION_LABELS[action] ?? action} ${key}${title}`;
183
+ }
184
+ return ACTION_LABELS[action] ?? action.replace(/[._]/g, " ");
185
+ }
186
+
187
+ function ActorIdentity({ evt, agentMap }: { evt: ActivityEvent; agentMap: Map<string, Agent> }) {
188
+ const id = evt.actorId;
189
+ if (evt.actorType === "agent") {
190
+ const agent = agentMap.get(id);
191
+ return <Identity name={agent?.name ?? id.slice(0, 8)} size="sm" />;
192
+ }
193
+ if (evt.actorType === "system") return <Identity name="System" size="sm" />;
194
+ if (evt.actorType === "user") return <Identity name="Board" size="sm" />;
195
+ return <Identity name={id || "Unknown"} size="sm" />;
196
+ }
197
+
198
+ export function IssueDetail() {
199
+ const { issueId } = useParams<{ issueId: string }>();
200
+ const { selectedCompanyId } = useCompany();
201
+ const { openPanel, closePanel, panelVisible, setPanelVisible } = usePanel();
202
+ const { setBreadcrumbs } = useBreadcrumbs();
203
+ const queryClient = useQueryClient();
204
+ const navigate = useNavigate();
205
+ const location = useLocation();
206
+ const { pushToast } = useToast();
207
+ const [moreOpen, setMoreOpen] = useState(false);
208
+ const [copied, setCopied] = useState(false);
209
+ const [mobilePropsOpen, setMobilePropsOpen] = useState(false);
210
+ const [detailTab, setDetailTab] = useState("comments");
211
+ const [secondaryOpen, setSecondaryOpen] = useState({
212
+ approvals: false,
213
+ });
214
+ const [attachmentError, setAttachmentError] = useState<string | null>(null);
215
+ const [attachmentDragActive, setAttachmentDragActive] = useState(false);
216
+ const fileInputRef = useRef<HTMLInputElement | null>(null);
217
+ const lastMarkedReadIssueIdRef = useRef<string | null>(null);
218
+
219
+ const { data: issue, isLoading, error } = useQuery({
220
+ queryKey: queryKeys.issues.detail(issueId!),
221
+ queryFn: () => issuesApi.get(issueId!),
222
+ enabled: !!issueId,
223
+ });
224
+ const resolvedCompanyId = issue?.companyId ?? selectedCompanyId;
225
+
226
+ const { data: comments } = useQuery({
227
+ queryKey: queryKeys.issues.comments(issueId!),
228
+ queryFn: () => issuesApi.listComments(issueId!),
229
+ enabled: !!issueId,
230
+ });
231
+
232
+ const { data: activity } = useQuery({
233
+ queryKey: queryKeys.issues.activity(issueId!),
234
+ queryFn: () => activityApi.forIssue(issueId!),
235
+ enabled: !!issueId,
236
+ });
237
+
238
+ const { data: linkedRuns } = useQuery({
239
+ queryKey: queryKeys.issues.runs(issueId!),
240
+ queryFn: () => activityApi.runsForIssue(issueId!),
241
+ enabled: !!issueId,
242
+ refetchInterval: 5000,
243
+ });
244
+
245
+ const { data: linkedApprovals } = useQuery({
246
+ queryKey: queryKeys.issues.approvals(issueId!),
247
+ queryFn: () => issuesApi.listApprovals(issueId!),
248
+ enabled: !!issueId,
249
+ });
250
+
251
+ const { data: attachments } = useQuery({
252
+ queryKey: queryKeys.issues.attachments(issueId!),
253
+ queryFn: () => issuesApi.listAttachments(issueId!),
254
+ enabled: !!issueId,
255
+ });
256
+
257
+ const { data: liveRuns } = useQuery({
258
+ queryKey: queryKeys.issues.liveRuns(issueId!),
259
+ queryFn: () => heartbeatsApi.liveRunsForIssue(issueId!),
260
+ enabled: !!issueId,
261
+ refetchInterval: 3000,
262
+ });
263
+
264
+ const { data: activeRun } = useQuery({
265
+ queryKey: queryKeys.issues.activeRun(issueId!),
266
+ queryFn: () => heartbeatsApi.activeRunForIssue(issueId!),
267
+ enabled: !!issueId,
268
+ refetchInterval: 3000,
269
+ });
270
+
271
+ const hasLiveRuns = (liveRuns ?? []).length > 0 || !!activeRun;
272
+ const sourceBreadcrumb = useMemo(
273
+ () => readIssueDetailBreadcrumb(location.state) ?? { label: "Issues", href: "/issues" },
274
+ [location.state],
275
+ );
276
+
277
+ // Filter out runs already shown by the live widget to avoid duplication
278
+ const timelineRuns = useMemo(() => {
279
+ const liveIds = new Set<string>();
280
+ for (const r of liveRuns ?? []) liveIds.add(r.id);
281
+ if (activeRun) liveIds.add(activeRun.id);
282
+ if (liveIds.size === 0) return linkedRuns ?? [];
283
+ return (linkedRuns ?? []).filter((r) => !liveIds.has(r.runId));
284
+ }, [linkedRuns, liveRuns, activeRun]);
285
+
286
+ const { data: allIssues } = useQuery({
287
+ queryKey: queryKeys.issues.list(selectedCompanyId!),
288
+ queryFn: () => issuesApi.list(selectedCompanyId!),
289
+ enabled: !!selectedCompanyId,
290
+ });
291
+
292
+ const { data: agents } = useQuery({
293
+ queryKey: queryKeys.agents.list(selectedCompanyId!),
294
+ queryFn: () => agentsApi.list(selectedCompanyId!),
295
+ enabled: !!selectedCompanyId,
296
+ });
297
+
298
+ const { data: session } = useQuery({
299
+ queryKey: queryKeys.auth.session,
300
+ queryFn: () => authApi.getSession(),
301
+ });
302
+
303
+ const { data: projects } = useQuery({
304
+ queryKey: queryKeys.projects.list(selectedCompanyId!),
305
+ queryFn: () => projectsApi.list(selectedCompanyId!),
306
+ enabled: !!selectedCompanyId,
307
+ });
308
+ const currentUserId = session?.user?.id ?? session?.session?.userId ?? null;
309
+ const { orderedProjects } = useProjectOrder({
310
+ projects: projects ?? [],
311
+ companyId: selectedCompanyId,
312
+ userId: currentUserId,
313
+ });
314
+ const { slots: issuePluginDetailSlots } = usePluginSlots({
315
+ slotTypes: ["detailTab"],
316
+ entityType: "issue",
317
+ companyId: resolvedCompanyId,
318
+ enabled: !!resolvedCompanyId,
319
+ });
320
+ const issuePluginTabItems = useMemo(
321
+ () => issuePluginDetailSlots.map((slot) => ({
322
+ value: `plugin:${slot.pluginKey}:${slot.id}`,
323
+ label: slot.displayName,
324
+ slot,
325
+ })),
326
+ [issuePluginDetailSlots],
327
+ );
328
+ const activePluginTab = issuePluginTabItems.find((item) => item.value === detailTab) ?? null;
329
+
330
+ const agentMap = useMemo(() => {
331
+ const map = new Map<string, Agent>();
332
+ for (const a of agents ?? []) map.set(a.id, a);
333
+ return map;
334
+ }, [agents]);
335
+
336
+ const mentionOptions = useMemo<MentionOption[]>(() => {
337
+ const options: MentionOption[] = [];
338
+ const activeAgents = [...(agents ?? [])]
339
+ .filter((agent) => agent.status !== "terminated")
340
+ .sort((a, b) => a.name.localeCompare(b.name));
341
+ for (const agent of activeAgents) {
342
+ options.push({
343
+ id: `agent:${agent.id}`,
344
+ name: agent.name,
345
+ kind: "agent",
346
+ agentId: agent.id,
347
+ agentIcon: agent.icon,
348
+ });
349
+ }
350
+ for (const project of orderedProjects) {
351
+ options.push({
352
+ id: `project:${project.id}`,
353
+ name: project.name,
354
+ kind: "project",
355
+ projectId: project.id,
356
+ projectColor: project.color,
357
+ });
358
+ }
359
+ return options;
360
+ }, [agents, orderedProjects]);
361
+
362
+ const childIssues = useMemo(() => {
363
+ if (!allIssues || !issue) return [];
364
+ return allIssues
365
+ .filter((i) => i.parentId === issue.id)
366
+ .sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
367
+ }, [allIssues, issue]);
368
+
369
+ const commentReassignOptions = useMemo(() => {
370
+ const options: Array<{ id: string; label: string; searchText?: string }> = [];
371
+ const activeAgents = [...(agents ?? [])]
372
+ .filter((agent) => agent.status !== "terminated")
373
+ .sort((a, b) => a.name.localeCompare(b.name));
374
+ for (const agent of activeAgents) {
375
+ options.push({ id: `agent:${agent.id}`, label: agent.name });
376
+ }
377
+ if (currentUserId) {
378
+ options.push({ id: `user:${currentUserId}`, label: "Me" });
379
+ }
380
+ return options;
381
+ }, [agents, currentUserId]);
382
+
383
+ const actualAssigneeValue = useMemo(
384
+ () => assigneeValueFromSelection(issue ?? {}),
385
+ [issue],
386
+ );
387
+
388
+ const suggestedAssigneeValue = useMemo(
389
+ () => suggestedCommentAssigneeValue(issue ?? {}, comments, currentUserId),
390
+ [issue, comments, currentUserId],
391
+ );
392
+
393
+ const commentsWithRunMeta = useMemo(() => {
394
+ const runMetaByCommentId = new Map<string, { runId: string; runAgentId: string | null }>();
395
+ const agentIdByRunId = new Map<string, string>();
396
+ for (const run of linkedRuns ?? []) {
397
+ agentIdByRunId.set(run.runId, run.agentId);
398
+ }
399
+ for (const evt of activity ?? []) {
400
+ if (evt.action !== "issue.comment_added" || !evt.runId) continue;
401
+ const details = evt.details ?? {};
402
+ const commentId = typeof details["commentId"] === "string" ? details["commentId"] : null;
403
+ if (!commentId || runMetaByCommentId.has(commentId)) continue;
404
+ runMetaByCommentId.set(commentId, {
405
+ runId: evt.runId,
406
+ runAgentId: evt.agentId ?? agentIdByRunId.get(evt.runId) ?? null,
407
+ });
408
+ }
409
+ return (comments ?? []).map((comment) => {
410
+ const meta = runMetaByCommentId.get(comment.id);
411
+ return meta ? { ...comment, ...meta } : comment;
412
+ });
413
+ }, [activity, comments, linkedRuns]);
414
+
415
+ const issueCostSummary = useMemo(() => {
416
+ let input = 0;
417
+ let output = 0;
418
+ let cached = 0;
419
+ let cost = 0;
420
+ let hasCost = false;
421
+ let hasTokens = false;
422
+
423
+ for (const run of linkedRuns ?? []) {
424
+ const usage = asRecord(run.usageJson);
425
+ const result = asRecord(run.resultJson);
426
+ const runInput = usageNumber(usage, "inputTokens", "input_tokens");
427
+ const runOutput = usageNumber(usage, "outputTokens", "output_tokens");
428
+ const runCached = usageNumber(
429
+ usage,
430
+ "cachedInputTokens",
431
+ "cached_input_tokens",
432
+ "cache_read_input_tokens",
433
+ );
434
+ const runCost = visibleRunCostUsd(usage, result);
435
+ if (runCost > 0) hasCost = true;
436
+ if (runInput + runOutput + runCached > 0) hasTokens = true;
437
+ input += runInput;
438
+ output += runOutput;
439
+ cached += runCached;
440
+ cost += runCost;
441
+ }
442
+
443
+ return {
444
+ input,
445
+ output,
446
+ cached,
447
+ cost,
448
+ totalTokens: input + output,
449
+ hasCost,
450
+ hasTokens,
451
+ };
452
+ }, [linkedRuns]);
453
+
454
+ const invalidateIssue = () => {
455
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.detail(issueId!) });
456
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.activity(issueId!) });
457
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.runs(issueId!) });
458
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.approvals(issueId!) });
459
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.attachments(issueId!) });
460
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.documents(issueId!) });
461
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.liveRuns(issueId!) });
462
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.activeRun(issueId!) });
463
+ if (selectedCompanyId) {
464
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.list(selectedCompanyId) });
465
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.listMineByMe(selectedCompanyId) });
466
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.listTouchedByMe(selectedCompanyId) });
467
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.listUnreadTouchedByMe(selectedCompanyId) });
468
+ queryClient.invalidateQueries({ queryKey: queryKeys.sidebarBadges(selectedCompanyId) });
469
+ }
470
+ };
471
+
472
+ const markIssueRead = useMutation({
473
+ mutationFn: (id: string) => issuesApi.markRead(id),
474
+ onSuccess: () => {
475
+ if (selectedCompanyId) {
476
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.listMineByMe(selectedCompanyId) });
477
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.listTouchedByMe(selectedCompanyId) });
478
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.listUnreadTouchedByMe(selectedCompanyId) });
479
+ queryClient.invalidateQueries({ queryKey: queryKeys.sidebarBadges(selectedCompanyId) });
480
+ }
481
+ },
482
+ });
483
+
484
+ const updateIssue = useMutation({
485
+ mutationFn: (data: Record<string, unknown>) => issuesApi.update(issueId!, data),
486
+ onSuccess: () => {
487
+ invalidateIssue();
488
+ },
489
+ });
490
+
491
+ const addComment = useMutation({
492
+ mutationFn: ({ body, reopen }: { body: string; reopen?: boolean }) =>
493
+ issuesApi.addComment(issueId!, body, reopen),
494
+ onSuccess: () => {
495
+ invalidateIssue();
496
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.comments(issueId!) });
497
+ },
498
+ });
499
+
500
+ const addCommentAndReassign = useMutation({
501
+ mutationFn: ({
502
+ body,
503
+ reopen,
504
+ reassignment,
505
+ }: {
506
+ body: string;
507
+ reopen?: boolean;
508
+ reassignment: CommentReassignment;
509
+ }) =>
510
+ issuesApi.update(issueId!, {
511
+ comment: body,
512
+ assigneeAgentId: reassignment.assigneeAgentId,
513
+ assigneeUserId: reassignment.assigneeUserId,
514
+ ...(reopen ? { status: "todo" } : {}),
515
+ }),
516
+ onSuccess: () => {
517
+ invalidateIssue();
518
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.comments(issueId!) });
519
+ },
520
+ });
521
+
522
+ const uploadAttachment = useMutation({
523
+ mutationFn: async (file: File) => {
524
+ if (!selectedCompanyId) throw new Error("No company selected");
525
+ return issuesApi.uploadAttachment(selectedCompanyId, issueId!, file);
526
+ },
527
+ onSuccess: () => {
528
+ setAttachmentError(null);
529
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.attachments(issueId!) });
530
+ invalidateIssue();
531
+ },
532
+ onError: (err) => {
533
+ setAttachmentError(err instanceof Error ? err.message : "Upload failed");
534
+ },
535
+ });
536
+
537
+ const importMarkdownDocument = useMutation({
538
+ mutationFn: async (file: File) => {
539
+ const baseName = fileBaseName(file.name);
540
+ const key = slugifyDocumentKey(baseName);
541
+ const existing = (issue?.documentSummaries ?? []).find((doc) => doc.key === key) ?? null;
542
+ const body = await file.text();
543
+ const inferredTitle = titleizeFilename(baseName);
544
+ const nextTitle = existing?.title ?? inferredTitle ?? null;
545
+ return issuesApi.upsertDocument(issueId!, key, {
546
+ title: key === "plan" ? null : nextTitle,
547
+ format: "markdown",
548
+ body,
549
+ baseRevisionId: existing?.latestRevisionId ?? null,
550
+ });
551
+ },
552
+ onSuccess: () => {
553
+ setAttachmentError(null);
554
+ invalidateIssue();
555
+ },
556
+ onError: (err) => {
557
+ setAttachmentError(err instanceof Error ? err.message : "Document import failed");
558
+ },
559
+ });
560
+
561
+ const deleteAttachment = useMutation({
562
+ mutationFn: (attachmentId: string) => issuesApi.deleteAttachment(attachmentId),
563
+ onSuccess: () => {
564
+ setAttachmentError(null);
565
+ queryClient.invalidateQueries({ queryKey: queryKeys.issues.attachments(issueId!) });
566
+ invalidateIssue();
567
+ },
568
+ onError: (err) => {
569
+ setAttachmentError(err instanceof Error ? err.message : "Delete failed");
570
+ },
571
+ });
572
+
573
+ useEffect(() => {
574
+ const titleLabel = issue?.title ?? issueId ?? "Issue";
575
+ setBreadcrumbs([
576
+ sourceBreadcrumb,
577
+ { label: hasLiveRuns ? `🔵 ${titleLabel}` : titleLabel },
578
+ ]);
579
+ }, [setBreadcrumbs, sourceBreadcrumb, issue, issueId, hasLiveRuns]);
580
+
581
+ // Redirect to identifier-based URL if navigated via UUID
582
+ useEffect(() => {
583
+ if (issue?.identifier && issueId !== issue.identifier) {
584
+ navigate(`/issues/${issue.identifier}`, { replace: true, state: location.state });
585
+ }
586
+ }, [issue, issueId, navigate, location.state]);
587
+
588
+ useEffect(() => {
589
+ if (!issue?.id) return;
590
+ if (lastMarkedReadIssueIdRef.current === issue.id) return;
591
+ lastMarkedReadIssueIdRef.current = issue.id;
592
+ markIssueRead.mutate(issue.id);
593
+ }, [issue?.id]); // eslint-disable-line react-hooks/exhaustive-deps
594
+
595
+ useEffect(() => {
596
+ if (issue) {
597
+ openPanel(
598
+ <IssueProperties issue={issue} onUpdate={(data) => updateIssue.mutate(data)} />
599
+ );
600
+ }
601
+ return () => closePanel();
602
+ }, [issue]); // eslint-disable-line react-hooks/exhaustive-deps
603
+
604
+ const copyIssueToClipboard = async () => {
605
+ if (!issue) return;
606
+ const decodeEntities = (text: string) => {
607
+ const el = document.createElement("textarea");
608
+ el.innerHTML = text;
609
+ return el.value;
610
+ };
611
+ const title = decodeEntities(issue.title);
612
+ const body = decodeEntities(issue.description ?? "");
613
+ const md = `# ${issue.identifier}: ${title}\n\n${body}`.trimEnd();
614
+ await navigator.clipboard.writeText(md);
615
+ setCopied(true);
616
+ pushToast({ title: "Copied to clipboard", tone: "success" });
617
+ setTimeout(() => setCopied(false), 2000);
618
+ };
619
+
620
+ if (isLoading) return <p className="text-sm text-muted-foreground">Loading...</p>;
621
+ if (error) return <p className="text-sm text-destructive">{error.message}</p>;
622
+ if (!issue) return null;
623
+
624
+ // Ancestors are returned oldest-first from the server (root at end, immediate parent at start)
625
+ const ancestors = issue.ancestors ?? [];
626
+ const handleFilePicked = async (evt: ChangeEvent<HTMLInputElement>) => {
627
+ const files = evt.target.files;
628
+ if (!files || files.length === 0) return;
629
+ for (const file of Array.from(files)) {
630
+ if (isMarkdownFile(file)) {
631
+ await importMarkdownDocument.mutateAsync(file);
632
+ } else {
633
+ await uploadAttachment.mutateAsync(file);
634
+ }
635
+ }
636
+ if (fileInputRef.current) {
637
+ fileInputRef.current.value = "";
638
+ }
639
+ };
640
+
641
+ const handleAttachmentDrop = async (evt: DragEvent<HTMLDivElement>) => {
642
+ evt.preventDefault();
643
+ setAttachmentDragActive(false);
644
+ const files = evt.dataTransfer.files;
645
+ if (!files || files.length === 0) return;
646
+ for (const file of Array.from(files)) {
647
+ if (isMarkdownFile(file)) {
648
+ await importMarkdownDocument.mutateAsync(file);
649
+ } else {
650
+ await uploadAttachment.mutateAsync(file);
651
+ }
652
+ }
653
+ };
654
+
655
+ const isImageAttachment = (attachment: IssueAttachment) => attachment.contentType.startsWith("image/");
656
+ const attachmentList = attachments ?? [];
657
+ const hasAttachments = attachmentList.length > 0;
658
+ const attachmentUploadButton = (
659
+ <>
660
+ <input
661
+ ref={fileInputRef}
662
+ type="file"
663
+ accept="image/*,application/pdf,text/plain,text/markdown,application/json,text/csv,text/html,.md,.markdown"
664
+ className="hidden"
665
+ onChange={handleFilePicked}
666
+ multiple
667
+ />
668
+ <Button
669
+ variant="outline"
670
+ size="sm"
671
+ onClick={() => fileInputRef.current?.click()}
672
+ disabled={uploadAttachment.isPending || importMarkdownDocument.isPending}
673
+ className={cn(
674
+ "shadow-none",
675
+ attachmentDragActive && "border-primary bg-primary/5",
676
+ )}
677
+ >
678
+ <Paperclip className="h-3.5 w-3.5 mr-1.5" />
679
+ {uploadAttachment.isPending || importMarkdownDocument.isPending ? "Uploading..." : (
680
+ <>
681
+ <span className="hidden sm:inline">Upload attachment</span>
682
+ <span className="sm:hidden">Upload</span>
683
+ </>
684
+ )}
685
+ </Button>
686
+ </>
687
+ );
688
+
689
+ return (
690
+ <div className="max-w-2xl space-y-6">
691
+ {/* Parent chain breadcrumb */}
692
+ {ancestors.length > 0 && (
693
+ <nav className="flex items-center gap-1 text-xs text-muted-foreground flex-wrap">
694
+ {[...ancestors].reverse().map((ancestor, i) => (
695
+ <span key={ancestor.id} className="flex items-center gap-1">
696
+ {i > 0 && <ChevronRight className="h-3 w-3 shrink-0" />}
697
+ <Link
698
+ to={`/issues/${ancestor.identifier ?? ancestor.id}`}
699
+ state={location.state}
700
+ className="hover:text-foreground transition-colors truncate max-w-[200px]"
701
+ title={ancestor.title}
702
+ >
703
+ {ancestor.title}
704
+ </Link>
705
+ </span>
706
+ ))}
707
+ <ChevronRight className="h-3 w-3 shrink-0" />
708
+ <span className="text-foreground/60 truncate max-w-[200px]">{issue.title}</span>
709
+ </nav>
710
+ )}
711
+
712
+ {issue.hiddenAt && (
713
+ <div className="flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">
714
+ <EyeOff className="h-4 w-4 shrink-0" />
715
+ This issue is hidden
716
+ </div>
717
+ )}
718
+
719
+ <div className="space-y-3">
720
+ <div className="flex items-center gap-2 min-w-0 flex-wrap">
721
+ <StatusIcon
722
+ status={issue.status}
723
+ onChange={(status) => updateIssue.mutate({ status })}
724
+ />
725
+ <PriorityIcon
726
+ priority={issue.priority}
727
+ onChange={(priority) => updateIssue.mutate({ priority })}
728
+ />
729
+ <span className="text-sm font-mono text-muted-foreground shrink-0">{issue.identifier ?? issue.id.slice(0, 8)}</span>
730
+
731
+ {hasLiveRuns && (
732
+ <span className="inline-flex items-center gap-1.5 rounded-full bg-cyan-500/10 border border-cyan-500/30 px-2 py-0.5 text-[10px] font-medium text-cyan-600 dark:text-cyan-400 shrink-0">
733
+ <span className="relative flex h-1.5 w-1.5">
734
+ <span className="animate-pulse absolute inline-flex h-full w-full rounded-full bg-cyan-400 opacity-75" />
735
+ <span className="relative inline-flex rounded-full h-1.5 w-1.5 bg-cyan-400" />
736
+ </span>
737
+ Live
738
+ </span>
739
+ )}
740
+
741
+ {issue.originKind === "routine_execution" && issue.originId && (
742
+ <Link
743
+ to={`/routines/${issue.originId}`}
744
+ className="inline-flex items-center gap-1 rounded-full bg-violet-500/10 border border-violet-500/30 px-2 py-0.5 text-[10px] font-medium text-violet-600 dark:text-violet-400 shrink-0 hover:bg-violet-500/20 transition-colors"
745
+ >
746
+ <Repeat className="h-3 w-3" />
747
+ Routine
748
+ </Link>
749
+ )}
750
+
751
+ {issue.projectId ? (
752
+ <Link
753
+ to={`/projects/${issue.projectId}`}
754
+ className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors rounded px-1 -mx-1 py-0.5 min-w-0"
755
+ >
756
+ <Hexagon className="h-3 w-3 shrink-0" />
757
+ <span className="truncate">{(projects ?? []).find((p) => p.id === issue.projectId)?.name ?? issue.projectId.slice(0, 8)}</span>
758
+ </Link>
759
+ ) : (
760
+ <span className="inline-flex items-center gap-1 text-xs text-muted-foreground opacity-50 px-1 -mx-1 py-0.5">
761
+ <Hexagon className="h-3 w-3 shrink-0" />
762
+ No project
763
+ </span>
764
+ )}
765
+
766
+ {(issue.labels ?? []).length > 0 && (
767
+ <div className="hidden sm:flex items-center gap-1">
768
+ {(issue.labels ?? []).slice(0, 4).map((label) => (
769
+ <span
770
+ key={label.id}
771
+ className="inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-medium"
772
+ style={{
773
+ borderColor: label.color,
774
+ color: pickTextColorForPillBg(label.color, 0.12),
775
+ backgroundColor: `${label.color}1f`,
776
+ }}
777
+ >
778
+ {label.name}
779
+ </span>
780
+ ))}
781
+ {(issue.labels ?? []).length > 4 && (
782
+ <span className="text-[10px] text-muted-foreground">+{(issue.labels ?? []).length - 4}</span>
783
+ )}
784
+ </div>
785
+ )}
786
+
787
+ <div className="ml-auto flex items-center gap-0.5 md:hidden shrink-0">
788
+ <Button
789
+ variant="ghost"
790
+ size="icon-xs"
791
+ onClick={copyIssueToClipboard}
792
+ title="Copy issue as markdown"
793
+ >
794
+ {copied ? <Check className="h-4 w-4 text-green-500" /> : <Copy className="h-4 w-4" />}
795
+ </Button>
796
+ <Button
797
+ variant="ghost"
798
+ size="icon-xs"
799
+ onClick={() => setMobilePropsOpen(true)}
800
+ title="Properties"
801
+ >
802
+ <SlidersHorizontal className="h-4 w-4" />
803
+ </Button>
804
+ </div>
805
+
806
+ <div className="hidden md:flex items-center md:ml-auto shrink-0">
807
+ <Button
808
+ variant="ghost"
809
+ size="icon-xs"
810
+ onClick={copyIssueToClipboard}
811
+ title="Copy issue as markdown"
812
+ >
813
+ {copied ? <Check className="h-4 w-4 text-green-500" /> : <Copy className="h-4 w-4" />}
814
+ </Button>
815
+ <Button
816
+ variant="ghost"
817
+ size="icon-xs"
818
+ className={cn(
819
+ "shrink-0 transition-opacity duration-200",
820
+ panelVisible ? "opacity-0 pointer-events-none w-0 overflow-hidden" : "opacity-100",
821
+ )}
822
+ onClick={() => setPanelVisible(true)}
823
+ title="Show properties"
824
+ >
825
+ <SlidersHorizontal className="h-4 w-4" />
826
+ </Button>
827
+
828
+ <Popover open={moreOpen} onOpenChange={setMoreOpen}>
829
+ <PopoverTrigger asChild>
830
+ <Button variant="ghost" size="icon-xs" className="shrink-0">
831
+ <MoreHorizontal className="h-4 w-4" />
832
+ </Button>
833
+ </PopoverTrigger>
834
+ <PopoverContent className="w-44 p-1" align="end">
835
+ <button
836
+ className="flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-destructive"
837
+ onClick={() => {
838
+ updateIssue.mutate(
839
+ { hiddenAt: new Date().toISOString() },
840
+ { onSuccess: () => navigate("/issues/all") },
841
+ );
842
+ setMoreOpen(false);
843
+ }}
844
+ >
845
+ <EyeOff className="h-3 w-3" />
846
+ Hide this Issue
847
+ </button>
848
+ </PopoverContent>
849
+ </Popover>
850
+ </div>
851
+ </div>
852
+
853
+ <InlineEditor
854
+ value={issue.title}
855
+ onSave={(title) => updateIssue.mutateAsync({ title })}
856
+ as="h2"
857
+ className="text-xl font-bold"
858
+ />
859
+
860
+ <InlineEditor
861
+ value={issue.description ?? ""}
862
+ onSave={(description) => updateIssue.mutateAsync({ description })}
863
+ as="p"
864
+ className="text-[15px] leading-7 text-foreground"
865
+ placeholder="Add a description..."
866
+ multiline
867
+ mentions={mentionOptions}
868
+ imageUploadHandler={async (file) => {
869
+ const attachment = await uploadAttachment.mutateAsync(file);
870
+ return attachment.contentPath;
871
+ }}
872
+ />
873
+ </div>
874
+
875
+ <PluginSlotOutlet
876
+ slotTypes={["toolbarButton", "contextMenuItem"]}
877
+ entityType="issue"
878
+ context={{
879
+ companyId: issue.companyId,
880
+ projectId: issue.projectId ?? null,
881
+ entityId: issue.id,
882
+ entityType: "issue",
883
+ }}
884
+ className="flex flex-wrap gap-2"
885
+ itemClassName="inline-flex"
886
+ missingBehavior="placeholder"
887
+ />
888
+
889
+ <PluginLauncherOutlet
890
+ placementZones={["toolbarButton"]}
891
+ entityType="issue"
892
+ context={{
893
+ companyId: issue.companyId,
894
+ projectId: issue.projectId ?? null,
895
+ entityId: issue.id,
896
+ entityType: "issue",
897
+ }}
898
+ className="flex flex-wrap gap-2"
899
+ itemClassName="inline-flex"
900
+ />
901
+
902
+ <PluginSlotOutlet
903
+ slotTypes={["taskDetailView"]}
904
+ entityType="issue"
905
+ context={{
906
+ companyId: issue.companyId,
907
+ projectId: issue.projectId ?? null,
908
+ entityId: issue.id,
909
+ entityType: "issue",
910
+ }}
911
+ className="space-y-3"
912
+ itemClassName="rounded-lg border border-border p-3"
913
+ missingBehavior="placeholder"
914
+ />
915
+
916
+ <IssueDocumentsSection
917
+ issue={issue}
918
+ canDeleteDocuments={Boolean(session?.user?.id)}
919
+ mentions={mentionOptions}
920
+ imageUploadHandler={async (file) => {
921
+ const attachment = await uploadAttachment.mutateAsync(file);
922
+ return attachment.contentPath;
923
+ }}
924
+ extraActions={!hasAttachments ? attachmentUploadButton : undefined}
925
+ />
926
+
927
+ {hasAttachments ? (
928
+ <div
929
+ className={cn(
930
+ "space-y-3 rounded-lg transition-colors",
931
+ )}
932
+ onDragEnter={(evt) => {
933
+ evt.preventDefault();
934
+ setAttachmentDragActive(true);
935
+ }}
936
+ onDragOver={(evt) => {
937
+ evt.preventDefault();
938
+ setAttachmentDragActive(true);
939
+ }}
940
+ onDragLeave={(evt) => {
941
+ if (evt.currentTarget.contains(evt.relatedTarget as Node | null)) return;
942
+ setAttachmentDragActive(false);
943
+ }}
944
+ onDrop={(evt) => void handleAttachmentDrop(evt)}
945
+ >
946
+ <div className="flex items-center justify-between gap-2">
947
+ <h3 className="text-sm font-medium text-muted-foreground">Attachments</h3>
948
+ {attachmentUploadButton}
949
+ </div>
950
+
951
+ {attachmentError && (
952
+ <p className="text-xs text-destructive">{attachmentError}</p>
953
+ )}
954
+
955
+ <div className="space-y-2">
956
+ {attachmentList.map((attachment) => (
957
+ <div key={attachment.id} className="border border-border rounded-md p-2">
958
+ <div className="flex items-center justify-between gap-2">
959
+ <a
960
+ href={attachment.contentPath}
961
+ target="_blank"
962
+ rel="noreferrer"
963
+ className="text-xs hover:underline truncate"
964
+ title={attachment.originalFilename ?? attachment.id}
965
+ >
966
+ {attachment.originalFilename ?? attachment.id}
967
+ </a>
968
+ <button
969
+ type="button"
970
+ className="text-muted-foreground hover:text-destructive"
971
+ onClick={() => deleteAttachment.mutate(attachment.id)}
972
+ disabled={deleteAttachment.isPending}
973
+ title="Delete attachment"
974
+ >
975
+ <Trash2 className="h-3.5 w-3.5" />
976
+ </button>
977
+ </div>
978
+ <p className="text-[11px] text-muted-foreground">
979
+ {attachment.contentType} · {(attachment.byteSize / 1024).toFixed(1)} KB
980
+ </p>
981
+ {isImageAttachment(attachment) && (
982
+ <a href={attachment.contentPath} target="_blank" rel="noreferrer">
983
+ <img
984
+ src={attachment.contentPath}
985
+ alt={attachment.originalFilename ?? "attachment"}
986
+ className="mt-2 max-h-56 rounded border border-border object-contain bg-accent/10"
987
+ loading="lazy"
988
+ />
989
+ </a>
990
+ )}
991
+ </div>
992
+ ))}
993
+ </div>
994
+ </div>
995
+ ) : null}
996
+
997
+ <IssueWorkspaceCard
998
+ issue={issue}
999
+ project={orderedProjects.find((p) => p.id === issue.projectId) ?? null}
1000
+ onUpdate={(data) => updateIssue.mutate(data)}
1001
+ />
1002
+
1003
+ <Separator />
1004
+
1005
+ <Tabs value={detailTab} onValueChange={setDetailTab} className="space-y-3">
1006
+ <TabsList variant="line" className="w-full justify-start gap-1">
1007
+ <TabsTrigger value="comments" className="gap-1.5">
1008
+ <MessageSquare className="h-3.5 w-3.5" />
1009
+ Comments
1010
+ </TabsTrigger>
1011
+ <TabsTrigger value="subissues" className="gap-1.5">
1012
+ <ListTree className="h-3.5 w-3.5" />
1013
+ Sub-issues
1014
+ </TabsTrigger>
1015
+ <TabsTrigger value="activity" className="gap-1.5">
1016
+ <ActivityIcon className="h-3.5 w-3.5" />
1017
+ Activity
1018
+ </TabsTrigger>
1019
+ {issuePluginTabItems.map((item) => (
1020
+ <TabsTrigger key={item.value} value={item.value}>
1021
+ {item.label}
1022
+ </TabsTrigger>
1023
+ ))}
1024
+ </TabsList>
1025
+
1026
+ <TabsContent value="comments">
1027
+ <CommentThread
1028
+ comments={commentsWithRunMeta}
1029
+ linkedRuns={timelineRuns}
1030
+ companyId={issue.companyId}
1031
+ projectId={issue.projectId}
1032
+ issueStatus={issue.status}
1033
+ agentMap={agentMap}
1034
+ draftKey={`paperclip:issue-comment-draft:${issue.id}`}
1035
+ enableReassign
1036
+ reassignOptions={commentReassignOptions}
1037
+ currentAssigneeValue={actualAssigneeValue}
1038
+ suggestedAssigneeValue={suggestedAssigneeValue}
1039
+ mentions={mentionOptions}
1040
+ onAdd={async (body, reopen, reassignment) => {
1041
+ if (reassignment) {
1042
+ await addCommentAndReassign.mutateAsync({ body, reopen, reassignment });
1043
+ return;
1044
+ }
1045
+ await addComment.mutateAsync({ body, reopen });
1046
+ }}
1047
+ imageUploadHandler={async (file) => {
1048
+ const attachment = await uploadAttachment.mutateAsync(file);
1049
+ return attachment.contentPath;
1050
+ }}
1051
+ onAttachImage={async (file) => {
1052
+ await uploadAttachment.mutateAsync(file);
1053
+ }}
1054
+ liveRunSlot={<LiveRunWidget issueId={issueId!} companyId={issue.companyId} />}
1055
+ />
1056
+ </TabsContent>
1057
+
1058
+ <TabsContent value="subissues">
1059
+ {childIssues.length === 0 ? (
1060
+ <p className="text-xs text-muted-foreground">No sub-issues.</p>
1061
+ ) : (
1062
+ <div className="border border-border rounded-lg divide-y divide-border">
1063
+ {childIssues.map((child) => (
1064
+ <Link
1065
+ key={child.id}
1066
+ to={`/issues/${child.identifier ?? child.id}`}
1067
+ state={location.state}
1068
+ className="flex items-center justify-between px-3 py-2 text-sm hover:bg-accent/20 transition-colors"
1069
+ >
1070
+ <div className="flex items-center gap-2 min-w-0">
1071
+ <StatusIcon status={child.status} />
1072
+ <PriorityIcon priority={child.priority} />
1073
+ <span className="font-mono text-muted-foreground shrink-0">
1074
+ {child.identifier ?? child.id.slice(0, 8)}
1075
+ </span>
1076
+ <span className="truncate">{child.title}</span>
1077
+ </div>
1078
+ {child.assigneeAgentId && (() => {
1079
+ const name = agentMap.get(child.assigneeAgentId)?.name;
1080
+ return name
1081
+ ? <Identity name={name} size="sm" />
1082
+ : <span className="text-muted-foreground font-mono">{child.assigneeAgentId.slice(0, 8)}</span>;
1083
+ })()}
1084
+ </Link>
1085
+ ))}
1086
+ </div>
1087
+ )}
1088
+ </TabsContent>
1089
+
1090
+ <TabsContent value="activity">
1091
+ {linkedRuns && linkedRuns.length > 0 && (
1092
+ <div className="mb-3 px-3 py-2 rounded-lg border border-border">
1093
+ <div className="text-sm font-medium text-muted-foreground mb-1">Cost Summary</div>
1094
+ {!issueCostSummary.hasCost && !issueCostSummary.hasTokens ? (
1095
+ <div className="text-xs text-muted-foreground">No cost data yet.</div>
1096
+ ) : (
1097
+ <div className="flex flex-wrap gap-3 text-xs text-muted-foreground tabular-nums">
1098
+ {issueCostSummary.hasCost && (
1099
+ <span className="font-medium text-foreground">
1100
+ ${issueCostSummary.cost.toFixed(4)}
1101
+ </span>
1102
+ )}
1103
+ {issueCostSummary.hasTokens && (
1104
+ <span>
1105
+ Tokens {formatTokens(issueCostSummary.totalTokens)}
1106
+ {issueCostSummary.cached > 0
1107
+ ? ` (in ${formatTokens(issueCostSummary.input)}, out ${formatTokens(issueCostSummary.output)}, cached ${formatTokens(issueCostSummary.cached)})`
1108
+ : ` (in ${formatTokens(issueCostSummary.input)}, out ${formatTokens(issueCostSummary.output)})`}
1109
+ </span>
1110
+ )}
1111
+ </div>
1112
+ )}
1113
+ </div>
1114
+ )}
1115
+ {!activity || activity.length === 0 ? (
1116
+ <p className="text-xs text-muted-foreground">No activity yet.</p>
1117
+ ) : (
1118
+ <div className="space-y-1.5">
1119
+ {activity.slice(0, 20).map((evt) => (
1120
+ <div key={evt.id} className="flex items-center gap-1.5 text-xs text-muted-foreground">
1121
+ <ActorIdentity evt={evt} agentMap={agentMap} />
1122
+ <span>{formatAction(evt.action, evt.details)}</span>
1123
+ <span className="ml-auto shrink-0">{relativeTime(evt.createdAt)}</span>
1124
+ </div>
1125
+ ))}
1126
+ </div>
1127
+ )}
1128
+ </TabsContent>
1129
+
1130
+ {activePluginTab && (
1131
+ <TabsContent value={activePluginTab.value}>
1132
+ <PluginSlotMount
1133
+ slot={activePluginTab.slot}
1134
+ context={{
1135
+ companyId: issue.companyId,
1136
+ projectId: issue.projectId ?? null,
1137
+ entityId: issue.id,
1138
+ entityType: "issue",
1139
+ }}
1140
+ missingBehavior="placeholder"
1141
+ />
1142
+ </TabsContent>
1143
+ )}
1144
+ </Tabs>
1145
+
1146
+ {linkedApprovals && linkedApprovals.length > 0 && (
1147
+ <Collapsible
1148
+ open={secondaryOpen.approvals}
1149
+ onOpenChange={(open) => setSecondaryOpen((prev) => ({ ...prev, approvals: open }))}
1150
+ className="rounded-lg border border-border"
1151
+ >
1152
+ <CollapsibleTrigger className="flex w-full items-center justify-between px-3 py-2 text-left">
1153
+ <span className="text-sm font-medium text-muted-foreground">
1154
+ Linked Approvals ({linkedApprovals.length})
1155
+ </span>
1156
+ <ChevronDown
1157
+ className={cn("h-4 w-4 text-muted-foreground transition-transform", secondaryOpen.approvals && "rotate-180")}
1158
+ />
1159
+ </CollapsibleTrigger>
1160
+ <CollapsibleContent>
1161
+ <div className="border-t border-border divide-y divide-border">
1162
+ {linkedApprovals.map((approval) => (
1163
+ <Link
1164
+ key={approval.id}
1165
+ to={`/approvals/${approval.id}`}
1166
+ className="flex items-center justify-between px-3 py-2 text-xs hover:bg-accent/20 transition-colors"
1167
+ >
1168
+ <div className="flex items-center gap-2">
1169
+ <StatusBadge status={approval.status} />
1170
+ <span className="font-medium">
1171
+ {approval.type.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase())}
1172
+ </span>
1173
+ <span className="font-mono text-muted-foreground">{approval.id.slice(0, 8)}</span>
1174
+ </div>
1175
+ <span className="text-muted-foreground">{relativeTime(approval.createdAt)}</span>
1176
+ </Link>
1177
+ ))}
1178
+ </div>
1179
+ </CollapsibleContent>
1180
+ </Collapsible>
1181
+ )}
1182
+
1183
+
1184
+ {/* Mobile properties drawer */}
1185
+ <Sheet open={mobilePropsOpen} onOpenChange={setMobilePropsOpen}>
1186
+ <SheetContent side="bottom" className="max-h-[85dvh] pb-[env(safe-area-inset-bottom)]">
1187
+ <SheetHeader>
1188
+ <SheetTitle className="text-sm">Properties</SheetTitle>
1189
+ </SheetHeader>
1190
+ <ScrollArea className="flex-1 overflow-y-auto">
1191
+ <div className="px-4 pb-4">
1192
+ <IssueProperties issue={issue} onUpdate={(data) => updateIssue.mutate(data)} inline />
1193
+ </div>
1194
+ </ScrollArea>
1195
+ </SheetContent>
1196
+ </Sheet>
1197
+ <ScrollToBottom />
1198
+ </div>
1199
+ );
1200
+ }
1201
+