@brigade-dev/cli 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/app-path-routes-manifest.json +12 -12
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/(board)/board/page.js +1 -1
- package/.next/standalone/.next/server/app/(board)/board/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/(board)/board/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(board)/r/[repoId]/board/page.js +2 -2
- package/.next/standalone/.next/server/app/(board)/r/[repoId]/board/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/(board)/r/[repoId]/board/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(board)/r/[repoId]/task/[slug]/page.js +2 -2
- package/.next/standalone/.next/server/app/(board)/r/[repoId]/task/[slug]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/(board)/r/[repoId]/task/[slug]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(board)/task/[slug]/page.js +1 -1
- package/.next/standalone/.next/server/app/(board)/task/[slug]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/(board)/task/[slug]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(setup)/setup/page.js +2 -2
- package/.next/standalone/.next/server/app/(setup)/setup/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/(setup)/setup/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +2 -2
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/api/chat/poll/route.js +1 -1
- package/.next/standalone/.next/server/app/api/chat/poll/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/chat/route.js +1 -1
- package/.next/standalone/.next/server/app/api/chat/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/chat/session/route.js +1 -1
- package/.next/standalone/.next/server/app/api/chat/session/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/chat/sessions/route.js +1 -1
- package/.next/standalone/.next/server/app/api/chat/sessions/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/chat/stop/route.js +1 -1
- package/.next/standalone/.next/server/app/api/chat/stop/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/providers/auth-status/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/repos/[repoId]/chat/[[...path]]/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/repos/[repoId]/route.js +1 -1
- package/.next/standalone/.next/server/app/api/repos/[repoId]/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/repos/[repoId]/settings/[[...path]]/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/repos/[repoId]/tasks/[[...path]]/route.js +1 -1
- package/.next/standalone/.next/server/app/api/repos/[repoId]/tasks/[[...path]]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/repos/[repoId]/tasks/[[...path]]/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/repos/last-used/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/repos/pick-folder/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/repos/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/chat/reset/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/chat/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/create-branch/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/create-pr/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/data/rename/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/generate-commit-message/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/git/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/handoff/review/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/handoff/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/images/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/improve-title/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/merge-pr/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/move/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/pr-status/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/question-options/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/resolve-conflicts/launch/route.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/resolve-conflicts/launch/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/resolve-conflicts/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/route.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/status/route.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/[slug]/status/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/auto-move/route.js +2 -2
- package/.next/standalone/.next/server/app/api/tasks/auto-move/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/tasks/auto-move/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/counts/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/pr-check/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/route.js +1 -1
- package/.next/standalone/.next/server/app/api/tasks/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/test/reset/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.meta +2 -0
- package/.next/standalone/.next/server/app/index.rsc +13 -27
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +5 -14
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +13 -27
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -3
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/page.js +2 -2
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app-paths-manifest.json +12 -12
- package/.next/standalone/.next/server/chunks/2065.js +3 -3
- package/.next/standalone/.next/server/chunks/347.js +1 -1
- package/.next/standalone/.next/server/chunks/3544.js +2 -2
- package/.next/standalone/.next/server/chunks/{1853.js → 5198.js} +1 -1
- package/.next/standalone/.next/server/chunks/5704.js +1 -1
- package/.next/standalone/.next/server/chunks/5722.js +1 -0
- package/.next/standalone/.next/server/chunks/6802.js +1 -1
- package/.next/standalone/.next/server/chunks/8031.js +1 -1
- package/.next/standalone/.next/server/chunks/8825.js +3 -0
- package/.next/standalone/.next/server/chunks/9067.js +1 -1
- package/.next/standalone/.next/server/chunks/9967.js +1 -0
- package/.next/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/.next/standalone/.next/server/next-font-manifest.js +1 -1
- package/.next/standalone/.next/server/next-font-manifest.json +1 -1
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +2 -2
- package/.next/standalone/.next/static/chunks/1416-76d75f5cdc8064f0.js +5 -0
- package/.next/standalone/.next/static/chunks/3242-340ecc54abc559dc.js +1 -0
- package/.next/standalone/.next/static/chunks/4555-1cc0cadfd257b640.js +5 -0
- package/.next/standalone/.next/static/chunks/{5083-875e22a46dea6150.js → 5083-da5fc913278c9ec9.js} +3 -3
- package/.next/standalone/.next/static/chunks/app/(board)/board/page-d97d7979cfd5798f.js +1 -0
- package/.next/standalone/.next/static/chunks/app/(board)/r/[repoId]/board/page-2a12cb83a038bfa4.js +1 -0
- package/.next/standalone/.next/static/chunks/app/(board)/r/[repoId]/layout-94f90e6400c32897.js +1 -0
- package/.next/standalone/.next/static/chunks/app/(board)/r/[repoId]/task/[slug]/{page-0703323a4462caf0.js → page-c7b0b0a0327f6fce.js} +1 -1
- package/.next/standalone/.next/static/chunks/app/(board)/task/[slug]/{page-e5278f44e5936ae3.js → page-771b7f853905319b.js} +1 -1
- package/.next/standalone/.next/static/chunks/app/(setup)/{layout-1b51237f7b3ff3ff.js → layout-7eb803c6eff71185.js} +1 -1
- package/.next/standalone/.next/static/chunks/app/(setup)/setup/page-dccadc7f0cc15702.js +1 -0
- package/.next/standalone/.next/static/chunks/app/_global-error/{page-1b51237f7b3ff3ff.js → page-7eb803c6eff71185.js} +1 -1
- package/.next/standalone/.next/static/chunks/app/api/chat/poll/{route-1b51237f7b3ff3ff.js → route-7eb803c6eff71185.js} +1 -1
- package/.next/standalone/.next/static/chunks/app/api/chat/{route-1b51237f7b3ff3ff.js → route-7eb803c6eff71185.js} +1 -1
- package/.next/standalone/.next/static/chunks/app/api/chat/session/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/chat/sessions/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/chat/stop/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/providers/auth-status/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/repos/[repoId]/chat/[[...path]]/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/repos/[repoId]/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/repos/[repoId]/settings/[[...path]]/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/repos/[repoId]/tasks/[[...path]]/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/repos/last-used/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/repos/pick-folder/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/repos/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/chat/reset/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/chat/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/create-branch/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/create-pr/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/data/rename/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/generate-commit-message/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/git/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/handoff/review/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/handoff/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/images/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/improve-title/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/merge-pr/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/move/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/pr-status/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/question-options/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/resolve-conflicts/launch/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/resolve-conflicts/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/status/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/auto-move/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/counts/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/pr-check/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tasks/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/test/reset/route-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/app/layout-c38fc01326ac060a.js +1 -0
- package/.next/standalone/.next/static/chunks/app/page-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-7eb803c6eff71185.js +1 -0
- package/.next/standalone/.next/static/chunks/{webpack-3e5366b71e90a143.js → webpack-010bc8c5cfa5e600.js} +1 -1
- package/.next/standalone/.next/static/css/a0a0423b02496c0c.css +3 -0
- package/.next/standalone/.next/static/media/636a5ac981f94f8b-s.p.woff2 +0 -0
- package/.next/standalone/.next/static/media/6fe53d21e6e7ebd8-s.woff2 +0 -0
- package/.next/standalone/.next/static/media/8ebc6e9dde468c4a-s.woff2 +0 -0
- package/.next/standalone/.next/static/media/9e7b0a821b9dfcb4-s.woff2 +0 -0
- package/.next/standalone/package.json +1 -1
- package/bin/brigade.js +8 -10
- package/package.json +1 -1
- package/.next/standalone/.next/server/chunks/5049.js +0 -1
- package/.next/standalone/.next/server/chunks/542.js +0 -1
- package/.next/standalone/.next/server/chunks/6039.js +0 -1
- package/.next/standalone/.next/server/chunks/944.js +0 -3
- package/.next/standalone/.next/static/chunks/1416-bf500768058c7f99.js +0 -5
- package/.next/standalone/.next/static/chunks/8409-b769c7ca171825cc.js +0 -1
- package/.next/standalone/.next/static/chunks/9747-9c7022a3f430588b.js +0 -5
- package/.next/standalone/.next/static/chunks/app/(board)/board/page-afa17ad02f1a5b72.js +0 -1
- package/.next/standalone/.next/static/chunks/app/(board)/r/[repoId]/board/page-c5245960945c7d7a.js +0 -1
- package/.next/standalone/.next/static/chunks/app/(board)/r/[repoId]/layout-2ffd1120d8289ecd.js +0 -1
- package/.next/standalone/.next/static/chunks/app/(setup)/setup/page-cc8922011a51f165.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/chat/session/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/chat/sessions/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/chat/stop/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/providers/auth-status/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/repos/[repoId]/chat/[[...path]]/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/repos/[repoId]/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/repos/[repoId]/settings/[[...path]]/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/repos/[repoId]/tasks/[[...path]]/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/repos/last-used/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/repos/pick-folder/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/repos/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/chat/reset/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/chat/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/create-branch/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/create-pr/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/data/rename/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/generate-commit-message/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/git/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/handoff/review/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/handoff/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/images/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/improve-title/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/merge-pr/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/move/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/pr-status/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/question-options/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/resolve-conflicts/launch/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/resolve-conflicts/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/[slug]/status/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/auto-move/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/counts/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/pr-check/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tasks/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/test/reset/route-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/app/layout-e77efc16259e5bd2.js +0 -1
- package/.next/standalone/.next/static/chunks/app/page-3e702bf1b197ec82.js +0 -1
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-1b51237f7b3ff3ff.js +0 -1
- package/.next/standalone/.next/static/css/214e23fa1231e12f.css +0 -3
- package/.next/standalone/.next/static/css/e91b8c49739f08d3.css +0 -1
- /package/.next/standalone/.next/static/{XO1LWKVmDXHwIbl35KRwX → TEeaHQlTW3yW085fWMfjB}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{XO1LWKVmDXHwIbl35KRwX → TEeaHQlTW3yW085fWMfjB}/_ssgManifest.js +0 -0
package/.next/standalone/.next/static/chunks/{5083-875e22a46dea6150.js → 5083-da5fc913278c9ec9.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5083],{5083:(e,t,s)=>{s.r(t),s.d(t,{default:()=>ti});var r=s(5155),n=s(3321),a=s(2115),l=s(4621),i=s(8990),o=s(6218);function c({className:e,children:t,...s}){return(0,r.jsxs)(i.bL,{"data-slot":"scroll-area",className:(0,o.cn)("relative",e),...s,children:[(0,r.jsx)(i.LM,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] outline-none transition-[color,box-shadow] focus-visible:outline-1 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:t}),(0,r.jsx)(d,{}),(0,r.jsx)(i.OK,{})]})}function d({className:e,orientation:t="vertical",...s}){return(0,r.jsx)(i.VM,{"data-slot":"scroll-area-scrollbar",orientation:t,className:(0,o.cn)("flex touch-none select-none p-px transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:(0,r.jsx)(i.lr,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}var u=s(9239),m=s(6998),x=s(8528);function p({title:e,count:t,defaultOpen:s=!1,onToggleAll:n,toggleAllLabel:l,children:i}){let[o,c]=(0,a.useState)(s);return(0,r.jsxs)("div",{className:"rounded border bg-muted/30",children:[(0,r.jsxs)("div",{className:"flex cursor-pointer items-center gap-1.5 overflow-hidden px-3 py-2",onClick:()=>c(!o),children:[o?(0,r.jsx)(m.A,{className:"size-3.5 text-muted-foreground"}):(0,r.jsx)(x.A,{className:"size-3.5 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-sm font-medium",children:e}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",t,")"]}),n&&t>0&&(0,r.jsx)("button",{className:"ml-auto shrink-0 text-xs text-primary underline hover:text-primary/80 cursor-pointer",onClick:e=>{e.stopPropagation(),n()},children:l??"Toggle all"})]}),o&&(0,r.jsx)("div",{className:"overflow-hidden border-t px-3 py-2",children:i})]})}var f=s(2609),h=s(9304),g=s(4374);function b(e){return e.startsWith("diff --git")?"font-bold text-foreground bg-muted/50 pt-3 mt-2":e.startsWith("@@")?"text-blue-600 font-semibold bg-blue-500/10":e.startsWith("+")&&!e.startsWith("+++")?"bg-green-500/10 text-green-800":e.startsWith("-")&&!e.startsWith("---")?"bg-red-500/10 text-red-800":""}function j({diff:e,truncated:t,totalLines:s,maxHeight:n="400px"}){if(!e)return(0,r.jsx)("div",{className:"flex items-center justify-center py-4 text-xs text-muted-foreground",children:"No changes"});let a=function(e){let t=e.split("\n"),s=[],r=null;for(let e of t){let t=e.match(/^diff --git a\/(.+?) b\/(.+)$/);t?(r&&s.push(r),r={filePath:t[2],lines:[e]}):r&&r.lines.push(e)}return r&&s.push(r),s}(e),l=a.length>0;return(0,r.jsx)(c,{style:{maxHeight:n},children:(0,r.jsxs)("div",{className:"font-mono text-[11px] leading-relaxed",children:[l?a.map((e,t)=>(0,r.jsx)("div",{children:e.lines.map((e,s)=>(0,r.jsx)("div",{className:`px-2 py-px whitespace-pre ${b(e)}`,children:e||"\xa0"},`${t}-${s}`))},t)):e.split("\n").map((e,t)=>(0,r.jsx)("div",{className:`px-2 py-px whitespace-pre ${b(e)}`,children:e||"\xa0"},t)),t&&(0,r.jsxs)("div",{className:"mt-2 px-2 py-1.5 rounded bg-amber-500/10 border border-amber-500/20 text-amber-800 text-xs",children:["Diff truncated — showing first 5,000 of"," ",s?.toLocaleString()," lines"]})]})})}var y=s(8368);let v={M:{label:"M",color:"text-orange-500"},A:{label:"A",color:"text-green-600"},D:{label:"D",color:"text-red-600"},R:{label:"R",color:"text-blue-500"},"?":{label:"?",color:"text-gray-500"},C:{label:"C",color:"text-purple-500"},U:{label:"U",color:"text-yellow-600"}};function N({status:e,path:t,linesAdded:s,linesRemoved:n,checked:l,onToggle:i,slug:o,repoId:c,staged:d}){let u=v[e]||{label:e,color:"text-muted-foreground"},[p,b]=(0,a.useState)(!1),[N,w]=(0,a.useState)(null),[k,C]=(0,a.useState)(!1),[S,A]=(0,a.useState)(!1),[$,z]=(0,a.useState)(0),I=s??0,E=n??0,T=(0,a.useMemo)(()=>o?(0,y.jx)(c,o):null,[c,o]),R=!!o&&"?"!==e,D=async e=>{if(e.stopPropagation(),R){if(p)return void b(!1);if(b(!0),null===N){C(!0);try{let e=await fetch(`${T}/git`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"diff-file",file:t,staged:d})}),s=await e.json();w(s.diff||""),A(s.truncated||!1),z(s.totalLines||0)}catch{w("")}finally{C(!1)}}}};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2 rounded px-1 py-0.5 text-xs",children:[i&&(0,r.jsx)("div",{className:"flex cursor-pointer items-center",onClick:i,children:l?(0,r.jsx)(f.A,{className:"size-4 shrink-0 text-primary"}):(0,r.jsx)(h.A,{className:"size-4 shrink-0 text-muted-foreground/50"})}),(0,r.jsxs)("div",{className:`flex min-w-0 flex-1 items-center gap-2 rounded px-1 py-0.5 ${R?"cursor-pointer hover:bg-muted/50":""}`,onClick:R?D:void 0,children:[R&&(p?(0,r.jsx)(m.A,{className:"size-3 shrink-0 text-muted-foreground"}):(0,r.jsx)(x.A,{className:"size-3 shrink-0 text-muted-foreground"})),(0,r.jsx)("span",{className:`shrink-0 font-mono font-bold ${u.color}`,children:u.label}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground/80",children:t}),(I>0||E>0)&&(0,r.jsxs)("span",{className:"ml-auto flex shrink-0 items-center gap-1 font-mono tabular-nums",children:[I>0&&(0,r.jsxs)("span",{className:"text-green-600",children:["+",I]}),E>0&&(0,r.jsxs)("span",{className:"text-red-600",children:["-",E]})]})]})]}),p&&(0,r.jsx)("div",{className:"ml-6 mt-1 mb-2 rounded border bg-muted/10 overflow-hidden",children:k?(0,r.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,r.jsx)(g.A,{className:"size-3.5 animate-spin text-muted-foreground"})}):(0,r.jsx)(j,{diff:N||"",truncated:S,totalLines:$,maxHeight:"300px"})})]})}let w={M:{label:"M",color:"text-orange-500"},A:{label:"A",color:"text-green-600"},D:{label:"D",color:"text-red-600"},R:{label:"R",color:"text-blue-500"},C:{label:"C",color:"text-purple-500"}};function k({hash:e,author:t,relativeTime:s,message:n,files:l,slug:i,repoId:o}){let[c,d]=(0,a.useState)(!1),[u,p]=(0,a.useState)({}),[f,h]=(0,a.useState)(null),[b,v]=(0,a.useState)(null),N=(0,a.useMemo)(()=>i?(0,y.jx)(o,i):null,[o,i]),k=async t=>{if(b===t)return void v(null);if((v(t),!u[t])&&N){h(t);try{let s=await fetch(`${N}/git`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"diff-commit",hash:e,file:t})}),r=await s.json();p(e=>({...e,[t]:{diff:r.diff||"",truncated:r.truncated||!1,totalLines:r.totalLines||0}}))}catch{p(e=>({...e,[t]:{diff:"",truncated:!1,totalLines:0}}))}finally{h(null)}}};return(0,r.jsxs)("div",{className:"rounded border bg-muted/20",children:[(0,r.jsxs)("div",{className:"flex cursor-pointer items-center gap-2 px-3 py-2",onClick:()=>d(!c),children:[c?(0,r.jsx)(m.A,{className:"size-3 shrink-0 text-muted-foreground"}):(0,r.jsx)(x.A,{className:"size-3 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"min-w-0 truncate text-sm",children:n}),(0,r.jsx)("span",{className:"ml-auto shrink-0 font-mono text-[10px] text-muted-foreground",children:e})]}),c&&(0,r.jsxs)("div",{className:"border-t px-3 py-2",children:[(0,r.jsxs)("div",{className:"text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:t}),(0,r.jsx)("span",{className:"mx-1.5",children:"\xb7"}),(0,r.jsx)("span",{children:s})]}),l&&l.length>0&&(0,r.jsx)("div",{className:"mt-2 flex flex-col gap-0.5",children:l.map((e,t)=>{let s=w[e.status]||{label:e.status,color:"text-muted-foreground"},n=b===e.path,a=!!i;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:`flex min-w-0 items-center gap-2 text-xs rounded px-1 py-0.5 ${a?"cursor-pointer hover:bg-muted/50":""}`,onClick:a?()=>k(e.path):void 0,children:[a&&(n?(0,r.jsx)(m.A,{className:"size-3 shrink-0 text-muted-foreground"}):(0,r.jsx)(x.A,{className:"size-3 shrink-0 text-muted-foreground"})),(0,r.jsx)("span",{className:`shrink-0 font-mono font-bold ${s.color}`,children:s.label}),(0,r.jsx)("span",{className:"truncate font-mono text-foreground/70",children:e.path})]}),n&&(0,r.jsx)("div",{className:"ml-5 mt-1 mb-2 rounded border bg-muted/10 overflow-hidden",children:f===e.path?(0,r.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,r.jsx)(g.A,{className:"size-3.5 animate-spin text-muted-foreground"})}):(0,r.jsx)(j,{diff:u[e.path]?.diff||"",truncated:u[e.path]?.truncated,totalLines:u[e.path]?.totalLines,maxHeight:"300px"})})]},t)})})]})]})}var C=s(5413),S=s(1679);function A({slug:e,repoId:t}){let[s,n]=(0,a.useState)(null),[l,i]=(0,a.useState)(!0),[o,d]=(0,a.useState)(null),[m,x]=(0,a.useState)(!1),[f,h]=(0,a.useState)(null),[b,v]=(0,a.useState)(!1),[w,A]=(0,a.useState)(!1),[$,z]=(0,a.useState)(0),I=(0,a.useMemo)(()=>(0,y.jx)(t,e),[t,e]),E=(0,a.useCallback)(async()=>{i(!0),d(null);try{let e=await fetch(`${I}/git`),t=await e.json();t.error?(d(t.error),n(null)):n(t)}catch{d("Failed to fetch git status")}finally{i(!1)}},[I]);(0,a.useEffect)(()=>{E()},[E]);let T=async()=>{if(m)return void x(!1);if(x(!0),null===f){v(!0);try{let e=await fetch(`${I}/git`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"diff-branch"})}),t=await e.json();h(t.diff||""),A(t.truncated||!1),z(t.totalLines||0)}catch{h("")}finally{v(!1)}}},R=(0,a.useMemo)(()=>{if(!s)return[];let e=new Set,t=[];for(let r of s.staged)e.add(r.path),t.push({...r,staged:!0});for(let r of s.unstaged)e.has(r.path)||t.push(r);return t},[s]);return(0,r.jsx)("div",{className:"flex h-full flex-col",children:(0,r.jsx)(c,{className:"flex-1 min-h-0",children:(0,r.jsxs)("div",{className:"flex w-0 min-w-full flex-col gap-3 overflow-hidden p-3",children:[l&&!s&&(0,r.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,r.jsx)(g.A,{className:"size-4 animate-spin"})}),o&&(0,r.jsx)("div",{className:"rounded border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:o}),s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(p,{title:"Changes",count:R.length,defaultOpen:R.length>0,children:0===R.length?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"No changes"}):R.map((s,n)=>(0,r.jsx)(N,{status:s.status,path:s.path,linesAdded:s.linesAdded,linesRemoved:s.linesRemoved,slug:e,repoId:t,staged:s.staged},n))}),!s.onMain&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center gap-1.5",children:[(0,r.jsx)(C.A,{className:"size-3.5 text-muted-foreground"}),(0,r.jsx)("h3",{className:"text-sm font-medium",children:"Commits"})]}),0===s.commits.length?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"No commits on this branch yet"}):(0,r.jsx)("div",{className:"flex flex-col gap-1.5",children:s.commits.map(s=>(0,r.jsx)(k,{...s,slug:e,repoId:t},s.hash))})]}),!s.onMain&&s.commits.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)(u.$,{variant:"outline",size:"sm",onClick:T,className:"w-full gap-1.5 cursor-pointer",children:[(0,r.jsx)(S.A,{className:"size-3.5"}),m?"Hide all changes":"View all changes vs main"]}),m&&(0,r.jsx)("div",{className:"mt-2 rounded border bg-muted/10 overflow-hidden",children:b?(0,r.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,r.jsx)(g.A,{className:"size-4 animate-spin text-muted-foreground"})}):(0,r.jsx)(j,{diff:f||"",truncated:w,totalLines:$,maxHeight:"500px"})})]})]})]})})})}var $=s(2270);function z(e){return"object"==typeof e&&null!==e}let I=[/oauth token has expired/i,/token has expired/i,/expired.*token/i,/authentication_error/i,/failed to authenticate/i,/please obtain a new token/i];function E(e){let t,s=e.trim(),r=((t=s.match(/\{[\s\S]*"(?:message|detail)"\s*:\s*"([^"]+)"[\s\S]*\}/))?t[1]:null)??s;return/internal server error/i.test(r)?{message:"The AI service hit a temporary issue. You can try sending your message again.",details:s}:/overloaded/i.test(r)?{message:"The AI service is currently overloaded. Please wait a moment and try again.",details:s}:/rate limit/i.test(r)?{message:"Too many requests. Please wait a moment and try again.",details:s}:I.some(e=>e.test(r))?{message:"Authentication expired. Reconnect Claude CLI (`claude auth login`) and try again.",details:s}:/authentication|unauthorized|invalid.*key/i.test(r)?{message:"There was an authentication problem with the AI service.",details:s}:/chat request failed/i.test(r)?{message:"Couldn't reach the AI service. Check your connection and try again.",details:s}:{message:r}}function T(e){return"object"==typeof e&&null!==e}var R=s(9366);let D=new Set;function O(e,t){if(0===t.length&&e.length>0||t.length<e.length)return!1;if(t.length>e.length)return!0;for(let s=0;s<t.length;s++){let r=t[s],n=e[s];if(!n||r.id!==n.id||r.role!==n.role||(0,R.B)(n,r))return!0}return!1}function _(e){if("string"!=typeof e)return null;let t=e.trim();return!t||t.startsWith("pending-")?null:t}function L(e){let t=[],s=e=>{if("string"!=typeof e)return;let s=e.trim();s&&t.push(s)};if(s(e.result),s(e.error),Array.isArray(e.errors))for(let t of e.errors)s(t);return t}var P=s(7536),M=s(8884),F=s(7268),U=s(9392),W=s(4380),B=s(2515),q=s(9056),J=s(9664),H=s(3647),G=s(257),Y=s(1436),K=s(8541),Q=s(9683),V=s(3774),X=s(9702),Z=s(6336);let ee=(0,s(7206).default)(()=>Promise.all([s.e(161),s.e(232)]).then(s.bind(s,7851)).then(e=>({default:e.CodeBlock})),{loadableGenerated:{webpack:()=>[7851]},ssr:!1});function et(e){try{let t=JSON.parse(e);return{code:JSON.stringify(t,null,2),language:"json"}}catch{return{code:e,language:"text"}}}function es(e){try{let t=JSON.parse(e);return"object"==typeof t&&null!==t?t:null}catch{return null}}function er(e){let t=e.split("/").filter(Boolean);return t.length<=2?e:t.slice(-2).join("/")}let en={Bash:U.A,Read:W.A,Edit:B.A,Write:q.A,Grep:J.A,Glob:H.A,WebFetch:G.A,WebSearch:G.A,Task:Y.A,TodoWrite:K.A,Skill:Q.A,NotebookEdit:V.A},ea={borderRadius:"0.25rem",padding:"0.375rem",fontFamily:'"JetBrains Mono", monospace',maxHeight:"8rem",overflow:"auto"};function el({toolCall:e,isStreaming:t,subtle:s=!1}){let[n,l]=(0,a.useState)(!1),i=en[e.name]??X.A,o=!!e.output,c=!o&&!!t,{text:d,code:u}=function(e,t){let s=es(t);switch(e){case"Read":{let e=s?.file_path;return e?{text:"Read",code:er(e)}:{text:"Read file"}}case"Edit":{let e=s?.file_path;return e?{text:"Edit",code:er(e)}:{text:"Edit file"}}case"Write":{let e=s?.file_path;return e?{text:"Write",code:er(e)}:{text:"Write file"}}case"Bash":{let e=s?.command;if(!e)return{text:"Run command"};return{text:"Run",code:e.length>60?e.slice(0,57)+"...":e}}case"Grep":{let e=s?.pattern,t=s?.path;if(!e)return{text:"Search files"};let r=t?` in ${er(t)}`:"";return{text:"Search for",code:`${e}${r}`}}case"Glob":{let e=s?.pattern;return e?{text:"Find files",code:e}:{text:"Find files"}}case"WebFetch":{let e=s?.url;if(!e)return{text:"Fetch URL"};try{return{text:"Fetch",code:new URL(e).hostname}}catch{return{text:"Fetch URL"}}}case"WebSearch":{let e=s?.query;return e?{text:"Search web for",code:e}:{text:"Search the web"}}case"Task":{let e=s?.description;return e?{text:"Launch agent:",code:e}:{text:"Launch sub-agent"}}case"TodoWrite":return{text:"Update task list"};case"Skill":{let e=s?.skill;return e?{text:"Use skill",code:e}:{text:"Use skill"}}case"NotebookEdit":return{text:"Edit notebook"};default:return{text:e}}}(e.name,e.input);return(0,r.jsxs)("div",{className:s?"text-xs":"rounded-md border text-xs",children:[(0,r.jsxs)("button",{type:"button",className:`flex w-full cursor-pointer items-center gap-1.5 text-left transition-colors ${s?"py-0.5 text-muted-foreground hover:text-foreground":"rounded-md px-2 py-1.5 hover:bg-accent/50"}`,onClick:()=>l(!n),children:[c?(0,r.jsx)(g.A,{className:`shrink-0 animate-spin ${s?"size-3 text-orange-500":"size-3.5 text-amber-500"}`}):o?(0,r.jsx)("div",{className:`flex shrink-0 items-center justify-center rounded-full ${s?"size-3 text-muted-foreground":"size-3.5 bg-muted text-muted-foreground"}`,children:(0,r.jsx)(Z.A,{className:"size-2.5",strokeWidth:3})}):(0,r.jsx)("div",{className:`shrink-0 rounded-full border border-muted-foreground/30 ${s?"size-2.5":"size-3.5"}`}),(0,r.jsx)(i,{className:"size-3 shrink-0 text-muted-foreground"}),(0,r.jsxs)("span",{className:`flex-1 truncate ${s?"text-muted-foreground":"text-foreground"}`,children:[d,u&&(0,r.jsxs)(r.Fragment,{children:[" ",(0,r.jsx)("code",{className:`${s?"font-mono text-[11px] text-muted-foreground/90":"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-muted-foreground"}`,children:u})]})]}),n?(0,r.jsx)(m.A,{className:"size-3 shrink-0 text-muted-foreground"}):(0,r.jsx)(x.A,{className:"size-3 shrink-0 text-muted-foreground"})]}),n&&(0,r.jsxs)("div",{className:`${s?"ml-6 border-l border-border/70 pl-2.5 py-1.5 space-y-1.5":"border-t px-2 py-1.5 space-y-1.5"}`,children:[e.input&&(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Input"}),(()=>{let{code:t,language:s}=et(e.input);return(0,r.jsx)(ee,{code:t,language:s,variant:"dark",wrapLongLines:!0,customStyle:{...ea,marginTop:"0.25rem"}})})()]}),e.output&&(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Output"}),(()=>{let{code:t,language:s}=et(e.output);return(0,r.jsx)(ee,{code:t,language:s,variant:"dark",wrapLongLines:!0,customStyle:{...ea,marginTop:"0.25rem"}})})()]}),c&&!e.output&&(0,r.jsxs)("div",{className:`flex items-center gap-1.5 py-1 text-[11px] ${s?"text-orange-600":"text-amber-600"}`,children:[(0,r.jsx)(g.A,{className:"size-3 animate-spin"}),(0,r.jsx)("span",{children:"Running..."})]})]})]})}var ei=s(2773),eo=s(9266);function ec({questions:e,onAnswer:t,isAnswered:s}){let[n,l]=(0,a.useState)({}),[i,c]=(0,a.useState)({}),[d,u]=(0,a.useState)(!1),m=s||d||!t,x=1===e.length&&!e[0].multiSelect,p=(0,a.useCallback)(t=>{let s=e.map((s,r)=>{let a=n[r]||[],l=(t?.[r]??i[r])?.trim(),o=[...a];if(l&&o.push(l),1===e.length)return o.join(", ");let c=s.header||`Q${r+1}`;return`${c}: ${o.join(", ")}`});return 1===e.length?s[0]:s.join("\n")},[e,n,i]),f=e=>{if(m)return;let s=i[e]?.trim();if(!s)return;let r={...i,[e]:s};if(c(r),x){u(!0),t?.(s);return}let n=p(r);n&&(u(!0),t?.(n))};return(0,r.jsxs)("div",{className:(0,o.cn)("rounded-lg border p-4 space-y-4",m?"border-muted bg-muted/30 opacity-60":"border-primary/20 bg-primary/5"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-primary",children:[(0,r.jsx)(ei.A,{className:"size-4"}),(0,r.jsx)("span",{className:"text-xs font-medium uppercase tracking-wider",children:"Question"})]}),e.map((s,a)=>(0,r.jsxs)("div",{className:"space-y-2",children:[s.header&&(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:s.header}),(0,r.jsx)("p",{className:"text-sm font-medium",children:s.question}),(0,r.jsx)("div",{className:"flex flex-col gap-2",children:s.options.map((s,i)=>{let c=(n[a]||[]).includes(s.label);return(0,r.jsxs)("button",{onClick:()=>{var r;return r=s.label,void(m||(e[a].multiSelect?l(e=>{let t=e[a]||[],s=t.includes(r)?t.filter(e=>e!==r):[...t,r];return{...e,[a]:s}}):(l(e=>({...e,[a]:[r]})),x&&(u(!0),t?.(r)))))},disabled:m,className:(0,o.cn)("w-full rounded-lg border bg-background px-3 py-2 text-left transition-colors",m?"cursor-default":"cursor-pointer hover:bg-primary/10",c&&"bg-primary text-primary-foreground border-primary"),children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:`${i+1}. ${s.label}`}),s.description&&(0,r.jsx)("span",{className:(0,o.cn)("block text-xs mt-0.5",c?"text-primary-foreground/70":"text-muted-foreground"),children:s.description})]},s.label)})}),(0,r.jsxs)("div",{className:"flex gap-2 mt-1",children:[(0,r.jsx)("input",{type:"text",placeholder:"Type your answer…",value:i[a]||"",onChange:e=>c(t=>({...t,[a]:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),f(a))},disabled:m,className:"flex-1 rounded-md border px-3 py-1.5 text-sm bg-background outline-none focus:ring-2 focus:ring-ring disabled:opacity-60"}),(0,r.jsx)("button",{onClick:()=>f(a),disabled:m||!i[a]?.trim(),className:"rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground cursor-pointer disabled:opacity-50 disabled:cursor-default","aria-label":"Send custom answer",children:(0,r.jsx)(eo.A,{className:"size-3.5"})})]})]},a)),!x&&!m&&(0,r.jsx)("button",{onClick:()=>{if(m)return;let e=p();e&&(u(!0),t?.(e))},disabled:Object.values(n).every(e=>0===e.length)&&Object.values(i).every(e=>!e?.trim()),className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground cursor-pointer disabled:opacity-50 disabled:cursor-default hover:bg-primary/90 transition-colors",children:"Submit"})]})}var ed=s(8723);function eu({onAnswer:e,isAnswered:t}){let[s,n]=(0,a.useState)(!1),[l,i]=(0,a.useState)(!1),[c,d]=(0,a.useState)(""),u=t||s||!e,m=()=>{!u&&c.trim()&&(n(!0),e?.(c.trim()))};return(0,r.jsxs)("div",{className:(0,o.cn)("rounded-lg border p-4 space-y-3",u?"border-muted bg-muted/30 opacity-60":"border-yellow-500/20 bg-yellow-500/5"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-yellow-600",children:[(0,r.jsx)(ed.A,{className:"size-4"}),(0,r.jsx)("span",{className:"text-xs font-medium uppercase tracking-wider",children:"Plan ready for review"})]}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"The agent has prepared a plan and is waiting for your approval to proceed."}),!l&&(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:()=>{u||(n(!0),e?.("Approved — go ahead"))},disabled:u,className:(0,o.cn)("rounded-md px-4 py-2 text-sm font-medium transition-colors",u?"bg-muted text-muted-foreground cursor-default":"bg-green-600 text-white cursor-pointer hover:bg-green-700"),children:"Approve & proceed"}),(0,r.jsx)("button",{onClick:()=>{u||i(!0)},disabled:u,className:(0,o.cn)("rounded-md border px-4 py-2 text-sm font-medium transition-colors",u?"cursor-default":"cursor-pointer hover:bg-primary/10"),children:"Request changes"})]}),l&&!u&&(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"text",placeholder:"Describe what to change…",value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),m())},autoFocus:!0,className:"flex-1 rounded-md border px-3 py-1.5 text-sm bg-background outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsx)("button",{onClick:m,disabled:!c.trim(),className:"rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground cursor-pointer disabled:opacity-50 disabled:cursor-default",children:(0,r.jsx)(eo.A,{className:"size-3.5"})})]})]})}var em=s(8426),ex=s(7890),ep=s(5537),ef=s(3181),eh=s(2763);function eg({html:e}){let[t,s]=(0,a.useState)(!1),[n,l]=(0,a.useState)(!1),[i,o]=(0,a.useState)(150),[c,d]=(0,a.useState)(!1),u=(0,a.useId)(),p=(0,a.useMemo)(()=>{let t;return t=e.replace(/<script[\s\S]*?<\/script>/gi,""),`<!DOCTYPE html>
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5083],{5083:(e,t,s)=>{s.r(t),s.d(t,{default:()=>ti});var r=s(5155),n=s(3321),a=s(2115),l=s(4621),i=s(8990),o=s(6218);function c({className:e,children:t,...s}){return(0,r.jsxs)(i.bL,{"data-slot":"scroll-area",className:(0,o.cn)("relative",e),...s,children:[(0,r.jsx)(i.LM,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] outline-none transition-[color,box-shadow] focus-visible:outline-1 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:t}),(0,r.jsx)(d,{}),(0,r.jsx)(i.OK,{})]})}function d({className:e,orientation:t="vertical",...s}){return(0,r.jsx)(i.VM,{"data-slot":"scroll-area-scrollbar",orientation:t,className:(0,o.cn)("flex touch-none select-none p-px transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:(0,r.jsx)(i.lr,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}var u=s(9239),m=s(6998),x=s(8528);function f({title:e,count:t,defaultOpen:s=!1,onToggleAll:n,toggleAllLabel:l,children:i}){let[o,c]=(0,a.useState)(s);return(0,r.jsxs)("div",{className:"rounded border bg-muted/30",children:[(0,r.jsxs)("div",{className:"flex cursor-pointer items-center gap-1.5 overflow-hidden px-3 py-2",onClick:()=>c(!o),children:[o?(0,r.jsx)(m.A,{className:"size-3.5 text-muted-foreground"}):(0,r.jsx)(x.A,{className:"size-3.5 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-sm font-medium",children:e}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",t,")"]}),n&&t>0&&(0,r.jsx)("button",{className:"ml-auto shrink-0 text-xs text-primary underline hover:text-primary/80 cursor-pointer",onClick:e=>{e.stopPropagation(),n()},children:l??"Toggle all"})]}),o&&(0,r.jsx)("div",{className:"overflow-hidden border-t px-3 py-2",children:i})]})}var p=s(2609),h=s(9304),g=s(4374);function b(e){return e.startsWith("diff --git")?"font-bold text-foreground bg-muted/50 pt-3 mt-2":e.startsWith("@@")?"text-blue-600 font-semibold bg-blue-500/10":e.startsWith("+")&&!e.startsWith("+++")?"bg-green-500/10 text-green-800":e.startsWith("-")&&!e.startsWith("---")?"bg-red-500/10 text-red-800":""}function j({diff:e,truncated:t,totalLines:s,maxHeight:n="400px"}){if(!e)return(0,r.jsx)("div",{className:"flex items-center justify-center py-4 text-xs text-muted-foreground",children:"No changes"});let a=function(e){let t=e.split("\n"),s=[],r=null;for(let e of t){let t=e.match(/^diff --git a\/(.+?) b\/(.+)$/);t?(r&&s.push(r),r={filePath:t[2],lines:[e]}):r&&r.lines.push(e)}return r&&s.push(r),s}(e),l=a.length>0;return(0,r.jsx)(c,{style:{maxHeight:n},children:(0,r.jsxs)("div",{className:"font-mono text-[11px] leading-relaxed",children:[l?a.map((e,t)=>(0,r.jsx)("div",{children:e.lines.map((e,s)=>(0,r.jsx)("div",{className:`px-2 py-px whitespace-pre ${b(e)}`,children:e||"\xa0"},`${t}-${s}`))},t)):e.split("\n").map((e,t)=>(0,r.jsx)("div",{className:`px-2 py-px whitespace-pre ${b(e)}`,children:e||"\xa0"},t)),t&&(0,r.jsxs)("div",{className:"mt-2 px-2 py-1.5 rounded bg-amber-500/10 border border-amber-500/20 text-amber-800 text-xs",children:["Diff truncated — showing first 5,000 of"," ",s?.toLocaleString()," lines"]})]})})}var y=s(8368);let v={M:{label:"M",color:"text-orange-500"},A:{label:"A",color:"text-green-600"},D:{label:"D",color:"text-red-600"},R:{label:"R",color:"text-blue-500"},"?":{label:"?",color:"text-gray-500"},C:{label:"C",color:"text-purple-500"},U:{label:"U",color:"text-yellow-600"}};function N({status:e,path:t,linesAdded:s,linesRemoved:n,checked:l,onToggle:i,slug:o,repoId:c,staged:d}){let u=v[e]||{label:e,color:"text-muted-foreground"},[f,b]=(0,a.useState)(!1),[N,w]=(0,a.useState)(null),[k,C]=(0,a.useState)(!1),[S,A]=(0,a.useState)(!1),[$,z]=(0,a.useState)(0),I=s??0,E=n??0,T=(0,a.useMemo)(()=>o?(0,y.jx)(c,o):null,[c,o]),R=!!o&&"?"!==e,D=async e=>{if(e.stopPropagation(),R){if(f)return void b(!1);if(b(!0),null===N){C(!0);try{let e=await fetch(`${T}/git`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"diff-file",file:t,staged:d})}),s=await e.json();w(s.diff||""),A(s.truncated||!1),z(s.totalLines||0)}catch{w("")}finally{C(!1)}}}};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2 rounded px-1 py-0.5 text-xs",children:[i&&(0,r.jsx)("div",{className:"flex cursor-pointer items-center",onClick:i,children:l?(0,r.jsx)(p.A,{className:"size-4 shrink-0 text-primary"}):(0,r.jsx)(h.A,{className:"size-4 shrink-0 text-muted-foreground/50"})}),(0,r.jsxs)("div",{className:`flex min-w-0 flex-1 items-center gap-2 rounded px-1 py-0.5 ${R?"cursor-pointer hover:bg-muted/50":""}`,onClick:R?D:void 0,children:[R&&(f?(0,r.jsx)(m.A,{className:"size-3 shrink-0 text-muted-foreground"}):(0,r.jsx)(x.A,{className:"size-3 shrink-0 text-muted-foreground"})),(0,r.jsx)("span",{className:`shrink-0 font-mono font-bold ${u.color}`,children:u.label}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground/80",children:t}),(I>0||E>0)&&(0,r.jsxs)("span",{className:"ml-auto flex shrink-0 items-center gap-1 font-mono tabular-nums",children:[I>0&&(0,r.jsxs)("span",{className:"text-green-600",children:["+",I]}),E>0&&(0,r.jsxs)("span",{className:"text-red-600",children:["-",E]})]})]})]}),f&&(0,r.jsx)("div",{className:"ml-6 mt-1 mb-2 rounded border bg-muted/10 overflow-hidden",children:k?(0,r.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,r.jsx)(g.A,{className:"size-3.5 animate-spin text-muted-foreground"})}):(0,r.jsx)(j,{diff:N||"",truncated:S,totalLines:$,maxHeight:"300px"})})]})}let w={M:{label:"M",color:"text-orange-500"},A:{label:"A",color:"text-green-600"},D:{label:"D",color:"text-red-600"},R:{label:"R",color:"text-blue-500"},C:{label:"C",color:"text-purple-500"}};function k({hash:e,author:t,relativeTime:s,message:n,files:l,slug:i,repoId:o}){let[c,d]=(0,a.useState)(!1),[u,f]=(0,a.useState)({}),[p,h]=(0,a.useState)(null),[b,v]=(0,a.useState)(null),N=(0,a.useMemo)(()=>i?(0,y.jx)(o,i):null,[o,i]),k=async t=>{if(b===t)return void v(null);if((v(t),!u[t])&&N){h(t);try{let s=await fetch(`${N}/git`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"diff-commit",hash:e,file:t})}),r=await s.json();f(e=>({...e,[t]:{diff:r.diff||"",truncated:r.truncated||!1,totalLines:r.totalLines||0}}))}catch{f(e=>({...e,[t]:{diff:"",truncated:!1,totalLines:0}}))}finally{h(null)}}};return(0,r.jsxs)("div",{className:"rounded border bg-muted/20",children:[(0,r.jsxs)("div",{className:"flex cursor-pointer items-center gap-2 px-3 py-2",onClick:()=>d(!c),children:[c?(0,r.jsx)(m.A,{className:"size-3 shrink-0 text-muted-foreground"}):(0,r.jsx)(x.A,{className:"size-3 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"min-w-0 truncate text-sm",children:n}),(0,r.jsx)("span",{className:"ml-auto shrink-0 font-mono text-[10px] text-muted-foreground",children:e})]}),c&&(0,r.jsxs)("div",{className:"border-t px-3 py-2",children:[(0,r.jsxs)("div",{className:"text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:t}),(0,r.jsx)("span",{className:"mx-1.5",children:"\xb7"}),(0,r.jsx)("span",{children:s})]}),l&&l.length>0&&(0,r.jsx)("div",{className:"mt-2 flex flex-col gap-0.5",children:l.map((e,t)=>{let s=w[e.status]||{label:e.status,color:"text-muted-foreground"},n=b===e.path,a=!!i;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:`flex min-w-0 items-center gap-2 text-xs rounded px-1 py-0.5 ${a?"cursor-pointer hover:bg-muted/50":""}`,onClick:a?()=>k(e.path):void 0,children:[a&&(n?(0,r.jsx)(m.A,{className:"size-3 shrink-0 text-muted-foreground"}):(0,r.jsx)(x.A,{className:"size-3 shrink-0 text-muted-foreground"})),(0,r.jsx)("span",{className:`shrink-0 font-mono font-bold ${s.color}`,children:s.label}),(0,r.jsx)("span",{className:"truncate font-mono text-foreground/70",children:e.path})]}),n&&(0,r.jsx)("div",{className:"ml-5 mt-1 mb-2 rounded border bg-muted/10 overflow-hidden",children:p===e.path?(0,r.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,r.jsx)(g.A,{className:"size-3.5 animate-spin text-muted-foreground"})}):(0,r.jsx)(j,{diff:u[e.path]?.diff||"",truncated:u[e.path]?.truncated,totalLines:u[e.path]?.totalLines,maxHeight:"300px"})})]},t)})})]})]})}var C=s(5413),S=s(1679);function A({slug:e,repoId:t}){let[s,n]=(0,a.useState)(null),[l,i]=(0,a.useState)(!0),[o,d]=(0,a.useState)(null),[m,x]=(0,a.useState)(!1),[p,h]=(0,a.useState)(null),[b,v]=(0,a.useState)(!1),[w,A]=(0,a.useState)(!1),[$,z]=(0,a.useState)(0),I=(0,a.useMemo)(()=>(0,y.jx)(t,e),[t,e]),E=(0,a.useCallback)(async()=>{i(!0),d(null);try{let e=await fetch(`${I}/git`),t=await e.json();t.error?(d(t.error),n(null)):n(t)}catch{d("Failed to fetch git status")}finally{i(!1)}},[I]);(0,a.useEffect)(()=>{E()},[E]);let T=async()=>{if(m)return void x(!1);if(x(!0),null===p){v(!0);try{let e=await fetch(`${I}/git`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"diff-branch"})}),t=await e.json();h(t.diff||""),A(t.truncated||!1),z(t.totalLines||0)}catch{h("")}finally{v(!1)}}},R=(0,a.useMemo)(()=>{if(!s)return[];let e=new Set,t=[];for(let r of s.staged)e.add(r.path),t.push({...r,staged:!0});for(let r of s.unstaged)e.has(r.path)||t.push(r);return t},[s]);return(0,r.jsx)("div",{className:"flex h-full flex-col",children:(0,r.jsx)(c,{className:"flex-1 min-h-0",children:(0,r.jsxs)("div",{className:"flex w-0 min-w-full flex-col gap-3 overflow-hidden p-3",children:[l&&!s&&(0,r.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,r.jsx)(g.A,{className:"size-4 animate-spin"})}),o&&(0,r.jsx)("div",{className:"rounded border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:o}),s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(f,{title:"Changes",count:R.length,defaultOpen:R.length>0,children:0===R.length?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"No changes"}):R.map((s,n)=>(0,r.jsx)(N,{status:s.status,path:s.path,linesAdded:s.linesAdded,linesRemoved:s.linesRemoved,slug:e,repoId:t,staged:s.staged},n))}),!s.onMain&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center gap-1.5",children:[(0,r.jsx)(C.A,{className:"size-3.5 text-muted-foreground"}),(0,r.jsx)("h3",{className:"text-sm font-medium",children:"Commits"})]}),0===s.commits.length?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"No commits on this branch yet"}):(0,r.jsx)("div",{className:"flex flex-col gap-1.5",children:s.commits.map(s=>(0,r.jsx)(k,{...s,slug:e,repoId:t},s.hash))})]}),!s.onMain&&s.commits.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)(u.$,{variant:"outline",size:"sm",onClick:T,className:"w-full gap-1.5 cursor-pointer",children:[(0,r.jsx)(S.A,{className:"size-3.5"}),m?"Hide all changes":"View all changes vs main"]}),m&&(0,r.jsx)("div",{className:"mt-2 rounded border bg-muted/10 overflow-hidden",children:b?(0,r.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,r.jsx)(g.A,{className:"size-4 animate-spin text-muted-foreground"})}):(0,r.jsx)(j,{diff:p||"",truncated:w,totalLines:$,maxHeight:"500px"})})]})]})]})})})}var $=s(2270);function z(e){return"object"==typeof e&&null!==e}let I=[/oauth token has expired/i,/token has expired/i,/expired.*token/i,/authentication_error/i,/failed to authenticate/i,/please obtain a new token/i];function E(e){let t,s=e.trim(),r=((t=s.match(/\{[\s\S]*"(?:message|detail)"\s*:\s*"([^"]+)"[\s\S]*\}/))?t[1]:null)??s;return/internal server error/i.test(r)?{message:"The AI service hit a temporary issue. You can try sending your message again.",details:s}:/overloaded/i.test(r)?{message:"The AI service is currently overloaded. Please wait a moment and try again.",details:s}:/rate limit/i.test(r)?{message:"Too many requests. Please wait a moment and try again.",details:s}:I.some(e=>e.test(r))?{message:"Authentication expired. Reconnect Claude CLI (`claude auth login`) and try again.",details:s}:/authentication|unauthorized|invalid.*key/i.test(r)?{message:"There was an authentication problem with the AI service.",details:s}:/chat request failed/i.test(r)?{message:"Couldn't reach the AI service. Check your connection and try again.",details:s}:{message:r}}function T(e){return"object"==typeof e&&null!==e}var R=s(9366);let D=new Set;function O(e,t){if(0===t.length&&e.length>0||t.length<e.length)return!1;if(t.length>e.length)return!0;for(let s=0;s<t.length;s++){let r=t[s],n=e[s];if(!n||r.id!==n.id||r.role!==n.role||(0,R.B)(n,r))return!0}return!1}function _(e){if("string"!=typeof e)return null;let t=e.trim();return!t||t.startsWith("pending-")?null:t}function L(e){let t=[],s=e=>{if("string"!=typeof e)return;let s=e.trim();s&&t.push(s)};if(s(e.result),s(e.error),Array.isArray(e.errors))for(let t of e.errors)s(t);return t}var P=s(7536),M=s(8884),F=s(7268),U=s(9392),W=s(4380),B=s(2515),q=s(9056),J=s(9664),H=s(3647),G=s(257),Y=s(1436),K=s(8541),Q=s(9683),V=s(3774),X=s(9702),Z=s(6336);let ee=(0,s(7206).default)(()=>Promise.all([s.e(161),s.e(232)]).then(s.bind(s,7851)).then(e=>({default:e.CodeBlock})),{loadableGenerated:{webpack:()=>[7851]},ssr:!1});function et(e){try{let t=JSON.parse(e);return{code:JSON.stringify(t,null,2),language:"json"}}catch{return{code:e,language:"text"}}}function es(e){try{let t=JSON.parse(e);return"object"==typeof t&&null!==t?t:null}catch{return null}}function er(e){let t=e.split("/").filter(Boolean);return t.length<=2?e:t.slice(-2).join("/")}let en={Bash:U.A,Read:W.A,Edit:B.A,Write:q.A,Grep:J.A,Glob:H.A,WebFetch:G.A,WebSearch:G.A,Task:Y.A,TodoWrite:K.A,Skill:Q.A,NotebookEdit:V.A},ea={borderRadius:"0.25rem",padding:"0.375rem",fontFamily:'"JetBrains Mono", monospace',maxHeight:"8rem",overflow:"auto"};function el({toolCall:e,isStreaming:t,subtle:s=!1}){let[n,l]=(0,a.useState)(!1),i=en[e.name]??X.A,o=!!e.output,c=!o&&!!t,{text:d,code:u}=function(e,t){let s=es(t);switch(e){case"Read":{let e=s?.file_path;return e?{text:"Read",code:er(e)}:{text:"Read file"}}case"Edit":{let e=s?.file_path;return e?{text:"Edit",code:er(e)}:{text:"Edit file"}}case"Write":{let e=s?.file_path;return e?{text:"Write",code:er(e)}:{text:"Write file"}}case"Bash":{let e=s?.command;if(!e)return{text:"Run command"};return{text:"Run",code:e.length>60?e.slice(0,57)+"...":e}}case"Grep":{let e=s?.pattern,t=s?.path;if(!e)return{text:"Search files"};let r=t?` in ${er(t)}`:"";return{text:"Search for",code:`${e}${r}`}}case"Glob":{let e=s?.pattern;return e?{text:"Find files",code:e}:{text:"Find files"}}case"WebFetch":{let e=s?.url;if(!e)return{text:"Fetch URL"};try{return{text:"Fetch",code:new URL(e).hostname}}catch{return{text:"Fetch URL"}}}case"WebSearch":{let e=s?.query;return e?{text:"Search web for",code:e}:{text:"Search the web"}}case"Task":{let e=s?.description;return e?{text:"Launch sous chef:",code:e}:{text:"Launch sous chef"}}case"TodoWrite":return{text:"Update task list"};case"Skill":{let e=s?.skill;return e?{text:"Use skill",code:e}:{text:"Use skill"}}case"NotebookEdit":return{text:"Edit notebook"};default:return{text:e}}}(e.name,e.input);return(0,r.jsxs)("div",{className:s?"text-xs":"rounded-md border text-xs",children:[(0,r.jsxs)("button",{type:"button",className:`flex w-full cursor-pointer items-center gap-1.5 text-left transition-colors ${s?"py-0.5 text-muted-foreground hover:text-foreground":"rounded-md px-2 py-1.5 hover:bg-accent/50"}`,onClick:()=>l(!n),children:[c?(0,r.jsx)(g.A,{className:`shrink-0 animate-spin ${s?"size-3 text-orange-500":"size-3.5 text-amber-500"}`}):o?(0,r.jsx)("div",{className:`flex shrink-0 items-center justify-center rounded-full ${s?"size-3 text-muted-foreground":"size-3.5 bg-muted text-muted-foreground"}`,children:(0,r.jsx)(Z.A,{className:"size-2.5",strokeWidth:3})}):(0,r.jsx)("div",{className:`shrink-0 rounded-full border border-muted-foreground/30 ${s?"size-2.5":"size-3.5"}`}),(0,r.jsx)(i,{className:"size-3 shrink-0 text-muted-foreground"}),(0,r.jsxs)("span",{className:`flex-1 truncate ${s?"text-muted-foreground":"text-foreground"}`,children:[d,u&&(0,r.jsxs)(r.Fragment,{children:[" ",(0,r.jsx)("code",{className:`${s?"font-mono text-[11px] text-muted-foreground/90":"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-muted-foreground"}`,children:u})]})]}),n?(0,r.jsx)(m.A,{className:"size-3 shrink-0 text-muted-foreground"}):(0,r.jsx)(x.A,{className:"size-3 shrink-0 text-muted-foreground"})]}),n&&(0,r.jsxs)("div",{className:`${s?"ml-6 border-l border-border/70 pl-2.5 py-1.5 space-y-1.5":"border-t px-2 py-1.5 space-y-1.5"}`,children:[e.input&&(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Input"}),(()=>{let{code:t,language:s}=et(e.input);return(0,r.jsx)(ee,{code:t,language:s,variant:"dark",wrapLongLines:!0,customStyle:{...ea,marginTop:"0.25rem"}})})()]}),e.output&&(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Output"}),(()=>{let{code:t,language:s}=et(e.output);return(0,r.jsx)(ee,{code:t,language:s,variant:"dark",wrapLongLines:!0,customStyle:{...ea,marginTop:"0.25rem"}})})()]}),c&&!e.output&&(0,r.jsxs)("div",{className:`flex items-center gap-1.5 py-1 text-[11px] ${s?"text-orange-600":"text-amber-600"}`,children:[(0,r.jsx)(g.A,{className:"size-3 animate-spin"}),(0,r.jsx)("span",{children:"Running..."})]})]})]})}var ei=s(2773),eo=s(9266);function ec({questions:e,onAnswer:t,isAnswered:s}){let[n,l]=(0,a.useState)({}),[i,c]=(0,a.useState)({}),[d,u]=(0,a.useState)(!1),m=s||d||!t,x=1===e.length&&!e[0].multiSelect,f=(0,a.useCallback)(t=>{let s=e.map((s,r)=>{let a=n[r]||[],l=(t?.[r]??i[r])?.trim(),o=[...a];if(l&&o.push(l),1===e.length)return o.join(", ");let c=s.header||`Q${r+1}`;return`${c}: ${o.join(", ")}`});return 1===e.length?s[0]:s.join("\n")},[e,n,i]),p=e=>{if(m)return;let s=i[e]?.trim();if(!s)return;let r={...i,[e]:s};if(c(r),x){u(!0),t?.(s);return}let n=f(r);n&&(u(!0),t?.(n))};return(0,r.jsxs)("div",{className:(0,o.cn)("rounded-lg border p-4 space-y-4",m?"border-muted bg-muted/30 opacity-60":"border-primary/20 bg-primary/5"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-primary",children:[(0,r.jsx)(ei.A,{className:"size-4"}),(0,r.jsx)("span",{className:"text-xs font-medium uppercase tracking-wider",children:"Question"})]}),e.map((s,a)=>(0,r.jsxs)("div",{className:"space-y-2",children:[s.header&&(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:s.header}),(0,r.jsx)("p",{className:"text-sm font-medium",children:s.question}),(0,r.jsx)("div",{className:"flex flex-col gap-2",children:s.options.map((s,i)=>{let c=(n[a]||[]).includes(s.label);return(0,r.jsxs)("button",{onClick:()=>{var r;return r=s.label,void(m||(e[a].multiSelect?l(e=>{let t=e[a]||[],s=t.includes(r)?t.filter(e=>e!==r):[...t,r];return{...e,[a]:s}}):(l(e=>({...e,[a]:[r]})),x&&(u(!0),t?.(r)))))},disabled:m,className:(0,o.cn)("w-full rounded-lg border bg-background px-3 py-2 text-left transition-colors",m?"cursor-default":"cursor-pointer hover:bg-primary/10",c&&"bg-primary text-primary-foreground border-primary"),children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:`${i+1}. ${s.label}`}),s.description&&(0,r.jsx)("span",{className:(0,o.cn)("block text-xs mt-0.5",c?"text-primary-foreground/70":"text-muted-foreground"),children:s.description})]},s.label)})}),(0,r.jsxs)("div",{className:"flex gap-2 mt-1",children:[(0,r.jsx)("input",{type:"text",placeholder:"Type your answer…",value:i[a]||"",onChange:e=>c(t=>({...t,[a]:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),p(a))},disabled:m,className:"flex-1 rounded-md border px-3 py-1.5 text-sm bg-background outline-none focus:ring-2 focus:ring-ring disabled:opacity-60"}),(0,r.jsx)("button",{onClick:()=>p(a),disabled:m||!i[a]?.trim(),className:"rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground cursor-pointer disabled:opacity-50 disabled:cursor-default","aria-label":"Send custom answer",children:(0,r.jsx)(eo.A,{className:"size-3.5"})})]})]},a)),!x&&!m&&(0,r.jsx)("button",{onClick:()=>{if(m)return;let e=f();e&&(u(!0),t?.(e))},disabled:Object.values(n).every(e=>0===e.length)&&Object.values(i).every(e=>!e?.trim()),className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground cursor-pointer disabled:opacity-50 disabled:cursor-default hover:bg-primary/90 transition-colors",children:"Submit"})]})}var ed=s(8723);function eu({onAnswer:e,isAnswered:t}){let[s,n]=(0,a.useState)(!1),[l,i]=(0,a.useState)(!1),[c,d]=(0,a.useState)(""),u=t||s||!e,m=()=>{!u&&c.trim()&&(n(!0),e?.(c.trim()))};return(0,r.jsxs)("div",{className:(0,o.cn)("rounded-lg border p-4 space-y-3",u?"border-muted bg-muted/30 opacity-60":"border-yellow-500/20 bg-yellow-500/5"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-yellow-600",children:[(0,r.jsx)(ed.A,{className:"size-4"}),(0,r.jsx)("span",{className:"text-xs font-medium uppercase tracking-wider",children:"Plan ready for review"})]}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"The agent has prepared a plan and is waiting for your approval to proceed."}),!l&&(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:()=>{u||(n(!0),e?.("Approved — go ahead"))},disabled:u,className:(0,o.cn)("rounded-md px-4 py-2 text-sm font-medium transition-colors",u?"bg-muted text-muted-foreground cursor-default":"bg-green-600 text-white cursor-pointer hover:bg-green-700"),children:"Approve & proceed"}),(0,r.jsx)("button",{onClick:()=>{u||i(!0)},disabled:u,className:(0,o.cn)("rounded-md border px-4 py-2 text-sm font-medium transition-colors",u?"cursor-default":"cursor-pointer hover:bg-primary/10"),children:"Request changes"})]}),l&&!u&&(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"text",placeholder:"Describe what to change…",value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),m())},autoFocus:!0,className:"flex-1 rounded-md border px-3 py-1.5 text-sm bg-background outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsx)("button",{onClick:m,disabled:!c.trim(),className:"rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground cursor-pointer disabled:opacity-50 disabled:cursor-default",children:(0,r.jsx)(eo.A,{className:"size-3.5"})})]})]})}var em=s(8426),ex=s(7890),ef=s(5537),ep=s(3181),eh=s(2763);function eg({html:e}){let[t,s]=(0,a.useState)(!1),[n,l]=(0,a.useState)(!1),[i,o]=(0,a.useState)(150),[c,d]=(0,a.useState)(!1),u=(0,a.useId)(),f=(0,a.useMemo)(()=>{let t;return t=e.replace(/<script[\s\S]*?<\/script>/gi,""),`<!DOCTYPE html>
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
@@ -19,6 +19,6 @@ ${t}
|
|
|
19
19
|
new ResizeObserver(notifyHeight).observe(document.body);
|
|
20
20
|
</script>
|
|
21
21
|
</body>
|
|
22
|
-
</html>`},[e,u]);return((0,a.useEffect)(()=>{let e=e=>{if(e.data?.type==="html-preview-resize"&&e.data?.id===u){let t=Math.max(150,Math.round(e.data.height));o(Math.min(t,400)),d(t>400)}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[u]),e.trim())?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"group relative my-2 cursor-pointer overflow-hidden rounded-lg border bg-background transition-colors hover:border-primary",style:{maxHeight:400},onClick:()=>s(!0),children:[(0,r.jsx)("div",{className:"absolute left-2 top-1.5 z-10 rounded bg-background/80 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground backdrop-blur-sm",children:"Preview"}),(0,r.jsxs)("div",{className:"absolute bottom-2 right-2 z-10 flex items-center gap-1 rounded bg-background/80 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100",children:[(0,r.jsx)(ep.A,{className:"size-3"}),"Click to expand"]}),c&&(0,r.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-[5] h-12 bg-gradient-to-t from-background/80 to-transparent"}),(0,r.jsx)("iframe",{srcDoc:p,sandbox:"allow-scripts",title:"HTML Preview",className:"w-full border-0",style:{height:i,pointerEvents:"none"}})]}),(0,r.jsx)(eh.lG,{open:t,onOpenChange:s,children:(0,r.jsxs)(eh.Cf,{className:"sm:max-w-[90vw] h-[80vh] p-4 flex flex-col overflow-hidden",children:[(0,r.jsx)(eh.L3,{className:"sr-only",children:"HTML Preview"}),(0,r.jsx)("iframe",{srcDoc:p,sandbox:"allow-scripts",title:"HTML Preview",className:"w-full rounded border-0 flex-1 min-h-0"}),(0,r.jsxs)("div",{className:"flex shrink-0 cursor-pointer items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>l(!n),children:[n?(0,r.jsx)(m.A,{className:"size-3"}):(0,r.jsx)(x.A,{className:"size-3"}),(0,r.jsx)(ef.A,{className:"size-3"}),(0,r.jsx)("span",{children:n?"Hide code":"Show code"})]}),n&&(0,r.jsx)("div",{className:"min-h-0 max-h-[35vh] overflow-auto shrink-0 rounded-md",children:(0,r.jsx)(ee,{code:e,language:"html",variant:"light"})})]})})]}):(0,r.jsx)(ee,{code:e,language:"html",variant:"light"})}let eb="prose prose-sm max-w-none prose-p:my-1 prose-headings:my-2 prose-ul:my-1 prose-li:my-0 prose-code:rounded prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:text-xs prose-pre:my-2",ej={code({className:e,children:t,...s}){let n=/language-([\w-]+)/.exec(e||""),a=String(t).replace(/\n$/,"");return n&&"html-preview"===n[1]?(0,r.jsx)(eg,{html:a}):n?(0,r.jsx)(ee,{code:a,language:n[1],variant:"dark",customStyle:{fontFamily:'"JetBrains Mono", monospace'}}):(0,r.jsx)("code",{className:e,...s,children:t})},pre:({children:e})=>(0,r.jsx)(r.Fragment,{children:e})};function ey({text:e}){return(0,r.jsx)("div",{className:eb,children:(0,r.jsx)(em.oz,{remarkPlugins:[ex.A],components:ej,children:e})})}let ev=new Set(["Task","Skill","TodoWrite"]);function eN(e){return ev.has(e.name)}function ew(e){try{let t=JSON.parse(e);return{code:JSON.stringify(t,null,2),language:"json"}}catch{return{code:e,language:"text"}}}let ek={borderRadius:"0.25rem",padding:"0.375rem",fontFamily:'"JetBrains Mono", monospace',maxHeight:"8rem",overflow:"auto"};function eC({block:e,isStreaming:t,subtle:s=!1}){return(0,r.jsx)(el,{toolCall:e,isStreaming:t,subtle:s})}function eS({calls:e,isStreaming:t}){let[s,n]=(0,a.useState)(!1),l=function(e){let t=new Map;for(let s of e)t.set(s.name,(t.get(s.name)||0)+1);let s=Array.from(t.entries()).map(([e,t])=>t>1?`${e} x${t}`:e),r=s.slice(0,4),n=s.length-r.length,a=n>0?` \u00b7 +${n}`:"",l=`Used ${e.length} tool${1===e.length?"":"s"}`;return r.length>0?`${l} \u00b7 ${r.join(" \xb7 ")}${a}`:l}(e);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),className:"flex w-full items-center gap-1 text-left text-xs text-muted-foreground transition-colors hover:text-foreground",children:[(0,r.jsx)(x.A,{className:(0,o.cn)("size-3 shrink-0 transition-transform",s&&"rotate-90")}),(0,r.jsx)("span",{className:"truncate",children:l})]}),s&&(0,r.jsx)("div",{className:"mt-1 flex flex-col gap-0.5 pl-4",children:e.map((s,n)=>(0,r.jsx)(eC,{block:s,subtle:!0,isStreaming:t&&n===e.length-1},`${s.name}-${n}`))})]})}function eA({block:e,isStreaming:t}){let[s,n]=(0,a.useState)(!1),l=es(e.input),i="Skill"===e.name,c=i?Q.A:Y.A,d=i?l?.skill||"Using skill":l?.description||l?.subagent_type||"Running subagent",u=i?void 0:l?.subagent_type,m=!!e.output,p=!m&&!!t;return(0,r.jsxs)("div",{className:"rounded-md border border-orange-200/70 bg-orange-50/40 px-2.5 py-1.5",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),className:"flex w-full items-center gap-2 text-left",children:[(0,r.jsx)(c,{className:"size-3.5 shrink-0 text-orange-600"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("p",{className:"truncate text-xs font-medium text-orange-900",children:[i?"Skill":"Subagent",": ",d]}),u&&(0,r.jsx)("p",{className:"truncate text-[11px] text-orange-700/90",children:u})]}),p?(0,r.jsx)(g.A,{className:"size-3.5 shrink-0 animate-spin text-orange-600"}):m?(0,r.jsx)(Z.A,{className:"size-3.5 shrink-0 text-orange-600"}):null,(0,r.jsx)(x.A,{className:(0,o.cn)("size-3 shrink-0 text-orange-700 transition-transform",s&&"rotate-90")})]}),s&&(0,r.jsxs)("div",{className:"mt-1.5 space-y-1.5 border-t border-orange-200/80 pt-1.5",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-orange-700",children:"Input"}),(()=>{let{code:t,language:s}=ew(e.input);return(0,r.jsx)(ee,{code:t,language:s,variant:"dark",wrapLongLines:!0,customStyle:{...ek,marginTop:"0.25rem"}})})()]}),e.output&&(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-orange-700",children:"Output"}),(()=>{let{code:t,language:s}=ew(e.output);return(0,r.jsx)(ee,{code:t,language:s,variant:"dark",wrapLongLines:!0,customStyle:{...ek,marginTop:"0.25rem"}})})()]}),p&&!e.output&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-[11px] text-orange-600",children:[(0,r.jsx)(g.A,{className:"size-3 animate-spin"}),(0,r.jsx)("span",{children:"Running..."})]})]})]})}function e$({block:e}){let t=es(e.input),s=Array.isArray(t?.todos)?t.todos:[];return 0===s.length?(0,r.jsx)(eC,{block:e,subtle:!0}):(0,r.jsxs)("div",{className:"py-0.5",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Todo list"}),(0,r.jsx)("ul",{className:"mt-1 space-y-0.5 text-xs",children:s.map((e,t)=>{let s="completed"===e.status,n="in_progress"===e.status&&e.activeForm?e.activeForm:e.content||"";return(0,r.jsx)("li",{className:(0,o.cn)("leading-relaxed text-foreground",s&&"line-through"),children:n},`${e.content||"todo"}-${t}`)})})]})}function ez({block:e}){return(0,r.jsx)("div",{className:"max-w-[90%] rounded-lg border border-red-200 bg-red-50 px-3.5 py-3 text-sm",children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("span",{className:"mt-0.5 shrink-0 text-base leading-none","aria-hidden":!0,children:"⚠️"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"font-medium text-red-900",children:"Something went wrong"}),(0,r.jsx)("p",{className:"mt-0.5 text-red-700",children:e.message}),e.details&&(0,r.jsxs)("details",{className:"mt-2",children:[(0,r.jsx)("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:"Technical details"}),(0,r.jsx)("pre",{className:"mt-1.5 whitespace-pre-wrap break-all rounded bg-white p-2 text-xs text-muted-foreground",children:e.details})]})]})]})})}function eI({images:e,slug:t,repoId:s}){let[n,l]=(0,a.useState)(null),i=e=>(0,y.wy)(s,t,e);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex gap-1.5 flex-wrap mt-1",children:e.map(e=>(0,r.jsx)("button",{onClick:()=>l(e),className:"size-16 shrink-0 cursor-pointer overflow-hidden rounded border hover:ring-2 hover:ring-ring",children:(0,r.jsx)("img",{src:i(e),alt:e,className:"size-full object-cover"})},e))}),(0,r.jsx)(eh.lG,{open:!!n,onOpenChange:e=>!e&&l(null),children:(0,r.jsxs)(eh.Cf,{className:"max-w-3xl p-2",showCloseButton:!1,children:[(0,r.jsx)(eh.L3,{className:"sr-only",children:"Image preview"}),n&&(0,r.jsx)("img",{src:i(n),alt:n,className:"w-full rounded object-contain max-h-[80vh]"})]})})]})}let eE=["Tasting","Simmering","Reducing","Prepping","Seasoning","Plating"],eT=["Counting clean forks","Looking for the missing whisk","Trying not to burn garlic","Keeping the pass in order"];function eR(e){let t,s=.25>Math.random()?eT:eE;do t=s[Math.floor(Math.random()*s.length)];while(s.length>1&&t===e);return t}function eD(){let[e,t]=(0,a.useState)(()=>eR());return(0,a.useEffect)(()=>{let e=setInterval(()=>{t(e=>eR(e))},3e3);return()=>clearInterval(e)},[]),(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1",children:[(0,r.jsx)("span",{className:"size-2 shrink-0 rounded-full bg-orange-500 motion-safe:animate-pulse-dot motion-reduce:opacity-70",role:"status","aria-label":"Thinking"}),(0,r.jsxs)("span",{className:"text-sm italic text-orange-600",children:[e,"..."]})]})}function eO({message:e,showThinking:t,slug:s,repoId:n,onQuestionAnswer:a,isQuestionAnswered:l}){let i="assistant"===e.role?e.blocks:void 0;if("system"===e.role)return(0,r.jsx)("div",{className:"flex justify-center py-2",children:(0,r.jsx)("span",{className:"text-xs text-muted-foreground/70 italic",children:e.content})});if("user"===e.role){let t=e.images?.length?e.images:Array.from(e.content.matchAll(/\[Attached image: ([^\]]+)\]/g),e=>e[1]),a=e.images?.length?e.content:e.content.replace(/\[Attached image: [^\]]+\]\n*/g,"").trim();return(0,r.jsx)("div",{className:"flex flex-col items-end",children:(0,r.jsxs)("div",{className:"max-w-[90%] rounded-lg bg-primary/15 px-3 py-2 text-sm text-foreground",children:[t.length>0&&(0,r.jsx)(eI,{images:t,slug:s,repoId:n}),a&&(0,r.jsx)("p",{className:"whitespace-pre-wrap",children:a})]})})}if(i&&i.length>0){let e=i.reduce((e,t,s)=>"tool_call"===t.type?s:e,-1),s=i.reduce((e,t,s)=>"tool_call"===t.type&&"TodoWrite"===t.name?s:e,-1),n=[];for(let o=0;o<i.length;o++){let c=i[o];if("text"===c.type){if(!c.text.trim())continue;n.push((0,r.jsx)(ey,{text:c.text},`text-${o}`));continue}if("error"===c.type){n.push((0,r.jsx)(ez,{block:c},`error-${o}`));continue}if("ask_question"===c.type){n.push((0,r.jsx)(ec,{questions:c.questions,onAnswer:a,isAnswered:l},`question-${o}`));continue}if("plan_approval"===c.type){n.push((0,r.jsx)(eu,{onAnswer:a,isAnswered:l},`plan-${o}`));continue}if("tool_call"!==c.type)continue;if("TodoWrite"===c.name){if(o!==s)continue;n.push((0,r.jsx)(e$,{block:c},`todo-${o}`));continue}let d=o===e;if("Task"===c.name||"Skill"===c.name){n.push((0,r.jsx)(eA,{block:c,isStreaming:d&&t},`agent-${o}`));continue}if(!eN(c)){let s=o,a=[c];for(;o+1<i.length;){let e=i[o+1];if("tool_call"!==e.type||eN(e))break;a.push(e),o+=1}let l=e>=s&&e<=o;n.push((0,r.jsx)(eS,{calls:a,isStreaming:l&&t},`tools-${s}`))}}return(0,r.jsxs)("div",{className:"flex flex-col gap-2 text-sm",children:[n,t&&(0,r.jsx)(eD,{})]})}let o=e.content||"",c=!!o.trim(),d=e.toolCalls&&e.toolCalls.length>0;return c||d?(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[c&&(0,r.jsx)("div",{className:"max-w-[90%] rounded-lg bg-muted px-3 py-2 text-sm text-foreground",children:(0,r.jsx)("div",{className:eb,children:(0,r.jsx)(em.oz,{remarkPlugins:[ex.A],components:ej,children:o})})}),d&&(0,r.jsx)("div",{className:"flex max-w-[90%] flex-col gap-1",children:e.toolCalls.map((e,t)=>(0,r.jsx)(el,{toolCall:e,subtle:!0},t))})]}):t?(0,r.jsx)(eD,{}):null}var e_=s(4),eL=s(9913);let eP={warning:{border:"border-amber-200",bg:"bg-amber-50/70",dot:"bg-amber-500",text:"text-amber-800"},success:{border:"border-emerald-200",bg:"bg-emerald-50/70",dot:"bg-emerald-500",text:"text-emerald-700"},muted:{border:"border-border",bg:"bg-muted/50",dot:"bg-muted-foreground",text:"text-muted-foreground"}};function eM({variant:e,dot:t,centered:s,children:n,actions:a,className:l}){let i=eP[e];return(0,r.jsxs)("div",{className:(0,o.cn)("flex items-center gap-3 rounded-lg border px-4 py-2.5 text-xs",i.border,i.bg,s&&"justify-center",l),children:[t&&(0,r.jsx)("span",{className:(0,o.cn)("size-1.5 shrink-0 rounded-full",i.dot,"warning"===e&&"animate-pulse")}),(0,r.jsx)("div",{className:(0,o.cn)("min-w-0",!s&&"flex-1",i.text),children:n}),a&&(0,r.jsx)("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:a})]})}var eF=s(872),eU=s(4268),eW=s(1553),eB=s(3927),eq=s(3853),eJ=s(553);let eH=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function eG({onSend:e,onStop:t,isStreaming:s,slug:n,repoId:l,onModelChange:i,selectedModel:c,leftToolbar:d}){let[m,x]=(0,a.useState)(""),[p,f]=(0,a.useState)([]),[h,g]=(0,a.useState)(!1),[b,j]=(0,a.useState)(null),[v,N]=(0,a.useState)(!1),[w,k]=(0,a.useState)(null),C=(0,a.useRef)(null),[S,A]=(0,a.useState)(M.xj),[$,z]=(0,a.useState)(c||M.xj),I=(0,a.useMemo)(()=>(0,y.jx)(l,n),[l,n]);(0,a.useEffect)(()=>{let e=window.localStorage.getItem(M.yX);if(!e)return;let t=(0,M.Ou)(e);A(t),t!==e&&window.localStorage.setItem(M.yX,t)},[]),(0,a.useEffect)(()=>{c&&z(c)},[c]),(0,a.useEffect)(()=>{c||z(S||M.xj)},[S,c]);let E=(0,a.useRef)(i);(0,a.useEffect)(()=>{E.current=i},[i]),(0,a.useEffect)(()=>{E.current?.($)},[$]),(0,a.useEffect)(()=>()=>{p.forEach(e=>URL.revokeObjectURL(e.previewUrl))},[]);let T=(0,a.useCallback)(e=>{j(null);let t=Array.from(e);for(let e of t){if(!eH.has(e.type))return void j("Only images are supported (PNG, JPEG, GIF, WebP).");if(e.size>5242880)return void j("Images must be under 5 MB.")}f(e=>{let s=[...e,...t.map(e=>({file:e,previewUrl:URL.createObjectURL(e)}))];return s.length>5?(j("Maximum 5 images per message."),e):s})},[]),R=(0,a.useCallback)(e=>{f(t=>(URL.revokeObjectURL(t[e].previewUrl),t.filter((t,s)=>s!==e))),j(null)},[]),D=(0,a.useCallback)(e=>{let t=Array.from(e.clipboardData.files).filter(e=>eH.has(e.type));t.length>0&&(e.preventDefault(),T(t))},[T]),O=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),N(!0)},[]),_=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),N(!1)},[]),L=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),N(!1),e.dataTransfer.files.length>0&&T(e.dataTransfer.files)},[T]),P=(0,a.useCallback)(async()=>{let t=m.trim();if((t||0!==p.length)&&!s)if(p.length>0){g(!0),j(null);try{let s=[];for(let e of p){let t=new FormData;t.append("file",e.file);let r=await fetch(`${I}/images`,{method:"POST",body:t});if(!r.ok){let e=await r.json();j(e.error||"Upload failed — try again.");return}let n=await r.json();s.push(n.filename)}p.forEach(e=>URL.revokeObjectURL(e.previewUrl)),f([]),x(""),e(t,s,$)}catch{j("Upload failed — try again.")}finally{g(!1)}}else e(t,void 0,$),x("")},[m,p,s,I,e,$]),F=(0,a.useCallback)(e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),P())},[P]),U=(0,a.useCallback)(e=>{let t=(0,M.Ou)(e);A(t),c||z(t),window.localStorage.setItem(M.yX,t)},[c]);return(0,r.jsxs)("div",{className:(0,o.cn)("py-5",v&&"ring-2 ring-primary ring-inset rounded-md"),onDragOver:O,onDragLeave:_,onDrop:L,children:[p.length>0&&(0,r.jsx)("div",{className:"flex gap-2 px-1 pb-2 flex-wrap",children:p.map((e,t)=>(0,r.jsxs)("div",{className:"relative group",children:[(0,r.jsx)("button",{onClick:()=>k(t),className:"size-14 shrink-0 cursor-pointer overflow-hidden rounded border hover:ring-2 hover:ring-ring",children:(0,r.jsx)("img",{src:e.previewUrl,alt:e.file.name,className:"size-full object-cover"})}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),R(t)},className:"absolute -top-1.5 -right-1.5 flex size-5 items-center justify-center rounded-full bg-destructive text-destructive-foreground text-xs cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity",children:(0,r.jsx)(eU.A,{className:"size-3"})})]},t))}),(0,r.jsx)(eh.lG,{open:null!==w,onOpenChange:e=>!e&&k(null),children:(0,r.jsxs)(eh.Cf,{className:"max-w-3xl p-2",children:[(0,r.jsx)(eh.L3,{className:"sr-only",children:"Image preview"}),null!==w&&p[w]&&(0,r.jsx)("img",{src:p[w].previewUrl,alt:p[w].file.name,className:"w-full rounded object-contain max-h-[80vh]"})]})}),b&&(0,r.jsx)("div",{className:"px-1 pb-2 text-xs text-destructive",children:b}),(0,r.jsxs)("div",{className:"rounded-xl border bg-white shadow-[0_10px_22px_-20px_rgba(15,23,42,0.3)] transition-shadow focus-within:shadow-[0_12px_26px_-18px_rgba(15,23,42,0.34)] focus-within:ring-2 focus-within:ring-ring",children:[(0,r.jsx)("input",{ref:C,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&T(e.target.files),e.target.value=""}}),(0,r.jsx)("textarea",{className:"w-full resize-none bg-transparent px-6 pt-4 pb-5 text-sm outline-none placeholder:text-muted-foreground",rows:2,placeholder:"Write a message... (Cmd+Enter to send)",value:m,onChange:e=>x(e.target.value),onKeyDown:F,onPaste:D,disabled:s}),(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 pb-3",children:[(0,r.jsx)(eF.Y6,{label:"Attach image",children:(0,r.jsx)(u.$,{variant:"ghost",size:"icon",onClick:()=>C.current?.click(),disabled:s||h,className:"shrink-0 cursor-pointer",children:(0,r.jsx)(eW.A,{className:"size-4"})})}),d,(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)(eJ.B,{value:$,onChange:z,disabled:s,defaultModel:S,onDefaultModelChange:U}),s?(0,r.jsx)(u.$,{variant:"outline",size:"icon",onClick:t,className:"shrink-0 cursor-pointer",children:(0,r.jsx)(eB.A,{className:"size-4"})}):(0,r.jsx)(u.$,{size:"icon",onClick:P,disabled:!m.trim()&&0===p.length||h,className:"shrink-0 cursor-pointer",children:(0,r.jsx)(eq.A,{className:"size-4"})})]})]})]})}function eY(e){if("string"!=typeof e)return null;let t=e.trim();return!t||t.startsWith("pending-")?null:t}function eK(e){return(e||"").replace(/\[Attached image: [^\]]+\]\n*/g,"").trim()}function eQ(e){if(!e)return null;let t=e.match(/-(\d{10,})$/);if(!t)return null;let s=Number(t[1]);return Number.isFinite(s)?s:null}function eV({taskSlug:e,taskTitle:t,repoId:s,status:l,onTaskUpdated:i,autoStartContext:o,autoStartModel:c,autoStartImages:d,autoImproveTitle:m=!1,prefetchedActiveChat:x}){let p=(0,n.useParams)(),f=(0,y.NK)(p),h=s||f,g=(0,a.useMemo)(()=>(0,y.Yg)(h),[h]),b=(0,a.useMemo)(()=>(0,y.jx)(h,e),[h,e]),j="chat-main",[v,N]=(0,a.useState)(null),[w,k]=(0,a.useState)(void 0),[C,S]=(0,a.useState)(null),[A,U]=(0,a.useState)(!1),[W,B]=(0,a.useState)(null),[q,J]=(0,a.useState)(!1),{messages:H,isStreaming:G,wasDisconnected:Y,sendMessage:K,stopAgent:Q,clearSessionId:V,injectSystemMessage:X,reloadFromServer:Z,hydrateFromSnapshot:ee,sessionId:et,sessionIdRef:es,awaitingInputFromQuestion:er}=function(e,t="chat-main",s,r){let l=(0,n.useParams)(),i=(0,y.NK)(l),o=r||i,c=(0,a.useMemo)(()=>(0,y.Yg)(o),[o]),d=(0,a.useMemo)(()=>e?(0,y.jx)(o,e):null,[o,e]),[u,m]=(0,a.useState)([]),[x,p]=(0,a.useState)(!1),[f,h]=(0,a.useState)(!1),[g,b]=(0,a.useState)(!1),j=(0,a.useRef)(null),[v,N]=(0,a.useState)(null),w=(0,a.useRef)(null),k=(0,a.useRef)(!1),C=(0,a.useRef)(t),S=(0,a.useRef)([]);S.current=u;let A=(0,a.useRef)(null),R=(0,a.useRef)(!1),P=(0,a.useRef)(!1),M=(0,a.useCallback)(e=>{let t=_(e);j.current=t,N(t)},[]),F=(0,a.useCallback)(e=>{m(t=>O(t,e.messages)?e.messages:t),M(e.sessionId)},[M]),U=(0,a.useCallback)(e=>({messages:e.messages.filter(e=>"assistant"!==e.role||(e.content||"").trim().length>0||e.blocks&&e.blocks.length>0||e.toolCalls&&e.toolCalls.length>0),sessionId:_(e.sessionId)}),[]),W=(0,a.useCallback)(()=>{if(!e)return;let s=S.current,r=j.current;if(R.current){P.current=!0;return}R.current=!0,(0,$.yd)(e,t,s,r,o).finally(()=>{R.current=!1,P.current&&(P.current=!1,W())})},[e,t,o]);(0,a.useEffect)(()=>()=>{if(w.current?.abort(),e&&S.current.length>0){let s=S.current,r=A.current;r&&(s=s.map(e=>e.id===r.id?{...e,content:r.content,blocks:r.blocks}:e),A.current=null),(0,$.YF)(e,t,s,j.current,o)}},[e,t,o]),(0,a.useEffect)(()=>{C.current!==t&&(C.current=t,k.current=!1,m([]),M(null))},[t,M]),(0,a.useEffect)(()=>{if(!s||s.storageId!==t||!s.chat)return;let e=U(s.chat);m(t=>t.length>0?t:e.messages),!j.current&&e.sessionId&&M(e.sessionId)},[s,t,U,M]),(0,a.useEffect)(()=>{if(!e||k.current)return;k.current=!0;let r=s=>{let r=U(s);F(r),r.sessionId!==s.sessionId&&(0,$.yd)(e,t,r.messages,r.sessionId,o).catch(()=>{})};s?.storageId===t&&s.chat?r(s.chat):(0,$.Hg)(e,t,o).then(s=>{if(s){console.log("[BG-AGENT] loadChat: found",s.messages.length,"messages"),r(s);return}try{let s=`kanban-chat-${e}-${t}`,n=localStorage.getItem(s);if(n){let a=JSON.parse(n);if(a.messages&&a.messages.length>0){console.log("[BG-AGENT] migrating localStorage chat to file:",s,a.messages.length,"messages");let n=U(a);r(a),(0,$.yd)(e,t,n.messages,n.sessionId,o).then(()=>{try{localStorage.removeItem(s)}catch{}});return}}}catch{}console.log("[BG-AGENT] loadChat: no persisted chat found for",e,t)})},[e,t,M,F,s,U,o]);let B=(0,a.useCallback)(()=>{e&&(0,$.Hg)(e,t,o).then(e=>{!e||(m(t=>O(t,e.messages)?e.messages:t),e.sessionId&&M(e.sessionId))})},[e,t,M,o]),q=(0,a.useCallback)(async(s,r)=>{let{images:n,model:a}=r||{};if(!e)return;b(!1),h(!1);let l={id:`user-${Date.now()}`,role:"user",content:s,images:n?.length?n:void 0},i=s;if(n&&n.length>0){let e=n.map(e=>`[Attached image: ${e}]`).join("\n");i=`${e}
|
|
22
|
+
</html>`},[e,u]);return((0,a.useEffect)(()=>{let e=e=>{if(e.data?.type==="html-preview-resize"&&e.data?.id===u){let t=Math.max(150,Math.round(e.data.height));o(Math.min(t,400)),d(t>400)}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[u]),e.trim())?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"group relative my-2 cursor-pointer overflow-hidden rounded-lg border bg-background transition-colors hover:border-primary",style:{maxHeight:400},onClick:()=>s(!0),children:[(0,r.jsx)("div",{className:"absolute left-2 top-1.5 z-10 rounded bg-background/80 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground backdrop-blur-sm",children:"Preview"}),(0,r.jsxs)("div",{className:"absolute bottom-2 right-2 z-10 flex items-center gap-1 rounded bg-background/80 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100",children:[(0,r.jsx)(ef.A,{className:"size-3"}),"Click to expand"]}),c&&(0,r.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-[5] h-12 bg-gradient-to-t from-background/80 to-transparent"}),(0,r.jsx)("iframe",{srcDoc:f,sandbox:"allow-scripts",title:"HTML Preview",className:"w-full border-0",style:{height:i,pointerEvents:"none"}})]}),(0,r.jsx)(eh.lG,{open:t,onOpenChange:s,children:(0,r.jsxs)(eh.Cf,{className:"sm:max-w-[90vw] h-[80vh] p-4 flex flex-col overflow-hidden",children:[(0,r.jsx)(eh.L3,{className:"sr-only",children:"HTML Preview"}),(0,r.jsx)("iframe",{srcDoc:f,sandbox:"allow-scripts",title:"HTML Preview",className:"w-full rounded border-0 flex-1 min-h-0"}),(0,r.jsxs)("div",{className:"flex shrink-0 cursor-pointer items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>l(!n),children:[n?(0,r.jsx)(m.A,{className:"size-3"}):(0,r.jsx)(x.A,{className:"size-3"}),(0,r.jsx)(ep.A,{className:"size-3"}),(0,r.jsx)("span",{children:n?"Hide code":"Show code"})]}),n&&(0,r.jsx)("div",{className:"min-h-0 max-h-[35vh] overflow-auto shrink-0 rounded-md",children:(0,r.jsx)(ee,{code:e,language:"html",variant:"light"})})]})})]}):(0,r.jsx)(ee,{code:e,language:"html",variant:"light"})}let eb="prose prose-sm max-w-none prose-p:my-1 prose-headings:my-2 prose-ul:my-1 prose-li:my-0 prose-code:rounded prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:text-xs prose-pre:my-2",ej={code({className:e,children:t,...s}){let n=/language-([\w-]+)/.exec(e||""),a=String(t).replace(/\n$/,"");return n&&"html-preview"===n[1]?(0,r.jsx)(eg,{html:a}):n?(0,r.jsx)(ee,{code:a,language:n[1],variant:"dark",customStyle:{fontFamily:'"JetBrains Mono", monospace'}}):(0,r.jsx)("code",{className:e,...s,children:t})},pre:({children:e})=>(0,r.jsx)(r.Fragment,{children:e})};function ey({text:e}){return(0,r.jsx)("div",{className:eb,children:(0,r.jsx)(em.oz,{remarkPlugins:[ex.A],components:ej,children:e})})}let ev=new Set(["Task","Skill","TodoWrite"]);function eN(e){return ev.has(e.name)}function ew(e){try{let t=JSON.parse(e);return{code:JSON.stringify(t,null,2),language:"json"}}catch{return{code:e,language:"text"}}}let ek={borderRadius:"0.25rem",padding:"0.375rem",fontFamily:'"JetBrains Mono", monospace',maxHeight:"8rem",overflow:"auto"};function eC({block:e,isStreaming:t,subtle:s=!1}){return(0,r.jsx)(el,{toolCall:e,isStreaming:t,subtle:s})}function eS({calls:e,isStreaming:t}){let[s,n]=(0,a.useState)(!1),l=function(e){let t=new Map;for(let s of e)t.set(s.name,(t.get(s.name)||0)+1);let s=Array.from(t.entries()).map(([e,t])=>t>1?`${e} x${t}`:e),r=s.slice(0,4),n=s.length-r.length,a=n>0?` \u00b7 +${n}`:"",l=`Used ${e.length} tool${1===e.length?"":"s"}`;return r.length>0?`${l} \u00b7 ${r.join(" \xb7 ")}${a}`:l}(e);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),className:"flex w-full items-center gap-1 text-left text-xs text-muted-foreground transition-colors hover:text-foreground",children:[(0,r.jsx)(x.A,{className:(0,o.cn)("size-3 shrink-0 transition-transform",s&&"rotate-90")}),(0,r.jsx)("span",{className:"truncate",children:l})]}),s&&(0,r.jsx)("div",{className:"mt-1 flex flex-col gap-0.5 pl-4",children:e.map((s,n)=>(0,r.jsx)(eC,{block:s,subtle:!0,isStreaming:t&&n===e.length-1},`${s.name}-${n}`))})]})}function eA({block:e,isStreaming:t}){let[s,n]=(0,a.useState)(!1),l=es(e.input),i="Skill"===e.name,c=i?Q.A:Y.A,d=i?l?.skill||"Using skill":l?.description||l?.subagent_type||"Running sous chef",u=i?void 0:l?.subagent_type,m=!!e.output,f=!m&&!!t;return(0,r.jsxs)("div",{className:"rounded-md border border-orange-200/70 bg-orange-50/40 px-2.5 py-1.5",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),className:"flex w-full items-center gap-2 text-left",children:[(0,r.jsx)(c,{className:"size-3.5 shrink-0 text-orange-600"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("p",{className:"truncate text-xs font-medium text-orange-900",children:[i?"Skill":"Sous chef",": ",d]}),u&&(0,r.jsx)("p",{className:"truncate text-[11px] text-orange-700/90",children:u})]}),f?(0,r.jsx)(g.A,{className:"size-3.5 shrink-0 animate-spin text-orange-600"}):m?(0,r.jsx)(Z.A,{className:"size-3.5 shrink-0 text-orange-600"}):null,(0,r.jsx)(x.A,{className:(0,o.cn)("size-3 shrink-0 text-orange-700 transition-transform",s&&"rotate-90")})]}),s&&(0,r.jsxs)("div",{className:"mt-1.5 space-y-1.5 border-t border-orange-200/80 pt-1.5",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-orange-700",children:"Input"}),(()=>{let{code:t,language:s}=ew(e.input);return(0,r.jsx)(ee,{code:t,language:s,variant:"dark",wrapLongLines:!0,customStyle:{...ek,marginTop:"0.25rem"}})})()]}),e.output&&(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-orange-700",children:"Output"}),(()=>{let{code:t,language:s}=ew(e.output);return(0,r.jsx)(ee,{code:t,language:s,variant:"dark",wrapLongLines:!0,customStyle:{...ek,marginTop:"0.25rem"}})})()]}),f&&!e.output&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-[11px] text-orange-600",children:[(0,r.jsx)(g.A,{className:"size-3 animate-spin"}),(0,r.jsx)("span",{children:"Running..."})]})]})]})}function e$({block:e}){let t=es(e.input),s=Array.isArray(t?.todos)?t.todos:[];return 0===s.length?(0,r.jsx)(eC,{block:e,subtle:!0}):(0,r.jsxs)("div",{className:"py-0.5",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Todo list"}),(0,r.jsx)("ul",{className:"mt-1 space-y-0.5 text-xs",children:s.map((e,t)=>{let s="completed"===e.status,n="in_progress"===e.status&&e.activeForm?e.activeForm:e.content||"";return(0,r.jsx)("li",{className:(0,o.cn)("leading-relaxed text-foreground",s&&"line-through"),children:n},`${e.content||"todo"}-${t}`)})})]})}function ez({block:e}){return(0,r.jsx)("div",{className:"max-w-[90%] rounded-lg border border-red-200 bg-red-50 px-3.5 py-3 text-sm",children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("span",{className:"mt-0.5 shrink-0 text-base leading-none","aria-hidden":!0,children:"⚠️"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"font-medium text-red-900",children:"Something went wrong"}),(0,r.jsx)("p",{className:"mt-0.5 text-red-700",children:e.message}),e.details&&(0,r.jsxs)("details",{className:"mt-2",children:[(0,r.jsx)("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:"Technical details"}),(0,r.jsx)("pre",{className:"mt-1.5 whitespace-pre-wrap break-all rounded bg-white p-2 text-xs text-muted-foreground",children:e.details})]})]})]})})}function eI({images:e,slug:t,repoId:s}){let[n,l]=(0,a.useState)(null),i=e=>(0,y.wy)(s,t,e);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex gap-1.5 flex-wrap mt-1",children:e.map(e=>(0,r.jsx)("button",{onClick:()=>l(e),className:"size-16 shrink-0 cursor-pointer overflow-hidden rounded border hover:ring-2 hover:ring-ring",children:(0,r.jsx)("img",{src:i(e),alt:e,className:"size-full object-cover"})},e))}),(0,r.jsx)(eh.lG,{open:!!n,onOpenChange:e=>!e&&l(null),children:(0,r.jsxs)(eh.Cf,{className:"max-w-3xl p-2",showCloseButton:!1,children:[(0,r.jsx)(eh.L3,{className:"sr-only",children:"Image preview"}),n&&(0,r.jsx)("img",{src:i(n),alt:n,className:"w-full rounded object-contain max-h-[80vh]"})]})})]})}let eE=["Tasting","Simmering","Reducing","Prepping","Seasoning","Plating"],eT=["Counting clean forks","Looking for the missing whisk","Trying not to burn garlic","Keeping the pass in order"];function eR(e){let t,s=.25>Math.random()?eT:eE;do t=s[Math.floor(Math.random()*s.length)];while(s.length>1&&t===e);return t}function eD(){let[e,t]=(0,a.useState)(()=>eR());return(0,a.useEffect)(()=>{let e=setInterval(()=>{t(e=>eR(e))},7e3);return()=>clearInterval(e)},[]),(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1",children:[(0,r.jsx)("span",{className:"size-2 shrink-0 rounded-full bg-orange-500 motion-safe:animate-pulse-dot motion-reduce:opacity-70",role:"status","aria-label":"Thinking"}),(0,r.jsxs)("span",{className:"text-sm italic text-orange-600",children:[e,"..."]})]})}function eO({message:e,showThinking:t,slug:s,repoId:n,onQuestionAnswer:a,isQuestionAnswered:l}){let i="assistant"===e.role?e.blocks:void 0;if("system"===e.role)return(0,r.jsx)("div",{className:"flex justify-center py-2",children:(0,r.jsx)("span",{className:"text-xs text-muted-foreground/70 italic",children:e.content})});if("user"===e.role){let t=e.images?.length?e.images:Array.from(e.content.matchAll(/\[Attached image: ([^\]]+)\]/g),e=>e[1]),a=e.images?.length?e.content:e.content.replace(/\[Attached image: [^\]]+\]\n*/g,"").trim();return(0,r.jsx)("div",{className:"flex flex-col items-end",children:(0,r.jsxs)("div",{className:"max-w-[90%] rounded-lg bg-primary/15 px-3 py-2 text-sm text-foreground",children:[t.length>0&&(0,r.jsx)(eI,{images:t,slug:s,repoId:n}),a&&(0,r.jsx)("p",{className:"whitespace-pre-wrap",children:a})]})})}if(i&&i.length>0){let e=i.reduce((e,t,s)=>"tool_call"===t.type?s:e,-1),s=i.reduce((e,t,s)=>"tool_call"===t.type&&"TodoWrite"===t.name?s:e,-1),n=[];for(let o=0;o<i.length;o++){let c=i[o];if("text"===c.type){if(!c.text.trim())continue;n.push((0,r.jsx)(ey,{text:c.text},`text-${o}`));continue}if("error"===c.type){n.push((0,r.jsx)(ez,{block:c},`error-${o}`));continue}if("ask_question"===c.type){n.push((0,r.jsx)(ec,{questions:c.questions,onAnswer:a,isAnswered:l},`question-${o}`));continue}if("plan_approval"===c.type){n.push((0,r.jsx)(eu,{onAnswer:a,isAnswered:l},`plan-${o}`));continue}if("tool_call"!==c.type)continue;if("TodoWrite"===c.name){if(o!==s)continue;n.push((0,r.jsx)(e$,{block:c},`todo-${o}`));continue}let d=o===e;if("Task"===c.name||"Skill"===c.name){n.push((0,r.jsx)(eA,{block:c,isStreaming:d&&t},`agent-${o}`));continue}if(!eN(c)){let s=o,a=[c];for(;o+1<i.length;){let e=i[o+1];if("tool_call"!==e.type||eN(e))break;a.push(e),o+=1}let l=e>=s&&e<=o;n.push((0,r.jsx)(eS,{calls:a,isStreaming:l&&t},`tools-${s}`))}}return(0,r.jsxs)("div",{className:"flex flex-col gap-2 text-sm",children:[n,t&&(0,r.jsx)(eD,{})]})}let o=e.content||"",c=!!o.trim(),d=e.toolCalls&&e.toolCalls.length>0;return c||d?(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[c&&(0,r.jsx)("div",{className:"max-w-[90%] rounded-lg bg-muted px-3 py-2 text-sm text-foreground",children:(0,r.jsx)("div",{className:eb,children:(0,r.jsx)(em.oz,{remarkPlugins:[ex.A],components:ej,children:o})})}),d&&(0,r.jsx)("div",{className:"flex max-w-[90%] flex-col gap-1",children:e.toolCalls.map((e,t)=>(0,r.jsx)(el,{toolCall:e,subtle:!0},t))})]}):t?(0,r.jsx)(eD,{}):null}var e_=s(4),eL=s(9913);let eP={warning:{border:"border-amber-200",bg:"bg-amber-50/70",dot:"bg-amber-500",text:"text-amber-800"},success:{border:"border-emerald-200",bg:"bg-emerald-50/70",dot:"bg-emerald-500",text:"text-emerald-700"},muted:{border:"border-border",bg:"bg-muted/50",dot:"bg-muted-foreground",text:"text-muted-foreground"}};function eM({variant:e,dot:t,centered:s,children:n,actions:a,className:l}){let i=eP[e];return(0,r.jsxs)("div",{className:(0,o.cn)("flex items-center gap-3 rounded-lg border px-4 py-2.5 text-xs",i.border,i.bg,s&&"justify-center",l),children:[t&&(0,r.jsx)("span",{className:(0,o.cn)("size-1.5 shrink-0 rounded-full",i.dot,"warning"===e&&"animate-pulse")}),(0,r.jsx)("div",{className:(0,o.cn)("min-w-0",!s&&"flex-1",i.text),children:n}),a&&(0,r.jsx)("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:a})]})}var eF=s(872),eU=s(4268),eW=s(1553),eB=s(3927),eq=s(3853),eJ=s(553);let eH=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function eG({onSend:e,onStop:t,isStreaming:s,slug:n,repoId:l,onModelChange:i,selectedModel:c,leftToolbar:d}){let[m,x]=(0,a.useState)(""),[f,p]=(0,a.useState)([]),[h,g]=(0,a.useState)(!1),[b,j]=(0,a.useState)(null),[v,N]=(0,a.useState)(!1),[w,k]=(0,a.useState)(null),C=(0,a.useRef)(null),[S,A]=(0,a.useState)(M.xj),[$,z]=(0,a.useState)(c||M.xj),I=(0,a.useMemo)(()=>(0,y.jx)(l,n),[l,n]);(0,a.useEffect)(()=>{let e=window.localStorage.getItem(M.yX);if(!e)return;let t=(0,M.Ou)(e);A(t),t!==e&&window.localStorage.setItem(M.yX,t)},[]),(0,a.useEffect)(()=>{c&&z(c)},[c]),(0,a.useEffect)(()=>{c||z(S||M.xj)},[S,c]);let E=(0,a.useRef)(i);(0,a.useEffect)(()=>{E.current=i},[i]),(0,a.useEffect)(()=>{E.current?.($)},[$]),(0,a.useEffect)(()=>()=>{f.forEach(e=>URL.revokeObjectURL(e.previewUrl))},[]);let T=(0,a.useCallback)(e=>{j(null);let t=Array.from(e);for(let e of t){if(!eH.has(e.type))return void j("Only images are supported (PNG, JPEG, GIF, WebP).");if(e.size>5242880)return void j("Images must be under 5 MB.")}p(e=>{let s=[...e,...t.map(e=>({file:e,previewUrl:URL.createObjectURL(e)}))];return s.length>5?(j("Maximum 5 images per message."),e):s})},[]),R=(0,a.useCallback)(e=>{p(t=>(URL.revokeObjectURL(t[e].previewUrl),t.filter((t,s)=>s!==e))),j(null)},[]),D=(0,a.useCallback)(e=>{let t=Array.from(e.clipboardData.files).filter(e=>eH.has(e.type));t.length>0&&(e.preventDefault(),T(t))},[T]),O=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),N(!0)},[]),_=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),N(!1)},[]),L=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),N(!1),e.dataTransfer.files.length>0&&T(e.dataTransfer.files)},[T]),P=(0,a.useCallback)(async()=>{let t=m.trim();if((t||0!==f.length)&&!s)if(f.length>0){g(!0),j(null);try{let s=[];for(let e of f){let t=new FormData;t.append("file",e.file);let r=await fetch(`${I}/images`,{method:"POST",body:t});if(!r.ok){let e=await r.json();j(e.error||"Upload failed — try again.");return}let n=await r.json();s.push(n.filename)}f.forEach(e=>URL.revokeObjectURL(e.previewUrl)),p([]),x(""),e(t,s,$)}catch{j("Upload failed — try again.")}finally{g(!1)}}else e(t,void 0,$),x("")},[m,f,s,I,e,$]),F=(0,a.useCallback)(e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),P())},[P]),U=(0,a.useCallback)(e=>{let t=(0,M.Ou)(e);A(t),c||z(t),window.localStorage.setItem(M.yX,t)},[c]);return(0,r.jsxs)("div",{className:(0,o.cn)("py-5",v&&"ring-2 ring-primary ring-inset rounded-md"),onDragOver:O,onDragLeave:_,onDrop:L,children:[f.length>0&&(0,r.jsx)("div",{className:"flex gap-2 px-1 pb-2 flex-wrap",children:f.map((e,t)=>(0,r.jsxs)("div",{className:"relative group",children:[(0,r.jsx)("button",{onClick:()=>k(t),className:"size-14 shrink-0 cursor-pointer overflow-hidden rounded border hover:ring-2 hover:ring-ring",children:(0,r.jsx)("img",{src:e.previewUrl,alt:e.file.name,className:"size-full object-cover"})}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),R(t)},className:"absolute -top-1.5 -right-1.5 flex size-5 items-center justify-center rounded-full bg-destructive text-destructive-foreground text-xs cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity",children:(0,r.jsx)(eU.A,{className:"size-3"})})]},t))}),(0,r.jsx)(eh.lG,{open:null!==w,onOpenChange:e=>!e&&k(null),children:(0,r.jsxs)(eh.Cf,{className:"max-w-3xl p-2",children:[(0,r.jsx)(eh.L3,{className:"sr-only",children:"Image preview"}),null!==w&&f[w]&&(0,r.jsx)("img",{src:f[w].previewUrl,alt:f[w].file.name,className:"w-full rounded object-contain max-h-[80vh]"})]})}),b&&(0,r.jsx)("div",{className:"px-1 pb-2 text-xs text-destructive",children:b}),(0,r.jsxs)("div",{className:"rounded-xl border bg-white shadow-[0_10px_22px_-20px_rgba(15,23,42,0.3)] transition-shadow focus-within:shadow-[0_12px_26px_-18px_rgba(15,23,42,0.34)] focus-within:ring-2 focus-within:ring-ring",children:[(0,r.jsx)("input",{ref:C,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&T(e.target.files),e.target.value=""}}),(0,r.jsx)("textarea",{className:"w-full resize-none bg-transparent px-6 pt-4 pb-5 text-sm outline-none placeholder:text-muted-foreground",rows:2,placeholder:"Write a message... (Cmd+Enter to send)",value:m,onChange:e=>x(e.target.value),onKeyDown:F,onPaste:D,disabled:s}),(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 pb-3",children:[(0,r.jsx)(eF.Y6,{label:"Attach image",children:(0,r.jsx)(u.$,{variant:"ghost",size:"icon",onClick:()=>C.current?.click(),disabled:s||h,className:"shrink-0 cursor-pointer",children:(0,r.jsx)(eW.A,{className:"size-4"})})}),d,(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)(eJ.B,{value:$,onChange:z,disabled:s,defaultModel:S,onDefaultModelChange:U}),s?(0,r.jsx)(u.$,{variant:"outline",size:"icon",onClick:t,className:"shrink-0 cursor-pointer",children:(0,r.jsx)(eB.A,{className:"size-4"})}):(0,r.jsx)(u.$,{size:"icon",onClick:P,disabled:!m.trim()&&0===f.length||h,className:"shrink-0 cursor-pointer",children:(0,r.jsx)(eq.A,{className:"size-4"})})]})]})]})}function eY(e){if("string"!=typeof e)return null;let t=e.trim();return!t||t.startsWith("pending-")?null:t}function eK(e){return(e||"").replace(/\[Attached image: [^\]]+\]\n*/g,"").trim()}function eQ(e){if(!e)return null;let t=e.match(/-(\d{10,})$/);if(!t)return null;let s=Number(t[1]);return Number.isFinite(s)?s:null}function eV({taskSlug:e,taskTitle:t,repoId:s,status:l,onTaskUpdated:i,autoStartContext:o,autoStartModel:c,autoStartImages:d,autoImproveTitle:m=!1,prefetchedActiveChat:x}){let f=(0,n.useParams)(),p=(0,y.NK)(f),h=s||p,g=(0,a.useMemo)(()=>(0,y.Yg)(h),[h]),b=(0,a.useMemo)(()=>(0,y.jx)(h,e),[h,e]),j="chat-main",[v,N]=(0,a.useState)(null),[w,k]=(0,a.useState)(void 0),[C,S]=(0,a.useState)(null),[A,U]=(0,a.useState)(!1),[W,B]=(0,a.useState)(null),[q,J]=(0,a.useState)(!1),{messages:H,isStreaming:G,wasDisconnected:Y,sendMessage:K,stopAgent:Q,clearSessionId:V,injectSystemMessage:X,reloadFromServer:Z,hydrateFromSnapshot:ee,sessionId:et,sessionIdRef:es,awaitingInputFromQuestion:er}=function(e,t="chat-main",s,r){let l=(0,n.useParams)(),i=(0,y.NK)(l),o=r||i,c=(0,a.useMemo)(()=>(0,y.Yg)(o),[o]),d=(0,a.useMemo)(()=>e?(0,y.jx)(o,e):null,[o,e]),[u,m]=(0,a.useState)([]),[x,f]=(0,a.useState)(!1),[p,h]=(0,a.useState)(!1),[g,b]=(0,a.useState)(!1),j=(0,a.useRef)(null),[v,N]=(0,a.useState)(null),w=(0,a.useRef)(null),k=(0,a.useRef)(!1),C=(0,a.useRef)(t),S=(0,a.useRef)([]);S.current=u;let A=(0,a.useRef)(null),R=(0,a.useRef)(!1),P=(0,a.useRef)(!1),M=(0,a.useCallback)(e=>{let t=_(e);j.current=t,N(t)},[]),F=(0,a.useCallback)(e=>{m(t=>O(t,e.messages)?e.messages:t),M(e.sessionId)},[M]),U=(0,a.useCallback)(e=>({messages:e.messages.filter(e=>"assistant"!==e.role||(e.content||"").trim().length>0||e.blocks&&e.blocks.length>0||e.toolCalls&&e.toolCalls.length>0),sessionId:_(e.sessionId)}),[]),W=(0,a.useCallback)(()=>{if(!e)return;let s=S.current,r=j.current;if(R.current){P.current=!0;return}R.current=!0,(0,$.yd)(e,t,s,r,o).finally(()=>{R.current=!1,P.current&&(P.current=!1,W())})},[e,t,o]);(0,a.useEffect)(()=>()=>{if(w.current?.abort(),e&&S.current.length>0){let s=S.current,r=A.current;r&&(s=s.map(e=>e.id===r.id?{...e,content:r.content,blocks:r.blocks}:e),A.current=null),(0,$.YF)(e,t,s,j.current,o)}},[e,t,o]),(0,a.useEffect)(()=>{C.current!==t&&(C.current=t,k.current=!1,m([]),M(null))},[t,M]),(0,a.useEffect)(()=>{if(!s||s.storageId!==t||!s.chat)return;let e=U(s.chat);m(t=>t.length>0?t:e.messages),!j.current&&e.sessionId&&M(e.sessionId)},[s,t,U,M]),(0,a.useEffect)(()=>{if(!e||k.current)return;k.current=!0;let r=s=>{let r=U(s);F(r),r.sessionId!==s.sessionId&&(0,$.yd)(e,t,r.messages,r.sessionId,o).catch(()=>{})};s?.storageId===t&&s.chat?r(s.chat):(0,$.Hg)(e,t,o).then(s=>{if(s){console.log("[BG-AGENT] loadChat: found",s.messages.length,"messages"),r(s);return}try{let s=`kanban-chat-${e}-${t}`,n=localStorage.getItem(s);if(n){let a=JSON.parse(n);if(a.messages&&a.messages.length>0){console.log("[BG-AGENT] migrating localStorage chat to file:",s,a.messages.length,"messages");let n=U(a);r(a),(0,$.yd)(e,t,n.messages,n.sessionId,o).then(()=>{try{localStorage.removeItem(s)}catch{}});return}}}catch{}console.log("[BG-AGENT] loadChat: no persisted chat found for",e,t)})},[e,t,M,F,s,U,o]);let B=(0,a.useCallback)(()=>{e&&(0,$.Hg)(e,t,o).then(e=>{!e||(m(t=>O(t,e.messages)?e.messages:t),e.sessionId&&M(e.sessionId))})},[e,t,M,o]),q=(0,a.useCallback)(async(s,r)=>{let{images:n,model:a}=r||{};if(!e)return;b(!1),h(!1);let l={id:`user-${Date.now()}`,role:"user",content:s,images:n?.length?n:void 0},i=s;if(n&&n.length>0){let e=n.map(e=>`[Attached image: ${e}]`).join("\n");i=`${e}
|
|
23
23
|
|
|
24
|
-
${s}`}S.current=[...S.current,l],m(S.current);let o=`assistant-${Date.now()}`;S.current=[...S.current,{id:o,role:"assistant",content:"",blocks:[]}],m(S.current),w.current?.abort(),w.current=new AbortController;try{d&&await fetch(`${d}/status`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"running"})})}catch{}p(!0),W();let u=!1,x=!1;try{let s=_(j.current);s!==j.current&&M(s);let r=!1;for(;;){console.log("[BG-AGENT] sendMessage:",s?`resuming session ${s}`:"starting new session");let n=await fetch(`${c}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:i,sessionId:s,taskSlug:e,storageId:t,model:a}),signal:w.current.signal});if(!n.ok){let e="Chat request failed";try{let t=await n.json();t?.code==="RUN_ALREADY_ACTIVE"?e=t.error||"A run is already active for this task. Stop it before starting another.":"string"==typeof t?.error&&t.error.trim().length>0&&(e=t.error.trim())}catch{}throw Error(e)}if(!n.body)throw Error("Chat request failed");let l=n.body.getReader(),d=new TextDecoder,p="",f=!1,g=null,j=null,y=!1,v=!1,N=function(e={}){let t=[],s=new Set,r=!1,n=!1,a=!1;return{getBlocks:()=>t,getContentText:()=>t.filter(e=>"text"===e.type).map(e=>e.text).join("\n\n"),hasInputRequestBlock:()=>a,processEvent:l=>{"assistant"===l.type&&l.message?function(l){if(T(l)&&Array.isArray(l.content))for(let i of l.content){if(!T(i)||n)continue;let l="string"==typeof i.type?i.type:"";if("text"===l){let e="string"==typeof i.text?i.text:"";if(!e)continue;if(function(e){return/api error:\s*\d{3}/i.test(e)||I.some(t=>t.test(e))}(e)){!function(e){let s=E(e),r=t[t.length-1];r&&"error"===r.type&&r.message===s.message&&r.details===s.details||t.push({type:"error",message:s.message,details:s.details})}(e),r=!1;continue}let s=t[t.length-1];r||!s||"text"!==s.type?t.push({type:"text",text:e}):s.text=e,r=!1;continue}if("tool_use"===l){let r="string"==typeof i.id?i.id:void 0;if(r&&s.has(r))continue;r&&s.add(r);let l=function(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return e}}(i.input),o="string"==typeof i.name&&i.name.trim().length>0?i.name:"tool",c="AskUserQuestion"===o?function(e){let t=e;if("string"==typeof t)try{t=JSON.parse(t)}catch{return null}if(!z(t)||!Array.isArray(t.questions))return null;let s=t.questions.map(e=>(function(e){if(!z(e))return null;let t="string"==typeof e.question?e.question.trim():"";if(!t)return null;let s=(Array.isArray(e.options)?e.options:[]).map(e=>(function(e){if(!z(e))return null;let t="string"==typeof e.label?e.label.trim():"";return t?{label:t,description:"string"==typeof e.description&&e.description.trim().length>0?e.description.trim():void 0}:null})(e)).filter(e=>null!==e);return{question:t,header:"string"==typeof e.header&&e.header.trim().length>0?e.header.trim():void 0,options:s,multiSelect:!0===e.multiSelect}})(e)).filter(e=>null!==e);return s.length>0?s:null}(l):null;if(c){t.push({type:"ask_question",questions:c}),a=!0,n=!0,e.onFirstQuestion?.();continue}if("ExitPlanMode"===o){let e=T(l)&&Array.isArray(l.allowedPrompts)?l.allowedPrompts:void 0;t.push({type:"plan_approval",allowedPrompts:e}),a=!0;continue}let d="string"==typeof i.input?i.input:JSON.stringify(i.input||{},null,2);t.push({type:"tool_call",name:o,input:d})}}}(l.message):"user"===l.type&&l.message?function(e){if(T(e)&&Array.isArray(e.content))for(let s of e.content){if(!T(s)||"tool_result"!==s.type)continue;let e="string"==typeof s.content?s.content:JSON.stringify(s.content||"",null,2);for(let s=t.length-1;s>=0;s--){let r=t[s];if("tool_call"===r.type&&!r.output){r.output=e.slice(0,500);break}}r=!0}}(l.message):"error"===l.type&&function(e){if(!("message"in e))return;let s="string"==typeof e.message?e.message:"Provider execution error",n="string"==typeof e.details?e.details:void 0,a=E(n??s);t.push({type:"error",message:n?s:a.message,details:n??a.details}),r=!1}(l)},resetForNewAssistantTurn:()=>{t.length=0,s.clear(),r=!1,n=!1,a=!1}}}({onFirstQuestion:()=>{if(f)return;f=!0,h(!0);let e=N.getContentText(),t=[...N.getBlocks()];A.current={id:o,content:e,blocks:t},m(s=>{let r=s.map(s=>s.id===o?{...s,content:e,blocks:t}:s);return S.current=r,r}),W(),w.current?.abort()}}),k=Date.now();for(;;){let{done:e,value:t}=await l.read();if(e)break;let r=(p+=d.decode(t,{stream:!0})).split("\n");for(let e of(p=r.pop()||"",r)){if(!e.startsWith("data: "))continue;let t=e.slice(6).trim();if("[DONE]"===t){y=!0;continue}try{let e=JSON.parse(t);v=!0,"system"===e.type&&e.session_id&&(M(e.session_id),W()),"result"===e.type&&e.session_id&&M(e.session_id),"result"===e.type&&!0===e.is_error&&(g=g||function(e){if("result"!==e.type||!0!==e.is_error)return null;let t=L(e);return t.length>0?t[0]:null}(e),j=j||function(e,t){if(!t||"result"!==e.type||!0!==e.is_error)return null;for(let s of L(e)){if(!/No conversation found with session ID:/i.test(s))continue;let e=s.match(/No conversation found with session ID:\s*([A-Za-z0-9-]+)/i);if(!e||e[1]===t)return s}return null}(e,s)),("assistant"===e.type||"user"===e.type||"error"===e.type)&&N.processEvent(e);let r=N.getContentText(),n=[...N.getBlocks()];A.current={id:o,content:r,blocks:n},m(e=>e.map(e=>e.id===o?{...e,content:r,blocks:n}:e))}catch{}}let n=Date.now();n-k>=3e3&&(k=n,W())}if(A.current=null,u=y,x=v,j&&s&&!r){r=!0,s=null,M(null),m(e=>{let t=e.map(e=>e.id===o?{...e,content:"",blocks:[]}:e);return S.current=t,t}),W();continue}if(g){let e=E(g);m(t=>{let s=t.map(t=>{if(t.id!==o)return t;let s=t.blocks||[],r=s.some(t=>"error"===t.type&&t.message===e.message&&t.details===e.details);return{...t,content:(t.content||"").trim().length>0?t.content:e.message,blocks:r?s:[...s,{type:"error",message:e.message,details:e.details}]}});return S.current=s,W(),s})}!y&&v&&b(!0),W();break}}catch(e){"AbortError"===e.name?W():(x&&!u&&b(!0),m(t=>{let s=E(e.message||"Chat request failed"),r={type:"error",message:s.message,details:s.details},n=t.map(e=>e.id===o?{...e,content:e.content||s.message,blocks:[...e.blocks||[],r]}:e);return S.current=n,W(),n}))}finally{A.current=null,p(!1),w.current=null}},[e,t,M,W,d,c]),J=(0,a.useCallback)(()=>{w.current?.abort()},[]),H=(0,a.useCallback)(async()=>{if(!e)return;w.current?.abort();let s=j.current;if(!s)try{let r=await fetch(`${c}/chat/session?taskSlug=${encodeURIComponent(e)}&storageId=${encodeURIComponent(t)}`);if(r.ok){let e=await r.json();e.sessionId&&(s=e.sessionId)}}catch{}try{await fetch(`${c}/chat/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s,taskSlug:e,storageId:t})})}catch{d&&await fetch(`${d}/status`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"idle"})}).catch(()=>{})}p(!1),h(!1)},[e,t,c,d]),G=(0,a.useCallback)(()=>{j.current=null,N(null),h(!1),e&&(0,$.yd)(e,t,S.current,null,o)},[e,t,o]),Y=(0,a.useCallback)(e=>{let t={id:`system-${Date.now()}`,role:"system",content:e};S.current=[...S.current,t],m(S.current),W()},[W]);return{messages:u,isStreaming:x,wasDisconnected:g,sendMessage:q,stopStreaming:J,stopAgent:H,clearChat:(0,a.useCallback)(()=>{if(w.current?.abort(),w.current=null,p(!1),h(!1),m([]),S.current=[],M(null),e){(0,$._e)(e,t,o);let s=`kanban-init-sent-${e}-${t}`;try{sessionStorage.removeItem(s)}catch{}D.delete(s),fetch(`${c}/chat/session?taskSlug=${encodeURIComponent(e)}&storageId=${encodeURIComponent(t)}`,{method:"DELETE"}).catch(()=>{})}},[e,t,M,c,o]),clearSessionId:G,injectSystemMessage:Y,reloadFromServer:B,hydrateFromSnapshot:F,sessionId:v,sessionIdRef:j,awaitingInputFromQuestion:f}}(e,j,x,h),{addSession:en,removeSession:ea,getSession:el}=(0,P.a)(),ei=(0,a.useRef)(null),eo=(0,a.useRef)(null),[ec,ed]=(0,a.useState)(!0),[eu,em]=(0,a.useState)(!1),ex=(0,a.useRef)(i);ex.current=i;let ep=(0,a.useRef)(null),ef=(0,a.useRef)(null),eh=(0,a.useRef)(null),eg=(0,a.useRef)(!1),eb="needs_tasting"===l||eu||er,ej=G||"running"===l&&!eb,ey=w||M.xj,ev=(0,a.useMemo)(()=>(0,M.xq)(ey).provider,[ey]),eN=C?.providers?.[ev],ew=!eN||eN.connected,ek=(0,a.useMemo)(()=>(0,F.p)(t),[t]);(0,a.useEffect)(()=>{eg.current=!1,eh.current=null,em(!1),k(void 0)},[e]);let eC=(0,a.useCallback)(async()=>{U(!0);try{let e=await (0,$.qq)();return e&&S(e),e}finally{U(!1)}},[]);(0,a.useEffect)(()=>{eC()},[eC,ev]),(0,a.useEffect)(()=>{J(!1)},[ev]),(0,a.useEffect)(()=>{if(ew&&!W)return;let e=setInterval(()=>{eC()},5e3);return()=>clearInterval(e)},[ew,W,eC]);let eS=(0,a.useCallback)(async e=>{let t=(0,M.xq)(e).provider,s=C?.providers?.[t],r=C?.checkedAt?Date.parse(C.checkedAt):0,n=r>0&&Date.now()-r<15e3;if(s&&n)return s.connected;let a=await eC(),l=a?.providers?.[t];return!l||l.connected},[C,eC]);(0,a.useEffect)(()=>{eS(w||M.xj)},[w,eS]);let eA=(0,a.useCallback)(async(e,t,s)=>{let r=eY(t),n={messages:[...H],sessionId:eY(es.current)},a=n.sessionId!==r,l=new Set(n.messages.map(e=>e.id)),i=[],o=new Map;for(let t of e){if(l.has(t.id)){let e=n.messages.findIndex(e=>e.id===t.id);-1!==e&&(0,R.B)(n.messages[e],t)&&o.set(e,t);continue}!function(e,t){if("user"!==t.role)return!1;let s=eK(t.content);if(!s)return!1;let r=eQ(t.id);for(let t=e.length-1;t>=0;t--){let n=e[t];if("user"!==n.role||eK(n.content)!==s)continue;let a=eQ(n.id);if(null!==r&&null!==a)return 1e4>=Math.abs(r-a);return!0}return!1}(n.messages,t)&&i.push(t)}if(o.size>0){for(let[e,t]of o)n.messages[e]=t;a=!0}if(i.length>0&&(n.messages=[...n.messages,...i],a=!0),s){let e=n.messages.findIndex(e=>e.id===s.id);-1!==e?(0,R.B)(n.messages[e],s)&&(n.messages[e]=s,a=!0):(n.messages.push(s),a=!0)}a&&ee({messages:n.messages,sessionId:r})},[H,es,ee]);(0,a.useEffect)(()=>{let t=`${e}-${j}`;ep.current!==t&&(ep.current=t,(async()=>{try{let t=await fetch(`${g}/chat/session?taskSlug=${encodeURIComponent(e)}&storageId=${encodeURIComponent(j)}`);if(!t.ok)return;let s=await t.json(),r="string"==typeof s.sessionId?s.sessionId.trim():null,n=eY(r)??r;if(em(!!(s.awaitingInput||"needs_tasting"===s.status)),!n)return void em(!1);let a=await fetch(`${g}/chat/poll?sessionId=${encodeURIComponent(n)}&afterIndex=0`);if(!a.ok)return;let l=await a.json();em(!!(l.awaitingInput||"needs_tasting"===l.status)),await eA(Array.isArray(l.messages)?l.messages:[],n,l.inProgress||null),"running"===l.status?en({sessionId:n,taskSlug:e,storageId:j,lastIndex:l.totalCount||0}):(ea(n),ex.current())}catch{}})())},[e,j,g,en,ea,eA]),(0,a.useEffect)(()=>{if(G)return;let t=el(e,j);if(!(t||et||"running"===l||eb))return;let s=setInterval(()=>{Z(),!el(e,j)&&t&&ex.current()},3e3);return()=>clearInterval(s)},[G,et,l,eb,e,j,el,Z]),(0,a.useEffect)(()=>{if(G&&et){let t=el(e,j);t?.sessionId!==et&&en({sessionId:et,taskSlug:e,storageId:j,lastIndex:0})}},[G,et,e,j,en,el]);let e$=(0,a.useRef)(G);e$.current=G;let ez=(0,a.useRef)(en);ez.current=en,(0,a.useEffect)(()=>()=>{let t=es.current;t&&e$.current&&ez.current({sessionId:t,taskSlug:e,storageId:j,lastIndex:0})},[e,j,es]);let eI=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(!eI.current&&G){ex.current(),eI.current=G;return}if(eI.current&&!G){let e=setTimeout(()=>{ex.current()},500);return et&&ea(et),eI.current=G,()=>clearTimeout(e)}eI.current=G},[G,et,ea]),(0,a.useEffect)(()=>{let e=eo.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:s,clientHeight:r}=e;ed(s-t-r<100)};return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[]);let eE=(0,a.useRef)(!1);(0,a.useEffect)(()=>{ec&&(eE.current||!(H.length>0)||(eE.current=!0,ej||eb))&&ei.current?.scrollIntoView({behavior:"smooth"})},[H,ec,ej,eb]),(0,a.useEffect)(()=>{if(eb&&ec){let e=setTimeout(()=>{ei.current?.scrollIntoView({behavior:"smooth"})},100);return()=>clearTimeout(e)}},[eb,ec]);let eT=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(Y&&!G&&!eT.current){eT.current=!0;let e=setTimeout(()=>{V();let e=w||M.xj;(async()=>{if(!await eS(e))return B({id:`queued-${Date.now()}`,message:"Continue where you left off",model:e});X("Connection interrupted — reconnecting…"),K("Continue where you left off",{model:e})})()},2e3);return()=>clearTimeout(e)}Y||G||(eT.current=!1)},[Y,G,V,X,K,w,eS]);let eR=(()=>{if(G||ej)return!1;if(Y)return!0;let e=[...H].reverse().find(e=>"system"===e.role);if(e?.content?.includes("Session restarted")){let t=H.indexOf(e);return!H.slice(t+1).some(e=>"user"===e.role)}return!1})(),eD=(0,a.useCallback)(async(e,t,s)=>{let r=s||w||M.xj;await eS(r)?(B(null),em(!1),eh.current||(eh.current=r),K(e,{images:t,model:r})):B({id:`queued-${Date.now()}`,message:e,images:t,model:r})},[w,eS,K]);(0,a.useEffect)(()=>{v&&(eh.current||(eh.current=v.model||w||M.xj),em(!1),K(v.message,{images:v.images,model:v.model}),N(null))},[v,w,K]);let eP=(0,a.useCallback)(()=>{W&&(B(null),eD(W.message,W.images,W.model))},[W,eD]);(0,a.useEffect)(()=>{if(!W||!ew||ef.current===W.id)return;ef.current=W.id;let e=setTimeout(()=>{eP()},250);return()=>clearTimeout(e)},[W,ew,eP]);let eF=(0,a.useCallback)(e=>{w!==e&&k(e)},[w]),eU=(0,a.useCallback)(async()=>{let e=w||M.xj;await eS(e)?(V(),em(!1),K("Continue where you left off",{model:e})):B({id:`queued-${Date.now()}`,message:"Continue where you left off",model:e})},[w,eS,V,K]),eW=(0,a.useCallback)(async()=>{await Q(),et&&ea(et),ex.current()},[Q,et,ea]),eB=(0,a.useRef)(!1);return((0,a.useEffect)(()=>{if(eB.current)return;let e=o?.trim();e&&(eB.current=!0,c&&k(c),N({message:e,images:d?.length?d:void 0,model:c||w||M.xj}))},[o,c,d,w]),(0,a.useEffect)(()=>{if(!m&&!ek||eg.current||G)return;let e=H.find(e=>"user"===e.role&&(e.content||"").trim().length>0),t=H.find(e=>"assistant"===e.role&&(e.content||"").trim().length>0);e&&t&&(eg.current=!0,fetch(`${b}/improve-title`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:eh.current||c||w||M.xj,userMessage:e.content,assistantMessage:t.content})}).then(e=>e.ok?e.json():null).then(e=>{e?.changed&&ex.current()}).catch(()=>{}))},[m,ek,G,H,b,c,w]),x||0!==H.length||e)?(0,r.jsxs)("div",{className:"flex h-full flex-col overflow-hidden bg-white",children:[(0,r.jsx)("div",{ref:eo,className:"flex-1 min-h-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-3 px-6 py-4 md:px-10 md:py-5",children:[0===H.length&&!ej&&(0,r.jsx)("div",{className:"py-10 text-center text-xs text-muted-foreground",children:"Start a conversation."}),H.map((t,s)=>{let n=s+1<H.length&&"user"===H[s+1].role;return(0,r.jsx)(eO,{message:t,slug:e,repoId:h,showThinking:ej&&"assistant"===t.role&&s===H.length-1,onQuestionAnswer:eD,isQuestionAnswered:"assistant"===t.role&&n&&!!t.blocks?.some(e=>"ask_question"===e.type||"plan_approval"===e.type)},t.id)}),ej&&(0===H.length||H[H.length-1]?.role!=="assistant")&&(0,r.jsx)(eO,{message:{id:"__tail-thinking__",role:"assistant",content:""},slug:e,repoId:h,showThinking:!0}),(0,r.jsx)("div",{ref:ei})]})}),(0,r.jsxs)("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-2 px-6 pt-2 pb-4 md:px-10 md:pb-6",children:[eN&&!eN.connected&&(0,r.jsxs)(eM,{variant:"warning",dot:!0,actions:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:async()=>{try{await navigator.clipboard.writeText(eN.reauthCommand),J(!0),window.setTimeout(()=>J(!1),1500)}catch{J(!1)}},className:"rounded-full border border-amber-200 bg-white px-3 py-1 text-xs font-medium text-amber-700 cursor-pointer hover:bg-amber-100 transition-colors",children:q?"Copied":"Reconnect"}),(0,r.jsx)("button",{onClick:()=>{eC()},disabled:A,className:"rounded-full border border-amber-200 bg-white px-3 py-1 text-xs font-medium text-amber-700 cursor-pointer hover:bg-amber-100 transition-colors disabled:opacity-60 disabled:cursor-default",children:A?"Checking...":"Check again"})]}),children:[(0,r.jsxs)("p",{children:["expired"===eN.reason?`${M.OW[ev]} authentication expired.`:`${M.OW[ev]} is disconnected.`," ","Run this command in your terminal:"]}),(0,r.jsx)("code",{className:"mt-1 inline-block rounded bg-amber-100 px-1 py-0.5 text-[11px]",children:eN.reauthCommand}),W&&(0,r.jsx)("p",{className:"mt-1 text-[11px] text-amber-700",children:"Your last message is queued."})]}),W&&ew&&(0,r.jsx)(eM,{variant:"success",dot:!0,actions:(0,r.jsx)("button",{onClick:eP,className:"rounded-full border border-emerald-200 bg-white px-3 py-1 text-xs font-medium text-emerald-700 cursor-pointer hover:bg-emerald-100 transition-colors",children:"Retry now"}),children:"Reconnected. Retrying your queued message automatically."}),eR&&(0,r.jsxs)(eM,{variant:"muted",centered:!0,children:[(0,r.jsx)("span",{children:"Conversation was interrupted"}),(0,r.jsxs)(u.$,{variant:"outline",size:"sm",onClick:eU,className:"ml-2 gap-1 h-7 px-3 text-xs cursor-pointer",children:[(0,r.jsx)(eL.A,{className:"size-3"}),"Resume"]})]}),(0,r.jsx)(eG,{onSend:eD,onModelChange:eF,selectedModel:w,onStop:eW,isStreaming:ej,slug:e,repoId:h})]})]}):(0,r.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,r.jsx)(e_._,{size:"lg"})})}var eX=s(2264),eZ=s(1597),e0=s(9467),e1=s(4289),e5=s(774),e2=s(7241),e3=s(1735),e6=s(5357);let e4={pending:null,in_progress:(0,r.jsx)(g.A,{className:"size-3.5 animate-spin text-orange-500"}),done:(0,r.jsx)(Z.A,{className:"size-3.5 text-green-600"}),error:(0,r.jsx)(eU.A,{className:"size-3.5 text-red-500"}),warning:(0,r.jsx)(e3.A,{className:"size-3.5 text-amber-500"})};function e7({steps:e,onRetry:t,onCancel:s,cancelPending:n,onClose:a,isComplete:l,isError:i}){let c=!!(s||l||i);return(0,r.jsxs)("div",{className:"absolute right-0 top-full mt-2 z-50 w-80 rounded-lg border bg-background shadow-lg",children:[(0,r.jsxs)("div",{className:"p-4 space-y-2",children:[0===e.length&&!l&&!i&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,r.jsx)(g.A,{className:"size-3.5 animate-spin"}),"Starting handoff…"]}),e.map(e=>(0,r.jsxs)("div",{className:"flex items-start gap-2 text-sm",children:[(0,r.jsx)("span",{className:"mt-0.5 shrink-0 w-4",children:e4[e.status]}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:(0,o.cn)("error"===e.status&&"text-red-600","done"===e.status&&"text-muted-foreground"),children:e.label}),e.detail&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:e.detail})]})]},e.id)),l&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-green-600 pt-1",children:[(0,r.jsx)(e6.A,{className:"size-4"}),"Handed off!"]})]}),c&&(0,r.jsxs)("div",{className:"border-t px-4 py-2 flex gap-2",children:[s&&(0,r.jsx)(u.$,{size:"sm",variant:"outline",onClick:s,disabled:n,className:"flex-1 text-xs cursor-pointer",children:n?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.A,{className:"size-3.5 animate-spin mr-1"}),"Cancelling…"]}):"Cancel handoff"}),i&&t&&(0,r.jsx)(u.$,{size:"sm",variant:"outline",onClick:t,className:"flex-1 text-xs cursor-pointer",children:"Retry"}),(l||i)&&(0,r.jsx)(u.$,{size:"sm",variant:"ghost",onClick:a,className:"flex-1 text-xs cursor-pointer",children:"Close"})]})]})}let e8=(0,s(8460).F)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function e9({className:e,variant:t,...s}){return(0,r.jsx)("div",{className:(0,o.cn)(e8({variant:t}),e),...s})}var te=s(2083);let tt={addition:"bg-green-500/10 text-green-800",deletion:"bg-red-500/10 text-red-800",hunk:"bg-blue-500/8 text-blue-600 font-medium",context:"",meta:"text-muted-foreground"},ts={addition:"bg-green-500/15 text-green-700 border-r border-green-500/20",deletion:"bg-red-500/15 text-red-700 border-r border-red-500/20",hunk:"bg-blue-500/10 border-r border-blue-500/20",context:"bg-muted/30 text-muted-foreground border-r border-border/50",meta:"bg-muted/30 border-r border-border/50"};function tr({open:e,reviewData:t,truncated:s,totalLines:n,attempt:l,onApprove:i,onCancel:o,onResolveDifferently:c,submittingAction:d,submitError:p,onCancelHandoff:h,cancelHandoffPending:b}){let[j,y]=(0,a.useState)(!0),[v,N]=(0,a.useState)(!1),[w,k]=(0,a.useState)(""),[C,S]=(0,a.useState)(new Set),A=new Set(t.conflictFiles.filter(e=>"text"===e.type).map(e=>e.path)),$=new Set(t.conflictFiles.filter(e=>"binary"===e.type).map(e=>e.path)),z=!t.fullDiff||"No diff available"===t.fullDiff,I=(0,a.useMemo)(()=>z?[]:function(e,t,s){let r=e.split("\n"),n=[],a=null,l=0,i=0;for(let e of r){let r=e.match(/^diff --git a\/(.+?) b\/(.+)$/);if(r){a&&n.push(a);let e=r[2];a={filePath:e,lines:[],additions:0,deletions:0,isConflictFile:t.has(e),isBinaryConflict:s.has(e)};continue}if(!a)continue;let o=e.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@(.*)/);if(o){l=parseInt(o[1],10),i=parseInt(o[2],10),a.lines.push({content:e,type:"hunk",oldNum:null,newNum:null});continue}if(e.startsWith("index ")||e.startsWith("--- ")||e.startsWith("+++ ")||e.startsWith("old mode")||e.startsWith("new mode")||e.startsWith("new file")||e.startsWith("deleted file")||e.startsWith("similarity index")||e.startsWith("rename from")||e.startsWith("rename to")||e.startsWith("Binary files")){a.lines.push({content:e,type:"meta",oldNum:null,newNum:null});continue}if(e.startsWith("+")){a.additions++,a.lines.push({content:e.slice(1),type:"addition",oldNum:null,newNum:i++});continue}if(e.startsWith("-")){a.deletions++,a.lines.push({content:e.slice(1),type:"deletion",oldNum:l++,newNum:null});continue}a.lines.push({content:e.startsWith(" ")?e.slice(1):e,type:"context",oldNum:l++,newNum:i++})}return a&&n.push(a),n}(t.fullDiff,A,$),[t.fullDiff,z]),E=(0,a.useMemo)(()=>t.aiExplanation?function(e){let t=[],s=null,r=e.split("\n"),n=[];for(let e of r){let s=e.match(/^\|?\s*`?([^\s|`]+\.\w+)`?\s*\|\s*(.+?)\s*\|?\s*$/);if(s){let e=s[1].split("/").pop()||s[1];t.push({fileName:e,explanation:s[2].trim()});continue}let r=e.match(/^\*\*([^\s*]+\.\w+)\*\*\s*[—:\-–]\s*(.+)$/);if(r){let e=r[1].split("/").pop()||r[1];t.push({fileName:e,explanation:r[2].trim()});continue}let a=e.match(/^[-*]\s+`?([^\s`]+\.\w+)`?\s*[—:\-–]\s*(.+)$/);if(a){let e=a[1].split("/").pop()||a[1];t.push({fileName:e,explanation:a[2].trim()});continue}e.match(/^\|?\s*[-|]+\s*\|?\s*$/)||e.match(/^\|\s*File\s*\|/i)||n.push(e)}let a=n.join("\n").trim();return a&&(s=a),{fileExplanations:t,summary:s}}(t.aiExplanation):null,[t.aiExplanation]);return(0,r.jsx)(eh.lG,{open:e,onOpenChange:()=>{},children:(0,r.jsxs)(eh.Cf,{className:"sm:max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",showCloseButton:!1,onPointerDownOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,r.jsxs)(eh.c7,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(eh.L3,{children:"Review conflict resolution"}),l&&l>1&&(0,r.jsxs)(e9,{className:"bg-blue-100 text-blue-800 border-blue-300",children:["Attempt ",l]})]}),(0,r.jsxs)(eh.rr,{children:["The AI resolved ",t.conflictFiles.length," conflict",1!==t.conflictFiles.length?"s":"",". Review the changes before merging."]})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-3",children:[E&&(0,r.jsxs)("div",{className:"rounded-lg border border-indigo-200 bg-indigo-50/50 overflow-hidden",children:[(0,r.jsxs)("button",{onClick:()=>y(!j),className:"flex items-center gap-2 w-full px-3 py-2.5 bg-indigo-100/60 cursor-pointer hover:bg-indigo-100 transition-colors",children:[(0,r.jsx)(te.A,{className:"size-4 text-indigo-600"}),(0,r.jsx)("span",{className:"text-sm font-semibold text-indigo-800",children:"How conflicts were resolved"}),j?(0,r.jsx)(m.A,{className:"size-4 ml-auto text-indigo-500"}):(0,r.jsx)(x.A,{className:"size-4 ml-auto text-indigo-500"})]}),j&&(0,r.jsxs)("div",{className:"px-3 py-3 space-y-2",children:[E.fileExplanations.map((e,t)=>(0,r.jsxs)("div",{className:"flex gap-2.5 p-2.5 rounded-md bg-white border border-border/50",children:[(0,r.jsx)(V.A,{className:"size-4 text-amber-500 mt-0.5 shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-foreground",children:(0,r.jsx)("code",{className:"bg-muted px-1 py-0.5 rounded text-[11px]",children:e.fileName})}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1 leading-relaxed",children:e.explanation})]})]},t)),0===E.fileExplanations.length&&t.aiExplanation&&(0,r.jsx)("div",{className:"text-xs text-foreground/80 whitespace-pre-wrap leading-relaxed",children:t.aiExplanation}),E.summary&&(0,r.jsxs)("div",{className:"flex items-start gap-2 px-2.5 py-2 rounded-md bg-green-50 border border-green-200 text-xs text-green-800 leading-relaxed",children:[(0,r.jsx)(f.A,{className:"size-3.5 mt-0.5 shrink-0"}),(0,r.jsx)("span",{children:E.summary})]})]})]}),(0,r.jsx)("div",{className:"rounded-lg border",children:z?(0,r.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"No changes detected"}):(0,r.jsxs)("div",{className:"divide-y divide-border",children:[I.map((e,t)=>{let s=C.has(t),n=e.filePath.split("/").pop()||e.filePath,a=e.filePath.includes("/")?e.filePath.slice(0,e.filePath.lastIndexOf("/")+1):"";return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{onClick:()=>{S(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:`flex items-center gap-2 px-3 py-2 cursor-pointer sticky top-0 z-10 ${e.isConflictFile?"bg-amber-50 hover:bg-amber-100/70":"bg-muted/50 hover:bg-muted/80"} transition-colors`,children:[s?(0,r.jsx)(x.A,{className:"size-3.5 text-muted-foreground shrink-0"}):(0,r.jsx)(m.A,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,r.jsx)(V.A,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,r.jsxs)("span",{className:"font-mono text-xs truncate",children:[a&&(0,r.jsx)("span",{className:"text-muted-foreground",children:a}),(0,r.jsx)("span",{className:"font-medium",children:n})]}),e.isConflictFile&&(0,r.jsx)(e9,{className:"bg-amber-100 text-amber-800 border-amber-300 text-[10px] px-1.5 py-0",children:"CONFLICT"}),e.isBinaryConflict&&(0,r.jsx)(e9,{className:"bg-red-100 text-red-800 border-red-300 text-[10px] px-1.5 py-0",children:"BINARY"}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-1 text-xs shrink-0",children:[e.additions>0&&(0,r.jsxs)("span",{className:"text-green-600 font-medium",children:["+",e.additions]}),e.additions>0&&e.deletions>0&&(0,r.jsx)("span",{className:"text-muted-foreground",children:"\xb7"}),e.deletions>0&&(0,r.jsxs)("span",{className:"text-red-600 font-medium",children:["−",e.deletions]})]})]}),!s&&(0,r.jsx)("div",{className:"font-mono text-[11px] leading-5",children:e.lines.map((e,t)=>"meta"===e.type?null:(0,r.jsxs)("div",{className:`flex ${tt[e.type]}`,children:[(0,r.jsx)("span",{className:`w-10 shrink-0 text-right pr-2 select-none text-[10px] ${ts[e.type]}`,children:e.oldNum??""}),(0,r.jsx)("span",{className:`w-10 shrink-0 text-right pr-2 select-none text-[10px] ${ts[e.type]}`,children:e.newNum??""}),(0,r.jsx)("span",{className:"flex-1 px-2 whitespace-pre overflow-x-auto",children:"hunk"===e.type?(0,r.jsx)("span",{className:"font-medium",children:e.content}):e.content||"\xa0"})]},t))})]},t)}),s&&(0,r.jsxs)("div",{className:"px-3 py-2.5 bg-amber-50 border-t border-amber-200 text-amber-800 text-xs",children:[(0,r.jsx)(e3.A,{className:"size-3.5 inline mr-1.5 -mt-0.5"}),"Diff truncated — showing first 5,000 of"," ",n?.toLocaleString()," lines"]})]})})]}),v&&(0,r.jsxs)("div",{className:"border-t pt-3 mt-3 space-y-2 shrink-0",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"How should the conflicts be resolved?"}),(0,r.jsx)("textarea",{className:"w-full min-h-[80px] rounded-md border p-2 text-sm",placeholder:"Describe how you want the conflicts resolved...",value:w,onChange:e=>k(e.target.value)}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(u.$,{variant:"outline",size:"sm",onClick:()=>N(!1),disabled:null!==d||b,className:"cursor-pointer",children:"Back"}),(0,r.jsx)(u.$,{size:"sm",onClick:()=>c(w),disabled:!w.trim()||null!==d||b,className:"bg-amber-600 hover:bg-amber-700 text-white cursor-pointer",children:"retry"===d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.A,{className:"size-3.5 animate-spin mr-1"}),"Submitting…"]}):"Submit feedback"})]})]}),!v&&(0,r.jsxs)(eh.Es,{className:"shrink-0",children:[(0,r.jsxs)("div",{className:"flex w-full justify-between",children:[(0,r.jsx)(u.$,{variant:"outline",onClick:()=>N(!0),disabled:null!==d||b,className:"text-amber-700 border-amber-300 hover:bg-amber-50 cursor-pointer",children:"Resolve differently ↻"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(u.$,{variant:"outline",onClick:o,disabled:null!==d||b,className:"cursor-pointer",children:"cancel"===d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.A,{className:"size-3.5 animate-spin mr-1"}),"Cancelling…"]}):"Cancel"}),(0,r.jsx)(u.$,{onClick:i,disabled:null!==d||b,className:"bg-green-600 hover:bg-green-700 text-white cursor-pointer",children:"approve"===d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.A,{className:"size-3.5 animate-spin mr-1"}),"Approving…"]}):"Approve & Merge"})]})]}),(p||h)&&(0,r.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 text-xs",children:[(0,r.jsx)("span",{className:p?"text-red-600":"text-muted-foreground",children:p||"Need to abort immediately? Cancel the whole handoff."}),h&&(0,r.jsx)(u.$,{variant:"ghost",size:"sm",onClick:h,disabled:null!==d||b,className:"text-xs cursor-pointer",children:b?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.A,{className:"size-3.5 animate-spin mr-1"}),"Cancelling handoff…"]}):"Cancel handoff now"})]})]})]})})}var tn=s(6007),ta=s(9409),tl=s(2666);function ti(){let e,t=(0,n.useParams)(),s=(0,n.useRouter)(),i=(0,n.useSearchParams)(),c=t.slug,d=(0,y.NK)(t),p=(0,a.useMemo)(()=>(0,y.Yg)(d),[d]),f=d?`/r/${encodeURIComponent(d)}/board`:"/board",h=e=>d?`/r/${encodeURIComponent(d)}/task/${encodeURIComponent(e)}`:`/task/${encodeURIComponent(e)}`,b=(0,a.useMemo)(()=>`${p}/tasks`,[p]),j=(0,a.useMemo)(()=>`${b}/${encodeURIComponent(c)}`,[b,c]),v=i.get("context"),N=i.get("model"),w="1"===i.get("autoTitle"),k=i.get("images")?.split(",").filter(Boolean)||void 0,{task:C,loading:S,fetchTask:z}=(0,l.S)(c,d),{addToast:I}=(0,tl.d)();(0,a.useEffect)(()=>{if(d)return;let e=!1;return fetch("/api/repos").then(e=>e.ok?e.json():null).then(t=>{!e&&t?.lastRepoId&&s.replace(`/r/${encodeURIComponent(t.lastRepoId)}/task/${encodeURIComponent(c)}`)}).catch(()=>{}),()=>{e=!0}},[d,s,c]);let[E,T]=(0,a.useState)(null),R=(0,a.useCallback)(async()=>{try{let e=await fetch(`${b}/counts`),t=await e.json();return T({slugs:t.slugs,total:t.inputNeeded}),t}catch{return null}},[b]);(0,a.useEffect)(()=>{R()},[c,R]);let D=(0,a.useMemo)(()=>{if(!E||0===E.total)return null;let e=E.slugs.indexOf(c);if(-1===e)return{nextSlug:E.slugs[0],total:E.total};let t=(e+1)%E.slugs.length;return{nextSlug:E.slugs[t],total:E.total}},[E,c]),O=(0,a.useCallback)(async()=>{let e=await R();if(!e||0===e.inputNeeded)return;let t=e.slugs.indexOf(c),r=-1===t?e.slugs[0]:e.slugs[(t+1)%e.slugs.length];s.push(h(r))},[R,c,s]),[_,L]=(0,a.useState)(!1),[P,F]=(0,a.useState)(!1),[U,W]=(0,a.useState)(void 0),[B,q]=(0,a.useState)(!1),[J,H]=(0,a.useState)(!1),[G,Y]=(0,a.useState)(""),[K,Q]=(0,a.useState)(null),[V,X]=(0,a.useState)(!1),[ee,et]=(0,a.useState)(null),[es,er]=(0,a.useState)(0),[en,ea]=(0,a.useState)(0),[el,ei]=(0,a.useState)(!1),[eo,ec]=(0,a.useState)(null),[ed,eu]=(0,a.useState)(!1),em=(0,a.useRef)(null),[ex,ep]=(0,a.useState)(null),[ef,eh]=(0,a.useState)(null),[eg,eb]=(0,a.useState)(!1);(0,a.useEffect)(()=>{W(void 0),q(!1);let e=!1;return(async()=>{try{let t=await fetch(`${j}/chat?storageId=${encodeURIComponent("chat-main")}`);if(e)return;let s=t.ok?await t.json():null;if(e)return;W({storageId:"chat-main",chat:s}),q(!0)}catch{if(e)return;W(null),q(!0)}})(),()=>{e=!0}},[c,j]),(0,a.useEffect)(()=>{C?.branch&&fetch(`${j}/pr-status`).then(e=>e.json()).then(e=>{"state"in e?Q(e):Q(null)}).catch(()=>Q(null))},[j,C?.branch]);let ej=!C?.branch;(0,a.useEffect)(()=>{if(!C){X(!1),et(null);return}fetch(`${j}/git`).then(e=>e.json()).then(e=>{if(e.error){X(!1),et(null),er(0),ea(0);return}X((e.staged?.length??0)>0||(e.unstaged?.length??0)>0||(e.commits?.length??0)>0),et(e.worktreeCwd??null);let t=0,s=0;for(let r of e.staged??[])t+=r.linesAdded??0,s+=r.linesRemoved??0;for(let r of e.unstaged??[])t+=r.linesAdded??0,s+=r.linesRemoved??0;er(t),ea(s)}).catch(()=>{X(!1),et(null),er(0),ea(0)})},[j,C]),(0,a.useEffect)(()=>{let e=e=>{if("Escape"!==e.key)return;let t=e.target?.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&s.push(f)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s]);let ey=(0,a.useCallback)(async(e,t)=>{let s=await fetch(`${j}/move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetColumn:e,force:t})});if(s.ok){if((await s.json()).worktreeWarning){window.confirm("This task's worktree has uncommitted changes. Remove worktree anyway?")&&await ey(e,!0);return}await z()}},[j,z]),ev=(0,a.useCallback)(e=>{(0,$.U8)(c,e,d)},[c,d]),eN=(0,a.useCallback)(async()=>{let e=G.trim();if(!e||e===C?.title)return void H(!1);let t=await fetch(j,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e})});if(t.ok){let e=await t.json();H(!1),e.newSlug?(ev(e.newSlug),s.replace(h(e.newSlug))):await z()}},[G,C?.title,j,s,z,ev]),ew=(0,a.useCallback)(async e=>{(await fetch(j,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})})).ok&&await z()},[j,z]),ek=(0,a.useCallback)(async()=>{try{let e=await fetch(j,{method:"DELETE",signal:AbortSignal.timeout(3e4)});if(e.ok){let e=`kanban-chat-${c}-`;try{for(let t=window.localStorage.length-1;t>=0;t-=1){let s=window.localStorage.key(t);s&&s.startsWith(e)&&window.localStorage.removeItem(s)}}catch{}s.push(f)}else{let t=await e.json().catch(()=>null);I(t?.error??`Delete failed (${e.status})`,"error")}}catch{I("Delete request timed out — the server may be busy. Try again.","error")}},[j,c,s,f,I]),eC=(0,a.useCallback)(()=>{if(!ee)return;let e=`cd "${ee}"`;navigator.clipboard.writeText(e).then(()=>{ei(!0),setTimeout(()=>ei(!1),2e3)}).catch(()=>{})},[ee]),eS=(0,a.useCallback)(()=>{em.current||(eu(!0),em.current=setInterval(async()=>{try{let e=await fetch(`${j}/handoff`),t=await e.json();if("idle"===t.phase){em.current&&clearInterval(em.current),em.current=null,ec(null),eu(!1),ep(null),eh(null),eb(!1);return}ec(t),"completed"===t.phase?(em.current&&clearInterval(em.current),em.current=null,ep(null),eh(null),eb(!1),await z(),ej?(eu(!1),ec(null),X(!1),er(0),ea(0)):(eu(!1),s.push(f))):("error"===t.phase||"cancelled"===t.phase)&&(em.current&&clearInterval(em.current),em.current=null,ep(null),eb(!1))}catch{}},1500))},[j,z,s,f,ej]);(0,a.useEffect)(()=>()=>{em.current&&(clearInterval(em.current),em.current=null)},[c]),(0,a.useEffect)(()=>{fetch(`${j}/handoff`).then(e=>e.json()).then(e=>{e.phase&&"idle"!==e.phase&&(ec(e),eS())}).catch(()=>{})},[j,eS]);let eA=(0,a.useCallback)(async()=>{if(eo?.phase!=="running"&&eo?.phase!=="awaiting_review"){ec(null),ep(null),eh(null);try{let e=await fetch(`${j}/handoff`,{method:"POST"}),t=await e.json().catch(()=>({}));if(409===e.status&&t.phase&&"idle"!==t.phase){ec(t),eS();return}if(!e.ok){let e="string"==typeof t?.error?t.error:"Failed to start handoff";eu(!0),ec({phase:"error",steps:[{id:"start",label:"Failed to start handoff",status:"error",detail:e}],reviewData:null,reviewTruncated:!1,reviewTotalLines:0,reviewAttempt:1,errorMessage:e,startedAt:new Date().toISOString()});return}ec(t),eS()}catch{let e="Failed to reach handoff API";eu(!0),ec({phase:"error",steps:[{id:"start",label:"Failed to start handoff",status:"error",detail:e}],reviewData:null,reviewTruncated:!1,reviewTotalLines:0,reviewAttempt:1,errorMessage:e,startedAt:new Date().toISOString()})}}},[j,eo,eS]),e$=(0,a.useCallback)(async()=>{if(!eg){eb(!0),eh(null);try{let e=await fetch(`${j}/handoff`,{method:"DELETE"}),t=await e.json().catch(()=>({}));if(!e.ok){let e="string"==typeof t?.error?t.error:"Failed to cancel handoff";eh(e);return}em.current&&(clearInterval(em.current),em.current=null),ep(null),eu(!0),ec(e=>e?{...e,phase:"cancelled",reviewData:null}:null)}catch{eh("Failed to reach handoff cancel API")}finally{eb(!1)}}},[j,eg]),ez=(0,a.useCallback)(async(e,t)=>{if(!ex&&!eg){ep(e.action),eh(null);try{let s=await fetch(`${j}/handoff/review`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await s.json().catch(()=>({}));if(!s.ok){let e="string"==typeof r?.error?r.error:"Failed to submit review action";eh(e);try{let e=await fetch(`${j}/handoff`),t=await e.json();t.phase&&"idle"!==t.phase&&(ec(t),eS())}catch{}return}ec(e=>e?{...e,phase:t,reviewData:null}:null)}catch{eh("Failed to reach handoff review API")}finally{ep(null)}}},[j,ex,eg,eS]),eI=(0,a.useCallback)(async()=>{await ez({action:"approve"},"running")},[ez]),eE=(0,a.useCallback)(async()=>{await ez({action:"cancel"},"cancelled")},[ez]),eT=(0,a.useCallback)(async e=>{await ez({action:"retry",feedback:e},"running")},[ez]),eR=(0,a.useCallback)(()=>{eu(!1),ec(null),ep(null),eh(null),setTimeout(()=>eA(),0)},[eA]);if(S||!C)return(0,r.jsx)("div",{className:"flex h-screen items-center justify-center",children:(0,r.jsx)(e_._,{size:"lg"})});let eD=M.cZ.find(e=>e.id===C.column),eO=M.G$[C.column];return(0,r.jsxs)("div",{className:"flex h-screen flex-col",children:[(0,r.jsxs)("header",{className:"relative z-10 border-b border-border bg-background",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 pt-3 pb-1",children:[(0,r.jsx)(eF.Y6,{label:"Back to board",children:(0,r.jsxs)(u.$,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>s.push(f),children:[(0,r.jsx)(eZ.A,{className:"size-4"}),"Board"]})}),(0,r.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:J?(0,r.jsx)("input",{className:"w-full min-w-0 max-w-full border-b-2 border-primary bg-transparent px-0 py-0 text-sm font-medium outline-none sm:max-w-[36rem]",value:G,onChange:e=>Y(e.target.value),onBlur:eN,onKeyDown:e=>{"Enter"===e.key&&eN(),"Escape"===e.key&&H(!1)},autoFocus:!0}):(0,r.jsx)("h2",{className:"w-full min-w-0 max-w-full cursor-text truncate rounded px-0.5 text-sm font-medium transition-colors hover:bg-muted/50 sm:max-w-[36rem]",onClick:()=>{Y(C.title),H(!0)},children:C.title})}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[C.worktree?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted py-0.5 pl-2.5 pr-1 font-mono text-xs font-medium",children:[(0,r.jsx)(e0.A,{className:"size-3 text-muted-foreground"}),(0,r.jsx)("span",{className:"max-w-44 truncate",children:C.worktree.split("/").pop()||C.branch}),ee&&(0,r.jsx)(eF.Y6,{label:el?"Copied!":"Copy cd path",children:(0,r.jsx)("button",{onClick:eC,className:"ml-0.5 shrink-0 cursor-pointer rounded-full p-1 text-muted-foreground hover:bg-background hover:text-foreground",children:el?(0,r.jsx)(Z.A,{className:"size-3 text-green-600"}):(0,r.jsx)(e1.A,{className:"size-3"})})})]}):C.defaultBranch?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted py-0.5 px-2.5 font-mono text-xs font-medium text-muted-foreground",children:[(0,r.jsx)(e0.A,{className:"size-3"}),C.defaultBranch]}):null,(es>0||en>0)&&(0,r.jsx)(eF.Y6,{label:"Toggle git panel",children:(0,r.jsxs)(u.$,{variant:"ghost",size:"sm",className:(0,o.cn)("gap-2 font-mono text-xs tabular-nums border border-transparent hover:border-border",P&&"border-primary hover:border-primary"),onClick:()=>F(e=>!e),children:[es>0&&(0,r.jsxs)("span",{className:"text-green-600",children:["+",es]}),en>0&&(0,r.jsxs)("span",{className:"text-red-600",children:["-",en]})]})}),(0,r.jsxs)("div",{className:"relative",children:[K&&"MERGED"===K.state?(0,r.jsxs)(u.$,{variant:"outline",size:"sm",className:"gap-1.5",disabled:!0,children:[(0,r.jsx)(Z.A,{className:"size-3.5 text-green-600"}),"Handed off"]}):K&&"CLOSED"===K.state?(0,r.jsxs)(u.$,{variant:"outline",size:"sm",className:"gap-1.5",disabled:!0,children:[(0,r.jsx)(eU.A,{className:"size-3.5 text-red-500"}),"PR Closed"]}):(0,r.jsx)(eF.Y6,{label:ej?"Commit and push to main":"Commit, push, create PR, merge, and clean up",children:(0,r.jsxs)(u.$,{variant:"outline",size:"sm",className:(0,o.cn)("gap-1.5 cursor-pointer",V?"border-green-200 bg-green-50 text-green-700 hover:bg-green-100":""),onClick:eA,disabled:!V||eo?.phase==="running"||eo?.phase==="awaiting_review",children:[eo?.phase==="running"||eo?.phase==="awaiting_review"?(0,r.jsx)(g.A,{className:"size-3.5 animate-spin"}):(0,r.jsx)(e5.A,{className:"size-3.5"}),"Hands!"]})}),ed&&eo&&(0,r.jsx)(e7,{steps:eo.steps,onRetry:"error"===eo.phase?eR:void 0,onCancel:"running"===eo.phase||"awaiting_review"===eo.phase?e$:void 0,cancelPending:eg,onClose:()=>{eu(!1),ec(null),ep(null),eh(null)},isComplete:"completed"===eo.phase,isError:"error"===eo.phase||"cancelled"===eo.phase}),eo?.phase==="awaiting_review"&&eo.reviewData&&(0,r.jsx)(tr,{open:!0,reviewData:eo.reviewData,truncated:eo.reviewTruncated,totalLines:eo.reviewTotalLines,attempt:eo.reviewAttempt,onApprove:eI,onCancel:eE,onResolveDifferently:eT,submittingAction:ex,submitError:ef,onCancelHandoff:e$,cancelHandoffPending:eg})]}),_?(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(u.$,{variant:"destructive",size:"sm",onClick:ek,children:"Confirm Delete"}),(0,r.jsx)(u.$,{variant:"ghost",size:"sm",onClick:()=>L(!1),children:"Cancel"})]}):(0,r.jsx)(eF.Y6,{label:"Delete task",children:(0,r.jsx)(u.$,{variant:"ghost",size:"icon",onClick:()=>L(!0),children:(0,r.jsx)(e2.A,{className:"size-4"})})})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 pb-3 pt-1",children:[(0,r.jsxs)(eX.rI,{children:[(0,r.jsx)(eX.ty,{asChild:!0,children:(0,r.jsxs)("button",{className:"flex cursor-pointer items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium hover:bg-muted/50",children:[eO&&(0,r.jsx)(eO,{className:"size-3.5 text-muted-foreground"}),(0,r.jsx)("span",{children:eD?.title||C.column}),(0,r.jsx)(m.A,{className:"size-3 text-muted-foreground"})]})}),(0,r.jsx)(eX.SQ,{align:"start",children:M.cZ.map(e=>{let t=M.G$[e.id];return(0,r.jsxs)(eX._2,{onClick:()=>ey(e.id),children:[t&&(0,r.jsx)(t,{className:"size-3.5 text-muted-foreground"}),e.title,e.id===C.column&&(0,r.jsx)(Z.A,{className:"ml-auto size-3"})]},e.id)})})]}),(0,r.jsxs)(eX.rI,{children:[(0,r.jsx)(eX.ty,{asChild:!0,children:(0,r.jsxs)("button",{className:"flex cursor-pointer items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium hover:bg-muted/50",children:[(0,r.jsx)(tn.w,{priority:C.priority}),(0,r.jsx)("span",{children:M.fz.find(e=>e.value===C.priority)?.label??"No priority"}),(0,r.jsx)(m.A,{className:"size-3 text-muted-foreground"})]})}),(0,r.jsx)(eX.SQ,{align:"start",children:M.fz.map(e=>(0,r.jsxs)(eX._2,{onClick:()=>ew(e.value),className:"cursor-pointer",children:[(0,r.jsx)(tn.w,{priority:e.value}),e.label,e.value===C.priority&&(0,r.jsx)(Z.A,{className:"ml-auto size-3"})]},e.value))})]}),(e=(0,M.eE)(C.status),(0,r.jsxs)("span",{className:`inline-flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs font-medium ${e.pillBgClass} ${e.pillTextClass}`,children:["running"===C.status?(0,r.jsx)(ta.x,{size:"sm"}):(0,r.jsx)("span",{className:`size-1.5 rounded-full ${e.dotClass}`}),e.label]})),(0,r.jsx)("div",{className:"flex-1"}),D&&(0,r.jsx)(eF.Y6,{label:"Needs tasting",children:(0,r.jsxs)(u.$,{variant:"outline",size:"sm",className:"gap-1.5",onClick:O,children:[(0,r.jsx)("span",{className:(0,o.cn)("text-[11px] font-semibold px-[7px] py-px rounded-full tabular-nums",(0,M.eE)("needs_tasting").pillBgClass,(0,M.eE)("needs_tasting").pillTextClass),children:D.total}),1===D.total?"Order needs tasting":"Orders need tasting",(0,r.jsx)(x.A,{className:"size-3.5"})]})})]})]}),(0,r.jsxs)("div",{className:"relative flex flex-1 overflow-hidden",children:[(0,r.jsx)("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:B?(0,r.jsx)(eV,{taskSlug:c,taskTitle:C.title,repoId:d,status:C.status,onTaskUpdated:z,autoStartContext:v||void 0,autoStartModel:N||void 0,autoStartImages:k,autoImproveTitle:w,prefetchedActiveChat:U}):(0,r.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,r.jsx)(e_._,{size:"lg"})})}),(0,r.jsxs)("div",{className:(0,o.cn)("absolute inset-y-0 right-0 z-20 flex w-[400px] max-w-[50vw] flex-col border-l border-border bg-background shadow-lg transition-transform duration-300 ease-in-out",P?"translate-x-0":"translate-x-full"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)(e0.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"truncate font-mono text-xs text-muted-foreground",children:C.branch??"main"}),C.worktree&&(0,r.jsx)("span",{className:"shrink-0 rounded bg-green-50 px-1.5 py-0.5 text-[10px] font-medium text-green-700",children:C.worktree.split("/").pop()})]}),(0,r.jsx)(u.$,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>F(!1),children:(0,r.jsx)(eU.A,{className:"size-4"})})]}),P&&(0,r.jsx)(A,{slug:c,repoId:d})]})]})]})}}}]);
|
|
24
|
+
${s}`}S.current=[...S.current,l],m(S.current);let o=`assistant-${Date.now()}`;S.current=[...S.current,{id:o,role:"assistant",content:"",blocks:[]}],m(S.current),w.current?.abort(),w.current=new AbortController;try{d&&await fetch(`${d}/status`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"running"})})}catch{}f(!0),W();let u=!1,x=!1;try{let s=_(j.current);s!==j.current&&M(s);let r=!1;for(;;){console.log("[BG-AGENT] sendMessage:",s?`resuming session ${s}`:"starting new session");let n=await fetch(`${c}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:i,sessionId:s,taskSlug:e,storageId:t,model:a}),signal:w.current.signal});if(!n.ok){let e="Chat request failed";try{let t=await n.json();t?.code==="RUN_ALREADY_ACTIVE"?e=t.error||"A run is already active for this task. Stop it before starting another.":"string"==typeof t?.error&&t.error.trim().length>0&&(e=t.error.trim())}catch{}throw Error(e)}if(!n.body)throw Error("Chat request failed");let l=n.body.getReader(),d=new TextDecoder,f="",p=!1,g=null,j=null,y=!1,v=!1,N=function(e={}){let t=[],s=new Set,r=!1,n=!1,a=!1;return{getBlocks:()=>t,getContentText:()=>t.filter(e=>"text"===e.type).map(e=>e.text).join("\n\n"),hasInputRequestBlock:()=>a,processEvent:l=>{"assistant"===l.type&&l.message?function(l){if(T(l)&&Array.isArray(l.content))for(let i of l.content){if(!T(i)||n)continue;let l="string"==typeof i.type?i.type:"";if("text"===l){let e="string"==typeof i.text?i.text:"";if(!e)continue;if(function(e){return/api error:\s*\d{3}/i.test(e)||I.some(t=>t.test(e))}(e)){!function(e){let s=E(e),r=t[t.length-1];r&&"error"===r.type&&r.message===s.message&&r.details===s.details||t.push({type:"error",message:s.message,details:s.details})}(e),r=!1;continue}let s=t[t.length-1];r||!s||"text"!==s.type?t.push({type:"text",text:e}):s.text=e,r=!1;continue}if("tool_use"===l){let r="string"==typeof i.id?i.id:void 0;if(r&&s.has(r))continue;r&&s.add(r);let l=function(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return e}}(i.input),o="string"==typeof i.name&&i.name.trim().length>0?i.name:"tool",c="AskUserQuestion"===o?function(e){let t=e;if("string"==typeof t)try{t=JSON.parse(t)}catch{return null}if(!z(t)||!Array.isArray(t.questions))return null;let s=t.questions.map(e=>(function(e){if(!z(e))return null;let t="string"==typeof e.question?e.question.trim():"";if(!t)return null;let s=(Array.isArray(e.options)?e.options:[]).map(e=>(function(e){if(!z(e))return null;let t="string"==typeof e.label?e.label.trim():"";return t?{label:t,description:"string"==typeof e.description&&e.description.trim().length>0?e.description.trim():void 0}:null})(e)).filter(e=>null!==e);return{question:t,header:"string"==typeof e.header&&e.header.trim().length>0?e.header.trim():void 0,options:s,multiSelect:!0===e.multiSelect}})(e)).filter(e=>null!==e);return s.length>0?s:null}(l):null;if(c){t.push({type:"ask_question",questions:c}),a=!0,n=!0,e.onFirstQuestion?.();continue}if("ExitPlanMode"===o){let e=T(l)&&Array.isArray(l.allowedPrompts)?l.allowedPrompts:void 0;t.push({type:"plan_approval",allowedPrompts:e}),a=!0;continue}let d="string"==typeof i.input?i.input:JSON.stringify(i.input||{},null,2);t.push({type:"tool_call",name:o,input:d})}}}(l.message):"user"===l.type&&l.message?function(e){if(T(e)&&Array.isArray(e.content))for(let s of e.content){if(!T(s)||"tool_result"!==s.type)continue;let e="string"==typeof s.content?s.content:JSON.stringify(s.content||"",null,2);for(let s=t.length-1;s>=0;s--){let r=t[s];if("tool_call"===r.type&&!r.output){r.output=e.slice(0,500);break}}r=!0}}(l.message):"error"===l.type&&function(e){if(!("message"in e))return;let s="string"==typeof e.message?e.message:"Provider execution error",n="string"==typeof e.details?e.details:void 0,a=E(n??s);t.push({type:"error",message:n?s:a.message,details:n??a.details}),r=!1}(l)},resetForNewAssistantTurn:()=>{t.length=0,s.clear(),r=!1,n=!1,a=!1}}}({onFirstQuestion:()=>{if(p)return;p=!0,h(!0);let e=N.getContentText(),t=[...N.getBlocks()];A.current={id:o,content:e,blocks:t},m(s=>{let r=s.map(s=>s.id===o?{...s,content:e,blocks:t}:s);return S.current=r,r}),W(),w.current?.abort()}}),k=Date.now();for(;;){let{done:e,value:t}=await l.read();if(e)break;let r=(f+=d.decode(t,{stream:!0})).split("\n");for(let e of(f=r.pop()||"",r)){if(!e.startsWith("data: "))continue;let t=e.slice(6).trim();if("[DONE]"===t){y=!0;continue}try{let e=JSON.parse(t);v=!0,"system"===e.type&&e.session_id&&(M(e.session_id),W()),"result"===e.type&&e.session_id&&M(e.session_id),"result"===e.type&&!0===e.is_error&&(g=g||function(e){if("result"!==e.type||!0!==e.is_error)return null;let t=L(e);return t.length>0?t[0]:null}(e),j=j||function(e,t){if(!t||"result"!==e.type||!0!==e.is_error)return null;for(let s of L(e)){if(!/No conversation found with session ID:/i.test(s))continue;let e=s.match(/No conversation found with session ID:\s*([A-Za-z0-9-]+)/i);if(!e||e[1]===t)return s}return null}(e,s)),("assistant"===e.type||"user"===e.type||"error"===e.type)&&N.processEvent(e);let r=N.getContentText(),n=[...N.getBlocks()];A.current={id:o,content:r,blocks:n},m(e=>e.map(e=>e.id===o?{...e,content:r,blocks:n}:e))}catch{}}let n=Date.now();n-k>=3e3&&(k=n,W())}if(A.current=null,u=y,x=v,j&&s&&!r){r=!0,s=null,M(null),m(e=>{let t=e.map(e=>e.id===o?{...e,content:"",blocks:[]}:e);return S.current=t,t}),W();continue}if(g){let e=E(g);m(t=>{let s=t.map(t=>{if(t.id!==o)return t;let s=t.blocks||[],r=s.some(t=>"error"===t.type&&t.message===e.message&&t.details===e.details);return{...t,content:(t.content||"").trim().length>0?t.content:e.message,blocks:r?s:[...s,{type:"error",message:e.message,details:e.details}]}});return S.current=s,W(),s})}!y&&v&&b(!0),W();break}}catch(e){"AbortError"===e.name?W():(x&&!u&&b(!0),m(t=>{let s=E(e.message||"Chat request failed"),r={type:"error",message:s.message,details:s.details},n=t.map(e=>e.id===o?{...e,content:e.content||s.message,blocks:[...e.blocks||[],r]}:e);return S.current=n,W(),n}))}finally{A.current=null,f(!1),w.current=null}},[e,t,M,W,d,c]),J=(0,a.useCallback)(()=>{w.current?.abort()},[]),H=(0,a.useCallback)(async()=>{if(!e)return;w.current?.abort();let s=j.current;if(!s)try{let r=await fetch(`${c}/chat/session?taskSlug=${encodeURIComponent(e)}&storageId=${encodeURIComponent(t)}`);if(r.ok){let e=await r.json();e.sessionId&&(s=e.sessionId)}}catch{}try{await fetch(`${c}/chat/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s,taskSlug:e,storageId:t})})}catch{d&&await fetch(`${d}/status`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"idle"})}).catch(()=>{})}f(!1),h(!1)},[e,t,c,d]),G=(0,a.useCallback)(()=>{j.current=null,N(null),h(!1),e&&(0,$.yd)(e,t,S.current,null,o)},[e,t,o]),Y=(0,a.useCallback)(e=>{let t={id:`system-${Date.now()}`,role:"system",content:e};S.current=[...S.current,t],m(S.current),W()},[W]);return{messages:u,isStreaming:x,wasDisconnected:g,sendMessage:q,stopStreaming:J,stopAgent:H,clearChat:(0,a.useCallback)(()=>{if(w.current?.abort(),w.current=null,f(!1),h(!1),m([]),S.current=[],M(null),e){(0,$._e)(e,t,o);let s=`kanban-init-sent-${e}-${t}`;try{sessionStorage.removeItem(s)}catch{}D.delete(s),fetch(`${c}/chat/session?taskSlug=${encodeURIComponent(e)}&storageId=${encodeURIComponent(t)}`,{method:"DELETE"}).catch(()=>{})}},[e,t,M,c,o]),clearSessionId:G,injectSystemMessage:Y,reloadFromServer:B,hydrateFromSnapshot:F,sessionId:v,sessionIdRef:j,awaitingInputFromQuestion:p}}(e,j,x,h),{addSession:en,removeSession:ea,getSession:el}=(0,P.a)(),ei=(0,a.useRef)(null),eo=(0,a.useRef)(null),[ec,ed]=(0,a.useState)(!0),[eu,em]=(0,a.useState)(!1),ex=(0,a.useRef)(i);ex.current=i;let ef=(0,a.useRef)(null),ep=(0,a.useRef)(null),eh=(0,a.useRef)(null),eg=(0,a.useRef)(!1),eb="needs_tasting"===l||eu||er,ej=G||"running"===l&&!eb,ey=w||M.xj,ev=(0,a.useMemo)(()=>(0,M.xq)(ey).provider,[ey]),eN=C?.providers?.[ev],ew=!eN||eN.connected,ek=(0,a.useMemo)(()=>(0,F.p)(t),[t]);(0,a.useEffect)(()=>{eg.current=!1,eh.current=null,em(!1),k(void 0)},[e]);let eC=(0,a.useCallback)(async()=>{U(!0);try{let e=await (0,$.qq)();return e&&S(e),e}finally{U(!1)}},[]);(0,a.useEffect)(()=>{eC()},[eC,ev]),(0,a.useEffect)(()=>{J(!1)},[ev]),(0,a.useEffect)(()=>{if(ew&&!W)return;let e=setInterval(()=>{eC()},5e3);return()=>clearInterval(e)},[ew,W,eC]);let eS=(0,a.useCallback)(async e=>{let t=(0,M.xq)(e).provider,s=C?.providers?.[t],r=C?.checkedAt?Date.parse(C.checkedAt):0,n=r>0&&Date.now()-r<15e3;if(s&&n)return s.connected;let a=await eC(),l=a?.providers?.[t];return!l||l.connected},[C,eC]);(0,a.useEffect)(()=>{eS(w||M.xj)},[w,eS]);let eA=(0,a.useCallback)(async(e,t,s)=>{let r=eY(t),n={messages:[...H],sessionId:eY(es.current)},a=n.sessionId!==r,l=new Set(n.messages.map(e=>e.id)),i=[],o=new Map;for(let t of e){if(l.has(t.id)){let e=n.messages.findIndex(e=>e.id===t.id);-1!==e&&(0,R.B)(n.messages[e],t)&&o.set(e,t);continue}!function(e,t){if("user"!==t.role)return!1;let s=eK(t.content);if(!s)return!1;let r=eQ(t.id);for(let t=e.length-1;t>=0;t--){let n=e[t];if("user"!==n.role||eK(n.content)!==s)continue;let a=eQ(n.id);if(null!==r&&null!==a)return 1e4>=Math.abs(r-a);return!0}return!1}(n.messages,t)&&i.push(t)}if(o.size>0){for(let[e,t]of o)n.messages[e]=t;a=!0}if(i.length>0&&(n.messages=[...n.messages,...i],a=!0),s){let e=n.messages.findIndex(e=>e.id===s.id);-1!==e?(0,R.B)(n.messages[e],s)&&(n.messages[e]=s,a=!0):(n.messages.push(s),a=!0)}a&&ee({messages:n.messages,sessionId:r})},[H,es,ee]);(0,a.useEffect)(()=>{let t=`${e}-${j}`;ef.current!==t&&(ef.current=t,(async()=>{try{let t=await fetch(`${g}/chat/session?taskSlug=${encodeURIComponent(e)}&storageId=${encodeURIComponent(j)}`);if(!t.ok)return;let s=await t.json(),r="string"==typeof s.sessionId?s.sessionId.trim():null,n=eY(r)??r;if(em(!!(s.awaitingInput||"needs_tasting"===s.status)),!n)return void em(!1);let a=await fetch(`${g}/chat/poll?sessionId=${encodeURIComponent(n)}&afterIndex=0`);if(!a.ok)return;let l=await a.json();em(!!(l.awaitingInput||"needs_tasting"===l.status)),await eA(Array.isArray(l.messages)?l.messages:[],n,l.inProgress||null),"running"===l.status?en({sessionId:n,taskSlug:e,storageId:j,lastIndex:l.totalCount||0}):(ea(n),ex.current())}catch{}})())},[e,j,g,en,ea,eA]),(0,a.useEffect)(()=>{if(G)return;let t=el(e,j);if(!(t||et||"running"===l||eb))return;let s=setInterval(()=>{Z(),!el(e,j)&&t&&ex.current()},3e3);return()=>clearInterval(s)},[G,et,l,eb,e,j,el,Z]),(0,a.useEffect)(()=>{if(G&&et){let t=el(e,j);t?.sessionId!==et&&en({sessionId:et,taskSlug:e,storageId:j,lastIndex:0})}},[G,et,e,j,en,el]);let e$=(0,a.useRef)(G);e$.current=G;let ez=(0,a.useRef)(en);ez.current=en,(0,a.useEffect)(()=>()=>{let t=es.current;t&&e$.current&&ez.current({sessionId:t,taskSlug:e,storageId:j,lastIndex:0})},[e,j,es]);let eI=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(!eI.current&&G){ex.current(),eI.current=G;return}if(eI.current&&!G){let e=setTimeout(()=>{ex.current()},500);return et&&ea(et),eI.current=G,()=>clearTimeout(e)}eI.current=G},[G,et,ea]),(0,a.useEffect)(()=>{let e=eo.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:s,clientHeight:r}=e;ed(s-t-r<100)};return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[]);let eE=(0,a.useRef)(!1);(0,a.useEffect)(()=>{ec&&(eE.current||!(H.length>0)||(eE.current=!0,ej||eb))&&ei.current?.scrollIntoView({behavior:"smooth"})},[H,ec,ej,eb]),(0,a.useEffect)(()=>{if(eb&&ec){let e=setTimeout(()=>{ei.current?.scrollIntoView({behavior:"smooth"})},100);return()=>clearTimeout(e)}},[eb,ec]);let eT=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(Y&&!G&&!eT.current){eT.current=!0;let e=setTimeout(()=>{V();let e=w||M.xj;(async()=>{if(!await eS(e))return B({id:`queued-${Date.now()}`,message:"Continue where you left off",model:e});X("Connection interrupted — reconnecting…"),K("Continue where you left off",{model:e})})()},2e3);return()=>clearTimeout(e)}Y||G||(eT.current=!1)},[Y,G,V,X,K,w,eS]);let eR=(()=>{if(G||ej)return!1;if(Y)return!0;let e=[...H].reverse().find(e=>"system"===e.role);if(e?.content?.includes("Session restarted")){let t=H.indexOf(e);return!H.slice(t+1).some(e=>"user"===e.role)}return!1})(),eD=(0,a.useCallback)(async(e,t,s)=>{let r=s||w||M.xj;await eS(r)?(B(null),em(!1),eh.current||(eh.current=r),K(e,{images:t,model:r})):B({id:`queued-${Date.now()}`,message:e,images:t,model:r})},[w,eS,K]);(0,a.useEffect)(()=>{v&&(eh.current||(eh.current=v.model||w||M.xj),em(!1),K(v.message,{images:v.images,model:v.model}),N(null))},[v,w,K]);let eP=(0,a.useCallback)(()=>{W&&(B(null),eD(W.message,W.images,W.model))},[W,eD]);(0,a.useEffect)(()=>{if(!W||!ew||ep.current===W.id)return;ep.current=W.id;let e=setTimeout(()=>{eP()},250);return()=>clearTimeout(e)},[W,ew,eP]);let eF=(0,a.useCallback)(e=>{w!==e&&k(e)},[w]),eU=(0,a.useCallback)(async()=>{let e=w||M.xj;await eS(e)?(V(),em(!1),K("Continue where you left off",{model:e})):B({id:`queued-${Date.now()}`,message:"Continue where you left off",model:e})},[w,eS,V,K]),eW=(0,a.useCallback)(async()=>{await Q(),et&&ea(et),ex.current()},[Q,et,ea]),eB=(0,a.useRef)(!1);return((0,a.useEffect)(()=>{if(eB.current)return;let e=o?.trim();e&&(eB.current=!0,c&&k(c),N({message:e,images:d?.length?d:void 0,model:c||w||M.xj}))},[o,c,d,w]),(0,a.useEffect)(()=>{if(!m&&!ek||eg.current||G)return;let e=H.find(e=>"user"===e.role&&(e.content||"").trim().length>0),t=H.find(e=>"assistant"===e.role&&(e.content||"").trim().length>0);e&&t&&(eg.current=!0,fetch(`${b}/improve-title`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:eh.current||c||w||M.xj,userMessage:e.content,assistantMessage:t.content})}).then(e=>e.ok?e.json():null).then(e=>{e?.changed&&ex.current()}).catch(()=>{}))},[m,ek,G,H,b,c,w]),x||0!==H.length||e)?(0,r.jsxs)("div",{className:"flex h-full flex-col overflow-hidden bg-white",children:[(0,r.jsx)("div",{ref:eo,className:"flex-1 min-h-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-3 px-6 py-4 md:px-10 md:py-5",children:[0===H.length&&!ej&&(0,r.jsx)("div",{className:"py-10 text-center text-xs text-muted-foreground",children:"Start a conversation."}),H.map((t,s)=>{let n=s+1<H.length&&"user"===H[s+1].role;return(0,r.jsx)(eO,{message:t,slug:e,repoId:h,showThinking:ej&&"assistant"===t.role&&s===H.length-1,onQuestionAnswer:eD,isQuestionAnswered:"assistant"===t.role&&n&&!!t.blocks?.some(e=>"ask_question"===e.type||"plan_approval"===e.type)},t.id)}),ej&&(0===H.length||H[H.length-1]?.role!=="assistant")&&(0,r.jsx)(eO,{message:{id:"__tail-thinking__",role:"assistant",content:""},slug:e,repoId:h,showThinking:!0}),(0,r.jsx)("div",{ref:ei})]})}),(0,r.jsxs)("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-2 px-6 pt-2 pb-4 md:px-10 md:pb-6",children:[eN&&!eN.connected&&(0,r.jsxs)(eM,{variant:"warning",dot:!0,actions:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:async()=>{try{await navigator.clipboard.writeText(eN.reauthCommand),J(!0),window.setTimeout(()=>J(!1),1500)}catch{J(!1)}},className:"rounded-full border border-amber-200 bg-white px-3 py-1 text-xs font-medium text-amber-700 cursor-pointer hover:bg-amber-100 transition-colors",children:q?"Copied":"Reconnect"}),(0,r.jsx)("button",{onClick:()=>{eC()},disabled:A,className:"rounded-full border border-amber-200 bg-white px-3 py-1 text-xs font-medium text-amber-700 cursor-pointer hover:bg-amber-100 transition-colors disabled:opacity-60 disabled:cursor-default",children:A?"Checking...":"Check again"})]}),children:[(0,r.jsxs)("p",{children:["expired"===eN.reason?`${M.OW[ev]} authentication expired.`:`${M.OW[ev]} is disconnected.`," ","Run this command in your terminal:"]}),(0,r.jsx)("code",{className:"mt-1 inline-block rounded bg-amber-100 px-1 py-0.5 text-[11px]",children:eN.reauthCommand}),W&&(0,r.jsx)("p",{className:"mt-1 text-[11px] text-amber-700",children:"Your last message is queued."})]}),W&&ew&&(0,r.jsx)(eM,{variant:"success",dot:!0,actions:(0,r.jsx)("button",{onClick:eP,className:"rounded-full border border-emerald-200 bg-white px-3 py-1 text-xs font-medium text-emerald-700 cursor-pointer hover:bg-emerald-100 transition-colors",children:"Retry now"}),children:"Reconnected. Retrying your queued message automatically."}),eR&&(0,r.jsxs)(eM,{variant:"muted",centered:!0,children:[(0,r.jsx)("span",{children:"Conversation was interrupted"}),(0,r.jsxs)(u.$,{variant:"outline",size:"sm",onClick:eU,className:"ml-2 gap-1 h-7 px-3 text-xs cursor-pointer",children:[(0,r.jsx)(eL.A,{className:"size-3"}),"Resume"]})]}),(0,r.jsx)(eG,{onSend:eD,onModelChange:eF,selectedModel:w,onStop:eW,isStreaming:ej,slug:e,repoId:h})]})]}):(0,r.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,r.jsx)(e_._,{size:"lg"})})}var eX=s(2264),eZ=s(1597),e0=s(9467),e1=s(4289),e5=s(774),e2=s(7241),e3=s(1735),e6=s(5357);let e4={pending:null,in_progress:(0,r.jsx)(g.A,{className:"size-3.5 animate-spin text-orange-500"}),done:(0,r.jsx)(Z.A,{className:"size-3.5 text-green-600"}),error:(0,r.jsx)(eU.A,{className:"size-3.5 text-red-500"}),warning:(0,r.jsx)(e3.A,{className:"size-3.5 text-amber-500"})};function e7({steps:e,onRetry:t,onCancel:s,cancelPending:n,onClose:a,isComplete:l,isError:i}){let c=!!(s||l||i);return(0,r.jsxs)("div",{className:"absolute right-0 top-full mt-2 z-50 w-80 rounded-lg border bg-background shadow-lg",children:[(0,r.jsxs)("div",{className:"p-4 space-y-2",children:[0===e.length&&!l&&!i&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,r.jsx)(g.A,{className:"size-3.5 animate-spin"}),"Starting handoff…"]}),e.map(e=>(0,r.jsxs)("div",{className:"flex items-start gap-2 text-sm",children:[(0,r.jsx)("span",{className:"mt-0.5 shrink-0 w-4",children:e4[e.status]}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:(0,o.cn)("error"===e.status&&"text-red-600","done"===e.status&&"text-muted-foreground"),children:e.label}),e.detail&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:e.detail})]})]},e.id)),l&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-green-600 pt-1",children:[(0,r.jsx)(e6.A,{className:"size-4"}),"Handed off!"]})]}),c&&(0,r.jsxs)("div",{className:"border-t px-4 py-2 flex gap-2",children:[s&&(0,r.jsx)(u.$,{size:"sm",variant:"outline",onClick:s,disabled:n,className:"flex-1 text-xs cursor-pointer",children:n?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.A,{className:"size-3.5 animate-spin mr-1"}),"Cancelling…"]}):"Cancel handoff"}),i&&t&&(0,r.jsx)(u.$,{size:"sm",variant:"outline",onClick:t,className:"flex-1 text-xs cursor-pointer",children:"Retry"}),(l||i)&&(0,r.jsx)(u.$,{size:"sm",variant:"ghost",onClick:a,className:"flex-1 text-xs cursor-pointer",children:"Close"})]})]})}let e8=(0,s(8460).F)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function e9({className:e,variant:t,...s}){return(0,r.jsx)("div",{className:(0,o.cn)(e8({variant:t}),e),...s})}var te=s(2083);let tt={addition:"bg-green-500/10 text-green-800",deletion:"bg-red-500/10 text-red-800",hunk:"bg-blue-500/8 text-blue-600 font-medium",context:"",meta:"text-muted-foreground"},ts={addition:"bg-green-500/15 text-green-700 border-r border-green-500/20",deletion:"bg-red-500/15 text-red-700 border-r border-red-500/20",hunk:"bg-blue-500/10 border-r border-blue-500/20",context:"bg-muted/30 text-muted-foreground border-r border-border/50",meta:"bg-muted/30 border-r border-border/50"};function tr({open:e,reviewData:t,truncated:s,totalLines:n,attempt:l,onApprove:i,onCancel:o,onResolveDifferently:c,submittingAction:d,submitError:f,onCancelHandoff:h,cancelHandoffPending:b}){let[j,y]=(0,a.useState)(!0),[v,N]=(0,a.useState)(!1),[w,k]=(0,a.useState)(""),[C,S]=(0,a.useState)(new Set),A=new Set(t.conflictFiles.filter(e=>"text"===e.type).map(e=>e.path)),$=new Set(t.conflictFiles.filter(e=>"binary"===e.type).map(e=>e.path)),z=!t.fullDiff||"No diff available"===t.fullDiff,I=(0,a.useMemo)(()=>z?[]:function(e,t,s){let r=e.split("\n"),n=[],a=null,l=0,i=0;for(let e of r){let r=e.match(/^diff --git a\/(.+?) b\/(.+)$/);if(r){a&&n.push(a);let e=r[2];a={filePath:e,lines:[],additions:0,deletions:0,isConflictFile:t.has(e),isBinaryConflict:s.has(e)};continue}if(!a)continue;let o=e.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@(.*)/);if(o){l=parseInt(o[1],10),i=parseInt(o[2],10),a.lines.push({content:e,type:"hunk",oldNum:null,newNum:null});continue}if(e.startsWith("index ")||e.startsWith("--- ")||e.startsWith("+++ ")||e.startsWith("old mode")||e.startsWith("new mode")||e.startsWith("new file")||e.startsWith("deleted file")||e.startsWith("similarity index")||e.startsWith("rename from")||e.startsWith("rename to")||e.startsWith("Binary files")){a.lines.push({content:e,type:"meta",oldNum:null,newNum:null});continue}if(e.startsWith("+")){a.additions++,a.lines.push({content:e.slice(1),type:"addition",oldNum:null,newNum:i++});continue}if(e.startsWith("-")){a.deletions++,a.lines.push({content:e.slice(1),type:"deletion",oldNum:l++,newNum:null});continue}a.lines.push({content:e.startsWith(" ")?e.slice(1):e,type:"context",oldNum:l++,newNum:i++})}return a&&n.push(a),n}(t.fullDiff,A,$),[t.fullDiff,z]),E=(0,a.useMemo)(()=>t.aiExplanation?function(e){let t=[],s=null,r=e.split("\n"),n=[];for(let e of r){let s=e.match(/^\|?\s*`?([^\s|`]+\.\w+)`?\s*\|\s*(.+?)\s*\|?\s*$/);if(s){let e=s[1].split("/").pop()||s[1];t.push({fileName:e,explanation:s[2].trim()});continue}let r=e.match(/^\*\*([^\s*]+\.\w+)\*\*\s*[—:\-–]\s*(.+)$/);if(r){let e=r[1].split("/").pop()||r[1];t.push({fileName:e,explanation:r[2].trim()});continue}let a=e.match(/^[-*]\s+`?([^\s`]+\.\w+)`?\s*[—:\-–]\s*(.+)$/);if(a){let e=a[1].split("/").pop()||a[1];t.push({fileName:e,explanation:a[2].trim()});continue}e.match(/^\|?\s*[-|]+\s*\|?\s*$/)||e.match(/^\|\s*File\s*\|/i)||n.push(e)}let a=n.join("\n").trim();return a&&(s=a),{fileExplanations:t,summary:s}}(t.aiExplanation):null,[t.aiExplanation]);return(0,r.jsx)(eh.lG,{open:e,onOpenChange:()=>{},children:(0,r.jsxs)(eh.Cf,{className:"sm:max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",showCloseButton:!1,onPointerDownOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,r.jsxs)(eh.c7,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(eh.L3,{children:"Review conflict resolution"}),l&&l>1&&(0,r.jsxs)(e9,{className:"bg-blue-100 text-blue-800 border-blue-300",children:["Attempt ",l]})]}),(0,r.jsxs)(eh.rr,{children:["The AI resolved ",t.conflictFiles.length," conflict",1!==t.conflictFiles.length?"s":"",". Review the changes before merging."]})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-3",children:[E&&(0,r.jsxs)("div",{className:"rounded-lg border border-indigo-200 bg-indigo-50/50 overflow-hidden",children:[(0,r.jsxs)("button",{onClick:()=>y(!j),className:"flex items-center gap-2 w-full px-3 py-2.5 bg-indigo-100/60 cursor-pointer hover:bg-indigo-100 transition-colors",children:[(0,r.jsx)(te.A,{className:"size-4 text-indigo-600"}),(0,r.jsx)("span",{className:"text-sm font-semibold text-indigo-800",children:"How conflicts were resolved"}),j?(0,r.jsx)(m.A,{className:"size-4 ml-auto text-indigo-500"}):(0,r.jsx)(x.A,{className:"size-4 ml-auto text-indigo-500"})]}),j&&(0,r.jsxs)("div",{className:"px-3 py-3 space-y-2",children:[E.fileExplanations.map((e,t)=>(0,r.jsxs)("div",{className:"flex gap-2.5 p-2.5 rounded-md bg-white border border-border/50",children:[(0,r.jsx)(V.A,{className:"size-4 text-amber-500 mt-0.5 shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-foreground",children:(0,r.jsx)("code",{className:"bg-muted px-1 py-0.5 rounded text-[11px]",children:e.fileName})}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1 leading-relaxed",children:e.explanation})]})]},t)),0===E.fileExplanations.length&&t.aiExplanation&&(0,r.jsx)("div",{className:"text-xs text-foreground/80 whitespace-pre-wrap leading-relaxed",children:t.aiExplanation}),E.summary&&(0,r.jsxs)("div",{className:"flex items-start gap-2 px-2.5 py-2 rounded-md bg-green-50 border border-green-200 text-xs text-green-800 leading-relaxed",children:[(0,r.jsx)(p.A,{className:"size-3.5 mt-0.5 shrink-0"}),(0,r.jsx)("span",{children:E.summary})]})]})]}),(0,r.jsx)("div",{className:"rounded-lg border",children:z?(0,r.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"No changes detected"}):(0,r.jsxs)("div",{className:"divide-y divide-border",children:[I.map((e,t)=>{let s=C.has(t),n=e.filePath.split("/").pop()||e.filePath,a=e.filePath.includes("/")?e.filePath.slice(0,e.filePath.lastIndexOf("/")+1):"";return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{onClick:()=>{S(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:`flex items-center gap-2 px-3 py-2 cursor-pointer sticky top-0 z-10 ${e.isConflictFile?"bg-amber-50 hover:bg-amber-100/70":"bg-muted/50 hover:bg-muted/80"} transition-colors`,children:[s?(0,r.jsx)(x.A,{className:"size-3.5 text-muted-foreground shrink-0"}):(0,r.jsx)(m.A,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,r.jsx)(V.A,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,r.jsxs)("span",{className:"font-mono text-xs truncate",children:[a&&(0,r.jsx)("span",{className:"text-muted-foreground",children:a}),(0,r.jsx)("span",{className:"font-medium",children:n})]}),e.isConflictFile&&(0,r.jsx)(e9,{className:"bg-amber-100 text-amber-800 border-amber-300 text-[10px] px-1.5 py-0",children:"CONFLICT"}),e.isBinaryConflict&&(0,r.jsx)(e9,{className:"bg-red-100 text-red-800 border-red-300 text-[10px] px-1.5 py-0",children:"BINARY"}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-1 text-xs shrink-0",children:[e.additions>0&&(0,r.jsxs)("span",{className:"text-green-600 font-medium",children:["+",e.additions]}),e.additions>0&&e.deletions>0&&(0,r.jsx)("span",{className:"text-muted-foreground",children:"\xb7"}),e.deletions>0&&(0,r.jsxs)("span",{className:"text-red-600 font-medium",children:["−",e.deletions]})]})]}),!s&&(0,r.jsx)("div",{className:"font-mono text-[11px] leading-5",children:e.lines.map((e,t)=>"meta"===e.type?null:(0,r.jsxs)("div",{className:`flex ${tt[e.type]}`,children:[(0,r.jsx)("span",{className:`w-10 shrink-0 text-right pr-2 select-none text-[10px] ${ts[e.type]}`,children:e.oldNum??""}),(0,r.jsx)("span",{className:`w-10 shrink-0 text-right pr-2 select-none text-[10px] ${ts[e.type]}`,children:e.newNum??""}),(0,r.jsx)("span",{className:"flex-1 px-2 whitespace-pre overflow-x-auto",children:"hunk"===e.type?(0,r.jsx)("span",{className:"font-medium",children:e.content}):e.content||"\xa0"})]},t))})]},t)}),s&&(0,r.jsxs)("div",{className:"px-3 py-2.5 bg-amber-50 border-t border-amber-200 text-amber-800 text-xs",children:[(0,r.jsx)(e3.A,{className:"size-3.5 inline mr-1.5 -mt-0.5"}),"Diff truncated — showing first 5,000 of"," ",n?.toLocaleString()," lines"]})]})})]}),v&&(0,r.jsxs)("div",{className:"border-t pt-3 mt-3 space-y-2 shrink-0",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"How should the conflicts be resolved?"}),(0,r.jsx)("textarea",{className:"w-full min-h-[80px] rounded-md border p-2 text-sm",placeholder:"Describe how you want the conflicts resolved...",value:w,onChange:e=>k(e.target.value)}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(u.$,{variant:"outline",size:"sm",onClick:()=>N(!1),disabled:null!==d||b,className:"cursor-pointer",children:"Back"}),(0,r.jsx)(u.$,{size:"sm",onClick:()=>c(w),disabled:!w.trim()||null!==d||b,className:"bg-amber-600 hover:bg-amber-700 text-white cursor-pointer",children:"retry"===d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.A,{className:"size-3.5 animate-spin mr-1"}),"Submitting…"]}):"Submit feedback"})]})]}),!v&&(0,r.jsxs)(eh.Es,{className:"shrink-0",children:[(0,r.jsxs)("div",{className:"flex w-full justify-between",children:[(0,r.jsx)(u.$,{variant:"outline",onClick:()=>N(!0),disabled:null!==d||b,className:"text-amber-700 border-amber-300 hover:bg-amber-50 cursor-pointer",children:"Resolve differently ↻"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(u.$,{variant:"outline",onClick:o,disabled:null!==d||b,className:"cursor-pointer",children:"cancel"===d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.A,{className:"size-3.5 animate-spin mr-1"}),"Cancelling…"]}):"Cancel"}),(0,r.jsx)(u.$,{onClick:i,disabled:null!==d||b,className:"bg-green-600 hover:bg-green-700 text-white cursor-pointer",children:"approve"===d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.A,{className:"size-3.5 animate-spin mr-1"}),"Approving…"]}):"Approve & Merge"})]})]}),(f||h)&&(0,r.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 text-xs",children:[(0,r.jsx)("span",{className:f?"text-red-600":"text-muted-foreground",children:f||"Need to abort immediately? Cancel the whole handoff."}),h&&(0,r.jsx)(u.$,{variant:"ghost",size:"sm",onClick:h,disabled:null!==d||b,className:"text-xs cursor-pointer",children:b?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.A,{className:"size-3.5 animate-spin mr-1"}),"Cancelling handoff…"]}):"Cancel handoff now"})]})]})]})})}var tn=s(6007),ta=s(9409),tl=s(2666);function ti(){let e,t=(0,n.useParams)(),s=(0,n.useRouter)(),i=(0,n.useSearchParams)(),c=t.slug,d=(0,y.NK)(t),f=(0,a.useMemo)(()=>(0,y.Yg)(d),[d]),p=d?`/r/${encodeURIComponent(d)}/board`:"/board",h=e=>d?`/r/${encodeURIComponent(d)}/task/${encodeURIComponent(e)}`:`/task/${encodeURIComponent(e)}`,b=(0,a.useMemo)(()=>`${f}/tasks`,[f]),j=(0,a.useMemo)(()=>`${b}/${encodeURIComponent(c)}`,[b,c]),v=i.get("context"),N=i.get("model"),w="1"===i.get("autoTitle"),k=i.get("images")?.split(",").filter(Boolean)||void 0,{task:C,loading:S,fetchTask:z}=(0,l.S)(c,d),{addToast:I}=(0,tl.d)();(0,a.useEffect)(()=>{if(d)return;let e=!1;return fetch("/api/repos").then(e=>e.ok?e.json():null).then(t=>{!e&&t?.lastRepoId&&s.replace(`/r/${encodeURIComponent(t.lastRepoId)}/task/${encodeURIComponent(c)}`)}).catch(()=>{}),()=>{e=!0}},[d,s,c]);let[E,T]=(0,a.useState)(null),R=(0,a.useCallback)(async()=>{try{let e=await fetch(`${b}/counts`),t=await e.json();return T({slugs:t.slugs,total:t.inputNeeded}),t}catch{return null}},[b]);(0,a.useEffect)(()=>{R()},[c,R]);let D=(0,a.useMemo)(()=>{if(!E||0===E.total)return null;let e=E.slugs.indexOf(c);if(-1===e)return{nextSlug:E.slugs[0],total:E.total};let t=(e+1)%E.slugs.length;return{nextSlug:E.slugs[t],total:E.total}},[E,c]),O=(0,a.useCallback)(async()=>{let e=await R();if(!e||0===e.inputNeeded)return;let t=e.slugs.indexOf(c),r=-1===t?e.slugs[0]:e.slugs[(t+1)%e.slugs.length];s.push(h(r))},[R,c,s]),[_,L]=(0,a.useState)(!1),[P,F]=(0,a.useState)(!1),[U,W]=(0,a.useState)(void 0),[B,q]=(0,a.useState)(!1),[J,H]=(0,a.useState)(!1),[G,Y]=(0,a.useState)(""),[K,Q]=(0,a.useState)(null),[V,X]=(0,a.useState)(!1),[ee,et]=(0,a.useState)(null),[es,er]=(0,a.useState)(0),[en,ea]=(0,a.useState)(0),[el,ei]=(0,a.useState)(!1),[eo,ec]=(0,a.useState)(null),[ed,eu]=(0,a.useState)(!1),em=(0,a.useRef)(null),[ex,ef]=(0,a.useState)(null),[ep,eh]=(0,a.useState)(null),[eg,eb]=(0,a.useState)(!1);(0,a.useEffect)(()=>{W(void 0),q(!1);let e=!1;return(async()=>{try{let t=await fetch(`${j}/chat?storageId=${encodeURIComponent("chat-main")}`);if(e)return;let s=t.ok?await t.json():null;if(e)return;W({storageId:"chat-main",chat:s}),q(!0)}catch{if(e)return;W(null),q(!0)}})(),()=>{e=!0}},[c,j]),(0,a.useEffect)(()=>{C?.branch&&fetch(`${j}/pr-status`).then(e=>e.json()).then(e=>{"state"in e?Q(e):Q(null)}).catch(()=>Q(null))},[j,C?.branch]);let ej=!C?.branch;(0,a.useEffect)(()=>{if(!C){X(!1),et(null);return}fetch(`${j}/git`).then(e=>e.json()).then(e=>{if(e.error){X(!1),et(null),er(0),ea(0);return}X((e.staged?.length??0)>0||(e.unstaged?.length??0)>0||(e.commits?.length??0)>0),et(e.worktreeCwd??null);let t=0,s=0;for(let r of e.staged??[])t+=r.linesAdded??0,s+=r.linesRemoved??0;for(let r of e.unstaged??[])t+=r.linesAdded??0,s+=r.linesRemoved??0;er(t),ea(s)}).catch(()=>{X(!1),et(null),er(0),ea(0)})},[j,C]),(0,a.useEffect)(()=>{let e=e=>{if("Escape"!==e.key)return;let t=e.target?.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&s.push(p)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s]);let ey=(0,a.useCallback)(async(e,t)=>{let s=await fetch(`${j}/move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetColumn:e,force:t})});if(s.ok){if((await s.json()).worktreeWarning){window.confirm("This task's worktree has uncommitted changes. Remove worktree anyway?")&&await ey(e,!0);return}await z()}},[j,z]),ev=(0,a.useCallback)(e=>{(0,$.U8)(c,e,d)},[c,d]),eN=(0,a.useCallback)(async()=>{let e=G.trim();if(!e||e===C?.title)return void H(!1);let t=await fetch(j,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e})});if(t.ok){let e=await t.json();H(!1),e.newSlug?(ev(e.newSlug),s.replace(h(e.newSlug))):await z()}},[G,C?.title,j,s,z,ev]),ew=(0,a.useCallback)(async e=>{(await fetch(j,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})})).ok&&await z()},[j,z]),ek=(0,a.useCallback)(async()=>{try{let e=await fetch(j,{method:"DELETE",signal:AbortSignal.timeout(3e4)});if(e.ok){let e=`kanban-chat-${c}-`;try{for(let t=window.localStorage.length-1;t>=0;t-=1){let s=window.localStorage.key(t);s&&s.startsWith(e)&&window.localStorage.removeItem(s)}}catch{}s.push(p)}else{let t=await e.json().catch(()=>null);I(t?.error??`Delete failed (${e.status})`,"error")}}catch{I("Delete request timed out — the server may be busy. Try again.","error")}},[j,c,s,p,I]),eC=(0,a.useCallback)(()=>{if(!ee)return;let e=`cd "${ee}"`;navigator.clipboard.writeText(e).then(()=>{ei(!0),setTimeout(()=>ei(!1),2e3)}).catch(()=>{})},[ee]),eS=(0,a.useCallback)(()=>{em.current||(eu(!0),em.current=setInterval(async()=>{try{let e=await fetch(`${j}/handoff`),t=await e.json();if("idle"===t.phase){em.current&&clearInterval(em.current),em.current=null,ec(null),eu(!1),ef(null),eh(null),eb(!1);return}ec(t),"completed"===t.phase?(em.current&&clearInterval(em.current),em.current=null,ef(null),eh(null),eb(!1),await z(),ej?(eu(!1),ec(null),X(!1),er(0),ea(0)):(eu(!1),s.push(p))):("error"===t.phase||"cancelled"===t.phase)&&(em.current&&clearInterval(em.current),em.current=null,ef(null),eb(!1))}catch{}},1500))},[j,z,s,p,ej]);(0,a.useEffect)(()=>()=>{em.current&&(clearInterval(em.current),em.current=null)},[c]),(0,a.useEffect)(()=>{fetch(`${j}/handoff`).then(e=>e.json()).then(e=>{e.phase&&"idle"!==e.phase&&(ec(e),eS())}).catch(()=>{})},[j,eS]);let eA=(0,a.useCallback)(async()=>{if(eo?.phase!=="running"&&eo?.phase!=="awaiting_review"){ec(null),ef(null),eh(null);try{let e=await fetch(`${j}/handoff`,{method:"POST"}),t=await e.json().catch(()=>({}));if(409===e.status&&t.phase&&"idle"!==t.phase){ec(t),eS();return}if(!e.ok){let e="string"==typeof t?.error?t.error:"Failed to start handoff";eu(!0),ec({phase:"error",steps:[{id:"start",label:"Failed to start handoff",status:"error",detail:e}],reviewData:null,reviewTruncated:!1,reviewTotalLines:0,reviewAttempt:1,errorMessage:e,startedAt:new Date().toISOString()});return}ec(t),eS()}catch{let e="Failed to reach handoff API";eu(!0),ec({phase:"error",steps:[{id:"start",label:"Failed to start handoff",status:"error",detail:e}],reviewData:null,reviewTruncated:!1,reviewTotalLines:0,reviewAttempt:1,errorMessage:e,startedAt:new Date().toISOString()})}}},[j,eo,eS]),e$=(0,a.useCallback)(async()=>{if(!eg){eb(!0),eh(null);try{let e=await fetch(`${j}/handoff`,{method:"DELETE"}),t=await e.json().catch(()=>({}));if(!e.ok){let e="string"==typeof t?.error?t.error:"Failed to cancel handoff";eh(e);return}em.current&&(clearInterval(em.current),em.current=null),ef(null),eu(!0),ec(e=>e?{...e,phase:"cancelled",reviewData:null}:null)}catch{eh("Failed to reach handoff cancel API")}finally{eb(!1)}}},[j,eg]),ez=(0,a.useCallback)(async(e,t)=>{if(!ex&&!eg){ef(e.action),eh(null);try{let s=await fetch(`${j}/handoff/review`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await s.json().catch(()=>({}));if(!s.ok){let e="string"==typeof r?.error?r.error:"Failed to submit review action";eh(e);try{let e=await fetch(`${j}/handoff`),t=await e.json();t.phase&&"idle"!==t.phase&&(ec(t),eS())}catch{}return}ec(e=>e?{...e,phase:t,reviewData:null}:null)}catch{eh("Failed to reach handoff review API")}finally{ef(null)}}},[j,ex,eg,eS]),eI=(0,a.useCallback)(async()=>{await ez({action:"approve"},"running")},[ez]),eE=(0,a.useCallback)(async()=>{await ez({action:"cancel"},"cancelled")},[ez]),eT=(0,a.useCallback)(async e=>{await ez({action:"retry",feedback:e},"running")},[ez]),eR=(0,a.useCallback)(()=>{eu(!1),ec(null),ef(null),eh(null),setTimeout(()=>eA(),0)},[eA]);if(S||!C)return(0,r.jsx)("div",{className:"flex h-screen items-center justify-center",children:(0,r.jsx)(e_._,{size:"lg"})});let eD=M.cZ.find(e=>e.id===C.column),eO=M.G$[C.column];return(0,r.jsxs)("div",{className:"flex h-screen flex-col",children:[(0,r.jsxs)("header",{className:"relative z-10 border-b border-border bg-background",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 pt-3 pb-1",children:[(0,r.jsx)(eF.Y6,{label:"Back to board",children:(0,r.jsxs)(u.$,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>s.push(p),children:[(0,r.jsx)(eZ.A,{className:"size-4"}),"Board"]})}),(0,r.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:J?(0,r.jsx)("input",{className:"w-full min-w-0 max-w-full border-b-2 border-primary bg-transparent px-0 py-0 text-sm font-medium outline-none sm:max-w-[36rem]",value:G,onChange:e=>Y(e.target.value),onBlur:eN,onKeyDown:e=>{"Enter"===e.key&&eN(),"Escape"===e.key&&H(!1)},autoFocus:!0}):(0,r.jsx)("h2",{className:"w-full min-w-0 max-w-full cursor-text truncate rounded px-0.5 text-sm font-medium transition-colors hover:bg-muted/50 sm:max-w-[36rem]",onClick:()=>{Y(C.title),H(!0)},children:C.title})}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[C.worktree?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted py-0.5 pl-2.5 pr-1 font-mono text-xs font-medium",children:[(0,r.jsx)(e0.A,{className:"size-3 text-muted-foreground"}),(0,r.jsx)("span",{className:"max-w-44 truncate",children:C.worktree.split("/").pop()||C.branch}),ee&&(0,r.jsx)(eF.Y6,{label:el?"Copied!":"Copy cd path",children:(0,r.jsx)("button",{onClick:eC,className:"ml-0.5 shrink-0 cursor-pointer rounded-full p-1 text-muted-foreground hover:bg-background hover:text-foreground",children:el?(0,r.jsx)(Z.A,{className:"size-3 text-green-600"}):(0,r.jsx)(e1.A,{className:"size-3"})})})]}):C.defaultBranch?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted py-0.5 px-2.5 font-mono text-xs font-medium text-muted-foreground",children:[(0,r.jsx)(e0.A,{className:"size-3"}),C.defaultBranch]}):null,(es>0||en>0)&&(0,r.jsx)(eF.Y6,{label:"Toggle git panel",children:(0,r.jsxs)(u.$,{variant:"ghost",size:"sm",className:(0,o.cn)("gap-2 font-mono text-xs tabular-nums border border-transparent hover:border-border",P&&"border-primary hover:border-primary"),onClick:()=>F(e=>!e),children:[es>0&&(0,r.jsxs)("span",{className:"text-green-600",children:["+",es]}),en>0&&(0,r.jsxs)("span",{className:"text-red-600",children:["-",en]})]})}),(0,r.jsxs)("div",{className:"relative",children:[K&&"MERGED"===K.state?(0,r.jsxs)(u.$,{variant:"outline",size:"sm",className:"gap-1.5",disabled:!0,children:[(0,r.jsx)(Z.A,{className:"size-3.5 text-green-600"}),"Handed off"]}):K&&"CLOSED"===K.state?(0,r.jsxs)(u.$,{variant:"outline",size:"sm",className:"gap-1.5",disabled:!0,children:[(0,r.jsx)(eU.A,{className:"size-3.5 text-red-500"}),"PR Closed"]}):(0,r.jsx)(eF.Y6,{label:ej?"Commit and push to main":"Commit, push, create PR, merge, and clean up",children:(0,r.jsxs)(u.$,{variant:"outline",size:"sm",className:(0,o.cn)("gap-1.5 cursor-pointer",V?"border-green-200 bg-green-50 text-green-700 hover:bg-green-100":""),onClick:eA,disabled:!V||eo?.phase==="running"||eo?.phase==="awaiting_review",children:[eo?.phase==="running"||eo?.phase==="awaiting_review"?(0,r.jsx)(g.A,{className:"size-3.5 animate-spin"}):(0,r.jsx)(e5.A,{className:"size-3.5"}),"Hands!"]})}),ed&&eo&&(0,r.jsx)(e7,{steps:eo.steps,onRetry:"error"===eo.phase?eR:void 0,onCancel:"running"===eo.phase||"awaiting_review"===eo.phase?e$:void 0,cancelPending:eg,onClose:()=>{eu(!1),ec(null),ef(null),eh(null)},isComplete:"completed"===eo.phase,isError:"error"===eo.phase||"cancelled"===eo.phase}),eo?.phase==="awaiting_review"&&eo.reviewData&&(0,r.jsx)(tr,{open:!0,reviewData:eo.reviewData,truncated:eo.reviewTruncated,totalLines:eo.reviewTotalLines,attempt:eo.reviewAttempt,onApprove:eI,onCancel:eE,onResolveDifferently:eT,submittingAction:ex,submitError:ep,onCancelHandoff:e$,cancelHandoffPending:eg})]}),_?(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(u.$,{variant:"destructive",size:"sm",onClick:ek,children:"Confirm Delete"}),(0,r.jsx)(u.$,{variant:"ghost",size:"sm",onClick:()=>L(!1),children:"Cancel"})]}):(0,r.jsx)(eF.Y6,{label:"Delete task",children:(0,r.jsx)(u.$,{variant:"ghost",size:"icon",onClick:()=>L(!0),children:(0,r.jsx)(e2.A,{className:"size-4"})})})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 pb-3 pt-1",children:[(0,r.jsxs)(eX.rI,{children:[(0,r.jsx)(eX.ty,{asChild:!0,children:(0,r.jsxs)("button",{className:"flex cursor-pointer items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium hover:bg-muted/50",children:[eO&&(0,r.jsx)(eO,{className:"size-3.5 text-muted-foreground"}),(0,r.jsx)("span",{children:eD?.title||C.column}),(0,r.jsx)(m.A,{className:"size-3 text-muted-foreground"})]})}),(0,r.jsx)(eX.SQ,{align:"start",children:M.cZ.map(e=>{let t=M.G$[e.id];return(0,r.jsxs)(eX._2,{onClick:()=>ey(e.id),children:[t&&(0,r.jsx)(t,{className:"size-3.5 text-muted-foreground"}),e.title,e.id===C.column&&(0,r.jsx)(Z.A,{className:"ml-auto size-3"})]},e.id)})})]}),(0,r.jsxs)(eX.rI,{children:[(0,r.jsx)(eX.ty,{asChild:!0,children:(0,r.jsxs)("button",{className:"flex cursor-pointer items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium hover:bg-muted/50",children:[(0,r.jsx)(tn.w,{priority:C.priority}),(0,r.jsx)("span",{children:M.fz.find(e=>e.value===C.priority)?.label??"No priority"}),(0,r.jsx)(m.A,{className:"size-3 text-muted-foreground"})]})}),(0,r.jsx)(eX.SQ,{align:"start",children:M.fz.map(e=>(0,r.jsxs)(eX._2,{onClick:()=>ew(e.value),className:"cursor-pointer",children:[(0,r.jsx)(tn.w,{priority:e.value}),e.label,e.value===C.priority&&(0,r.jsx)(Z.A,{className:"ml-auto size-3"})]},e.value))})]}),(e=(0,M.eE)(C.status),(0,r.jsxs)("span",{className:`inline-flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs font-medium ${e.pillBgClass} ${e.pillTextClass}`,children:["running"===C.status?(0,r.jsx)(ta.x,{size:"sm"}):(0,r.jsx)("span",{className:`size-1.5 rounded-full ${e.dotClass}`}),e.label]})),(0,r.jsx)("div",{className:"flex-1"}),D&&(0,r.jsx)(eF.Y6,{label:"Needs tasting",children:(0,r.jsxs)(u.$,{variant:"outline",size:"sm",className:"gap-1.5",onClick:O,children:[(0,r.jsx)("span",{className:(0,o.cn)("text-[11px] font-semibold px-[7px] py-px rounded-full tabular-nums",(0,M.eE)("needs_tasting").pillBgClass,(0,M.eE)("needs_tasting").pillTextClass),children:D.total}),1===D.total?"Order needs tasting":"Orders need tasting",(0,r.jsx)(x.A,{className:"size-3.5"})]})})]})]}),(0,r.jsxs)("div",{className:"relative flex flex-1 overflow-hidden",children:[(0,r.jsx)("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:B?(0,r.jsx)(eV,{taskSlug:c,taskTitle:C.title,repoId:d,status:C.status,onTaskUpdated:z,autoStartContext:v||void 0,autoStartModel:N||void 0,autoStartImages:k,autoImproveTitle:w,prefetchedActiveChat:U}):(0,r.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,r.jsx)(e_._,{size:"lg"})})}),(0,r.jsxs)("div",{className:(0,o.cn)("absolute inset-y-0 right-0 z-20 flex w-[400px] max-w-[50vw] flex-col border-l border-border bg-background shadow-lg transition-transform duration-300 ease-in-out",P?"translate-x-0":"translate-x-full"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)(e0.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"truncate font-mono text-xs text-muted-foreground",children:C.branch??"main"}),C.worktree&&(0,r.jsx)("span",{className:"shrink-0 rounded bg-green-50 px-1.5 py-0.5 text-[10px] font-medium text-green-700",children:C.worktree.split("/").pop()})]}),(0,r.jsx)(u.$,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>F(!1),children:(0,r.jsx)(eU.A,{className:"size-4"})})]}),P&&(0,r.jsx)(A,{slug:c,repoId:d})]})]})]})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4541],{},_=>{_.O(0,[7133,3242,4555,3604,9798,878,1545,1719,1416,8441,3794,7358],()=>_(_.s=1416)),_N_E=_.O()}]);
|
package/.next/standalone/.next/static/chunks/app/(board)/r/[repoId]/board/page-2a12cb83a038bfa4.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4808],{},_=>{_.O(0,[7133,3242,4555,3604,9798,878,1545,1719,1416,8441,3794,7358],()=>_(_.s=1416)),_N_E=_.O()}]);
|
package/.next/standalone/.next/static/chunks/app/(board)/r/[repoId]/layout-94f90e6400c32897.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4864],{872:(e,t,r)=>{"use strict";r.d(t,{Bc:()=>s,Y6:()=>n}),r(5155);var a=r(2115);let s=r(5828).Kq;function n({label:e,side:t="top",align:r="center",delayDuration:s,sideOffset:n,children:o}){let i="string"==typeof e||"number"==typeof e?String(e):void 0,d=o.props??{};return a.cloneElement(o,{title:d.title??i,"aria-label":d["aria-label"]??i})}},2763:(e,t,r)=>{"use strict";r.d(t,{Cf:()=>c,Es:()=>p,L3:()=>f,c7:()=>u,lG:()=>i,rr:()=>h});var a=r(5155);r(2115);var s=r(9483),n=r(4268),o=r(6218);function i({...e}){return(0,a.jsx)(s.bL,{"data-slot":"dialog",...e})}function d({...e}){return(0,a.jsx)(s.ZL,{"data-slot":"dialog-portal",...e})}function l({className:e,...t}){return(0,a.jsx)(s.hJ,{"data-slot":"dialog-overlay",className:(0,o.cn)("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t})}function c({className:e,children:t,showCloseButton:r=!0,...i}){return(0,a.jsxs)(d,{"data-slot":"dialog-portal",children:[(0,a.jsx)(l,{}),(0,a.jsxs)(s.UC,{"data-slot":"dialog-content",className:(0,o.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:max-w-lg",e),...i,children:[t,r&&(0,a.jsxs)(s.bm,{"data-slot":"dialog-close",className:"focus:outline-hidden absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",children:[(0,a.jsx)(n.A,{}),(0,a.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function u({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"dialog-header",className:(0,o.cn)("flex flex-col gap-2 text-center sm:text-left",e),...t})}function p({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"dialog-footer",className:(0,o.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function f({className:e,...t}){return(0,a.jsx)(s.hE,{"data-slot":"dialog-title",className:(0,o.cn)("text-lg font-semibold leading-none",e),...t})}function h({className:e,...t}){return(0,a.jsx)(s.VY,{"data-slot":"dialog-description",className:(0,o.cn)("text-sm text-muted-foreground",e),...t})}},3612:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(8698).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},3827:(e,t,r)=>{Promise.resolve().then(r.bind(r,6896))},6218:(e,t,r)=>{"use strict";r.d(t,{cn:()=>n});var a=r(9722),s=r(622);function n(...e){return(0,s.QP)((0,a.$)(e))}},6896:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>h});var a=r(5155),s=r(2115),n=r(3321),o=r(9239),i=r(872),d=r(2763),l=r(6218),c=r(7241),u=r(3612);let p=(0,r(8698).A)("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);function f({repoId:e}){let t=(0,n.useRouter)(),r=(0,n.usePathname)(),[f,h]=(0,s.useState)([]),[x,m]=(0,s.useState)(!0),[g,b]=(0,s.useState)(!1),[v,y]=(0,s.useState)(!1),[j,w]=(0,s.useState)(null),[k,N]=(0,s.useState)(null),C=(0,s.useMemo)(()=>async()=>{try{let e=await fetch("/api/repos");if(!e.ok)return;let t=await e.json();h(Array.isArray(t.repos)?t.repos:[])}finally{m(!1)}},[]);(0,s.useEffect)(()=>{C()},[C]),(0,s.useEffect)(()=>{e&&fetch("/api/repos/last-used",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({repoId:e})}).catch(()=>{})},[e]);let $=async r=>{r!==e&&(await fetch("/api/repos/last-used",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({repoId:r})}).catch(()=>{}),t.push(`/r/${encodeURIComponent(r)}/board`))},z=async()=>{w(null),y(!0);try{let e=await fetch("/api/repos/pick-folder",{method:"POST"}),r=await e.json().catch(()=>({}));if(!e.ok)return void w(r.error||"Unable to open folder picker.");if(r.canceled||!r.path)return;let a=await fetch("/api/repos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r.path})}),s=await a.json().catch(()=>({}));if(!a.ok)return void w(s.error||"Failed to add kitchen.");await C(),N(s.repo??null),s.repo?.id&&(b(!1),t.push(`/r/${encodeURIComponent(s.repo.id)}/board`))}catch{w("Failed to add kitchen.")}finally{y(!1)}},S=async r=>{if(!window.confirm("Remove this kitchen from Brigade?"))return;let a=await fetch(`/api/repos/${encodeURIComponent(r)}`,{method:"DELETE"});if(!a.ok){let e=await a.json().catch(()=>({error:"Failed to remove kitchen."}));window.alert(e.error||"Failed to remove kitchen.");return}if(await C(),r===e){let e=f.find(e=>e.id!==r);e?t.push(`/r/${encodeURIComponent(e.id)}/board`):t.push("/board")}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("aside",{className:"fixed left-0 top-0 z-30 hidden h-screen w-[88px] border-r border-border bg-background/95 px-2 py-0 backdrop-blur md:flex md:flex-col",children:[(0,a.jsx)("div",{className:"flex h-[53px] items-center justify-center",children:(0,a.jsx)("span",{className:"translate-y-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Kitchens"})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto pr-0.5",children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-2 pt-4 pb-2",children:[x&&(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"..."}),!x&&0===f.length&&(0,a.jsx)("p",{className:"px-1 text-center text-[11px] text-muted-foreground",children:"No kitchens"}),f.map(t=>{let s=t.id===e||r.startsWith(`/r/${t.id}/`);return(0,a.jsxs)("div",{className:"group relative",children:[(0,a.jsx)(i.Y6,{label:`${t.name} — ${t.path}`,children:(0,a.jsx)("button",{type:"button",onClick:()=>$(t.id),className:(0,l.cn)("flex size-14 items-center justify-center rounded-xl border text-sm font-semibold transition",s?"border-primary bg-primary/15 text-foreground shadow-xs":"border-border bg-card text-muted-foreground hover:bg-accent hover:text-foreground"),title:`${t.name} — ${t.path}`,children:function(e){let t=e.trim();if(!t)return"R";let r=t.split(/[\s_-]+/).filter(Boolean);return 1===r.length?r[0].slice(0,2).toUpperCase():`${r[0][0]}${r[1][0]}`.toUpperCase()}(t.name)})}),(0,a.jsx)(i.Y6,{label:`Remove kitchen ${t.name}`,children:(0,a.jsx)("button",{type:"button",onClick:()=>S(t.id),className:"absolute -right-1 -top-1 rounded-full border border-border bg-background p-1 text-muted-foreground opacity-0 shadow-xs transition hover:bg-accent hover:text-foreground group-hover:opacity-100",children:(0,a.jsx)(c.A,{className:"size-3"})})}),(0,a.jsx)("p",{className:"mt-1 max-w-14 truncate text-center text-[10px] text-muted-foreground",title:t.name,children:t.name})]},t.id)}),(0,a.jsx)("div",{className:"mt-3 flex justify-center",children:(0,a.jsx)(i.Y6,{label:"Add kitchen",children:(0,a.jsx)(o.$,{variant:"outline",size:"icon",className:"size-14 rounded-xl border-2 border-primary/50",onClick:()=>{w(null),N(null),b(!0)},children:(0,a.jsx)(u.A,{className:"size-6"})})})})]})})]}),(0,a.jsx)(d.lG,{open:g,onOpenChange:b,children:(0,a.jsxs)(d.Cf,{className:"sm:max-w-md",children:[(0,a.jsxs)(d.c7,{children:[(0,a.jsx)(d.L3,{children:"Add Kitchen"}),(0,a.jsx)(d.rr,{children:"Pick a local folder to add to Brigade."})]}),(0,a.jsxs)("div",{className:"rounded-xl border-2 border-dashed border-primary/40 bg-primary/5 p-6 text-center",children:[(0,a.jsx)(p,{className:"mx-auto mb-2 size-8 text-primary"}),(0,a.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Select a folder"}),(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Pick any local folder"}),(0,a.jsx)(o.$,{type:"button",variant:"outline",className:"mt-4",onClick:z,disabled:v,children:v?"Adding...":"Select folder"})]}),k&&(0,a.jsxs)("div",{className:"rounded-lg border border-primary/30 bg-primary/5 px-3 py-2",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-foreground",children:k.name}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:k.path})]}),j&&(0,a.jsx)("p",{className:"text-sm text-destructive",children:j}),(0,a.jsx)(d.Es,{children:(0,a.jsx)(o.$,{type:"button",variant:"ghost",onClick:()=>b(!1),disabled:v,children:"Cancel"})})]})})]})}function h({children:e}){let t=(0,n.useParams)(),r="string"==typeof t.repoId?t.repoId:void 0;return(0,s.useEffect)(()=>{if(!r)return;let e=window.fetch.bind(window),t=e=>!r||e.startsWith(`/api/repos/${encodeURIComponent(r)}`)?e:e.startsWith("/api/tasks")||e.startsWith("/api/chat")?`/api/repos/${encodeURIComponent(r)}${e.slice(4)}`:e;return window.fetch=(r,a)=>{if("string"==typeof r)return e(t(r),a);if(r instanceof URL){let s=r.toString(),n=window.location.origin;if(s.startsWith(n)){let r=s.slice(n.length),o=t(r);if(o!==r)return e(`${n}${o}`,a)}return e(r,a)}if(r instanceof Request){let s=r.url,n=window.location.origin;if(s.startsWith(n)){let o=s.slice(n.length),i=t(o);if(i!==o)return e(new Request(`${n}${i}`,r),a)}}return e(r,a)},()=>{window.fetch=e}},[r]),(0,a.jsxs)("div",{className:"min-h-screen md:pl-[88px]",children:[(0,a.jsx)(f,{repoId:r}),e]})}},9239:(e,t,r)=>{"use strict";r.d(t,{$:()=>d,r:()=>i});var a=r(5155);r(2115);var s=r(2442),n=r(8460),o=r(6218);let i=(0,n.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all cursor-pointer disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function d({className:e,variant:t,size:r,asChild:n=!1,type:d,...l}){let c=n?s.DX:"button";return(0,a.jsx)(c,{"data-slot":"button",className:(0,o.cn)(i({variant:t,size:r,className:e})),...!n?{type:d??"button"}:{},...l})}}},e=>{e.O(0,[7133,3242,4555,8441,3794,7358],()=>e(e.s=3827)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2395],{4322:(e,s,_)=>{Promise.resolve().then(_.bind(_,5083))}},e=>{e.O(0,[7133,
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2395],{4322:(e,s,_)=>{Promise.resolve().then(_.bind(_,5083))}},e=>{e.O(0,[7133,3242,4555,3604,9798,124,1545,1719,5083,8441,3794,7358],()=>e(e.s=4322)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3782],{779:(e,s,_)=>{Promise.resolve().then(_.bind(_,5083))}},e=>{e.O(0,[7133,
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3782],{779:(e,s,_)=>{Promise.resolve().then(_.bind(_,5083))}},e=>{e.O(0,[7133,3242,4555,3604,9798,124,1545,1719,5083,8441,3794,7358],()=>e(e.s=779)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[276,909,1525,1527,1672,2012,2451,2818,2996,3574,3606,4074,4134,4452,4504,4896,4976,5329,5418,5645,5809,5833,5880,6456,6546,6668,6819,6988,7328,7577,7851,7908,8057,8167,8243,8324,8348,8355,8440,8677,8914,9776,9823],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[276,909,1525,1527,1672,2012,2451,2818,2996,3574,3606,4074,4134,4452,4504,4896,4976,5329,5418,5645,5809,5833,5880,6456,6546,6668,6819,6988,7328,7577,7851,7908,8057,8167,8243,8324,8348,8355,8440,8677,8914,8974,9776,9823],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
|