@patodo/localapp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (527) hide show
  1. package/.localapp-artifact.json +2731 -0
  2. package/LICENSE +21 -0
  3. package/README.md +288 -0
  4. package/bin/localapp.mjs +34182 -0
  5. package/package.json +21 -0
  6. package/runtime/bootstrap/localapp-daemon-bootstrap.mjs +150 -0
  7. package/runtime/native/adapter-manifest.json +85 -0
  8. package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/Info.plist +21 -0
  9. package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/MacOS/LocalAppBridge +0 -0
  10. package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/Resources/localapp-native-ipc-client.mjs +940 -0
  11. package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/_CodeSignature/CodeResources +128 -0
  12. package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/Info.plist +21 -0
  13. package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/MacOS/LocalAppBridge +0 -0
  14. package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/Resources/localapp-native-ipc-client.mjs +940 -0
  15. package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/_CodeSignature/CodeResources +128 -0
  16. package/runtime/native/linux-x64/localapp-native-ipc-client.mjs +940 -0
  17. package/runtime/native/linux-x64/localapp-notifications +0 -0
  18. package/runtime/native/win32-x64/localapp-native-ipc-client.mjs +940 -0
  19. package/runtime/native/win32-x64/localapp-native.exe +0 -0
  20. package/runtime/server/.localapp-server-runtime.json +133 -0
  21. package/runtime/server/bin/server-cli.cjs +8343 -0
  22. package/runtime/server/bin/server.mjs +8 -0
  23. package/runtime/server/bin/worker.cjs +144339 -0
  24. package/runtime/server/node_modules/sql.js/dist/sql-wasm.js +185 -0
  25. package/runtime/server/node_modules/sql.js/dist/sql-wasm.wasm +0 -0
  26. package/runtime/server/node_modules/sql.js/package.json +58 -0
  27. package/runtime/server/package.json +11 -0
  28. package/runtime/server/runner/localapp-runner.mjs +324 -0
  29. package/runtime/server/web/404.html +1 -0
  30. package/runtime/server/web/_next/static/CqtRUQyhpQ2FmEc3vaVz3/_buildManifest.js +1 -0
  31. package/runtime/server/web/_next/static/CqtRUQyhpQ2FmEc3vaVz3/_ssgManifest.js +1 -0
  32. package/runtime/server/web/_next/static/chunks/184-184da63eba05808f.js +1 -0
  33. package/runtime/server/web/_next/static/chunks/265-a58973dbf631dc41.js +1 -0
  34. package/runtime/server/web/_next/static/chunks/308-d74213c6f5179bf0.js +1 -0
  35. package/runtime/server/web/_next/static/chunks/416-53d48ad9442eb7b2.js +1 -0
  36. package/runtime/server/web/_next/static/chunks/448-280e06e915001cb5.js +1 -0
  37. package/runtime/server/web/_next/static/chunks/66-6f6658280a10fbca.js +1 -0
  38. package/runtime/server/web/_next/static/chunks/740d80ee-6c0a9504f1fd46f8.js +1 -0
  39. package/runtime/server/web/_next/static/chunks/86-7105ac54171494a1.js +1 -0
  40. package/runtime/server/web/_next/static/chunks/900-743e38de13217291.js +1 -0
  41. package/runtime/server/web/_next/static/chunks/app/(dashboard)/inbox/page-32b885c019043e48.js +1 -0
  42. package/runtime/server/web/_next/static/chunks/app/(dashboard)/layout-4b3a212263712a5c.js +1 -0
  43. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/analytics/page-6af9adc14ccfa925.js +1 -0
  44. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/apps/[name]/settings/page-8b6f809eeccdbd22.js +1 -0
  45. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/apps/page-7f1ddf07889da248.js +1 -0
  46. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/dashboard/page-a25eb621fb18491d.js +1 -0
  47. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/device-actions/page-e6045823829567f7.js +1 -0
  48. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/device-notifications/page-377ed49cf55da81d.js +1 -0
  49. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/favorites/page-82f292daebf98a2f.js +1 -0
  50. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/groups/page-fe4ed80c7b11920f.js +1 -0
  51. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/info/page-d5d5075eec069ce3.js +1 -0
  52. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/keys/page-35ed01bf39a163b6.js +1 -0
  53. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/layout-5481d53aae3a0ce1.js +1 -0
  54. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/orgs/page-44c606ff2233f1a8.js +1 -0
  55. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/page-f2331bbbe09541aa.js +1 -0
  56. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/pages/page-6bf4e160a99411ce.js +1 -0
  57. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/peers/page-27041dd149601002.js +1 -0
  58. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/recent/page-f321688d374a8ff3.js +1 -0
  59. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/settings/page-64e724318dc3a584.js +1 -0
  60. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/studio/page-a2c0c34538ac62b3.js +1 -0
  61. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/subscriptions/page-57cdaafe12347e32.js +1 -0
  62. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/system/page-96d2e1f8c2fb22b0.js +1 -0
  63. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/tasks/page-bf16b78ed6749d78.js +1 -0
  64. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/users/page-c47d4524d2a156b8.js +1 -0
  65. package/runtime/server/web/_next/static/chunks/app/(dashboard)/page-f4641be7b88818a2.js +1 -0
  66. package/runtime/server/web/_next/static/chunks/app/_not-found/page-f4902e6b69eebd4c.js +1 -0
  67. package/runtime/server/web/_next/static/chunks/app/layout-5557bc90d966fded.js +1 -0
  68. package/runtime/server/web/_next/static/chunks/app/platform-shell/[userId]/[name]/page-da0d5e71857f33d1.js +1 -0
  69. package/runtime/server/web/_next/static/chunks/app/platform-shell-preview/page-52fa7e8c8b480934.js +1 -0
  70. package/runtime/server/web/_next/static/chunks/app/setup/page-9e29d6f66825a8f8.js +1 -0
  71. package/runtime/server/web/_next/static/chunks/framework-1c02a2e60068b586.js +1 -0
  72. package/runtime/server/web/_next/static/chunks/main-21ea4d4d10f4a256.js +1 -0
  73. package/runtime/server/web/_next/static/chunks/main-app-5b3c67453d8c5b99.js +1 -0
  74. package/runtime/server/web/_next/static/chunks/pages/_app-649f81c9fedecf29.js +1 -0
  75. package/runtime/server/web/_next/static/chunks/pages/_error-64e3bd84e2ecae08.js +1 -0
  76. package/runtime/server/web/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  77. package/runtime/server/web/_next/static/chunks/webpack-0bed2fdf6baa566e.js +1 -0
  78. package/runtime/server/web/_next/static/css/afdc0938fca59693.css +3 -0
  79. package/runtime/server/web/_next/static/media/013b72fa676f92e0-s.woff2 +0 -0
  80. package/runtime/server/web/_next/static/media/22a5144ee8d83bca-s.p.woff2 +0 -0
  81. package/runtime/server/web/_next/static/media/2b5b02fc7e511755-s.woff2 +0 -0
  82. package/runtime/server/web/_next/static/media/65f03d54ccadf4a8-s.woff2 +0 -0
  83. package/runtime/server/web/_next/static/media/7d4881bb7e1bf84d-s.p.woff2 +0 -0
  84. package/runtime/server/web/_next/static/media/9766a7e9e2e0ad5a-s.woff2 +0 -0
  85. package/runtime/server/web/_next/static/media/aa016aab0e6d1295-s.woff2 +0 -0
  86. package/runtime/server/web/_next/static/media/b66cf8e69499582a-s.woff2 +0 -0
  87. package/runtime/server/web/_next/static/media/b9408752a0c24fb9-s.woff2 +0 -0
  88. package/runtime/server/web/_next/static/media/e038a29029a234f2-s.woff2 +0 -0
  89. package/runtime/server/web/_next/static/media/f639721981034f88-s.woff2 +0 -0
  90. package/runtime/server/web/home/redline-launch-hero.png +0 -0
  91. package/runtime/server/web/inbox.html +1 -0
  92. package/runtime/server/web/inbox.txt +27 -0
  93. package/runtime/server/web/index.html +1 -0
  94. package/runtime/server/web/index.txt +27 -0
  95. package/runtime/server/web/my/analytics.html +1 -0
  96. package/runtime/server/web/my/analytics.txt +27 -0
  97. package/runtime/server/web/my/apps/placeholder/settings.html +1 -0
  98. package/runtime/server/web/my/apps/placeholder/settings.txt +24 -0
  99. package/runtime/server/web/my/apps.html +1 -0
  100. package/runtime/server/web/my/apps.txt +27 -0
  101. package/runtime/server/web/my/dashboard.html +1 -0
  102. package/runtime/server/web/my/dashboard.txt +27 -0
  103. package/runtime/server/web/my/device-actions.html +1 -0
  104. package/runtime/server/web/my/device-actions.txt +24 -0
  105. package/runtime/server/web/my/device-notifications.html +1 -0
  106. package/runtime/server/web/my/device-notifications.txt +24 -0
  107. package/runtime/server/web/my/favorites.html +1 -0
  108. package/runtime/server/web/my/favorites.txt +27 -0
  109. package/runtime/server/web/my/groups.html +1 -0
  110. package/runtime/server/web/my/groups.txt +27 -0
  111. package/runtime/server/web/my/info.html +1 -0
  112. package/runtime/server/web/my/info.txt +27 -0
  113. package/runtime/server/web/my/keys.html +1 -0
  114. package/runtime/server/web/my/keys.txt +27 -0
  115. package/runtime/server/web/my/orgs.html +1 -0
  116. package/runtime/server/web/my/orgs.txt +27 -0
  117. package/runtime/server/web/my/pages.html +1 -0
  118. package/runtime/server/web/my/pages.txt +27 -0
  119. package/runtime/server/web/my/peers.html +1 -0
  120. package/runtime/server/web/my/peers.txt +24 -0
  121. package/runtime/server/web/my/recent.html +1 -0
  122. package/runtime/server/web/my/recent.txt +27 -0
  123. package/runtime/server/web/my/settings.html +1 -0
  124. package/runtime/server/web/my/settings.txt +27 -0
  125. package/runtime/server/web/my/studio.html +1 -0
  126. package/runtime/server/web/my/studio.txt +24 -0
  127. package/runtime/server/web/my/subscriptions.html +1 -0
  128. package/runtime/server/web/my/subscriptions.txt +27 -0
  129. package/runtime/server/web/my/system.html +1 -0
  130. package/runtime/server/web/my/system.txt +24 -0
  131. package/runtime/server/web/my/tasks.html +1 -0
  132. package/runtime/server/web/my/tasks.txt +24 -0
  133. package/runtime/server/web/my/users.html +1 -0
  134. package/runtime/server/web/my/users.txt +27 -0
  135. package/runtime/server/web/my.html +1 -0
  136. package/runtime/server/web/my.txt +27 -0
  137. package/runtime/server/web/platform-shell/placeholder/placeholder.html +1 -0
  138. package/runtime/server/web/platform-shell/placeholder/placeholder.txt +23 -0
  139. package/runtime/server/web/platform-shell-preview.html +1 -0
  140. package/runtime/server/web/platform-shell-preview.txt +23 -0
  141. package/runtime/server/web/setup.html +1 -0
  142. package/runtime/server/web/setup.txt +23 -0
  143. package/template/.claude/skills/agent-tool-patterns/SKILL.md +195 -0
  144. package/template/.claude/skills/localapp/SKILL.md +80 -0
  145. package/template/.claude/skills/localapp-auth/SKILL.md +299 -0
  146. package/template/.claude/skills/localapp-business/SKILL.md +325 -0
  147. package/template/.claude/skills/localapp-data/SKILL.md +381 -0
  148. package/template/.claude/skills/localapp-device-actions/SKILL.md +60 -0
  149. package/template/.claude/skills/localapp-notify/SKILL.md +118 -0
  150. package/template/.claude/skills/localapp-transitions/SKILL.md +238 -0
  151. package/template/.claude/skills/localapp-ui/SKILL.md +67 -0
  152. package/template/.claude/skills/localapp-upload/SKILL.md +172 -0
  153. package/template/AGENTS.md +33 -0
  154. package/template/CLAUDE.md +117 -0
  155. package/template/ISSUES.md +32 -0
  156. package/template/backend/resources/work_items/mutations.json +83 -0
  157. package/template/backend/resources/work_items/queries.json +83 -0
  158. package/template/backend/resources/work_items/schema.json +31 -0
  159. package/template/backend/schemas/mutations.schema.json +15 -0
  160. package/template/backend/schemas/queries.schema.json +36 -0
  161. package/template/backend/schemas/resource-schema.schema.json +25 -0
  162. package/template/components.json +25 -0
  163. package/template/index.html +12 -0
  164. package/template/migrations/001_work_items.sql +6 -0
  165. package/template/package.json +70 -0
  166. package/template/postcss.config.js +5 -0
  167. package/template/runtime/dev-shell.tsx +6398 -0
  168. package/template/runtime/hooks/use-mobile.ts +19 -0
  169. package/template/runtime/issue-reference.ts +44 -0
  170. package/template/runtime/lib/utils.ts +6 -0
  171. package/template/runtime/package.json +14 -0
  172. package/template/runtime/platform-capabilities.json +109 -0
  173. package/template/runtime/sdk/agent/package.json +51 -0
  174. package/template/runtime/sdk/agent/src/agent-chat.tsx +188 -0
  175. package/template/runtime/sdk/agent/src/assistant-ui-adapter.ts +87 -0
  176. package/template/runtime/sdk/agent/src/context.ts +56 -0
  177. package/template/runtime/sdk/agent/src/dev-bridge.ts +21 -0
  178. package/template/runtime/sdk/agent/src/index.ts +19 -0
  179. package/template/runtime/sdk/agent/src/llm-adapter.ts +263 -0
  180. package/template/runtime/sdk/agent/src/native-registry.ts +61 -0
  181. package/template/runtime/sdk/agent/src/platform-runtime.ts +164 -0
  182. package/template/runtime/sdk/agent/src/postmessage-bridge.ts +60 -0
  183. package/template/runtime/sdk/agent/src/postmessage-types.ts +150 -0
  184. package/template/runtime/sdk/agent/src/tools.ts +70 -0
  185. package/template/runtime/sdk/agent/src/types.ts +27 -0
  186. package/template/runtime/sdk/agent/src/use-agent.ts +139 -0
  187. package/template/runtime/sdk/agent/src/use-register-edit-session.ts +54 -0
  188. package/template/runtime/sdk/agent/src/use-register-tools.ts +92 -0
  189. package/template/runtime/sdk/agent/tests/platform-runtime.test.ts +154 -0
  190. package/template/runtime/sdk/agent/tests/postmessage-bridge.test.ts +119 -0
  191. package/template/runtime/sdk/agent/tests/shell-integration.test.ts +71 -0
  192. package/template/runtime/sdk/agent/tests/use-register-edit-session.test.tsx +125 -0
  193. package/template/runtime/sdk/agent/tests/use-register-tools.test.ts +208 -0
  194. package/template/runtime/sdk/agent/tsconfig.json +18 -0
  195. package/template/runtime/sdk/agent/vitest.config.ts +8 -0
  196. package/template/runtime/sdk/backend/package.json +15 -0
  197. package/template/runtime/sdk/backend/src/index.ts +92 -0
  198. package/template/runtime/sdk/backend/tsconfig.json +8 -0
  199. package/template/runtime/sdk/core/package.json +15 -0
  200. package/template/runtime/sdk/core/src/client.ts +317 -0
  201. package/template/runtime/sdk/core/src/collaboration.ts +66 -0
  202. package/template/runtime/sdk/core/src/desktop.ts +469 -0
  203. package/template/runtime/sdk/core/src/device.ts +112 -0
  204. package/template/runtime/sdk/core/src/index.ts +6 -0
  205. package/template/runtime/sdk/core/src/invalidate.ts +40 -0
  206. package/template/runtime/sdk/core/src/types.ts +108 -0
  207. package/template/runtime/sdk/core/tests/capabilities.test.ts +64 -0
  208. package/template/runtime/sdk/core/tests/client.test.ts +424 -0
  209. package/template/runtime/sdk/core/tests/collaboration.test.ts +92 -0
  210. package/template/runtime/sdk/core/tests/desktop.test.ts +310 -0
  211. package/template/runtime/sdk/core/tests/device.test.ts +69 -0
  212. package/template/runtime/sdk/core/tsconfig.json +17 -0
  213. package/template/runtime/sdk/react/package.json +34 -0
  214. package/template/runtime/sdk/react/src/client.ts +7 -0
  215. package/template/runtime/sdk/react/src/components/can.tsx +24 -0
  216. package/template/runtime/sdk/react/src/hooks/use-action.ts +34 -0
  217. package/template/runtime/sdk/react/src/hooks/use-capabilities.ts +35 -0
  218. package/template/runtime/sdk/react/src/hooks/use-count.ts +37 -0
  219. package/template/runtime/sdk/react/src/hooks/use-create.ts +37 -0
  220. package/template/runtime/sdk/react/src/hooks/use-delete.ts +36 -0
  221. package/template/runtime/sdk/react/src/hooks/use-desktop-action.ts +94 -0
  222. package/template/runtime/sdk/react/src/hooks/use-device-action.ts +62 -0
  223. package/template/runtime/sdk/react/src/hooks/use-get.ts +37 -0
  224. package/template/runtime/sdk/react/src/hooks/use-group-members.ts +31 -0
  225. package/template/runtime/sdk/react/src/hooks/use-groups.ts +31 -0
  226. package/template/runtime/sdk/react/src/hooks/use-list.ts +53 -0
  227. package/template/runtime/sdk/react/src/hooks/use-me.ts +35 -0
  228. package/template/runtime/sdk/react/src/hooks/use-mutation.ts +30 -0
  229. package/template/runtime/sdk/react/src/hooks/use-permissions.ts +37 -0
  230. package/template/runtime/sdk/react/src/hooks/use-platform-data.ts +94 -0
  231. package/template/runtime/sdk/react/src/hooks/use-query.ts +30 -0
  232. package/template/runtime/sdk/react/src/hooks/use-time.ts +36 -0
  233. package/template/runtime/sdk/react/src/hooks/use-transaction.ts +30 -0
  234. package/template/runtime/sdk/react/src/hooks/use-transitions.ts +82 -0
  235. package/template/runtime/sdk/react/src/hooks/use-update.ts +37 -0
  236. package/template/runtime/sdk/react/src/hooks/use-upload.ts +30 -0
  237. package/template/runtime/sdk/react/src/hooks/use-users.ts +31 -0
  238. package/template/runtime/sdk/react/src/index.ts +40 -0
  239. package/template/runtime/sdk/react/src/permissions.ts +94 -0
  240. package/template/runtime/sdk/react/tests/permissions.test.ts +176 -0
  241. package/template/runtime/sdk/react/tests/use-action.test.tsx +64 -0
  242. package/template/runtime/sdk/react/tests/use-capabilities.test.tsx +48 -0
  243. package/template/runtime/sdk/react/tests/use-desktop-action.test.tsx +144 -0
  244. package/template/runtime/sdk/react/tests/use-permissions.test.tsx +162 -0
  245. package/template/runtime/sdk/react/tests/use-platform-data.test.tsx +89 -0
  246. package/template/runtime/sdk/react/tests/use-transaction.test.tsx +65 -0
  247. package/template/runtime/sdk/react/tests/use-transitions.test.ts +149 -0
  248. package/template/runtime/sdk/react/tsconfig.json +18 -0
  249. package/template/runtime/sdk/react/vitest.config.ts +9 -0
  250. package/template/runtime/sdk/react/vitest.setup.ts +6 -0
  251. package/template/runtime/server-core/dist/generated/platform-capabilities.d.ts +84 -0
  252. package/template/runtime/server-core/dist/generated/platform-capabilities.d.ts.map +1 -0
  253. package/template/runtime/server-core/dist/generated/platform-capabilities.js +115 -0
  254. package/template/runtime/server-core/dist/generated/platform-capabilities.js.map +1 -0
  255. package/template/runtime/server-core/dist/index.d.ts +19 -0
  256. package/template/runtime/server-core/dist/index.d.ts.map +1 -0
  257. package/template/runtime/server-core/dist/index.js +35 -0
  258. package/template/runtime/server-core/dist/index.js.map +1 -0
  259. package/template/runtime/server-core/dist/lib/__tests__/action-runtime-hardening.test.d.ts +2 -0
  260. package/template/runtime/server-core/dist/lib/__tests__/action-runtime-hardening.test.d.ts.map +1 -0
  261. package/template/runtime/server-core/dist/lib/__tests__/action-runtime-hardening.test.js +475 -0
  262. package/template/runtime/server-core/dist/lib/__tests__/action-runtime-hardening.test.js.map +1 -0
  263. package/template/runtime/server-core/dist/lib/__tests__/app-api-contract.test.d.ts +2 -0
  264. package/template/runtime/server-core/dist/lib/__tests__/app-api-contract.test.d.ts.map +1 -0
  265. package/template/runtime/server-core/dist/lib/__tests__/app-api-contract.test.js +65 -0
  266. package/template/runtime/server-core/dist/lib/__tests__/app-api-contract.test.js.map +1 -0
  267. package/template/runtime/server-core/dist/lib/__tests__/app-runtime.test.d.ts +2 -0
  268. package/template/runtime/server-core/dist/lib/__tests__/app-runtime.test.d.ts.map +1 -0
  269. package/template/runtime/server-core/dist/lib/__tests__/app-runtime.test.js +103 -0
  270. package/template/runtime/server-core/dist/lib/__tests__/app-runtime.test.js.map +1 -0
  271. package/template/runtime/server-core/dist/lib/__tests__/backend-actions.test.d.ts +2 -0
  272. package/template/runtime/server-core/dist/lib/__tests__/backend-actions.test.d.ts.map +1 -0
  273. package/template/runtime/server-core/dist/lib/__tests__/backend-actions.test.js +358 -0
  274. package/template/runtime/server-core/dist/lib/__tests__/backend-actions.test.js.map +1 -0
  275. package/template/runtime/server-core/dist/lib/__tests__/backend-contract.test.d.ts +2 -0
  276. package/template/runtime/server-core/dist/lib/__tests__/backend-contract.test.d.ts.map +1 -0
  277. package/template/runtime/server-core/dist/lib/__tests__/backend-contract.test.js +786 -0
  278. package/template/runtime/server-core/dist/lib/__tests__/backend-contract.test.js.map +1 -0
  279. package/template/runtime/server-core/dist/lib/__tests__/content-capabilities.test.d.ts +2 -0
  280. package/template/runtime/server-core/dist/lib/__tests__/content-capabilities.test.d.ts.map +1 -0
  281. package/template/runtime/server-core/dist/lib/__tests__/content-capabilities.test.js +82 -0
  282. package/template/runtime/server-core/dist/lib/__tests__/content-capabilities.test.js.map +1 -0
  283. package/template/runtime/server-core/dist/lib/__tests__/database-write-guard.test.d.ts +2 -0
  284. package/template/runtime/server-core/dist/lib/__tests__/database-write-guard.test.d.ts.map +1 -0
  285. package/template/runtime/server-core/dist/lib/__tests__/database-write-guard.test.js +42 -0
  286. package/template/runtime/server-core/dist/lib/__tests__/database-write-guard.test.js.map +1 -0
  287. package/template/runtime/server-core/dist/lib/__tests__/issue-collaboration.test.d.ts +2 -0
  288. package/template/runtime/server-core/dist/lib/__tests__/issue-collaboration.test.d.ts.map +1 -0
  289. package/template/runtime/server-core/dist/lib/__tests__/issue-collaboration.test.js +144 -0
  290. package/template/runtime/server-core/dist/lib/__tests__/issue-collaboration.test.js.map +1 -0
  291. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-minimization.test.d.ts +2 -0
  292. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-minimization.test.d.ts.map +1 -0
  293. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-minimization.test.js +75 -0
  294. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-minimization.test.js.map +1 -0
  295. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-pins.test.d.ts +2 -0
  296. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-pins.test.d.ts.map +1 -0
  297. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-pins.test.js +85 -0
  298. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-pins.test.js.map +1 -0
  299. package/template/runtime/server-core/dist/lib/__tests__/issue-cross-references.test.d.ts +2 -0
  300. package/template/runtime/server-core/dist/lib/__tests__/issue-cross-references.test.d.ts.map +1 -0
  301. package/template/runtime/server-core/dist/lib/__tests__/issue-cross-references.test.js +75 -0
  302. package/template/runtime/server-core/dist/lib/__tests__/issue-cross-references.test.js.map +1 -0
  303. package/template/runtime/server-core/dist/lib/__tests__/issue-dependencies.test.d.ts +2 -0
  304. package/template/runtime/server-core/dist/lib/__tests__/issue-dependencies.test.d.ts.map +1 -0
  305. package/template/runtime/server-core/dist/lib/__tests__/issue-dependencies.test.js +78 -0
  306. package/template/runtime/server-core/dist/lib/__tests__/issue-dependencies.test.js.map +1 -0
  307. package/template/runtime/server-core/dist/lib/__tests__/issue-duplicates.test.d.ts +2 -0
  308. package/template/runtime/server-core/dist/lib/__tests__/issue-duplicates.test.d.ts.map +1 -0
  309. package/template/runtime/server-core/dist/lib/__tests__/issue-duplicates.test.js +66 -0
  310. package/template/runtime/server-core/dist/lib/__tests__/issue-duplicates.test.js.map +1 -0
  311. package/template/runtime/server-core/dist/lib/__tests__/issue-list.test.d.ts +2 -0
  312. package/template/runtime/server-core/dist/lib/__tests__/issue-list.test.d.ts.map +1 -0
  313. package/template/runtime/server-core/dist/lib/__tests__/issue-list.test.js +322 -0
  314. package/template/runtime/server-core/dist/lib/__tests__/issue-list.test.js.map +1 -0
  315. package/template/runtime/server-core/dist/lib/__tests__/issue-potential-duplicates.test.d.ts +2 -0
  316. package/template/runtime/server-core/dist/lib/__tests__/issue-potential-duplicates.test.d.ts.map +1 -0
  317. package/template/runtime/server-core/dist/lib/__tests__/issue-potential-duplicates.test.js +49 -0
  318. package/template/runtime/server-core/dist/lib/__tests__/issue-potential-duplicates.test.js.map +1 -0
  319. package/template/runtime/server-core/dist/lib/__tests__/issue-reactions.test.d.ts +2 -0
  320. package/template/runtime/server-core/dist/lib/__tests__/issue-reactions.test.d.ts.map +1 -0
  321. package/template/runtime/server-core/dist/lib/__tests__/issue-reactions.test.js +67 -0
  322. package/template/runtime/server-core/dist/lib/__tests__/issue-reactions.test.js.map +1 -0
  323. package/template/runtime/server-core/dist/lib/__tests__/issue-revisions.test.d.ts +2 -0
  324. package/template/runtime/server-core/dist/lib/__tests__/issue-revisions.test.d.ts.map +1 -0
  325. package/template/runtime/server-core/dist/lib/__tests__/issue-revisions.test.js +91 -0
  326. package/template/runtime/server-core/dist/lib/__tests__/issue-revisions.test.js.map +1 -0
  327. package/template/runtime/server-core/dist/lib/__tests__/issue-saved-views.test.d.ts +2 -0
  328. package/template/runtime/server-core/dist/lib/__tests__/issue-saved-views.test.d.ts.map +1 -0
  329. package/template/runtime/server-core/dist/lib/__tests__/issue-saved-views.test.js +69 -0
  330. package/template/runtime/server-core/dist/lib/__tests__/issue-saved-views.test.js.map +1 -0
  331. package/template/runtime/server-core/dist/lib/__tests__/issue-sub-issues.test.d.ts +2 -0
  332. package/template/runtime/server-core/dist/lib/__tests__/issue-sub-issues.test.d.ts.map +1 -0
  333. package/template/runtime/server-core/dist/lib/__tests__/issue-sub-issues.test.js +159 -0
  334. package/template/runtime/server-core/dist/lib/__tests__/issue-sub-issues.test.js.map +1 -0
  335. package/template/runtime/server-core/dist/lib/__tests__/issue-task-conversion.test.d.ts +2 -0
  336. package/template/runtime/server-core/dist/lib/__tests__/issue-task-conversion.test.d.ts.map +1 -0
  337. package/template/runtime/server-core/dist/lib/__tests__/issue-task-conversion.test.js +102 -0
  338. package/template/runtime/server-core/dist/lib/__tests__/issue-task-conversion.test.js.map +1 -0
  339. package/template/runtime/server-core/dist/lib/__tests__/issue-templates.test.d.ts +2 -0
  340. package/template/runtime/server-core/dist/lib/__tests__/issue-templates.test.d.ts.map +1 -0
  341. package/template/runtime/server-core/dist/lib/__tests__/issue-templates.test.js +65 -0
  342. package/template/runtime/server-core/dist/lib/__tests__/issue-templates.test.js.map +1 -0
  343. package/template/runtime/server-core/dist/lib/__tests__/issue-timeline.test.d.ts +2 -0
  344. package/template/runtime/server-core/dist/lib/__tests__/issue-timeline.test.d.ts.map +1 -0
  345. package/template/runtime/server-core/dist/lib/__tests__/issue-timeline.test.js +226 -0
  346. package/template/runtime/server-core/dist/lib/__tests__/issue-timeline.test.js.map +1 -0
  347. package/template/runtime/server-core/dist/lib/__tests__/issue-types.test.d.ts +2 -0
  348. package/template/runtime/server-core/dist/lib/__tests__/issue-types.test.d.ts.map +1 -0
  349. package/template/runtime/server-core/dist/lib/__tests__/issue-types.test.js +64 -0
  350. package/template/runtime/server-core/dist/lib/__tests__/issue-types.test.js.map +1 -0
  351. package/template/runtime/server-core/dist/lib/__tests__/migrations.test.d.ts +2 -0
  352. package/template/runtime/server-core/dist/lib/__tests__/migrations.test.d.ts.map +1 -0
  353. package/template/runtime/server-core/dist/lib/__tests__/migrations.test.js +101 -0
  354. package/template/runtime/server-core/dist/lib/__tests__/migrations.test.js.map +1 -0
  355. package/template/runtime/server-core/dist/lib/__tests__/platform-capabilities.test.d.ts +2 -0
  356. package/template/runtime/server-core/dist/lib/__tests__/platform-capabilities.test.d.ts.map +1 -0
  357. package/template/runtime/server-core/dist/lib/__tests__/platform-capabilities.test.js +69 -0
  358. package/template/runtime/server-core/dist/lib/__tests__/platform-capabilities.test.js.map +1 -0
  359. package/template/runtime/server-core/dist/lib/__tests__/transitions.test.d.ts +2 -0
  360. package/template/runtime/server-core/dist/lib/__tests__/transitions.test.d.ts.map +1 -0
  361. package/template/runtime/server-core/dist/lib/__tests__/transitions.test.js +32 -0
  362. package/template/runtime/server-core/dist/lib/__tests__/transitions.test.js.map +1 -0
  363. package/template/runtime/server-core/dist/lib/access-control.d.ts +34 -0
  364. package/template/runtime/server-core/dist/lib/access-control.d.ts.map +1 -0
  365. package/template/runtime/server-core/dist/lib/access-control.js +138 -0
  366. package/template/runtime/server-core/dist/lib/access-control.js.map +1 -0
  367. package/template/runtime/server-core/dist/lib/app-api-contract.d.ts +69 -0
  368. package/template/runtime/server-core/dist/lib/app-api-contract.d.ts.map +1 -0
  369. package/template/runtime/server-core/dist/lib/app-api-contract.js +57 -0
  370. package/template/runtime/server-core/dist/lib/app-api-contract.js.map +1 -0
  371. package/template/runtime/server-core/dist/lib/app-db.d.ts +486 -0
  372. package/template/runtime/server-core/dist/lib/app-db.d.ts.map +1 -0
  373. package/template/runtime/server-core/dist/lib/app-db.js +2581 -0
  374. package/template/runtime/server-core/dist/lib/app-db.js.map +1 -0
  375. package/template/runtime/server-core/dist/lib/app-runtime.d.ts +28 -0
  376. package/template/runtime/server-core/dist/lib/app-runtime.d.ts.map +1 -0
  377. package/template/runtime/server-core/dist/lib/app-runtime.js +56 -0
  378. package/template/runtime/server-core/dist/lib/app-runtime.js.map +1 -0
  379. package/template/runtime/server-core/dist/lib/backend-actions.d.ts +149 -0
  380. package/template/runtime/server-core/dist/lib/backend-actions.d.ts.map +1 -0
  381. package/template/runtime/server-core/dist/lib/backend-actions.js +926 -0
  382. package/template/runtime/server-core/dist/lib/backend-actions.js.map +1 -0
  383. package/template/runtime/server-core/dist/lib/backend-contract.d.ts +399 -0
  384. package/template/runtime/server-core/dist/lib/backend-contract.d.ts.map +1 -0
  385. package/template/runtime/server-core/dist/lib/backend-contract.js +1148 -0
  386. package/template/runtime/server-core/dist/lib/backend-contract.js.map +1 -0
  387. package/template/runtime/server-core/dist/lib/content-capabilities.d.ts +30 -0
  388. package/template/runtime/server-core/dist/lib/content-capabilities.d.ts.map +1 -0
  389. package/template/runtime/server-core/dist/lib/content-capabilities.js +133 -0
  390. package/template/runtime/server-core/dist/lib/content-capabilities.js.map +1 -0
  391. package/template/runtime/server-core/dist/lib/issue-saved-replies.d.ts +7 -0
  392. package/template/runtime/server-core/dist/lib/issue-saved-replies.d.ts.map +1 -0
  393. package/template/runtime/server-core/dist/lib/issue-saved-replies.js +22 -0
  394. package/template/runtime/server-core/dist/lib/issue-saved-replies.js.map +1 -0
  395. package/template/runtime/server-core/dist/lib/issue-saved-views.d.ts +43 -0
  396. package/template/runtime/server-core/dist/lib/issue-saved-views.d.ts.map +1 -0
  397. package/template/runtime/server-core/dist/lib/issue-saved-views.js +201 -0
  398. package/template/runtime/server-core/dist/lib/issue-saved-views.js.map +1 -0
  399. package/template/runtime/server-core/dist/lib/issue-task-conversion.d.ts +11 -0
  400. package/template/runtime/server-core/dist/lib/issue-task-conversion.d.ts.map +1 -0
  401. package/template/runtime/server-core/dist/lib/issue-task-conversion.js +66 -0
  402. package/template/runtime/server-core/dist/lib/issue-task-conversion.js.map +1 -0
  403. package/template/runtime/server-core/dist/lib/issue-templates.d.ts +16 -0
  404. package/template/runtime/server-core/dist/lib/issue-templates.d.ts.map +1 -0
  405. package/template/runtime/server-core/dist/lib/issue-templates.js +89 -0
  406. package/template/runtime/server-core/dist/lib/issue-templates.js.map +1 -0
  407. package/template/runtime/server-core/dist/lib/migrations.d.ts +31 -0
  408. package/template/runtime/server-core/dist/lib/migrations.d.ts.map +1 -0
  409. package/template/runtime/server-core/dist/lib/migrations.js +180 -0
  410. package/template/runtime/server-core/dist/lib/migrations.js.map +1 -0
  411. package/template/runtime/server-core/dist/lib/notify-permission-sql.d.ts +21 -0
  412. package/template/runtime/server-core/dist/lib/notify-permission-sql.d.ts.map +1 -0
  413. package/template/runtime/server-core/dist/lib/notify-permission-sql.js +71 -0
  414. package/template/runtime/server-core/dist/lib/notify-permission-sql.js.map +1 -0
  415. package/template/runtime/server-core/dist/lib/record-access.d.ts +34 -0
  416. package/template/runtime/server-core/dist/lib/record-access.d.ts.map +1 -0
  417. package/template/runtime/server-core/dist/lib/record-access.js +81 -0
  418. package/template/runtime/server-core/dist/lib/record-access.js.map +1 -0
  419. package/template/runtime/server-core/dist/lib/runtime-errors.d.ts +28 -0
  420. package/template/runtime/server-core/dist/lib/runtime-errors.d.ts.map +1 -0
  421. package/template/runtime/server-core/dist/lib/runtime-errors.js +67 -0
  422. package/template/runtime/server-core/dist/lib/runtime-errors.js.map +1 -0
  423. package/template/runtime/server-core/dist/lib/transitions.d.ts +55 -0
  424. package/template/runtime/server-core/dist/lib/transitions.d.ts.map +1 -0
  425. package/template/runtime/server-core/dist/lib/transitions.js +142 -0
  426. package/template/runtime/server-core/dist/lib/transitions.js.map +1 -0
  427. package/template/runtime/server-core/dist/types/models.d.ts +163 -0
  428. package/template/runtime/server-core/dist/types/models.d.ts.map +1 -0
  429. package/template/runtime/server-core/dist/types/models.js +3 -0
  430. package/template/runtime/server-core/dist/types/models.js.map +1 -0
  431. package/template/runtime/server-core/package.json +24 -0
  432. package/template/runtime/styles/preset.css +282 -0
  433. package/template/runtime/sync-template-command.cjs +19 -0
  434. package/template/runtime/sync-template.cjs +71 -0
  435. package/template/runtime/tsconfig.base.json +20 -0
  436. package/template/runtime/version.json +3 -0
  437. package/template/runtime/vite-plugin.mjs +309 -0
  438. package/template/src/App.tsx +273 -0
  439. package/template/src/components/ui/accordion.tsx +79 -0
  440. package/template/src/components/ui/alert-dialog.tsx +197 -0
  441. package/template/src/components/ui/alert.tsx +76 -0
  442. package/template/src/components/ui/aspect-ratio.tsx +11 -0
  443. package/template/src/components/ui/avatar.tsx +110 -0
  444. package/template/src/components/ui/badge.tsx +49 -0
  445. package/template/src/components/ui/breadcrumb.tsx +122 -0
  446. package/template/src/components/ui/button-group.tsx +83 -0
  447. package/template/src/components/ui/button.tsx +67 -0
  448. package/template/src/components/ui/calendar.tsx +221 -0
  449. package/template/src/components/ui/card.tsx +103 -0
  450. package/template/src/components/ui/carousel.tsx +240 -0
  451. package/template/src/components/ui/chart.tsx +373 -0
  452. package/template/src/components/ui/checkbox.tsx +31 -0
  453. package/template/src/components/ui/collapsible.tsx +33 -0
  454. package/template/src/components/ui/combobox.tsx +299 -0
  455. package/template/src/components/ui/command.tsx +193 -0
  456. package/template/src/components/ui/context-menu.tsx +261 -0
  457. package/template/src/components/ui/dialog.tsx +168 -0
  458. package/template/src/components/ui/direction.tsx +22 -0
  459. package/template/src/components/ui/drawer.tsx +132 -0
  460. package/template/src/components/ui/dropdown-menu.tsx +269 -0
  461. package/template/src/components/ui/empty.tsx +104 -0
  462. package/template/src/components/ui/field.tsx +238 -0
  463. package/template/src/components/ui/hover-card.tsx +42 -0
  464. package/template/src/components/ui/input-group.tsx +154 -0
  465. package/template/src/components/ui/input-otp.tsx +87 -0
  466. package/template/src/components/ui/input.tsx +19 -0
  467. package/template/src/components/ui/item.tsx +196 -0
  468. package/template/src/components/ui/kbd.tsx +26 -0
  469. package/template/src/components/ui/label.tsx +22 -0
  470. package/template/src/components/ui/menubar.tsx +280 -0
  471. package/template/src/components/ui/native-select.tsx +61 -0
  472. package/template/src/components/ui/navigation-menu.tsx +164 -0
  473. package/template/src/components/ui/pagination.tsx +129 -0
  474. package/template/src/components/ui/popover.tsx +87 -0
  475. package/template/src/components/ui/progress.tsx +31 -0
  476. package/template/src/components/ui/radio-group.tsx +42 -0
  477. package/template/src/components/ui/resizable.tsx +50 -0
  478. package/template/src/components/ui/scroll-area.tsx +53 -0
  479. package/template/src/components/ui/select.tsx +192 -0
  480. package/template/src/components/ui/separator.tsx +26 -0
  481. package/template/src/components/ui/sheet.tsx +145 -0
  482. package/template/src/components/ui/sidebar.tsx +700 -0
  483. package/template/src/components/ui/skeleton.tsx +13 -0
  484. package/template/src/components/ui/slider.tsx +59 -0
  485. package/template/src/components/ui/sonner.tsx +47 -0
  486. package/template/src/components/ui/spinner.tsx +10 -0
  487. package/template/src/components/ui/switch.tsx +33 -0
  488. package/template/src/components/ui/table.tsx +114 -0
  489. package/template/src/components/ui/tabs.tsx +90 -0
  490. package/template/src/components/ui/textarea.tsx +18 -0
  491. package/template/src/components/ui/toggle-group.tsx +89 -0
  492. package/template/src/components/ui/toggle.tsx +45 -0
  493. package/template/src/components/ui/tooltip.tsx +57 -0
  494. package/template/src/hooks/use-mobile.ts +3 -0
  495. package/template/src/index.css +4 -0
  496. package/template/src/lib/utils.ts +3 -0
  497. package/template/src/main.tsx +10 -0
  498. package/template/src/vite-env.d.ts +1 -0
  499. package/template/template.gitignore +10 -0
  500. package/template/template.npmrc +1 -0
  501. package/template/tests/agent-context.test.ts +69 -0
  502. package/template/tests/agent-guidance-template.test.ts +49 -0
  503. package/template/tests/agent-runtime.test.ts +198 -0
  504. package/template/tests/agent-tools.test.ts +150 -0
  505. package/template/tests/agent-use-agent.test.ts +86 -0
  506. package/template/tests/assistant-ui-adapter.test.ts +211 -0
  507. package/template/tests/business-modeling-template.test.ts +71 -0
  508. package/template/tests/client.test.ts +382 -0
  509. package/template/tests/dev-issue-search-suggestions.test.ts +36 -0
  510. package/template/tests/dev-shell-context.test.tsx +40 -0
  511. package/template/tests/dev-shell-template.test.ts +2593 -0
  512. package/template/tests/invalidation.test.ts +126 -0
  513. package/template/tests/main-tsx.test.ts +28 -0
  514. package/template/tests/media-preview-template.test.ts +21 -0
  515. package/template/tests/mutations.test.ts +224 -0
  516. package/template/tests/react.test.ts +302 -0
  517. package/template/tests/redirect.test.ts +51 -0
  518. package/template/tests/skill-docs.test.ts +76 -0
  519. package/template/tests/state-transitions-template.test.ts +61 -0
  520. package/template/tests/template-ui.test.ts +145 -0
  521. package/template/tests/upload.test.ts +143 -0
  522. package/template/tests/vite-plugin.test.ts +426 -0
  523. package/template/tests/vite-proxy-security.test.ts +153 -0
  524. package/template/tsconfig.json +11 -0
  525. package/template/vite.config.ts +7 -0
  526. package/template/vitest.config.ts +16 -0
  527. package/template/vitest.setup.ts +1 -0
@@ -0,0 +1,2593 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+
5
+ const root = path.resolve(__dirname, "..");
6
+ const runtimeRoot = fs.existsSync(path.join(root, "runtime")) ? "runtime" : path.join(".localapp", "runtime");
7
+ const TRANSPARENT = "rgba(0, 0, 0, 0)";
8
+
9
+ function readTemplateFile(relativePath: string) {
10
+ const parts = relativePath.split(/[\\/]/);
11
+ const resolved = parts[0] === "runtime" ? path.join(runtimeRoot, ...parts.slice(1)) : relativePath;
12
+ return fs.readFileSync(path.join(root, resolved), "utf-8");
13
+ }
14
+
15
+ function cssForRuntimeTokens() {
16
+ const preset = readTemplateFile(path.join("runtime", "styles", "preset.css"));
17
+ const tokenNames = [
18
+ "--localapp-dev-muted",
19
+ "--localapp-dev-muted-foreground",
20
+ "--localapp-dev-border",
21
+ "--localapp-dev-focus",
22
+ "--localapp-dev-accent",
23
+ "--localapp-dev-accent-foreground",
24
+ "--localapp-dev-stripe-from",
25
+ "--localapp-dev-stripe-via",
26
+ "--localapp-dev-stripe-to",
27
+ ];
28
+ const declarations = tokenNames
29
+ .map((token) => preset.match(new RegExp(`${token}:\\s*([^;]+);`))?.[0])
30
+ .filter(Boolean)
31
+ .join("\n");
32
+
33
+ return `
34
+ :root { ${declarations} }
35
+ .bg-localapp-dev-muted { background-color: var(--localapp-dev-muted); }
36
+ .text-localapp-dev-muted-foreground { color: var(--localapp-dev-muted-foreground); }
37
+ .border-localapp-dev-border { border-color: var(--localapp-dev-border); border-width: 1px; border-style: solid; }
38
+ .ring-localapp-dev-focus { outline-color: var(--localapp-dev-focus); }
39
+ .bg-localapp-dev-accent { background-color: var(--localapp-dev-accent); }
40
+ .text-localapp-dev-accent-foreground { color: var(--localapp-dev-accent-foreground); }
41
+ .from-localapp-dev-stripe-from { --tw-gradient-from: var(--localapp-dev-stripe-from); }
42
+ .via-localapp-dev-stripe-via { --tw-gradient-via: var(--localapp-dev-stripe-via); }
43
+ .to-localapp-dev-stripe-to { --tw-gradient-to: var(--localapp-dev-stripe-to); }
44
+ `;
45
+ }
46
+
47
+ describe("dev-shell template", () => {
48
+ it("nav 标签内最后一个子元素是视觉锚点彩条", () => {
49
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
50
+ const expectedGradient =
51
+ "h-[3px] bg-gradient-to-r from-localapp-dev-stripe-from via-localapp-dev-stripe-via to-localapp-dev-stripe-to";
52
+ expect(devShell).toContain(expectedGradient);
53
+ });
54
+
55
+ it("彩条作为 nav 标签内的最后一个子元素", () => {
56
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
57
+ const expectedGradient =
58
+ "h-[3px] bg-gradient-to-r from-localapp-dev-stripe-from via-localapp-dev-stripe-via to-localapp-dev-stripe-to";
59
+ const navEndIndex = devShell.indexOf("</nav>");
60
+ expect(navEndIndex).toBeGreaterThan(0);
61
+ const lastGradientIndex = devShell.lastIndexOf(expectedGradient);
62
+ expect(lastGradientIndex).toBeGreaterThan(0);
63
+ expect(lastGradientIndex).toBeLessThan(navEndIndex);
64
+ });
65
+
66
+ it("彩条配色使用 runtime 声明的 DevShell token", () => {
67
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
68
+ expect(devShell).toContain("from-localapp-dev-stripe-from");
69
+ expect(devShell).toContain("via-localapp-dev-stripe-via");
70
+ expect(devShell).toContain("to-localapp-dev-stripe-to");
71
+ });
72
+
73
+ it("包含开发工具入口和身份/时间/数据/诊断分区", () => {
74
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
75
+ expect(devShell).toContain("开发工具");
76
+ expect(devShell).toContain("身份");
77
+ expect(devShell).toContain("时间");
78
+ expect(devShell).toContain("数据");
79
+ expect(devShell).toContain("诊断");
80
+ });
81
+
82
+ it("DEV 按钮是顶栏最左侧入口,替代独立开发徽章", () => {
83
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
84
+ expect(devShell).toContain("DEV_NAV_LABEL");
85
+ expect(devShell).toContain("aria-label=\"打开 DEV 菜单\"");
86
+ expect(devShell).not.toContain(">开发</span>");
87
+ });
88
+
89
+ it("DevShell 顶栏显式派生自平台 nav-shell 结构模型", () => {
90
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
91
+ expect(devShell).toContain("PLATFORM_NAV_SHELL_MODEL");
92
+ expect(devShell).toContain("deriveDevShellNavModel");
93
+ expect(devShell).toContain("localapp-platform-nav-left");
94
+ expect(devShell).toContain("localapp-platform-nav-right");
95
+ });
96
+
97
+ it("工具列表和开发工具入口收纳在 DEV 下拉菜单中", () => {
98
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
99
+ expect(devShell).toContain("DEV_MENU_TOOLS");
100
+ expect(devShell).toContain("DEV_MENU_TOOLKIT");
101
+ expect(devShell).toContain("devMenuOpen");
102
+ expect(devShell).not.toContain("工具 {toolCount}");
103
+ expect(devShell).not.toContain("devToolkitOpen ? DEV_BUTTON_SUCCESS : DEV_BUTTON_IDLE");
104
+ });
105
+
106
+ it("DEV 下拉菜单项会关闭下拉并打开对应面板", () => {
107
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
108
+ expect(devShell).toContain("openToolsFromDevMenu");
109
+ expect(devShell).toContain("openDevToolkitFromDevMenu");
110
+ expect(devShell).toContain("setDevMenuOpen(false)");
111
+ expect(devShell).toContain("setToolsOpen(true)");
112
+ expect(devShell).toContain("setDevToolkitOpen(true)");
113
+ });
114
+
115
+ it("DEV 下拉菜单支持键盘和外部点击关闭", () => {
116
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
117
+ expect(devShell).toContain("devMenuRef");
118
+ expect(devShell).toContain('event.key === "Escape"');
119
+ expect(devShell).toContain('document.addEventListener("keydown"');
120
+ expect(devShell).toContain('document.addEventListener("mousedown"');
121
+ });
122
+
123
+ it("身份切换会调用 dev context API 并派发刷新事件", () => {
124
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
125
+ expect(devShell).toContain("/api/dev/context");
126
+ expect(devShell).toContain("localapp:dev-context-changed");
127
+ expect(devShell).toContain("window.dispatchEvent");
128
+ });
129
+
130
+ it("身份切换只使用平台用户搜索和固定快捷项,不提供编造用户入口", () => {
131
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
132
+ expect(devShell).toContain("/api/dev/users");
133
+ expect(devShell).toContain("ownUser");
134
+ expect(devShell).toContain("setOwnUser");
135
+ expect(devShell).toContain("搜索平台用户");
136
+ expect(devShell).toContain("历史用户 1");
137
+ expect(devShell).toContain("历史用户 2");
138
+ expect(devShell).not.toContain('setUser("dev-user"');
139
+ expect(devShell).not.toContain('setUser("alice"');
140
+ expect(devShell).not.toContain('setUser("bob"');
141
+ expect(devShell).not.toContain('placeholder="用户 ID"');
142
+ });
143
+
144
+ it("dev context 失败时提示使用 localapp dev 启动", () => {
145
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
146
+
147
+ expect(devShell).toContain("请使用 npm run dev 或 localapp dev 启动开发环境");
148
+ expect(devShell).toContain("readDevContextError");
149
+ expect(devShell).toContain("readDevJson");
150
+ expect(devShell).toContain("Expected JSON");
151
+ expect(devShell).toContain('readDevJson(res, "Server time request")');
152
+ expect(devShell).toContain('readDevJson(res, "Dev context update")');
153
+ });
154
+
155
+ it("时间切换支持固定时间和恢复真实时间", () => {
156
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
157
+ expect(devShell).toContain("timeMode");
158
+ expect(devShell).toContain("fixed");
159
+ expect(devShell).toContain("real");
160
+ });
161
+
162
+ it("时间设置使用常规日期和时间输入,不暴露 ISO 字符串编辑", () => {
163
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
164
+ expect(devShell).toContain('type="date"');
165
+ expect(devShell).toContain('type="time"');
166
+ expect(devShell).toContain("toDevIsoDateTime");
167
+ expect(devShell).not.toContain('useState("2026-07-01T09:00:00.000Z")');
168
+ });
169
+
170
+ it("DevShell 不复制生产 nav-shell 用户入口", () => {
171
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
172
+ expect(devShell).not.toContain("Login");
173
+ expect(devShell).not.toContain("Logout");
174
+ expect(devShell).not.toContain("Favorites");
175
+ expect(devShell).not.toContain("DEV_NAV_NOTIFICATIONS");
176
+ });
177
+
178
+ it("DevShell 顶栏对齐生产 nav-shell 的应用名和用户头像用户名", () => {
179
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
180
+ expect(devShell).toContain("appTitle");
181
+ expect(devShell).toContain("getDevShellAppTitle");
182
+ expect(devShell).toContain("DevShellUserEntry");
183
+ expect(devShell).toContain("avatarUrl");
184
+ expect(devShell).toContain("getUserInitial");
185
+ expect(devShell).not.toContain("<span className={navModel.appTitleClass}>App</span>");
186
+ });
187
+
188
+ it("DevShell AI 侧栏复用生产 AI 侧栏的核心能力", () => {
189
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
190
+ expect(devShell).toContain("react-markdown");
191
+ expect(devShell).toContain("remark-gfm");
192
+ expect(devShell).toContain("ReactMarkdown");
193
+ expect(devShell).toContain("remarkPlugins={[remarkGfm]}");
194
+ expect(devShell).toContain("localapp-ai-sidebar-width");
195
+ expect(devShell).toContain("handleDragStart");
196
+ expect(devShell).toContain("cursor-col-resize");
197
+ });
198
+
199
+ it("数据和诊断分区接入统一 Server 的 dev-only API", () => {
200
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
201
+ expect(devShell).toContain("localapp:platform_request");
202
+ expect(devShell).toContain("localapp:platform_response");
203
+ expect(devShell).toContain("handlePlatformRequest");
204
+ expect(devShell).toContain("respondToPlatformRequest");
205
+ expect(devShell).toContain("confirmDialog");
206
+ expect(devShell).toContain("downloadFromDevShell");
207
+ expect(devShell).not.toContain("localapp:platform-ai");
208
+ expect(devShell).not.toContain("localapp:platform-download");
209
+ expect(devShell).toContain("/api/dev/data/reset");
210
+ expect(devShell).toContain("/api/dev/data/snapshots");
211
+ expect(devShell).toContain("/api/dev/diagnostics/requests");
212
+ expect(devShell).toContain("/api/dev/business");
213
+ expect(devShell).toContain("重置应用数据");
214
+ expect(devShell).not.toContain("重置 dev.db");
215
+ });
216
+
217
+ it("DevShell 在当前页面接管登录请求并打开身份选择", () => {
218
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
219
+ expect(devShell).toContain('case "auth.login"');
220
+ expect(devShell).toContain("setDevToolkitOpen(true)");
221
+ expect(devShell).toContain("event.preventDefault()");
222
+ });
223
+
224
+ it("DevShell 同时提供 SDK native tool registry,与生产 shell 使用同一工具契约", () => {
225
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
226
+ expect(devShell).toContain("@localapp/sdk-agent/native-registry");
227
+ expect(devShell).toContain("setPlatformToolRegistry");
228
+ expect(devShell).toContain("registerDevTools");
229
+ });
230
+
231
+ it("DevShell 提供编辑会话入口和快捷键宿主", () => {
232
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
233
+
234
+ expect(devShell).toContain("setPlatformEditSessionRegistry");
235
+ expect(devShell).toContain("registerEditSession");
236
+ expect(devShell).toContain("DEV_NAV_SAVE");
237
+ expect(devShell).toContain("DEV_NAV_UNDO");
238
+ expect(devShell).toContain("DEV_NAV_REDO");
239
+ expect(devShell).toContain("isEditableShortcutTarget");
240
+ expect(devShell).toContain("Ctrl+S");
241
+ expect(devShell).toContain("Ctrl+Z");
242
+ expect(devShell).toContain("Ctrl+Y");
243
+ });
244
+
245
+ it("DevShell 订阅本地 presence 并在左侧显示在线人数", () => {
246
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
247
+ expect(devShell).toContain("/api/presence/events");
248
+ expect(devShell).toContain("/api/presence/heartbeat");
249
+ expect(devShell).toContain("/api/presence/leave");
250
+ expect(devShell).toContain("clientId");
251
+ expect(devShell).toContain("navigator.sendBeacon");
252
+ expect(devShell).toContain("presence:snapshot");
253
+ expect(devShell).toContain("authenticatedUsers");
254
+ expect(devShell).toContain('document.visibilityState === "hidden"');
255
+ expect(devShell).toContain('document.addEventListener("visibilitychange", handleVisibilityChange)');
256
+ expect(devShell).toContain('window.addEventListener("blur", handleWindowBlur)');
257
+ expect(devShell).toContain('window.addEventListener("focus", handleWindowFocus)');
258
+ expect(devShell).toContain('window.addEventListener("pagehide", handlePageHide)');
259
+ expect(devShell).toContain('window.addEventListener("pageshow", handleWindowFocus)');
260
+ expect(devShell).toContain("DEV_NAV_ONLINE_USERS");
261
+ expect(devShell).toContain("当前在线用户");
262
+ });
263
+
264
+ it("DevShell 提供与生产一致的本地 Issue 入口和三态工作台", () => {
265
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
266
+
267
+ expect(devShell).toContain("DEV_NAV_ISSUES");
268
+ expect(devShell).toContain("openIssueCount");
269
+ expect(devShell).toContain("data-localapp-issues-workspace");
270
+ expect(devShell).toContain('kind: "detail"');
271
+ expect(devShell).toContain('kind: "create"');
272
+ expect(devShell).toContain("/api/issues");
273
+ expect(devShell).toContain("Issue 服务暂不可用");
274
+ expect(devShell).toContain("按标签筛选");
275
+ expect(devShell).toContain('aria-label="按创建者筛选"');
276
+ expect(devShell).toContain('aria-label="按负责人筛选"');
277
+ expect(devShell).toContain("[&_label:focus-within]:ring-2 [&_label:focus-within]:ring-localapp-dev-focus");
278
+ expect(devShell).toContain('<option value="none">未分配</option>');
279
+ expect(devShell).toContain('<option value="none">无标签</option>');
280
+ expect(devShell).toContain('updateIssueQuery({ assignee: event.target.value })');
281
+ expect(devShell).toContain('updateIssueQuery({ author: event.target.value })');
282
+ expect(devShell).toContain("activeDevIssueAdvancedFilterCount(query, user?.id)");
283
+ expect(devShell).toContain('aria-controls="localapp-dev-issue-advanced-filters"');
284
+ expect(devShell).toContain('data-testid="issue-advanced-filters"');
285
+ expect(devShell).toContain("advancedIssueFiltersOpen ? \"grid\" : \"hidden\"");
286
+ expect(devShell).toContain("sm:contents");
287
+ expect(devShell).toContain("sm:hidden");
288
+ expect(devShell).toContain('select aria-label="Issue 视图" value={activeSavedViewId ? `saved:${activeSavedViewId}` : activeView}');
289
+ expect(devShell).toContain('if (value.startsWith("saved:"))');
290
+ expect(devShell).toContain("selectIssueView(value as DevIssueListView)");
291
+ expect(devShell).toContain('className="hidden max-w-full gap-1 lg:flex lg:flex-col" aria-label="Issue 视图导航"');
292
+ expect(devShell).toContain("关闭 Issue");
293
+ expect(devShell).not.toContain("window.alert");
294
+ });
295
+
296
+ it("DevShell Open count 优先读取 meta.open,并仅在其非法时回退 data.length", () => {
297
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
298
+
299
+ expect(devShell).toContain("requestDevIssueBody<DevIssue[]>(`/api/issues?${query.toString()}`");
300
+ expect(devShell).toContain("const open = body.meta?.open");
301
+ expect(devShell).toContain("typeof open === \"number\" && Number.isFinite(open) && open >= 0");
302
+ expect(devShell).toContain("Array.isArray(body.data) ? body.data.length : 0");
303
+ expect(devShell).toContain("if (active) setOpenIssueCount(open)");
304
+ expect(devShell).not.toContain('if (active) setOpenIssueCount(null)');
305
+ expect(devShell).toContain('throw new Error("Issue 服务暂不可用")');
306
+ });
307
+
308
+ it("DevShell Issue 状态按钮、列表和详情使用一致的中文状态名称", () => {
309
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
310
+
311
+ expect(devShell).toContain('aria-label={`开启 ${meta.open}`}');
312
+ expect(devShell).toContain('aria-label={`已关闭 ${meta.closed}`}');
313
+ expect(devShell).toContain('开启 {meta.open}');
314
+ expect(devShell).toContain('已关闭 {meta.closed}');
315
+ expect(devShell).toContain('`${query.status === "open" ? "开启" : "已关闭"}的 Issues`');
316
+ expect(devShell).toContain('detail.issue.status === "open" ? "开启"');
317
+ expect(devShell).toContain('"已关闭 · 不计划处理" : "已关闭 · 已完成"');
318
+ });
319
+
320
+ it("DevShell 批量标签操作按当前标签集合添加或移除并保留失败项", () => {
321
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
322
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
323
+
324
+ expect(workspace).toContain('aria-label="批量标签操作"');
325
+ expect(workspace).toContain("[&_[data-localapp-issue-bulk-toolbar]_label:focus-within]:ring-2");
326
+ expect(workspace).toContain("[&_[data-localapp-issue-bulk-toolbar]_label:focus-within]:ring-localapp-dev-focus");
327
+ expect(workspace).toContain('grid-cols-1 gap-2 min-[360px]:grid-cols-2 sm:contents [&>label]:min-w-0');
328
+ expect(workspace).toContain('value={`add:${label.id}`}');
329
+ expect(workspace).toContain('value={`remove:${label.id}`}');
330
+ expect(workspace).toContain('aria-label="批量类型操作"');
331
+ expect(workspace).toContain('JSON.stringify({ pagePath, issueType })');
332
+ expect(workspace).toContain('setBulkIssueTypeAction("")');
333
+ expect(workspace).toContain('issue?.labels?.map((label) => label.id) ?? []');
334
+ expect(workspace).toContain("const applyBulkIssueLabel = async");
335
+ expect(workspace).toContain("const focusSelectAllAfterBulkSave = () =>");
336
+ expect(workspace).toContain("document.querySelector<HTMLInputElement>('[data-localapp-issues-workspace] input[aria-label=\"选择当前页全部 Issue\"]')");
337
+ expect(workspace).toContain("if (!control || control.disabled)");
338
+ expect(workspace).toContain("if (stableChecks < 3 && attempts++ < 20)");
339
+ expect(workspace).toContain("if (failedIds.length === 0) focusSelectAllAfterBulkSave()");
340
+ expect(workspace).toContain("const selectionAnchorIssueIdRef = useRef<number | null>(null)");
341
+ expect(workspace).toContain("const toggleIssueSelectionRange = (issueId: number, selected: boolean, range: boolean)");
342
+ expect(workspace).toContain("event.shiftKey && event.detail > 0");
343
+ expect(workspace).toContain('if (event.key === " ")');
344
+ expect(workspace).toContain("requestDevIssue<DevIssueDetail>(`/api/issues/${issueId}/labels`");
345
+ expect(workspace).toContain("setSelectedIssueIds(new Set(failedIds))");
346
+ });
347
+
348
+ it("DevShell 批量负责人操作合并当前集合并保留失败项", () => {
349
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
350
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
351
+
352
+ expect(workspace).toContain('aria-label="批量负责人操作"');
353
+ expect(workspace).toContain("const applyBulkIssueAssignee = async");
354
+ expect(workspace).toContain("const current = issue?.assignee_ids ?? []");
355
+ expect(workspace).toContain("requestDevIssue<DevIssueDetail>(`/api/issues/${issueId}/assignees`");
356
+ expect(workspace).toContain("body: JSON.stringify({ pagePath, userIds })");
357
+ });
358
+
359
+ it("DevShell 批量里程碑操作支持设置、清除并保留失败项", () => {
360
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
361
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
362
+
363
+ expect(workspace).toContain('aria-label="批量里程碑操作"');
364
+ expect(workspace).toContain('<option value="none">清除里程碑</option>');
365
+ expect(workspace).toContain("const applyBulkIssueMilestone = async");
366
+ expect(workspace).toContain("const milestoneId = value === \"none\" ? null : Number(value)");
367
+ expect(workspace).toContain("requestDevIssue<DevIssueDetail>(`/api/issues/${issueId}/milestone`");
368
+ expect(workspace).toContain("body: JSON.stringify({ pagePath, milestoneId })");
369
+ expect(workspace).toContain("setSelectedIssueIds(new Set(failedIds))");
370
+ });
371
+
372
+ it("DevShell 在列表行显示可解析里程碑并复用结构化筛选", () => {
373
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
374
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
375
+
376
+ expect(workspace).toContain("const issueMilestone = availableMilestones.find((milestone) => milestone.id === issue.milestone_id)");
377
+ expect(workspace).toContain('aria-label={`按里程碑筛选 ${issueMilestone.title}`}');
378
+ expect(workspace).toContain("updateIssueQuery({ milestone: String(issueMilestone.id), offset: 0 })");
379
+ expect(workspace).toContain("<CalendarDays className=\"h-3.5 w-3.5 shrink-0\"");
380
+ });
381
+
382
+ it("DevShell 仅将列表标签升级为结构化筛选入口", () => {
383
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
384
+ const badge = devShell.slice(devShell.indexOf("function DevIssueLabelBadge"), devShell.indexOf("function DevIssueLabelManager"));
385
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
386
+
387
+ expect(badge).toContain("onSelect?: (labelId: string) => void");
388
+ expect(badge).toContain('aria-label={`按标签筛选 ${label.name}`}');
389
+ expect(workspace).toContain("onSelect={(labelId) => updateIssueQuery({ label: labelId, offset: 0 })}");
390
+ expect(workspace).toContain("<DevIssueLabelBadge key={label.id} label={label} onSelect=");
391
+ expect(devShell).toContain("<DevIssueLabelBadge key={label.id} label={label} />");
392
+ });
393
+
394
+ it("DevShell 将可见负责人头像升级为筛选入口并保持溢出静态", () => {
395
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
396
+ const assignees = devShell.slice(devShell.indexOf("function DevIssueListAssignees"), devShell.indexOf("function DevIssueDetailSkeleton"));
397
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
398
+
399
+ expect(assignees).toContain("onSelect: (userId: string) => void");
400
+ expect(assignees).toContain('aria-label={`按负责人筛选 ${identity.displayName}`}');
401
+ expect(assignees).toContain("onClick={() => onSelect(identity.id)}");
402
+ expect(assignees).toContain('aria-label={`另外 ${overflow} 位负责人`}');
403
+ expect(workspace).toContain("onSelect={(userId) => updateIssueQuery({ assignee: userId, offset: 0 })}");
404
+ });
405
+
406
+ it("DevShell 解析列表创建者名称并按稳定 ID 筛选", () => {
407
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
408
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
409
+
410
+ expect(workspace).toContain("const issueReporter = resolveDevIssueIdentity(issue.reporter_id, issueMentionCandidates)");
411
+ expect(workspace).toContain('aria-label={`按创建者筛选 ${issueReporter.displayName}`}');
412
+ expect(workspace).toContain('title={`${issueReporter.displayName} @${issueReporter.id}`}');
413
+ expect(workspace).toContain("updateIssueQuery({ author: issueReporter.id, offset: 0 })");
414
+ });
415
+
416
+ it("DevShell 区分列表创建时间与后续活动时间", () => {
417
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
418
+ const activity = devShell.slice(devShell.indexOf("function DevIssueListActivityTime"), devShell.indexOf("function DevIssueListAssignees"));
419
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
420
+
421
+ expect(activity).toContain("issue.last_activity_at ?? issue.updated_at ?? issue.created_at");
422
+ expect(activity).toContain('data-kind={created ? "created" : "activity"}');
423
+ expect(activity).toContain('{created ? "创建于" : "活动于"}');
424
+ expect(activity).toContain("<DevIssueTime timestamp={timestamp} />");
425
+ expect(workspace).toContain("<DevIssueListActivityTime issue={issue} />");
426
+ });
427
+
428
+ it("DevShell 在 Closed 列表区分已完成与不计划处理", () => {
429
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
430
+ const status = devShell.slice(devShell.indexOf("function DevIssueListStatusIcon"), devShell.indexOf("function DevIssueListActivityTime"));
431
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
432
+
433
+ expect(status).toContain('issue.state_reason === "not_planned"');
434
+ expect(status).toContain("<CircleSlash2");
435
+ expect(status).toContain('notPlanned ? "已关闭:不计划处理" : "已关闭:已完成"');
436
+ expect(workspace).toContain("<DevIssueListStatusIcon issue={issue} className=\"mt-1 h-4 w-4 shrink-0\" />");
437
+ });
438
+
439
+ it("DevShell 支持 assignee 搜索限定词、URL 状态和服务端筛选", () => {
440
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
441
+ expect(devShell).toContain('assignee: "localappIssueAssignee"');
442
+ expect(devShell).toContain('["assignee:", "负责人", "筛选分配给指定用户的 Issue"]');
443
+ expect(devShell).toContain('updates[key === "author" ? "author" : key === "assignee" ? "assignee" : "participant"]');
444
+ expect(devShell).toContain('requestQuery.set("assignee", nextQuery.assignee)');
445
+ expect(devShell).toContain('kind: "负责人"');
446
+ });
447
+
448
+ it("DevShell Issue 行显示紧凑负责人组与溢出计数", () => {
449
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
450
+ expect(devShell).toContain("function DevIssueListAssignees(");
451
+ expect(devShell).toContain('aria-label={`负责人:${resolved.map((identity) => identity.displayName).join("、")}`}');
452
+ expect(devShell).toContain("const visible = resolved.slice(0, 3)");
453
+ expect(devShell).toContain("另外 ${overflow} 位负责人");
454
+ expect(devShell).toContain("<DevIssueListAssignees ids={issue.assignee_ids ?? []} identities={issueMentionCandidates} onSelect={(userId) => updateIssueQuery({ assignee: userId, offset: 0 })} />");
455
+ });
456
+
457
+ it("DevShell 支持负责人、标签与里程碑缺失元数据筛选", () => {
458
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
459
+ expect(devShell).toContain('["no:", "缺失项", "筛选缺少元数据的 Issue"]');
460
+ expect(devShell).toContain('add("assignee", "无负责人", "仅显示尚未分配负责人的 Issue")');
461
+ expect(devShell).toContain('add("label", "无标签", "仅显示尚未添加标签的 Issue")');
462
+ expect(devShell).toContain('add("milestone", "无里程碑", "仅显示尚未设置里程碑的 Issue")');
463
+ expect(devShell).toContain('key === "no" && /^(assignee|label|milestone)$/i.test(rawValue)');
464
+ expect(devShell).toContain('updates[rawValue.toLowerCase() as "assignee" | "label" | "milestone"] = "none"');
465
+ expect(devShell).toContain('query.assignee === "none" ? "未分配"');
466
+ expect(devShell).toContain('query.label === "none" ? "未添加"');
467
+ expect(devShell).toContain('(issue.labels ?? [])');
468
+ expect(devShell).toContain('issue?.labels?.map((label) => label.id) ?? []');
469
+ });
470
+
471
+ it("DevShell Issue 详情从统一 Server 加载 GitHub 风格 Markdown 时间线", () => {
472
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
473
+
474
+ expect(devShell).toContain("interface DevIssueDetail");
475
+ expect(devShell).toContain("type DevIssueTimelineItem");
476
+ expect(devShell).toContain("loadIssueDetail");
477
+ expect(devShell).toContain("/api/issues/${issueId}?");
478
+ expect(devShell).toContain("aria-label=\"Issue 时间线\"");
479
+ expect(devShell).toContain("DevIssueMarkdown");
480
+ expect(devShell).toContain("inline-flex h-11 w-11 cursor-pointer");
481
+ expect(devShell).toContain("sm:h-6 sm:w-6");
482
+ expect(devShell).toContain("remarkPlugins={[remarkGfm]}");
483
+ expect(devShell).toContain("event_type === \"opened\"");
484
+ expect(devShell).toContain("event_type === \"closed\"");
485
+ expect(devShell).toContain("event_type === \"reopened\"");
486
+ expect(devShell).toContain('event.event_type === "labels_changed"');
487
+ expect(devShell).toContain('event.event_type === "assignees_changed"');
488
+ expect(devShell).toContain('event.event_type === "subscribed"');
489
+ expect(devShell).toContain('event.event_type === "unsubscribed"');
490
+ expect(devShell).toContain("将 ${addedName} 设为负责人");
491
+ });
492
+
493
+ it("DevShell Issue 详情同步 Hosted 的讨论流、元数据和响应式契约", () => {
494
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
495
+
496
+ for (const attribute of [
497
+ "data-localapp-issue-detail",
498
+ "data-localapp-issue-discussion",
499
+ "data-localapp-issue-metadata",
500
+ "data-localapp-issue-body-card",
501
+ "data-localapp-issue-comment-card",
502
+ "data-localapp-issue-event",
503
+ ]) {
504
+ expect(devShell).toContain(attribute);
505
+ }
506
+ expect(devShell).toContain("text-2xl font-normal leading-8 tracking-normal");
507
+ expect(devShell).toContain("sm:text-[32px] sm:leading-10");
508
+ expect(devShell).toContain("lg:grid-cols-[minmax(0,3fr)_minmax(240px,1fr)]");
509
+ expect(devShell).toContain("lg:gap-6");
510
+ expect(devShell).toContain("<details data-localapp-issue-metadata");
511
+ expect(devShell).toContain("className=\"border-b border-localapp-dev-border py-3 lg:hidden\"");
512
+ expect(devShell).toContain("max-lg:hidden min-w-0 border-l");
513
+ expect(devShell).toContain("[&_[data-localapp-issue-body-card]]:rounded-[6px]");
514
+ expect(devShell).toContain("data-localapp-issue-comment-card data-localapp-issue-comment-pinned={comment.pinned_at ? \"true\" : undefined} data-localapp-issue-comment-id={comment.id}");
515
+ expect(devShell).toContain('className={`min-w-0 overflow-hidden rounded-[6px]');
516
+ expect(devShell).toContain("min-w-0 max-w-none overflow-hidden");
517
+ expect(devShell).toContain("max-w-full overflow-x-auto");
518
+ expect(devShell).toContain("break-all");
519
+ });
520
+
521
+ it("DevShell Issue 身份按当前、最近、平台缓存和未知 ID 依次降级", () => {
522
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
523
+
524
+ expect(devShell).toContain("function resolveDevIssueIdentity");
525
+ expect(devShell).toContain("function DevIssueActor");
526
+ expect(devShell).toContain("currentUser");
527
+ expect(devShell).toContain("recentUsers");
528
+ expect(devShell).toContain("platformUsers");
529
+ expect(devShell).toContain("displayName?.trim() || user.name?.trim() || user.id");
530
+ expect(devShell).toContain('displayName: userId || "未知用户"');
531
+ expect(devShell).toContain("avatarUrl: null");
532
+ expect(devShell).toContain("@{identity.id || \"未知\"}");
533
+ expect(devShell).toContain("getDevIssueIdentityInitial(identity)");
534
+ expect(devShell).toContain("platformUsers={platformUsers}");
535
+ expect(devShell).toContain("recentUsers={devContext?.recentUsers ?? []}");
536
+ });
537
+
538
+ it("DevShell Issue composer 支持 Markdown 编辑预览和评论状态动作", () => {
539
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
540
+
541
+ expect(devShell).toContain("function DevIssueComposer");
542
+ expect(devShell).toContain('useState<"edit" | "preview">("edit")');
543
+ expect(devShell).toContain(">编辑</button>");
544
+ expect(devShell).toContain(">预览</button>");
545
+ expect(devShell).toContain("评论并关闭");
546
+ expect(devShell).toContain("重新打开并评论");
547
+ expect(devShell).toContain("statusAction");
548
+ expect(devShell).toContain('stateReason: statusAction === "close" ? closeReason : undefined');
549
+ expect(devShell).toContain("/comments");
550
+ });
551
+
552
+ it("DevShell Markdown 工具栏同步命令、选择区、快捷键和附件队列契约", () => {
553
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
554
+
555
+ expect(devShell).toContain("type DevIssueMarkdownCommand");
556
+ expect(devShell).toContain("function applyDevIssueMarkdownCommand");
557
+ for (const command of ["heading", "bold", "italic", "quote", "code", "link", "bullet-list", "ordered-list", "task-list"]) {
558
+ expect(devShell).toContain(`command: "${command}"`);
559
+ }
560
+ for (const label of ["标题格式", "粗体", "斜体", "引用", "行内代码", "链接", "无序列表", "有序列表", "任务列表"]) {
561
+ expect(devShell).toContain(`label: "${label}"`);
562
+ }
563
+ expect(devShell).toContain("data-localapp-issue-editor");
564
+ expect(devShell).toContain("data-localapp-issue-toolbar");
565
+ expect(devShell).toContain("flex-wrap");
566
+ expect(devShell).toContain("overflow-x-hidden");
567
+ expect(devShell).toContain("sm:flex-nowrap");
568
+ expect(devShell).toContain("sm:overflow-x-auto");
569
+ expect(devShell).toContain("const toolbarButtonRefs = useRef<Array<HTMLButtonElement | null>>([])");
570
+ expect(devShell).toContain("const [toolbarFocusIndex, setToolbarFocusIndex] = useState(0)");
571
+ expect(devShell).toContain("handleDevIssueToolbarKeyDown");
572
+ expect(devShell).toContain('event.key === "Home"');
573
+ expect(devShell).toContain('event.key === "End"');
574
+ expect(devShell).toContain('event.key === "ArrowLeft" || event.key === "ArrowUp"');
575
+ expect(devShell).toContain('tabIndex={toolbarFocusIndex === index ? 0 : -1}');
576
+ expect(devShell).toContain("onFocus={() => setToolbarFocusIndex(index)}");
577
+ expect(devShell).toContain('role="tablist" aria-label="Markdown 模式"');
578
+ expect(devShell).toContain('role="tab" aria-selected={mode === "edit"}');
579
+ expect(devShell).toContain('role="tabpanel"');
580
+ expect(devShell).toContain('event.key === "ArrowRight"');
581
+ expect(devShell).toContain('event.key === "ArrowLeft"');
582
+ expect(devShell).toContain("data-localapp-issue-attachment-queue");
583
+ expect(devShell).toContain('aria-busy={hasUploadingIssueAttachments || undefined}');
584
+ expect(devShell).toContain('role="status" aria-label="附件队列状态" aria-live="polite" aria-atomic="true"');
585
+ expect(devShell).toContain('role="status" aria-label={`${attachment.fileName} 已上传`}');
586
+ expect(devShell).toContain("已上传 · {formatDevIssueFileSize(attachment.fileSize)}");
587
+ expect(devShell).toContain('<Check className="h-3.5 w-3.5"');
588
+ expect(devShell).toContain("function devIssueAttachmentMarkdown(");
589
+ expect(devShell).toContain("DEV_ISSUE_MARKDOWN_PUNCTUATION");
590
+ expect(devShell).toContain("Array.from(attachment.file_name, (character)");
591
+ expect(devShell).toContain('DEV_ISSUE_MARKDOWN_PUNCTUATION.has(character) ? `\\\\${character}` : character');
592
+ expect(devShell).toContain("function removeDevIssueAttachmentMarkdown(");
593
+ expect(devShell).toContain("setBody((current) => removeDevIssueAttachmentMarkdown(current, attachment.attachment))");
594
+ expect(devShell).toContain('aria-live="polite"');
595
+ expect(devShell).toContain("textarea.selectionStart");
596
+ expect(devShell).toContain("textarea.selectionEnd");
597
+ expect(devShell).toContain("textarea.setSelectionRange");
598
+ expect(devShell).toContain("event.ctrlKey || event.metaKey");
599
+ expect(devShell).toContain("h-11 rounded px-3 text-xs font-medium sm:h-7");
600
+ expect(devShell).toContain("h-11 w-11 shrink-0 sm:h-8 sm:w-8");
601
+ expect(devShell).toContain("h-11 sm:h-8");
602
+ expect(devShell).toContain('event.key.toLowerCase() === "b"');
603
+ expect(devShell).toContain('event.key.toLowerCase() === "i"');
604
+ expect(devShell).toContain('event.key.toLowerCase() === "k"');
605
+ });
606
+
607
+ it("DevShell 同步多标签、负责人、本人订阅与动态筛选契约", () => {
608
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
609
+
610
+ expect(devShell).toContain("interface DevIssueCollaborationMetadata");
611
+ expect(devShell).toContain("/api/issues/labels?");
612
+ expect(devShell).toContain('kind: "labels" | "assignees" | "subscription" | "milestone" | "lock"');
613
+ expect(devShell).toContain('label === "Labels" ? "标签" : "负责人"');
614
+ expect(devShell).toContain('aria-label={`编辑${localizedLabel}`}');
615
+ expect(devShell).toContain(">通知</h4>");
616
+ expect(devShell).toContain("取消订阅");
617
+ expect(devShell).toContain("availableLabels.map");
618
+ expect(devShell).toContain("collaboration?.assignee_ids");
619
+ expect(devShell).toContain("collaboration?.subscriber_ids");
620
+ expect(devShell).toContain('aria-label="Issue 元数据状态"');
621
+ expect(devShell).toContain('aria-live="polite"');
622
+ expect(devShell).toContain("localMetadataError");
623
+ expect(devShell).toContain('role="alert" className="rounded');
624
+ });
625
+
626
+ it("DevShell 使用列表快捷键且不劫持编辑控件", () => {
627
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
628
+ expect(devShell).toContain("issueSearchInputRef");
629
+ expect(devShell).toContain('event.key === "/"');
630
+ expect(devShell).toContain('event.key.toLowerCase() === "c"');
631
+ expect(devShell).toContain("target.isContentEditable");
632
+ expect(devShell).toContain('["INPUT", "TEXTAREA", "SELECT"]');
633
+ expect(devShell).toContain("issueSearchInputRef.current?.focus()");
634
+ expect(devShell).toContain('setView({ kind: "create",');
635
+ });
636
+
637
+ it("DevShell reporter 编辑标题正文,owner 单独编辑 label,评论仍只允许作者管理", () => {
638
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
639
+
640
+ expect(devShell).toContain("canEditIssueContent");
641
+ expect(devShell).toContain("user?.id === detail.issue.reporter_id");
642
+ expect(devShell).toContain("canEditIssueType");
643
+ expect(devShell).toContain('user?.role === "owner"');
644
+ expect(devShell).toContain("canEditIssueContent || canEditIssueType");
645
+ expect(devShell).toContain("编辑 Issue");
646
+ expect(devShell).toContain("保存 Issue");
647
+ expect(devShell).toContain("DEV_ISSUE_TITLE_MAX_CHARACTERS = 256");
648
+ expect(devShell).toContain("Array.from(createTitle.trim()).length");
649
+ expect(devShell).toContain("Array.from(title.trim()).length");
650
+ expect(devShell).toContain("Issue 标题不能超过 256 个字符");
651
+ expect(devShell).toContain('aria-invalid={createTitleTooLong || undefined}');
652
+ expect(devShell).toContain('data-localapp-issue-create-title aria-label="标题"');
653
+ expect(devShell).toContain('aria-invalid={titleTooLong || undefined}');
654
+ expect(devShell).toContain("{createTitleCharacterCount} / {DEV_ISSUE_TITLE_MAX_CHARACTERS}");
655
+ expect(devShell).toContain('textareaLabel="编辑 Issue 正文" placeholder="更新 Issue 描述" submitLabel="保存 Issue"');
656
+ expect(devShell).toContain('placeholder="更新 Issue 描述"');
657
+ expect(devShell).toContain('placeholder="更新评论"');
658
+ expect(devShell).toContain('placeholder="留下评论"');
659
+ expect(devShell).toContain('placeholder="详细描述问题、复现步骤或期望结果"');
660
+ expect(devShell).toContain("placeholder?: string;");
661
+ expect(devShell).toContain("placeholder={resolvedPlaceholder}");
662
+ expect(devShell).toContain('textareaLabel.includes("评论")');
663
+ expect(devShell).toContain('draftId={`edit-issue-${detail.issue.id}`}');
664
+ expect(devShell).toContain("saveIssue(body, attachmentIds, draftId)");
665
+ expect(devShell).toContain("canEditIssueContent &&");
666
+ expect(devShell).toContain("canEditIssueType &&");
667
+ expect(devShell).toContain('aria-label="编辑 Issue 类型"');
668
+ expect(devShell).toContain("canEditIssueType ? { issueType: editingIssueType }");
669
+ expect(devShell).toContain('user.id === detail.issue.reporter_id || user.role === "owner"');
670
+ expect(devShell).toContain("comment.author_id === currentUserId");
671
+ expect(devShell).toContain("编辑评论");
672
+ expect(devShell).toContain('textareaLabel="编辑评论内容" placeholder="更新评论" submitLabel="保存评论"');
673
+ expect(devShell).toContain('draftId={`edit-comment-${comment.id}`}');
674
+ expect(devShell).toContain("onCancel={() => { clearCommentDraft(comment.id, true); setEditingCommentId(null); setEditingCommentVersion(null); setRemovedCommentAttachmentIds([]); }}");
675
+ expect(devShell).toContain("删除评论");
676
+ expect(devShell).toContain('role="alertdialog" aria-label="删除评论确认"');
677
+ expect(devShell).toContain("取消删除");
678
+ expect(devShell).toContain("确认删除评论");
679
+ expect(devShell).toContain("deleteCommentCancelRef");
680
+ expect(devShell).toContain('event.key === "Escape"');
681
+ expect(devShell).toContain("restoreDeleteCommentTriggerFocus");
682
+ expect(devShell).toContain("contentMissing || submitDisabled");
683
+ expect(devShell).toContain("allowEmpty={visibleCommentAttachments.length > 0}");
684
+ expect(devShell).toContain("<DevIssueAttachmentLinks attachments={visibleCommentAttachments}");
685
+ expect(devShell).toContain("移除现有附件");
686
+ expect(devShell).toContain("removedAttachmentIds");
687
+ expect(devShell).toContain("removedIssueAttachmentIds");
688
+ expect(devShell).toContain("visibleIssueAttachments");
689
+ expect(devShell).toContain("issueAttachmentRemoveRequest");
690
+ expect(devShell).toContain("removeTextRequest={issueAttachmentRemoveRequest}");
691
+ expect(devShell).toContain("/comments/${commentId}");
692
+ expect(devShell).toContain('method: "DELETE"');
693
+ });
694
+
695
+ it("DevShell Issue composer 支持选择、拖拽和粘贴附件及其上传生命周期", () => {
696
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
697
+
698
+ expect(devShell).toContain("handleIssueFiles");
699
+ expect(devShell).toContain("handleIssueDrop");
700
+ expect(devShell).toContain("handleIssuePaste");
701
+ expect(devShell).toContain('type="file"');
702
+ expect(devShell).toContain('data-testid="issue-attachment-input"');
703
+ expect(devShell).toContain('data-testid="issue-attachment-input" hidden type="file"');
704
+ expect(devShell).not.toContain('data-testid="issue-attachment-input" aria-label="添加附件"');
705
+ expect(devShell).toContain("拖拽文件或粘贴截图");
706
+ expect(devShell).toContain("new FormData()");
707
+ expect(devShell).toContain("/api/issues/attachments");
708
+ expect(devShell).toContain('status: "uploading"');
709
+ expect(devShell).toContain('status: "uploaded"');
710
+ expect(devShell).toContain('status: "error"');
711
+ expect(devShell).toContain("URL.createObjectURL");
712
+ expect(devShell).toContain("URL.revokeObjectURL");
713
+ expect(devShell).toContain("移除 ${attachment.fileName}");
714
+ expect(devShell).toContain("重试 ${attachment.fileName}");
715
+ expect(devShell).toContain("h-11 w-11 shrink-0 sm:h-7 sm:w-7");
716
+ expect(devShell).toContain("单个附件不能超过 25 MiB");
717
+ expect(devShell).toContain("DEV_ISSUE_MAX_DRAFT_ATTACHMENTS = 20");
718
+ expect(devShell).toContain("const acceptedFiles = files.slice(0, remainingCapacity)");
719
+ expect(devShell).toContain("files.length - acceptedFiles.length");
720
+ expect(devShell).toContain("每个草稿最多添加 20 个附件;已忽略");
721
+ expect(devShell).toContain("setAttachmentLimitError(null)");
722
+ expect(devShell).toContain("const [attachmentsExpanded, setAttachmentsExpanded] = useState(false)");
723
+ expect(devShell).toContain("DEV_ISSUE_VISIBLE_UPLOADED_ATTACHMENTS = 4");
724
+ expect(devShell).toContain("attachment.status !== \"uploaded\"");
725
+ expect(devShell).toContain("显示其余 ${hiddenUploadedAttachmentCount} 个已上传附件");
726
+ expect(devShell).toContain('aria-expanded={attachmentsExpanded}');
727
+ expect(devShell).toContain('aria-controls={attachmentListId}');
728
+ expect(devShell).toContain("收起已上传附件");
729
+ expect(devShell).toContain("const addAttachmentButtonRef = useRef<HTMLButtonElement | null>(null)");
730
+ expect(devShell).toContain("const attachmentRemoveButtonRefs = useRef(new Map<string, HTMLButtonElement>())");
731
+ expect(devShell).toContain("visibleAttachments.findIndex((item) => item.clientId === attachment.clientId)");
732
+ expect(devShell).toContain("window.requestAnimationFrame(() =>");
733
+ expect(devShell).toContain("attachmentRemoveButtonRefs.current.get(nextAttachmentId)");
734
+ expect(devShell).toContain("addAttachmentButtonRef.current");
735
+ });
736
+
737
+ it("DevShell 新建 Issue 表单使用移动触控尺寸和桌面紧凑尺寸", () => {
738
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
739
+ const createStart = devShell.indexOf('{view.kind === "create" && (');
740
+ const createForm = devShell.slice(createStart, devShell.indexOf('{view.kind === "detail" && (', createStart));
741
+
742
+ expect(createForm).toContain("block h-11 w-full rounded");
743
+ expect(createForm).toContain("sm:h-9");
744
+ expect(createForm).toContain("h-11 rounded px-3 text-xs font-medium sm:h-8");
745
+ expect(createForm).toContain("`${DEV_OUTLINE_BUTTON} h-11 sm:h-8`");
746
+ expect(createForm).toContain('data-localapp-issue-create-workspace className="grid min-w-0 gap-5 lg:grid-cols-[minmax(0,3fr)_minmax(240px,1fr)] lg:gap-6"');
747
+ expect(createForm).toContain('data-localapp-issue-create-main className="min-w-0 space-y-4"');
748
+ expect(createForm).toContain('data-localapp-issue-create-triage aria-label="Issue 分诊" className="min-w-0 space-y-4 border-t border-localapp-dev-border pt-4 lg:border-l lg:border-t-0 lg:pl-5 lg:pt-0"');
749
+ expect(createForm.indexOf("data-localapp-issue-create-main")).toBeLessThan(createForm.indexOf("data-localapp-issue-create-triage"));
750
+ });
751
+
752
+ it("DevShell 按应用、用户和 Issue 隔离会话草稿并在提交后清理", () => {
753
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
754
+
755
+ expect(devShell).toContain("localapp:issues:draft:v1");
756
+ expect(devShell).toContain("sessionStorage.getItem");
757
+ expect(devShell).toContain("sessionStorage.setItem");
758
+ expect(devShell).toContain("sessionStorage.removeItem");
759
+ expect(devShell).toContain('persistenceKey={`${issueDraftPrefix}:comment:${detail.issue.id}:body`}');
760
+ expect(devShell).toContain('title || issueType !== "task"');
761
+ expect(devShell).toContain("pendingIssueFocusIdRef");
762
+ });
763
+
764
+ it("DevShell 恢复 Issue 与评论编辑草稿时保留原并发版本", () => {
765
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
766
+
767
+ expect(devShell).toContain(":edit:${detail.issue.id}:meta");
768
+ expect(devShell).toContain(":edit:${detail.issue.id}:body");
769
+ expect(devShell).toContain('commentDraftKey(comment.id, "version")');
770
+ expect(devShell).toContain("preferPersistedDraft");
771
+ expect(devShell).toContain("expectedUpdatedAt: editingIssueVersion");
772
+ });
773
+
774
+ it("DevShell 在编辑上下文内提示并允许局部丢弃已恢复草稿", () => {
775
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
776
+
777
+ expect(devShell).toContain("已恢复上次未完成的编辑");
778
+ expect(devShell).toContain("丢弃已恢复草稿");
779
+ expect(devShell).toContain("restoredIssueDraft");
780
+ expect(devShell).toContain("restoredCommentDraft");
781
+ expect(devShell).toContain("clearCommentDraft(comment.id)");
782
+ expect(devShell).toContain("const bodyKey = commentDraftKey(commentId, \"body\")");
783
+ expect(devShell).toContain("discardDevIssueAttachmentDraft(pagePath, issueEditBodyKey)");
784
+ expect(devShell).toContain("window.sessionStorage.removeItem(key)");
785
+ expect(devShell).toContain("discardDevIssueAttachmentDraft(pagePath, bodyKey)");
786
+ expect(devShell).toContain("discardDevIssueAttachmentDraft(pagePath, issueEditBodyKey)");
787
+ expect(devShell).toContain('method: "DELETE"');
788
+ expect(devShell).toContain("releaseDevIssueAttachment(pagePath, attachment)");
789
+ expect(devShell).toContain('className="mb-3 flex flex-wrap items-center justify-between');
790
+ expect(devShell).toContain('role="alertdialog" aria-label="丢弃草稿确认"');
791
+ expect(devShell).toContain("未提交内容和已上传附件将被清除且无法恢复");
792
+ expect(devShell).toContain("保留草稿");
793
+ expect(devShell).toContain("确认丢弃");
794
+ expect(devShell).toContain('event.key === "Escape"');
795
+ expect(devShell).toContain("discardDraftCancelRef.current?.focus()");
796
+ expect(devShell).toContain("discardDraftTriggerRef.current?.focus()");
797
+ });
798
+
799
+ it("DevShell 对齐 Issue 搜索和 Markdown 预览高频快捷键", () => {
800
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
801
+
802
+ expect(devShell).toContain('event.key === "/" && (event.metaKey || event.ctrlKey)');
803
+ expect(devShell).toContain('aria-keyshortcuts="Meta+/ Control+/"');
804
+ expect(devShell).toContain('aria-label="清除 Issue 搜索"');
805
+ expect(devShell).not.toContain('role="combobox" aria-expanded={visibleSearchSuggestions.length > 0}');
806
+ expect(devShell).toContain("[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none");
807
+ expect(devShell).toContain("const clearIssueSearch = () =>");
808
+ expect(devShell).toContain('if (event.key === "Escape" && searchInput)');
809
+ expect(devShell).toContain('updateIssueQuery({ q: "", searchIn: "", offset: 0 })');
810
+ expect(devShell).toContain('issueSearchInputRef.current?.focus()');
811
+ expect(devShell).toContain('aria-keyshortcuts="Alt+ArrowLeft"');
812
+ expect(devShell).toContain('aria-keyshortcuts="C"');
813
+ expect(devShell).toContain('aria-keyshortcuts="Escape"');
814
+ expect(devShell).toContain("data-localapp-issue-link");
815
+ expect(devShell).toContain('aria-keyshortcuts="J K ArrowDown ArrowUp O Enter"');
816
+ expect(devShell).toContain('const issueFilterShortcutLabels: Record<string, string> = { u: "按创建者筛选", l: "按标签筛选", m: "按里程碑筛选", a: "按负责人筛选" }');
817
+ expect(devShell).toContain('aria-keyshortcuts="U"');
818
+ expect(devShell).toContain('aria-keyshortcuts="L"');
819
+ expect(devShell).toContain('aria-keyshortcuts="M"');
820
+ expect(devShell).toContain('aria-keyshortcuts="A"');
821
+ const issueTitleLink = devShell.split("<a href={createDevIssueHref(issue.id)} data-localapp-issue-link")[1]?.split("</a>")[0] ?? "";
822
+ expect(issueTitleLink).toContain("focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-localapp-dev-focus");
823
+ expect(devShell).toContain('querySelectorAll<HTMLAnchorElement>("[data-localapp-issue-link]")');
824
+ expect(devShell).toContain('issueNavigationKey === "j"');
825
+ expect(devShell).toContain('issueNavigationKey === "k"');
826
+ expect(devShell).toContain('event.key === "ArrowDown"');
827
+ expect(devShell).toContain('event.key === "ArrowUp"');
828
+ expect(devShell).toContain("links.includes(document.activeElement as HTMLAnchorElement)");
829
+ expect(devShell).toContain('event.key === "ArrowLeft" && event.altKey');
830
+ expect(devShell).toContain("!nestedDialog");
831
+ expect(devShell).toContain('event.key.toLowerCase() === "p" && event.shiftKey');
832
+ expect(devShell).toContain('aria-keyshortcuts="Meta+Shift+P Control+Shift+P"');
833
+ expect(devShell).toContain('if (event.key === "Escape" && visibleSearchSuggestions.length > 0) { event.preventDefault(); event.stopPropagation();');
834
+ });
835
+
836
+ it("DevShell Issue 附件以受控 URL 渲染图片预览和普通文件链接", () => {
837
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
838
+
839
+ expect(devShell).toContain("isDevIssueSafeImage");
840
+ expect(devShell).toContain("attachment.url");
841
+ expect(devShell).not.toContain("attachments/${attachment.id}?${new URLSearchParams");
842
+ expect(devShell).toContain("attachment.comment_id === comment.id");
843
+ expect(devShell).toContain("attachment.issue_id === detail.issue.id && attachment.comment_id === null");
844
+ expect(devShell).toContain("alt={attachment.file_name}");
845
+ expect(devShell).toContain("formatDevIssueFileSize");
846
+ });
847
+
848
+ it("DevShell 阅读态过滤 Markdown 已引用附件且保留编辑态管理", () => {
849
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
850
+
851
+ expect(devShell).toContain("function collectReferencedDevIssueAttachmentIds(");
852
+ expect(devShell).toContain('node.type === "image" || node.type === "link"');
853
+ expect(devShell).toContain("function filterUnreferencedDevIssueAttachments(");
854
+ expect(devShell).toContain("const unreferencedCommentAttachments = filterUnreferencedDevIssueAttachments(comment.body, commentAttachments)");
855
+ expect(devShell).toContain("<DevIssueAttachmentLinks attachments={unreferencedCommentAttachments}");
856
+ expect(devShell).toContain('filterUnreferencedDevIssueAttachments(detail.issue.description ?? "", detail.attachments.filter');
857
+ expect(devShell).toContain("<DevIssueAttachmentLinks attachments={visibleCommentAttachments} onRemove=");
858
+ expect(devShell).toContain("<DevIssueAttachmentLinks attachments={visibleIssueAttachments} onRemove=");
859
+ });
860
+
861
+ it("DevShell 只向具状态权限的用户显示评论并关闭或重开", () => {
862
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
863
+
864
+ expect(devShell).toContain("canChangeStatus={canManageIssue}");
865
+ expect(devShell).toContain("canChangeStatus?: boolean");
866
+ expect(devShell).toContain('canChangeStatus && status === "open"');
867
+ expect(devShell).toContain('canChangeStatus && status === "closed"');
868
+ });
869
+
870
+ it("statusAction 成功后同步详情并刷新服务端权威列表", () => {
871
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
872
+
873
+ expect(devShell).toContain("syncIssueStatusAcrossViews");
874
+ expect(devShell).toContain("current.map((issue) => issue.id === updatedIssue.id ? updatedIssue : issue)");
875
+ expect(devShell).toContain("await Promise.all([loadIssueDetail(issue.id), fetchIssues(query)])");
876
+ expect(devShell).toContain("requestDevIssue<DevIssueDetail>(`/api/issues/${detail.issue.id}/comments`");
877
+ expect(devShell).toContain("syncIssueDetailAcrossViews(commentDetail)");
878
+ expect(devShell).not.toContain("commentResult.issue");
879
+ expect(devShell).toContain("onIssuesChanged()");
880
+ expect(devShell).not.toContain("setStatus(nextStatus)");
881
+ });
882
+
883
+ it("DELETE comment 使用 pagePath query 且不发送 JSON body", () => {
884
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
885
+ const start = devShell.indexOf("const deleteComment");
886
+ const end = devShell.indexOf("const deleteCurrentIssue", start);
887
+ const deleteComment = devShell.slice(start, end);
888
+
889
+ expect(deleteComment).toContain("new URLSearchParams({ pagePath })");
890
+ expect(deleteComment).toContain("/comments/${commentId}?${requestQuery.toString()}");
891
+ expect(deleteComment).toContain('method: "DELETE"');
892
+ expect(deleteComment).not.toContain('headers: { "Content-Type": "application/json" }');
893
+ expect(deleteComment).not.toContain("body: JSON.stringify");
894
+ });
895
+
896
+ it("composer 在附件上传中或失败时显示错误并拒绝任何提交", () => {
897
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
898
+
899
+ expect(devShell).toContain("hasBlockingIssueAttachments");
900
+ expect(devShell).toContain('attachment.status === "uploading"');
901
+ expect(devShell).toContain('attachment.status === "error"');
902
+ expect(devShell).toContain("请移除或重试上传失败的附件");
903
+ expect(devShell).toContain("if (hasBlockingIssueAttachments) return");
904
+ expect(devShell).toContain("disabled={submitting || hasBlockingIssueAttachments || contentMissing || submitDisabled}");
905
+ expect(devShell).toContain('attachment.status === "uploading" && <LoaderCircle className="h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none" aria-hidden="true" />');
906
+ expect(devShell).not.toContain('className="animate-pulse text-localapp-dev-muted-foreground">上传中</span>');
907
+ expect(devShell).toContain('<Upload className="h-3.5 w-3.5" aria-hidden="true" />添加附件');
908
+ expect(devShell).toContain('title={`重试 ${attachment.fileName}`}');
909
+ expect(devShell).toContain('<RotateCw className="h-3.5 w-3.5" aria-hidden="true" />');
910
+ expect(devShell).toContain('title={`移除 ${attachment.fileName}`}');
911
+ expect(devShell).toContain('<Trash2 className="h-3.5 w-3.5" aria-hidden="true" />');
912
+ expect(devShell).toContain("h-11 w-11 shrink-0 sm:h-7 sm:w-7");
913
+ });
914
+
915
+ it("附件上传只接受最新代次,且提交、移除和卸载均使旧结果失效", () => {
916
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
917
+
918
+ expect(devShell).toContain("issueAttachmentUploadGenerationsRef");
919
+ expect(devShell).toContain("nextIssueAttachmentUploadGeneration");
920
+ expect(devShell).toContain("issueAttachmentUploadGenerationsRef.current.get(pending.clientId) !== generation");
921
+ expect(devShell).toContain("uploadIssueAttachment(pending, nextIssueAttachmentUploadGeneration(pending.clientId))");
922
+ expect(devShell).toContain("nextIssueAttachmentUploadGeneration(attachment.clientId)");
923
+ expect(devShell).toContain("issueAttachmentUploadGenerationsRef.current.clear()");
924
+ expect(devShell).toContain("revokeDevIssueAttachmentPreview");
925
+ expect(devShell).toContain("releaseDevIssueAttachments");
926
+ expect(devShell).toContain("releaseDevIssueAttachments(attachments)");
927
+ });
928
+
929
+ it("DevShell 只持久化已上传附件并恢复原 draftId", () => {
930
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
931
+
932
+ expect(devShell).toContain("readDevIssueAttachmentDraft");
933
+ expect(devShell).toContain("writeDevIssueAttachmentDraft");
934
+ expect(devShell).toContain('attachment.url.startsWith("/api/issues/attachments/")');
935
+ expect(devShell).toContain('item.status === "uploaded" && item.attachment');
936
+ expect(devShell).toContain("initialAttachmentDraft?.draftId ?? draftId");
937
+ expect(devShell).toContain("draftId: activeDraftId");
938
+ expect(devShell).toContain("fileName: attachment.file_name");
939
+ expect(devShell).toContain("previewUrl: isDevIssueSafeImage(attachment.mime_type) ? attachment.url : null");
940
+ });
941
+
942
+ it("Issue 工作台关闭时恢复 opener 焦点并限制 Tab 在 dialog 内", () => {
943
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
944
+
945
+ expect(devShell).toContain("DEV_ISSUE_FOCUSABLE_SELECTOR");
946
+ expect(devShell).toContain("previouslyFocused");
947
+ expect(devShell).toContain("previouslyFocused.focus()");
948
+ expect(devShell).toContain('event.key === "Tab"');
949
+ expect(devShell).toContain("focusableElements[0]");
950
+ expect(devShell).toContain("focusableElements[focusableElements.length - 1]");
951
+ });
952
+
953
+ it("Issue 工作台与遮罩只铺满应用内容区并移除小窗宽度限制", () => {
954
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
955
+ const start = devShell.indexOf("function DevIssuesWorkspace");
956
+ const end = devShell.indexOf("function DevIssueStatusIcon", start);
957
+ const workspace = devShell.slice(start, end);
958
+
959
+ expect(workspace).toContain("data-localapp-issues-layer");
960
+ expect(workspace).toContain("absolute inset-0");
961
+ expect(workspace).toContain("h-full w-full");
962
+ expect(workspace).toContain("sm:p-2");
963
+ expect(workspace).not.toContain("fixed inset-0");
964
+ expect(workspace).not.toContain("max-w-[680px]");
965
+ expect(workspace).not.toContain("max-h-[calc(100vh-2rem)]");
966
+ expect(workspace).toContain('className="pointer-events-none absolute inset-0 bg-black/45"');
967
+ expect(workspace).not.toContain('className="absolute inset-0 bg-black/45" aria-hidden="true" onClick={onClose}');
968
+ });
969
+
970
+ it("DevShell 用保留查询参数同步 Issue 直达与浏览器历史", () => {
971
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
972
+
973
+ expect(devShell).toContain('const DEV_ISSUE_DEEP_LINK_PARAM = "localappIssueId"');
974
+ expect(devShell).toContain("readDevIssueDeepLinkId");
975
+ expect(devShell).toContain("updateDevIssueDeepLinkUrl");
976
+ expect(devShell).toContain('window.addEventListener("popstate"');
977
+ expect(devShell).toContain("selectedIssueId={selectedIssueId}");
978
+ expect(devShell).toContain("onIssueNavigate={navigateToIssue}");
979
+ expect(devShell).toContain("url.searchParams.delete(DEV_ISSUE_DEEP_LINK_PARAM)");
980
+ expect(devShell).toContain("deepLinkAttemptKeyRef");
981
+ expect(devShell).toContain('const attemptKey = `${pagePath}:${selectedIssueId}`');
982
+ });
983
+
984
+ it("DevShell Issue 列表使用原生链接并在详情提供复制入口", () => {
985
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
986
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
987
+ const detail = devShell.slice(devShell.indexOf("function DevIssueDetailPanel"), devShell.indexOf("function DevToolkitSidebar"));
988
+
989
+ expect(workspace).toContain("<a href={createDevIssueHref(issue.id)}");
990
+ expect(workspace).toContain("isPlainDevIssueLinkClick(event)");
991
+ expect(workspace).toContain("flex min-h-11 max-w-full items-center");
992
+ const issueRow = workspace.split("data-localapp-issue-row")[1]?.split(">{canBulkManage")[0] ?? "";
993
+ expect(issueRow).toContain("focus-within:bg-localapp-dev-muted");
994
+ expect(workspace).toContain("sm:min-h-6");
995
+ expect(workspace).toContain("(issue.comment_count ?? 0) > 0");
996
+ expect(workspace).toContain('aria-label={`${issue.issue_number} 的评论数 ${issue.comment_count}`}');
997
+ const commentCountLink = workspace.split('aria-label={`${issue.issue_number} 的评论数 ${issue.comment_count}`}')[1]?.split("</a>")[0] ?? "";
998
+ expect(commentCountLink).toContain("focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-localapp-dev-focus");
999
+ expect(workspace).toContain('aria-hidden="true" className="h-11 w-11 shrink-0');
1000
+ expect(workspace).toContain("sm:h-6 sm:w-10");
1001
+ expect(workspace).toContain("event.preventDefault()");
1002
+ expect(detail).toContain('aria-label={linkCopied ? "已复制 Issue 链接" : "复制 Issue 链接"}');
1003
+ expect(detail).toContain("flex shrink-0 items-center gap-1");
1004
+ expect(detail).toContain("h-11 w-11 sm:h-8 sm:w-8");
1005
+ expect(detail).toContain("copyDevIssueUrl(createDevIssueHref(detail.issue.id))");
1006
+ expect(detail).toContain("无法复制 Issue 链接");
1007
+ });
1008
+
1009
+ it("DevShell 为 Issue 正文和评论提供与 Platform 同构的 reactions", () => {
1010
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1011
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
1012
+ const reactions = devShell.slice(devShell.indexOf("const DEV_ISSUE_REACTION_EMOJI"), devShell.indexOf("function DevIssueTimeline"));
1013
+ const detail = devShell.slice(devShell.indexOf("function DevIssueDetailPanel"), devShell.indexOf("function DevToolkitSidebar"));
1014
+
1015
+ expect(devShell).toContain('const DEV_ISSUE_REACTION_CONTENTS = ["+1", "-1", "laugh", "hooray", "confused", "heart", "rocket", "eyes"] as const');
1016
+ expect(workspace).toContain("/reactions`");
1017
+ expect(workspace).toContain("content, reacted");
1018
+ expect(reactions).toContain("data-localapp-issue-reactions");
1019
+ expect(reactions).toContain('aria-label="添加表态"');
1020
+ expect(devShell).toContain("SmilePlus");
1021
+ expect(reactions).toContain('<SmilePlus aria-hidden="true" className="h-4 w-4" />');
1022
+ expect(reactions).toContain('aria-haspopup="menu"');
1023
+ expect(reactions).toContain('role="menu"');
1024
+ expect(reactions).toContain('role="menuitemcheckbox"');
1025
+ expect(reactions).toContain('aria-checked={selected}');
1026
+ expect(reactions).toContain('selected ? "取消" : "添加"');
1027
+ expect(reactions).toContain('void toggle(content, !selected)');
1028
+ expect(reactions).toContain('["ArrowRight", "ArrowLeft", "ArrowDown", "ArrowUp", "Home", "End"]');
1029
+ expect(reactions).toContain('event.key === "Escape"');
1030
+ expect(reactions).toContain("reactionTriggerRef.current?.focus()");
1031
+ expect(reactions).not.toContain("if (additionsDisabled) currentUserId = undefined");
1032
+ expect(reactions).toContain("disabled={pendingContent !== null || (additionsDisabled && !selected)}");
1033
+ expect(reactions).toContain("{currentUserId && !additionsDisabled && <>");
1034
+ expect(reactions).toContain("return currentUserId");
1035
+ expect(reactions).toContain("${count} 个表态");
1036
+ expect(reactions).toContain('aria-label="选择表态"');
1037
+ expect(reactions).toContain('${selected ? "取消" : "添加"} ${DEV_ISSUE_REACTION_EMOJI[content]} 表态');
1038
+ expect(reactions).toContain("onToggleReaction(content, reacted");
1039
+ expect(reactions).toContain("if (additionsDisabled || !currentUserId) setPickerOpen(false)");
1040
+ expect(reactions).toContain("if (additionsDisabled || !currentUserId) setReactionError");
1041
+ expect(reactions).toContain("const [reactionError, setReactionError]");
1042
+ expect(reactions).toContain('role="alert"');
1043
+ expect(reactions).toContain(': <span key={content} aria-label={label}');
1044
+ expect(reactions).toContain("h-11 min-w-11");
1045
+ expect(reactions).toContain("h-11 w-11 rounded-full");
1046
+ expect(reactions).toContain("h-11 w-11 text-base sm:h-8 sm:w-8");
1047
+ expect(reactions).toContain("bottom-12");
1048
+ expect(reactions).toContain("sm:bottom-9");
1049
+ expect(reactions).not.toContain("top-12");
1050
+ expect(reactions).not.toContain('<span aria-hidden="true">+</span>');
1051
+ expect(detail).toContain("reactions={detail.reactions ?? []}");
1052
+ expect(detail).toContain("onToggleReaction={onToggleReaction}");
1053
+ });
1054
+
1055
+ it("DevShell 提供完全离线的 Issue 对话锁定状态和操作", () => {
1056
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1057
+ expect(devShell).toContain("locked_at?: string | null");
1058
+ expect(devShell).toContain("locked_by?: string | null");
1059
+ expect(devShell).toContain('updateIssueCollaboration("lock", { locked, ...(locked && reason ? { reason } : {}) })');
1060
+ expect(devShell).toContain('aria-label={detail.issue.locked_at ? "解锁对话" : "锁定对话"}');
1061
+ expect(devShell).toContain("对话已锁定");
1062
+ expect(devShell).toContain('event.event_type === "locked"');
1063
+ expect(devShell).toContain('event.event_type === "unlocked"');
1064
+ expect(devShell).toContain('role="dialog" aria-modal="true" aria-labelledby="dev-issue-lock-title"');
1065
+ expect(devShell).toContain('aria-label="锁定原因"');
1066
+ expect(devShell).toContain("const lockDialogRef = useRef<HTMLDivElement | null>(null)");
1067
+ expect(devShell).toContain("dialog.querySelectorAll<HTMLElement>('button:not([disabled]), select:not([disabled])')");
1068
+ expect(devShell).toContain('event.key !== "Tab"');
1069
+ expect(devShell).toContain("document.activeElement === first");
1070
+ expect(devShell).toContain("document.activeElement === last");
1071
+ expect(devShell).toContain("window.requestAnimationFrame(() => window.requestAnimationFrame(() => lockTriggerRef.current?.focus()))");
1072
+ expect(devShell).toContain("DEV_ISSUE_LOCK_REASON_LABELS");
1073
+ expect(devShell).toContain('onToggleLock(true, lockReason)');
1074
+ });
1075
+
1076
+ it("DevShell 折叠同一用户连续编辑事件并保留可展开的原始时间", () => {
1077
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1078
+ expect(devShell).toContain("function groupDevIssueTimeline(");
1079
+ expect(devShell).toContain('next.event.actor_id !== item.event.actor_id');
1080
+ expect(devShell).toContain("function DevIssueEditEventGroup(");
1081
+ expect(devShell).toContain('aria-expanded={expanded}');
1082
+ expect(devShell).toContain('编辑了此 Issue {item.events.length} 次');
1083
+ expect(devShell).toContain('visibleDisplayTimeline.map((item) => item.kind === "event-group"');
1084
+ });
1085
+
1086
+ it("DevShell 折叠连续历史事件批次并可展开完整动作", () => {
1087
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1088
+ expect(devShell).toContain('groupType: "edited" | "history"');
1089
+ expect(devShell).toContain("DEV_ISSUE_HISTORY_BATCH_THRESHOLD = 4");
1090
+ expect(devShell).toContain('groupType: "history"');
1091
+ expect(devShell).toContain("function DevIssueHistoryEventGroup(");
1092
+ expect(devShell).toContain('aria-label={`历史更新明细,共 ${item.events.length} 项`}');
1093
+ expect(devShell).toContain("devIssueEventText(event, identities)");
1094
+ expect(devShell).toContain("<DevIssueTime timestamp={event.created_at} precise />");
1095
+ });
1096
+
1097
+ it("DevShell 提供完全离线的时间线活动筛选、计数和空态", () => {
1098
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1099
+ expect(devShell).toContain('type DevIssueTimelineFilter = "all" | "comments" | "history"');
1100
+ expect(devShell).toContain("function filterDevIssueTimeline(");
1101
+ expect(devShell).toContain('role="radiogroup" aria-label="筛选时间线活动"');
1102
+ expect(devShell).toContain('className="shrink-0 whitespace-nowrap text-xs font-medium text-localapp-dev-muted-foreground">活动</span>');
1103
+ expect(devShell).toContain('role="radiogroup" aria-label="筛选时间线活动" className="grid w-full grid-cols-3');
1104
+ expect(devShell).toContain('aria-label={`显示更早的 ${hiddenTimelineCount} 条活动`}');
1105
+ expect(devShell).toContain("DEV_ISSUE_TIMELINE_PAGE_SIZE = 20");
1106
+ expect(devShell).toContain("setVisibleActivityCount((count) => count + DEV_ISSUE_TIMELINE_PAGE_SIZE)");
1107
+ expect(devShell).toContain("hiddenTimelineCount <= DEV_ISSUE_TIMELINE_PAGE_SIZE");
1108
+ expect(devShell).toContain("revealEarlierRef.current?.focus()");
1109
+ expect(devShell).not.toContain("showAllActivity");
1110
+ expect(devShell).toContain('className="mt-4 grid w-full grid-cols-2 gap-2 sm:ml-auto sm:w-fit');
1111
+ expect(devShell).toContain("h-11 rounded px-2.5 text-xs font-medium");
1112
+ expect(devShell).toContain("sm:h-7");
1113
+ expect(devShell).toContain('role="radio" aria-checked={activityFilter === option.value}');
1114
+ expect(devShell).toContain('tabIndex={activityFilter === option.value ? 0 : -1}');
1115
+ expect(devShell).toContain('event.key === "Home"');
1116
+ expect(devShell).toContain('event.key === "End"');
1117
+ expect(devShell).toContain('setActivityFilter("all")');
1118
+ expect(devShell).toContain('filterDevIssueTimeline(timeline, activityFilter)');
1119
+ expect(devShell).toContain('activityFilter === "comments" ? "还没有评论"');
1120
+ });
1121
+
1122
+ it("DevShell 在正文和提交者评论中显示 Author 身份徽标", () => {
1123
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1124
+ expect(devShell).toContain("badge?: React.ReactNode");
1125
+ expect(devShell).toContain('badge={comment.author_id === reporterId ? "Author" : undefined}');
1126
+ expect(devShell).toContain('badge="Author"');
1127
+ expect(devShell).toContain('timestampHref={createDevIssueHref(detail.issue.id)}');
1128
+ expect(devShell).toContain('const localizedBadge = badge === "Author" ? "作者" : badge');
1129
+ expect(devShell).toContain('timestampSuffix.props.children === "edited"');
1130
+ expect(devShell).toContain('children: "已编辑"');
1131
+ expect(devShell).toContain('data-localapp-issue-actor-action className="shrink-0 self-start"');
1132
+ const timeline = devShell.slice(devShell.indexOf("function DevIssueTimeline"), devShell.indexOf("function revokeDevIssueAttachmentPreview"));
1133
+ expect(timeline).toContain('action={!comment.deleted_at ? <DevIssueActionMenu label="评论操作"');
1134
+ expect(timeline).not.toContain('flex flex-wrap items-center justify-between gap-2 border-b border-localapp-dev-border');
1135
+ });
1136
+
1137
+ it("DevShell 在详情头部显示创建时间、可见评论数和首评链接", () => {
1138
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1139
+ const detail = devShell.slice(devShell.indexOf("function DevIssueDetailPanel"), devShell.indexOf("function DevToolkitSidebar"));
1140
+ expect(detail).toContain('item is Extract<DevIssueTimelineItem, { kind: "comment" }>');
1141
+ expect(detail).toContain('<DevIssueTime timestamp={detail.issue.created_at} />');
1142
+ expect(detail).toContain('href={createDevIssueCommentHref(detail.issue.id, firstVisibleComment.comment.id)}');
1143
+ expect(detail).toContain("inline-flex h-11 items-center px-1");
1144
+ expect(detail).toContain('{visibleComments.length} 条评论');
1145
+ expect(detail).toContain('<span>0 条评论</span>');
1146
+ expect(detail).toContain("打开了此 Issue");
1147
+ expect(detail).toContain('className="inline-flex items-center gap-2 whitespace-nowrap"');
1148
+ expect(detail).toContain('className="hidden sm:inline" aria-hidden="true">·</span>');
1149
+ });
1150
+
1151
+ it("DevShell 显示并局部丢弃新建与评论的恢复草稿", () => {
1152
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1153
+ const composer = devShell.slice(devShell.indexOf("function DevIssueComposer"), devShell.indexOf("function DevIssueDetailPanel"));
1154
+ expect(composer).toContain("showRestoredDraftNotice?: boolean");
1155
+ expect(composer).toContain("onDiscardRestoredDraft?: () => void");
1156
+ expect(composer).toContain("已恢复未提交的草稿");
1157
+ expect(composer).toContain("丢弃草稿");
1158
+ expect(composer).toContain("DevIssueDiscardDraftControl");
1159
+ expect(composer).toContain('writeDevIssueSessionDraft(persistenceKey, "")');
1160
+ expect(devShell).toContain("showRestoredDraftNotice restoredDraft={createWasRestoredDraft}");
1161
+ expect(devShell).toContain('writeDevIssueCreateDraft(createPersistenceKey, "", "task", [], [], null)');
1162
+ expect(devShell).toContain('persistenceKey={`${issueDraftPrefix}:comment:${detail.issue.id}:body`} showRestoredDraftNotice');
1163
+ });
1164
+
1165
+ it("DevShell owner 可在创建时原子提交附加标签与负责人", () => {
1166
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1167
+
1168
+ expect(devShell).toContain("const [createLabelIds, setCreateLabelIds]");
1169
+ expect(devShell).toContain("const [createAssigneeIds, setCreateAssigneeIds]");
1170
+ expect(devShell).toContain("data-localapp-create-metadata");
1171
+ expect(devShell).toContain('user?.role === "owner"');
1172
+ expect(devShell).toContain('labelIds: createLabelIds');
1173
+ expect(devShell).toContain("issueType, draftId, attachmentIds");
1174
+ expect(devShell).toContain('(["task", "bug", "feature"] as const)');
1175
+ expect(devShell).toContain("assigneeIds: createAssigneeIds");
1176
+ expect(devShell).toContain('id !== "bug" && id !== "feature"');
1177
+ expect(devShell).toContain("milestoneId: number | null");
1178
+ expect(devShell).toContain("Number.isSafeInteger(value?.milestoneId)");
1179
+ expect(devShell).toContain('milestoneCatalogLoaded && createMilestoneId !== null && !availableMilestones.some((item) => item.id === createMilestoneId)');
1180
+ expect(devShell).toContain("writeDevIssueCreateDraft(createPersistenceKey, createTitle, issueType, createLabelIds, createAssigneeIds, createMilestoneId)");
1181
+ expect(devShell).toContain('writeDevIssueCreateDraft(createPersistenceKey, "", "task", [], [], null)');
1182
+ });
1183
+
1184
+ it("DevShell 将 Issue 类型作为独立的列表和 URL 筛选条件", () => {
1185
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1186
+ expect(devShell).toContain('issueType: "localappIssueType"');
1187
+ expect(devShell).toContain('requestQuery.set("type", nextQuery.issueType)');
1188
+ expect(devShell).toContain('aria-label="按类型筛选"');
1189
+ expect(devShell).toContain('<DevIssueTypeBadge issue={issue}');
1190
+ expect(devShell).toContain('DEV_ISSUE_TYPE_LABELS[detail.issue.issue_type ?? detail.issue.label]');
1191
+ expect(devShell).toContain('aria-label="设置 Issue 类型"');
1192
+ expect(devShell).toContain('onSetIssueType={(issueType) => onUpdateIssue({ issueType })}');
1193
+ });
1194
+
1195
+ it("DevShell 为文件拖拽提供稳定激活态和无障碍提示", () => {
1196
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1197
+ const composer = devShell.slice(devShell.indexOf("function DevIssueComposer"), devShell.indexOf("function DevIssueDetailPanel"));
1198
+ expect(composer).toContain("const [dragActive, setDragActive] = useState(false)");
1199
+ expect(composer).toContain("const dragDepthRef = useRef(0)");
1200
+ expect(composer).toContain('includes("Files")');
1201
+ expect(composer).toContain('data-drag-active={dragActive ? "true" : undefined}');
1202
+ expect(composer).toContain('aria-label="附件拖拽状态"');
1203
+ expect(composer).toContain("松开以上传文件");
1204
+ expect(composer).toContain("dragDepthRef.current = 0");
1205
+ });
1206
+
1207
+ it("DevShell 从评论引用创建独立的本地 Issue 草稿", () => {
1208
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1209
+ expect(devShell).toContain('label: "引用到新 Issue"');
1210
+ expect(devShell).toContain("referenceDevIssueComment(");
1211
+ expect(devShell).toContain("reference-comment:${source.issue.id}:${commentId}");
1212
+ expect(devShell).toContain("原评论保持不变,提交后将创建独立 Issue。");
1213
+ expect(devShell).toContain("onReferenceComment={onReferenceComment}");
1214
+ expect(devShell).toContain("onClick={cancelCreateIssue}");
1215
+ expect(devShell).toContain('`[data-localapp-issue-comment-id="${commentId}"] button[aria-label="评论操作"]`');
1216
+ expect(devShell).toContain("window.setTimeout(focusCommentMenu, 150)");
1217
+ });
1218
+
1219
+ it("DevShell 自动揭示被活动筛选隐藏的有效评论深链", () => {
1220
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1221
+ const timeline = devShell.slice(devShell.indexOf("function DevIssueTimeline"), devShell.indexOf("function revokeDevIssueAttachmentPreview"));
1222
+ const detail = devShell.slice(devShell.indexOf("function DevIssueDetailPanel"), devShell.indexOf("function DevToolkitSidebar"));
1223
+ expect(timeline).toContain("const selectedCommentVisible = Boolean(");
1224
+ expect(timeline).toContain('if (selectedCommentVisible) setActivityFilter("comments")');
1225
+ expect(timeline).toContain('activityFilter !== "comments"');
1226
+ expect(timeline).toContain("!item.comment.deleted_at");
1227
+ expect(detail).toContain('href={createDevIssueCommentHref(detail.issue.id, firstVisibleComment.comment.id)}');
1228
+ });
1229
+
1230
+ it("DevShell 统一相对时间并保留精确语义提示", () => {
1231
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1232
+ expect(devShell).toContain("function formatDevIssueRelativeTime(");
1233
+ expect(devShell).toContain("function DevIssueTime(");
1234
+ expect(devShell).toContain("if (!Number.isFinite(milliseconds)) return timestamp");
1235
+ expect(devShell).toContain('<time dateTime={timestamp} title={exact}');
1236
+ expect(devShell).toContain('<DevIssueTime timestamp={timestamp} href={timestampHref}');
1237
+ expect(devShell).toContain("inline-flex h-11 items-center px-1");
1238
+ expect(devShell).toContain('<DevIssueTime timestamp={event.created_at} precise />');
1239
+ expect(devShell).toContain('<DevIssueTime timestamp={item.event.created_at} />');
1240
+ expect(devShell).toContain('<DevIssueTime timestamp={detail.issue.created_at} />');
1241
+ expect(devShell).toContain("<DevIssueListActivityTime issue={issue} />");
1242
+ });
1243
+
1244
+ it("DevShell 以紧凑头像 roster 展示参与者和溢出计数", () => {
1245
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1246
+ expect(devShell).toContain("function DevIssueParticipantRoster(");
1247
+ expect(devShell).toContain("participantIds.slice(0, 8)");
1248
+ expect(devShell).toContain('aria-label="Issue 参与者"');
1249
+ expect(devShell).toContain('aria-label={`另外 ${overflow} 位参与者`}');
1250
+ expect(devShell).toContain("<DevIssueParticipantRoster participantIds={participantIds} identities={identities} />");
1251
+ });
1252
+
1253
+ it("DevShell 将正文与评论低频动作收纳到同构操作菜单", () => {
1254
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1255
+ const actionMenu = devShell.slice(devShell.indexOf("function DevIssueActionMenu"), devShell.indexOf("const DEV_ISSUE_REACTION_EMOJI"));
1256
+ const timeline = devShell.slice(devShell.indexOf("function DevIssueTimeline"), devShell.indexOf("function revokeDevIssueAttachmentPreview"));
1257
+ const detail = devShell.slice(devShell.indexOf("function DevIssueDetailPanel"), devShell.indexOf("function DevToolkitSidebar"));
1258
+
1259
+ expect(actionMenu).toContain('aria-haspopup="menu"');
1260
+ expect(actionMenu).toContain("const menuId = React.useId()");
1261
+ expect(actionMenu).toContain("aria-controls={menuId}");
1262
+ expect(actionMenu).toContain("id={menuId}");
1263
+ expect(actionMenu).toContain('role="menu"');
1264
+ expect(actionMenu).toContain('role="menuitem"');
1265
+ expect(actionMenu).toContain("h-11 w-11 sm:h-8 sm:w-8");
1266
+ expect(actionMenu).toContain("min-h-11");
1267
+ expect(actionMenu).toContain('event.key === "Escape"');
1268
+ expect(actionMenu).toContain('document.addEventListener("mousedown"');
1269
+ expect(actionMenu).toContain('document.addEventListener("keydown", onKeyDown, true)');
1270
+ expect(actionMenu).toContain("triggerRef.current?.focus()");
1271
+ expect(actionMenu).toContain('initialFocusRef = useRef<"first" | "last">("first")');
1272
+ expect(actionMenu).toContain('event.key !== "ArrowDown" && event.key !== "ArrowUp"');
1273
+ expect(devShell).toContain("restoreFocus?: boolean");
1274
+ expect(actionMenu).toContain("close(item.restoreFocus !== false)");
1275
+ expect(timeline).toContain('label: "复制评论链接"');
1276
+ expect(timeline).toContain('label: "引用回复", restoreFocus: false');
1277
+ expect(actionMenu).toContain('event.key === "Home"');
1278
+ expect(actionMenu).toContain('event.key === "End"');
1279
+ expect(actionMenu).toContain("startsWith(key)");
1280
+ expect(actionMenu).toContain("!item.disabled");
1281
+ expect(actionMenu).toContain("if (items.length === 0) setOpen(false)");
1282
+ expect(actionMenu).toContain("rootRef.current?.contains(document.activeElement)");
1283
+ expect(timeline).toContain('label="评论操作"');
1284
+ expect(timeline).toContain('label: "编辑评论"');
1285
+ expect(timeline).toContain('label: "删除评论", restoreFocus: false, destructive: true');
1286
+ expect(detail).toContain('label="Issue 操作"');
1287
+ expect(detail).toContain('label: "编辑 Issue"');
1288
+ expect(detail).toContain('label: "引用回复", restoreFocus: false');
1289
+ expect(detail).toContain("quoteDevIssueComment(detail.issue.description ?? \"\", detail.issue.reporter_id)");
1290
+ expect(detail).not.toContain('aria-label="编辑 Issue"');
1291
+ });
1292
+
1293
+ it("DevShell 将评论引用追加到现有草稿并聚焦 composer", () => {
1294
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1295
+ const timeline = devShell.slice(devShell.indexOf("function DevIssueTimeline"), devShell.indexOf("function revokeDevIssueAttachmentPreview"));
1296
+ const composer = devShell.slice(devShell.indexOf("function DevIssueComposer"), devShell.indexOf("function DevIssueMetadata"));
1297
+ const detail = devShell.slice(devShell.indexOf("function DevIssueDetailPanel"), devShell.indexOf("function DevToolkitSidebar"));
1298
+
1299
+ expect(devShell).toContain("function quoteDevIssueComment");
1300
+ expect(timeline).toContain('label: "引用回复"');
1301
+ expect(timeline).toContain("onQuoteComment(comment.body, comment.author_id)");
1302
+ expect(timeline).toContain('...(currentUserId && !interactionsLocked ? [{ label: "引用回复"');
1303
+ expect(composer).toContain("insertRequest");
1304
+ expect(composer).toContain('current.trim() ? `${current}\\n\\n${insertRequest.text}` : insertRequest.text');
1305
+ expect(composer).toContain('setMode("edit")');
1306
+ expect(composer).toContain("selectionRestorePendingRef.current = true");
1307
+ expect(detail).toContain("commentInsertRequest");
1308
+ expect(detail).toContain("onInsertRequestApplied");
1309
+ });
1310
+
1311
+ it("DevShell 提供保留应用 URL 状态的评论 permalink 和直达定位", () => {
1312
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1313
+ const timeline = devShell.slice(devShell.indexOf("function DevIssueTimeline"), devShell.indexOf("function revokeDevIssueAttachmentPreview"));
1314
+ const detail = devShell.slice(devShell.indexOf("function DevIssueDetailPanel"), devShell.indexOf("function DevToolkitSidebar"));
1315
+
1316
+ expect(devShell).toContain('const DEV_ISSUE_COMMENT_DEEP_LINK_PARAM = "localappIssueCommentId"');
1317
+ expect(devShell).toContain("readDevIssueCommentDeepLinkId");
1318
+ expect(devShell).toContain("updateDevIssueCommentDeepLinkUrl");
1319
+ expect(devShell).toContain("createDevIssueCommentHref");
1320
+ expect(timeline).toContain('label: "复制评论链接"');
1321
+ expect(timeline).toContain('aria-current={selectedCommentId === comment.id && !comment.deleted_at ? "location" : undefined}');
1322
+ expect(timeline).toContain("scrollIntoView?.({ block: \"center\" })");
1323
+ expect(timeline).toContain('aria-live="polite"');
1324
+ expect(detail).toContain("selectedCommentId={selectedCommentId}");
1325
+ expect(detail).toContain("getCommentHref");
1326
+ expect(detail).toContain("onCopyCommentLink");
1327
+ });
1328
+
1329
+ it("DevShell 从保留 URL 参数恢复列表筛选并同步浏览器历史", () => {
1330
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1331
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
1332
+
1333
+ expect(devShell).toContain('q: "localappIssueQ"');
1334
+ expect(devShell).toContain('searchIn: "localappIssueIn"');
1335
+ expect(devShell).toContain('status: "localappIssueStatus"');
1336
+ expect(devShell).toContain("readDevIssueListQueryFromUrl");
1337
+ expect(devShell).toContain("updateDevIssueListQueryUrl");
1338
+ expect(workspace).toContain('historyMode: "push" | "replace" = "push"');
1339
+ expect(workspace).toContain('window.history[historyMode === "push" ? "pushState" : "replaceState"]');
1340
+ expect(workspace).toContain('window.addEventListener("popstate", restoreIssueListQuery)');
1341
+ expect(workspace).toContain('updateIssueQuery(parseDevIssueSearchInput(searchInput');
1342
+ expect(workspace).toContain("setSearchInput(formatDevIssueSearchInput(restored.q, restored.searchIn))");
1343
+ expect(workspace).toContain("return formatDevIssueSearchInput(restored.q, restored.searchIn)");
1344
+ });
1345
+
1346
+ it("DevShell 搜索框解析 GitHub 风格限定词并同步结构化筛选", () => {
1347
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1348
+ const parser = devShell.slice(devShell.indexOf("function parseDevIssueSearchInput"), devShell.indexOf("function readDevIssueListMeta"));
1349
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
1350
+
1351
+ expect(parser).toContain('key === "is"');
1352
+ expect(parser).toContain('key === "in"');
1353
+ expect(parser).toContain('["title", "body", "comments"]');
1354
+ expect(parser).toContain('/^(locked|unlocked)$/i');
1355
+ expect(parser).toContain('key === "label"');
1356
+ expect(parser).toContain('key === "author" || key === "involves"');
1357
+ expect(parser).toContain('key === "milestone"');
1358
+ expect(parser).toContain('key === "mentions" && rawValue.toLowerCase() === "@me"');
1359
+ expect(parser).toContain('rawValue.toLowerCase() === "subscribed"');
1360
+ expect(parser).toContain('/^(assignee|label|milestone)$/i');
1361
+ expect(parser).toContain('/^(activity|created|updated|comments)-(asc|desc)$/i');
1362
+ expect(parser).toContain('rawValue.toLowerCase() === "@me"');
1363
+ expect(workspace).toContain("parseDevIssueSearchInput(searchInput");
1364
+ expect(workspace).toContain("milestones: availableMilestones");
1365
+ expect(workspace).toContain('setSearchInput(formatDevIssueSearchInput(updates.q, updates.searchIn ?? ""))');
1366
+ expect(workspace).toContain("updateIssueQuery(updates)");
1367
+ });
1368
+
1369
+ it("DevShell 搜索框提供完全离线且键盘可访问的限定词建议", () => {
1370
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1371
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
1372
+
1373
+ expect(devShell).toContain("function getDevIssueSearchSuggestions(");
1374
+ expect(devShell).toContain("function applyDevIssueSearchSuggestion(");
1375
+ expect(workspace).toContain('role="listbox" aria-label="搜索限定词建议"');
1376
+ expect(workspace).toContain('role="option"');
1377
+ expect(workspace).toContain('event.key === "ArrowDown"');
1378
+ expect(workspace).toContain('event.key === "ArrowUp"');
1379
+ expect(workspace).toContain('event.key === "Tab"');
1380
+ expect(workspace).toContain('event.key === "Escape"');
1381
+ expect(workspace).toContain("issueMentionCandidates");
1382
+ expect(devShell).toContain('add("locked", "Locked"');
1383
+ expect(devShell).toContain('add("unlocked", "Unlocked"');
1384
+ expect(devShell).toContain('["in:", "范围", "限定搜索标题、正文或评论"]');
1385
+ expect(devShell).toContain('add("comments", "评论", "仅搜索未删除评论")');
1386
+ });
1387
+
1388
+ it("DevShell 显示可单独移除且响应式换行的已应用筛选摘要", () => {
1389
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1390
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
1391
+ expect(workspace).toContain('kind: "对话"');
1392
+ expect(workspace).toContain('aria-label="对话已锁定"');
1393
+
1394
+ expect(workspace).toContain('role="region" aria-label="已应用筛选"');
1395
+ expect(workspace).toContain("appliedIssueFilters.map");
1396
+ expect(workspace).toContain('aria-label={`移除${filter.kind}筛选 ${filter.value}`}');
1397
+ expect(workspace).toContain('filter.key === "subscribed" ? { subscribed: false } : filter.key === "mentioned" ? { mentioned: false } : { [filter.key]: "" }');
1398
+ expect(workspace).toContain('aria-label="清除全部筛选"');
1399
+ expect(workspace).toContain("focusIssueSearchAfterFilterChange");
1400
+ expect(workspace).toContain("flex-wrap");
1401
+ expect(workspace).toContain("h-11 shrink-0 rounded");
1402
+ expect(workspace).toContain("sm:h-7");
1403
+ expect(workspace).toContain("issueMentionCandidates.find");
1404
+ });
1405
+
1406
+ it("DevShell 从空结果重置筛选后将焦点恢复到搜索框", () => {
1407
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1408
+ expect(devShell).toContain("const clearIssueListFiltersAndFocus = () => {");
1409
+ expect(devShell).toContain('updateIssueQuery({ q: "", searchIn: "", issueType: "", label: "", author: "", participant: "", assignee: "", milestone: "", reason: "", subscribed: false, mentioned: false, locked: "", offset: 0 })');
1410
+ expect(devShell).toContain("focusIssueSearchAfterFilterChange();");
1411
+ expect(devShell).toContain('onClick={clearIssueListFiltersAndFocus}>重置筛选</button>');
1412
+ expect(devShell).toContain('onClick={clearIssueListFiltersAndFocus} aria-label="清除全部筛选"');
1413
+ });
1414
+
1415
+ it("DevShell 支持从详情头部或 R 快捷键直接聚焦评论编辑器", () => {
1416
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1417
+ expect(devShell).toContain('data-localapp-issue-comment-composer');
1418
+ expect(devShell).toContain('aria-label="添加评论"');
1419
+ expect(devShell).toContain('aria-keyshortcuts="R"');
1420
+ expect(devShell).toContain('event.key.toLowerCase() === "r"');
1421
+ expect(devShell).toContain('view.kind === "detail" && user && dialog?.querySelector("[data-localapp-issue-comment-composer]")');
1422
+ expect(devShell).toContain("focusDevIssueCommentComposer");
1423
+ expect(devShell).toContain('matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth"');
1424
+ });
1425
+
1426
+ it("DevShell 订阅本地 Issue 失效事件并静默合并刷新", () => {
1427
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1428
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
1429
+
1430
+ expect(workspace).toContain('new EventSource(`/api/issues/events?${params.toString()}`)');
1431
+ expect(workspace).toContain('events.addEventListener("issue:changed"');
1432
+ expect(workspace).toContain('document.visibilityState === "hidden"');
1433
+ expect(workspace).toContain("const connect = (refresh: boolean) =>");
1434
+ expect(workspace).toContain('const handleVisibilityChange = () => document.visibilityState === "hidden" ? disconnect() : connect(true)');
1435
+ expect(workspace).toContain("connect(false)");
1436
+ expect(workspace).toContain('document.addEventListener("visibilitychange", handleVisibilityChange)');
1437
+ expect(workspace).toContain('document.removeEventListener("visibilitychange", handleVisibilityChange)');
1438
+ expect(workspace).toContain('window.addEventListener("blur", handleWindowBlur)');
1439
+ expect(workspace).toContain('window.addEventListener("focus", handleWindowFocus)');
1440
+ expect(workspace).toContain('window.addEventListener("pagehide", handleWindowBlur)');
1441
+ expect(workspace).toContain('window.addEventListener("pageshow", handleWindowFocus)');
1442
+ expect(workspace).toContain("if (events) return");
1443
+ expect(workspace).toContain("const changed = envelope.data");
1444
+ expect(workspace).toContain("issueEventRefreshTimerRef");
1445
+ expect(workspace).toContain("window.setTimeout");
1446
+ expect(workspace).toContain("refreshIssueDetailSilently");
1447
+ expect(workspace).toContain("void fetchIssues(issueQueryRef.current)");
1448
+ expect(workspace).toContain("events?.close()");
1449
+ expect(workspace).toContain("const [detailUpdateNotice, setDetailUpdateNotice] = useState(false)");
1450
+ expect(workspace).toContain("nextDetail.issue.updated_at !== currentDetail.issue.updated_at");
1451
+ expect(workspace).toContain('role="status" aria-label="Issue 协作更新"');
1452
+ expect(workspace).toContain("已同步最新协作活动");
1453
+ expect(workspace).toContain('aria-label="关闭协作更新提示"');
1454
+ });
1455
+
1456
+ it("DevShell 提供完全离线的 edited 标记与无障碍修订历史对话框", () => {
1457
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1458
+ const historyDialog = devShell.slice(devShell.indexOf("function DevIssueRevisionDialog"), devShell.indexOf("function DevIssueDetailPanel"));
1459
+ const detail = devShell.slice(devShell.indexOf("function DevIssueDetailPanel"), devShell.indexOf("function DevToolkitSidebar"));
1460
+
1461
+ expect(devShell).toContain("interface DevIssueRevision");
1462
+ expect(devShell).toContain("UserRound, X } from \"lucide-react\"");
1463
+ expect(historyDialog).toContain("/api/issues/${issueId}/history");
1464
+ expect(historyDialog).toContain("/api/issues/${issueId}/comments/${commentId}/history");
1465
+ expect(historyDialog).toContain('role="dialog"');
1466
+ expect(historyDialog).toContain('aria-modal="true"');
1467
+ expect(historyDialog).toContain('aria-describedby="dev-issue-history-target"');
1468
+ expect(historyDialog).toContain('id="dev-issue-history-target"');
1469
+ expect(historyDialog).toContain('aria-label="编辑历史版本"');
1470
+ expect(historyDialog).toContain('event.key === "Escape"');
1471
+ expect(historyDialog).toContain('if (event.key !== "Tab" || !dialogRef.current) return;\n event.stopPropagation();');
1472
+ expect(historyDialog).toContain("returnFocus.focus()");
1473
+ expect(historyDialog).toContain("正在加载编辑历史");
1474
+ expect(historyDialog).toContain("重试");
1475
+ expect(historyDialog).toContain("h-11 w-11 sm:h-8 sm:w-8");
1476
+ expect(historyDialog).toContain("mt-3 h-11 sm:h-8");
1477
+ expect(detail).toContain("查看 Issue 编辑历史");
1478
+ expect(detail).toContain("onViewHistory");
1479
+ expect(devShell).toContain("查看评论编辑历史");
1480
+ expect(devShell).toContain("inline-flex h-11 items-center");
1481
+ expect(devShell).toContain("sm:h-6");
1482
+ });
1483
+
1484
+ it("DevShell 使用本地身份提供键盘可访问的 mention 自动补全", () => {
1485
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1486
+ const composer = devShell.slice(devShell.indexOf("function DevIssueComposer"), devShell.indexOf("function DevIssueMetadata"));
1487
+
1488
+ expect(devShell).toContain("function findDevIssueMentionQuery");
1489
+ expect(devShell).toContain("function applyDevIssueMention");
1490
+ expect(devShell).toContain("issueMentionCandidates");
1491
+ expect(composer).toContain('aria-autocomplete="list"');
1492
+ expect(composer).toContain('role="listbox"');
1493
+ expect(composer).toContain('aria-label="提及用户建议"');
1494
+ expect(composer).not.toContain('aria-label="Mention 用户"');
1495
+ expect(composer).toContain('role="option"');
1496
+ expect(composer).toContain('aria-label={`${displayName},账号 @${candidate.id}`}');
1497
+ expect(composer).toContain('role="status" aria-label="提及用户建议状态"');
1498
+ expect(composer).toContain("没有匹配的用户");
1499
+ expect(composer).toContain('aria-activedescendant');
1500
+ expect(composer).toContain('["ArrowDown", "ArrowUp", "Enter", "Tab", "Escape"]');
1501
+ expect(composer).toContain('if (event.key === "Escape") { event.preventDefault(); event.stopPropagation(); setMentionOpen(false); return; }');
1502
+ expect(composer).toContain("selectDevIssueMention");
1503
+ expect(composer).toContain("min-h-11 w-full min-w-0");
1504
+ expect(composer).toContain("sm:min-h-10");
1505
+ expect(devShell).toContain("mentionCandidates={identities}");
1506
+ expect(devShell).not.toContain("/api/notifications");
1507
+ });
1508
+
1509
+ it("DevShell 修改草稿时清除过期的内联提交错误", () => {
1510
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1511
+ const composer = devShell.slice(devShell.indexOf("function DevIssueComposer"), devShell.indexOf("function DevIssueMetadata"));
1512
+
1513
+ expect(composer).toContain("const [submitError, setSubmitError] = useState<string | null>(null)");
1514
+ expect(composer).toMatch(/const handleDevIssueBodyChange[\s\S]*?setSubmitError\(null\);[\s\S]*?setBody\(event\.target\.value\)/);
1515
+ expect(composer).toContain('(attachmentSubmitError || submitError) && <p role="alert"');
1516
+ });
1517
+
1518
+ it("DevShell 支持不绕过阻塞条件的 composer 快捷提交", () => {
1519
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1520
+ const composer = devShell.slice(devShell.indexOf("function DevIssueComposer"), devShell.indexOf("function DevIssueMetadata"));
1521
+
1522
+ expect(composer).toContain('event.defaultPrevented || submitting || hasBlockingIssueAttachments || contentMissing || submitDisabled');
1523
+ expect(composer).toContain("event.currentTarget.requestSubmit()");
1524
+ expect(composer).toContain('aria-keyshortcuts="Meta+Enter Control+Enter"');
1525
+ expect(composer.match(/event\.nativeEvent\.isComposing \|\| event\.keyCode === 229/g)).toHaveLength(2);
1526
+ expect(composer).toContain('selectionRef.current = { start: 0, end: 0 }');
1527
+ expect(composer).toContain("setCaret(0)");
1528
+ expect(composer).toContain("setMentionOpen(false)");
1529
+ expect(composer).toContain('if (!statusAction) window.requestAnimationFrame(() => textareaRef.current?.focus())');
1530
+ expect(composer).toContain('role="status" aria-live="polite" aria-atomic="true" aria-label="提交状态"');
1531
+ expect(composer).toContain('statusAction === "close" ? "评论并关闭成功"');
1532
+ expect(composer).toContain('statusAction === "reopen" ? "重新打开并评论成功"');
1533
+ expect(composer).toContain('submitAnnouncement && (body || attachments.length > 0)');
1534
+ });
1535
+
1536
+ it("DevShell 实时详情刷新不会用远端版本重建评论 composer", () => {
1537
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1538
+ const detail = devShell.slice(devShell.indexOf("function DevIssueDetailPanel"), devShell.indexOf("function DevToolkitSidebar"));
1539
+
1540
+ expect(detail).toContain("draftId={commentDraftId}");
1541
+ expect(detail).not.toContain('key={`comment-${detail.issue.id}-${detail.issue.updated_at}`}');
1542
+ });
1543
+
1544
+ it("DevShell 详情顶栏持续显示 Issue 编号与当前标题", () => {
1545
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1546
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
1547
+
1548
+ expect(workspace).toContain('const detailTitle = view.kind === "detail" ? detail?.issue.title ?? view.issue.title : undefined');
1549
+ expect(workspace).toContain('`Issue #${view.issue.issue_number} · ${detailTitle}`');
1550
+ expect(workspace).toContain('title={detailHeaderTitle}');
1551
+ expect(workspace).toContain('className="min-w-0 truncate text-sm font-semibold"');
1552
+ });
1553
+
1554
+ it("DevShell 时间线操作结果支持连续原子播报", () => {
1555
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1556
+ const timeline = devShell.slice(devShell.indexOf("function DevIssueTimeline"), devShell.indexOf("function DevIssueComposer"));
1557
+
1558
+ expect(timeline).toContain('role="status" aria-live="polite" aria-atomic="true" aria-label="时间线操作状态"');
1559
+ expect(timeline).toContain('label: "复制评论链接", onSelect: () => { setCopyAnnouncement("");');
1560
+ expect(timeline).toContain('setCopyAnnouncement("评论链接已复制")');
1561
+ });
1562
+
1563
+ it("DevShell 不在附件上传期间关闭 Issue 工作区", () => {
1564
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1565
+
1566
+ expect(devShell).toContain("function focusBusyDevIssueAttachmentQueue()")
1567
+ expect(devShell).toContain("if (focusBusyDevIssueAttachmentQueue()) return")
1568
+ expect(devShell).toContain('data-localapp-issue-attachment-queue')
1569
+ expect(devShell).toContain('tabIndex={-1}')
1570
+ expect(devShell).toContain('if (!nextOpen && focusBusyDevIssueAttachmentQueue())')
1571
+ expect(devShell).toContain('restoreDevIssueWorkspaceHistoryUrl')
1572
+ });
1573
+
1574
+ it("DevShell 在原 Issue 行消失时把返回焦点回退到搜索框", () => {
1575
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1576
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
1577
+
1578
+ expect(workspace).toContain('if (!open || view.kind !== "list" || loading || pendingIssueFocusIdRef.current === null) return');
1579
+ expect(workspace).toContain('(link ?? issueSearchInputRef.current)?.focus()');
1580
+ expect(workspace).toContain('if (view.kind === "detail" && pendingIssueFocusIdRef.current === null) pendingIssueFocusIdRef.current = view.issue.id');
1581
+ expect(workspace).toContain('[issues, loading, open, view.kind]');
1582
+ });
1583
+
1584
+ it("DevShell 详情变更后使用服务端权威筛选刷新当前列表", () => {
1585
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1586
+ const functionBody = (name: string, nextName: string) => devShell.slice(devShell.indexOf(`const ${name} =`), devShell.indexOf(`const ${nextName} =`));
1587
+
1588
+ expect(functionBody("toggleIssueStatus", "updateIssueDetail")).toContain("await Promise.all([loadIssueDetail(issue.id), fetchIssues(query)])");
1589
+ expect(functionBody("updateIssueDetail", "updateIssueCollaboration")).toContain("await Promise.all([loadIssueDetail(detail.issue.id), fetchIssues(query)])");
1590
+ });
1591
+
1592
+ it("DevShell 详情活动不会绕过当前筛选向列表插入记录", () => {
1593
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1594
+ const functionBody = (name: string, nextName: string) => devShell.slice(devShell.indexOf(`const ${name} =`), devShell.indexOf(`const ${nextName} =`));
1595
+ const syncBody = functionBody("syncIssueStatusAcrossViews", "syncIssueDetailAcrossViews");
1596
+ const deleteBody = devShell.slice(devShell.indexOf("const deleteComment ="), devShell.indexOf("\n\n return (", devShell.indexOf("const deleteComment =")));
1597
+
1598
+ expect(syncBody).toContain("current.map((issue) => issue.id === updatedIssue.id ? updatedIssue : issue)");
1599
+ expect(syncBody).not.toContain("[updatedIssue, ...current]");
1600
+ expect(functionBody("toggleIssueReaction", "createComment")).toContain("await fetchIssues(query)");
1601
+ expect(functionBody("createComment", "updateComment")).toContain("await fetchIssues(query)");
1602
+ expect(functionBody("updateComment", "deleteComment")).toContain("await fetchIssues(query)");
1603
+ expect(deleteBody).toContain("await Promise.all([loadIssueDetail(detail.issue.id), fetchIssues(query)])");
1604
+ });
1605
+
1606
+ it("DevShell composer 提交失败只由对应 composer 呈现", () => {
1607
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1608
+ const functionBody = (name: string, nextName: string) => devShell.slice(devShell.indexOf(`const ${name} =`), devShell.indexOf(`const ${nextName} =`));
1609
+
1610
+ expect(functionBody("submitIssue", "toggleIssueStatus")).not.toContain("setError(message)");
1611
+ expect(functionBody("createComment", "updateComment")).not.toContain("setError(message)");
1612
+ expect(functionBody("updateComment", "deleteComment")).not.toContain("setError(message)");
1613
+ expect(functionBody("updateIssueDetail", "updateIssueCollaboration")).toContain("if (!updates.draftId) setError(message)");
1614
+ expect(functionBody("updateIssueCollaboration", "toggleIssueReaction")).toContain("setError(message)");
1615
+ });
1616
+
1617
+ it("DevShell 区分分页越界与普通空状态", () => {
1618
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1619
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
1620
+
1621
+ expect(workspace).toContain("const issuePageOutOfRange = query.offset > 0 && issues.length === 0");
1622
+ expect(workspace).toContain("当前页已无 Issue");
1623
+ expect(workspace).toContain("updateIssueQuery({ offset: 0 })}>返回第一页");
1624
+ expect(workspace).toContain('issues.length === 0 ? `0 / ${meta.total}`');
1625
+ });
1626
+
1627
+ it("DevShell 为已渲染详情的实时同步失败提供就地重试", () => {
1628
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1629
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
1630
+
1631
+ expect(workspace).toContain("const [detailSyncFailed, setDetailSyncFailed] = useState(false)");
1632
+ expect(workspace).toContain("const retryIssueDetailSync = async () =>");
1633
+ expect(workspace).toContain("if (detailSyncing || !currentDetail) return");
1634
+ expect(workspace).toContain('detailSyncFailed && <button type="button" disabled={detailSyncing}');
1635
+ expect(workspace).toContain('detailSyncing ? "正在同步..." : "重新同步"');
1636
+ expect(workspace).toContain("h-11 shrink-0 sm:h-7");
1637
+ });
1638
+
1639
+ it("DevShell 将列表刷新错误与详情错误隔离", () => {
1640
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1641
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
1642
+
1643
+ expect(workspace).toContain("const [listError, setListError] = useState<string | null>(null)");
1644
+ expect(workspace).toContain("setListError(null)");
1645
+ expect(workspace).toContain('requestError.name === "TimeoutError" ? "Issue 服务暂不可用"');
1646
+ expect(workspace).toContain("{listError && issues.length > 0");
1647
+ expect(workspace).toContain("listError && issues.length === 0");
1648
+ expect(workspace).toContain("pendingListRetryFocusRef");
1649
+ expect(workspace).toContain("retryIssueList");
1650
+ expect(workspace).not.toContain("{error && issues.length > 0");
1651
+ });
1652
+
1653
+ it("DevShell 详情导航只接受最新请求并在离开时使旧请求失效", () => {
1654
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1655
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
1656
+
1657
+ expect(workspace).toContain("const detailRequestGenerationRef = useRef(0)");
1658
+ expect(workspace).toContain("const generation = ++detailRequestGenerationRef.current");
1659
+ expect(workspace).toContain("if (detailRequestGenerationRef.current !== generation) return");
1660
+ expect(workspace).toContain("if (detailRequestGenerationRef.current === generation) setDetailLoading(false)");
1661
+ expect(workspace).toContain("++detailRequestGenerationRef.current; setDetailLoading(false)");
1662
+ });
1663
+
1664
+ it("DevShell 评论编辑冲突保留草稿并显示远端版本入口", () => {
1665
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1666
+ const timeline = devShell.slice(devShell.indexOf("function DevIssueTimeline"), devShell.indexOf("function DevIssueComposer"));
1667
+ const updateComment = devShell.slice(devShell.indexOf("const updateComment ="), devShell.indexOf("const deleteComment ="));
1668
+
1669
+ expect(updateComment).toContain("await loadIssueDetail(detail.issue.id).catch(() => undefined)");
1670
+ expect(timeline).toContain("editingCommentVersion !== comment.updated_at");
1671
+ expect(timeline).toContain("此评论有新变更,当前草稿尚未被覆盖。");
1672
+ expect(timeline).toContain("加载最新内容");
1673
+ expect(timeline).toContain("h-11 shrink-0 sm:h-8");
1674
+ });
1675
+
1676
+ it("DevShell 明确放弃冲突的 Issue 草稿后再加载最新内容", () => {
1677
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1678
+ const detailPanel = devShell.slice(devShell.indexOf("function DevIssueDetailPanel"), devShell.indexOf("function DevToolkitSidebar"));
1679
+
1680
+ expect(detailPanel).toContain("放弃草稿并加载最新");
1681
+ expect(detailPanel).toContain("h-11 shrink-0 sm:h-8");
1682
+ expect(detailPanel).toContain("block h-11 w-full rounded");
1683
+ expect(detailPanel).toContain("h-11 rounded border");
1684
+ expect(detailPanel).toContain("sm:h-9");
1685
+ expect(detailPanel).toMatch(/const beginIssueEdit[\s\S]*?if \(editingIssue\)[\s\S]*?writeDevIssueEditMeta\(issueEditMetaKey, null\)[\s\S]*?writeDevIssueSessionDraft\(issueEditBodyKey, \"\"\)/);
1686
+ });
1687
+
1688
+ it("DevShell 删除评论失败向确认框传播异常以保留重试", () => {
1689
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1690
+ const deleteComment = devShell.slice(devShell.indexOf("const deleteComment ="), devShell.indexOf("return (", devShell.indexOf("const deleteComment =")));
1691
+ const timeline = devShell.slice(devShell.indexOf("function DevIssueTimeline"), devShell.indexOf("function DevIssueComposer"));
1692
+
1693
+ expect(deleteComment).toContain("setError(message)");
1694
+ expect(deleteComment).toContain("throw requestError instanceof Error ? requestError : new Error(message)");
1695
+ expect(timeline).toContain("Keep the confirmation visible so the user can retry.");
1696
+ });
1697
+
1698
+ it("DevShell 删除评论确认框约束 Tab 焦点并关联说明", () => {
1699
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1700
+ const timeline = devShell.slice(devShell.indexOf("function DevIssueTimeline("), devShell.indexOf("function DevIssueDetailPanel"));
1701
+
1702
+ expect(timeline).toContain("deleteCommentConfirmRef");
1703
+ expect(timeline).toContain("mt-3 flex flex-wrap justify-end gap-2");
1704
+ expect(timeline).toContain("h-11 sm:h-8");
1705
+ expect(timeline).toContain("handleDeleteConfirmationKeyDown");
1706
+ expect(timeline).toContain("confirmedComment && !confirmedComment.comment.deleted_at");
1707
+ expect(timeline).toContain("setConfirmingDeleteCommentId(null)");
1708
+ expect(timeline).toContain("editedComment && !editedComment.comment.deleted_at");
1709
+ expect(timeline).toContain('setCopyAnnouncement("评论已被删除,编辑已结束")');
1710
+ expect(timeline).toContain('event.key !== "Tab"');
1711
+ expect(timeline).toContain('aria-describedby={`delete-comment-${comment.id}-description`}');
1712
+ });
1713
+
1714
+ it("DevShell 仅向 owner 提供永久删除 Issue 并保留失败确认", () => {
1715
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1716
+ const detailPanel = devShell.slice(devShell.indexOf("function DevIssueDetailPanel"));
1717
+
1718
+ expect(devShell).toContain('method: "DELETE", credentials: "include"');
1719
+ expect(detailPanel).toContain('user.id === pageOwnerId || user.role === "owner"');
1720
+ expect(detailPanel).toContain('aria-label="删除 Issue 确认"');
1721
+ expect(detailPanel).toContain("deleteIssueConfirmRef");
1722
+ expect(detailPanel).toContain("setDeleteIssueError");
1723
+ expect(detailPanel).toContain("此操作无法撤销");
1724
+ expect(detailPanel).toContain('label: "删除 Issue", destructive: true, restoreFocus: false');
1725
+ expect(detailPanel).toContain("deleteIssueTriggerRef.current = trigger");
1726
+ expect(detailPanel).not.toContain('<div className="mt-4 flex justify-end"><button ref={deleteIssueTriggerRef}');
1727
+ });
1728
+
1729
+ it("DevShell 提供 owner-only 标签管理视图和完整本地 CRUD", () => {
1730
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1731
+ const manager = devShell.slice(devShell.indexOf("function DevIssueLabelManager"), devShell.indexOf("function DevIssuesWorkspace"));
1732
+
1733
+ expect(devShell).toContain('aria-label="管理 Issue 标签"');
1734
+ expect(devShell).toContain('user.id === pageOwnerId || user.role === "owner"');
1735
+ expect(devShell).toContain("const deleteTriggerRef = useRef<HTMLElement | null>(null)");
1736
+ expect(devShell).toContain("event.key === \"Escape\" && !saving");
1737
+ expect(devShell).toContain("document.activeElement === last");
1738
+ expect(manager).toContain("新建标签");
1739
+ expect(manager).toContain("保存更改");
1740
+ expect(manager).toContain("确认删除标签");
1741
+ expect(manager).toContain("deleteLabelTriggerRef");
1742
+ expect(manager).toContain('event.key !== "Tab"');
1743
+ expect(manager).toContain('event.key === "Escape"');
1744
+ expect(devShell).toMatch(/import \{[^}]*\bPlus\b[^}]*\} from "lucide-react"/);
1745
+ expect(devShell).toContain('method: "POST", credentials: "include"');
1746
+ expect(devShell).toContain('method: "PATCH", credentials: "include"');
1747
+ expect(devShell).toContain('method: "DELETE", credentials: "include"');
1748
+ });
1749
+
1750
+ it("DevShell 删除评论成功后播报结果并聚焦保留卡片", () => {
1751
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1752
+ const timeline = devShell.slice(devShell.indexOf("function DevIssueTimeline("), devShell.indexOf("function DevIssueDetailPanel"));
1753
+
1754
+ expect(timeline).toContain('setCopyAnnouncement("评论已删除")');
1755
+ expect(timeline).toContain('`[data-localapp-issue-comment-id="${commentId}"]`');
1756
+ });
1757
+
1758
+ it("DevShell 编辑 Composer 打开后聚焦正文", () => {
1759
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1760
+ const composer = devShell.slice(devShell.indexOf("function DevIssueComposer("), devShell.indexOf("interface DevIssueMetadataPickerItem"));
1761
+
1762
+ expect(composer).toContain('autoFocus = submitLabel.startsWith("保存")');
1763
+ expect(composer).toContain("textareaRef.current?.focus()");
1764
+ });
1765
+
1766
+ it("DevShell 退出评论编辑后聚焦对应评论卡片", () => {
1767
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1768
+ const timeline = devShell.slice(devShell.indexOf("function DevIssueTimeline("), devShell.indexOf("function DevIssueDetailPanel"));
1769
+
1770
+ expect(timeline).toContain("previousEditingCommentIdRef");
1771
+ expect(timeline).toContain('`[data-localapp-issue-comment-id="${previousEditingCommentId}"]`');
1772
+ });
1773
+
1774
+ it("DevShell 退出 Issue 编辑后聚焦操作入口", () => {
1775
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1776
+ const detail = devShell.slice(devShell.indexOf("function DevIssueDetailPanel("), devShell.indexOf("function DevToolkitSidebar"));
1777
+
1778
+ expect(detail).toContain("previousEditingIssueRef");
1779
+ expect(detail).toContain("[data-localapp-issue-body-card] button[aria-label=\"Issue 操作\"]");
1780
+ });
1781
+
1782
+ it("DevShell 创建 Issue 后进入新详情并同步深链", () => {
1783
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1784
+ const submit = devShell.slice(devShell.indexOf("const submitIssue ="), devShell.indexOf("const updateIssueDetail ="));
1785
+
1786
+ expect(submit).toContain('const created = await requestDevIssue<DevIssue>("/api/issues"');
1787
+ expect(submit).toContain("onIssueNavigate(created.id)");
1788
+ expect(submit).toContain("await loadIssueDetail(created.id)");
1789
+ expect(devShell).toContain('data-localapp-issue-title tabIndex={-1}');
1790
+ expect(devShell).toContain('[data-localapp-issue-title]');
1791
+ const detailTitle = devShell.match(/<h3 data-localapp-issue-title[^>]+>/)?.[0] ?? "";
1792
+ expect(detailTitle).not.toContain("focus-visible:ring");
1793
+ expect(detailTitle).toContain("outline-none");
1794
+ expect(devShell).toContain("createIssueTriggerRef");
1795
+ expect(devShell).toContain("pendingCreateIssueFocusRef");
1796
+ });
1797
+
1798
+ it("DevShell 创建评论后写入评论深链并聚焦新评论", () => {
1799
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1800
+ const create = devShell.slice(devShell.indexOf("const createComment ="), devShell.indexOf("const updateComment ="));
1801
+
1802
+ expect(create).toContain("const previousCommentIds = new Set(detail.timeline.flatMap");
1803
+ expect(create).toContain("createDevIssueCommentHref(detail.issue.id, createdComment.comment.id)");
1804
+ expect(create).toContain("window.history.replaceState(window.history.state");
1805
+ });
1806
+
1807
+ it("DevShell 删除当前深链评论后清理失效参数", () => {
1808
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1809
+
1810
+ expect(devShell).toContain("function clearDevIssueCommentDeepLinkUrl(");
1811
+ expect(devShell).toContain("clearDevIssueCommentDeepLinkUrl(new URL(window.location.href), commentId)");
1812
+ });
1813
+
1814
+ it("DevShell 附件在新标签页打开并保留工作台", () => {
1815
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1816
+ const attachments = devShell.slice(devShell.indexOf("function DevIssueAttachmentLinks("), devShell.indexOf("function DevIssueEventIcon"));
1817
+
1818
+ expect(attachments).toContain('target="_blank" rel="noreferrer"');
1819
+ expect(attachments).toContain("在新标签页打开附件");
1820
+ expect(attachments).toContain("flex min-h-11 min-w-0 flex-1 items-center");
1821
+ expect(attachments).toContain("shrink-0 text-localapp-dev-muted-foreground");
1822
+ expect(attachments).toContain('loading="lazy" decoding="async"');
1823
+ });
1824
+
1825
+ it("DevShell 锁定失败在活动模态层显示且不重复到后方 metadata", () => {
1826
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
1827
+ const metadata = devShell.slice(devShell.indexOf("function DevIssueMetadata"), devShell.indexOf("function DevIssueRevisionDialog"));
1828
+
1829
+ expect(metadata).toContain("localMetadataError && !lockDialogOpen");
1830
+ expect(metadata).toContain("localMetadataError && lockDialogOpen");
1831
+ expect(metadata).toContain("data-localapp-issue-lock-error role=\"alert\"");
1832
+ expect(metadata).toContain("runMetadataAction(onToggleLock(true, lockReason)).then(closeLockDialog).catch(() => undefined)");
1833
+ });
1834
+
1835
+ it("DevShell Issue 列表保留 Platform 的查询与并发请求契约", () => {
1836
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1837
+ const start = devShell.indexOf("function DevIssuesWorkspace");
1838
+ const end = devShell.indexOf("function DevIssueMarkdown", start);
1839
+ const workspace = devShell.slice(start, end);
1840
+
1841
+ for (const parameter of ["status", "sort", "direction", "limit", "offset"]) {
1842
+ expect(workspace, `DevShell list query must serialize ${parameter}`).toContain(`requestQuery.set(\"${parameter}\"`);
1843
+ }
1844
+ for (const parameter of ["q", "label", "author", "participant"]) {
1845
+ expect(workspace, `DevShell must omit an empty optional ${parameter}`).toContain(`if (nextQuery.${parameter}) requestQuery.set(\"${parameter}\"`);
1846
+ }
1847
+ expect(workspace).toContain('if (nextQuery.subscribed) requestQuery.set("subscribed", "true")');
1848
+ expect(workspace).toContain("listRequestGenerationRef");
1849
+ expect(workspace).toContain("listAbortRef.current?.abort()");
1850
+ expect(workspace).toContain("new AbortController()");
1851
+ expect(workspace).toContain("signal: controller.signal");
1852
+ expect(workspace).toContain("listRequestGenerationRef.current !== generation");
1853
+ expect(devShell).toContain('error instanceof Error && error.name === "AbortError"');
1854
+ expect(workspace).toContain("window.setTimeout");
1855
+ expect(workspace).toContain("}, 250)");
1856
+ expect(workspace).toContain('event.key === "Enter"');
1857
+ });
1858
+
1859
+ it("DevShell Issue 列表提供 Platform 同构的视图、状态和分页结构", () => {
1860
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1861
+ const start = devShell.indexOf("function DevIssuesWorkspace");
1862
+ const end = devShell.indexOf("function DevIssueMarkdown", start);
1863
+ const workspace = devShell.slice(start, end);
1864
+
1865
+ for (const attribute of ["data-localapp-issue-list", "data-localapp-issue-view-rail", "data-localapp-issue-toolbar", "data-localapp-issue-row"]) {
1866
+ expect(workspace).toContain(attribute);
1867
+ }
1868
+ expect(workspace).toContain('created: "我创建的"');
1869
+ expect(workspace).toContain('participating: "我参与的"');
1870
+ expect(workspace).toContain('subscribed: "我关注的"');
1871
+ expect(workspace).toContain('mentioned: "提及我的"');
1872
+ expect(workspace).toContain('assigned: "分配给我的"');
1873
+ expect(workspace).toContain('recent: "最近活动"');
1874
+ expect(workspace).toContain('nextView === "assigned" && user');
1875
+ expect(workspace).toContain('assignee: user.id');
1876
+ expect(workspace).toContain('query.assignee === user.id');
1877
+ expect(workspace).toContain("query.subscribed");
1878
+ expect(workspace).toContain("query.mentioned");
1879
+ expect(workspace).toContain('if (nextQuery.mentioned) requestQuery.set("mentioned", "true")');
1880
+ expect(workspace).toContain("meta.open");
1881
+ expect(workspace).toContain("meta.closed");
1882
+ expect(workspace).toContain("meta.total");
1883
+ expect(workspace).toContain("issues.map((issue, index)");
1884
+ expect(workspace).toContain("aria-posinset={meta.offset + index + 1}");
1885
+ expect(workspace).toContain("aria-setsize={meta.total}");
1886
+ expect(workspace).toContain("aria-busy={refreshingIssues}");
1887
+ expect(workspace).toContain('role="status" aria-live="polite" aria-atomic="true"');
1888
+ expect(workspace).toContain("当前显示第 ${meta.offset + 1} 至 ${Math.min(meta.offset + issues.length, meta.total)} 条,共 ${meta.total} 条 Issue");
1889
+ expect(workspace).toContain("query.offset + query.limit");
1890
+ expect(workspace).toContain('id="localapp-dev-issue-results"');
1891
+ expect(workspace).toContain('aria-controls="localapp-dev-issue-results"');
1892
+ expect(workspace).toContain("paginationFocusPendingRef.current = true");
1893
+ expect(workspace).toContain('[data-localapp-issue-link]');
1894
+ expect(workspace).toContain("comment_count");
1895
+ expect(workspace).toContain("participant_ids?.length");
1896
+ expect(workspace).toContain("h-11 shrink-0 rounded px-3");
1897
+ expect(workspace).toContain("h-11 min-w-0 w-full");
1898
+ expect(workspace).toContain("h-11 items-center gap-1.5");
1899
+ expect(workspace).toContain("h-11 w-11");
1900
+ });
1901
+
1902
+ it("DevShell Issue 列表涵盖加载、刷新、空态、错误重试与无横向溢出的响应式布局", () => {
1903
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1904
+ const start = devShell.indexOf("function DevIssuesWorkspace");
1905
+ const end = devShell.indexOf("function DevIssueMarkdown", start);
1906
+ const workspace = devShell.slice(start, end);
1907
+
1908
+ expect(workspace).toContain("Array.from({ length: 6 }");
1909
+ expect(workspace).toContain("aria-busy={loading}");
1910
+ expect(workspace).toContain("refreshingIssues = loading && issues.length > 0");
1911
+ expect(workspace).toContain("正在更新结果");
1912
+ expect(workspace).toContain('data-stale={refreshingIssues ? "true" : undefined}');
1913
+ expect(workspace).not.toContain('className={refreshingIssues ? "opacity-60" : undefined}');
1914
+ expect(workspace).toContain("显示上次结果");
1915
+ expect(workspace).toContain("无法加载 Issues");
1916
+ expect(workspace).toContain("motion-safe:animate-pulse");
1917
+ expect(workspace).toContain("h-11 shrink-0 items-center");
1918
+ expect(workspace).toContain("h-11 w-11 shrink-0");
1919
+ expect(workspace).toContain("h-11 sm:h-8");
1920
+ expect(workspace).toContain("重置筛选");
1921
+ expect(workspace).toContain("const hasActiveIssueFilters = Boolean(query.q || query.searchIn || query.issueType || query.label || query.author || query.participant || query.assignee || query.milestone || query.reason || query.subscribed || query.mentioned || query.locked)");
1922
+ expect(workspace).toContain('hasActiveIssueFilters ? "当前筛选没有匹配的 Issue"');
1923
+ expect(workspace).toContain("hasActiveIssueFilters && <button");
1924
+ expect(workspace).toContain("重试");
1925
+ expect(workspace).toContain("grid-rows-[auto_minmax(0,1fr)]");
1926
+ expect(workspace).toContain("lg:grid-cols-[240px_minmax(0,1fr)]");
1927
+ expect(workspace).toContain("lg:grid-rows-1");
1928
+ expect(workspace).toContain("lg:flex-col");
1929
+ expect(workspace).toContain("h-full min-w-0 cursor-pointer bg-transparent");
1930
+ expect(workspace).toContain("sm:flex-row");
1931
+ expect(workspace).toContain("max-w-full");
1932
+ expect(workspace).toContain("overflow-x-hidden");
1933
+ expect(workspace).toContain("text-base font-semibold leading-6");
1934
+ expect(workspace).toContain("text-sm leading-5");
1935
+ });
1936
+
1937
+ it("DevShell 离线展示置顶区并只向 page owner 提供置顶维护", () => {
1938
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1939
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
1940
+ const metadata = devShell.slice(devShell.indexOf("function DevIssueMetadata"), devShell.indexOf("function DevIssueRevisionDialog"));
1941
+
1942
+ expect(devShell).toContain("pinned?: DevIssue[]");
1943
+ expect(workspace).toContain("setPinnedIssues(Array.isArray(body.pinned) ? body.pinned : [])");
1944
+ expect(workspace).toContain('data-localapp-pinned-issues');
1945
+ expect(workspace).toContain("置顶 Issues");
1946
+ expect(workspace).toContain("sm:grid-cols-2 xl:grid-cols-3");
1947
+ expect(workspace).toContain('query.status === "open"');
1948
+ expect(workspace).toContain('activeView === "all"');
1949
+ expect(workspace).toContain('updateIssueCollaboration("pin", { pinned })');
1950
+ expect(metadata).toContain('aria-label={detail.issue.pinned_at ? "取消置顶" : "置顶 Issue"}');
1951
+ expect(devShell).toContain('canManagePin={Boolean(user && (user.id === pageOwnerId || user.role === "owner"))}');
1952
+ expect(metadata).toContain("onTogglePin(!detail.issue.pinned_at)");
1953
+ });
1954
+
1955
+ it("DevShell 离线提供同构 Sub-issues 层级、进度与 owner 维护入口", () => {
1956
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1957
+ expect(devShell).toContain("subIssues?: DevIssueSubIssueItem[]");
1958
+ expect(devShell).toContain("subIssueSummary?: { total: number; completed: number; percent: number }");
1959
+ expect(devShell).toContain("function DevIssueSubIssues(");
1960
+ expect(devShell).toContain("data-localapp-sub-issues");
1961
+ expect(devShell).toContain('aria-label="Sub-issues 完成进度"');
1962
+ expect(devShell).toContain("创建子 Issue");
1963
+ expect(devShell).toContain("要关联的 Issue 编号");
1964
+ expect(devShell).toContain("移除 Sub-issue #");
1965
+ expect(devShell).toContain("parentIssueId: view.parentIssueId");
1966
+ expect(devShell).toContain("/sub-issues/${child.issue.id}");
1967
+ expect(devShell).toContain("canManageSubIssues");
1968
+ expect(devShell).toContain("function DevSubIssueReorderControls(");
1969
+ expect(devShell).toContain('label={`重排 Sub-issue #${issue.issue_number}`}');
1970
+ expect(devShell).toContain('label: "移到顶部"');
1971
+ expect(devShell).toContain('label: "移到底部"');
1972
+ expect(devShell).toContain('method: "PATCH"');
1973
+ expect(devShell).toContain("/sub-issues/priority");
1974
+ expect(devShell).toContain("onDragStart");
1975
+ expect(devShell).toContain('aria-live="polite">{announcement}');
1976
+ expect(devShell).toContain("function DevIssueNestedBranch(");
1977
+ expect(devShell).toContain("/sub-issues?${params.toString()}");
1978
+ expect(devShell).toContain('aria-label={`${expanded ? "折叠" : "展开"} Sub-issue #${issue.issue_number}`}');
1979
+ expect(devShell).toContain('role="tree" aria-label="Sub-issues"');
1980
+ expect(devShell).toContain('expanded && state.status === "idle"');
1981
+ });
1982
+
1983
+ it("DevShell Issue 详情在请求期间保持稳定骨架并为失败提供恢复操作", () => {
1984
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
1985
+
1986
+ expect(devShell).toContain("function DevIssueDetailSkeleton()");
1987
+ expect(devShell).toContain('aria-label="正在加载 Issue 详情"');
1988
+ expect(devShell).toContain("function DevIssueDetailError(");
1989
+ expect(devShell).toContain("无法加载 Issue 详情");
1990
+ expect(devShell).toContain("detailErrorHeadingRef");
1991
+ expect(devShell).toContain("detailErrorHeadingRef.current?.focus()");
1992
+ expect(devShell).toContain('aria-labelledby={headingId} aria-describedby={descriptionId}');
1993
+ expect(devShell).toContain('aria-label="从错误页返回 Issue 列表"');
1994
+ expect(devShell).toContain('aria-label="重试加载 Issue 详情"');
1995
+ const errorHeading = devShell.match(/<h3 ref=\{detailErrorHeadingRef\}[^>]+>/)?.[0] ?? "";
1996
+ expect(errorHeading).not.toContain("focus-visible:ring");
1997
+ expect(devShell).toContain("<DevIssueDetailSkeleton />");
1998
+ expect(devShell).toContain("<DevIssueDetailError");
1999
+ expect(devShell).toContain("返回列表");
2000
+ expect(devShell).toContain("devContext ? <DevIssuesWorkspace");
2001
+ expect(devShell).toContain('data-localapp-shell-nav-background inert={issuesOpen ? ("true" as unknown as boolean) : undefined} aria-hidden={issuesOpen ? true : undefined}');
2002
+ expect(devShell).toContain('aria-hidden={issuesOpen ? true : undefined} className="shrink-0"');
2003
+ expect(devShell).toContain('data-localapp-app-background inert={issuesOpen ? ("true" as unknown as boolean) : undefined} aria-hidden={issuesOpen ? true : undefined}');
2004
+ expect(devShell).toContain('aria-hidden={issuesOpen ? true : undefined} className="absolute inset-0"');
2005
+ expect(devShell).toContain('issuesOpen ? <div data-localapp-issues-layer');
2006
+ expect(devShell).toContain("function DevIssueContextError(");
2007
+ expect(devShell).toContain("无法打开 Issue 工作台");
2008
+ expect(devShell).toContain("requestDevContext()");
2009
+ expect(devShell).toContain("Dev context request timed out");
2010
+ expect(devShell).toContain("controller.abort()");
2011
+ expect(devShell).toContain("retryTimer = setTimeout(loadContext, 1_000)");
2012
+ expect(devShell).toContain("setDevContextError(null)");
2013
+ });
2014
+
2015
+ it("DevShell 在真实 dev context 就绪前不请求虚构应用的 Issue 数量", () => {
2016
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2017
+ const countEffectStart = devShell.indexOf("const query = new URLSearchParams({ pagePath: getDevIssuePagePath(devContext), status: \"open\" })");
2018
+ const countEffect = devShell.slice(devShell.lastIndexOf("useEffect(() => {", countEffectStart), devShell.indexOf("const respondToPlatformRequest", countEffectStart));
2019
+
2020
+ expect(countEffect).toContain("if (!devContext)");
2021
+ expect(countEffect).toContain("setOpenIssueCount(null)");
2022
+ expect(countEffect.indexOf("if (!devContext)")).toBeLessThan(countEffect.indexOf("getDevIssuePagePath(devContext)"));
2023
+ expect(countEffect).toContain("controller.abort()")
2024
+ expect(countEffect).toContain("[devContext, issuesRevision]");
2025
+ });
2026
+
2027
+ it("DevShell 标签目录失败时保持标签为空并提供原地重试", () => {
2028
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
2029
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
2030
+
2031
+ expect(workspace).toContain("const [labelCatalogError, setLabelCatalogError] = useState(false)");
2032
+ expect(workspace).toContain("const [labelCatalogRevision, setLabelCatalogRevision] = useState(0)");
2033
+ expect(devShell).toContain("标签目录暂不可用");
2034
+ expect(workspace).toContain("devCatalogRetryLabel(labelCatalogError, userCatalogError, milestoneCatalogError)");
2035
+ expect(workspace).toContain("setLabelCatalogRevision((revision) => revision + 1)");
2036
+ expect(workspace).toContain("pendingCatalogRetryFocusRef");
2037
+ expect(workspace).toContain("catalogRetrying");
2038
+ expect(workspace).toContain("focusAfterCatalogRetry");
2039
+ });
2040
+
2041
+ it("DevShell 负责人目录失败时保留已知用户并提供原地重试", () => {
2042
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
2043
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
2044
+
2045
+ expect(workspace).toContain("const [userCatalog, setUserCatalog] = useState<DevUserBasic[]>(platformUsers)");
2046
+ expect(workspace).toContain("const [userCatalogError, setUserCatalogError] = useState(false)");
2047
+ expect(workspace).toContain("const [userCatalogRevision, setUserCatalogRevision] = useState(0)");
2048
+ expect(workspace).toContain('requestDevIssueCatalogWithRetry((signal) => requestDevIssue<{ users?: DevUserBasic[]; source?: string }>("/api/dev/users", { credentials: "include", signal })');
2049
+ expect(devShell).toContain("负责人目录加载失败,正在显示已知用户");
2050
+ expect(workspace).toContain("aria-label={devCatalogRetryLabel(labelCatalogError, userCatalogError, milestoneCatalogError)}");
2051
+ expect(workspace).toContain("setUserCatalogRevision((revision) => revision + 1)");
2052
+ expect(workspace).toContain("...recentUsers, ...platformUsers, ...userCatalog");
2053
+ });
2054
+
2055
+ it("DevShell 将有效的离线负责人目录视为成功降级", () => {
2056
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
2057
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
2058
+
2059
+ expect(workspace).toContain("setUserCatalogError(false)");
2060
+ expect(workspace).not.toContain('setUserCatalogError(body.source === "unavailable")');
2061
+ });
2062
+
2063
+ it("DevShell 里程碑目录失败时保留已知目录并提供原地重试", () => {
2064
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
2065
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
2066
+
2067
+ expect(workspace).toContain("const [milestoneCatalogError, setMilestoneCatalogError] = useState(false)");
2068
+ expect(workspace).toContain("const [milestoneCatalogLoading, setMilestoneCatalogLoading] = useState(false)");
2069
+ expect(workspace).toContain("const [milestoneCatalogRevision, setMilestoneCatalogRevision] = useState(0)");
2070
+ expect(devShell).toContain("里程碑目录加载失败,正在显示已知里程碑");
2071
+ expect(devShell).toContain("重试里程碑目录");
2072
+ expect(workspace).toContain("if (milestoneCatalogError) setMilestoneCatalogRevision((revision) => revision + 1)");
2073
+ expect(workspace).toContain("labelCatalogLoading || userCatalogLoading || milestoneCatalogLoading");
2074
+ expect(workspace).toContain("labelCatalogError || userCatalogError || milestoneCatalogError");
2075
+ });
2076
+
2077
+ it("DevShell 负责人目录不可用时仍可操作详情已有负责人", () => {
2078
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
2079
+ const metadata = devShell.slice(devShell.indexOf("function DevIssueMetadata("), devShell.indexOf("function DevIssueRevisionDialog"));
2080
+
2081
+ expect(metadata).toContain("new Set([...assigneeIds, ...identities.map((identity) => identity.id)])");
2082
+ expect(metadata).toContain(".map((id) => resolveDevIssueIdentity(id, identities))");
2083
+ expect(metadata).toContain("items={assigneeCandidates.map((identity)");
2084
+ });
2085
+
2086
+ it("DevShell 移动端 metadata 折叠摘要显示标签、负责人和锁定状态", () => {
2087
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
2088
+ const detail = devShell.slice(devShell.indexOf("function DevIssueDetailPanel("), devShell.indexOf("function DevToolkitSidebar"));
2089
+ expect(detail).toContain("mobileMetadataSummary");
2090
+ expect(detail).toContain("个标签");
2091
+ expect(detail).toContain("未分配");
2092
+ expect(detail).toContain("已锁定");
2093
+ expect(detail).toContain("data-localapp-issue-metadata-summary");
2094
+ expect(detail).toContain('summary className="min-h-11');
2095
+ expect(devShell).toContain('className={`${DEV_ICON_BUTTON} h-11 w-11 sm:h-7 sm:w-7`}');
2096
+ expect(devShell).toContain('className={`${DEV_OUTLINE_BUTTON} h-11 w-full text-left sm:h-8`}');
2097
+ });
2098
+
2099
+ it("DevShell 标签目录不可用时仍可操作详情已有自定义标签", () => {
2100
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
2101
+ const metadata = devShell.slice(devShell.indexOf("function DevIssueMetadata("), devShell.indexOf("function DevIssueRevisionDialog"));
2102
+
2103
+ expect(metadata).toContain("[...(collaboration?.labels ?? []), ...availableLabels]");
2104
+ expect(metadata).toContain("items={labelCandidates.map((label)");
2105
+ });
2106
+
2107
+ it("DevShell 元数据选择器支持方向键和首尾键导航", () => {
2108
+ const devShell = readTemplateFile(path.join("runtime", "dev-shell.tsx"));
2109
+ const picker = devShell.slice(devShell.indexOf("function DevIssueMetadataPicker("), devShell.indexOf("function DevIssueParticipantRoster"));
2110
+ expect(picker).toContain("h-11 w-full rounded");
2111
+ expect(picker).toContain("sm:h-8");
2112
+
2113
+ expect(picker).toContain('!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)');
2114
+ expect(picker).toContain("optionRefs.current[nextIndex]?.focus()");
2115
+ expect(picker).toContain("focus-within:ring-localapp-dev-focus");
2116
+ });
2117
+
2118
+ it("DevShell 使用 AST 任务顺序提供进度、直接切换和版本冲突保护", () => {
2119
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2120
+
2121
+ expect(devShell).toContain("function collectDevIssueTasks(");
2122
+ expect(devShell).toContain("unified().use(remarkParse).use(remarkGfm).parse(markdown)");
2123
+ expect(devShell).toContain("function toggleDevIssueTask(");
2124
+ expect(devShell).toContain("function rehypeDevIssueTaskIndexes()");
2125
+ expect(devShell).toContain("node.properties.dataIssueTaskIndex = index++");
2126
+ expect(devShell).toContain("rehypePlugins={[rehypeDevIssueTaskIndexes]}");
2127
+ expect(devShell).toContain('(props as Record<string, unknown>)["data-issue-task-index"]');
2128
+ expect(devShell).toContain("index === null || !onToggleTask || tasksDisabled");
2129
+ expect(devShell).not.toContain("let taskIndex = 0");
2130
+ expect(devShell).toContain("任务 {completed} / {tasks.length}");
2131
+ expect(devShell).toContain('role="progressbar" aria-label="任务进度"');
2132
+ expect(devShell).toContain("aria-valuenow={completed} aria-valuemin={0} aria-valuemax={tasks.length}");
2133
+ expect(devShell).toContain('aria-valuetext={`已完成 ${completed} / ${tasks.length} 个任务`}');
2134
+ expect(devShell).toContain("expectedUpdatedAt: detail.issue.updated_at");
2135
+ expect(devShell).toContain("expectedUpdatedAt ? { expectedUpdatedAt } : {}");
2136
+ expect(devShell).toContain("issue_content_conflict");
2137
+ expect(devShell).toContain("savingTaskTarget");
2138
+ expect(devShell).toContain("onToggleCommentTask={toggleCommentTask}");
2139
+ });
2140
+
2141
+ it("DevShell 完全离线确认并转换首帖任务为 Sub-issue", () => {
2142
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2143
+
2144
+ expect(devShell).toContain("convertible: !node.checked");
2145
+ expect(devShell).toContain("将任务 ${index! + 1} 转换为 Sub-issue");
2146
+ expect(devShell).toContain("/tasks/${taskIndex}/convert");
2147
+ expect(devShell).toContain('role="alertdialog" aria-label="转换为 Sub-issue"');
2148
+ expect(devShell).toContain('aria-label="Sub-issue 标题"');
2149
+ expect(devShell).toContain("expectedUpdatedAt: detail.issue.updated_at");
2150
+ expect(devShell).toContain("data-localapp-issue-reference={issueNumber ?? undefined}");
2151
+ });
2152
+
2153
+ it("DevShell 普通 Issue 与评论编辑携带版本令牌并保留冲突草稿", () => {
2154
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2155
+ expect(devShell).toContain("expectedUpdatedAt: editingIssueVersion ?? detail.issue.updated_at ?? detail.issue.created_at");
2156
+ expect(devShell).toContain("onUpdateComment(comment.id, body, editingCommentVersion ?? comment.updated_at, draftId, attachmentIds, removedCommentAttachmentIds)");
2157
+ expect(devShell).toContain("editingIssueVersion !== (detail.issue.updated_at ?? detail.issue.created_at)");
2158
+ expect(devShell).toContain("editingCommentVersion !== comment.updated_at");
2159
+ expect(devShell).toContain("当前草稿已保留");
2160
+ expect(devShell).toContain("The workspace alert keeps the API error visible without losing draft text.\n throw error;");
2161
+ });
2162
+
2163
+ it("DevShell 使用 AST 渲染同应用 Issue 引用并支持内部导航", () => {
2164
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2165
+ const references = readTemplateFile("runtime/issue-reference.ts");
2166
+ expect(references).toContain("remarkDevIssueReferences");
2167
+ expect(references).toContain('["link", "linkReference", "code", "inlineCode", "html"]');
2168
+ expect(devShell).toContain("remarkPlugins={[remarkGfm, remarkDevIssueReferences]}");
2169
+ expect(devShell).toContain("readDevIssueReference(href)");
2170
+ expect(devShell).toContain("onOpenIssueReference(issueNumber)");
2171
+ expect(devShell).toContain("getIssueReferenceHref={createDevIssueNumberHref}");
2172
+ expect(devShell).toContain("/api/issues/by-number/${issueId}");
2173
+ expect(devShell).toContain("loadIssueDetailByNumber(issueNumber)");
2174
+ expect(devShell).toContain('const DEV_ISSUE_NUMBER_DEEP_LINK_PARAM = "localappIssueNumber"');
2175
+ expect(devShell).toContain("selectedIssueNumber={selectedIssueNumber}");
2176
+ expect(devShell).toContain('onIssueNavigate(nextDetail.issue.id, "replace")');
2177
+ expect(devShell).toContain("const detailLookupByNumberRef = useRef(false)");
2178
+ expect(devShell).toContain("loadIssueDetail(view.issue.id, detailLookupByNumberRef.current)");
2179
+ const referenceNavigation = devShell.slice(devShell.indexOf("const openIssueByNumber = useCallback"), devShell.indexOf("const refreshIssueDetailSilently"));
2180
+ expect(referenceNavigation).toContain("onIssueNumberNavigate(issueNumber)");
2181
+ expect(referenceNavigation).toContain("loadIssueDetailByNumber(issueNumber)");
2182
+ expect(referenceNavigation.indexOf("onIssueNumberNavigate(issueNumber)")).toBeLessThan(referenceNavigation.indexOf("loadIssueDetailByNumber(issueNumber)"));
2183
+ });
2184
+
2185
+ it("DevShell 支持已完成与不计划处理两种关闭原因", () => {
2186
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2187
+ expect(devShell).toContain('state_reason?: "completed" | "not_planned" | null');
2188
+ expect(devShell).toContain('aria-label="关闭原因"');
2189
+ expect(devShell).toContain('value="completed">已完成</option>');
2190
+ expect(devShell).toContain("h-11 sm:h-8");
2191
+ expect(devShell).toContain('value="not_planned">不计划处理</option>');
2192
+ expect(devShell).toContain("/>}关闭 Issue</button>");
2193
+ expect(devShell).toContain('role="group" aria-label={detail.issue.status === "open" ? "关闭 Issue" : "重新打开 Issue"}');
2194
+ expect(devShell).toContain("aria-busy={submitting || undefined}");
2195
+ expect(devShell).toContain('submitting && <LoaderCircle className="h-4 w-4 animate-spin motion-reduce:animate-none" aria-hidden="true" />');
2196
+ expect(devShell).toContain("focus-within:ring-2 focus-within:ring-localapp-dev-focus");
2197
+ expect(devShell).toContain('stateReason: nextStatus === "closed" ? stateReason : null');
2198
+ expect(devShell).toContain('detail.issue.state_reason === "not_planned" ? <CircleSlash2');
2199
+ expect(devShell).toContain('"已关闭 · 不计划处理" : "已关闭 · 已完成"');
2200
+ expect(devShell).not.toContain('关闭原因:{detail.issue.state_reason');
2201
+ expect(devShell).toContain("statusActionFocusPendingRef");
2202
+ expect(devShell).toContain("statusActionRef.current?.focus()");
2203
+ expect(devShell).toContain("await toggleIssueStatus(detail.issue, stateReason)");
2204
+ expect(devShell).toContain('["关闭 Issue", "重新打开 Issue"].includes(button.textContent?.trim() ?? "")');
2205
+ });
2206
+
2207
+ it("DevShell composer 将 busy 反馈绑定到实际提交动作", () => {
2208
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2209
+ expect(devShell).toContain('useState<"submit" | "close" | "reopen" | null>(null)');
2210
+ expect(devShell).toContain('setSubmittingAction(statusAction ?? "submit")');
2211
+ expect(devShell).toContain('aria-busy={submittingAction === "submit" || undefined}');
2212
+ expect(devShell).toContain('aria-busy={submittingAction === "close" || undefined}');
2213
+ expect(devShell).toContain('aria-busy={submittingAction === "reopen" || undefined}');
2214
+ expect(devShell).not.toContain('{submitting ? "提交中..." : submitLabel}');
2215
+ });
2216
+
2217
+ it("DevShell Labels 与 Assignees 使用可搜索且可恢复焦点的元数据选择器", () => {
2218
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2219
+
2220
+ expect(devShell).toContain("function DevIssueMetadataPicker(");
2221
+ expect(devShell).toContain('role="dialog" aria-label={`选择${localizedLabel}`}');
2222
+ expect(devShell).toContain('role="searchbox" aria-label={`搜索${localizedLabel}`}');
2223
+ expect(devShell).toContain("没有匹配项");
2224
+ expect(devShell).toContain('event.key === "Escape"');
2225
+ expect(devShell).toContain('document.addEventListener("mousedown", closeOnOutside)');
2226
+ expect(devShell).toContain("triggerRef.current?.focus()");
2227
+ expect(devShell).toContain('<DevIssueMetadataPicker label="Labels"');
2228
+ expect(devShell).toContain('<DevIssueMetadataPicker label="Assignees"');
2229
+ expect(devShell).not.toContain("setLabelsOpen");
2230
+ expect(devShell).not.toContain("setAssigneesOpen");
2231
+ });
2232
+
2233
+ it("DevShell 详情元数据使用一致的中文可见标题", () => {
2234
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2235
+ for (const label of ["创建者", "标签", "负责人", "通知", "对话", "参与者"]) {
2236
+ expect(devShell).toContain(`>${label}</h4>`);
2237
+ }
2238
+ expect(devShell).toContain("<span>Issue 详情</span>");
2239
+ });
2240
+
2241
+ it("DevShell 元数据选择器内联显示失败并独立拥有错误", () => {
2242
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2243
+
2244
+ expect(devShell).toContain("const [toggleError, setToggleError] = useState<string | null>(null)");
2245
+ expect(devShell).toContain('role="alert" className="mx-2 mt-2 rounded border border-localapp-dev-danger');
2246
+ expect(devShell).toContain('error instanceof Error ? error.message : `${localizedLabel}更新失败`');
2247
+ expect(devShell).toContain("onToggle={(labelId, selected) => onToggleLabel(labelId, selected)}");
2248
+ expect(devShell).toContain("onToggle={(userId, selected) => onToggleAssignee(userId, selected)}");
2249
+ expect(devShell).not.toContain("runMetadataAction(onToggleLabel(labelId, selected))");
2250
+ expect(devShell).not.toContain("runMetadataAction(onToggleAssignee(userId, selected))");
2251
+ });
2252
+
2253
+ it("DevShell 仅向本地 owner 提供当前页批量状态操作并保留失败项", () => {
2254
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2255
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
2256
+
2257
+ expect(devShell).toContain('canBulkManage = Boolean(user && (user.id === pageOwnerId || user.role === "owner"))');
2258
+ expect(devShell).toContain('aria-label="选择当前页全部 Issue"');
2259
+ expect(devShell).toContain('role="status" aria-live="polite" aria-atomic="true" aria-label="Issue 选择状态"');
2260
+ expect(devShell).toContain('selectedIssueCount > 0 ? `已选择 ${selectedIssueCount} 条 Issue` : "未选择 Issue"');
2261
+ expect(devShell).toContain('aria-label={`选择 Issue #${issue.issue_number}`}');
2262
+ expect(workspace.match(/inline-flex h-11 w-11 shrink-0 cursor-pointer[^\"]*focus-within:ring-2/g)).toHaveLength(2);
2263
+ expect(devShell).toContain("inline-flex h-11 w-11 shrink-0 cursor-pointer");
2264
+ expect(devShell).toContain("sm:h-6 sm:w-6");
2265
+ expect(devShell).toContain('role="toolbar" aria-label="批量 Issue 操作"');
2266
+ expect(devShell).toContain("selectAllIssuesRef.current?.focus()");
2267
+ expect(devShell).toContain("Promise.allSettled");
2268
+ expect(devShell).toContain("setSelectedIssueIds(new Set(failedIds))");
2269
+ expect(devShell).toContain("条失败,可重试失败项");
2270
+ expect(devShell).toContain("正在更新 ${selectedIssueCount} 条 Issue");
2271
+ expect(devShell).toContain("条已选 Issue 已不在当前列表,选择已更新");
2272
+ expect(devShell).toContain("selectionReconciliationFocusRef.current = bulkToolbarFocusedRef.current ||");
2273
+ expect(devShell).toContain("bulkToolbarFocusedRef.current");
2274
+ expect(devShell).toContain("onFocusCapture={() => { bulkToolbarFocusedRef.current = true; }}");
2275
+ expect(devShell).toContain("if (toolbar.isConnected && !toolbar.contains(document.activeElement))");
2276
+ });
2277
+
2278
+ it("DevShell mirrors milestone management, filtering, creation, and detail assignment", () => {
2279
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2280
+ expect(devShell).toContain('type DevIssuesView =');
2281
+ expect(devShell).toContain('| { kind: "milestones" }');
2282
+ expect(devShell).toContain('aria-label="管理 Issue 里程碑"');
2283
+ expect(devShell).toContain('aria-label="按里程碑筛选"');
2284
+ expect(devShell).toContain('aria-label="设置里程碑"');
2285
+ expect(devShell).toContain('aria-label="里程碑"');
2286
+ expect(devShell).toContain('requestDevIssue<DevIssueMilestoneDefinition[]>(`/api/issues/milestones?${params.toString()}`');
2287
+ expect(devShell).toContain('event.stopPropagation(); setConfirmingDelete(null);');
2288
+ expect(devShell).toContain('/api/issues/milestones');
2289
+ expect(devShell).toContain('updateIssueCollaboration("milestone", { milestoneId })');
2290
+ expect(devShell).toContain('user.id === pageOwnerId || user.role === "owner"');
2291
+ });
2292
+
2293
+ it("移动 DevShell nav 隐藏次要文案并为左右操作提供收缩边界", () => {
2294
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2295
+
2296
+ expect(devShell).toContain("overflow-x-auto");
2297
+ expect(devShell).toContain("localapp-platform-nav-right flex shrink-0");
2298
+ expect(devShell).toContain("data-localapp-presence-count");
2299
+ expect(devShell).toContain('className="hidden sm:inline"');
2300
+ expect(devShell).toContain("data-localapp-user-label");
2301
+ expect(devShell).toContain("hidden md:inline");
2302
+ expect(devShell).toContain('className="flex shrink-0 items-center gap-1"');
2303
+ });
2304
+
2305
+ it("DevShell Issue 焦点陷阱排除 CSS 隐藏区域", () => {
2306
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2307
+
2308
+ expect(devShell).toContain("function isDevIssueFocusTargetVisible");
2309
+ expect(devShell).toContain('style.display === "none" || style.visibility === "hidden"');
2310
+ expect(devShell).toContain("isDevIssueFocusTargetVisible(element, dialog)");
2311
+ });
2312
+
2313
+ it("DevShell Issue 列表请求拥有覆盖 JSON body 的截止时间", () => {
2314
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2315
+
2316
+ expect(devShell).toContain("const DEV_ISSUE_LIST_REQUEST_TIMEOUT_MS = 8_000");
2317
+ expect(devShell).toContain("controller.abort(new DOMException(\"Issue list request timed out\", \"TimeoutError\"))");
2318
+ expect(devShell).toContain("window.clearTimeout(requestTimeout)");
2319
+ expect(devShell).toContain('requestError.name === "TimeoutError" ? "Issue 服务暂不可用"');
2320
+ });
2321
+
2322
+ it("DevShell Issue 详情读取与静默同步共享截止时间", () => {
2323
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2324
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
2325
+
2326
+ expect(devShell).toContain("async function requestDevIssue<T>");
2327
+ expect(devShell).toContain("const DEV_ISSUE_REQUEST_TIMEOUT_MS = 8_000");
2328
+ expect(workspace).toContain("requestDevIssue<DevIssueDetail>(`${endpoint}?${query.toString()}`, { credentials: \"include\" })");
2329
+ expect(workspace).toContain("requestDevIssue<DevIssueDetail>(`/api/issues/${issueId}?${params.toString()}`, { credentials: \"include\" })");
2330
+ });
2331
+
2332
+ it("DevShell Issue 写操作、附件与历史读取共享截止时间", () => {
2333
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2334
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
2335
+ const composer = devShell.slice(devShell.indexOf("function DevIssueComposer"), devShell.indexOf("function DevIssueMetadataPicker"));
2336
+ const revisions = devShell.slice(devShell.indexOf("function DevIssueRevisionDialog"), devShell.indexOf("function DevIssueDetailPanel"));
2337
+
2338
+ expect(workspace).not.toContain("await readDevIssueResponse<");
2339
+ expect(workspace).toContain("requestDevIssue<DevIssueDetail>(`/api/issues/${detail.issue.id}/comments`");
2340
+ expect(workspace).toContain("requestDevIssue<DevIssueDetail>(`/api/issues/${detail.issue.id}/reactions`");
2341
+ expect(composer).toContain('requestDevIssue<DevIssueAttachment>("/api/issues/attachments"');
2342
+ expect(revisions).toContain("requestDevIssue<DevIssueRevision[]>(`${target}?${query.toString()}`");
2343
+ });
2344
+
2345
+ it("DevShell 标签与负责人目录共享请求截止时间和卸载中止", () => {
2346
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2347
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
2348
+
2349
+ expect(workspace).toContain("requestDevIssue<DevIssueLabelDefinition[]>(`/api/issues/labels?${params.toString()}`");
2350
+ expect(workspace).toContain('requestDevIssue<{ users?: DevUserBasic[]; source?: string }>("/api/dev/users"');
2351
+ expect(devShell).toContain("const DEV_ISSUE_CATALOG_RETRY_DELAY_MS = 300");
2352
+ expect(devShell).toContain("function waitForDevIssueCatalogRetry(");
2353
+ expect(devShell).toContain("async function requestDevIssueCatalogWithRetry");
2354
+ expect(workspace).toContain("requestDevIssueCatalogWithRetry((signal) => requestDevIssue<DevIssueLabelDefinition[]>");
2355
+ expect(workspace).toContain("requestDevIssueCatalogWithRetry((signal) => requestDevIssue<DevIssueMilestoneDefinition[]>");
2356
+ expect(workspace).toContain("requestDevIssueCatalogWithRetry((signal) => requestDevIssue<{ users?: DevUserBasic[];");
2357
+ expect(workspace).toContain('controller.abort(new DOMException("Superseded", "AbortError"))');
2358
+ });
2359
+
2360
+ it("DevShell 不依赖 Tailwind 默认 palette class", () => {
2361
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2362
+ const forbiddenPatterns = [
2363
+ "bg-zinc-",
2364
+ "text-zinc-",
2365
+ "border-zinc-",
2366
+ "bg-indigo-",
2367
+ "text-indigo-",
2368
+ "border-indigo-",
2369
+ "bg-emerald-",
2370
+ "text-emerald-",
2371
+ "from-indigo-",
2372
+ "via-fuchsia-",
2373
+ "to-orange-",
2374
+ ];
2375
+
2376
+ for (const pattern of forbiddenPatterns) {
2377
+ expect(devShell, `DevShell must not use ${pattern}`).not.toContain(pattern);
2378
+ }
2379
+ });
2380
+
2381
+ it("runtime preset 声明 DevShell 专属样式 token", () => {
2382
+ const preset = readTemplateFile(path.join("runtime", "styles", "preset.css"));
2383
+ const requiredTokens = [
2384
+ "--localapp-dev",
2385
+ "--localapp-dev-foreground",
2386
+ "--localapp-dev-muted",
2387
+ "--localapp-dev-muted-foreground",
2388
+ "--localapp-dev-border",
2389
+ "--localapp-dev-focus",
2390
+ "--localapp-dev-accent",
2391
+ "--localapp-dev-accent-foreground",
2392
+ "--localapp-dev-stripe-from",
2393
+ "--localapp-dev-stripe-via",
2394
+ "--localapp-dev-stripe-to",
2395
+ "--color-localapp-dev",
2396
+ "--color-localapp-dev-muted",
2397
+ "--color-localapp-dev-border",
2398
+ "--color-localapp-dev-focus",
2399
+ ];
2400
+
2401
+ for (const token of requiredTokens) {
2402
+ expect(preset, `runtime preset must define ${token}`).toContain(token);
2403
+ }
2404
+ });
2405
+
2406
+ it("runtime preset 将 DevShell 源码加入 Tailwind 扫描范围", () => {
2407
+ const preset = readTemplateFile(path.join("runtime", "styles", "preset.css"));
2408
+
2409
+ expect(preset).toContain('@source "../dev-shell.tsx";');
2410
+ });
2411
+
2412
+ it("preset theme 映射支持生成 DevShell token utility", () => {
2413
+ const preset = readTemplateFile(path.join("runtime", "styles", "preset.css"));
2414
+
2415
+ expect(preset).toContain("--color-localapp-dev-muted: var(--localapp-dev-muted)");
2416
+ expect(preset).toContain("--color-localapp-dev-muted-foreground: var(--localapp-dev-muted-foreground)");
2417
+ expect(preset).toContain("--color-localapp-dev-border: var(--localapp-dev-border)");
2418
+ expect(preset).toContain("--color-localapp-dev-focus: var(--localapp-dev-focus)");
2419
+ expect(preset).toContain("--color-localapp-dev-stripe-from: var(--localapp-dev-stripe-from)");
2420
+ expect(preset).toContain("--color-localapp-dev-stripe-via: var(--localapp-dev-stripe-via)");
2421
+ expect(preset).toContain("--color-localapp-dev-stripe-to: var(--localapp-dev-stripe-to)");
2422
+ });
2423
+
2424
+ it("DevShell success token 与白字达到 AA 对比度", () => {
2425
+ const preset = readTemplateFile(path.join("runtime", "styles", "preset.css"));
2426
+ expect(preset).toContain("--localapp-dev-success: oklch(0.54 0.13 165)");
2427
+ });
2428
+
2429
+ it("DevShell 提供与 Hosted 同构的 Issue dependencies 工作区和阻塞标识", () => {
2430
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2431
+ const detailPanel = devShell.slice(devShell.indexOf("function DevIssueDetailPanel"), devShell.indexOf("function DevToolkitSidebar"));
2432
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
2433
+
2434
+ expect(devShell).toContain("function DevIssueDependencies(");
2435
+ expect(devShell).toContain("dependencySummary?: { blockedBy: number; blocking: number; unresolvedBlockers: number; isBlocked: boolean }");
2436
+ expect(devShell).toContain('data-localapp-issue-dependencies');
2437
+ expect(devShell).toContain("被以下 Issue 阻塞");
2438
+ expect(devShell).toContain("正在阻塞");
2439
+ expect(workspace).toContain("/dependencies/blocked-by/");
2440
+ expect(workspace).toContain("direction === \"blockedBy\"");
2441
+ expect(detailPanel.indexOf("<DevIssueSubIssues")).toBeLessThan(detailPanel.indexOf("<DevIssueDependencies"));
2442
+ const dependenciesIndex = detailPanel.indexOf("<DevIssueDependencies");
2443
+ expect(dependenciesIndex).toBeLessThan(detailPanel.indexOf("<DevIssueTimeline", dependenciesIndex));
2444
+ expect(devShell).toContain('aria-label="已阻塞:存在未解决依赖"');
2445
+ expect(devShell).toContain("Boolean(issue.is_blocked)");
2446
+ const preset = readTemplateFile(path.join("runtime", "styles", "preset.css"));
2447
+ expect(preset).toContain("[data-localapp-sub-issues] > header > div:last-child");
2448
+ expect(preset).toContain("flex-basis: 100%");
2449
+ });
2450
+
2451
+ it("DevShell 创建页提供竞态安全且非阻塞的潜在重复 Issue 建议", () => {
2452
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2453
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
2454
+ expect(devShell).toContain("function DevIssuePotentialDuplicates(");
2455
+ expect(workspace).toContain("/api/issues/potential-duplicates?");
2456
+ expect(workspace).toContain("Array.from(createBody).length < 100");
2457
+ expect(workspace).toContain("window.setTimeout(() =>");
2458
+ expect(workspace).toContain("controller.abort()");
2459
+ expect(workspace).toContain("onBodyChange={setCreateBody}");
2460
+ expect(devShell).toContain("const navigateToIssueNumber = useCallback((issueNumber: number)");
2461
+ expect(workspace).toContain("onIssueNumberNavigate(issueNumber)");
2462
+ expect(workspace).toContain("重复项建议暂不可用");
2463
+ expect(workspace).toContain("<DevIssuePotentialDuplicates");
2464
+ expect(workspace).toContain("submitDisabled={!createTitle.trim() || createTitleTooLong}");
2465
+ });
2466
+
2467
+ it("DevShell 完全离线提供应用 Issue 模板选择与草稿优先", () => {
2468
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2469
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
2470
+ expect(workspace).toContain("/api/issues/config?");
2471
+ expect(devShell).toContain("function DevIssueTemplateChooser(");
2472
+ expect(workspace).toContain('setView({ kind: "templates" })');
2473
+ expect(workspace).toContain("hasPersistedDevIssueCreateContent");
2474
+ expect(workspace).toContain("模板中的标签已不可用");
2475
+ expect(devShell).toContain("打开空白 Issue");
2476
+ expect(workspace).toContain("initialBody={createInitialBody}");
2477
+ expect(workspace).toContain("onCreateSubIssue={() => showCreateIssue(detail.issue.id)}");
2478
+ });
2479
+
2480
+ it("DevShell 完全离线提供当前用户私有保存视图", () => {
2481
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2482
+ const workspace = devShell.slice(devShell.indexOf("function DevIssuesWorkspace"), devShell.indexOf("function DevIssueMarkdown"));
2483
+ expect(devShell).toContain("type DevIssueSavedView");
2484
+ expect(workspace).toContain("/api/issues/views?");
2485
+ expect(workspace).toContain("/api/issues/views/${viewId}/copy");
2486
+ expect(workspace).toContain("保存的视图");
2487
+ expect(workspace).toContain("保存当前 Issue 视图");
2488
+ expect(workspace).toContain("有未保存更改");
2489
+ expect(workspace).toContain("删除保存视图");
2490
+ expect(workspace).toContain('<optgroup label="保存的视图">');
2491
+ expect(workspace).not.toContain("savedView.user_id");
2492
+ });
2493
+
2494
+ it("DevShell 评论 Composer 完全离线提供个人保存回复", () => {
2495
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2496
+ expect(devShell).toContain("/api/issues/saved-replies");
2497
+ expect(devShell).toContain('aria-label="保存回复"');
2498
+ expect(devShell).toContain('aria-label="搜索保存回复"');
2499
+ expect(devShell).toContain('aria-keyshortcuts="Control+."');
2500
+ expect(devShell).toContain('reply.body.indexOf("%cursor%")');
2501
+ expect(devShell).toContain('savedReplies = textareaLabel === "添加评论"');
2502
+ expect(devShell).toContain("确认删除");
2503
+ });
2504
+
2505
+ it("DevShell 同构展示并撤销 Duplicate Issue 关系", () => {
2506
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2507
+ expect(devShell).toContain("function DevIssueDuplicates(");
2508
+ expect(devShell).toContain("Canonical Issue #");
2509
+ expect(devShell).toContain("撤销重复标记");
2510
+ expect(devShell).toContain("marked_as_duplicate");
2511
+ expect(devShell).toContain("unmarked_as_duplicate");
2512
+ expect(devShell).toContain("/duplicate/${canonicalIssueId}");
2513
+ expect(devShell).toContain("is_duplicate?: number");
2514
+ expect(devShell).toContain(">重复</span>");
2515
+ expect(devShell).toContain("setUnmarking(true)");
2516
+ expect(devShell).toContain('succeeded ? document.querySelector<HTMLElement>("[data-localapp-issue-title]") : undoRef.current');
2517
+ });
2518
+
2519
+ it("DevShell 同构展示并导航 Issue cross-reference", () => {
2520
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2521
+ expect(devShell).toContain("function DevIssueCrossReference(");
2522
+ expect(devShell).toContain("cross_reference");
2523
+ expect(devShell).toContain("中提到了此 Issue");
2524
+ expect(devShell).toContain("createDevIssueCrossReferenceHref");
2525
+ expect(devShell).toContain("pendingReferenceCommentIdRef");
2526
+ expect(devShell).toContain('item.kind === "event" ? [item.event.actor_id] : [item.crossReference.actor_id]');
2527
+ expect(devShell).toContain("pendingIssueChangedIdsRef.current.add(changed.issueId ?? null)");
2528
+ });
2529
+
2530
+ it("DevShell 完全离线提供单条置顶评论", () => {
2531
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2532
+ expect(devShell).toContain("pinned_at?: string | null");
2533
+ expect(devShell).toContain("pinned_by?: string | null");
2534
+ expect(devShell).toContain("/comments/${commentId}/pin");
2535
+ expect(devShell).toContain('method: pinned ? "PUT" : "DELETE"');
2536
+ expect(devShell).toContain("canManageCommentPins");
2537
+ expect(devShell).toContain("data-localapp-issue-comment-pinned");
2538
+ expect(devShell).toContain("filteredTimeline.unshift(pinnedComment)");
2539
+ expect(devShell).toContain('label: comment.pinned_at ? "取消置顶评论" : "置顶评论"');
2540
+ expect(devShell).toContain("disabled: pinningCommentId !== null");
2541
+ expect(devShell).toContain("setPinningCommentId(comment.id)");
2542
+ expect(devShell).toContain("{comment.pinned_at && <div");
2543
+ expect(devShell).not.toContain("{(comment.pinned_at || (canManageCommentPins && !comment.deleted_at)) && <div");
2544
+ expect(devShell).toContain("comment_pinned");
2545
+ expect(devShell).toContain("comment_unpinned");
2546
+ });
2547
+
2548
+ it("DevShell 完全离线提供评论最小化与临时展开", () => {
2549
+ const devShell = readTemplateFile("runtime/dev-shell.tsx");
2550
+ expect(devShell).toContain("DevIssueCommentMinimizedReason");
2551
+ expect(devShell).toContain("DEV_ISSUE_COMMENT_MINIMIZED_REASON_LABELS");
2552
+ expect(devShell).toContain("/comments/${commentId}/minimize");
2553
+ expect(devShell).toContain("data-localapp-issue-comment-minimized");
2554
+ expect(devShell).toContain("expandedMinimizedComments");
2555
+ expect(devShell).toContain('role="alertdialog" aria-label="最小化评论"');
2556
+ expect(devShell).toContain("comment_minimized");
2557
+ expect(devShell).toContain("comment_unminimized");
2558
+ });
2559
+
2560
+ it("DevShell 关键控件的 computed style 不回退到透明背景或默认文本色", () => {
2561
+ const css = cssForRuntimeTokens();
2562
+ expect(css).toContain("--localapp-dev-muted:");
2563
+ expect(css).toContain("--localapp-dev-accent:");
2564
+ const style = document.createElement("style");
2565
+ style.textContent = css;
2566
+ document.head.appendChild(style);
2567
+
2568
+ const devButton = document.createElement("button");
2569
+ devButton.className = "bg-localapp-dev-muted text-localapp-dev-muted-foreground border-localapp-dev-border ring-localapp-dev-focus";
2570
+ document.body.appendChild(devButton);
2571
+
2572
+ const userState = document.createElement("span");
2573
+ userState.className = "text-localapp-dev-muted-foreground";
2574
+ document.body.appendChild(userState);
2575
+
2576
+ const button = document.createElement("button");
2577
+ button.className = "bg-localapp-dev-accent text-localapp-dev-accent-foreground";
2578
+ document.body.appendChild(button);
2579
+
2580
+ expect(getComputedStyle(devButton).backgroundColor).not.toBe("");
2581
+ expect(getComputedStyle(devButton).backgroundColor).not.toBe(TRANSPARENT);
2582
+ expect(getComputedStyle(devButton).color).not.toBe("");
2583
+ expect(getComputedStyle(devButton).color).not.toBe("rgb(0, 0, 0)");
2584
+ expect(getComputedStyle(devButton).outlineColor).not.toBe("");
2585
+ expect(getComputedStyle(devButton).outlineColor).not.toBe("rgb(0, 0, 0)");
2586
+ expect(getComputedStyle(userState).color).not.toBe("");
2587
+ expect(getComputedStyle(userState).color).not.toBe("rgb(0, 0, 0)");
2588
+ expect(getComputedStyle(button).backgroundColor).not.toBe("");
2589
+ expect(getComputedStyle(button).backgroundColor).not.toBe(TRANSPARENT);
2590
+ expect(getComputedStyle(button).color).not.toBe("");
2591
+ expect(getComputedStyle(button).color).not.toBe("rgb(0, 0, 0)");
2592
+ });
2593
+ });