@seqyuan/annodex 0.1.10 → 0.1.12
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/app/api/agent/[id]/events/route.ts +94 -0
- package/app/api/agent/[id]/route.ts +83 -0
- package/app/api/agent/new/route.ts +53 -0
- package/app/api/auth/all-providers/route.ts +21 -0
- package/app/api/auth/api-key/[provider]/route.ts +7 -0
- package/app/api/auth/login/[provider]/route.ts +7 -0
- package/app/api/auth/login/route.ts +22 -0
- package/app/api/auth/logout/[provider]/route.ts +7 -0
- package/app/api/auth/providers/route.ts +15 -0
- package/app/api/auth/status/route.ts +6 -0
- package/app/api/default-cwd/route.ts +22 -0
- package/app/api/files/[...path]/route.ts +621 -0
- package/app/api/harness/route.ts +47 -0
- package/app/api/home/route.ts +6 -0
- package/app/api/internal/runtime/route.ts +26 -0
- package/app/api/models/route.ts +67 -0
- package/app/api/models-config/discover/route.ts +42 -0
- package/app/api/models-config/route.ts +152 -0
- package/app/api/models-config/test/route.ts +154 -0
- package/app/api/projects/browse/route.ts +51 -0
- package/app/api/projects/route.ts +83 -0
- package/app/api/reports/[id]/route.ts +108 -0
- package/app/api/search/route.ts +122 -0
- package/app/api/sessions/[id]/context/route.ts +23 -0
- package/app/api/sessions/[id]/route.ts +124 -0
- package/app/api/sessions/new/route.ts +5 -0
- package/app/api/sessions/route.ts +16 -0
- package/app/api/settings/route.ts +51 -0
- package/app/api/skills/install/route.ts +249 -0
- package/app/api/skills/route.ts +161 -0
- package/app/api/skills/search/route.ts +121 -0
- package/app/api/soul/route.ts +47 -0
- package/app/api/version/route.ts +55 -0
- package/app/globals.css +736 -0
- package/app/layout.tsx +40 -0
- package/app/login/page.tsx +133 -0
- package/app/page.tsx +10 -0
- package/components/AppShell.tsx +1058 -0
- package/components/ChatInput.tsx +1103 -0
- package/components/ChatMinimap.tsx +381 -0
- package/components/ChatWindow.tsx +576 -0
- package/components/CodeMirrorEditor.tsx +137 -0
- package/components/ConversationSearch.tsx +369 -0
- package/components/DataTableViewer.tsx +248 -0
- package/components/FileExplorer.tsx +758 -0
- package/components/FileIcons.tsx +241 -0
- package/components/FileViewer.tsx +1273 -0
- package/components/GlobalFileEditor.tsx +98 -0
- package/components/MarkdownRenderer.tsx +331 -0
- package/components/MermaidDiagram.tsx +80 -0
- package/components/MessageView.tsx +1141 -0
- package/components/ModelsConfig.tsx +1991 -0
- package/components/ProjectContext.tsx +252 -0
- package/components/ProjectFolderPicker.tsx +202 -0
- package/components/ProjectsConfig.tsx +288 -0
- package/components/ProviderIcons.tsx +91 -0
- package/components/ReportPanel.tsx +237 -0
- package/components/ResizeHandle.tsx +105 -0
- package/components/SessionSidebar.tsx +1464 -0
- package/components/SettingsDialog.tsx +287 -0
- package/components/SkillsConfig.tsx +1093 -0
- package/components/SubagentPanel.tsx +191 -0
- package/components/TabBar.tsx +115 -0
- package/components/ToolPanel.tsx +131 -0
- package/components/WidgetRenderer.tsx +505 -0
- package/components/viewers/DocumentToolbar.tsx +78 -0
- package/components/viewers/DocxViewer.tsx +97 -0
- package/components/viewers/PdfViewer.tsx +206 -0
- package/components/viewers/PptxViewer.tsx +240 -0
- package/components/viewers/XlsxViewer.tsx +143 -0
- package/hooks/useAgentSession.ts +710 -0
- package/hooks/useAudio.ts +50 -0
- package/hooks/useDragDrop.ts +52 -0
- package/hooks/useResizable.ts +60 -0
- package/hooks/useTheme.ts +85 -0
- package/lib/agent-client.ts +39 -0
- package/lib/annodex-config.ts +556 -0
- package/lib/auth-token.ts +74 -0
- package/lib/auth.ts +90 -0
- package/lib/brand.ts +5 -0
- package/lib/code-theme.ts +32 -0
- package/lib/codex-compat-proxy.ts +1603 -0
- package/lib/codex-home.ts +6 -0
- package/lib/codex-server.ts +796 -0
- package/lib/codex-session.ts +590 -0
- package/lib/codex-usage.ts +213 -0
- package/lib/file-paths.ts +34 -0
- package/lib/model-discovery.ts +379 -0
- package/lib/normalize.ts +30 -0
- package/lib/npx.ts +87 -0
- package/lib/pi-types.ts +49 -0
- package/lib/projects.ts +269 -0
- package/lib/provider-api.ts +88 -0
- package/lib/report-prompt.ts +61 -0
- package/lib/report-store.ts +597 -0
- package/lib/report-update-parser.ts +66 -0
- package/lib/rpc-manager.ts +668 -0
- package/lib/runtime-state.ts +117 -0
- package/lib/session-reader.ts +903 -0
- package/lib/session-runtime.ts +105 -0
- package/lib/subagent-progress.ts +279 -0
- package/lib/types.ts +241 -0
- package/lib/widget-export.ts +318 -0
- package/lib/widget-guidelines.ts +288 -0
- package/lib/widget-prompt.ts +76 -0
- package/lib/widget-utils.ts +523 -0
- package/package.json +23 -18
- package/postcss.config.mjs +8 -0
- package/proxy.ts +64 -0
- package/scripts/postinstall.cjs +25 -0
- package/tsconfig.json +41 -0
- package/.next/BUILD_ID +0 -1
- package/.next/app-path-routes-manifest.json +0 -39
- package/.next/build-manifest.json +0 -20
- package/.next/diagnostics/build-diagnostics.json +0 -6
- package/.next/diagnostics/framework.json +0 -1
- package/.next/export-marker.json +0 -6
- package/.next/images-manifest.json +0 -68
- package/.next/next-minimal-server.js.nft.json +0 -1
- package/.next/next-server.js.nft.json +0 -1
- package/.next/package.json +0 -1
- package/.next/prerender-manifest.json +0 -109
- package/.next/react-loadable-manifest.json +0 -2320
- package/.next/required-server-files.js +0 -343
- package/.next/required-server-files.json +0 -343
- package/.next/routes-manifest.json +0 -286
- package/.next/server/app/_global-error/page.js +0 -32
- package/.next/server/app/_global-error/page.js.nft.json +0 -1
- package/.next/server/app/_global-error/page_client-reference-manifest.js +0 -1
- package/.next/server/app/_global-error.html +0 -1
- package/.next/server/app/_global-error.meta +0 -16
- package/.next/server/app/_global-error.rsc +0 -14
- package/.next/server/app/_global-error.segments/_full.segment.rsc +0 -14
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +0 -5
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +0 -5
- package/.next/server/app/_global-error.segments/_head.segment.rsc +0 -5
- package/.next/server/app/_global-error.segments/_index.segment.rsc +0 -5
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +0 -1
- package/.next/server/app/_not-found/page.js +0 -2
- package/.next/server/app/_not-found/page.js.nft.json +0 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +0 -1
- package/.next/server/app/_not-found.html +0 -1
- package/.next/server/app/_not-found.meta +0 -16
- package/.next/server/app/_not-found.rsc +0 -18
- package/.next/server/app/_not-found.segments/_full.segment.rsc +0 -18
- package/.next/server/app/_not-found.segments/_head.segment.rsc +0 -6
- package/.next/server/app/_not-found.segments/_index.segment.rsc +0 -5
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +0 -5
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +0 -5
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +0 -4
- package/.next/server/app/api/agent/[id]/events/route.js +0 -3
- package/.next/server/app/api/agent/[id]/events/route.js.nft.json +0 -1
- package/.next/server/app/api/agent/[id]/events/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/agent/[id]/route.js +0 -1
- package/.next/server/app/api/agent/[id]/route.js.nft.json +0 -1
- package/.next/server/app/api/agent/[id]/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/agent/new/route.js +0 -1
- package/.next/server/app/api/agent/new/route.js.nft.json +0 -1
- package/.next/server/app/api/agent/new/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/auth/all-providers/route.js +0 -1
- package/.next/server/app/api/auth/all-providers/route.js.nft.json +0 -1
- package/.next/server/app/api/auth/all-providers/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/auth/api-key/[provider]/route.js +0 -1
- package/.next/server/app/api/auth/api-key/[provider]/route.js.nft.json +0 -1
- package/.next/server/app/api/auth/api-key/[provider]/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/auth/login/[provider]/route.js +0 -1
- package/.next/server/app/api/auth/login/[provider]/route.js.nft.json +0 -1
- package/.next/server/app/api/auth/login/[provider]/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/auth/login/route.js +0 -1
- package/.next/server/app/api/auth/login/route.js.nft.json +0 -1
- package/.next/server/app/api/auth/login/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/auth/logout/[provider]/route.js +0 -1
- package/.next/server/app/api/auth/logout/[provider]/route.js.nft.json +0 -1
- package/.next/server/app/api/auth/logout/[provider]/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/auth/providers/route.js +0 -1
- package/.next/server/app/api/auth/providers/route.js.nft.json +0 -1
- package/.next/server/app/api/auth/providers/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/auth/status/route.js +0 -1
- package/.next/server/app/api/auth/status/route.js.nft.json +0 -1
- package/.next/server/app/api/auth/status/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/default-cwd/route.js +0 -1
- package/.next/server/app/api/default-cwd/route.js.nft.json +0 -1
- package/.next/server/app/api/default-cwd/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/files/[...path]/route.js +0 -4
- package/.next/server/app/api/files/[...path]/route.js.nft.json +0 -1
- package/.next/server/app/api/files/[...path]/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/harness/route.js +0 -1
- package/.next/server/app/api/harness/route.js.nft.json +0 -1
- package/.next/server/app/api/harness/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/home/route.js +0 -1
- package/.next/server/app/api/home/route.js.nft.json +0 -1
- package/.next/server/app/api/home/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/internal/runtime/route.js +0 -1
- package/.next/server/app/api/internal/runtime/route.js.nft.json +0 -1
- package/.next/server/app/api/internal/runtime/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/models/route.js +0 -1
- package/.next/server/app/api/models/route.js.nft.json +0 -1
- package/.next/server/app/api/models/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/models-config/discover/route.js +0 -1
- package/.next/server/app/api/models-config/discover/route.js.nft.json +0 -1
- package/.next/server/app/api/models-config/discover/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/models-config/route.js +0 -1
- package/.next/server/app/api/models-config/route.js.nft.json +0 -1
- package/.next/server/app/api/models-config/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/models-config/test/route.js +0 -1
- package/.next/server/app/api/models-config/test/route.js.nft.json +0 -1
- package/.next/server/app/api/models-config/test/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/projects/browse/route.js +0 -1
- package/.next/server/app/api/projects/browse/route.js.nft.json +0 -1
- package/.next/server/app/api/projects/browse/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/projects/route.js +0 -1
- package/.next/server/app/api/projects/route.js.nft.json +0 -1
- package/.next/server/app/api/projects/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/reports/[id]/route.js +0 -10
- package/.next/server/app/api/reports/[id]/route.js.nft.json +0 -1
- package/.next/server/app/api/reports/[id]/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/search/route.js +0 -1
- package/.next/server/app/api/search/route.js.nft.json +0 -1
- package/.next/server/app/api/search/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/sessions/[id]/context/route.js +0 -1
- package/.next/server/app/api/sessions/[id]/context/route.js.nft.json +0 -1
- package/.next/server/app/api/sessions/[id]/context/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/sessions/[id]/route.js +0 -1
- package/.next/server/app/api/sessions/[id]/route.js.nft.json +0 -1
- package/.next/server/app/api/sessions/[id]/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/sessions/new/route.js +0 -1
- package/.next/server/app/api/sessions/new/route.js.nft.json +0 -1
- package/.next/server/app/api/sessions/new/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/sessions/route.js +0 -1
- package/.next/server/app/api/sessions/route.js.nft.json +0 -1
- package/.next/server/app/api/sessions/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/settings/route.js +0 -1
- package/.next/server/app/api/settings/route.js.nft.json +0 -1
- package/.next/server/app/api/settings/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/skills/install/route.js +0 -5
- package/.next/server/app/api/skills/install/route.js.nft.json +0 -1
- package/.next/server/app/api/skills/install/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/skills/route.js +0 -6
- package/.next/server/app/api/skills/route.js.nft.json +0 -1
- package/.next/server/app/api/skills/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/skills/search/route.js +0 -1
- package/.next/server/app/api/skills/search/route.js.nft.json +0 -1
- package/.next/server/app/api/skills/search/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/soul/route.js +0 -1
- package/.next/server/app/api/soul/route.js.nft.json +0 -1
- package/.next/server/app/api/soul/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/version/route.js +0 -1
- package/.next/server/app/api/version/route.js.nft.json +0 -1
- package/.next/server/app/api/version/route_client-reference-manifest.js +0 -1
- package/.next/server/app/index.html +0 -1
- package/.next/server/app/index.meta +0 -14
- package/.next/server/app/index.rsc +0 -17
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +0 -6
- package/.next/server/app/index.segments/_full.segment.rsc +0 -17
- package/.next/server/app/index.segments/_head.segment.rsc +0 -6
- package/.next/server/app/index.segments/_index.segment.rsc +0 -5
- package/.next/server/app/index.segments/_tree.segment.rsc +0 -4
- package/.next/server/app/login/page.js +0 -2
- package/.next/server/app/login/page.js.nft.json +0 -1
- package/.next/server/app/login/page_client-reference-manifest.js +0 -1
- package/.next/server/app/login.html +0 -1
- package/.next/server/app/login.meta +0 -15
- package/.next/server/app/login.rsc +0 -22
- package/.next/server/app/login.segments/_full.segment.rsc +0 -22
- package/.next/server/app/login.segments/_head.segment.rsc +0 -6
- package/.next/server/app/login.segments/_index.segment.rsc +0 -5
- package/.next/server/app/login.segments/_tree.segment.rsc +0 -4
- package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +0 -9
- package/.next/server/app/login.segments/login.segment.rsc +0 -5
- package/.next/server/app/page.js +0 -261
- package/.next/server/app/page.js.nft.json +0 -1
- package/.next/server/app/page_client-reference-manifest.js +0 -1
- package/.next/server/app-paths-manifest.json +0 -39
- package/.next/server/chunks/1048.js +0 -1
- package/.next/server/chunks/1367.js +0 -77
- package/.next/server/chunks/1381.js +0 -1
- package/.next/server/chunks/165.js +0 -1
- package/.next/server/chunks/1681.js +0 -215
- package/.next/server/chunks/1688.js +0 -45
- package/.next/server/chunks/1703.js +0 -79
- package/.next/server/chunks/1712.js +0 -43
- package/.next/server/chunks/1813.js +0 -1
- package/.next/server/chunks/2325.js +0 -80
- package/.next/server/chunks/258.js +0 -1
- package/.next/server/chunks/2671.js +0 -287
- package/.next/server/chunks/2778.js +0 -1
- package/.next/server/chunks/2943.js +0 -1
- package/.next/server/chunks/3031.js +0 -226
- package/.next/server/chunks/3181.js +0 -1
- package/.next/server/chunks/3493.js +0 -1
- package/.next/server/chunks/3672.js +0 -1
- package/.next/server/chunks/3701.js +0 -104
- package/.next/server/chunks/4013.js +0 -1
- package/.next/server/chunks/402.js +0 -2
- package/.next/server/chunks/4035.js +0 -80
- package/.next/server/chunks/4248.js +0 -153
- package/.next/server/chunks/4367.js +0 -1
- package/.next/server/chunks/4406.js +0 -141
- package/.next/server/chunks/4741.js +0 -18
- package/.next/server/chunks/4768.js +0 -1
- package/.next/server/chunks/4858.js +0 -148
- package/.next/server/chunks/4980.js +0 -1
- package/.next/server/chunks/5155.js +0 -5
- package/.next/server/chunks/5293.js +0 -166
- package/.next/server/chunks/5399.js +0 -8
- package/.next/server/chunks/5409.js +0 -1
- package/.next/server/chunks/5797.js +0 -93
- package/.next/server/chunks/5851.js +0 -36
- package/.next/server/chunks/6206.js +0 -1
- package/.next/server/chunks/6296.js +0 -1
- package/.next/server/chunks/63.js +0 -45
- package/.next/server/chunks/6346.js +0 -1
- package/.next/server/chunks/6406.js +0 -23
- package/.next/server/chunks/642.js +0 -1
- package/.next/server/chunks/6429.js +0 -50
- package/.next/server/chunks/6729.js +0 -64
- package/.next/server/chunks/6907.js +0 -115
- package/.next/server/chunks/6980.js +0 -1
- package/.next/server/chunks/7073.js +0 -24
- package/.next/server/chunks/7233.js +0 -24
- package/.next/server/chunks/7307.js +0 -1
- package/.next/server/chunks/7362.js +0 -9
- package/.next/server/chunks/7567.js +0 -29
- package/.next/server/chunks/7765.js +0 -1
- package/.next/server/chunks/7890.js +0 -1
- package/.next/server/chunks/8065.js +0 -1
- package/.next/server/chunks/8238.js +0 -34
- package/.next/server/chunks/8276.js +0 -1
- package/.next/server/chunks/8336.js +0 -1
- package/.next/server/chunks/8477.js +0 -3
- package/.next/server/chunks/8490.js +0 -1
- package/.next/server/chunks/8916.js +0 -1
- package/.next/server/chunks/9280.js +0 -252
- package/.next/server/chunks/9315.js +0 -1
- package/.next/server/chunks/9537.js +0 -90
- package/.next/server/chunks/966.js +0 -1
- package/.next/server/chunks/9818.js +0 -21
- package/.next/server/chunks/static/media/pdf.worker.min.c476e1a0.mjs +0 -6
- package/.next/server/functions-config-manifest.json +0 -16
- package/.next/server/interception-route-rewrite-manifest.js +0 -1
- package/.next/server/middleware-build-manifest.js +0 -1
- package/.next/server/middleware-manifest.json +0 -6
- package/.next/server/middleware-react-loadable-manifest.js +0 -1
- package/.next/server/middleware.js +0 -18
- package/.next/server/middleware.js.nft.json +0 -1
- package/.next/server/next-font-manifest.js +0 -1
- package/.next/server/next-font-manifest.json +0 -1
- package/.next/server/pages/404.html +0 -1
- package/.next/server/pages/500.html +0 -1
- package/.next/server/pages-manifest.json +0 -4
- package/.next/server/prefetch-hints.json +0 -1
- package/.next/server/server-reference-manifest.js +0 -1
- package/.next/server/server-reference-manifest.json +0 -1
- package/.next/server/webpack-runtime.js +0 -1
- package/.next/static/6cuMSvcr0FVO-GiK5RJZh/_buildManifest.js +0 -1
- package/.next/static/6cuMSvcr0FVO-GiK5RJZh/_ssgManifest.js +0 -1
- package/.next/static/chunks/0b9a0da7.9075af772487e743.js +0 -62
- package/.next/static/chunks/1413.922d232de90c0c41.js +0 -115
- package/.next/static/chunks/1643.467a526a1f24f54d.js +0 -24
- package/.next/static/chunks/1852.5543122f11aa7fed.js +0 -1
- package/.next/static/chunks/1960.b1e26436d7a5f586.js +0 -1
- package/.next/static/chunks/2170a4aa.4213bb2183c9cdf9.js +0 -1
- package/.next/static/chunks/2274.6cd173f80a1405a2.js +0 -21
- package/.next/static/chunks/2419.347fdfe3c170854d.js +0 -166
- package/.next/static/chunks/2619.9aac8983f30c7c8a.js +0 -1
- package/.next/static/chunks/2623.d20fabd8e18197c6.js +0 -287
- package/.next/static/chunks/2729.f5365061a849d659.js +0 -34
- package/.next/static/chunks/2821.934bcf60fbdc28c6.js +0 -1
- package/.next/static/chunks/2918becc.abff2ece1de37bc1.js +0 -153
- package/.next/static/chunks/2947.114e51cb06d1c01a.js +0 -23
- package/.next/static/chunks/3079.4c511fa1144e3adf.js +0 -79
- package/.next/static/chunks/3274.208ca44844cd7d95.js +0 -148
- package/.next/static/chunks/3308.465a94263d04bfea.js +0 -73
- package/.next/static/chunks/3325.e4bfe1ca657f3b5b.js +0 -80
- package/.next/static/chunks/3506.2a7eaa08b9f55337.js +0 -90
- package/.next/static/chunks/363642f4-043c1475ab9af70e.js +0 -1
- package/.next/static/chunks/3794-123fdf632563f469.js +0 -32
- package/.next/static/chunks/3837.a755ccfe6f9c1c1c.js +0 -5
- package/.next/static/chunks/394.91597771688df6d0.js +0 -1
- package/.next/static/chunks/3997.1009c06025691712.js +0 -1
- package/.next/static/chunks/4453.91a357dc43c21745.js +0 -1
- package/.next/static/chunks/4491.44fdf20580ac72bd.js +0 -24
- package/.next/static/chunks/4829.cf1d50e43e6d9db5.js +0 -1
- package/.next/static/chunks/498.fe1d9da9ecad6c36.js +0 -1
- package/.next/static/chunks/4bd1b696-e356ca5ba0218e27.js +0 -1
- package/.next/static/chunks/5019.b5a1a2b8daf17525.js +0 -1
- package/.next/static/chunks/5034.8f16c3fa3ce75411.js +0 -1
- package/.next/static/chunks/5074.d16651da01ec4e02.js +0 -1
- package/.next/static/chunks/51fb665c.0950e1b79671348d.js +0 -45
- package/.next/static/chunks/532.5956ed631aff722b.js +0 -9
- package/.next/static/chunks/5326.69460442bdcd6cd3.js +0 -1
- package/.next/static/chunks/5403.ff110bf5bf600758.js +0 -64
- package/.next/static/chunks/547.902a733488cfe3f7.js +0 -77
- package/.next/static/chunks/5567.540d7fc108ad6ee5.js +0 -215
- package/.next/static/chunks/5590.ef62922166d308b4.js +0 -1
- package/.next/static/chunks/5690.9d6eb1edb1399995.js +0 -1
- package/.next/static/chunks/5749.25faee4a1e55b854.js +0 -226
- package/.next/static/chunks/58bb9007.1ccb6bba34b4c635.js +0 -80
- package/.next/static/chunks/6121.f3f43f1896ea0cd9.js +0 -1
- package/.next/static/chunks/6600.583c88eef37aa524.js +0 -1
- package/.next/static/chunks/6696.a41aec266e657d54.js +0 -141
- package/.next/static/chunks/6922.42148793782d2fe7.js +0 -1
- package/.next/static/chunks/7006.e191611ffc2b9528.js +0 -43
- package/.next/static/chunks/7343.9fbb58204d8ac681.js +0 -1
- package/.next/static/chunks/73972abe.25a4cffa03b2bcef.js +0 -119
- package/.next/static/chunks/7547.58bda8a2aabba0d4.js +0 -93
- package/.next/static/chunks/7648.4ae2f183b4db0353.js +0 -1
- package/.next/static/chunks/7874.8db6929b94cdf697.js +0 -1
- package/.next/static/chunks/7959.1f20a35df316216a.js +0 -104
- package/.next/static/chunks/83.85d62d7fc9850b75.js +0 -29
- package/.next/static/chunks/8436.cab94b59cca0a8ff.js +0 -1
- package/.next/static/chunks/8451.ff6ff72b57dc52e1.js +0 -1
- package/.next/static/chunks/8489.45f22859734f514f.js +0 -36
- package/.next/static/chunks/8568.f85d8b36fc9a9037.js +0 -1
- package/.next/static/chunks/8771-3e14b6810486df1f.js +0 -1
- package/.next/static/chunks/8863.be51033a67436277.js +0 -1
- package/.next/static/chunks/90542734.dc1a2723e4f6affb.js +0 -1
- package/.next/static/chunks/9500.1488aec06ee78127.js +0 -1
- package/.next/static/chunks/9633.155548b5fca6e580.js +0 -1
- package/.next/static/chunks/9779.673004a62d70e36a.js +0 -1
- package/.next/static/chunks/app/_global-error/page-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/_not-found/page-c72daab99269beff.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/events/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/agent/new/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/auth/all-providers/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/auth/api-key/[provider]/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/auth/login/[provider]/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/auth/login/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/auth/logout/[provider]/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/auth/providers/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/auth/status/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/default-cwd/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/files/[...path]/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/harness/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/home/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/internal/runtime/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/models/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/models-config/discover/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/models-config/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/models-config/test/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/projects/browse/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/projects/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/reports/[id]/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/search/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/context/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/sessions/new/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/sessions/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/settings/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/skills/install/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/skills/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/skills/search/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/soul/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/version/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/layout-be148b7ae915b22a.js +0 -1
- package/.next/static/chunks/app/login/page-ebf0e6de99062783.js +0 -1
- package/.next/static/chunks/app/page-c45d98ea81c548ca.js +0 -260
- package/.next/static/chunks/d3ac728e.7964f816a1ca64e5.js +0 -1
- package/.next/static/chunks/framework-711ef29bc66f648c.js +0 -1
- package/.next/static/chunks/main-app-45a0f19af99d61b6.js +0 -1
- package/.next/static/chunks/main-f74964b7ae52493e.js +0 -5
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/global-error-9bfa08b9491621f2.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
- package/.next/static/chunks/webpack-fcf4a889ecbd753c.js +0 -1
- package/.next/static/css/45029451a1d7255d.css +0 -3
- package/.next/static/media/15605e25b523335c-s.woff2 +0 -0
- package/.next/static/media/1a3dce5cfb5f7760-s.woff2 +0 -0
- package/.next/static/media/1cdd02902f937a18-s.woff2 +0 -0
- package/.next/static/media/4c4b3b30b6bcb2be-s.woff2 +0 -0
- package/.next/static/media/641a7b8a5800ee0e-s.woff2 +0 -0
- package/.next/static/media/7deddc85b7ffd1dc-s.p.woff2 +0 -0
- package/.next/static/media/ec14413c594b3356-s.p.woff2 +0 -0
- package/.next/static/media/pdf.worker.min.29aaf158.mjs +0 -6
- package/.next/trace +0 -74
- package/.next/trace-build +0 -1
- package/.next/types/app/api/agent/[id]/events/route.ts +0 -351
- package/.next/types/app/api/agent/[id]/route.ts +0 -351
- package/.next/types/app/api/agent/new/route.ts +0 -351
- package/.next/types/app/api/auth/all-providers/route.ts +0 -351
- package/.next/types/app/api/auth/api-key/[provider]/route.ts +0 -351
- package/.next/types/app/api/auth/login/[provider]/route.ts +0 -351
- package/.next/types/app/api/auth/login/route.ts +0 -351
- package/.next/types/app/api/auth/logout/[provider]/route.ts +0 -351
- package/.next/types/app/api/auth/providers/route.ts +0 -351
- package/.next/types/app/api/auth/status/route.ts +0 -351
- package/.next/types/app/api/default-cwd/route.ts +0 -351
- package/.next/types/app/api/files/[...path]/route.ts +0 -351
- package/.next/types/app/api/harness/route.ts +0 -351
- package/.next/types/app/api/home/route.ts +0 -351
- package/.next/types/app/api/internal/runtime/route.ts +0 -351
- package/.next/types/app/api/models/route.ts +0 -351
- package/.next/types/app/api/models-config/discover/route.ts +0 -351
- package/.next/types/app/api/models-config/route.ts +0 -351
- package/.next/types/app/api/models-config/test/route.ts +0 -351
- package/.next/types/app/api/projects/browse/route.ts +0 -351
- package/.next/types/app/api/projects/route.ts +0 -351
- package/.next/types/app/api/reports/[id]/route.ts +0 -351
- package/.next/types/app/api/search/route.ts +0 -351
- package/.next/types/app/api/sessions/[id]/context/route.ts +0 -351
- package/.next/types/app/api/sessions/[id]/route.ts +0 -351
- package/.next/types/app/api/sessions/new/route.ts +0 -351
- package/.next/types/app/api/sessions/route.ts +0 -351
- package/.next/types/app/api/settings/route.ts +0 -351
- package/.next/types/app/api/skills/install/route.ts +0 -351
- package/.next/types/app/api/skills/route.ts +0 -351
- package/.next/types/app/api/skills/search/route.ts +0 -351
- package/.next/types/app/api/soul/route.ts +0 -351
- package/.next/types/app/api/version/route.ts +0 -351
- package/.next/types/app/layout.ts +0 -87
- package/.next/types/app/login/page.ts +0 -87
- package/.next/types/app/page.ts +0 -87
- package/.next/types/package.json +0 -1
- package/.next/types/routes.d.ts +0 -106
- package/.next/types/validator.ts +0 -376
|
@@ -0,0 +1,1141 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useRef, useEffect, useMemo } from "react";
|
|
4
|
+
import { WidgetRenderer } from "@/components/WidgetRenderer";
|
|
5
|
+
import { MarkdownRenderer } from "@/components/MarkdownRenderer";
|
|
6
|
+
import { hasWidgetFence, parseShowWidgets } from "@/lib/widget-utils";
|
|
7
|
+
import { hasReportUpdateFence, stripReportUpdateFences } from "@/lib/report-update-parser";
|
|
8
|
+
import { encodeFilePathForApi, getFileName, normalizeFilePathSlashes } from "@/lib/file-paths";
|
|
9
|
+
import type {
|
|
10
|
+
AgentMessage,
|
|
11
|
+
UserMessage,
|
|
12
|
+
AssistantMessage,
|
|
13
|
+
ToolResultMessage,
|
|
14
|
+
CustomMessage,
|
|
15
|
+
AssistantContentBlock,
|
|
16
|
+
TextContent,
|
|
17
|
+
ImageContent,
|
|
18
|
+
ToolCallContent,
|
|
19
|
+
ThinkingContent,
|
|
20
|
+
} from "@/lib/types";
|
|
21
|
+
|
|
22
|
+
interface Props {
|
|
23
|
+
message: AgentMessage;
|
|
24
|
+
isStreaming?: boolean;
|
|
25
|
+
toolResults?: Map<string, ToolResultMessage>;
|
|
26
|
+
modelNames?: Record<string, string>;
|
|
27
|
+
entryId?: string;
|
|
28
|
+
onFork?: (entryId: string) => void;
|
|
29
|
+
forking?: boolean;
|
|
30
|
+
onSendMessage?: (content: string) => void;
|
|
31
|
+
showTimestamp?: boolean;
|
|
32
|
+
prevTimestamp?: number;
|
|
33
|
+
renderVisualCodeBlocks?: boolean;
|
|
34
|
+
cwd?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function formatTime(ts?: number): string | null {
|
|
38
|
+
if (!ts) return null;
|
|
39
|
+
const d = new Date(ts);
|
|
40
|
+
const now = new Date();
|
|
41
|
+
const isToday = d.getFullYear() === now.getFullYear() &&
|
|
42
|
+
d.getMonth() === now.getMonth() &&
|
|
43
|
+
d.getDate() === now.getDate();
|
|
44
|
+
const time = d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
45
|
+
if (isToday) return time;
|
|
46
|
+
const date = d.toLocaleDateString([], { month: "short", day: "numeric", year: d.getFullYear() !== now.getFullYear() ? "numeric" : undefined });
|
|
47
|
+
return `${date} ${time}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function copyText(text: string): Promise<void> {
|
|
51
|
+
if (navigator.clipboard?.writeText) {
|
|
52
|
+
return navigator.clipboard.writeText(text);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const ta = document.createElement("textarea");
|
|
56
|
+
ta.value = text;
|
|
57
|
+
ta.style.position = "fixed";
|
|
58
|
+
ta.style.opacity = "0";
|
|
59
|
+
document.body.appendChild(ta);
|
|
60
|
+
ta.select();
|
|
61
|
+
document.execCommand("copy");
|
|
62
|
+
document.body.removeChild(ta);
|
|
63
|
+
return Promise.resolve();
|
|
64
|
+
} catch {
|
|
65
|
+
return Promise.reject();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function imageContentSrc(image: ImageContent): string | null {
|
|
70
|
+
if (image.source?.type === "base64" && image.source.data) {
|
|
71
|
+
return `data:${image.source.media_type ?? "image/png"};base64,${image.source.data}`;
|
|
72
|
+
}
|
|
73
|
+
if (image.source?.type === "url" && image.source.url) return image.source.url;
|
|
74
|
+
if (image.data) return `data:${image.mimeType ?? "image/png"};base64,${image.data}`;
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const PREVIEW_PATH_RE = /(?:file:\/\/)?(?:(?:[A-Za-z]:[\\/])|\/|~\/|\.{1,2}[\\/]|[A-Za-z0-9_.-]+[\\/])[^`"'<>|\s{}\[\]]+?\.(?:png|jpe?g|webp|gif|svg|bmp|avif|pdf)(?=$|[\s`"'<>|{}\[\]),.;:!?])/gi;
|
|
79
|
+
const IMAGE_EXT_RE = /\.(?:png|jpe?g|webp|gif|svg|bmp|avif)$/i;
|
|
80
|
+
const PDF_EXT_RE = /\.pdf$/i;
|
|
81
|
+
const WINDOWS_ABSOLUTE_RE = /^[A-Za-z]:[\\/]/;
|
|
82
|
+
const MAX_LOCAL_PREVIEW_PATHS = 24;
|
|
83
|
+
|
|
84
|
+
function fileReadUrl(filePath: string): string {
|
|
85
|
+
return `/api/files/${encodeFilePathForApi(filePath)}?type=read`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function normalizeResolvedPath(filePath: string): string {
|
|
89
|
+
const normalized = normalizeFilePathSlashes(filePath);
|
|
90
|
+
const absolute = normalized.startsWith("/") || WINDOWS_ABSOLUTE_RE.test(normalized);
|
|
91
|
+
if (WINDOWS_ABSOLUTE_RE.test(normalized)) return normalized;
|
|
92
|
+
|
|
93
|
+
const parts: string[] = [];
|
|
94
|
+
for (const part of normalized.split("/")) {
|
|
95
|
+
if (!part || part === ".") continue;
|
|
96
|
+
if (part === "..") {
|
|
97
|
+
if (parts.length > 0 && parts[parts.length - 1] !== "..") parts.pop();
|
|
98
|
+
else if (!absolute) parts.push(part);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
parts.push(part);
|
|
102
|
+
}
|
|
103
|
+
return `${absolute ? "/" : ""}${parts.join("/")}`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function resolveLocalPreviewPath(rawPath: string, cwd?: string): string | null {
|
|
107
|
+
let value = rawPath
|
|
108
|
+
.trim()
|
|
109
|
+
.replace(/^file:\/\//i, "")
|
|
110
|
+
.replace(/[),.;:!?]+$/g, "");
|
|
111
|
+
|
|
112
|
+
if (!value || value.startsWith("//")) return null;
|
|
113
|
+
value = normalizeFilePathSlashes(value);
|
|
114
|
+
|
|
115
|
+
if (value.startsWith("/") || WINDOWS_ABSOLUTE_RE.test(value)) {
|
|
116
|
+
return normalizeResolvedPath(value);
|
|
117
|
+
}
|
|
118
|
+
if (value.startsWith("~/")) {
|
|
119
|
+
const homeMatch = cwd?.match(/^(\/Users\/[^/]+|\/home\/[^/]+)(?:\/|$)/);
|
|
120
|
+
return homeMatch ? normalizeResolvedPath(`${homeMatch[1]}/${value.slice(2)}`) : null;
|
|
121
|
+
}
|
|
122
|
+
if (!cwd) return null;
|
|
123
|
+
return normalizeResolvedPath(`${cwd.replace(/\/+$/, "")}/${value.replace(/^\.?\//, "")}`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function extractLocalImagePreviewPaths(text: string | null | undefined, cwd?: string): string[] {
|
|
127
|
+
if (!text) return [];
|
|
128
|
+
const paths: string[] = [];
|
|
129
|
+
const seen = new Set<string>();
|
|
130
|
+
const markdownImageUrls = new Set<string>();
|
|
131
|
+
for (const match of text.matchAll(/!\[[^\]]*]\(([^)]+)\)/g)) {
|
|
132
|
+
if (match[1]) markdownImageUrls.add(match[1].trim());
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const add = (path: string | null) => {
|
|
136
|
+
if (!path || seen.has(path) || paths.length >= MAX_LOCAL_PREVIEW_PATHS) return;
|
|
137
|
+
seen.add(path);
|
|
138
|
+
paths.push(path);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
PREVIEW_PATH_RE.lastIndex = 0;
|
|
142
|
+
for (const match of text.matchAll(PREVIEW_PATH_RE)) {
|
|
143
|
+
const raw = match[0];
|
|
144
|
+
if (/^[a-z][a-z\d+.-]*:\/\//i.test(raw) && !/^file:\/\//i.test(raw)) continue;
|
|
145
|
+
const preceding = text.slice(Math.max(0, match.index - 12), match.index);
|
|
146
|
+
if (/[A-Za-z][A-Za-z\d+.-]*:\/?$/.test(preceding) || raw.startsWith("//")) continue;
|
|
147
|
+
if (markdownImageUrls.has(raw)) continue;
|
|
148
|
+
|
|
149
|
+
const resolved = resolveLocalPreviewPath(raw, cwd);
|
|
150
|
+
if (!resolved) continue;
|
|
151
|
+
if (IMAGE_EXT_RE.test(resolved)) {
|
|
152
|
+
add(resolved);
|
|
153
|
+
} else if (PDF_EXT_RE.test(resolved)) {
|
|
154
|
+
add(resolved.replace(PDF_EXT_RE, ".png"));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return paths;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function uniqueImagePaths(paths: string[]): string[] {
|
|
161
|
+
const seen = new Set<string>();
|
|
162
|
+
const result: string[] = [];
|
|
163
|
+
for (const path of paths) {
|
|
164
|
+
if (seen.has(path)) continue;
|
|
165
|
+
seen.add(path);
|
|
166
|
+
result.push(path);
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function ImagePreviewGrid({ images, maxHeight = 360 }: { images: ImageContent[]; maxHeight?: number }) {
|
|
172
|
+
if (images.length === 0) return null;
|
|
173
|
+
return (
|
|
174
|
+
<div
|
|
175
|
+
style={{
|
|
176
|
+
display: "grid",
|
|
177
|
+
gridTemplateColumns: images.length === 1 ? "minmax(0, 1fr)" : "repeat(auto-fit, minmax(180px, 1fr))",
|
|
178
|
+
gap: 8,
|
|
179
|
+
minWidth: 0,
|
|
180
|
+
}}
|
|
181
|
+
>
|
|
182
|
+
{images.map((image, index) => {
|
|
183
|
+
const src = imageContentSrc(image);
|
|
184
|
+
if (!src) return null;
|
|
185
|
+
return (
|
|
186
|
+
<a
|
|
187
|
+
key={index}
|
|
188
|
+
href={src}
|
|
189
|
+
target="_blank"
|
|
190
|
+
rel="noreferrer"
|
|
191
|
+
title="Open image"
|
|
192
|
+
style={{
|
|
193
|
+
display: "block",
|
|
194
|
+
minWidth: 0,
|
|
195
|
+
border: "1px solid var(--border)",
|
|
196
|
+
borderRadius: 6,
|
|
197
|
+
overflow: "hidden",
|
|
198
|
+
background: "var(--bg)",
|
|
199
|
+
}}
|
|
200
|
+
>
|
|
201
|
+
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
202
|
+
<img
|
|
203
|
+
src={src}
|
|
204
|
+
alt=""
|
|
205
|
+
loading="lazy"
|
|
206
|
+
style={{
|
|
207
|
+
display: "block",
|
|
208
|
+
width: "100%",
|
|
209
|
+
maxHeight,
|
|
210
|
+
objectFit: "contain",
|
|
211
|
+
}}
|
|
212
|
+
/>
|
|
213
|
+
</a>
|
|
214
|
+
);
|
|
215
|
+
})}
|
|
216
|
+
</div>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function LocalImagePathPreviewGrid({ imagePaths, maxHeight = 360 }: { imagePaths: string[]; maxHeight?: number }) {
|
|
221
|
+
const [failed, setFailed] = useState<Set<string>>(() => new Set());
|
|
222
|
+
const attemptsRef = useRef<Map<string, number>>(new Map());
|
|
223
|
+
const imagePathsKey = imagePaths.join("\0");
|
|
224
|
+
|
|
225
|
+
useEffect(() => {
|
|
226
|
+
const active = new Set(imagePaths);
|
|
227
|
+
attemptsRef.current = new Map([...attemptsRef.current].filter(([path]) => active.has(path)));
|
|
228
|
+
setFailed((prev) => {
|
|
229
|
+
const next = new Set([...prev].filter((path) => active.has(path)));
|
|
230
|
+
return next.size === prev.size ? prev : next;
|
|
231
|
+
});
|
|
232
|
+
}, [imagePaths, imagePathsKey]);
|
|
233
|
+
|
|
234
|
+
useEffect(() => {
|
|
235
|
+
const retryable = [...failed].some((path) => (attemptsRef.current.get(path) ?? 0) < 3);
|
|
236
|
+
if (!retryable) return;
|
|
237
|
+
const timer = window.setTimeout(() => {
|
|
238
|
+
setFailed((prev) => {
|
|
239
|
+
const next = new Set(prev);
|
|
240
|
+
for (const path of prev) {
|
|
241
|
+
if ((attemptsRef.current.get(path) ?? 0) < 3) next.delete(path);
|
|
242
|
+
}
|
|
243
|
+
return next;
|
|
244
|
+
});
|
|
245
|
+
}, 2500);
|
|
246
|
+
return () => window.clearTimeout(timer);
|
|
247
|
+
}, [failed]);
|
|
248
|
+
|
|
249
|
+
const visiblePaths = imagePaths.filter((path) => !failed.has(path));
|
|
250
|
+
if (visiblePaths.length === 0) return null;
|
|
251
|
+
|
|
252
|
+
return (
|
|
253
|
+
<div
|
|
254
|
+
style={{
|
|
255
|
+
display: "grid",
|
|
256
|
+
gridTemplateColumns: visiblePaths.length === 1 ? "minmax(0, 1fr)" : "repeat(auto-fit, minmax(180px, 1fr))",
|
|
257
|
+
gap: 8,
|
|
258
|
+
minWidth: 0,
|
|
259
|
+
}}
|
|
260
|
+
>
|
|
261
|
+
{visiblePaths.map((path) => {
|
|
262
|
+
const src = fileReadUrl(path);
|
|
263
|
+
const name = getFileName(path);
|
|
264
|
+
return (
|
|
265
|
+
<a
|
|
266
|
+
key={path}
|
|
267
|
+
href={src}
|
|
268
|
+
target="_blank"
|
|
269
|
+
rel="noreferrer"
|
|
270
|
+
title={path}
|
|
271
|
+
style={{
|
|
272
|
+
display: "block",
|
|
273
|
+
minWidth: 0,
|
|
274
|
+
border: "1px solid var(--border)",
|
|
275
|
+
borderRadius: 6,
|
|
276
|
+
overflow: "hidden",
|
|
277
|
+
background: "var(--bg)",
|
|
278
|
+
}}
|
|
279
|
+
>
|
|
280
|
+
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
281
|
+
<img
|
|
282
|
+
src={src}
|
|
283
|
+
alt={name}
|
|
284
|
+
loading="lazy"
|
|
285
|
+
onError={() => {
|
|
286
|
+
attemptsRef.current.set(path, (attemptsRef.current.get(path) ?? 0) + 1);
|
|
287
|
+
setFailed((prev) => {
|
|
288
|
+
const next = new Set(prev);
|
|
289
|
+
next.add(path);
|
|
290
|
+
return next;
|
|
291
|
+
});
|
|
292
|
+
}}
|
|
293
|
+
style={{
|
|
294
|
+
display: "block",
|
|
295
|
+
width: "100%",
|
|
296
|
+
maxHeight,
|
|
297
|
+
objectFit: "contain",
|
|
298
|
+
}}
|
|
299
|
+
/>
|
|
300
|
+
<div
|
|
301
|
+
style={{
|
|
302
|
+
padding: "4px 6px",
|
|
303
|
+
borderTop: "1px solid var(--border)",
|
|
304
|
+
color: "var(--text-dim)",
|
|
305
|
+
fontSize: 10,
|
|
306
|
+
fontFamily: "var(--font-mono)",
|
|
307
|
+
overflow: "hidden",
|
|
308
|
+
textOverflow: "ellipsis",
|
|
309
|
+
whiteSpace: "nowrap",
|
|
310
|
+
}}
|
|
311
|
+
>
|
|
312
|
+
{name}
|
|
313
|
+
</div>
|
|
314
|
+
</a>
|
|
315
|
+
);
|
|
316
|
+
})}
|
|
317
|
+
</div>
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function visibleToolResultText(text: string | null, hasImages: boolean): string | null {
|
|
322
|
+
if (!text || !hasImages) return text;
|
|
323
|
+
return text
|
|
324
|
+
.replace(/\n?\[Current model does not support images\. The image will be omitted from this request\.\]\s*/g, "")
|
|
325
|
+
.trim();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function assistantModelLabel(message: AssistantMessage, modelNames?: Record<string, string>): string | null {
|
|
329
|
+
const provider = message.provider?.trim();
|
|
330
|
+
const model = message.model?.trim();
|
|
331
|
+
if (provider && model && model !== "unknown") {
|
|
332
|
+
return modelNames?.[`${provider}:${model}`] ?? modelNames?.[model] ?? model;
|
|
333
|
+
}
|
|
334
|
+
if (provider && provider !== "codex" && provider !== "unknown") return provider;
|
|
335
|
+
return model && model !== "unknown" ? (modelNames?.[model] ?? model) : null;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export function MessageView({ message, isStreaming, toolResults, modelNames, entryId, onFork, forking, onSendMessage, showTimestamp, prevTimestamp, renderVisualCodeBlocks, cwd }: Props) {
|
|
339
|
+
if (message.role === "user") {
|
|
340
|
+
return <UserMessageView message={message as UserMessage} entryId={entryId} onFork={onFork} forking={forking} />;
|
|
341
|
+
}
|
|
342
|
+
if (message.role === "assistant") {
|
|
343
|
+
return <AssistantMessageView message={message as AssistantMessage} isStreaming={isStreaming} toolResults={toolResults} modelNames={modelNames} onSendMessage={onSendMessage} showTimestamp={showTimestamp} prevTimestamp={prevTimestamp} renderVisualCodeBlocks={renderVisualCodeBlocks} cwd={cwd} />;
|
|
344
|
+
}
|
|
345
|
+
if (message.role === "toolResult") {
|
|
346
|
+
// Rendered inline under its toolCall — skip standalone rendering if paired
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
if (message.role === "custom") {
|
|
350
|
+
return <CustomMessageView message={message as CustomMessage} showTimestamp={showTimestamp} />;
|
|
351
|
+
}
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function UserMessageView({ message, entryId, onFork, forking }: {
|
|
356
|
+
message: UserMessage;
|
|
357
|
+
entryId?: string;
|
|
358
|
+
onFork?: (entryId: string) => void;
|
|
359
|
+
forking?: boolean;
|
|
360
|
+
}) {
|
|
361
|
+
const [hovered, setHovered] = useState(false);
|
|
362
|
+
const [copied, setCopied] = useState(false);
|
|
363
|
+
|
|
364
|
+
const content =
|
|
365
|
+
typeof message.content === "string"
|
|
366
|
+
? message.content
|
|
367
|
+
: message.content
|
|
368
|
+
.filter((b): b is TextContent => b.type === "text")
|
|
369
|
+
.map((b) => b.text)
|
|
370
|
+
.join("\n");
|
|
371
|
+
|
|
372
|
+
const imageBlocks: ImageContent[] =
|
|
373
|
+
typeof message.content === "string"
|
|
374
|
+
? []
|
|
375
|
+
: message.content.filter((b): b is ImageContent => b.type === "image");
|
|
376
|
+
|
|
377
|
+
const time = formatTime(message.timestamp);
|
|
378
|
+
const canFork = !!entryId && !!onFork;
|
|
379
|
+
|
|
380
|
+
const copyContent = () => {
|
|
381
|
+
copyText(content).then(() => {
|
|
382
|
+
setCopied(true);
|
|
383
|
+
setTimeout(() => setCopied(false), 1500);
|
|
384
|
+
});
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
return (
|
|
388
|
+
<div
|
|
389
|
+
style={{ marginBottom: 16, display: "flex", flexDirection: "column", alignItems: "flex-end" }}
|
|
390
|
+
onMouseEnter={() => setHovered(true)}
|
|
391
|
+
onMouseLeave={() => setHovered(false)}
|
|
392
|
+
>
|
|
393
|
+
<div style={{ display: "flex", alignItems: "flex-end", gap: 6, maxWidth: "85%" }}>
|
|
394
|
+
<div
|
|
395
|
+
style={{
|
|
396
|
+
flex: 1,
|
|
397
|
+
minWidth: 0,
|
|
398
|
+
background: "var(--user-bg)",
|
|
399
|
+
border: "1px solid rgba(59,130,246,0.2)",
|
|
400
|
+
borderRadius: 12,
|
|
401
|
+
padding: "8px 12px",
|
|
402
|
+
fontSize: 14,
|
|
403
|
+
lineHeight: 1.6,
|
|
404
|
+
color: "var(--text)",
|
|
405
|
+
whiteSpace: "pre-wrap",
|
|
406
|
+
wordBreak: "break-word",
|
|
407
|
+
}}
|
|
408
|
+
>
|
|
409
|
+
{imageBlocks.length > 0 && (
|
|
410
|
+
<div style={{ display: "flex", gap: 6, flexWrap: "wrap", marginBottom: content ? 8 : 0 }}>
|
|
411
|
+
{imageBlocks.map((img, i) => {
|
|
412
|
+
const src = imageContentSrc(img);
|
|
413
|
+
if (!src) return null;
|
|
414
|
+
return (
|
|
415
|
+
// eslint-disable-next-line @next/next/no-img-element
|
|
416
|
+
<img
|
|
417
|
+
key={i}
|
|
418
|
+
src={src}
|
|
419
|
+
alt=""
|
|
420
|
+
style={{ maxWidth: 240, maxHeight: 240, borderRadius: 6, objectFit: "contain", display: "block", border: "1px solid rgba(59,130,246,0.15)" }}
|
|
421
|
+
/>
|
|
422
|
+
);
|
|
423
|
+
})}
|
|
424
|
+
</div>
|
|
425
|
+
)}
|
|
426
|
+
{content}
|
|
427
|
+
</div>
|
|
428
|
+
|
|
429
|
+
</div>
|
|
430
|
+
|
|
431
|
+
{/* Bottom row: action buttons + timestamp */}
|
|
432
|
+
<div style={{
|
|
433
|
+
display: "flex", alignItems: "center", justifyContent: "flex-end",
|
|
434
|
+
gap: 6, marginTop: 3,
|
|
435
|
+
}}>
|
|
436
|
+
<div style={{
|
|
437
|
+
display: "flex", gap: 3,
|
|
438
|
+
opacity: hovered ? 1 : 0,
|
|
439
|
+
pointerEvents: hovered ? "auto" : "none",
|
|
440
|
+
transition: "opacity 0.12s",
|
|
441
|
+
}}>
|
|
442
|
+
<button
|
|
443
|
+
onClick={copyContent}
|
|
444
|
+
title="Copy message"
|
|
445
|
+
style={{
|
|
446
|
+
display: "flex", alignItems: "center", gap: 4,
|
|
447
|
+
padding: "3px 8px", height: 22,
|
|
448
|
+
background: "none", border: "none",
|
|
449
|
+
borderRadius: 5,
|
|
450
|
+
color: copied ? "var(--accent)" : "var(--text-dim)",
|
|
451
|
+
cursor: "pointer",
|
|
452
|
+
fontSize: 11, fontWeight: 400,
|
|
453
|
+
whiteSpace: "nowrap",
|
|
454
|
+
transition: "color 0.12s",
|
|
455
|
+
}}
|
|
456
|
+
onMouseEnter={(e) => { if (!copied) e.currentTarget.style.color = "var(--accent)"; }}
|
|
457
|
+
onMouseLeave={(e) => { if (!copied) e.currentTarget.style.color = "var(--text-dim)"; }}
|
|
458
|
+
>
|
|
459
|
+
{copied ? (
|
|
460
|
+
<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
|
|
461
|
+
<polyline points="20 6 9 17 4 12" />
|
|
462
|
+
</svg>
|
|
463
|
+
) : (
|
|
464
|
+
<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
|
|
465
|
+
<rect x="9" y="9" width="13" height="13" rx="2" ry="2" />
|
|
466
|
+
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
|
|
467
|
+
</svg>
|
|
468
|
+
)}
|
|
469
|
+
{copied ? "Copied" : "Copy"}
|
|
470
|
+
</button>
|
|
471
|
+
</div>
|
|
472
|
+
{canFork && (
|
|
473
|
+
<div style={{
|
|
474
|
+
display: "flex", gap: 3,
|
|
475
|
+
opacity: (hovered || forking) ? 1 : 0,
|
|
476
|
+
pointerEvents: (hovered || forking) ? "auto" : "none",
|
|
477
|
+
transition: "opacity 0.12s",
|
|
478
|
+
}}>
|
|
479
|
+
<button
|
|
480
|
+
onClick={() => { onFork!(entryId!); }}
|
|
481
|
+
disabled={forking}
|
|
482
|
+
title={forking ? "Creating new session..." : "New session - creates an independent copy from here"}
|
|
483
|
+
style={{
|
|
484
|
+
display: "flex", alignItems: "center", gap: 4,
|
|
485
|
+
padding: "3px 8px", height: 22,
|
|
486
|
+
background: "none", border: "none",
|
|
487
|
+
borderRadius: 5,
|
|
488
|
+
color: forking ? "var(--accent)" : "var(--text-dim)",
|
|
489
|
+
cursor: forking ? "not-allowed" : "pointer",
|
|
490
|
+
fontSize: 11, fontWeight: 400,
|
|
491
|
+
whiteSpace: "nowrap",
|
|
492
|
+
transition: "color 0.12s",
|
|
493
|
+
}}
|
|
494
|
+
onMouseEnter={(e) => { if (!forking) e.currentTarget.style.color = "var(--accent)"; }}
|
|
495
|
+
onMouseLeave={(e) => { if (!forking) e.currentTarget.style.color = "var(--text-dim)"; }}
|
|
496
|
+
>
|
|
497
|
+
<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
|
|
498
|
+
<line x1="6" y1="3" x2="6" y2="15" />
|
|
499
|
+
<circle cx="18" cy="6" r="3" />
|
|
500
|
+
<circle cx="6" cy="18" r="3" />
|
|
501
|
+
<path d="M18 9a9 9 0 0 1-9 9" />
|
|
502
|
+
</svg>
|
|
503
|
+
{forking ? "Creating..." : "New session"}
|
|
504
|
+
</button>
|
|
505
|
+
</div>
|
|
506
|
+
)}
|
|
507
|
+
{time && <span style={{ fontSize: 10, color: "var(--text-dim)" }}>{time}</span>}
|
|
508
|
+
</div>
|
|
509
|
+
</div>
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function AssistantMessageView({
|
|
514
|
+
message,
|
|
515
|
+
isStreaming,
|
|
516
|
+
toolResults,
|
|
517
|
+
modelNames,
|
|
518
|
+
onSendMessage,
|
|
519
|
+
showTimestamp,
|
|
520
|
+
prevTimestamp,
|
|
521
|
+
renderVisualCodeBlocks,
|
|
522
|
+
cwd,
|
|
523
|
+
}: {
|
|
524
|
+
message: AssistantMessage;
|
|
525
|
+
isStreaming?: boolean;
|
|
526
|
+
toolResults?: Map<string, ToolResultMessage>;
|
|
527
|
+
modelNames?: Record<string, string>;
|
|
528
|
+
onSendMessage?: (content: string) => void;
|
|
529
|
+
showTimestamp?: boolean;
|
|
530
|
+
prevTimestamp?: number;
|
|
531
|
+
renderVisualCodeBlocks?: boolean;
|
|
532
|
+
cwd?: string;
|
|
533
|
+
}) {
|
|
534
|
+
const time = showTimestamp ? formatTime(message.timestamp) : null;
|
|
535
|
+
const blocks = message.content ?? [];
|
|
536
|
+
const [hovered, setHovered] = useState(false);
|
|
537
|
+
const [copied, setCopied] = useState(false);
|
|
538
|
+
const streamStartRef = useRef<number | null>(null);
|
|
539
|
+
const [tps, setTps] = useState<number | null>(null);
|
|
540
|
+
const blocksRef = useRef(blocks);
|
|
541
|
+
blocksRef.current = blocks;
|
|
542
|
+
|
|
543
|
+
// Streaming-based timing for thinking blocks
|
|
544
|
+
const blockStartTimesRef = useRef<Map<number, number>>(new Map());
|
|
545
|
+
const [streamingDurations, setStreamingDurations] = useState<Map<number, number>>(new Map());
|
|
546
|
+
|
|
547
|
+
// Thinking duration derived from file timestamps: time from prev message end to this message end
|
|
548
|
+
// This is the total generation time (thinking + any text before first tool call)
|
|
549
|
+
const thinkingDurationFromFile = useMemo<number | undefined>(() => {
|
|
550
|
+
if (!message.timestamp || !prevTimestamp) return undefined;
|
|
551
|
+
const secs = Math.round((message.timestamp - prevTimestamp) / 1000);
|
|
552
|
+
return secs > 0 ? secs : undefined;
|
|
553
|
+
}, [message.timestamp, prevTimestamp]);
|
|
554
|
+
|
|
555
|
+
// Tool call durations derived from session file timestamps (accurate for completed messages)
|
|
556
|
+
// assistant message timestamp = when generation ended = when tools started running
|
|
557
|
+
// toolResult timestamp = when tool execution finished
|
|
558
|
+
const toolCallDurations = useMemo<Map<string, number>>(() => {
|
|
559
|
+
const map = new Map<string, number>();
|
|
560
|
+
if (!toolResults || !message.timestamp) return map;
|
|
561
|
+
for (const [callId, result] of toolResults) {
|
|
562
|
+
if (result.timestamp && message.timestamp) {
|
|
563
|
+
const secs = Math.round((result.timestamp - message.timestamp) / 1000);
|
|
564
|
+
if (secs > 0) map.set(callId, secs);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
return map;
|
|
568
|
+
}, [toolResults, message.timestamp]);
|
|
569
|
+
|
|
570
|
+
const textContent = blocks
|
|
571
|
+
.filter((b): b is TextContent => b.type === "text")
|
|
572
|
+
.map((b) => b.text)
|
|
573
|
+
.join("\n");
|
|
574
|
+
|
|
575
|
+
const copyContent = () => {
|
|
576
|
+
copyText(textContent).then(() => {
|
|
577
|
+
setCopied(true);
|
|
578
|
+
setTimeout(() => setCopied(false), 1500);
|
|
579
|
+
});
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
useEffect(() => {
|
|
583
|
+
if (!isStreaming) {
|
|
584
|
+
// Finalise any un-finished thinking block durations on stream end
|
|
585
|
+
const now = Date.now();
|
|
586
|
+
setStreamingDurations((prev: Map<number, number>) => {
|
|
587
|
+
const next = new Map(prev);
|
|
588
|
+
for (const [idx, start] of blockStartTimesRef.current) {
|
|
589
|
+
if (!next.has(idx)) next.set(idx, Math.round((now - start) / 1000));
|
|
590
|
+
}
|
|
591
|
+
return next;
|
|
592
|
+
});
|
|
593
|
+
streamStartRef.current = null;
|
|
594
|
+
setTps(null);
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
const tick = () => {
|
|
598
|
+
const bs = blocksRef.current;
|
|
599
|
+
const now = Date.now();
|
|
600
|
+
|
|
601
|
+
// Record start time for each block the first time we see it
|
|
602
|
+
bs.forEach((_, i) => {
|
|
603
|
+
if (!blockStartTimesRef.current.has(i)) blockStartTimesRef.current.set(i, now);
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
// When a non-last block has a successor already started, finalise its duration
|
|
607
|
+
setStreamingDurations((prev: Map<number, number>) => {
|
|
608
|
+
let changed = false;
|
|
609
|
+
const next = new Map(prev);
|
|
610
|
+
for (let i = 0; i < bs.length - 1; i++) {
|
|
611
|
+
if (!next.has(i) && blockStartTimesRef.current.has(i)) {
|
|
612
|
+
const start = blockStartTimesRef.current.get(i)!;
|
|
613
|
+
const nextStart = blockStartTimesRef.current.get(i + 1) ?? now;
|
|
614
|
+
next.set(i, Math.round((nextStart - start) / 1000));
|
|
615
|
+
changed = true;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
return changed ? next : prev;
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
let chars = 0;
|
|
622
|
+
for (const b of bs) {
|
|
623
|
+
if (b.type === "text") chars += (b as TextContent).text?.length ?? 0;
|
|
624
|
+
else if (b.type === "thinking") chars += (b as ThinkingContent).thinking?.length ?? 0;
|
|
625
|
+
else if (b.type === "toolCall") chars += JSON.stringify((b as ToolCallContent).input ?? {}).length;
|
|
626
|
+
}
|
|
627
|
+
if (chars === 0) return;
|
|
628
|
+
if (streamStartRef.current === null) streamStartRef.current = now;
|
|
629
|
+
const elapsed = (now - streamStartRef.current) / 1000;
|
|
630
|
+
if (elapsed > 0.5) setTps(chars / 4 / elapsed);
|
|
631
|
+
};
|
|
632
|
+
const id = setInterval(tick, 300);
|
|
633
|
+
return () => clearInterval(id);
|
|
634
|
+
}, [isStreaming]);
|
|
635
|
+
const modelLabel = assistantModelLabel(message, modelNames);
|
|
636
|
+
|
|
637
|
+
return (
|
|
638
|
+
<div
|
|
639
|
+
style={{ marginBottom: 16 }}
|
|
640
|
+
onMouseEnter={() => setHovered(true)}
|
|
641
|
+
onMouseLeave={() => setHovered(false)}
|
|
642
|
+
>
|
|
643
|
+
{/* Model label */}
|
|
644
|
+
<div
|
|
645
|
+
style={{
|
|
646
|
+
fontSize: 11,
|
|
647
|
+
color: "var(--text-dim)",
|
|
648
|
+
marginBottom: 4,
|
|
649
|
+
display: "flex",
|
|
650
|
+
alignItems: "center",
|
|
651
|
+
gap: 6,
|
|
652
|
+
}}
|
|
653
|
+
>
|
|
654
|
+
{modelLabel && <span>{modelLabel}</span>}
|
|
655
|
+
{isStreaming && (() => {
|
|
656
|
+
let chars = 0;
|
|
657
|
+
for (const b of blocks) {
|
|
658
|
+
if (b.type === "text") chars += (b as TextContent).text?.length ?? 0;
|
|
659
|
+
else if (b.type === "thinking") chars += (b as ThinkingContent).thinking?.length ?? 0;
|
|
660
|
+
else if (b.type === "toolCall") chars += JSON.stringify((b as ToolCallContent).input ?? {}).length;
|
|
661
|
+
}
|
|
662
|
+
const est = Math.round(chars / 4);
|
|
663
|
+
return (
|
|
664
|
+
<>
|
|
665
|
+
|
|
666
|
+
{est > 0 && (
|
|
667
|
+
<span style={{ display: "flex", alignItems: "center", gap: 4, color: "var(--text)" }} title="预估 token 数(流式接收中)">
|
|
668
|
+
<span style={{ display: "flex", alignItems: "center", gap: 2, fontSize: 11, fontWeight: 400 }}>
|
|
669
|
+
<svg width="10" height="10" viewBox="0 0 10 10" fill="none" stroke="currentColor" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round">
|
|
670
|
+
<line x1="5" y1="1.5" x2="5" y2="8.5" /><polyline points="2 6 5 8.5 8 6" />
|
|
671
|
+
</svg>
|
|
672
|
+
{est}
|
|
673
|
+
</span>
|
|
674
|
+
{tps !== null && (() => {
|
|
675
|
+
const bg = tps >= 50 ? "#53b3cb" : tps >= 30 ? "#9bc53d" : tps >= 15 ? "#f9c22e" : "#e01a4f";
|
|
676
|
+
return (
|
|
677
|
+
<span style={{ marginLeft: 6, padding: "1px 6px", borderRadius: 4, background: bg, color: "#fff", fontSize: 11, fontWeight: 400 }}>
|
|
678
|
+
{tps.toFixed(1)} t/s
|
|
679
|
+
</span>
|
|
680
|
+
);
|
|
681
|
+
})()}
|
|
682
|
+
</span>
|
|
683
|
+
)}
|
|
684
|
+
</>
|
|
685
|
+
);
|
|
686
|
+
})()}
|
|
687
|
+
</div>
|
|
688
|
+
|
|
689
|
+
<div style={{ display: "flex", flexDirection: "column", gap: 8 }}>
|
|
690
|
+
{blocks.map((block, i) => (
|
|
691
|
+
<BlockView key={i} block={block} toolResults={toolResults} isStreaming={isStreaming} streamingDuration={streamingDurations.get(i) ?? (block.type === "thinking" ? thinkingDurationFromFile : undefined)} toolCallDurations={toolCallDurations} onSendMessage={onSendMessage} renderVisualCodeBlocks={renderVisualCodeBlocks} cwd={cwd} />
|
|
692
|
+
))}
|
|
693
|
+
</div>
|
|
694
|
+
|
|
695
|
+
<div style={{
|
|
696
|
+
display: "flex", alignItems: "center", gap: 8, marginTop: 4,
|
|
697
|
+
}}>
|
|
698
|
+
{message.usage && !isStreaming && (
|
|
699
|
+
<div style={{ fontSize: 11, color: "var(--text-dim)" }}>
|
|
700
|
+
{formatUsage(message.usage)}
|
|
701
|
+
</div>
|
|
702
|
+
)}
|
|
703
|
+
{textContent && !isStreaming && (
|
|
704
|
+
<button
|
|
705
|
+
onClick={copyContent}
|
|
706
|
+
title="Copy message"
|
|
707
|
+
style={{
|
|
708
|
+
display: "flex", alignItems: "center", gap: 4,
|
|
709
|
+
padding: "3px 8px", height: 22,
|
|
710
|
+
background: "none", border: "none",
|
|
711
|
+
borderRadius: 5,
|
|
712
|
+
color: copied ? "var(--accent)" : "var(--text-dim)",
|
|
713
|
+
cursor: "pointer",
|
|
714
|
+
fontSize: 11, fontWeight: 400,
|
|
715
|
+
whiteSpace: "nowrap",
|
|
716
|
+
opacity: hovered ? 1 : 0,
|
|
717
|
+
pointerEvents: hovered ? "auto" : "none",
|
|
718
|
+
transition: "opacity 0.12s, color 0.12s",
|
|
719
|
+
}}
|
|
720
|
+
onMouseEnter={(e) => { if (!copied) e.currentTarget.style.color = "var(--accent)"; }}
|
|
721
|
+
onMouseLeave={(e) => { if (!copied) e.currentTarget.style.color = "var(--text-dim)"; }}
|
|
722
|
+
>
|
|
723
|
+
{copied ? (
|
|
724
|
+
<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
|
|
725
|
+
<polyline points="20 6 9 17 4 12" />
|
|
726
|
+
</svg>
|
|
727
|
+
) : (
|
|
728
|
+
<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
|
|
729
|
+
<rect x="9" y="9" width="13" height="13" rx="2" ry="2" />
|
|
730
|
+
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
|
|
731
|
+
</svg>
|
|
732
|
+
)}
|
|
733
|
+
{copied ? "Copied" : "Copy"}
|
|
734
|
+
</button>
|
|
735
|
+
)}
|
|
736
|
+
{time && !isStreaming && (
|
|
737
|
+
<span style={{ fontSize: 10, color: "var(--text-dim)", marginLeft: "auto" }}>{time}</span>
|
|
738
|
+
)}
|
|
739
|
+
</div>
|
|
740
|
+
</div>
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
function BlockView({ block, toolResults, isStreaming, streamingDuration, toolCallDurations, onSendMessage, renderVisualCodeBlocks, cwd }: { block: AssistantContentBlock; toolResults?: Map<string, ToolResultMessage>; isStreaming?: boolean; streamingDuration?: number; toolCallDurations?: Map<string, number>; onSendMessage?: (content: string) => void; renderVisualCodeBlocks?: boolean; cwd?: string }) {
|
|
745
|
+
if (block.type === "text") {
|
|
746
|
+
return <TextBlock block={block as TextContent} isStreaming={isStreaming} onSendMessage={onSendMessage} renderVisualCodeBlocks={renderVisualCodeBlocks} cwd={cwd} />;
|
|
747
|
+
}
|
|
748
|
+
if (block.type === "image") {
|
|
749
|
+
return <ImagePreviewGrid images={[block as ImageContent]} />;
|
|
750
|
+
}
|
|
751
|
+
if (block.type === "thinking") {
|
|
752
|
+
return <ThinkingBlock block={block as ThinkingContent} duration={streamingDuration} />;
|
|
753
|
+
}
|
|
754
|
+
if (block.type === "toolCall") {
|
|
755
|
+
const tc = block as ToolCallContent;
|
|
756
|
+
const result = toolResults?.get(tc.toolCallId);
|
|
757
|
+
const duration = toolCallDurations?.get(tc.toolCallId);
|
|
758
|
+
return <ToolCallBlock block={tc} result={result} duration={duration} cwd={cwd} />;
|
|
759
|
+
}
|
|
760
|
+
return null;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
function TextBlock({ block, isStreaming, onSendMessage, renderVisualCodeBlocks, cwd }: { block: TextContent; isStreaming?: boolean; onSendMessage?: (content: string) => void; renderVisualCodeBlocks?: boolean; cwd?: string }) {
|
|
764
|
+
const displayText = stripReportUpdateFences(block.text);
|
|
765
|
+
const segments = parseShowWidgets(displayText);
|
|
766
|
+
const hasWidgets = segments.some((s) => s.type === "widget");
|
|
767
|
+
const hasReportUpdate = hasReportUpdateFence(block.text);
|
|
768
|
+
|
|
769
|
+
if (!hasWidgets) {
|
|
770
|
+
if (hasReportUpdate && !displayText.trim()) {
|
|
771
|
+
return <ReportUpdatePlaceholder isStreaming={isStreaming} />;
|
|
772
|
+
}
|
|
773
|
+
if (isStreaming && hasWidgetFence(displayText)) {
|
|
774
|
+
const text = segments
|
|
775
|
+
.filter((seg) => seg.type === "text")
|
|
776
|
+
.map((seg) => seg.content)
|
|
777
|
+
.join("\n\n");
|
|
778
|
+
return (
|
|
779
|
+
<>
|
|
780
|
+
{text && <TextBlockMarkdown text={text} onSendMessage={onSendMessage} renderVisualCodeBlocks={renderVisualCodeBlocks} cwd={cwd} />}
|
|
781
|
+
<WidgetLoadingPlaceholder />
|
|
782
|
+
</>
|
|
783
|
+
);
|
|
784
|
+
}
|
|
785
|
+
return <TextBlockMarkdown text={displayText} onSendMessage={onSendMessage} renderVisualCodeBlocks={renderVisualCodeBlocks} cwd={cwd} />;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
return (
|
|
789
|
+
<>
|
|
790
|
+
{segments.map((seg, i) =>
|
|
791
|
+
seg.type === "text" ? (
|
|
792
|
+
<TextBlockMarkdown key={i} text={seg.content} onSendMessage={onSendMessage} renderVisualCodeBlocks={renderVisualCodeBlocks} cwd={cwd} />
|
|
793
|
+
) : (
|
|
794
|
+
<WidgetRenderer
|
|
795
|
+
key={i}
|
|
796
|
+
code={seg.code}
|
|
797
|
+
isStreaming={!!seg.partial}
|
|
798
|
+
title={seg.title}
|
|
799
|
+
showOverlay={seg.showOverlay}
|
|
800
|
+
onSendMessage={onSendMessage}
|
|
801
|
+
/>
|
|
802
|
+
)
|
|
803
|
+
)}
|
|
804
|
+
</>
|
|
805
|
+
);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
function ReportUpdatePlaceholder({ isStreaming }: { isStreaming?: boolean }) {
|
|
809
|
+
return (
|
|
810
|
+
<div style={{
|
|
811
|
+
border: "1px solid var(--border)",
|
|
812
|
+
borderRadius: 6,
|
|
813
|
+
padding: "8px 10px",
|
|
814
|
+
background: "var(--bg-panel)",
|
|
815
|
+
color: "var(--text-muted)",
|
|
816
|
+
fontSize: 12,
|
|
817
|
+
}}>
|
|
818
|
+
{isStreaming ? "Updating analysis report..." : "Analysis report updated"}
|
|
819
|
+
</div>
|
|
820
|
+
);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
function TextBlockMarkdown({ text, onSendMessage, renderVisualCodeBlocks, cwd }: { text: string; onSendMessage?: (content: string) => void; renderVisualCodeBlocks?: boolean; cwd?: string }) {
|
|
824
|
+
const imagePaths = useMemo(() => extractLocalImagePreviewPaths(text, cwd), [cwd, text]);
|
|
825
|
+
return (
|
|
826
|
+
<div style={{ display: "flex", flexDirection: "column", gap: imagePaths.length > 0 ? 8 : 0 }}>
|
|
827
|
+
<MarkdownRenderer content={text} onWidgetSendMessage={onSendMessage} renderVisualCodeBlocks={renderVisualCodeBlocks} />
|
|
828
|
+
{imagePaths.length > 0 && <LocalImagePathPreviewGrid imagePaths={imagePaths} />}
|
|
829
|
+
</div>
|
|
830
|
+
);
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
function WidgetLoadingPlaceholder() {
|
|
834
|
+
return (
|
|
835
|
+
<div
|
|
836
|
+
style={{
|
|
837
|
+
position: "relative",
|
|
838
|
+
height: 88,
|
|
839
|
+
border: "1px solid var(--border)",
|
|
840
|
+
borderRadius: 6,
|
|
841
|
+
overflow: "hidden",
|
|
842
|
+
background: "var(--bg-panel)",
|
|
843
|
+
}}
|
|
844
|
+
>
|
|
845
|
+
<div className="widget-shimmer" style={{ position: "absolute", inset: 0 }} />
|
|
846
|
+
</div>
|
|
847
|
+
);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
function ThinkingBlock({ block, duration }: { block: ThinkingContent; duration?: number }) {
|
|
851
|
+
const [expanded, setExpanded] = useState(false);
|
|
852
|
+
return (
|
|
853
|
+
<div
|
|
854
|
+
style={{
|
|
855
|
+
border: "1px solid var(--border)",
|
|
856
|
+
borderRadius: 6,
|
|
857
|
+
overflow: "hidden",
|
|
858
|
+
fontSize: 13,
|
|
859
|
+
}}
|
|
860
|
+
>
|
|
861
|
+
<button
|
|
862
|
+
onClick={() => setExpanded((v) => !v)}
|
|
863
|
+
style={{
|
|
864
|
+
display: "flex",
|
|
865
|
+
alignItems: "center",
|
|
866
|
+
gap: 6,
|
|
867
|
+
width: "100%",
|
|
868
|
+
padding: "6px 10px",
|
|
869
|
+
background: "var(--bg-panel)",
|
|
870
|
+
border: "none",
|
|
871
|
+
color: "var(--text-muted)",
|
|
872
|
+
cursor: "pointer",
|
|
873
|
+
fontSize: 12,
|
|
874
|
+
textAlign: "left",
|
|
875
|
+
}}
|
|
876
|
+
>
|
|
877
|
+
<span>Thinking</span>
|
|
878
|
+
{duration !== undefined && (
|
|
879
|
+
<span style={{ marginLeft: "auto", fontSize: 11, color: "var(--text-dim)", fontVariantNumeric: "tabular-nums" }}>{duration}s</span>
|
|
880
|
+
)}
|
|
881
|
+
</button>
|
|
882
|
+
{expanded && (
|
|
883
|
+
<div
|
|
884
|
+
style={{
|
|
885
|
+
padding: "8px 10px",
|
|
886
|
+
color: "var(--text-muted)",
|
|
887
|
+
fontSize: 12,
|
|
888
|
+
lineHeight: 1.6,
|
|
889
|
+
whiteSpace: "pre-wrap",
|
|
890
|
+
background: "var(--bg-panel)",
|
|
891
|
+
borderTop: "1px solid var(--border)",
|
|
892
|
+
}}
|
|
893
|
+
>
|
|
894
|
+
{block.thinking}
|
|
895
|
+
</div>
|
|
896
|
+
)}
|
|
897
|
+
</div>
|
|
898
|
+
);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
function ToolCallBlock({ block, result, duration, cwd }: { block: ToolCallContent; result?: ToolResultMessage; duration?: number; cwd?: string }) {
|
|
903
|
+
const [expanded, setExpanded] = useState(false);
|
|
904
|
+
const inputStr = JSON.stringify(block.input, null, 2);
|
|
905
|
+
|
|
906
|
+
// Result display
|
|
907
|
+
const resultText = result
|
|
908
|
+
? result.content.filter((b): b is { type: "text"; text: string } => b.type === "text").map((b) => b.text).join("\n")
|
|
909
|
+
: null;
|
|
910
|
+
const resultImages = result
|
|
911
|
+
? result.content.filter((b): b is ImageContent => b.type === "image")
|
|
912
|
+
: [];
|
|
913
|
+
const displayResultText = visibleToolResultText(resultText, resultImages.length > 0);
|
|
914
|
+
const resultIsEmpty = displayResultText === null ? false : (displayResultText.trim() === "(no output)" || displayResultText.trim() === "");
|
|
915
|
+
const isError = result?.isError ?? false;
|
|
916
|
+
const inputImagePaths = useMemo(() => extractLocalImagePreviewPaths(inputStr, cwd), [cwd, inputStr]);
|
|
917
|
+
const resultImagePaths = useMemo(() => extractLocalImagePreviewPaths(displayResultText, cwd), [cwd, displayResultText]);
|
|
918
|
+
const collapsedPathPreviews = resultImagePaths.length > 0 ? resultImagePaths : inputImagePaths;
|
|
919
|
+
|
|
920
|
+
return (
|
|
921
|
+
<div
|
|
922
|
+
style={{
|
|
923
|
+
borderRadius: 7,
|
|
924
|
+
overflow: "hidden",
|
|
925
|
+
fontSize: 12,
|
|
926
|
+
border: isError ? "1px solid rgba(248,113,113,0.45)" : "1px solid rgba(34,197,94,0.25)",
|
|
927
|
+
background: isError ? "rgba(248,113,113,0.05)" : "rgba(34,197,94,0.04)",
|
|
928
|
+
}}
|
|
929
|
+
>
|
|
930
|
+
{/* ── Tool call header ── */}
|
|
931
|
+
<button
|
|
932
|
+
onClick={() => setExpanded((v) => !v)}
|
|
933
|
+
style={{
|
|
934
|
+
display: "flex",
|
|
935
|
+
alignItems: "center",
|
|
936
|
+
gap: 7,
|
|
937
|
+
width: "100%",
|
|
938
|
+
padding: "6px 10px",
|
|
939
|
+
background: "none",
|
|
940
|
+
border: "none",
|
|
941
|
+
color: "var(--text-muted)",
|
|
942
|
+
cursor: "pointer",
|
|
943
|
+
fontSize: 12,
|
|
944
|
+
textAlign: "left",
|
|
945
|
+
minWidth: 0,
|
|
946
|
+
}}
|
|
947
|
+
>
|
|
948
|
+
<span style={{ color: isError ? "#f87171" : "#16a34a", fontFamily: "var(--font-mono)", fontWeight: 600, fontSize: 11, flexShrink: 0 }}>
|
|
949
|
+
{block.toolName}
|
|
950
|
+
</span>
|
|
951
|
+
<span style={{ color: "var(--text-dim)", fontFamily: "var(--font-mono)", fontSize: 11, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flex: 1, minWidth: 0 }}>
|
|
952
|
+
{getToolPreview(block)}
|
|
953
|
+
</span>
|
|
954
|
+
{duration !== undefined && (
|
|
955
|
+
<span style={{ fontSize: 11, color: "var(--text-dim)", flexShrink: 0, fontVariantNumeric: "tabular-nums" }}>{duration}s</span>
|
|
956
|
+
)}
|
|
957
|
+
<svg width="10" height="10" viewBox="0 0 10 10" fill="none" stroke="var(--text-dim)" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" style={{ flexShrink: 0, transform: expanded ? "rotate(180deg)" : "none", transition: "transform 0.15s" }}>
|
|
958
|
+
<polyline points="2 3.5 5 6.5 8 3.5" />
|
|
959
|
+
</svg>
|
|
960
|
+
</button>
|
|
961
|
+
|
|
962
|
+
{!expanded && (resultImages.length > 0 || collapsedPathPreviews.length > 0) && (
|
|
963
|
+
<div
|
|
964
|
+
style={{
|
|
965
|
+
padding: "0 10px 10px",
|
|
966
|
+
background: isError ? "rgba(248,113,113,0.04)" : "rgba(34,197,94,0.02)",
|
|
967
|
+
}}
|
|
968
|
+
>
|
|
969
|
+
{resultImages.length > 0 && <ImagePreviewGrid images={resultImages} maxHeight={280} />}
|
|
970
|
+
{collapsedPathPreviews.length > 0 && <LocalImagePathPreviewGrid imagePaths={collapsedPathPreviews} maxHeight={280} />}
|
|
971
|
+
</div>
|
|
972
|
+
)}
|
|
973
|
+
|
|
974
|
+
{/* ── Expanded: input args ── */}
|
|
975
|
+
{expanded && (
|
|
976
|
+
<pre
|
|
977
|
+
style={{
|
|
978
|
+
margin: 0,
|
|
979
|
+
padding: "8px 10px",
|
|
980
|
+
color: "var(--text-muted)",
|
|
981
|
+
fontSize: 12,
|
|
982
|
+
lineHeight: 1.5,
|
|
983
|
+
overflow: "auto",
|
|
984
|
+
background: "var(--bg-subtle)",
|
|
985
|
+
borderTop: isError ? "1px solid rgba(248,113,113,0.25)" : "1px solid rgba(34,197,94,0.2)",
|
|
986
|
+
whiteSpace: "pre-wrap",
|
|
987
|
+
wordBreak: "break-all",
|
|
988
|
+
}}
|
|
989
|
+
>
|
|
990
|
+
{inputStr}
|
|
991
|
+
</pre>
|
|
992
|
+
)}
|
|
993
|
+
|
|
994
|
+
{/* ── Paired result — only shown when expanded ── */}
|
|
995
|
+
{expanded && result && (
|
|
996
|
+
<PairedResult
|
|
997
|
+
text={displayResultText ?? ""}
|
|
998
|
+
isEmpty={resultIsEmpty}
|
|
999
|
+
isError={isError}
|
|
1000
|
+
images={resultImages}
|
|
1001
|
+
imagePaths={uniqueImagePaths([...resultImagePaths, ...inputImagePaths])}
|
|
1002
|
+
/>
|
|
1003
|
+
)}
|
|
1004
|
+
</div>
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
function PairedResult({ text, isEmpty, isError, images, imagePaths }: {
|
|
1009
|
+
text: string;
|
|
1010
|
+
isEmpty: boolean;
|
|
1011
|
+
isError: boolean;
|
|
1012
|
+
images: ImageContent[];
|
|
1013
|
+
imagePaths: string[];
|
|
1014
|
+
}) {
|
|
1015
|
+
const hasText = !isEmpty || text.trim().length > 0;
|
|
1016
|
+
return (
|
|
1017
|
+
<div
|
|
1018
|
+
style={{
|
|
1019
|
+
borderTop: `1px solid ${isError ? "rgba(248,113,113,0.3)" : "rgba(34,197,94,0.15)"}`,
|
|
1020
|
+
background: isError ? "rgba(248,113,113,0.04)" : "var(--bg-subtle)",
|
|
1021
|
+
}}
|
|
1022
|
+
>
|
|
1023
|
+
{images.length > 0 && (
|
|
1024
|
+
<div style={{ padding: "10px 10px 0", background: "var(--bg)" }}>
|
|
1025
|
+
<ImagePreviewGrid images={images} />
|
|
1026
|
+
</div>
|
|
1027
|
+
)}
|
|
1028
|
+
{imagePaths.length > 0 && (
|
|
1029
|
+
<div style={{ padding: "10px 10px 0", background: "var(--bg)" }}>
|
|
1030
|
+
<LocalImagePathPreviewGrid imagePaths={imagePaths} />
|
|
1031
|
+
</div>
|
|
1032
|
+
)}
|
|
1033
|
+
{hasText && (
|
|
1034
|
+
<pre
|
|
1035
|
+
style={{
|
|
1036
|
+
margin: 0,
|
|
1037
|
+
padding: "8px 10px",
|
|
1038
|
+
color: isError ? "#f87171" : (isEmpty ? "var(--text-dim)" : "var(--text-muted)"),
|
|
1039
|
+
fontSize: 12,
|
|
1040
|
+
lineHeight: 1.5,
|
|
1041
|
+
overflow: "auto",
|
|
1042
|
+
maxHeight: 400,
|
|
1043
|
+
background: "var(--bg)",
|
|
1044
|
+
whiteSpace: "pre-wrap",
|
|
1045
|
+
wordBreak: "break-all",
|
|
1046
|
+
fontStyle: isEmpty ? "italic" : "normal",
|
|
1047
|
+
opacity: isEmpty ? 0.6 : 1,
|
|
1048
|
+
}}
|
|
1049
|
+
>
|
|
1050
|
+
{isEmpty ? "(no output)" : text}
|
|
1051
|
+
</pre>
|
|
1052
|
+
)}
|
|
1053
|
+
</div>
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
|
|
1058
|
+
function getToolPreview(block: ToolCallContent): string {
|
|
1059
|
+
const input = block.input;
|
|
1060
|
+
if (!input || typeof input !== "object") return "";
|
|
1061
|
+
const keys = Object.keys(input);
|
|
1062
|
+
if (keys.length === 0) return "";
|
|
1063
|
+
|
|
1064
|
+
// Common tool input patterns
|
|
1065
|
+
if ("command" in input) return String(input.command).slice(0, 120);
|
|
1066
|
+
if ("path" in input) return String(input.path).slice(0, 120);
|
|
1067
|
+
if ("file_path" in input) return String(input.file_path).slice(0, 120);
|
|
1068
|
+
if ("pattern" in input) return String(input.pattern).slice(0, 120);
|
|
1069
|
+
if ("query" in input) return String(input.query).slice(0, 120);
|
|
1070
|
+
|
|
1071
|
+
const first = input[keys[0]];
|
|
1072
|
+
return String(first).slice(0, 120);
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
function formatUsage(usage: {
|
|
1076
|
+
input: number;
|
|
1077
|
+
output: number;
|
|
1078
|
+
cacheRead: number;
|
|
1079
|
+
cacheWrite: number;
|
|
1080
|
+
cost: { total: number };
|
|
1081
|
+
}): string {
|
|
1082
|
+
const parts = [];
|
|
1083
|
+
if (usage.input) parts.push(`${usage.input.toLocaleString()} in`);
|
|
1084
|
+
if (usage.output) parts.push(`${usage.output.toLocaleString()} out`);
|
|
1085
|
+
if (usage.cacheRead) parts.push(`${usage.cacheRead.toLocaleString()} cache`);
|
|
1086
|
+
if (usage.cost?.total) parts.push(`$${usage.cost.total.toFixed(4)}`);
|
|
1087
|
+
return parts.join(" · ");
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
|
|
1091
|
+
|
|
1092
|
+
function CustomMessageView({ message, showTimestamp }: {
|
|
1093
|
+
message: CustomMessage;
|
|
1094
|
+
showTimestamp?: boolean;
|
|
1095
|
+
}) {
|
|
1096
|
+
if (!message.display) return null;
|
|
1097
|
+
|
|
1098
|
+
const time = showTimestamp ? formatTime(message.timestamp) : null;
|
|
1099
|
+
const content = typeof message.content === "string"
|
|
1100
|
+
? message.content
|
|
1101
|
+
: message.content.filter((b): b is TextContent => b.type === "text").map((b) => b.text).join("\n");
|
|
1102
|
+
|
|
1103
|
+
const isSubagentNotify = message.customType === "subagent-notify";
|
|
1104
|
+
const bgTaskMatch = content.match(/^Background task (completed|failed|paused):\s*\*\*(.+?)\*\*/);
|
|
1105
|
+
const statusIcon = bgTaskMatch
|
|
1106
|
+
? (bgTaskMatch[1] === "completed" ? "✅" : bgTaskMatch[1] === "failed" ? "❌" : "⏸")
|
|
1107
|
+
: isSubagentNotify ? "🤖" : "ℹ";
|
|
1108
|
+
|
|
1109
|
+
return (
|
|
1110
|
+
<div style={{ marginBottom: 12 }}>
|
|
1111
|
+
<div
|
|
1112
|
+
style={{
|
|
1113
|
+
padding: "8px 14px",
|
|
1114
|
+
borderRadius: 8,
|
|
1115
|
+
border: `1px solid ${isSubagentNotify ? "rgba(99,102,241,0.25)" : "var(--border)"}`,
|
|
1116
|
+
background: isSubagentNotify ? "rgba(99,102,241,0.05)" : "var(--bg-panel)",
|
|
1117
|
+
fontSize: 13,
|
|
1118
|
+
lineHeight: 1.6,
|
|
1119
|
+
color: "var(--text-muted)",
|
|
1120
|
+
}}
|
|
1121
|
+
>
|
|
1122
|
+
<div style={{ display: "flex", alignItems: "flex-start", gap: 8 }}>
|
|
1123
|
+
<span style={{ flexShrink: 0, fontSize: 14 }}>{statusIcon}</span>
|
|
1124
|
+
<div style={{ flex: 1, minWidth: 0 }}>
|
|
1125
|
+
<MarkdownRenderer content={content} style={{ fontSize: 13 }} />
|
|
1126
|
+
</div>
|
|
1127
|
+
</div>
|
|
1128
|
+
</div>
|
|
1129
|
+
{(time || bgTaskMatch) && (
|
|
1130
|
+
<div style={{ display: "flex", alignItems: "center", justifyContent: "flex-end", gap: 6, marginTop: 3 }}>
|
|
1131
|
+
{bgTaskMatch && (
|
|
1132
|
+
<span style={{ fontSize: 10, color: "var(--text-dim)" }}>
|
|
1133
|
+
{bgTaskMatch[2]}
|
|
1134
|
+
</span>
|
|
1135
|
+
)}
|
|
1136
|
+
{time && <span style={{ fontSize: 10, color: "var(--text-dim)" }}>{time}</span>}
|
|
1137
|
+
</div>
|
|
1138
|
+
)}
|
|
1139
|
+
</div>
|
|
1140
|
+
);
|
|
1141
|
+
}
|