chat-js 1.0.0-alpha.7 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/dist/index.js +7487 -6859
- package/package.json +2 -2
- package/templates/chat-app/AGENTS.md +1 -1
- package/templates/chat-app/agent/agent.ts +0 -2
- package/templates/chat-app/agent/hooks/followup-suggestions.ts +1 -1
- package/templates/chat-app/agent/hooks/projects.ts +1 -1
- package/templates/chat-app/agent/hooks/search.ts +1 -1
- package/templates/chat-app/agent/instructions/projects.ts +1 -1
- package/templates/chat-app/agent/tools/mcp.ts +1 -1
- package/templates/chat-app/app/(auth)/device-login/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/api/files/upload/route.ts +1 -1
- package/templates/chat-app/app/(chat)/chat/{[id] → [chatId]}/page.tsx +4 -4
- package/templates/chat-app/app/(chat)/project/[projectId]/chat/[chatId]/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/project/[projectId]/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/settings/connectors/[connectorId]/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/settings/connectors/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/settings/models/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/share/[id]/page.tsx +1 -1
- package/templates/chat-app/app/api/agent-conversations/route.test.ts +5 -5
- package/templates/chat-app/app/api/agent-conversations/route.ts +2 -2
- package/templates/chat-app/app/api/agent-response-groups/route.test.ts +5 -5
- package/templates/chat-app/app/api/agent-response-groups/route.ts +1 -1
- package/templates/chat-app/app/api/eve/[...path]/route.test.ts +133 -4
- package/templates/chat-app/app/api/eve/[...path]/route.ts +175 -49
- package/templates/chat-app/app/api/eve-guest/route.ts +1 -1
- package/templates/chat-app/app/api/mcp/oauth/callback/route.ts +1 -1
- package/templates/chat-app/app/editor.css +0 -6
- package/templates/chat-app/app/layout.tsx +11 -18
- package/templates/chat-app/app/opengraph-image.png +0 -0
- package/templates/chat-app/chat.config.ts +0 -44
- package/templates/chat-app/chatjs/core/chat/compose.ts +4 -4
- package/templates/chat-app/chatjs/core/chat/contracts.ts +6 -6
- package/templates/chat-app/chatjs/core/gateway/runtime.ts +0 -7
- package/templates/chat-app/chatjs/core/installation/contracts.ts +0 -7
- package/templates/chat-app/chatjs/core/ui/slots.tsx +15 -5
- package/templates/chat-app/chatjs/generated/installed-auth-ui.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-auth.ts +4 -2
- package/templates/chat-app/chatjs/generated/installed-billing.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-chat-ui.ts +28 -24
- package/templates/chat-app/chatjs/generated/installed-chat.ts +12 -12
- package/templates/chat-app/chatjs/generated/installed-cleanup.ts +4 -4
- package/templates/chat-app/chatjs/generated/installed-instrumentation.ts +8 -2
- package/templates/chat-app/chatjs/generated/installed-layout.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-model-visibility.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-navigation.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-routers.ts +18 -19
- package/templates/chat-app/chatjs/generated/installed-session-profiles.ts +5 -3
- package/templates/chat-app/chatjs/generated/installed-sign-out.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-signed-out.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-uploads.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed.ts +2 -0
- package/templates/chat-app/chatjs/plugins/ai-titles/{chat.ts → chat-server.ts} +3 -1
- package/templates/chat-app/chatjs/plugins/ai-titles/generate-title.ts +7 -9
- package/templates/chat-app/chatjs/plugins/ai-titles/{chatjs.json → plugin.json} +3 -4
- package/templates/chat-app/chatjs/plugins/ai-titles/title-queries.ts +4 -4
- package/templates/chat-app/chatjs/plugins/attachment-uploads/{client-plugin.ts → chat-ui.ts} +1 -3
- package/templates/chat-app/chatjs/plugins/attachment-uploads/plugin.json +16 -0
- package/templates/chat-app/chatjs/plugins/credits/billing.ts +3 -1
- package/templates/chat-app/chatjs/plugins/credits/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/credits/{chatjs.json → plugin.json} +4 -13
- package/templates/chat-app/chatjs/plugins/credits/router.ts +4 -2
- package/templates/chat-app/chatjs/plugins/desktop/auth-form.tsx +3 -1
- package/templates/chat-app/chatjs/plugins/desktop/auth-server.ts +3 -1
- package/templates/chat-app/chatjs/plugins/desktop/{client-plugin.ts → layout-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/desktop/navigation.ts +3 -1
- package/templates/chat-app/chatjs/plugins/desktop/{chatjs.json → plugin.json} +4 -16
- package/templates/chat-app/chatjs/plugins/desktop/sign-out.ts +3 -1
- package/templates/chat-app/chatjs/plugins/feedback/chat-server.ts +13 -0
- package/templates/chat-app/chatjs/plugins/feedback/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/feedback/feedback-actions.tsx +4 -4
- package/templates/chat-app/chatjs/plugins/feedback/feedback-queries.ts +11 -11
- package/templates/chat-app/chatjs/plugins/feedback/feedback-schema.ts +2 -2
- package/templates/chat-app/chatjs/plugins/feedback/{chatjs.json → plugin.json} +5 -14
- package/templates/chat-app/chatjs/plugins/feedback/router.ts +9 -7
- package/templates/chat-app/chatjs/plugins/feedback/vote-message.ts +3 -6
- package/templates/chat-app/chatjs/plugins/followup-suggestions/{chat.ts → chat-server.ts} +3 -1
- package/templates/chat-app/chatjs/plugins/followup-suggestions/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/followup-suggestions/followup-queries.ts +2 -2
- package/templates/chat-app/chatjs/plugins/followup-suggestions/{chatjs.json → plugin.json} +5 -17
- package/templates/chat-app/chatjs/plugins/followup-suggestions/router.ts +8 -9
- package/templates/chat-app/chatjs/plugins/followup-suggestions/suggestions.tsx +2 -7
- package/templates/chat-app/chatjs/plugins/followup-suggestions/use-followups.ts +2 -2
- package/templates/chat-app/chatjs/plugins/guest-chat/cleanup.ts +1 -7
- package/templates/chat-app/chatjs/plugins/guest-chat/guest-auth.ts +1 -0
- package/templates/chat-app/chatjs/plugins/guest-chat/instrumentation.ts +6 -0
- package/templates/chat-app/chatjs/plugins/guest-chat/{chatjs.json → plugin.json} +6 -12
- package/templates/chat-app/chatjs/plugins/guest-chat/session-profile.ts +3 -1
- package/templates/chat-app/chatjs/plugins/guest-chat/signed-out.tsx +53 -24
- package/templates/chat-app/chatjs/plugins/image-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/image-viewer/plugin.json +11 -0
- package/templates/chat-app/chatjs/plugins/mcp/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/db/encrypted-text.ts +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/{chatjs.json → plugin.json} +5 -13
- package/templates/chat-app/chatjs/plugins/mcp/router.ts +4 -2
- package/templates/chat-app/chatjs/plugins/mcp/routes/connectors-page.tsx +4 -1
- package/templates/chat-app/chatjs/plugins/mcp/setup.ts +2 -2
- package/templates/chat-app/chatjs/plugins/mcp/ui/connectors-settings.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/ui/mcp-connect-dialog.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/ui/mcp-create-dialog.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/{mcp-env.ts → validate-env.ts} +2 -1
- package/templates/chat-app/chatjs/plugins/model-preferences/{client-plugin.ts → chat-ui.ts} +1 -3
- package/templates/chat-app/chatjs/plugins/model-preferences/model-row.tsx +3 -0
- package/templates/chat-app/chatjs/plugins/model-preferences/{use-model-preferences.ts → model-visibility.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/model-preferences/models-settings.tsx +1 -0
- package/templates/chat-app/chatjs/plugins/model-preferences/{chatjs.json → plugin.json} +5 -13
- package/templates/chat-app/chatjs/plugins/model-preferences/router.ts +5 -1
- package/templates/chat-app/chatjs/plugins/projects/{chat.ts → chat-server.ts} +3 -1
- package/templates/chat-app/chatjs/plugins/projects/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/projects/conversation-hook.ts +1 -1
- package/templates/chat-app/chatjs/plugins/projects/db/project-queries.ts +2 -2
- package/templates/chat-app/chatjs/plugins/projects/{chatjs.json → plugin.json} +5 -14
- package/templates/chat-app/chatjs/plugins/projects/router.ts +7 -7
- package/templates/chat-app/chatjs/plugins/projects/routes/project-page.tsx +10 -1
- package/templates/chat-app/chatjs/plugins/projects/ui/chat-contributions.tsx +3 -3
- package/templates/chat-app/chatjs/plugins/projects/ui/delete-project-dialog.tsx +0 -3
- package/templates/chat-app/chatjs/plugins/projects/ui/eve-move-project-dialog.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/projects/ui/project-icon-picker.tsx +1 -0
- package/templates/chat-app/chatjs/plugins/projects/ui/sidebar-projects.tsx +12 -11
- package/templates/chat-app/chatjs/plugins/search/{chat.ts → chat-server.ts} +8 -6
- package/templates/chat-app/chatjs/plugins/search/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/search/{chatjs.json → plugin.json} +5 -14
- package/templates/chat-app/chatjs/plugins/search/router.ts +4 -2
- package/templates/chat-app/chatjs/plugins/search/search-backfill.ts +4 -4
- package/templates/chat-app/chatjs/plugins/search/search-chats.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/search/search-hook.ts +2 -2
- package/templates/chat-app/chatjs/plugins/search/search-queries.ts +13 -13
- package/templates/chat-app/chatjs/plugins/search/search-results-view.tsx +2 -2
- package/templates/chat-app/chatjs/plugins/search/search-schema.ts +3 -3
- package/templates/chat-app/chatjs/plugins/sharing/{chat.ts → chat-server.ts} +3 -1
- package/templates/chat-app/chatjs/plugins/sharing/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/sharing/{chatjs.json → plugin.json} +5 -14
- package/templates/chat-app/chatjs/plugins/sharing/router.ts +4 -2
- package/templates/chat-app/chatjs/plugins/sharing/ui/chat-contributions.tsx +9 -11
- package/templates/chat-app/chatjs/plugins/sharing/ui/share-button.tsx +6 -6
- package/templates/chat-app/chatjs/plugins/sharing/ui/share-dialog.tsx +9 -9
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/plugin.json +12 -0
- package/templates/chat-app/chatjs/plugins/streamdown-math/chat-ui.ts +11 -0
- package/templates/chat-app/chatjs/plugins/streamdown-math/plugin.json +6 -0
- package/templates/chat-app/chatjs/plugins/streamdown-mermaid/chat-ui.ts +10 -0
- package/templates/chat-app/chatjs/plugins/streamdown-mermaid/plugin.json +6 -0
- package/templates/chat-app/chatjs/plugins/video-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/video-viewer/plugin.json +10 -0
- package/templates/chat-app/chatjs/providers/gateway.ts +49 -55
- package/templates/chat-app/chatjs/tools/attach-workspace-file/tool.ts +2 -2
- package/templates/chat-app/chatjs/tools/generate-image/tool.test.ts +3 -14
- package/templates/chat-app/components/ai-elements/response.tsx +16 -15
- package/templates/chat-app/components/auth-form-view.tsx +35 -43
- package/templates/chat-app/components/chat/chat-composer.tsx +90 -27
- package/templates/chat-app/components/chat/chat-conversation-screen.tsx +3 -3
- package/templates/chat-app/components/chat/chat-navigation.tsx +11 -1
- package/templates/chat-app/components/chat/chat-sidebar.tsx +8 -9
- package/templates/chat-app/components/chat/chat-transcript.tsx +52 -23
- package/templates/chat-app/components/chat-slots.tsx +1 -1
- package/templates/chat-app/components/composer/composer-menu.tsx +5 -4
- package/templates/chat-app/components/composer/prompt-form.tsx +7 -1
- package/templates/chat-app/components/eve/eve-chat-error.tsx +12 -2
- package/templates/chat-app/components/eve/eve-chat-header.tsx +5 -7
- package/templates/chat-app/components/eve/eve-chat-page.tsx +9 -9
- package/templates/chat-app/components/eve/eve-composer.tsx +16 -5
- package/templates/chat-app/components/eve/eve-conversation.tsx +342 -209
- package/templates/chat-app/components/eve/eve-creation-recovery.tsx +53 -3
- package/templates/chat-app/components/eve/eve-deletion-provider.tsx +10 -12
- package/templates/chat-app/components/eve/eve-history-list.tsx +4 -9
- package/templates/chat-app/components/eve/eve-logical-context.tsx +1 -0
- package/templates/chat-app/components/eve/eve-logical-navigation.tsx +3 -3
- package/templates/chat-app/components/eve/eve-message-content.tsx +252 -0
- package/templates/chat-app/components/eve/eve-message-part.tsx +13 -58
- package/templates/chat-app/components/eve/eve-pending-input.tsx +82 -5
- package/templates/chat-app/components/eve/eve-runtime-provider.tsx +74 -15
- package/templates/chat-app/components/eve/use-eve-composer-draft.ts +64 -26
- package/templates/chat-app/components/eve/use-eve-fork.ts +14 -16
- package/templates/chat-app/components/eve/use-logical-commands.ts +3 -3
- package/templates/chat-app/components/eve/use-new-eve-conversation.tsx +42 -7
- package/templates/chat-app/components/model-selection-indicator.tsx +12 -10
- package/templates/chat-app/components/model-selector-view.tsx +211 -186
- package/templates/chat-app/components/new-chat-button.tsx +1 -1
- package/templates/chat-app/components/parallel-responses/model-picker.tsx +5 -1
- package/templates/chat-app/components/parallel-responses/responses.tsx +2 -2
- package/templates/chat-app/components/settings/settings-nav.tsx +1 -1
- package/templates/chat-app/components/settings/settings-navigation-link.tsx +1 -0
- package/templates/chat-app/components/sidebar-top-row.tsx +1 -1
- package/templates/chat-app/components/ui/sidebar.tsx +1 -1
- package/templates/chat-app/components/ui/trace.tsx +1 -1
- package/templates/chat-app/hooks/use-auto-focus.ts +12 -13
- package/templates/chat-app/integrations/routers.ts +1 -1
- package/templates/chat-app/lib/ai/active-gateway.ts +0 -9
- package/templates/chat-app/lib/ai/app-models.test.ts +0 -4
- package/templates/chat-app/lib/ai/app-models.ts +11 -6
- package/templates/chat-app/lib/ai/gateways/registry.ts +4 -31
- package/templates/chat-app/lib/ai/model-catalog.ts +50 -0
- package/templates/chat-app/lib/ai/models.ts +4 -39
- package/templates/chat-app/lib/ai/providers.ts +2 -16
- package/templates/chat-app/lib/chat-after-create.test.ts +1 -1
- package/templates/chat-app/lib/chat-after-create.ts +1 -1
- package/templates/chat-app/lib/config-schema.ts +0 -96
- package/templates/chat-app/lib/db/eve-creation-failure.ts +3 -3
- package/templates/chat-app/lib/db/eve-current-copy.ts +11 -11
- package/templates/chat-app/lib/db/eve-deletion.ts +19 -19
- package/templates/chat-app/lib/db/eve-dispatch.ts +115 -18
- package/templates/chat-app/lib/db/eve-file-purge.ts +4 -4
- package/templates/chat-app/lib/db/eve-files.ts +13 -13
- package/templates/chat-app/lib/db/eve-queries.ts +28 -43
- package/templates/chat-app/lib/db/eve-response-groups.ts +30 -112
- package/templates/chat-app/lib/db/eve-subagents.ts +8 -8
- package/templates/chat-app/lib/db/eve-title.ts +2 -2
- package/templates/chat-app/lib/db/eve-workspace-deletion.ts +3 -3
- package/templates/chat-app/lib/db/eve-workspace-turns.ts +37 -5
- package/templates/chat-app/lib/db/eve-workspaces.ts +3 -3
- package/templates/chat-app/lib/db/migrations/0029_branch_identifiers.sql +23 -0
- package/templates/chat-app/lib/db/migrations/meta/0029_snapshot.json +2547 -0
- package/templates/chat-app/lib/db/migrations/meta/_journal.json +7 -0
- package/templates/chat-app/lib/db/schema.ts +19 -25
- package/templates/chat-app/lib/devtools-disabled.ts +1 -0
- package/templates/chat-app/lib/eve/completed-copy-source.test.ts +12 -2
- package/templates/chat-app/lib/eve/completed-copy-source.ts +5 -2
- package/templates/chat-app/lib/eve/contracts.test.ts +5 -5
- package/templates/chat-app/lib/eve/contracts.ts +1 -1
- package/templates/chat-app/lib/eve/conversation-scope.test.ts +2 -2
- package/templates/chat-app/lib/eve/conversation-scope.ts +4 -4
- package/templates/chat-app/lib/eve/create-conversation-operation.test.ts +1 -1
- package/templates/chat-app/lib/eve/create-response-group.test.ts +3 -3
- package/templates/chat-app/lib/eve/delete-local-conversation.ts +3 -3
- package/templates/chat-app/lib/eve/generated-files.test.ts +1 -1
- package/templates/chat-app/lib/eve/generated-files.ts +2 -2
- package/templates/chat-app/lib/eve/logical-chat.test.ts +17 -17
- package/templates/chat-app/lib/eve/logical-chat.ts +27 -31
- package/templates/chat-app/lib/eve/logical-response-slots.ts +4 -7
- package/templates/chat-app/lib/eve/message-delivery.ts +1 -0
- package/templates/chat-app/lib/eve/model-selection.test.ts +47 -50
- package/templates/chat-app/lib/eve/model-selection.ts +5 -37
- package/templates/chat-app/lib/eve/pending-create.test.ts +46 -7
- package/templates/chat-app/lib/eve/pending-create.ts +36 -4
- package/templates/chat-app/lib/eve/persisted-wire-order.test.ts +2 -2
- package/templates/chat-app/lib/eve/prepare-deletion.ts +3 -3
- package/templates/chat-app/lib/eve/purge-local-resources.ts +3 -3
- package/templates/chat-app/lib/eve/reconcile-workspace-turn.ts +2 -2
- package/templates/chat-app/lib/eve/request-policy.ts +1 -0
- package/templates/chat-app/lib/eve/resolve-creation-request.ts +1 -1
- package/templates/chat-app/lib/eve/response-group-contracts.ts +1 -1
- package/templates/chat-app/lib/eve/response-group-lineage.test.ts +12 -12
- package/templates/chat-app/lib/eve/response-group-lineage.ts +21 -24
- package/templates/chat-app/lib/eve/response-group.test.ts +2 -2
- package/templates/chat-app/lib/eve/response-group.ts +1 -1
- package/templates/chat-app/lib/eve/response-model.ts +11 -1
- package/templates/chat-app/lib/eve/restore-message-attachments.test.ts +1 -1
- package/templates/chat-app/lib/eve/restore-message-attachments.ts +3 -3
- package/templates/chat-app/lib/eve/retire-session.ts +3 -3
- package/templates/chat-app/lib/eve/steer-rejected.ts +7 -0
- package/templates/chat-app/lib/eve/tool-cost.test.ts +18 -6
- package/templates/chat-app/lib/eve/tool-cost.ts +10 -18
- package/templates/chat-app/lib/eve/workspace-turn-evidence.test.ts +27 -0
- package/templates/chat-app/lib/eve/workspace-turn-evidence.ts +20 -13
- package/templates/chat-app/oxfmt.config.ts +0 -2
- package/templates/chat-app/package.json +7 -9
- package/templates/chat-app/playwright.config.ts +5 -1
- package/templates/chat-app/proxy.ts +2 -4
- package/templates/chat-app/scripts/agent-status.ts +6 -19
- package/templates/chat-app/scripts/build-eve.test.ts +56 -0
- package/templates/chat-app/scripts/build-eve.ts +12 -5
- package/templates/chat-app/scripts/check-env.ts +77 -73
- package/templates/chat-app/scripts/environment-validation-report.ts +1 -20
- package/templates/chat-app/scripts/installed-environment-validation.ts +14 -15
- package/templates/chat-app/trpc/init.ts +2 -0
- package/templates/chat-app/trpc/react.tsx +2 -2
- package/templates/chat-app/trpc/routers/_app.test.ts +56 -0
- package/templates/chat-app/trpc/routers/_app.ts +12 -11
- package/templates/chat-app/trpc/routers/eve.router.ts +2 -2
- package/templates/electron/forge.config.ts +1 -19
- package/templates/electron/scripts/write-branding.ts +1 -5
- package/templates/chat-app/app/privacy/page.tsx +0 -153
- package/templates/chat-app/app/terms/page.tsx +0 -270
- package/templates/chat-app/chatjs/core/installation/plugin.ts +0 -13
- package/templates/chat-app/chatjs/plugins/attachment-uploads/chatjs.json +0 -22
- package/templates/chat-app/chatjs/plugins/credits/server-plugin.ts +0 -5
- package/templates/chat-app/chatjs/plugins/feedback/chat.ts +0 -13
- package/templates/chat-app/chatjs/plugins/feedback/server-plugin.ts +0 -8
- package/templates/chat-app/chatjs/plugins/followup-suggestions/server-plugin.ts +0 -8
- package/templates/chat-app/chatjs/plugins/guest-chat/server-plugin.ts +0 -12
- package/templates/chat-app/chatjs/plugins/image-viewer/chatjs.json +0 -17
- package/templates/chat-app/chatjs/plugins/mcp/server-plugin.ts +0 -5
- package/templates/chat-app/chatjs/plugins/model-preferences/server-plugin.ts +0 -8
- package/templates/chat-app/chatjs/plugins/projects/server-plugin.ts +0 -8
- package/templates/chat-app/chatjs/plugins/search/server-plugin.ts +0 -5
- package/templates/chat-app/chatjs/plugins/sharing/server-plugin.ts +0 -5
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/chatjs.json +0 -18
- package/templates/chat-app/chatjs/plugins/video-viewer/chatjs.json +0 -16
- package/templates/chat-app/components/ai-elements/context-hover.radix.tsx +0 -15
- package/templates/chat-app/components/ai-elements/context-hover.tsx +0 -17
- package/templates/chat-app/components/ai-elements/context.tsx +0 -405
- package/templates/chat-app/components/composer/editor.css +0 -96
- package/templates/chat-app/components/lexical-chat-input.tsx +0 -276
- package/templates/chat-app/components/model-selection-indicator.radix.tsx +0 -17
- package/templates/chat-app/components/ui/resizable.tsx +0 -49
- package/templates/chat-app/lib/ai/gateways/fallback-models.ts +0 -29
- package/templates/chat-app/lib/ai/models.generated.ts +0 -4242
- package/templates/chat-app/lib/ai/usage-token-details.test.ts +0 -76
- package/templates/chat-app/lib/ai/usage-token-details.ts +0 -33
- package/templates/chat-app/lib/chat-route.ts +0 -18
- package/templates/chat-app/providers/parse-chat-id-from-pathname.test.ts +0 -126
- package/templates/chat-app/providers/parse-chat-id-from-pathname.ts +0 -51
- package/templates/chat-app/scripts/fetch-models.ts +0 -30
- package/templates/chat-app/scripts/gateway-snapshot-warning.test.ts +0 -9
- /package/templates/chat-app/chatjs/plugins/attachment-uploads/{integration.tsx → uploads.ts} +0 -0
|
@@ -39,20 +39,9 @@ vi.mock(
|
|
|
39
39
|
vi.mock("@/lib/eve/tool-image-context", () => ({
|
|
40
40
|
eveToolImageContext: { get: mocks.images },
|
|
41
41
|
}));
|
|
42
|
-
vi.mock(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
getActiveGateway: (): { fetchModels: typeof mocks.catalog } => ({
|
|
46
|
-
fetchModels: mocks.catalog,
|
|
47
|
-
}),
|
|
48
|
-
})
|
|
49
|
-
);
|
|
50
|
-
vi.mock(
|
|
51
|
-
"@/lib/ai/to-model-data",
|
|
52
|
-
(): { toModelData: (value: unknown) => unknown } => ({
|
|
53
|
-
toModelData: (value: unknown) => value,
|
|
54
|
-
})
|
|
55
|
-
);
|
|
42
|
+
vi.mock("@/lib/ai/model-catalog", () => ({
|
|
43
|
+
loadModelCatalog: mocks.catalog,
|
|
44
|
+
}));
|
|
56
45
|
vi.mock("@/lib/config", () => ({
|
|
57
46
|
config: {
|
|
58
47
|
ai: { tools: { image: { default: "test-image" } } },
|
|
@@ -2,31 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
import "streamdown/styles.css";
|
|
4
4
|
|
|
5
|
-
import React, { memo } from "react";
|
|
5
|
+
import React, { memo, useMemo } from "react";
|
|
6
6
|
import type { ComponentProps } from "react";
|
|
7
7
|
import { Streamdown } from "streamdown";
|
|
8
8
|
import { cn } from "@/lib/utils";
|
|
9
9
|
import { code } from "@streamdown/code";
|
|
10
|
-
import {
|
|
11
|
-
import { mermaid } from "@streamdown/mermaid";
|
|
12
|
-
|
|
13
|
-
const plugins = { code, math, mermaid };
|
|
10
|
+
import { useMarkdownPlugins } from "@/chatjs/core/ui/slots";
|
|
14
11
|
|
|
15
12
|
type ResponseProps = ComponentProps<typeof Streamdown>;
|
|
16
13
|
|
|
17
14
|
const ResponseComponent = ({
|
|
18
15
|
className,
|
|
19
16
|
...props
|
|
20
|
-
}: ResponseProps): React.JSX.Element =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
}: ResponseProps): React.JSX.Element => {
|
|
18
|
+
const markdown = useMarkdownPlugins();
|
|
19
|
+
const plugins = useMemo(() => ({ code, ...markdown }), [markdown]);
|
|
20
|
+
return (
|
|
21
|
+
<Streamdown
|
|
22
|
+
className={cn(
|
|
23
|
+
"w-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",
|
|
24
|
+
className
|
|
25
|
+
)}
|
|
26
|
+
plugins={plugins}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
30
31
|
|
|
31
32
|
const Response = memo(
|
|
32
33
|
ResponseComponent,
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
CardTitle,
|
|
9
9
|
} from "@/components/ui/card";
|
|
10
10
|
import { InternalLink } from "@/components/internal-link";
|
|
11
|
-
import { cn } from "@/lib/utils";
|
|
12
11
|
|
|
13
12
|
export const AuthFormView = ({
|
|
14
13
|
mode,
|
|
@@ -27,46 +26,39 @@ export const AuthFormView = ({
|
|
|
27
26
|
readonly children: ReactNode;
|
|
28
27
|
readonly className?: string;
|
|
29
28
|
}) => (
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
</Card>
|
|
66
|
-
<div className="text-muted-foreground [&_a]:hover:text-primary text-center text-xs text-balance [&_a]:underline [&_a]:underline-offset-4">
|
|
67
|
-
By clicking continue, you agree to our{" "}
|
|
68
|
-
<InternalLink href="/terms">Terms of Service</InternalLink> and{" "}
|
|
69
|
-
<InternalLink href="/privacy">Privacy Policy</InternalLink>.
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
29
|
+
<Card className={className}>
|
|
30
|
+
<CardHeader className="text-center">
|
|
31
|
+
<CardTitle className="text-xl">
|
|
32
|
+
{title ?? (mode === "login" ? "Welcome back" : "Create an account")}
|
|
33
|
+
</CardTitle>
|
|
34
|
+
<CardDescription>
|
|
35
|
+
{description ??
|
|
36
|
+
(mode === "login"
|
|
37
|
+
? "Sign in to your account"
|
|
38
|
+
: "Get started in seconds")}
|
|
39
|
+
</CardDescription>
|
|
40
|
+
</CardHeader>
|
|
41
|
+
<CardContent>
|
|
42
|
+
<div className="grid gap-6">
|
|
43
|
+
{children}
|
|
44
|
+
{footer ?? (
|
|
45
|
+
<div className="text-center text-sm">
|
|
46
|
+
{mode === "login"
|
|
47
|
+
? "Don't have an account? "
|
|
48
|
+
: "Already have an account? "}
|
|
49
|
+
<InternalLink
|
|
50
|
+
className="underline underline-offset-4"
|
|
51
|
+
href={
|
|
52
|
+
mode === "login"
|
|
53
|
+
? `/register?${new URLSearchParams(query)}`
|
|
54
|
+
: `/login?${new URLSearchParams(query)}`
|
|
55
|
+
}
|
|
56
|
+
>
|
|
57
|
+
{mode === "login" ? "Sign up" : "Sign in"}
|
|
58
|
+
</InternalLink>
|
|
59
|
+
</div>
|
|
60
|
+
)}
|
|
61
|
+
</div>
|
|
62
|
+
</CardContent>
|
|
63
|
+
</Card>
|
|
72
64
|
);
|
|
@@ -7,14 +7,16 @@ import {
|
|
|
7
7
|
InputGroup,
|
|
8
8
|
InputGroupAddon,
|
|
9
9
|
InputGroupButton,
|
|
10
|
+
InputGroupTextarea,
|
|
10
11
|
} from "@/components/ui/input-group";
|
|
11
12
|
import { ArrowUpIcon, Loader2Icon, SquareIcon } from "lucide-react";
|
|
12
13
|
|
|
13
14
|
import type { ChatStatus } from "ai";
|
|
14
15
|
|
|
15
|
-
import {
|
|
16
|
+
import { useAutoFocus } from "@/hooks/use-auto-focus";
|
|
17
|
+
import { useMounted } from "@/hooks/use-mounted";
|
|
16
18
|
|
|
17
|
-
import React from "react";
|
|
19
|
+
import React, { useLayoutEffect } from "react";
|
|
18
20
|
import type { ReadonlyReactNode } from "@/lib/readonly-react-node";
|
|
19
21
|
|
|
20
22
|
import { useIsMobile } from "@/hooks/use-mobile";
|
|
@@ -70,13 +72,31 @@ const ComposerAction = ({
|
|
|
70
72
|
);
|
|
71
73
|
};
|
|
72
74
|
|
|
75
|
+
const composerActionStatus = (
|
|
76
|
+
status: ChatStatus,
|
|
77
|
+
allowFollowUp: boolean | undefined,
|
|
78
|
+
hasDraft: boolean
|
|
79
|
+
): ChatStatus =>
|
|
80
|
+
status === "streaming" && allowFollowUp === true && hasDraft
|
|
81
|
+
? "ready"
|
|
82
|
+
: status;
|
|
83
|
+
|
|
84
|
+
const canSubmitDraft = (
|
|
85
|
+
status: ChatStatus,
|
|
86
|
+
hasDraft: boolean,
|
|
87
|
+
draftLength: number
|
|
88
|
+
): boolean =>
|
|
89
|
+
(status === "ready" || status === "error") &&
|
|
90
|
+
hasDraft &&
|
|
91
|
+
draftLength <= MAX_DRAFT_LENGTH;
|
|
92
|
+
|
|
73
93
|
/**
|
|
74
94
|
* A controlled composer for runtimes that own their own submission lifecycle.
|
|
75
95
|
*
|
|
76
96
|
* @param {string} draft Current text controlled by the runtime.
|
|
77
97
|
* @param {(draft: string) => void} onDraftChange Writes text changes back to the runtime.
|
|
78
98
|
* @param {() => void} onSubmit Submits the current draft.
|
|
79
|
-
* @param {boolean} disabled Disables
|
|
99
|
+
* @param {boolean} disabled Disables submission.
|
|
80
100
|
* @param {ChatStatus | undefined} status Runtime-owned status value.
|
|
81
101
|
* @param {(() => void) | undefined} onStop Cancels the active submission.
|
|
82
102
|
* @param {boolean | undefined} stopDisabled Runtime-owned stopDisabled value.
|
|
@@ -85,7 +105,9 @@ const ComposerAction = ({
|
|
|
85
105
|
* @param {ReadonlyReactNode | undefined} attachments Current attached files.
|
|
86
106
|
* @param {boolean | undefined} hasAttachments Runtime-owned hasAttachments value.
|
|
87
107
|
* @param {boolean | undefined} readOnly Runtime-owned readOnly value.
|
|
88
|
-
* @param {
|
|
108
|
+
* @param {boolean | undefined} allowDraftWhileBusy Allows typing during a submission without a Stop action.
|
|
109
|
+
* @param {boolean | undefined} allowSendWhileStreaming Switches Stop to Send when the draft contains text or files.
|
|
110
|
+
* @param {ComponentProps<"textarea">["onPaste"] | undefined} onPaste Runtime-owned onPaste value.
|
|
89
111
|
* @returns {React.JSX.Element} The composed message interface.
|
|
90
112
|
*/
|
|
91
113
|
export const ChatComposer = ({
|
|
@@ -101,6 +123,8 @@ export const ChatComposer = ({
|
|
|
101
123
|
attachments,
|
|
102
124
|
hasAttachments = false,
|
|
103
125
|
readOnly = false,
|
|
126
|
+
allowDraftWhileBusy = false,
|
|
127
|
+
allowSendWhileStreaming,
|
|
104
128
|
onPaste,
|
|
105
129
|
primitives = defaultPrimitives,
|
|
106
130
|
sendIcon,
|
|
@@ -110,7 +134,9 @@ export const ChatComposer = ({
|
|
|
110
134
|
readonly attachments?: ReadonlyReactNode;
|
|
111
135
|
readonly hasAttachments?: boolean;
|
|
112
136
|
readonly readOnly?: boolean;
|
|
113
|
-
readonly
|
|
137
|
+
readonly allowDraftWhileBusy?: boolean;
|
|
138
|
+
readonly allowSendWhileStreaming?: boolean;
|
|
139
|
+
readonly onPaste?: ComponentProps<"textarea">["onPaste"];
|
|
114
140
|
readonly draft: string;
|
|
115
141
|
readonly onDraftChange: (draft: string) => void;
|
|
116
142
|
readonly onSubmit: () => void;
|
|
@@ -122,14 +148,48 @@ export const ChatComposer = ({
|
|
|
122
148
|
readonly tools?: ReadonlyReactNode;
|
|
123
149
|
}): ReactJSX.Element => {
|
|
124
150
|
const isMobile = useIsMobile();
|
|
151
|
+
const mounted = useMounted();
|
|
125
152
|
const busy = status === "submitted" || status === "streaming";
|
|
126
|
-
const
|
|
153
|
+
const hasDraft = Boolean(draft.trim()) || hasAttachments;
|
|
154
|
+
const actionStatus = composerActionStatus(
|
|
155
|
+
status,
|
|
156
|
+
allowSendWhileStreaming,
|
|
157
|
+
hasDraft
|
|
158
|
+
);
|
|
159
|
+
const editorReadOnly = readOnly || (busy && !onStop && !allowDraftWhileBusy);
|
|
160
|
+
const inputRef = useAutoFocus(autoFocus && !editorReadOnly);
|
|
161
|
+
useLayoutEffect((): (() => void) | undefined => {
|
|
162
|
+
const input = inputRef.current;
|
|
163
|
+
if (!input || !draft || CSS.supports("field-sizing", "content")) {
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Clearing the explicit height lets shorter or newly unwrapped drafts shrink.
|
|
168
|
+
const fitDraft = (): void => {
|
|
169
|
+
input.style.height = "";
|
|
170
|
+
input.style.height = `${input.scrollHeight}px`;
|
|
171
|
+
};
|
|
172
|
+
fitDraft();
|
|
173
|
+
let width = input.offsetWidth;
|
|
174
|
+
let frame = 0;
|
|
175
|
+
const observer = new ResizeObserver(() => {
|
|
176
|
+
if (input.offsetWidth !== width) {
|
|
177
|
+
width = input.offsetWidth;
|
|
178
|
+
cancelAnimationFrame(frame);
|
|
179
|
+
frame = requestAnimationFrame(fitDraft);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
observer.observe(input);
|
|
183
|
+
return () => {
|
|
184
|
+
observer.disconnect();
|
|
185
|
+
cancelAnimationFrame(frame);
|
|
186
|
+
input.style.height = "";
|
|
187
|
+
};
|
|
188
|
+
}, [draft, inputRef]);
|
|
127
189
|
const canSend =
|
|
128
190
|
!disabled &&
|
|
129
191
|
!editorReadOnly &&
|
|
130
|
-
|
|
131
|
-
(Boolean(draft.trim()) || hasAttachments) &&
|
|
132
|
-
draft.length <= MAX_DRAFT_LENGTH;
|
|
192
|
+
canSubmitDraft(actionStatus, hasDraft, draft.length);
|
|
133
193
|
const submit = (): void => {
|
|
134
194
|
if (canSend) {
|
|
135
195
|
onSubmit();
|
|
@@ -138,7 +198,7 @@ export const ChatComposer = ({
|
|
|
138
198
|
return (
|
|
139
199
|
<PromptForm
|
|
140
200
|
primitives={primitives}
|
|
141
|
-
editable={!
|
|
201
|
+
editable={!editorReadOnly}
|
|
142
202
|
onSubmit={(event) => {
|
|
143
203
|
event.preventDefault();
|
|
144
204
|
submit();
|
|
@@ -149,7 +209,7 @@ export const ChatComposer = ({
|
|
|
149
209
|
<ComposerAction
|
|
150
210
|
primitives={primitives}
|
|
151
211
|
sendIcon={sendIcon}
|
|
152
|
-
status={status}
|
|
212
|
+
status={canSend ? actionStatus : status}
|
|
153
213
|
onStop={onStop}
|
|
154
214
|
stopDisabled={stopDisabled}
|
|
155
215
|
canSend={canSend}
|
|
@@ -163,34 +223,37 @@ export const ChatComposer = ({
|
|
|
163
223
|
) : undefined
|
|
164
224
|
}
|
|
165
225
|
>
|
|
166
|
-
<
|
|
226
|
+
<InputGroupTextarea
|
|
167
227
|
aria-label="Message"
|
|
168
|
-
|
|
169
|
-
className="max-h-[max(35svh,5rem)] min-h-[60px] overflow-y-scroll sm:min-h-[80px]"
|
|
228
|
+
className="max-h-[max(35svh,5rem)] min-h-[60px] flex-none [scrollbar-width:thin] overflow-y-auto px-2.5 pt-2.5 pb-[5px] leading-normal [tab-size:1] placeholder:text-base placeholder-shown:pt-2 placeholder-shown:pl-3 sm:min-h-[80px] md:text-[15px]"
|
|
170
229
|
data-testid="multimodal-input"
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
) => {
|
|
230
|
+
dir="auto"
|
|
231
|
+
ref={inputRef}
|
|
232
|
+
rows={1}
|
|
233
|
+
spellCheck
|
|
234
|
+
value={draft}
|
|
235
|
+
onChange={(event) => {
|
|
236
|
+
onDraftChange(event.currentTarget.value);
|
|
237
|
+
}}
|
|
238
|
+
onKeyDown={(event) => {
|
|
177
239
|
if (
|
|
178
|
-
event.
|
|
179
|
-
!
|
|
240
|
+
event.key === "Enter" &&
|
|
241
|
+
!event.nativeEvent.isComposing &&
|
|
242
|
+
// oxlint-disable-next-line typescript/no-deprecated -- WebKit clears isComposing before the IME confirmation keydown; 229 still identifies it.
|
|
243
|
+
event.nativeEvent.keyCode !== 229 &&
|
|
244
|
+
(isMobile ? event.ctrlKey : !event.shiftKey)
|
|
180
245
|
) {
|
|
181
|
-
|
|
246
|
+
event.preventDefault();
|
|
247
|
+
submit();
|
|
182
248
|
}
|
|
183
|
-
submit();
|
|
184
|
-
return true;
|
|
185
249
|
}}
|
|
186
|
-
onInputChange={onDraftChange}
|
|
187
250
|
onPaste={onPaste}
|
|
188
251
|
placeholder={
|
|
189
252
|
isMobile
|
|
190
253
|
? "Send a message... (Ctrl+Enter to send)"
|
|
191
254
|
: "Send a message..."
|
|
192
255
|
}
|
|
193
|
-
readOnly={editorReadOnly}
|
|
256
|
+
readOnly={!mounted || editorReadOnly}
|
|
194
257
|
/>
|
|
195
258
|
</PromptForm>
|
|
196
259
|
);
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
/** One transcript and placement contract. Runtime-owned recovery and composer
|
|
21
21
|
* controllers occupy fixed slots; callers cannot replace message rendering. */
|
|
22
22
|
export const ChatConversationScreen = ({
|
|
23
|
-
|
|
23
|
+
branchId,
|
|
24
24
|
welcome = false,
|
|
25
25
|
header,
|
|
26
26
|
transcript,
|
|
@@ -30,7 +30,7 @@ export const ChatConversationScreen = ({
|
|
|
30
30
|
leading,
|
|
31
31
|
trailing,
|
|
32
32
|
}: {
|
|
33
|
-
readonly
|
|
33
|
+
readonly branchId: string;
|
|
34
34
|
readonly welcome?: boolean;
|
|
35
35
|
readonly header?: ReactNode;
|
|
36
36
|
readonly transcript: ComponentProps<typeof ChatTranscript>;
|
|
@@ -49,7 +49,7 @@ export const ChatConversationScreen = ({
|
|
|
49
49
|
</ChatWelcomeView>
|
|
50
50
|
) : (
|
|
51
51
|
<ChatConversationBody>
|
|
52
|
-
<MessageScrollerProvider autoScroll key={
|
|
52
|
+
<MessageScrollerProvider autoScroll key={branchId}>
|
|
53
53
|
<MessageScroller className="flex-1">
|
|
54
54
|
<MessageScrollerViewport preserveScrollOnPrepend>
|
|
55
55
|
<MessageScrollerContent className="mx-auto w-full max-w-3xl p-4">
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { useParams } from "next/navigation";
|
|
3
4
|
import { createContext, useContext } from "react";
|
|
4
5
|
|
|
5
6
|
/** Embed the application without replacing its links or navigation controls. */
|
|
6
7
|
export const ChatNavigationContext = createContext<{
|
|
7
|
-
readonly
|
|
8
|
+
readonly chatId: string | null;
|
|
8
9
|
readonly navigate: (href: string) => void;
|
|
9
10
|
} | null>(null);
|
|
10
11
|
|
|
11
12
|
export const useChatNavigation = () => useContext(ChatNavigationContext);
|
|
13
|
+
|
|
14
|
+
export const useActiveChatId = (): string | null => {
|
|
15
|
+
const embedded = useChatNavigation();
|
|
16
|
+
const params = useParams();
|
|
17
|
+
if (embedded) {
|
|
18
|
+
return embedded.chatId;
|
|
19
|
+
}
|
|
20
|
+
return typeof params?.chatId === "string" ? params.chatId : null;
|
|
21
|
+
};
|
|
@@ -78,7 +78,7 @@ export const ChatSidebar = ({
|
|
|
78
78
|
ownerId,
|
|
79
79
|
history,
|
|
80
80
|
account,
|
|
81
|
-
|
|
81
|
+
chatId,
|
|
82
82
|
onProjectSelect,
|
|
83
83
|
onChatSelect,
|
|
84
84
|
}: {
|
|
@@ -87,7 +87,7 @@ export const ChatSidebar = ({
|
|
|
87
87
|
readonly history: SidebarData | Promise<SidebarData>;
|
|
88
88
|
readonly account: ComponentProps<typeof ChatAccount>;
|
|
89
89
|
readonly onChatSelect?: (id: string) => void;
|
|
90
|
-
readonly
|
|
90
|
+
readonly chatId?: string;
|
|
91
91
|
readonly onProjectSelect?: (id: string) => void;
|
|
92
92
|
}) => (
|
|
93
93
|
<Sidebar
|
|
@@ -98,10 +98,12 @@ export const ChatSidebar = ({
|
|
|
98
98
|
>
|
|
99
99
|
<SidebarHeader className="shrink-0">
|
|
100
100
|
<SidebarMenu>
|
|
101
|
-
<
|
|
101
|
+
<SidebarMenuItem>
|
|
102
102
|
<SidebarTopRow />
|
|
103
|
-
</
|
|
104
|
-
<
|
|
103
|
+
</SidebarMenuItem>
|
|
104
|
+
<SidebarMenuItem>
|
|
105
|
+
<NewChatButton />
|
|
106
|
+
</SidebarMenuItem>
|
|
105
107
|
<Suspense
|
|
106
108
|
fallback={
|
|
107
109
|
<SidebarMenuItem>
|
|
@@ -117,10 +119,7 @@ export const ChatSidebar = ({
|
|
|
117
119
|
<SidebarSeparator />
|
|
118
120
|
<ScrollArea className="relative flex-1 overflow-y-auto">
|
|
119
121
|
<SidebarContent className="max-w-(--sidebar-width) pr-2 group-data-[collapsible=icon]:hidden">
|
|
120
|
-
<SidebarSections
|
|
121
|
-
conversationId={conversationId}
|
|
122
|
-
onProjectSelect={onProjectSelect}
|
|
123
|
-
/>
|
|
122
|
+
<SidebarSections chatId={chatId} onProjectSelect={onProjectSelect} />
|
|
124
123
|
<Suspense fallback={<HistorySkeleton />}>
|
|
125
124
|
<History data={history} />
|
|
126
125
|
</Suspense>
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { hasText } from "@/components/text-value";
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import { interactions } from "eve/events";
|
|
6
|
+
import type { Answer, Interaction, SessionView } from "eve/events";
|
|
7
|
+
import React, { useMemo } from "react";
|
|
7
8
|
import type { JSX as ReactJSX, ReactNode } from "react";
|
|
8
9
|
import { toast } from "sonner";
|
|
9
10
|
|
|
@@ -21,7 +22,7 @@ import type {
|
|
|
21
22
|
import type { ReadonlyReactNode } from "@/lib/readonly-react-node";
|
|
22
23
|
|
|
23
24
|
import { EveAttachment } from "../eve/eve-attachment";
|
|
24
|
-
import {
|
|
25
|
+
import { EveMessageContent } from "../eve/eve-message-content";
|
|
25
26
|
import { MessageActions } from "@/components/chat-slots";
|
|
26
27
|
|
|
27
28
|
const messagePartIdentity = (part: ReadonlyEveMessagePart): string => {
|
|
@@ -50,7 +51,7 @@ const messagePartIdentity = (part: ReadonlyEveMessagePart): string => {
|
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
interface ChatTranscriptProps {
|
|
53
|
-
readonly
|
|
54
|
+
readonly branchId?: string;
|
|
54
55
|
readonly messageKey?: (message: ReadonlyEveMessage) => string;
|
|
55
56
|
readonly messages: readonly ReadonlyEveMessage[];
|
|
56
57
|
readonly isReadonly: boolean;
|
|
@@ -77,6 +78,7 @@ interface ChatTranscriptProps {
|
|
|
77
78
|
) => string | undefined;
|
|
78
79
|
readonly disabled: boolean;
|
|
79
80
|
readonly inputDisabled?: boolean;
|
|
81
|
+
readonly view?: SessionView;
|
|
80
82
|
readonly respond: (response: Answer) => void;
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -88,12 +90,13 @@ interface MessageRowProps extends Omit<
|
|
|
88
90
|
readonly userMessage: ReadonlyEveMessage | undefined;
|
|
89
91
|
readonly isLast: boolean;
|
|
90
92
|
readonly actionsDisabled: boolean;
|
|
93
|
+
readonly interactionsByCall: ReadonlyMap<string, readonly Interaction[]>;
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
const AssistantFeedback = ({
|
|
94
97
|
message,
|
|
95
98
|
userMessage,
|
|
96
|
-
|
|
99
|
+
branchId,
|
|
97
100
|
disabled,
|
|
98
101
|
actionsDisabled,
|
|
99
102
|
editor,
|
|
@@ -103,16 +106,16 @@ const AssistantFeedback = ({
|
|
|
103
106
|
MessageRowProps,
|
|
104
107
|
| "message"
|
|
105
108
|
| "userMessage"
|
|
106
|
-
| "
|
|
109
|
+
| "branchId"
|
|
107
110
|
| "disabled"
|
|
108
111
|
| "actionsDisabled"
|
|
109
112
|
| "editor"
|
|
110
113
|
| "onRegenerate"
|
|
111
114
|
> & { readonly modelId: string | undefined }): ReactJSX.Element => (
|
|
112
115
|
<>
|
|
113
|
-
{hasText(
|
|
116
|
+
{hasText(branchId) && (
|
|
114
117
|
<MessageActions
|
|
115
|
-
|
|
118
|
+
branchId={branchId}
|
|
116
119
|
disabled={disabled}
|
|
117
120
|
messageId={message.id}
|
|
118
121
|
/>
|
|
@@ -146,7 +149,7 @@ const AssistantFeedback = ({
|
|
|
146
149
|
const EveMessageActions = ({
|
|
147
150
|
message,
|
|
148
151
|
userMessage,
|
|
149
|
-
|
|
152
|
+
branchId,
|
|
150
153
|
isReadonly,
|
|
151
154
|
disabled,
|
|
152
155
|
actionsDisabled,
|
|
@@ -161,7 +164,7 @@ const EveMessageActions = ({
|
|
|
161
164
|
MessageRowProps,
|
|
162
165
|
| "message"
|
|
163
166
|
| "userMessage"
|
|
164
|
-
| "
|
|
167
|
+
| "branchId"
|
|
165
168
|
| "isReadonly"
|
|
166
169
|
| "disabled"
|
|
167
170
|
| "actionsDisabled"
|
|
@@ -214,7 +217,7 @@ const EveMessageActions = ({
|
|
|
214
217
|
<AssistantFeedback
|
|
215
218
|
message={message}
|
|
216
219
|
userMessage={userMessage}
|
|
217
|
-
|
|
220
|
+
branchId={branchId}
|
|
218
221
|
disabled={disabled}
|
|
219
222
|
actionsDisabled={actionsDisabled}
|
|
220
223
|
editor={editor}
|
|
@@ -237,11 +240,13 @@ const EveMessageRow = ({
|
|
|
237
240
|
message,
|
|
238
241
|
userMessage,
|
|
239
242
|
isLast,
|
|
240
|
-
|
|
243
|
+
branchId,
|
|
241
244
|
isReadonly,
|
|
242
245
|
disabled,
|
|
243
246
|
actionsDisabled,
|
|
244
247
|
inputDisabled,
|
|
248
|
+
view,
|
|
249
|
+
interactionsByCall,
|
|
245
250
|
respond,
|
|
246
251
|
onEdit,
|
|
247
252
|
onRegenerate,
|
|
@@ -274,7 +279,7 @@ const EveMessageRow = ({
|
|
|
274
279
|
<EveMessageActions
|
|
275
280
|
message={message}
|
|
276
281
|
userMessage={userMessage}
|
|
277
|
-
|
|
282
|
+
branchId={branchId}
|
|
278
283
|
isReadonly={isReadonly}
|
|
279
284
|
disabled={disabled}
|
|
280
285
|
actionsDisabled={actionsDisabled}
|
|
@@ -319,16 +324,15 @@ const EveMessageRow = ({
|
|
|
319
324
|
actions={actions}
|
|
320
325
|
followUp={isLast && !isReadonly && !actionsDisabled && suggestions}
|
|
321
326
|
>
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
))}
|
|
327
|
+
<EveMessageContent
|
|
328
|
+
inputDisabled={responseDisabled(isReadonly, disabled, inputDisabled)}
|
|
329
|
+
interactionsByCall={interactionsByCall}
|
|
330
|
+
isReadonly={isReadonly}
|
|
331
|
+
messageId={message.id}
|
|
332
|
+
parts={message.parts.map((part) => ({ key: nextPartKey(part), part }))}
|
|
333
|
+
respond={respond}
|
|
334
|
+
view={view}
|
|
335
|
+
/>
|
|
332
336
|
</ChatMessageView>
|
|
333
337
|
);
|
|
334
338
|
};
|
|
@@ -339,8 +343,31 @@ export const ChatTranscript = ({
|
|
|
339
343
|
messageKey,
|
|
340
344
|
disabled,
|
|
341
345
|
actionsDisabled = disabled,
|
|
346
|
+
view,
|
|
342
347
|
...props
|
|
343
348
|
}: ChatTranscriptProps): ReactJSX.Element[] => {
|
|
349
|
+
const interactionsByCall = useMemo(() => {
|
|
350
|
+
const byCall = new Map<string, Interaction[]>();
|
|
351
|
+
if (view !== undefined) {
|
|
352
|
+
for (const interaction of interactions(view)) {
|
|
353
|
+
const callId = interaction.call?.callId;
|
|
354
|
+
const { kind } = interaction.request;
|
|
355
|
+
if (
|
|
356
|
+
callId === undefined ||
|
|
357
|
+
(kind !== "question" && kind !== "approval")
|
|
358
|
+
) {
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
const entries = byCall.get(callId);
|
|
362
|
+
if (entries) {
|
|
363
|
+
entries.push(interaction);
|
|
364
|
+
} else {
|
|
365
|
+
byCall.set(callId, [interaction]);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return byCall;
|
|
370
|
+
}, [view]);
|
|
344
371
|
const precedingUsers: (ReadonlyEveMessage | undefined)[] = [];
|
|
345
372
|
let precedingUser: ReadonlyEveMessage | undefined;
|
|
346
373
|
for (const message of messages) {
|
|
@@ -362,6 +389,8 @@ export const ChatTranscript = ({
|
|
|
362
389
|
isLast={message.id === messages.at(-1)?.id}
|
|
363
390
|
disabled={disabled}
|
|
364
391
|
actionsDisabled={actionsDisabled}
|
|
392
|
+
interactionsByCall={interactionsByCall}
|
|
393
|
+
view={view}
|
|
365
394
|
/>
|
|
366
395
|
</MessageScrollerItem>
|
|
367
396
|
));
|
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
import type { ComposerControlProps } from "@/components/composer/control";
|
|
9
9
|
|
|
10
10
|
export const SidebarSections = defineSlot<{
|
|
11
|
-
readonly
|
|
11
|
+
readonly chatId?: string;
|
|
12
12
|
readonly allowManagement?: boolean;
|
|
13
13
|
readonly onProjectSelect?: (id: string) => void;
|
|
14
14
|
}>();
|