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
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import React from "react";
|
|
4
|
-
import
|
|
4
|
+
import { signInEnding } from "eve/events";
|
|
5
|
+
import type {
|
|
6
|
+
Interaction,
|
|
7
|
+
InteractionOutcome,
|
|
8
|
+
InteractionRequest,
|
|
9
|
+
Answer,
|
|
10
|
+
} from "eve/events";
|
|
5
11
|
import { Button, buttonVariants } from "@/components/ui/button";
|
|
6
12
|
import { Textarea } from "@/components/ui/textarea";
|
|
7
13
|
import {
|
|
8
14
|
Item,
|
|
9
15
|
ItemActions,
|
|
10
16
|
ItemContent,
|
|
17
|
+
ItemDescription,
|
|
11
18
|
ItemTitle,
|
|
12
19
|
} from "@/components/ui/item";
|
|
13
20
|
import {
|
|
@@ -117,6 +124,7 @@ const PendingSignIn = ({
|
|
|
117
124
|
disabled,
|
|
118
125
|
}: PendingInputProps): React.JSX.Element => {
|
|
119
126
|
const { signIn } = request;
|
|
127
|
+
const name = signIn?.displayName ?? signIn?.name ?? "account";
|
|
120
128
|
const url = signIn?.url;
|
|
121
129
|
const safeUrl =
|
|
122
130
|
url !== undefined && URL.canParse(url) && new URL(url).protocol === "https:"
|
|
@@ -152,7 +160,7 @@ const PendingSignIn = ({
|
|
|
152
160
|
target="_blank"
|
|
153
161
|
rel="noopener noreferrer"
|
|
154
162
|
>
|
|
155
|
-
Connect {
|
|
163
|
+
Connect {name}
|
|
156
164
|
</a>
|
|
157
165
|
) : (
|
|
158
166
|
<Button disabled>Sign-in unavailable</Button>
|
|
@@ -162,9 +170,7 @@ const PendingSignIn = ({
|
|
|
162
170
|
);
|
|
163
171
|
};
|
|
164
172
|
|
|
165
|
-
|
|
166
|
-
props: PendingInputProps
|
|
167
|
-
): React.JSX.Element => {
|
|
173
|
+
const PendingInput = (props: PendingInputProps): React.JSX.Element => {
|
|
168
174
|
const { request, disabled, respond } = props;
|
|
169
175
|
if (request.kind === "sign-in") {
|
|
170
176
|
return <PendingSignIn {...props} />;
|
|
@@ -207,3 +213,74 @@ export const EvePendingInput = (
|
|
|
207
213
|
</Item>
|
|
208
214
|
);
|
|
209
215
|
};
|
|
216
|
+
|
|
217
|
+
const outcomeLabels = {
|
|
218
|
+
accepted: "Answered",
|
|
219
|
+
declined: "Declined",
|
|
220
|
+
invalid: "Invalid response",
|
|
221
|
+
failed: "Failed",
|
|
222
|
+
expired: "Timed out",
|
|
223
|
+
abandoned: "Cancelled",
|
|
224
|
+
interrupted: "Cancelled",
|
|
225
|
+
withdrawn: "Cancelled",
|
|
226
|
+
} satisfies Record<InteractionOutcome, string>;
|
|
227
|
+
|
|
228
|
+
const interactionResult = (interaction: Interaction): string => {
|
|
229
|
+
if (interaction.status === "open") {
|
|
230
|
+
return "Response submitted";
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (
|
|
234
|
+
interaction.outcome === "accepted" &&
|
|
235
|
+
interaction.request.kind === "approval"
|
|
236
|
+
) {
|
|
237
|
+
return "Approved";
|
|
238
|
+
}
|
|
239
|
+
return outcomeLabels[interaction.outcome ?? "withdrawn"];
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export const EveInteraction = ({
|
|
243
|
+
interaction,
|
|
244
|
+
disabled,
|
|
245
|
+
respond,
|
|
246
|
+
}: {
|
|
247
|
+
readonly interaction: Interaction;
|
|
248
|
+
readonly disabled: boolean;
|
|
249
|
+
readonly respond: (response: Answer) => void;
|
|
250
|
+
}): React.JSX.Element => {
|
|
251
|
+
const { answer, interactionId, outcome, request, status } = interaction;
|
|
252
|
+
if (status === "open" && answer === undefined) {
|
|
253
|
+
return (
|
|
254
|
+
<PendingInput
|
|
255
|
+
request={{ ...request, interactionId }}
|
|
256
|
+
disabled={disabled}
|
|
257
|
+
respond={respond}
|
|
258
|
+
/>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const answerLabel =
|
|
263
|
+
answer?.text ??
|
|
264
|
+
request.options?.find((option) => option.id === answer?.optionId)?.label ??
|
|
265
|
+
answer?.optionId;
|
|
266
|
+
const service =
|
|
267
|
+
request.signIn?.displayName ?? request.signIn?.name ?? "Account";
|
|
268
|
+
const result =
|
|
269
|
+
request.kind === "sign-in" && status === "settled"
|
|
270
|
+
? `${service}${outcome === "accepted" ? "" : " authorization"} ${signInEnding(outcome ?? "withdrawn")}.`
|
|
271
|
+
: interactionResult(interaction);
|
|
272
|
+
|
|
273
|
+
return (
|
|
274
|
+
<Item variant="outline" size="sm">
|
|
275
|
+
<ItemContent>
|
|
276
|
+
<ItemTitle>{request.prompt}</ItemTitle>
|
|
277
|
+
{answerLabel !== undefined && (
|
|
278
|
+
<p className="text-sm break-words whitespace-pre-wrap">
|
|
279
|
+
{answerLabel}
|
|
280
|
+
</p>
|
|
281
|
+
)}
|
|
282
|
+
<ItemDescription>{result}</ItemDescription>
|
|
283
|
+
</ItemContent>
|
|
284
|
+
</Item>
|
|
285
|
+
);
|
|
286
|
+
};
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { idle } from "eve/events";
|
|
4
|
+
import type { Answer } from "eve/events";
|
|
4
5
|
|
|
5
6
|
import { hasText } from "@/components/text-value";
|
|
6
7
|
|
|
7
8
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
8
9
|
import { conversationOf } from "eve/client";
|
|
9
|
-
import type {
|
|
10
|
+
import type {
|
|
11
|
+
EveMessage,
|
|
12
|
+
EveMessagePart,
|
|
13
|
+
SessionStreamEvent,
|
|
14
|
+
} from "eve/client";
|
|
10
15
|
import { useEveAgent } from "eve/react";
|
|
11
16
|
import { usePathname } from "next/navigation";
|
|
12
17
|
import React, {
|
|
@@ -37,17 +42,62 @@ import {
|
|
|
37
42
|
useEveRuntime,
|
|
38
43
|
} from "./eve-logical-context";
|
|
39
44
|
import type { OpenRequest } from "./eve-logical-context";
|
|
45
|
+
import { handoffEveComposerDraft } from "./use-eve-composer-draft";
|
|
40
46
|
|
|
41
|
-
type Runtime = OpenRequest & {
|
|
47
|
+
type Runtime = Omit<OpenRequest, "getFollowUpDraft"> & {
|
|
48
|
+
chatId: string;
|
|
49
|
+
controller: LogicalChat;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const partInteraction = (part: EveMessagePart) => {
|
|
53
|
+
if (part.type === "tool") {
|
|
54
|
+
return part.interaction;
|
|
55
|
+
}
|
|
56
|
+
return part.type === "interaction" ? part : undefined;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const withLiveAnswers = (
|
|
60
|
+
confirmed: readonly EveMessage[],
|
|
61
|
+
live: readonly EveMessage[]
|
|
62
|
+
): readonly EveMessage[] => {
|
|
63
|
+
const answers = new Map<string, Answer>();
|
|
64
|
+
for (const message of live) {
|
|
65
|
+
for (const part of message.parts) {
|
|
66
|
+
const interaction = partInteraction(part);
|
|
67
|
+
if (interaction?.status === "open" && interaction.answer !== undefined) {
|
|
68
|
+
answers.set(interaction.interactionId, interaction.answer);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (answers.size === 0) {
|
|
73
|
+
return confirmed;
|
|
74
|
+
}
|
|
75
|
+
return confirmed.map((message) => ({
|
|
76
|
+
...message,
|
|
77
|
+
parts: message.parts.map((part) => {
|
|
78
|
+
const interaction = partInteraction(part);
|
|
79
|
+
if (interaction?.status !== "open" || interaction.answer !== undefined) {
|
|
80
|
+
return part;
|
|
81
|
+
}
|
|
82
|
+
const answer = answers.get(interaction.interactionId);
|
|
83
|
+
if (answer === undefined) {
|
|
84
|
+
return part;
|
|
85
|
+
}
|
|
86
|
+
return part.type === "tool"
|
|
87
|
+
? { ...part, interaction: { ...interaction, answer } }
|
|
88
|
+
: { ...interaction, type: "interaction", answer };
|
|
89
|
+
}),
|
|
90
|
+
}));
|
|
91
|
+
};
|
|
42
92
|
|
|
43
93
|
const NativeObserver = ({
|
|
44
94
|
controller,
|
|
45
|
-
|
|
95
|
+
branchId,
|
|
46
96
|
sessionId,
|
|
47
97
|
selected,
|
|
48
98
|
}: {
|
|
49
99
|
readonly controller: LogicalChat;
|
|
50
|
-
readonly
|
|
100
|
+
readonly branchId: string;
|
|
51
101
|
readonly sessionId: string;
|
|
52
102
|
readonly selected: boolean;
|
|
53
103
|
}): null => {
|
|
@@ -123,17 +173,18 @@ const NativeObserver = ({
|
|
|
123
173
|
(message) => message.metadata?.optimistic
|
|
124
174
|
);
|
|
125
175
|
return projectEveMessageDisplay(
|
|
126
|
-
|
|
176
|
+
// Attach the native hook's immediate answers to confirmed parts by interaction ID.
|
|
177
|
+
{ messages: [...withLiveAnswers(confirmed, agent.messages), ...pending] },
|
|
127
178
|
agent.events,
|
|
128
179
|
display.data ?? []
|
|
129
180
|
);
|
|
130
181
|
}, [agent.messages, agent.events, display.data]);
|
|
131
182
|
useEffect(() => {
|
|
132
|
-
controller.observe(
|
|
183
|
+
controller.observe(branchId, {
|
|
133
184
|
...agent,
|
|
134
185
|
messages: displayedData.messages,
|
|
135
186
|
});
|
|
136
|
-
}, [agent, displayedData, controller,
|
|
187
|
+
}, [agent, displayedData, controller, branchId]);
|
|
137
188
|
return null;
|
|
138
189
|
};
|
|
139
190
|
|
|
@@ -171,13 +222,13 @@ const RuntimeSlot = ({
|
|
|
171
222
|
[runtime.controller, runtime.ownerId, snapshot]
|
|
172
223
|
);
|
|
173
224
|
const selected = snapshot.branches.find(
|
|
174
|
-
(branch: { readonly id: string }) => branch.id === snapshot.
|
|
225
|
+
(branch: { readonly id: string }) => branch.id === snapshot.branchId
|
|
175
226
|
);
|
|
176
|
-
const agent = snapshot.agents.get(snapshot.
|
|
227
|
+
const agent = snapshot.agents.get(snapshot.branchId);
|
|
177
228
|
const header = (
|
|
178
229
|
<EveChatHeader
|
|
179
230
|
chatId={runtime.chatId}
|
|
180
|
-
|
|
231
|
+
branchId={snapshot.branchId}
|
|
181
232
|
fallbackTitle={
|
|
182
233
|
identity.data?.title ??
|
|
183
234
|
runtime.title ??
|
|
@@ -196,9 +247,9 @@ const RuntimeSlot = ({
|
|
|
196
247
|
<NativeObserver
|
|
197
248
|
key={branch.sessionId}
|
|
198
249
|
controller={runtime.controller}
|
|
199
|
-
|
|
250
|
+
branchId={branch.id}
|
|
200
251
|
sessionId={branch.sessionId}
|
|
201
|
-
selected={active && branch.id === snapshot.
|
|
252
|
+
selected={active && branch.id === snapshot.branchId}
|
|
202
253
|
/>
|
|
203
254
|
)
|
|
204
255
|
)}
|
|
@@ -206,7 +257,7 @@ const RuntimeSlot = ({
|
|
|
206
257
|
<EveLogicalContext.Provider value={context}>
|
|
207
258
|
{agent && hasText(selected?.sessionId) ? (
|
|
208
259
|
<EveConversation
|
|
209
|
-
|
|
260
|
+
branchId={selected.id}
|
|
210
261
|
sessionId={selected.sessionId}
|
|
211
262
|
ownerId={runtime.ownerId}
|
|
212
263
|
draftScopeId={runtime.chatId}
|
|
@@ -248,7 +299,7 @@ const EveRuntimeProvider = ({
|
|
|
248
299
|
const [runtimes, setRuntimes] = useState<Runtime[]>([]);
|
|
249
300
|
const registry = useRef(new Map<string, Runtime>());
|
|
250
301
|
const open = useCallback(
|
|
251
|
-
async (request: OpenRequest, navigate = true) => {
|
|
302
|
+
async ({ getFollowUpDraft, ...request }: OpenRequest, navigate = true) => {
|
|
252
303
|
// Query resolves the requested chat identity before looking up its owning runtime.
|
|
253
304
|
const identity = await queryClient.query(
|
|
254
305
|
trpc.eve.get.queryOptions({ id: request.id })
|
|
@@ -271,7 +322,7 @@ const EveRuntimeProvider = ({
|
|
|
271
322
|
)
|
|
272
323
|
.find((branch) =>
|
|
273
324
|
hasPendingCreation(sessionStorage, request.ownerId, {
|
|
274
|
-
|
|
325
|
+
branchId: branch.id,
|
|
275
326
|
})
|
|
276
327
|
);
|
|
277
328
|
const controller =
|
|
@@ -292,6 +343,14 @@ const EveRuntimeProvider = ({
|
|
|
292
343
|
controller,
|
|
293
344
|
title: identity.title,
|
|
294
345
|
};
|
|
346
|
+
const followUpDraft = getFollowUpDraft?.();
|
|
347
|
+
if (hasText(followUpDraft)) {
|
|
348
|
+
handoffEveComposerDraft(
|
|
349
|
+
request.ownerId,
|
|
350
|
+
identity.chatId,
|
|
351
|
+
followUpDraft
|
|
352
|
+
);
|
|
353
|
+
}
|
|
295
354
|
registry.current.set(identity.chatId, runtime);
|
|
296
355
|
setRuntimes([...registry.current.values()]);
|
|
297
356
|
if (
|
|
@@ -18,6 +18,44 @@ const composerDraft = z.object({
|
|
|
18
18
|
type Draft = ReadonlyNativeSurface<z.infer<typeof composerDraft>>;
|
|
19
19
|
|
|
20
20
|
const emptyDraft: Draft = { attachments: [], selectedTool: null, text: "" };
|
|
21
|
+
const draftKey = (ownerId: string, scopeId: string): string =>
|
|
22
|
+
`chatjs.eve.composer:${ownerId}:${scopeId}`;
|
|
23
|
+
|
|
24
|
+
const parseSavedDraft = (saved: string | null): Draft =>
|
|
25
|
+
saved === null || saved === ""
|
|
26
|
+
? emptyDraft
|
|
27
|
+
: composerDraft.parse(JSON.parse(saved));
|
|
28
|
+
|
|
29
|
+
const readHandoffDestination = (key: string): Draft => {
|
|
30
|
+
const saved = sessionStorage.getItem(key);
|
|
31
|
+
try {
|
|
32
|
+
return parseSavedDraft(saved);
|
|
33
|
+
} catch {
|
|
34
|
+
// An unreadable destination cannot be merged with the intact follow-up.
|
|
35
|
+
return emptyDraft;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** Transfer text typed in the composer that created this conversation. */
|
|
40
|
+
export const handoffEveComposerDraft = (
|
|
41
|
+
ownerId: string,
|
|
42
|
+
scopeId: string,
|
|
43
|
+
text: string
|
|
44
|
+
): void => {
|
|
45
|
+
const key = draftKey(ownerId, scopeId);
|
|
46
|
+
const draft = readHandoffDestination(key);
|
|
47
|
+
if (draft.text === text) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
sessionStorage.setItem(
|
|
51
|
+
key,
|
|
52
|
+
JSON.stringify({
|
|
53
|
+
...draft,
|
|
54
|
+
text: draft.text ? `${draft.text}\n\n${text}` : text,
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
21
59
|
interface DraftSnapshot {
|
|
22
60
|
value: Draft;
|
|
23
61
|
loaded: boolean;
|
|
@@ -37,6 +75,25 @@ const createDraftStore = (key: string) => {
|
|
|
37
75
|
listener();
|
|
38
76
|
}
|
|
39
77
|
};
|
|
78
|
+
const update = (change: (draft: Draft) => Draft): void => {
|
|
79
|
+
const value = change(snapshot.value);
|
|
80
|
+
let error: string | undefined;
|
|
81
|
+
try {
|
|
82
|
+
if (
|
|
83
|
+
value.text ||
|
|
84
|
+
value.attachments.length > 0 ||
|
|
85
|
+
value.selectedTool !== null
|
|
86
|
+
) {
|
|
87
|
+
sessionStorage.setItem(key, JSON.stringify(value));
|
|
88
|
+
} else {
|
|
89
|
+
sessionStorage.removeItem(key);
|
|
90
|
+
}
|
|
91
|
+
} catch {
|
|
92
|
+
error =
|
|
93
|
+
"Your draft could not be saved. Keep this tab open before switching responses.";
|
|
94
|
+
}
|
|
95
|
+
publish({ ...snapshot, value, error });
|
|
96
|
+
};
|
|
40
97
|
return {
|
|
41
98
|
getSnapshot: () => snapshot,
|
|
42
99
|
getServerSnapshot: () => initial,
|
|
@@ -44,12 +101,11 @@ const createDraftStore = (key: string) => {
|
|
|
44
101
|
listeners.add(listener);
|
|
45
102
|
if (!snapshot.loaded) {
|
|
46
103
|
try {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
publish({ value, loaded: true, error: undefined });
|
|
104
|
+
publish({
|
|
105
|
+
value: parseSavedDraft(sessionStorage.getItem(key)),
|
|
106
|
+
loaded: true,
|
|
107
|
+
error: undefined,
|
|
108
|
+
});
|
|
53
109
|
} catch {
|
|
54
110
|
publish({
|
|
55
111
|
...snapshot,
|
|
@@ -63,25 +119,7 @@ const createDraftStore = (key: string) => {
|
|
|
63
119
|
listeners.delete(listener);
|
|
64
120
|
};
|
|
65
121
|
},
|
|
66
|
-
update
|
|
67
|
-
const value = change(snapshot.value);
|
|
68
|
-
let error: string | undefined;
|
|
69
|
-
try {
|
|
70
|
-
if (
|
|
71
|
-
value.text ||
|
|
72
|
-
value.attachments.length > 0 ||
|
|
73
|
-
value.selectedTool !== null
|
|
74
|
-
) {
|
|
75
|
-
sessionStorage.setItem(key, JSON.stringify(value));
|
|
76
|
-
} else {
|
|
77
|
-
sessionStorage.removeItem(key);
|
|
78
|
-
}
|
|
79
|
-
} catch {
|
|
80
|
-
error =
|
|
81
|
-
"Your draft could not be saved. Keep this tab open before switching responses.";
|
|
82
|
-
}
|
|
83
|
-
publish({ ...snapshot, value, error });
|
|
84
|
-
},
|
|
122
|
+
update,
|
|
85
123
|
};
|
|
86
124
|
};
|
|
87
125
|
type ComposerDraftState = Draft & {
|
|
@@ -104,7 +142,7 @@ export const useEveComposerDraft = (
|
|
|
104
142
|
ownerId: string,
|
|
105
143
|
scopeId: string
|
|
106
144
|
): ComposerDraftState => {
|
|
107
|
-
const key =
|
|
145
|
+
const key = draftKey(ownerId, scopeId);
|
|
108
146
|
const store = useMemo(() => createDraftStore(key), [key]);
|
|
109
147
|
const { value, loaded, error } = useSyncExternalStore(
|
|
110
148
|
store.subscribe,
|
|
@@ -97,7 +97,7 @@ const operationModelSelection = (
|
|
|
97
97
|
|
|
98
98
|
export const useEveFork = (
|
|
99
99
|
ownerId: string,
|
|
100
|
-
|
|
100
|
+
branchId: string,
|
|
101
101
|
onComparisonStarted?: (
|
|
102
102
|
message: ReadonlyEveMessageInput,
|
|
103
103
|
selectedTool: UiToolName | undefined,
|
|
@@ -109,9 +109,7 @@ export const useEveFork = (
|
|
|
109
109
|
const restoreAttachments = useMutation(
|
|
110
110
|
trpc.eve.restoreAttachments.mutationOptions()
|
|
111
111
|
);
|
|
112
|
-
const family = useQuery(
|
|
113
|
-
trpc.eve.branches.queryOptions({ id: conversationId })
|
|
114
|
-
);
|
|
112
|
+
const family = useQuery(trpc.eve.branches.queryOptions({ id: branchId }));
|
|
115
113
|
const openRuntime = useEveRuntime();
|
|
116
114
|
const [isNavigating, startTransition] = useTransition();
|
|
117
115
|
const selectedModel = useDefaultModel();
|
|
@@ -159,7 +157,7 @@ export const useEveFork = (
|
|
|
159
157
|
const operation: Operation | undefined = readCreationRequest(
|
|
160
158
|
sessionStorage,
|
|
161
159
|
ownerId,
|
|
162
|
-
{
|
|
160
|
+
{ branchId }
|
|
163
161
|
);
|
|
164
162
|
if (!operation) {
|
|
165
163
|
return { ...current, loaded: true };
|
|
@@ -184,7 +182,7 @@ export const useEveFork = (
|
|
|
184
182
|
}
|
|
185
183
|
}
|
|
186
184
|
),
|
|
187
|
-
[
|
|
185
|
+
[branchId, ownerId, setAttachments]
|
|
188
186
|
);
|
|
189
187
|
const {
|
|
190
188
|
draft,
|
|
@@ -249,7 +247,7 @@ export const useEveFork = (
|
|
|
249
247
|
ownerId,
|
|
250
248
|
operation,
|
|
251
249
|
{
|
|
252
|
-
|
|
250
|
+
branchId,
|
|
253
251
|
}
|
|
254
252
|
);
|
|
255
253
|
await Promise.all([
|
|
@@ -290,7 +288,7 @@ export const useEveFork = (
|
|
|
290
288
|
if (error instanceof CreationRejectedError) {
|
|
291
289
|
setRejected(true);
|
|
292
290
|
try {
|
|
293
|
-
finishCreation(sessionStorage, ownerId, {
|
|
291
|
+
finishCreation(sessionStorage, ownerId, { branchId });
|
|
294
292
|
setPending(undefined);
|
|
295
293
|
setRejected(false);
|
|
296
294
|
} catch {
|
|
@@ -340,7 +338,7 @@ export const useEveFork = (
|
|
|
340
338
|
? responseModelSelection(regeneration.response, regeneration.events)
|
|
341
339
|
: undefined;
|
|
342
340
|
const fork = {
|
|
343
|
-
|
|
341
|
+
branchId,
|
|
344
342
|
beforeMessageId: boundary,
|
|
345
343
|
};
|
|
346
344
|
const text = message.parts
|
|
@@ -365,7 +363,7 @@ export const useEveFork = (
|
|
|
365
363
|
(part: ReadonlyEveMessagePart) => part.type === "file"
|
|
366
364
|
)
|
|
367
365
|
? await restoreAttachments.mutateAsync({
|
|
368
|
-
|
|
366
|
+
branchId,
|
|
369
367
|
messageId: message.id,
|
|
370
368
|
})
|
|
371
369
|
: [];
|
|
@@ -387,7 +385,7 @@ export const useEveFork = (
|
|
|
387
385
|
ownerId,
|
|
388
386
|
draftMessage(text, attachments),
|
|
389
387
|
modelId,
|
|
390
|
-
{
|
|
388
|
+
{ branchId, fork, forkKind: "regenerate" },
|
|
391
389
|
originalTool ?? undefined
|
|
392
390
|
);
|
|
393
391
|
setPending(operation);
|
|
@@ -426,9 +424,9 @@ export const useEveFork = (
|
|
|
426
424
|
message,
|
|
427
425
|
modelIds,
|
|
428
426
|
{
|
|
429
|
-
|
|
427
|
+
branchId,
|
|
430
428
|
fork: {
|
|
431
|
-
|
|
429
|
+
branchId,
|
|
432
430
|
},
|
|
433
431
|
},
|
|
434
432
|
requestedTool
|
|
@@ -479,7 +477,7 @@ export const useEveFork = (
|
|
|
479
477
|
await run(async () => {
|
|
480
478
|
if (pending && rejected) {
|
|
481
479
|
try {
|
|
482
|
-
finishCreation(sessionStorage, ownerId, {
|
|
480
|
+
finishCreation(sessionStorage, ownerId, { branchId });
|
|
483
481
|
setPending(undefined);
|
|
484
482
|
setRejected(false);
|
|
485
483
|
} catch {
|
|
@@ -518,7 +516,7 @@ export const useEveFork = (
|
|
|
518
516
|
ownerId,
|
|
519
517
|
message,
|
|
520
518
|
modelIds,
|
|
521
|
-
{
|
|
519
|
+
{ branchId, fork: source, forkKind: "edit" },
|
|
522
520
|
selectedTool ?? undefined
|
|
523
521
|
)
|
|
524
522
|
: prepareCreation(
|
|
@@ -526,7 +524,7 @@ export const useEveFork = (
|
|
|
526
524
|
ownerId,
|
|
527
525
|
message,
|
|
528
526
|
modelIds[0],
|
|
529
|
-
{
|
|
527
|
+
{ branchId, fork: source, forkKind: "edit" },
|
|
530
528
|
selectedTool ?? undefined
|
|
531
529
|
);
|
|
532
530
|
setPending(operation);
|
|
@@ -6,11 +6,11 @@ import type { LogicalCommands } from "@/lib/eve/logical-commands";
|
|
|
6
6
|
|
|
7
7
|
export const useLogicalCommands = (
|
|
8
8
|
commands: Readonly<Pick<LogicalCommands, "get" | "subscribe">>,
|
|
9
|
-
|
|
9
|
+
branchId: string
|
|
10
10
|
) => {
|
|
11
11
|
const getSnapshot = useCallback(
|
|
12
|
-
() => commands.get(
|
|
13
|
-
[commands,
|
|
12
|
+
() => commands.get(branchId),
|
|
13
|
+
[commands, branchId]
|
|
14
14
|
);
|
|
15
15
|
return useSyncExternalStore(commands.subscribe, getSnapshot, getSnapshot);
|
|
16
16
|
};
|
|
@@ -29,7 +29,9 @@ import { draftMessage, restoreDraft } from "@/lib/eve/draft";
|
|
|
29
29
|
import {
|
|
30
30
|
finishCreation,
|
|
31
31
|
prepareSelectedCreation,
|
|
32
|
+
readCreationFollowUp,
|
|
32
33
|
readCreationRequest,
|
|
34
|
+
saveCreationFollowUp,
|
|
33
35
|
} from "@/lib/eve/pending-create";
|
|
34
36
|
import { resolveCreationRequest } from "@/lib/eve/resolve-creation-request";
|
|
35
37
|
import type { ReadonlyNativeSurface } from "@/lib/readonly-native-surface";
|
|
@@ -70,6 +72,8 @@ export const useNewEveConversation = ({
|
|
|
70
72
|
() =>
|
|
71
73
|
createClientSnapshot<{
|
|
72
74
|
draft: string;
|
|
75
|
+
followUpDraft: string;
|
|
76
|
+
recoveredFollowUp: boolean;
|
|
73
77
|
selectedTool: UiToolName | null;
|
|
74
78
|
retainedOperationId: string | undefined;
|
|
75
79
|
retainedModelId: string | undefined;
|
|
@@ -78,6 +82,8 @@ export const useNewEveConversation = ({
|
|
|
78
82
|
}>(
|
|
79
83
|
{
|
|
80
84
|
draft: "",
|
|
85
|
+
followUpDraft: "",
|
|
86
|
+
recoveredFollowUp: false,
|
|
81
87
|
selectedTool: null,
|
|
82
88
|
retainedOperationId: undefined,
|
|
83
89
|
retainedModelId: undefined,
|
|
@@ -87,14 +93,24 @@ export const useNewEveConversation = ({
|
|
|
87
93
|
(current) => {
|
|
88
94
|
try {
|
|
89
95
|
const pending = readCreationRequest(sessionStorage, ownerId, scope);
|
|
96
|
+
const savedFollowUp = readCreationFollowUp(
|
|
97
|
+
sessionStorage,
|
|
98
|
+
ownerId,
|
|
99
|
+
scope
|
|
100
|
+
);
|
|
90
101
|
if (!pending) {
|
|
91
|
-
return
|
|
102
|
+
return {
|
|
103
|
+
...current,
|
|
104
|
+
draft: savedFollowUp,
|
|
105
|
+
recoveredFollowUp: hasText(savedFollowUp),
|
|
106
|
+
};
|
|
92
107
|
}
|
|
93
108
|
const restored = restoreDraft(pending.message);
|
|
94
109
|
setAttachments(restored.attachments);
|
|
95
110
|
return {
|
|
96
111
|
...current,
|
|
97
112
|
draft: restored.text,
|
|
113
|
+
followUpDraft: savedFollowUp,
|
|
98
114
|
selectedTool: pending.selectedTool ?? null,
|
|
99
115
|
retainedOperationId: pending.operationId,
|
|
100
116
|
retainedModelIds:
|
|
@@ -114,6 +130,8 @@ export const useNewEveConversation = ({
|
|
|
114
130
|
);
|
|
115
131
|
const {
|
|
116
132
|
draft,
|
|
133
|
+
followUpDraft,
|
|
134
|
+
recoveredFollowUp,
|
|
117
135
|
selectedTool,
|
|
118
136
|
retainedOperationId,
|
|
119
137
|
retainedModelId,
|
|
@@ -206,14 +224,24 @@ export const useNewEveConversation = ({
|
|
|
206
224
|
creationInput
|
|
207
225
|
);
|
|
208
226
|
retainOperation(operation);
|
|
227
|
+
if (recoveredFollowUp) {
|
|
228
|
+
saveCreationFollowUp(sessionStorage, ownerId, "", scope);
|
|
229
|
+
store.set("recoveredFollowUp", false);
|
|
230
|
+
}
|
|
209
231
|
const binding = await resolveCreationRequest(
|
|
210
232
|
sessionStorage,
|
|
211
233
|
ownerId,
|
|
212
234
|
operation,
|
|
213
235
|
scope
|
|
214
236
|
);
|
|
215
|
-
await openRuntime({
|
|
237
|
+
await openRuntime({
|
|
238
|
+
...binding,
|
|
239
|
+
operation,
|
|
240
|
+
ownerId,
|
|
241
|
+
getFollowUpDraft: () => store.getSnapshot().followUpDraft,
|
|
242
|
+
});
|
|
216
243
|
navigating = true;
|
|
244
|
+
saveCreationFollowUp(sessionStorage, ownerId, "", scope);
|
|
217
245
|
} catch (error) {
|
|
218
246
|
if (
|
|
219
247
|
error instanceof CreationRejectedError &&
|
|
@@ -282,7 +310,8 @@ export const useNewEveConversation = ({
|
|
|
282
310
|
autoFocus: true,
|
|
283
311
|
status: busy ? "submitted" : "ready",
|
|
284
312
|
disabled: busy,
|
|
285
|
-
|
|
313
|
+
allowDraftWhileBusy: true,
|
|
314
|
+
draft: busy ? followUpDraft : draft,
|
|
286
315
|
capabilities: {
|
|
287
316
|
files: busy ? { ...files, attachments: [] } : files,
|
|
288
317
|
selectedTool,
|
|
@@ -310,12 +339,18 @@ export const useNewEveConversation = ({
|
|
|
310
339
|
/>
|
|
311
340
|
),
|
|
312
341
|
onDraftChange: (value: string) => {
|
|
313
|
-
|
|
314
|
-
if (
|
|
315
|
-
|
|
342
|
+
store.set(busy ? "followUpDraft" : "draft", value);
|
|
343
|
+
if (busy || recoveredFollowUp) {
|
|
344
|
+
try {
|
|
345
|
+
saveCreationFollowUp(sessionStorage, ownerId, value, scope);
|
|
346
|
+
} catch {
|
|
347
|
+
setFailure(
|
|
348
|
+
"Your follow-up draft could not be saved. Keep this tab open."
|
|
349
|
+
);
|
|
350
|
+
}
|
|
316
351
|
}
|
|
317
352
|
},
|
|
318
|
-
readOnly: retained,
|
|
353
|
+
readOnly: retained && !busy,
|
|
319
354
|
} satisfies Omit<ComponentProps<typeof EveComposer>, "onSubmit">;
|
|
320
355
|
return {
|
|
321
356
|
contextual: scope?.context !== undefined,
|