From 218a3bbb52f3b4c14809be6860141a6a2d8be5bc Mon Sep 17 00:00:00 2001 From: Flavien David Date: Tue, 18 Mar 2025 16:32:27 +0100 Subject: [PATCH 1/8] Restructure extension --- extension/{app => platforms/chrome}/background.ts | 8 ++++---- extension/platforms/chrome/index.ts | 5 +++++ .../chrome/manifests}/manifest.base.json | 0 .../chrome/manifests}/manifest.development.json | 0 .../chrome/manifests}/manifest.production.json | 0 .../chrome/manifests}/manifest.release.json | 0 .../src => shared}/components/DropzoneContainer.tsx | 0 .../{app/src => shared}/components/PortContext.tsx | 0 .../components/assistants/AssistantFavorites.tsx | 0 .../components/assistants/AssistantPicker.tsx | 0 .../assistants/usePublicAgentConfigurations.ts | 0 .../src => shared}/components/auth/AuthProvider.tsx | 0 .../components/auth/ProtectedRoute.tsx | 0 .../{app/src => shared}/components/auth/useAuth.ts | 0 .../components/conversation/AgentMessage.tsx | 0 .../components/conversation/AgentMessageActions.tsx | 0 .../components/conversation/AgentSuggestion.tsx | 0 .../components/conversation/AttachFile.tsx | 0 .../components/conversation/AttachFragment.tsx | 0 .../conversation/ConversationContainer.tsx | 0 .../components/conversation/ConversationViewer.tsx | 0 .../conversation/ConversationsListButton.tsx | 0 .../components/conversation/FeedbackSelector.tsx | 0 .../components/conversation/FileUploaderContext.tsx | 0 .../conversation/GenerationContextProvider.tsx | 0 .../components/conversation/MessageGroup.tsx | 0 .../components/conversation/MessageItem.tsx | 0 .../components/conversation/ReachedLimitPopup.tsx | 0 .../components/conversation/UserMessage.tsx | 0 .../conversation/useConversationFeedbacks.ts | 0 .../components/conversation/useConversations.ts | 0 .../conversation/usePublicConversation.ts | 0 .../components/input_bar/InputBar.tsx | 0 .../components/input_bar/InputBarCitations.tsx | 0 .../components/input_bar/InputBarContainer.tsx | 0 .../components/input_bar/InputBarContext.tsx | 0 .../components/input_bar/editor/MentionList.tsx | 0 .../components/input_bar/editor/MentionStorage.ts | 0 .../input_bar/editor/MentionWithPaste.tsx | 0 .../components/input_bar/editor/suggestion.ts | 0 .../components/input_bar/editor/useCustomEditor.tsx | 0 .../input_bar/editor/useHandleMentions.tsx | 0 .../editor/usePublicAssistantSuggestions.ts | 0 .../components/markdown/CiteBlock.tsx | 0 .../components/markdown/MarkdownCitation.tsx | 0 .../components/markdown/MentionBlock.tsx | 0 .../components/utils/useSubmitFunction.tsx | 0 extension/shared/contextes/platform.ts | 7 +++++++ extension/{app/src => shared}/css/components.css | 0 extension/{app/src => shared}/css/custom.css | 0 extension/{app/src => shared}/css/global.css | 0 .../{app/src => shared}/hooks/useAuthErrorCheck.ts | 0 .../{app/src => shared}/hooks/useCurrentDomain.ts | 0 .../{app/src => shared}/hooks/useEventSource.ts | 0 .../src => shared}/hooks/useFileUploaderService.ts | 0 extension/{app => shared}/images/dust128.png | Bin extension/{app => shared}/images/dust16.png | Bin extension/{app => shared}/images/dust32.png | Bin extension/{app => shared}/images/dust48.png | Bin extension/{app => shared}/images/icon128.png | Bin .../{app/src => shared}/lib/assertNeverAndIgnore.ts | 0 extension/{app/src => shared}/lib/auth.ts | 0 extension/{app/src => shared}/lib/config.ts | 0 extension/{app/src => shared}/lib/conversation.ts | 0 extension/{app/src => shared}/lib/dust_api.ts | 0 extension/{app/src => shared}/lib/extraction.ts | 0 extension/{app/src => shared}/lib/feedbacks.ts | 0 extension/{app/src => shared}/lib/greetings.ts | 0 extension/{app/src => shared}/lib/messages.ts | 0 extension/{app/src => shared}/lib/storage.ts | 0 extension/{app/src => shared}/lib/swr.ts | 0 extension/{app/src => shared}/lib/types.ts | 0 extension/{app/src => shared}/lib/utils.ts | 0 .../{app/src => shared}/pages/ConversationPage.tsx | 0 extension/{app/src => shared}/pages/LoginPage.tsx | 0 extension/{app/src => shared}/pages/MainPage.tsx | 0 extension/{app/src => shared}/pages/RunPage.tsx | 0 extension/{app/src => shared}/pages/routes.tsx | 0 extension/shared/services/platform.ts | 3 +++ extension/tsconfig.json | 6 +++--- 80 files changed, 22 insertions(+), 7 deletions(-) rename extension/{app => platforms/chrome}/background.ts (99%) create mode 100644 extension/platforms/chrome/index.ts rename extension/{config => platforms/chrome/manifests}/manifest.base.json (100%) rename extension/{config => platforms/chrome/manifests}/manifest.development.json (100%) rename extension/{config => platforms/chrome/manifests}/manifest.production.json (100%) rename extension/{config => platforms/chrome/manifests}/manifest.release.json (100%) rename extension/{app/src => shared}/components/DropzoneContainer.tsx (100%) rename extension/{app/src => shared}/components/PortContext.tsx (100%) rename extension/{app/src => shared}/components/assistants/AssistantFavorites.tsx (100%) rename extension/{app/src => shared}/components/assistants/AssistantPicker.tsx (100%) rename extension/{app/src => shared}/components/assistants/usePublicAgentConfigurations.ts (100%) rename extension/{app/src => shared}/components/auth/AuthProvider.tsx (100%) rename extension/{app/src => shared}/components/auth/ProtectedRoute.tsx (100%) rename extension/{app/src => shared}/components/auth/useAuth.ts (100%) rename extension/{app/src => shared}/components/conversation/AgentMessage.tsx (100%) rename extension/{app/src => shared}/components/conversation/AgentMessageActions.tsx (100%) rename extension/{app/src => shared}/components/conversation/AgentSuggestion.tsx (100%) rename extension/{app/src => shared}/components/conversation/AttachFile.tsx (100%) rename extension/{app/src => shared}/components/conversation/AttachFragment.tsx (100%) rename extension/{app/src => shared}/components/conversation/ConversationContainer.tsx (100%) rename extension/{app/src => shared}/components/conversation/ConversationViewer.tsx (100%) rename extension/{app/src => shared}/components/conversation/ConversationsListButton.tsx (100%) rename extension/{app/src => shared}/components/conversation/FeedbackSelector.tsx (100%) rename extension/{app/src => shared}/components/conversation/FileUploaderContext.tsx (100%) rename extension/{app/src => shared}/components/conversation/GenerationContextProvider.tsx (100%) rename extension/{app/src => shared}/components/conversation/MessageGroup.tsx (100%) rename extension/{app/src => shared}/components/conversation/MessageItem.tsx (100%) rename extension/{app/src => shared}/components/conversation/ReachedLimitPopup.tsx (100%) rename extension/{app/src => shared}/components/conversation/UserMessage.tsx (100%) rename extension/{app/src => shared}/components/conversation/useConversationFeedbacks.ts (100%) rename extension/{app/src => shared}/components/conversation/useConversations.ts (100%) rename extension/{app/src => shared}/components/conversation/usePublicConversation.ts (100%) rename extension/{app/src => shared}/components/input_bar/InputBar.tsx (100%) rename extension/{app/src => shared}/components/input_bar/InputBarCitations.tsx (100%) rename extension/{app/src => shared}/components/input_bar/InputBarContainer.tsx (100%) rename extension/{app/src => shared}/components/input_bar/InputBarContext.tsx (100%) rename extension/{app/src => shared}/components/input_bar/editor/MentionList.tsx (100%) rename extension/{app/src => shared}/components/input_bar/editor/MentionStorage.ts (100%) rename extension/{app/src => shared}/components/input_bar/editor/MentionWithPaste.tsx (100%) rename extension/{app/src => shared}/components/input_bar/editor/suggestion.ts (100%) rename extension/{app/src => shared}/components/input_bar/editor/useCustomEditor.tsx (100%) rename extension/{app/src => shared}/components/input_bar/editor/useHandleMentions.tsx (100%) rename extension/{app/src => shared}/components/input_bar/editor/usePublicAssistantSuggestions.ts (100%) rename extension/{app/src => shared}/components/markdown/CiteBlock.tsx (100%) rename extension/{app/src => shared}/components/markdown/MarkdownCitation.tsx (100%) rename extension/{app/src => shared}/components/markdown/MentionBlock.tsx (100%) rename extension/{app/src => shared}/components/utils/useSubmitFunction.tsx (100%) create mode 100644 extension/shared/contextes/platform.ts rename extension/{app/src => shared}/css/components.css (100%) rename extension/{app/src => shared}/css/custom.css (100%) rename extension/{app/src => shared}/css/global.css (100%) rename extension/{app/src => shared}/hooks/useAuthErrorCheck.ts (100%) rename extension/{app/src => shared}/hooks/useCurrentDomain.ts (100%) rename extension/{app/src => shared}/hooks/useEventSource.ts (100%) rename extension/{app/src => shared}/hooks/useFileUploaderService.ts (100%) rename extension/{app => shared}/images/dust128.png (100%) rename extension/{app => shared}/images/dust16.png (100%) rename extension/{app => shared}/images/dust32.png (100%) rename extension/{app => shared}/images/dust48.png (100%) rename extension/{app => shared}/images/icon128.png (100%) rename extension/{app/src => shared}/lib/assertNeverAndIgnore.ts (100%) rename extension/{app/src => shared}/lib/auth.ts (100%) rename extension/{app/src => shared}/lib/config.ts (100%) rename extension/{app/src => shared}/lib/conversation.ts (100%) rename extension/{app/src => shared}/lib/dust_api.ts (100%) rename extension/{app/src => shared}/lib/extraction.ts (100%) rename extension/{app/src => shared}/lib/feedbacks.ts (100%) rename extension/{app/src => shared}/lib/greetings.ts (100%) rename extension/{app/src => shared}/lib/messages.ts (100%) rename extension/{app/src => shared}/lib/storage.ts (100%) rename extension/{app/src => shared}/lib/swr.ts (100%) rename extension/{app/src => shared}/lib/types.ts (100%) rename extension/{app/src => shared}/lib/utils.ts (100%) rename extension/{app/src => shared}/pages/ConversationPage.tsx (100%) rename extension/{app/src => shared}/pages/LoginPage.tsx (100%) rename extension/{app/src => shared}/pages/MainPage.tsx (100%) rename extension/{app/src => shared}/pages/RunPage.tsx (100%) rename extension/{app/src => shared}/pages/routes.tsx (100%) create mode 100644 extension/shared/services/platform.ts diff --git a/extension/app/background.ts b/extension/platforms/chrome/background.ts similarity index 99% rename from extension/app/background.ts rename to extension/platforms/chrome/background.ts index 72192fe64866..76ec95ad1784 100644 --- a/extension/app/background.ts +++ b/extension/platforms/chrome/background.ts @@ -5,8 +5,8 @@ import { AUTH0_CLIENT_DOMAIN, AUTH0_CLIENT_ID, DUST_API_AUDIENCE, -} from "./src/lib/config"; -import { extractPage } from "./src/lib/extraction"; +} from "../../app/src/lib/config"; +import { extractPage } from "../../app/src/lib/extraction"; import type { Auth0AuthorizeResponse, AuthBackgroundMessage, @@ -16,8 +16,8 @@ import type { GetActiveTabBackgroundMessage, GetActiveTabBackgroundResponse, InputBarStatusMessage, -} from "./src/lib/messages"; -import { generatePKCE } from "./src/lib/utils"; +} from "../../app/src/lib/messages"; +import { generatePKCE } from "../../app/src/lib/utils"; const log = console.error; diff --git a/extension/platforms/chrome/index.ts b/extension/platforms/chrome/index.ts new file mode 100644 index 000000000000..96a6920de3df --- /dev/null +++ b/extension/platforms/chrome/index.ts @@ -0,0 +1,5 @@ +import type { PlatformService } from "shared/services/platform"; + +export const chromePlatform: PlatformService = { + platform: "chrome", +}; diff --git a/extension/config/manifest.base.json b/extension/platforms/chrome/manifests/manifest.base.json similarity index 100% rename from extension/config/manifest.base.json rename to extension/platforms/chrome/manifests/manifest.base.json diff --git a/extension/config/manifest.development.json b/extension/platforms/chrome/manifests/manifest.development.json similarity index 100% rename from extension/config/manifest.development.json rename to extension/platforms/chrome/manifests/manifest.development.json diff --git a/extension/config/manifest.production.json b/extension/platforms/chrome/manifests/manifest.production.json similarity index 100% rename from extension/config/manifest.production.json rename to extension/platforms/chrome/manifests/manifest.production.json diff --git a/extension/config/manifest.release.json b/extension/platforms/chrome/manifests/manifest.release.json similarity index 100% rename from extension/config/manifest.release.json rename to extension/platforms/chrome/manifests/manifest.release.json diff --git a/extension/app/src/components/DropzoneContainer.tsx b/extension/shared/components/DropzoneContainer.tsx similarity index 100% rename from extension/app/src/components/DropzoneContainer.tsx rename to extension/shared/components/DropzoneContainer.tsx diff --git a/extension/app/src/components/PortContext.tsx b/extension/shared/components/PortContext.tsx similarity index 100% rename from extension/app/src/components/PortContext.tsx rename to extension/shared/components/PortContext.tsx diff --git a/extension/app/src/components/assistants/AssistantFavorites.tsx b/extension/shared/components/assistants/AssistantFavorites.tsx similarity index 100% rename from extension/app/src/components/assistants/AssistantFavorites.tsx rename to extension/shared/components/assistants/AssistantFavorites.tsx diff --git a/extension/app/src/components/assistants/AssistantPicker.tsx b/extension/shared/components/assistants/AssistantPicker.tsx similarity index 100% rename from extension/app/src/components/assistants/AssistantPicker.tsx rename to extension/shared/components/assistants/AssistantPicker.tsx diff --git a/extension/app/src/components/assistants/usePublicAgentConfigurations.ts b/extension/shared/components/assistants/usePublicAgentConfigurations.ts similarity index 100% rename from extension/app/src/components/assistants/usePublicAgentConfigurations.ts rename to extension/shared/components/assistants/usePublicAgentConfigurations.ts diff --git a/extension/app/src/components/auth/AuthProvider.tsx b/extension/shared/components/auth/AuthProvider.tsx similarity index 100% rename from extension/app/src/components/auth/AuthProvider.tsx rename to extension/shared/components/auth/AuthProvider.tsx diff --git a/extension/app/src/components/auth/ProtectedRoute.tsx b/extension/shared/components/auth/ProtectedRoute.tsx similarity index 100% rename from extension/app/src/components/auth/ProtectedRoute.tsx rename to extension/shared/components/auth/ProtectedRoute.tsx diff --git a/extension/app/src/components/auth/useAuth.ts b/extension/shared/components/auth/useAuth.ts similarity index 100% rename from extension/app/src/components/auth/useAuth.ts rename to extension/shared/components/auth/useAuth.ts diff --git a/extension/app/src/components/conversation/AgentMessage.tsx b/extension/shared/components/conversation/AgentMessage.tsx similarity index 100% rename from extension/app/src/components/conversation/AgentMessage.tsx rename to extension/shared/components/conversation/AgentMessage.tsx diff --git a/extension/app/src/components/conversation/AgentMessageActions.tsx b/extension/shared/components/conversation/AgentMessageActions.tsx similarity index 100% rename from extension/app/src/components/conversation/AgentMessageActions.tsx rename to extension/shared/components/conversation/AgentMessageActions.tsx diff --git a/extension/app/src/components/conversation/AgentSuggestion.tsx b/extension/shared/components/conversation/AgentSuggestion.tsx similarity index 100% rename from extension/app/src/components/conversation/AgentSuggestion.tsx rename to extension/shared/components/conversation/AgentSuggestion.tsx diff --git a/extension/app/src/components/conversation/AttachFile.tsx b/extension/shared/components/conversation/AttachFile.tsx similarity index 100% rename from extension/app/src/components/conversation/AttachFile.tsx rename to extension/shared/components/conversation/AttachFile.tsx diff --git a/extension/app/src/components/conversation/AttachFragment.tsx b/extension/shared/components/conversation/AttachFragment.tsx similarity index 100% rename from extension/app/src/components/conversation/AttachFragment.tsx rename to extension/shared/components/conversation/AttachFragment.tsx diff --git a/extension/app/src/components/conversation/ConversationContainer.tsx b/extension/shared/components/conversation/ConversationContainer.tsx similarity index 100% rename from extension/app/src/components/conversation/ConversationContainer.tsx rename to extension/shared/components/conversation/ConversationContainer.tsx diff --git a/extension/app/src/components/conversation/ConversationViewer.tsx b/extension/shared/components/conversation/ConversationViewer.tsx similarity index 100% rename from extension/app/src/components/conversation/ConversationViewer.tsx rename to extension/shared/components/conversation/ConversationViewer.tsx diff --git a/extension/app/src/components/conversation/ConversationsListButton.tsx b/extension/shared/components/conversation/ConversationsListButton.tsx similarity index 100% rename from extension/app/src/components/conversation/ConversationsListButton.tsx rename to extension/shared/components/conversation/ConversationsListButton.tsx diff --git a/extension/app/src/components/conversation/FeedbackSelector.tsx b/extension/shared/components/conversation/FeedbackSelector.tsx similarity index 100% rename from extension/app/src/components/conversation/FeedbackSelector.tsx rename to extension/shared/components/conversation/FeedbackSelector.tsx diff --git a/extension/app/src/components/conversation/FileUploaderContext.tsx b/extension/shared/components/conversation/FileUploaderContext.tsx similarity index 100% rename from extension/app/src/components/conversation/FileUploaderContext.tsx rename to extension/shared/components/conversation/FileUploaderContext.tsx diff --git a/extension/app/src/components/conversation/GenerationContextProvider.tsx b/extension/shared/components/conversation/GenerationContextProvider.tsx similarity index 100% rename from extension/app/src/components/conversation/GenerationContextProvider.tsx rename to extension/shared/components/conversation/GenerationContextProvider.tsx diff --git a/extension/app/src/components/conversation/MessageGroup.tsx b/extension/shared/components/conversation/MessageGroup.tsx similarity index 100% rename from extension/app/src/components/conversation/MessageGroup.tsx rename to extension/shared/components/conversation/MessageGroup.tsx diff --git a/extension/app/src/components/conversation/MessageItem.tsx b/extension/shared/components/conversation/MessageItem.tsx similarity index 100% rename from extension/app/src/components/conversation/MessageItem.tsx rename to extension/shared/components/conversation/MessageItem.tsx diff --git a/extension/app/src/components/conversation/ReachedLimitPopup.tsx b/extension/shared/components/conversation/ReachedLimitPopup.tsx similarity index 100% rename from extension/app/src/components/conversation/ReachedLimitPopup.tsx rename to extension/shared/components/conversation/ReachedLimitPopup.tsx diff --git a/extension/app/src/components/conversation/UserMessage.tsx b/extension/shared/components/conversation/UserMessage.tsx similarity index 100% rename from extension/app/src/components/conversation/UserMessage.tsx rename to extension/shared/components/conversation/UserMessage.tsx diff --git a/extension/app/src/components/conversation/useConversationFeedbacks.ts b/extension/shared/components/conversation/useConversationFeedbacks.ts similarity index 100% rename from extension/app/src/components/conversation/useConversationFeedbacks.ts rename to extension/shared/components/conversation/useConversationFeedbacks.ts diff --git a/extension/app/src/components/conversation/useConversations.ts b/extension/shared/components/conversation/useConversations.ts similarity index 100% rename from extension/app/src/components/conversation/useConversations.ts rename to extension/shared/components/conversation/useConversations.ts diff --git a/extension/app/src/components/conversation/usePublicConversation.ts b/extension/shared/components/conversation/usePublicConversation.ts similarity index 100% rename from extension/app/src/components/conversation/usePublicConversation.ts rename to extension/shared/components/conversation/usePublicConversation.ts diff --git a/extension/app/src/components/input_bar/InputBar.tsx b/extension/shared/components/input_bar/InputBar.tsx similarity index 100% rename from extension/app/src/components/input_bar/InputBar.tsx rename to extension/shared/components/input_bar/InputBar.tsx diff --git a/extension/app/src/components/input_bar/InputBarCitations.tsx b/extension/shared/components/input_bar/InputBarCitations.tsx similarity index 100% rename from extension/app/src/components/input_bar/InputBarCitations.tsx rename to extension/shared/components/input_bar/InputBarCitations.tsx diff --git a/extension/app/src/components/input_bar/InputBarContainer.tsx b/extension/shared/components/input_bar/InputBarContainer.tsx similarity index 100% rename from extension/app/src/components/input_bar/InputBarContainer.tsx rename to extension/shared/components/input_bar/InputBarContainer.tsx diff --git a/extension/app/src/components/input_bar/InputBarContext.tsx b/extension/shared/components/input_bar/InputBarContext.tsx similarity index 100% rename from extension/app/src/components/input_bar/InputBarContext.tsx rename to extension/shared/components/input_bar/InputBarContext.tsx diff --git a/extension/app/src/components/input_bar/editor/MentionList.tsx b/extension/shared/components/input_bar/editor/MentionList.tsx similarity index 100% rename from extension/app/src/components/input_bar/editor/MentionList.tsx rename to extension/shared/components/input_bar/editor/MentionList.tsx diff --git a/extension/app/src/components/input_bar/editor/MentionStorage.ts b/extension/shared/components/input_bar/editor/MentionStorage.ts similarity index 100% rename from extension/app/src/components/input_bar/editor/MentionStorage.ts rename to extension/shared/components/input_bar/editor/MentionStorage.ts diff --git a/extension/app/src/components/input_bar/editor/MentionWithPaste.tsx b/extension/shared/components/input_bar/editor/MentionWithPaste.tsx similarity index 100% rename from extension/app/src/components/input_bar/editor/MentionWithPaste.tsx rename to extension/shared/components/input_bar/editor/MentionWithPaste.tsx diff --git a/extension/app/src/components/input_bar/editor/suggestion.ts b/extension/shared/components/input_bar/editor/suggestion.ts similarity index 100% rename from extension/app/src/components/input_bar/editor/suggestion.ts rename to extension/shared/components/input_bar/editor/suggestion.ts diff --git a/extension/app/src/components/input_bar/editor/useCustomEditor.tsx b/extension/shared/components/input_bar/editor/useCustomEditor.tsx similarity index 100% rename from extension/app/src/components/input_bar/editor/useCustomEditor.tsx rename to extension/shared/components/input_bar/editor/useCustomEditor.tsx diff --git a/extension/app/src/components/input_bar/editor/useHandleMentions.tsx b/extension/shared/components/input_bar/editor/useHandleMentions.tsx similarity index 100% rename from extension/app/src/components/input_bar/editor/useHandleMentions.tsx rename to extension/shared/components/input_bar/editor/useHandleMentions.tsx diff --git a/extension/app/src/components/input_bar/editor/usePublicAssistantSuggestions.ts b/extension/shared/components/input_bar/editor/usePublicAssistantSuggestions.ts similarity index 100% rename from extension/app/src/components/input_bar/editor/usePublicAssistantSuggestions.ts rename to extension/shared/components/input_bar/editor/usePublicAssistantSuggestions.ts diff --git a/extension/app/src/components/markdown/CiteBlock.tsx b/extension/shared/components/markdown/CiteBlock.tsx similarity index 100% rename from extension/app/src/components/markdown/CiteBlock.tsx rename to extension/shared/components/markdown/CiteBlock.tsx diff --git a/extension/app/src/components/markdown/MarkdownCitation.tsx b/extension/shared/components/markdown/MarkdownCitation.tsx similarity index 100% rename from extension/app/src/components/markdown/MarkdownCitation.tsx rename to extension/shared/components/markdown/MarkdownCitation.tsx diff --git a/extension/app/src/components/markdown/MentionBlock.tsx b/extension/shared/components/markdown/MentionBlock.tsx similarity index 100% rename from extension/app/src/components/markdown/MentionBlock.tsx rename to extension/shared/components/markdown/MentionBlock.tsx diff --git a/extension/app/src/components/utils/useSubmitFunction.tsx b/extension/shared/components/utils/useSubmitFunction.tsx similarity index 100% rename from extension/app/src/components/utils/useSubmitFunction.tsx rename to extension/shared/components/utils/useSubmitFunction.tsx diff --git a/extension/shared/contextes/platform.ts b/extension/shared/contextes/platform.ts new file mode 100644 index 000000000000..e4292be3930b --- /dev/null +++ b/extension/shared/contextes/platform.ts @@ -0,0 +1,7 @@ +import React, { useContext } from "react"; + +import type { PlatformService } from "../services/platform"; + +export const PlatformContext = React.createContext(null!); + +export const usePlatform = () => useContext(PlatformContext); diff --git a/extension/app/src/css/components.css b/extension/shared/css/components.css similarity index 100% rename from extension/app/src/css/components.css rename to extension/shared/css/components.css diff --git a/extension/app/src/css/custom.css b/extension/shared/css/custom.css similarity index 100% rename from extension/app/src/css/custom.css rename to extension/shared/css/custom.css diff --git a/extension/app/src/css/global.css b/extension/shared/css/global.css similarity index 100% rename from extension/app/src/css/global.css rename to extension/shared/css/global.css diff --git a/extension/app/src/hooks/useAuthErrorCheck.ts b/extension/shared/hooks/useAuthErrorCheck.ts similarity index 100% rename from extension/app/src/hooks/useAuthErrorCheck.ts rename to extension/shared/hooks/useAuthErrorCheck.ts diff --git a/extension/app/src/hooks/useCurrentDomain.ts b/extension/shared/hooks/useCurrentDomain.ts similarity index 100% rename from extension/app/src/hooks/useCurrentDomain.ts rename to extension/shared/hooks/useCurrentDomain.ts diff --git a/extension/app/src/hooks/useEventSource.ts b/extension/shared/hooks/useEventSource.ts similarity index 100% rename from extension/app/src/hooks/useEventSource.ts rename to extension/shared/hooks/useEventSource.ts diff --git a/extension/app/src/hooks/useFileUploaderService.ts b/extension/shared/hooks/useFileUploaderService.ts similarity index 100% rename from extension/app/src/hooks/useFileUploaderService.ts rename to extension/shared/hooks/useFileUploaderService.ts diff --git a/extension/app/images/dust128.png b/extension/shared/images/dust128.png similarity index 100% rename from extension/app/images/dust128.png rename to extension/shared/images/dust128.png diff --git a/extension/app/images/dust16.png b/extension/shared/images/dust16.png similarity index 100% rename from extension/app/images/dust16.png rename to extension/shared/images/dust16.png diff --git a/extension/app/images/dust32.png b/extension/shared/images/dust32.png similarity index 100% rename from extension/app/images/dust32.png rename to extension/shared/images/dust32.png diff --git a/extension/app/images/dust48.png b/extension/shared/images/dust48.png similarity index 100% rename from extension/app/images/dust48.png rename to extension/shared/images/dust48.png diff --git a/extension/app/images/icon128.png b/extension/shared/images/icon128.png similarity index 100% rename from extension/app/images/icon128.png rename to extension/shared/images/icon128.png diff --git a/extension/app/src/lib/assertNeverAndIgnore.ts b/extension/shared/lib/assertNeverAndIgnore.ts similarity index 100% rename from extension/app/src/lib/assertNeverAndIgnore.ts rename to extension/shared/lib/assertNeverAndIgnore.ts diff --git a/extension/app/src/lib/auth.ts b/extension/shared/lib/auth.ts similarity index 100% rename from extension/app/src/lib/auth.ts rename to extension/shared/lib/auth.ts diff --git a/extension/app/src/lib/config.ts b/extension/shared/lib/config.ts similarity index 100% rename from extension/app/src/lib/config.ts rename to extension/shared/lib/config.ts diff --git a/extension/app/src/lib/conversation.ts b/extension/shared/lib/conversation.ts similarity index 100% rename from extension/app/src/lib/conversation.ts rename to extension/shared/lib/conversation.ts diff --git a/extension/app/src/lib/dust_api.ts b/extension/shared/lib/dust_api.ts similarity index 100% rename from extension/app/src/lib/dust_api.ts rename to extension/shared/lib/dust_api.ts diff --git a/extension/app/src/lib/extraction.ts b/extension/shared/lib/extraction.ts similarity index 100% rename from extension/app/src/lib/extraction.ts rename to extension/shared/lib/extraction.ts diff --git a/extension/app/src/lib/feedbacks.ts b/extension/shared/lib/feedbacks.ts similarity index 100% rename from extension/app/src/lib/feedbacks.ts rename to extension/shared/lib/feedbacks.ts diff --git a/extension/app/src/lib/greetings.ts b/extension/shared/lib/greetings.ts similarity index 100% rename from extension/app/src/lib/greetings.ts rename to extension/shared/lib/greetings.ts diff --git a/extension/app/src/lib/messages.ts b/extension/shared/lib/messages.ts similarity index 100% rename from extension/app/src/lib/messages.ts rename to extension/shared/lib/messages.ts diff --git a/extension/app/src/lib/storage.ts b/extension/shared/lib/storage.ts similarity index 100% rename from extension/app/src/lib/storage.ts rename to extension/shared/lib/storage.ts diff --git a/extension/app/src/lib/swr.ts b/extension/shared/lib/swr.ts similarity index 100% rename from extension/app/src/lib/swr.ts rename to extension/shared/lib/swr.ts diff --git a/extension/app/src/lib/types.ts b/extension/shared/lib/types.ts similarity index 100% rename from extension/app/src/lib/types.ts rename to extension/shared/lib/types.ts diff --git a/extension/app/src/lib/utils.ts b/extension/shared/lib/utils.ts similarity index 100% rename from extension/app/src/lib/utils.ts rename to extension/shared/lib/utils.ts diff --git a/extension/app/src/pages/ConversationPage.tsx b/extension/shared/pages/ConversationPage.tsx similarity index 100% rename from extension/app/src/pages/ConversationPage.tsx rename to extension/shared/pages/ConversationPage.tsx diff --git a/extension/app/src/pages/LoginPage.tsx b/extension/shared/pages/LoginPage.tsx similarity index 100% rename from extension/app/src/pages/LoginPage.tsx rename to extension/shared/pages/LoginPage.tsx diff --git a/extension/app/src/pages/MainPage.tsx b/extension/shared/pages/MainPage.tsx similarity index 100% rename from extension/app/src/pages/MainPage.tsx rename to extension/shared/pages/MainPage.tsx diff --git a/extension/app/src/pages/RunPage.tsx b/extension/shared/pages/RunPage.tsx similarity index 100% rename from extension/app/src/pages/RunPage.tsx rename to extension/shared/pages/RunPage.tsx diff --git a/extension/app/src/pages/routes.tsx b/extension/shared/pages/routes.tsx similarity index 100% rename from extension/app/src/pages/routes.tsx rename to extension/shared/pages/routes.tsx diff --git a/extension/shared/services/platform.ts b/extension/shared/services/platform.ts new file mode 100644 index 000000000000..e13e4d4aa781 --- /dev/null +++ b/extension/shared/services/platform.ts @@ -0,0 +1,3 @@ +export interface PlatformService { + platform: "chrome" | "front"; +} diff --git a/extension/tsconfig.json b/extension/tsconfig.json index 726e8e5e06b9..fdb1d2485d8c 100644 --- a/extension/tsconfig.json +++ b/extension/tsconfig.json @@ -9,9 +9,9 @@ "declaration": false, "noEmit": false, "isolatedModules": true, - "baseUrl": "./app", + "baseUrl": "./", "outDir": "./build", - "rootDir": "./app", + "rootDir": "./", "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, @@ -25,6 +25,6 @@ "@extension/*": ["./src/*"] } }, - "include": ["app/**/*"], + "include": ["./shared/**/*", "./platforms/**/*"], "exclude": ["node_modules", "build"] } From b753111f8724b4d7f8cbd1b91fbd1481a45af110 Mon Sep 17 00:00:00 2001 From: Flavien David Date: Tue, 18 Mar 2025 16:51:38 +0100 Subject: [PATCH 2/8] Restructure more --- extension/platforms/chrome/background.ts | 12 +++--- extension/tsconfig.json | 4 +- .../components/DropzoneContainer.tsx | 2 +- .../assistants/AssistantFavorites.tsx | 0 .../components/assistants/AssistantPicker.tsx | 0 .../usePublicAgentConfigurations.ts | 0 .../components/auth/AuthProvider.tsx | 6 +-- .../components/auth/ProtectedRoute.tsx | 8 ++-- .../{shared => ui}/components/auth/useAuth.ts | 8 ++-- .../components/conversation/AgentMessage.tsx | 40 +++++++++--------- .../conversation/AgentMessageActions.tsx | 2 +- .../conversation/AgentSuggestion.tsx | 8 ++-- .../components/conversation/AttachFile.tsx | 4 +- .../conversation/AttachFragment.tsx | 6 +-- .../conversation/ConversationContainer.tsx | 38 ++++++++--------- .../conversation/ConversationViewer.tsx | 16 +++---- .../conversation/ConversationsListButton.tsx | 2 +- .../conversation/FeedbackSelector.tsx | 0 .../conversation/FileUploaderContext.tsx | 0 .../GenerationContextProvider.tsx | 0 .../components/conversation/MessageGroup.tsx | 8 ++-- .../components/conversation/MessageItem.tsx | 16 +++---- .../conversation/ReachedLimitPopup.tsx | 0 .../components/conversation/UserMessage.tsx | 10 ++--- .../conversation/useConversationFeedbacks.ts | 6 +-- .../conversation/useConversations.ts | 4 +- .../conversation/usePublicConversation.ts | 4 +- .../components/input_bar/InputBar.tsx | 26 ++++++------ .../input_bar/InputBarCitations.tsx | 2 +- .../input_bar/InputBarContainer.tsx | 20 ++++----- .../components/input_bar/InputBarContext.tsx | 0 .../input_bar/editor/MentionList.tsx | 4 +- .../input_bar/editor/MentionStorage.ts | 2 +- .../input_bar/editor/MentionWithPaste.tsx | 2 +- .../components/input_bar/editor/suggestion.ts | 4 +- .../input_bar/editor/useCustomEditor.tsx | 8 ++-- .../input_bar/editor/useHandleMentions.tsx | 8 ++-- .../editor/usePublicAssistantSuggestions.ts | 4 +- .../components/markdown/CiteBlock.tsx | 3 +- .../components/markdown/MarkdownCitation.tsx | 0 .../components/markdown/MentionBlock.tsx | 0 .../components/utils/useSubmitFunction.tsx | 0 .../contextes/PlateformContext.ts} | 3 +- .../contextes}/PortContext.tsx | 0 extension/{shared => ui}/css/components.css | 0 extension/{shared => ui}/css/custom.css | 0 extension/{shared => ui}/css/global.css | 0 .../{shared => ui}/hooks/useAuthErrorCheck.ts | 4 +- .../{shared => ui}/hooks/useCurrentDomain.ts | 0 .../{shared => ui}/hooks/useEventSource.ts | 2 +- .../hooks/useFileUploaderService.ts | 8 ++-- extension/{shared => ui}/images/dust128.png | Bin extension/{shared => ui}/images/dust16.png | Bin extension/{shared => ui}/images/dust32.png | Bin extension/{shared => ui}/images/dust48.png | Bin extension/{shared => ui}/images/icon128.png | Bin extension/{app => ui}/main.html | 0 extension/{app => ui}/main.tsx | 12 +++--- .../{shared => ui}/pages/ConversationPage.tsx | 14 +++--- extension/{shared => ui}/pages/LoginPage.tsx | 2 +- extension/{shared => ui}/pages/MainPage.tsx | 18 ++++---- extension/{shared => ui}/pages/RunPage.tsx | 6 +-- extension/{shared => ui}/pages/routes.tsx | 10 ++--- 63 files changed, 182 insertions(+), 184 deletions(-) rename extension/{shared => ui}/components/DropzoneContainer.tsx (98%) rename extension/{shared => ui}/components/assistants/AssistantFavorites.tsx (100%) rename extension/{shared => ui}/components/assistants/AssistantPicker.tsx (100%) rename extension/{shared => ui}/components/assistants/usePublicAgentConfigurations.ts (100%) rename extension/{shared => ui}/components/auth/AuthProvider.tsx (89%) rename extension/{shared => ui}/components/auth/ProtectedRoute.tsx (93%) rename extension/{shared => ui}/components/auth/useAuth.ts (97%) rename extension/{shared => ui}/components/conversation/AgentMessage.tsx (95%) rename extension/{shared => ui}/components/conversation/AgentMessageActions.tsx (98%) rename extension/{shared => ui}/components/conversation/AgentSuggestion.tsx (91%) rename extension/{shared => ui}/components/conversation/AttachFile.tsx (87%) rename extension/{shared => ui}/components/conversation/AttachFragment.tsx (93%) rename extension/{shared => ui}/components/conversation/ConversationContainer.tsx (90%) rename extension/{shared => ui}/components/conversation/ConversationViewer.tsx (91%) rename extension/{shared => ui}/components/conversation/ConversationsListButton.tsx (97%) rename extension/{shared => ui}/components/conversation/FeedbackSelector.tsx (100%) rename extension/{shared => ui}/components/conversation/FileUploaderContext.tsx (100%) rename extension/{shared => ui}/components/conversation/GenerationContextProvider.tsx (100%) rename extension/{shared => ui}/components/conversation/MessageGroup.tsx (87%) rename extension/{shared => ui}/components/conversation/MessageItem.tsx (88%) rename extension/{shared => ui}/components/conversation/ReachedLimitPopup.tsx (100%) rename extension/{shared => ui}/components/conversation/UserMessage.tsx (90%) rename extension/{shared => ui}/components/conversation/useConversationFeedbacks.ts (83%) rename extension/{shared => ui}/components/conversation/useConversations.ts (87%) rename extension/{shared => ui}/components/conversation/usePublicConversation.ts (91%) rename extension/{shared => ui}/components/input_bar/InputBar.tsx (89%) rename extension/{shared => ui}/components/input_bar/InputBarCitations.tsx (94%) rename extension/{shared => ui}/components/input_bar/InputBarContainer.tsx (82%) rename extension/{shared => ui}/components/input_bar/InputBarContext.tsx (100%) rename extension/{shared => ui}/components/input_bar/editor/MentionList.tsx (95%) rename extension/{shared => ui}/components/input_bar/editor/MentionStorage.ts (78%) rename extension/{shared => ui}/components/input_bar/editor/MentionWithPaste.tsx (94%) rename extension/{shared => ui}/components/input_bar/editor/suggestion.ts (95%) rename extension/{shared => ui}/components/input_bar/editor/useCustomEditor.tsx (95%) rename extension/{shared => ui}/components/input_bar/editor/useHandleMentions.tsx (97%) rename extension/{shared => ui}/components/input_bar/editor/usePublicAssistantSuggestions.ts (86%) rename extension/{shared => ui}/components/markdown/CiteBlock.tsx (97%) rename extension/{shared => ui}/components/markdown/MarkdownCitation.tsx (100%) rename extension/{shared => ui}/components/markdown/MentionBlock.tsx (100%) rename extension/{shared => ui}/components/utils/useSubmitFunction.tsx (100%) rename extension/{shared/contextes/platform.ts => ui/contextes/PlateformContext.ts} (72%) rename extension/{shared/components => ui/contextes}/PortContext.tsx (100%) rename extension/{shared => ui}/css/components.css (100%) rename extension/{shared => ui}/css/custom.css (100%) rename extension/{shared => ui}/css/global.css (100%) rename extension/{shared => ui}/hooks/useAuthErrorCheck.ts (88%) rename extension/{shared => ui}/hooks/useCurrentDomain.ts (100%) rename extension/{shared => ui}/hooks/useEventSource.ts (99%) rename extension/{shared => ui}/hooks/useFileUploaderService.ts (97%) rename extension/{shared => ui}/images/dust128.png (100%) rename extension/{shared => ui}/images/dust16.png (100%) rename extension/{shared => ui}/images/dust32.png (100%) rename extension/{shared => ui}/images/dust48.png (100%) rename extension/{shared => ui}/images/icon128.png (100%) rename extension/{app => ui}/main.html (100%) rename extension/{app => ui}/main.tsx (87%) rename extension/{shared => ui}/pages/ConversationPage.tsx (76%) rename extension/{shared => ui}/pages/LoginPage.tsx (98%) rename extension/{shared => ui}/pages/MainPage.tsx (87%) rename extension/{shared => ui}/pages/RunPage.tsx (88%) rename extension/{shared => ui}/pages/routes.tsx (71%) diff --git a/extension/platforms/chrome/background.ts b/extension/platforms/chrome/background.ts index 76ec95ad1784..bae26ad3b6a0 100644 --- a/extension/platforms/chrome/background.ts +++ b/extension/platforms/chrome/background.ts @@ -1,12 +1,12 @@ -import type { PendingUpdate } from "@extension/lib/storage"; -import { getStoredUser, savePendingUpdate } from "@extension/lib/storage"; +import type { PendingUpdate } from "shared/lib/storage"; +import { getStoredUser, savePendingUpdate } from "shared/lib/storage"; import { AUTH0_CLIENT_DOMAIN, AUTH0_CLIENT_ID, DUST_API_AUDIENCE, -} from "../../app/src/lib/config"; -import { extractPage } from "../../app/src/lib/extraction"; +} from "../../shared/lib/config"; +import { extractPage } from "../../shared/lib/extraction"; import type { Auth0AuthorizeResponse, AuthBackgroundMessage, @@ -16,8 +16,8 @@ import type { GetActiveTabBackgroundMessage, GetActiveTabBackgroundResponse, InputBarStatusMessage, -} from "../../app/src/lib/messages"; -import { generatePKCE } from "../../app/src/lib/utils"; +} from "../../shared/lib/messages"; +import { generatePKCE } from "../../shared/lib/utils"; const log = console.error; diff --git a/extension/tsconfig.json b/extension/tsconfig.json index fdb1d2485d8c..115ece63939f 100644 --- a/extension/tsconfig.json +++ b/extension/tsconfig.json @@ -22,9 +22,9 @@ "noImplicitAny": true, "types": ["chrome", "react", "react-dom"], "paths": { - "@extension/*": ["./src/*"] + "@app/*": ["./*"] } }, - "include": ["./shared/**/*", "./platforms/**/*"], + "include": ["./shared/**/*", "./platforms/**/*", "./ui/**/*"], "exclude": ["node_modules", "build"] } diff --git a/extension/shared/components/DropzoneContainer.tsx b/extension/ui/components/DropzoneContainer.tsx similarity index 98% rename from extension/shared/components/DropzoneContainer.tsx rename to extension/ui/components/DropzoneContainer.tsx index aebb1e204810..a5d1b73e0b0c 100644 --- a/extension/shared/components/DropzoneContainer.tsx +++ b/extension/ui/components/DropzoneContainer.tsx @@ -1,3 +1,4 @@ +import { useFileDrop } from "@app/ui/components/conversation/FileUploaderContext"; import { isSupportedFileContentType, isSupportedImageContentType, @@ -6,7 +7,6 @@ import { supportedOtherFileFormats, } from "@dust-tt/client"; import { DropzoneOverlay, useSendNotification } from "@dust-tt/sparkle"; -import { useFileDrop } from "@extension/components/conversation/FileUploaderContext"; import { useEffect } from "react"; import { useDropzone } from "react-dropzone"; interface DropzoneContainerProps { diff --git a/extension/shared/components/assistants/AssistantFavorites.tsx b/extension/ui/components/assistants/AssistantFavorites.tsx similarity index 100% rename from extension/shared/components/assistants/AssistantFavorites.tsx rename to extension/ui/components/assistants/AssistantFavorites.tsx diff --git a/extension/shared/components/assistants/AssistantPicker.tsx b/extension/ui/components/assistants/AssistantPicker.tsx similarity index 100% rename from extension/shared/components/assistants/AssistantPicker.tsx rename to extension/ui/components/assistants/AssistantPicker.tsx diff --git a/extension/shared/components/assistants/usePublicAgentConfigurations.ts b/extension/ui/components/assistants/usePublicAgentConfigurations.ts similarity index 100% rename from extension/shared/components/assistants/usePublicAgentConfigurations.ts rename to extension/ui/components/assistants/usePublicAgentConfigurations.ts diff --git a/extension/shared/components/auth/AuthProvider.tsx b/extension/ui/components/auth/AuthProvider.tsx similarity index 89% rename from extension/shared/components/auth/AuthProvider.tsx rename to extension/ui/components/auth/AuthProvider.tsx index 22bfc3efbcf0..55ddfdca4222 100644 --- a/extension/shared/components/auth/AuthProvider.tsx +++ b/extension/ui/components/auth/AuthProvider.tsx @@ -1,7 +1,7 @@ +import type { AuthError } from "@app/shared/lib/auth"; +import type { StoredUser } from "@app/shared/lib/storage"; +import { useAuthHook } from "@app/ui/components/auth/useAuth"; import type { ExtensionWorkspaceType, WorkspaceType } from "@dust-tt/client"; -import { useAuthHook } from "@extension/components/auth/useAuth"; -import type { AuthError } from "@extension/lib/auth"; -import type { StoredUser } from "@extension/lib/storage"; import type { ReactNode } from "react"; import React, { createContext, useContext } from "react"; diff --git a/extension/shared/components/auth/ProtectedRoute.tsx b/extension/ui/components/auth/ProtectedRoute.tsx similarity index 93% rename from extension/shared/components/auth/ProtectedRoute.tsx rename to extension/ui/components/auth/ProtectedRoute.tsx index 187e3c6acdf5..75397c0e39a0 100644 --- a/extension/shared/components/auth/ProtectedRoute.tsx +++ b/extension/ui/components/auth/ProtectedRoute.tsx @@ -1,9 +1,9 @@ +import type { RouteChangeMesssage } from "@app/shared/lib/messages"; +import type { StoredUser } from "@app/shared/lib/storage"; +import { getPendingUpdate } from "@app/shared/lib/storage"; +import { useAuth } from "@app/ui/components/auth/AuthProvider"; import type { ExtensionWorkspaceType } from "@dust-tt/client"; import { Button, classNames, DustLogo, Page, Spinner } from "@dust-tt/sparkle"; -import { useAuth } from "@extension/components/auth/AuthProvider"; -import type { RouteChangeMesssage } from "@extension/lib/messages"; -import type { StoredUser } from "@extension/lib/storage"; -import { getPendingUpdate } from "@extension/lib/storage"; import type { ReactNode } from "react"; import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; diff --git a/extension/shared/components/auth/useAuth.ts b/extension/ui/components/auth/useAuth.ts similarity index 97% rename from extension/shared/components/auth/useAuth.ts rename to extension/ui/components/auth/useAuth.ts index d1fc579078c9..0c6740d0a5bd 100644 --- a/extension/shared/components/auth/useAuth.ts +++ b/extension/ui/components/auth/useAuth.ts @@ -1,4 +1,3 @@ -import type { WorkspaceType } from "@dust-tt/client"; import { AuthError, isValidEnterpriseConnectionName as isValidEnterpriseConnection, @@ -6,14 +5,15 @@ import { logout, makeEnterpriseConnectionName, refreshToken, -} from "@extension/lib/auth"; -import type { StoredTokens, StoredUser } from "@extension/lib/storage"; +} from "@app/shared/lib/auth"; +import type { StoredTokens, StoredUser } from "@app/shared/lib/storage"; import { clearStoredData, getStoredTokens, getStoredUser, saveSelectedWorkspace, -} from "@extension/lib/storage"; +} from "@app/shared/lib/storage"; +import type { WorkspaceType } from "@dust-tt/client"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; const log = console.error; diff --git a/extension/shared/components/conversation/AgentMessage.tsx b/extension/ui/components/conversation/AgentMessage.tsx similarity index 95% rename from extension/shared/components/conversation/AgentMessage.tsx rename to extension/ui/components/conversation/AgentMessage.tsx index 6e2ce6f93e77..da3e2dc61f42 100644 --- a/extension/shared/components/conversation/AgentMessage.tsx +++ b/extension/ui/components/conversation/AgentMessage.tsx @@ -1,4 +1,24 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ +import { assertNeverAndIgnore } from "@app/shared/lib/assertNeverAndIgnore"; +import { retryMessage } from "@app/shared/lib/conversation"; +import type { StoredUser } from "@app/shared/lib/storage"; +import { AgentMessageActions } from "@app/ui/components/conversation/AgentMessageActions"; +import type { FeedbackSelectorProps } from "@app/ui/components/conversation/FeedbackSelector"; +import { FeedbackSelector } from "@app/ui/components/conversation/FeedbackSelector"; +import { GenerationContext } from "@app/ui/components/conversation/GenerationContextProvider"; +import { + CitationsContext, + CiteBlock, + getCiteDirective, +} from "@app/ui/components/markdown/CiteBlock"; +import type { MarkdownCitation } from "@app/ui/components/markdown/MarkdownCitation"; +import { citationIconMap } from "@app/ui/components/markdown/MarkdownCitation"; +import { + MentionBlock, + mentionDirective, +} from "@app/ui/components/markdown/MentionBlock"; +import { useSubmitFunction } from "@app/ui/components/utils/useSubmitFunction"; +import { useEventSource } from "@app/ui/hooks/useEventSource"; import type { AgentActionPublicType, AgentActionSpecificEvent, @@ -42,26 +62,6 @@ import { Popover, useSendNotification, } from "@dust-tt/sparkle"; -import { AgentMessageActions } from "@extension/components/conversation/AgentMessageActions"; -import type { FeedbackSelectorProps } from "@extension/components/conversation/FeedbackSelector"; -import { FeedbackSelector } from "@extension/components/conversation/FeedbackSelector"; -import { GenerationContext } from "@extension/components/conversation/GenerationContextProvider"; -import { - CitationsContext, - CiteBlock, - getCiteDirective, -} from "@extension/components/markdown/CiteBlock"; -import type { MarkdownCitation } from "@extension/components/markdown/MarkdownCitation"; -import { citationIconMap } from "@extension/components/markdown/MarkdownCitation"; -import { - MentionBlock, - mentionDirective, -} from "@extension/components/markdown/MentionBlock"; -import { useSubmitFunction } from "@extension/components/utils/useSubmitFunction"; -import { useEventSource } from "@extension/hooks/useEventSource"; -import { assertNeverAndIgnore } from "@extension/lib/assertNeverAndIgnore"; -import { retryMessage } from "@extension/lib/conversation"; -import type { StoredUser } from "@extension/lib/storage"; import { useCallback, useContext, diff --git a/extension/shared/components/conversation/AgentMessageActions.tsx b/extension/ui/components/conversation/AgentMessageActions.tsx similarity index 98% rename from extension/shared/components/conversation/AgentMessageActions.tsx rename to extension/ui/components/conversation/AgentMessageActions.tsx index 33dccdf1c681..4e5f58250613 100644 --- a/extension/shared/components/conversation/AgentMessageActions.tsx +++ b/extension/ui/components/conversation/AgentMessageActions.tsx @@ -1,10 +1,10 @@ +import { classNames } from "@app/shared/lib/utils"; import type { AgentActionPublicType, AgentMessagePublicType, LightWorkspaceType, } from "@dust-tt/client"; import { Chip, Spinner } from "@dust-tt/sparkle"; -import { classNames } from "@extension/lib/utils"; import { useEffect, useMemo, useState } from "react"; interface AgentMessageActionsProps { agentMessage: AgentMessagePublicType; diff --git a/extension/shared/components/conversation/AgentSuggestion.tsx b/extension/ui/components/conversation/AgentSuggestion.tsx similarity index 91% rename from extension/shared/components/conversation/AgentSuggestion.tsx rename to extension/ui/components/conversation/AgentSuggestion.tsx index 6a427eb85c4b..ec4a8a1b9be3 100644 --- a/extension/shared/components/conversation/AgentSuggestion.tsx +++ b/extension/ui/components/conversation/AgentSuggestion.tsx @@ -1,3 +1,7 @@ +import { useDustAPI } from "@app/shared/lib/dust_api"; +import { AssistantPicker } from "@app/ui/components/assistants/AssistantPicker"; +import { usePublicAgentConfigurations } from "@app/ui/components/assistants/usePublicAgentConfigurations"; +import { useSubmitFunction } from "@app/ui/components/utils/useSubmitFunction"; import type { LightAgentConfigurationType, LightWorkspaceType, @@ -11,10 +15,6 @@ import { Spinner, useSendNotification, } from "@dust-tt/sparkle"; -import { AssistantPicker } from "@extension/components/assistants/AssistantPicker"; -import { usePublicAgentConfigurations } from "@extension/components/assistants/usePublicAgentConfigurations"; -import { useSubmitFunction } from "@extension/components/utils/useSubmitFunction"; -import { useDustAPI } from "@extension/lib/dust_api"; import { useMemo, useState } from "react"; interface AgentSuggestionProps { diff --git a/extension/shared/components/conversation/AttachFile.tsx b/extension/ui/components/conversation/AttachFile.tsx similarity index 87% rename from extension/shared/components/conversation/AttachFile.tsx rename to extension/ui/components/conversation/AttachFile.tsx index 66712d669f40..0f33c7261733 100644 --- a/extension/shared/components/conversation/AttachFile.tsx +++ b/extension/ui/components/conversation/AttachFile.tsx @@ -1,7 +1,7 @@ +import type { EditorService } from "@app/ui/components/input_bar/editor/useCustomEditor"; +import type { FileUploaderService } from "@app/ui/hooks/useFileUploaderService"; import { supportedFileExtensions } from "@dust-tt/client"; import { AttachmentIcon, Button } from "@dust-tt/sparkle"; -import type { EditorService } from "@extension/components/input_bar/editor/useCustomEditor"; -import type { FileUploaderService } from "@extension/hooks/useFileUploaderService"; import { useRef } from "react"; type AttachFileProps = { diff --git a/extension/shared/components/conversation/AttachFragment.tsx b/extension/ui/components/conversation/AttachFragment.tsx similarity index 93% rename from extension/shared/components/conversation/AttachFragment.tsx rename to extension/ui/components/conversation/AttachFragment.tsx index 25c73d9bd988..9d7266f26724 100644 --- a/extension/shared/components/conversation/AttachFragment.tsx +++ b/extension/ui/components/conversation/AttachFragment.tsx @@ -1,8 +1,8 @@ +import { InputBarContext } from "@app/ui/components/input_bar/InputBarContext"; +import { useCurrentUrlAndDomain } from "@app/ui/hooks/useCurrentDomain"; +import type { FileUploaderService } from "@app/ui/hooks/useFileUploaderService"; import type { ExtensionWorkspaceType } from "@dust-tt/client"; import { Button, CameraIcon, DocumentPlusIcon } from "@dust-tt/sparkle"; -import { InputBarContext } from "@extension/components/input_bar/InputBarContext"; -import { useCurrentUrlAndDomain } from "@extension/hooks/useCurrentDomain"; -import type { FileUploaderService } from "@extension/hooks/useFileUploaderService"; import { useContext, useEffect } from "react"; type AttachFragmentProps = { diff --git a/extension/shared/components/conversation/ConversationContainer.tsx b/extension/ui/components/conversation/ConversationContainer.tsx similarity index 90% rename from extension/shared/components/conversation/ConversationContainer.tsx rename to extension/ui/components/conversation/ConversationContainer.tsx index 13da657da00a..af83d6821c5b 100644 --- a/extension/shared/components/conversation/ConversationContainer.tsx +++ b/extension/ui/components/conversation/ConversationContainer.tsx @@ -1,35 +1,35 @@ -import type { - AgentMentionType, - ContentFragmentType, - ExtensionWorkspaceType, -} from "@dust-tt/client"; -import { Page, useSendNotification } from "@dust-tt/sparkle"; -import { ConversationViewer } from "@extension/components/conversation/ConversationViewer"; -import { GenerationContextProvider } from "@extension/components/conversation/GenerationContextProvider"; -import { ReachedLimitPopup } from "@extension/components/conversation/ReachedLimitPopup"; -import { usePublicConversation } from "@extension/components/conversation/usePublicConversation"; -import { AssistantInputBar } from "@extension/components/input_bar/InputBar"; -import { InputBarContext } from "@extension/components/input_bar/InputBarContext"; -import { useSubmitFunction } from "@extension/components/utils/useSubmitFunction"; import { createPlaceholderUserMessage, postConversation, postMessage, updateConversationWithOptimisticData, -} from "@extension/lib/conversation"; -import { useDustAPI } from "@extension/lib/dust_api"; -import { getRandomGreetingForName } from "@extension/lib/greetings"; -import type { StoredUser } from "@extension/lib/storage"; +} from "@app/shared/lib/conversation"; +import { useDustAPI } from "@app/shared/lib/dust_api"; +import { getRandomGreetingForName } from "@app/shared/lib/greetings"; +import type { StoredUser } from "@app/shared/lib/storage"; import { getConversationContext, getFileContentFragmentId, saveFilesContentFragmentIds, setConversationsContext, -} from "@extension/lib/storage"; +} from "@app/shared/lib/storage"; import type { UploadedFileWithKind, UploadedFileWithSupersededContentFragmentId, -} from "@extension/lib/types"; +} from "@app/shared/lib/types"; +import { ConversationViewer } from "@app/ui/components/conversation/ConversationViewer"; +import { GenerationContextProvider } from "@app/ui/components/conversation/GenerationContextProvider"; +import { ReachedLimitPopup } from "@app/ui/components/conversation/ReachedLimitPopup"; +import { usePublicConversation } from "@app/ui/components/conversation/usePublicConversation"; +import { AssistantInputBar } from "@app/ui/components/input_bar/InputBar"; +import { InputBarContext } from "@app/ui/components/input_bar/InputBarContext"; +import { useSubmitFunction } from "@app/ui/components/utils/useSubmitFunction"; +import type { + AgentMentionType, + ContentFragmentType, + ExtensionWorkspaceType, +} from "@dust-tt/client"; +import { Page, useSendNotification } from "@dust-tt/sparkle"; import { useCallback, useContext, useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; diff --git a/extension/shared/components/conversation/ConversationViewer.tsx b/extension/ui/components/conversation/ConversationViewer.tsx similarity index 91% rename from extension/shared/components/conversation/ConversationViewer.tsx rename to extension/ui/components/conversation/ConversationViewer.tsx index f62b6669aa59..a0096683f2c6 100644 --- a/extension/shared/components/conversation/ConversationViewer.tsx +++ b/extension/ui/components/conversation/ConversationViewer.tsx @@ -1,3 +1,11 @@ +import type { MessageWithContentFragmentsType } from "@app/shared/lib/conversation"; +import { getUpdatedMessagesFromEvent } from "@app/shared/lib/conversation"; +import type { StoredUser } from "@app/shared/lib/storage"; +import { classNames } from "@app/shared/lib/utils"; +import MessageGroup from "@app/ui/components/conversation/MessageGroup"; +import { useConversationFeedbacks } from "@app/ui/components/conversation/useConversationFeedbacks"; +import { usePublicConversation } from "@app/ui/components/conversation/usePublicConversation"; +import { useEventSource } from "@app/ui/hooks/useEventSource"; import type { AgentGenerationCancelledEvent, AgentMentionType, @@ -10,14 +18,6 @@ import type { UserMessageType, } from "@dust-tt/client"; import { isAgentMention } from "@dust-tt/client"; -import MessageGroup from "@extension/components/conversation/MessageGroup"; -import { useConversationFeedbacks } from "@extension/components/conversation/useConversationFeedbacks"; -import { usePublicConversation } from "@extension/components/conversation/usePublicConversation"; -import { useEventSource } from "@extension/hooks/useEventSource"; -import type { MessageWithContentFragmentsType } from "@extension/lib/conversation"; -import { getUpdatedMessagesFromEvent } from "@extension/lib/conversation"; -import type { StoredUser } from "@extension/lib/storage"; -import { classNames } from "@extension/lib/utils"; import { useCallback, useEffect, useMemo, useRef } from "react"; interface ConversationViewerProps { diff --git a/extension/shared/components/conversation/ConversationsListButton.tsx b/extension/ui/components/conversation/ConversationsListButton.tsx similarity index 97% rename from extension/shared/components/conversation/ConversationsListButton.tsx rename to extension/ui/components/conversation/ConversationsListButton.tsx index 16f1b66ddd13..0bac08f5d954 100644 --- a/extension/shared/components/conversation/ConversationsListButton.tsx +++ b/extension/ui/components/conversation/ConversationsListButton.tsx @@ -1,3 +1,4 @@ +import { useConversations } from "@app/ui/components/conversation/useConversations"; import type { ConversationWithoutContentPublicType } from "@dust-tt/client"; import { Button, @@ -11,7 +12,6 @@ import { ScrollArea, Spinner, } from "@dust-tt/sparkle"; -import { useConversations } from "@extension/components/conversation/useConversations"; import moment from "moment"; import React from "react"; import { useNavigate, useParams } from "react-router-dom"; diff --git a/extension/shared/components/conversation/FeedbackSelector.tsx b/extension/ui/components/conversation/FeedbackSelector.tsx similarity index 100% rename from extension/shared/components/conversation/FeedbackSelector.tsx rename to extension/ui/components/conversation/FeedbackSelector.tsx diff --git a/extension/shared/components/conversation/FileUploaderContext.tsx b/extension/ui/components/conversation/FileUploaderContext.tsx similarity index 100% rename from extension/shared/components/conversation/FileUploaderContext.tsx rename to extension/ui/components/conversation/FileUploaderContext.tsx diff --git a/extension/shared/components/conversation/GenerationContextProvider.tsx b/extension/ui/components/conversation/GenerationContextProvider.tsx similarity index 100% rename from extension/shared/components/conversation/GenerationContextProvider.tsx rename to extension/ui/components/conversation/GenerationContextProvider.tsx diff --git a/extension/shared/components/conversation/MessageGroup.tsx b/extension/ui/components/conversation/MessageGroup.tsx similarity index 87% rename from extension/shared/components/conversation/MessageGroup.tsx rename to extension/ui/components/conversation/MessageGroup.tsx index 3d69e82e63d7..379883df4b6b 100644 --- a/extension/shared/components/conversation/MessageGroup.tsx +++ b/extension/ui/components/conversation/MessageGroup.tsx @@ -1,11 +1,11 @@ +import type { MessageWithContentFragmentsType } from "@app/shared/lib/conversation"; +import type { AgentMessageFeedbackType } from "@app/shared/lib/feedbacks"; +import type { StoredUser } from "@app/shared/lib/storage"; +import MessageItem from "@app/ui/components/conversation/MessageItem"; import type { ConversationMessageReactionsType, LightWorkspaceType, } from "@dust-tt/client"; -import MessageItem from "@extension/components/conversation/MessageItem"; -import type { MessageWithContentFragmentsType } from "@extension/lib/conversation"; -import type { AgentMessageFeedbackType } from "@extension/lib/feedbacks"; -import type { StoredUser } from "@extension/lib/storage"; import React, { useEffect, useRef } from "react"; interface MessageGroupProps { diff --git a/extension/shared/components/conversation/MessageItem.tsx b/extension/ui/components/conversation/MessageItem.tsx similarity index 88% rename from extension/shared/components/conversation/MessageItem.tsx rename to extension/ui/components/conversation/MessageItem.tsx index 5d439ad044eb..523b1666b18e 100644 --- a/extension/shared/components/conversation/MessageItem.tsx +++ b/extension/ui/components/conversation/MessageItem.tsx @@ -1,3 +1,11 @@ +import type { MessageWithContentFragmentsType } from "@app/shared/lib/conversation"; +import { useDustAPI } from "@app/shared/lib/dust_api"; +import type { AgentMessageFeedbackType } from "@app/shared/lib/feedbacks"; +import type { StoredUser } from "@app/shared/lib/storage"; +import { AgentMessage } from "@app/ui/components/conversation/AgentMessage"; +import type { FeedbackSelectorProps } from "@app/ui/components/conversation/FeedbackSelector"; +import { UserMessage } from "@app/ui/components/conversation/UserMessage"; +import { useSubmitFunction } from "@app/ui/components/utils/useSubmitFunction"; import type { ConversationMessageReactionsType, LightWorkspaceType, @@ -12,14 +20,6 @@ import { Icon, SlackLogo, } from "@dust-tt/sparkle"; -import { AgentMessage } from "@extension/components/conversation/AgentMessage"; -import type { FeedbackSelectorProps } from "@extension/components/conversation/FeedbackSelector"; -import { UserMessage } from "@extension/components/conversation/UserMessage"; -import { useSubmitFunction } from "@extension/components/utils/useSubmitFunction"; -import type { MessageWithContentFragmentsType } from "@extension/lib/conversation"; -import { useDustAPI } from "@extension/lib/dust_api"; -import type { AgentMessageFeedbackType } from "@extension/lib/feedbacks"; -import type { StoredUser } from "@extension/lib/storage"; import React from "react"; import { useSWRConfig } from "swr"; diff --git a/extension/shared/components/conversation/ReachedLimitPopup.tsx b/extension/ui/components/conversation/ReachedLimitPopup.tsx similarity index 100% rename from extension/shared/components/conversation/ReachedLimitPopup.tsx rename to extension/ui/components/conversation/ReachedLimitPopup.tsx diff --git a/extension/shared/components/conversation/UserMessage.tsx b/extension/ui/components/conversation/UserMessage.tsx similarity index 90% rename from extension/shared/components/conversation/UserMessage.tsx rename to extension/ui/components/conversation/UserMessage.tsx index a7593e287a09..557684f07d79 100644 --- a/extension/shared/components/conversation/UserMessage.tsx +++ b/extension/ui/components/conversation/UserMessage.tsx @@ -1,15 +1,15 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import type { LightWorkspaceType, UserMessageType } from "@dust-tt/client"; -import { ConversationMessage, Markdown } from "@dust-tt/sparkle"; -import { AgentSuggestion } from "@extension/components/conversation/AgentSuggestion"; +import { AgentSuggestion } from "@app/ui/components/conversation/AgentSuggestion"; import { CiteBlock, getCiteDirective, -} from "@extension/components/markdown/CiteBlock"; +} from "@app/ui/components/markdown/CiteBlock"; import { MentionBlock, mentionDirective, -} from "@extension/components/markdown/MentionBlock"; +} from "@app/ui/components/markdown/MentionBlock"; +import type { LightWorkspaceType, UserMessageType } from "@dust-tt/client"; +import { ConversationMessage, Markdown } from "@dust-tt/sparkle"; import { useMemo } from "react"; import type { Components } from "react-markdown"; import type { PluggableList } from "react-markdown/lib/react-markdown"; diff --git a/extension/shared/components/conversation/useConversationFeedbacks.ts b/extension/ui/components/conversation/useConversationFeedbacks.ts similarity index 83% rename from extension/shared/components/conversation/useConversationFeedbacks.ts rename to extension/ui/components/conversation/useConversationFeedbacks.ts index 4dd93ab9db2f..d48ad705f0bd 100644 --- a/extension/shared/components/conversation/useConversationFeedbacks.ts +++ b/extension/ui/components/conversation/useConversationFeedbacks.ts @@ -1,6 +1,6 @@ -import { useDustAPI } from "@extension/lib/dust_api"; -import type { AgentMessageFeedbackType } from "@extension/lib/feedbacks"; -import { useSWRWithDefaults } from "@extension/lib/swr"; +import { useDustAPI } from "@app/shared/lib/dust_api"; +import type { AgentMessageFeedbackType } from "@app/shared/lib/feedbacks"; +import { useSWRWithDefaults } from "@app/shared/lib/swr"; import { useMemo } from "react"; type FeedbacksKey = diff --git a/extension/shared/components/conversation/useConversations.ts b/extension/ui/components/conversation/useConversations.ts similarity index 87% rename from extension/shared/components/conversation/useConversations.ts rename to extension/ui/components/conversation/useConversations.ts index eb4a0467a8a5..7791b1dee98a 100644 --- a/extension/shared/components/conversation/useConversations.ts +++ b/extension/ui/components/conversation/useConversations.ts @@ -1,6 +1,6 @@ +import { useDustAPI } from "@app/shared/lib/dust_api"; +import { useSWRWithDefaults } from "@app/shared/lib/swr"; import type { ConversationWithoutContentPublicType } from "@dust-tt/client"; -import { useDustAPI } from "@extension/lib/dust_api"; -import { useSWRWithDefaults } from "@extension/lib/swr"; import { useMemo } from "react"; type ConversationsKey = ["getConversations", string]; diff --git a/extension/shared/components/conversation/usePublicConversation.ts b/extension/ui/components/conversation/usePublicConversation.ts similarity index 91% rename from extension/shared/components/conversation/usePublicConversation.ts rename to extension/ui/components/conversation/usePublicConversation.ts index 141bd50ed123..fe8563261454 100644 --- a/extension/shared/components/conversation/usePublicConversation.ts +++ b/extension/ui/components/conversation/usePublicConversation.ts @@ -1,6 +1,6 @@ +import { useDustAPI } from "@app/shared/lib/dust_api"; +import { useSWRWithDefaults } from "@app/shared/lib/swr"; import type { ConversationPublicType } from "@dust-tt/client"; -import { useDustAPI } from "@extension/lib/dust_api"; -import { useSWRWithDefaults } from "@extension/lib/swr"; import type { KeyedMutator } from "swr"; type ConversationKey = diff --git a/extension/shared/components/input_bar/InputBar.tsx b/extension/ui/components/input_bar/InputBar.tsx similarity index 89% rename from extension/shared/components/input_bar/InputBar.tsx rename to extension/ui/components/input_bar/InputBar.tsx index fdd6a1a66c2c..884860d89c0e 100644 --- a/extension/shared/components/input_bar/InputBar.tsx +++ b/extension/ui/components/input_bar/InputBar.tsx @@ -1,3 +1,16 @@ +import { useDustAPI } from "@app/shared/lib/dust_api"; +import type { AttachSelectionMessage } from "@app/shared/lib/messages"; +import { sendInputBarStatus } from "@app/shared/lib/messages"; +import type { UploadedFileWithKind } from "@app/shared/lib/types"; +import { classNames, compareAgentsForSort } from "@app/shared/lib/utils"; +import { usePublicAgentConfigurations } from "@app/ui/components/assistants/usePublicAgentConfigurations"; +import { useFileDrop } from "@app/ui/components/conversation/FileUploaderContext"; +import { GenerationContext } from "@app/ui/components/conversation/GenerationContextProvider"; +import { InputBarCitations } from "@app/ui/components/input_bar/InputBarCitations"; +import type { InputBarContainerProps } from "@app/ui/components/input_bar/InputBarContainer"; +import { InputBarContainer } from "@app/ui/components/input_bar/InputBarContainer"; +import { InputBarContext } from "@app/ui/components/input_bar/InputBarContext"; +import { useFileUploaderService } from "@app/ui/hooks/useFileUploaderService"; import type { AgentMentionType, ConversationPublicType, @@ -5,19 +18,6 @@ import type { LightAgentConfigurationType, } from "@dust-tt/client"; import { Button, Page, Spinner, StopIcon } from "@dust-tt/sparkle"; -import { usePublicAgentConfigurations } from "@extension/components/assistants/usePublicAgentConfigurations"; -import { useFileDrop } from "@extension/components/conversation/FileUploaderContext"; -import { GenerationContext } from "@extension/components/conversation/GenerationContextProvider"; -import { InputBarCitations } from "@extension/components/input_bar/InputBarCitations"; -import type { InputBarContainerProps } from "@extension/components/input_bar/InputBarContainer"; -import { InputBarContainer } from "@extension/components/input_bar/InputBarContainer"; -import { InputBarContext } from "@extension/components/input_bar/InputBarContext"; -import { useFileUploaderService } from "@extension/hooks/useFileUploaderService"; -import { useDustAPI } from "@extension/lib/dust_api"; -import type { AttachSelectionMessage } from "@extension/lib/messages"; -import { sendInputBarStatus } from "@extension/lib/messages"; -import type { UploadedFileWithKind } from "@extension/lib/types"; -import { classNames, compareAgentsForSort } from "@extension/lib/utils"; import { useContext, useEffect, useMemo, useRef, useState } from "react"; /** diff --git a/extension/shared/components/input_bar/InputBarCitations.tsx b/extension/ui/components/input_bar/InputBarCitations.tsx similarity index 94% rename from extension/shared/components/input_bar/InputBarCitations.tsx rename to extension/ui/components/input_bar/InputBarCitations.tsx index 613fb88edb65..52f4ae0a6c32 100644 --- a/extension/shared/components/input_bar/InputBarCitations.tsx +++ b/extension/ui/components/input_bar/InputBarCitations.tsx @@ -1,3 +1,4 @@ +import type { FileUploaderService } from "@app/ui/hooks/useFileUploaderService"; import { Citation, CitationClose, @@ -8,7 +9,6 @@ import { Icon, ImageIcon, } from "@dust-tt/sparkle"; -import type { FileUploaderService } from "@extension/hooks/useFileUploaderService"; interface InputBarCitationsProps { fileUploaderService: FileUploaderService; diff --git a/extension/shared/components/input_bar/InputBarContainer.tsx b/extension/ui/components/input_bar/InputBarContainer.tsx similarity index 82% rename from extension/shared/components/input_bar/InputBarContainer.tsx rename to extension/ui/components/input_bar/InputBarContainer.tsx index 428531a6fa43..feb998da2091 100644 --- a/extension/shared/components/input_bar/InputBarContainer.tsx +++ b/extension/ui/components/input_bar/InputBarContainer.tsx @@ -1,19 +1,19 @@ +import { classNames } from "@app/shared/lib/utils"; +import { AssistantPicker } from "@app/ui/components/assistants/AssistantPicker"; +import { AttachFile } from "@app/ui/components/conversation/AttachFile"; +import { AttachFragment } from "@app/ui/components/conversation/AttachFragment"; +import type { CustomEditorProps } from "@app/ui/components/input_bar/editor/useCustomEditor"; +import useCustomEditor from "@app/ui/components/input_bar/editor/useCustomEditor"; +import useHandleMentions from "@app/ui/components/input_bar/editor/useHandleMentions"; +import { usePublicAssistantSuggestions } from "@app/ui/components/input_bar/editor/usePublicAssistantSuggestions"; +import { InputBarContext } from "@app/ui/components/input_bar/InputBarContext"; +import type { FileUploaderService } from "@app/ui/hooks/useFileUploaderService"; import type { AgentMentionType, ExtensionWorkspaceType, LightAgentConfigurationType, } from "@dust-tt/client"; import { SplitButton } from "@dust-tt/sparkle"; -import { AssistantPicker } from "@extension/components/assistants/AssistantPicker"; -import { AttachFile } from "@extension/components/conversation/AttachFile"; -import { AttachFragment } from "@extension/components/conversation/AttachFragment"; -import type { CustomEditorProps } from "@extension/components/input_bar/editor/useCustomEditor"; -import useCustomEditor from "@extension/components/input_bar/editor/useCustomEditor"; -import useHandleMentions from "@extension/components/input_bar/editor/useHandleMentions"; -import { usePublicAssistantSuggestions } from "@extension/components/input_bar/editor/usePublicAssistantSuggestions"; -import { InputBarContext } from "@extension/components/input_bar/InputBarContext"; -import type { FileUploaderService } from "@extension/hooks/useFileUploaderService"; -import { classNames } from "@extension/lib/utils"; import { EditorContent } from "@tiptap/react"; import { useContext, useEffect } from "react"; diff --git a/extension/shared/components/input_bar/InputBarContext.tsx b/extension/ui/components/input_bar/InputBarContext.tsx similarity index 100% rename from extension/shared/components/input_bar/InputBarContext.tsx rename to extension/ui/components/input_bar/InputBarContext.tsx diff --git a/extension/shared/components/input_bar/editor/MentionList.tsx b/extension/ui/components/input_bar/editor/MentionList.tsx similarity index 95% rename from extension/shared/components/input_bar/editor/MentionList.tsx rename to extension/ui/components/input_bar/editor/MentionList.tsx index 6002b3e696ef..e89f4355df37 100644 --- a/extension/shared/components/input_bar/editor/MentionList.tsx +++ b/extension/ui/components/input_bar/editor/MentionList.tsx @@ -1,6 +1,6 @@ +import { classNames } from "@app/shared/lib/utils"; +import type { EditorSuggestion } from "@app/ui/components/input_bar/editor/suggestion"; import { Avatar } from "@dust-tt/sparkle"; -import type { EditorSuggestion } from "@extension/components/input_bar/editor/suggestion"; -import { classNames } from "@extension/lib/utils"; import React, { forwardRef, useEffect, diff --git a/extension/shared/components/input_bar/editor/MentionStorage.ts b/extension/ui/components/input_bar/editor/MentionStorage.ts similarity index 78% rename from extension/shared/components/input_bar/editor/MentionStorage.ts rename to extension/ui/components/input_bar/editor/MentionStorage.ts index c1b103ece1bf..c3afeb77536d 100644 --- a/extension/shared/components/input_bar/editor/MentionStorage.ts +++ b/extension/ui/components/input_bar/editor/MentionStorage.ts @@ -1,4 +1,4 @@ -import type { EditorSuggestions } from "@extension/components/input_bar/editor/suggestion"; +import type { EditorSuggestions } from "@app/ui/components/input_bar/editor/suggestion"; import { Extension } from "@tiptap/react"; // Storage extension to manage mention suggestions. diff --git a/extension/shared/components/input_bar/editor/MentionWithPaste.tsx b/extension/ui/components/input_bar/editor/MentionWithPaste.tsx similarity index 94% rename from extension/shared/components/input_bar/editor/MentionWithPaste.tsx rename to extension/ui/components/input_bar/editor/MentionWithPaste.tsx index 0c391db218a2..578ae5d1ca9a 100644 --- a/extension/shared/components/input_bar/editor/MentionWithPaste.tsx +++ b/extension/ui/components/input_bar/editor/MentionWithPaste.tsx @@ -1,4 +1,4 @@ -import type { EditorSuggestions } from "@extension/components/input_bar/editor/suggestion"; +import type { EditorSuggestions } from "@app/ui/components/input_bar/editor/suggestion"; import Mention from "@tiptap/extension-mention"; import type { PasteRuleMatch } from "@tiptap/react"; import { nodePasteRule } from "@tiptap/react"; diff --git a/extension/shared/components/input_bar/editor/suggestion.ts b/extension/ui/components/input_bar/editor/suggestion.ts similarity index 95% rename from extension/shared/components/input_bar/editor/suggestion.ts rename to extension/ui/components/input_bar/editor/suggestion.ts index 90a8569423d6..e28dfad25d82 100644 --- a/extension/shared/components/input_bar/editor/suggestion.ts +++ b/extension/ui/components/input_bar/editor/suggestion.ts @@ -1,5 +1,5 @@ -import { MentionList } from "@extension/components/input_bar/editor/MentionList"; -import { compareForFuzzySort, subFilter } from "@extension/lib/utils"; +import { compareForFuzzySort, subFilter } from "@app/shared/lib/utils"; +import { MentionList } from "@app/ui/components/input_bar/editor/MentionList"; import type { Editor } from "@tiptap/core"; import { ReactRenderer } from "@tiptap/react"; import tippy from "tippy.js"; diff --git a/extension/shared/components/input_bar/editor/useCustomEditor.tsx b/extension/ui/components/input_bar/editor/useCustomEditor.tsx similarity index 95% rename from extension/shared/components/input_bar/editor/useCustomEditor.tsx rename to extension/ui/components/input_bar/editor/useCustomEditor.tsx index 99e784ec8de0..4c845d4aac0d 100644 --- a/extension/shared/components/input_bar/editor/useCustomEditor.tsx +++ b/extension/ui/components/input_bar/editor/useCustomEditor.tsx @@ -1,7 +1,7 @@ -import { MentionStorage } from "@extension/components/input_bar/editor/MentionStorage"; -import { MentionWithPaste } from "@extension/components/input_bar/editor/MentionWithPaste"; -import type { EditorSuggestions } from "@extension/components/input_bar/editor/suggestion"; -import { makeGetAssistantSuggestions } from "@extension/components/input_bar/editor/suggestion"; +import { MentionStorage } from "@app/ui/components/input_bar/editor/MentionStorage"; +import { MentionWithPaste } from "@app/ui/components/input_bar/editor/MentionWithPaste"; +import type { EditorSuggestions } from "@app/ui/components/input_bar/editor/suggestion"; +import { makeGetAssistantSuggestions } from "@app/ui/components/input_bar/editor/suggestion"; import { MentionPluginKey } from "@tiptap/extension-mention"; import Paragraph from "@tiptap/extension-paragraph"; import Placeholder from "@tiptap/extension-placeholder"; diff --git a/extension/shared/components/input_bar/editor/useHandleMentions.tsx b/extension/ui/components/input_bar/editor/useHandleMentions.tsx similarity index 97% rename from extension/shared/components/input_bar/editor/useHandleMentions.tsx rename to extension/ui/components/input_bar/editor/useHandleMentions.tsx index 89b6d91d0ad0..316b282f75da 100644 --- a/extension/shared/components/input_bar/editor/useHandleMentions.tsx +++ b/extension/ui/components/input_bar/editor/useHandleMentions.tsx @@ -1,11 +1,11 @@ +import type { + EditorMention, + EditorService, +} from "@app/ui/components/input_bar/editor/useCustomEditor"; import type { AgentMentionType, LightAgentConfigurationType, } from "@dust-tt/client"; -import type { - EditorMention, - EditorService, -} from "@extension/components/input_bar/editor/useCustomEditor"; import { useEffect, useRef } from "react"; const useHandleMentions = ( diff --git a/extension/shared/components/input_bar/editor/usePublicAssistantSuggestions.ts b/extension/ui/components/input_bar/editor/usePublicAssistantSuggestions.ts similarity index 86% rename from extension/shared/components/input_bar/editor/usePublicAssistantSuggestions.ts rename to extension/ui/components/input_bar/editor/usePublicAssistantSuggestions.ts index b4c46079c592..09bf015c53e9 100644 --- a/extension/shared/components/input_bar/editor/usePublicAssistantSuggestions.ts +++ b/extension/ui/components/input_bar/editor/usePublicAssistantSuggestions.ts @@ -1,6 +1,6 @@ +import { compareAgentsForSort } from "@app/shared/lib/utils"; +import { usePublicAgentConfigurations } from "@app/ui/components/assistants/usePublicAgentConfigurations"; import type { LightAgentConfigurationType } from "@dust-tt/client"; -import { usePublicAgentConfigurations } from "@extension/components/assistants/usePublicAgentConfigurations"; -import { compareAgentsForSort } from "@extension/lib/utils"; import { useMemo } from "react"; function makeEditorSuggestions( diff --git a/extension/shared/components/markdown/CiteBlock.tsx b/extension/ui/components/markdown/CiteBlock.tsx similarity index 97% rename from extension/shared/components/markdown/CiteBlock.tsx rename to extension/ui/components/markdown/CiteBlock.tsx index d065893fa363..a3b23633ca6f 100644 --- a/extension/shared/components/markdown/CiteBlock.tsx +++ b/extension/ui/components/markdown/CiteBlock.tsx @@ -1,10 +1,9 @@ +import type { MarkdownCitation } from "@app/ui/components/markdown/MarkdownCitation"; import { classNames } from "@dust-tt/sparkle"; import React, { useEffect } from "react"; import type { ReactMarkdownProps } from "react-markdown/lib/complex-types"; import { visit } from "unist-util-visit"; -import type { MarkdownCitation } from "./MarkdownCitation"; - export type CitationsContextType = { references: { [key: string]: MarkdownCitation; diff --git a/extension/shared/components/markdown/MarkdownCitation.tsx b/extension/ui/components/markdown/MarkdownCitation.tsx similarity index 100% rename from extension/shared/components/markdown/MarkdownCitation.tsx rename to extension/ui/components/markdown/MarkdownCitation.tsx diff --git a/extension/shared/components/markdown/MentionBlock.tsx b/extension/ui/components/markdown/MentionBlock.tsx similarity index 100% rename from extension/shared/components/markdown/MentionBlock.tsx rename to extension/ui/components/markdown/MentionBlock.tsx diff --git a/extension/shared/components/utils/useSubmitFunction.tsx b/extension/ui/components/utils/useSubmitFunction.tsx similarity index 100% rename from extension/shared/components/utils/useSubmitFunction.tsx rename to extension/ui/components/utils/useSubmitFunction.tsx diff --git a/extension/shared/contextes/platform.ts b/extension/ui/contextes/PlateformContext.ts similarity index 72% rename from extension/shared/contextes/platform.ts rename to extension/ui/contextes/PlateformContext.ts index e4292be3930b..87cc4a38fc2a 100644 --- a/extension/shared/contextes/platform.ts +++ b/extension/ui/contextes/PlateformContext.ts @@ -1,7 +1,6 @@ +import type { PlatformService } from "@app/shared/services/platform"; import React, { useContext } from "react"; -import type { PlatformService } from "../services/platform"; - export const PlatformContext = React.createContext(null!); export const usePlatform = () => useContext(PlatformContext); diff --git a/extension/shared/components/PortContext.tsx b/extension/ui/contextes/PortContext.tsx similarity index 100% rename from extension/shared/components/PortContext.tsx rename to extension/ui/contextes/PortContext.tsx diff --git a/extension/shared/css/components.css b/extension/ui/css/components.css similarity index 100% rename from extension/shared/css/components.css rename to extension/ui/css/components.css diff --git a/extension/shared/css/custom.css b/extension/ui/css/custom.css similarity index 100% rename from extension/shared/css/custom.css rename to extension/ui/css/custom.css diff --git a/extension/shared/css/global.css b/extension/ui/css/global.css similarity index 100% rename from extension/shared/css/global.css rename to extension/ui/css/global.css diff --git a/extension/shared/hooks/useAuthErrorCheck.ts b/extension/ui/hooks/useAuthErrorCheck.ts similarity index 88% rename from extension/shared/hooks/useAuthErrorCheck.ts rename to extension/ui/hooks/useAuthErrorCheck.ts index d1fbd1d425dc..28fbaac4d00c 100644 --- a/extension/shared/hooks/useAuthErrorCheck.ts +++ b/extension/ui/hooks/useAuthErrorCheck.ts @@ -1,5 +1,5 @@ -import { useAuth } from "@extension/components/auth/AuthProvider"; -import { logout, refreshToken } from "@extension/lib/auth"; +import { logout, refreshToken } from "@app/shared/lib/auth"; +import { useAuth } from "@app/ui/components/auth/AuthProvider"; import { useEffect } from "react"; export const useAuthErrorCheck = (error: any, mutate: () => any) => { diff --git a/extension/shared/hooks/useCurrentDomain.ts b/extension/ui/hooks/useCurrentDomain.ts similarity index 100% rename from extension/shared/hooks/useCurrentDomain.ts rename to extension/ui/hooks/useCurrentDomain.ts diff --git a/extension/shared/hooks/useEventSource.ts b/extension/ui/hooks/useEventSource.ts similarity index 99% rename from extension/shared/hooks/useEventSource.ts rename to extension/ui/hooks/useEventSource.ts index 843246b0d0ba..8a03b50dff64 100644 --- a/extension/shared/hooks/useEventSource.ts +++ b/extension/ui/hooks/useEventSource.ts @@ -1,4 +1,4 @@ -import { getAccessToken } from "@extension/lib/auth"; +import { getAccessToken } from "@app/shared/lib/auth"; import { useCallback, useEffect, useRef, useState } from "react"; const RECONNECT_DELAY = 5000; // 5 seconds. import { EventSourcePolyfill } from "event-source-polyfill"; diff --git a/extension/shared/hooks/useFileUploaderService.ts b/extension/ui/hooks/useFileUploaderService.ts similarity index 97% rename from extension/shared/hooks/useFileUploaderService.ts rename to extension/ui/hooks/useFileUploaderService.ts index 16904bdc81da..6cdb4fe683b0 100644 --- a/extension/shared/hooks/useFileUploaderService.ts +++ b/extension/ui/hooks/useFileUploaderService.ts @@ -1,3 +1,7 @@ +import { getIncludeCurrentTab } from "@app/shared/lib/conversation"; +import { useDustAPI } from "@app/shared/lib/dust_api"; +import type { GetActiveTabOptions } from "@app/shared/lib/messages"; +import type { UploadedFileKind } from "@app/shared/lib/types"; import type { ConversationPublicType, Result, @@ -10,10 +14,6 @@ import { Ok, } from "@dust-tt/client"; import { useSendNotification } from "@dust-tt/sparkle"; -import { getIncludeCurrentTab } from "@extension/lib/conversation"; -import { useDustAPI } from "@extension/lib/dust_api"; -import type { GetActiveTabOptions } from "@extension/lib/messages"; -import type { UploadedFileKind } from "@extension/lib/types"; import { useState } from "react"; interface FileBlob { diff --git a/extension/shared/images/dust128.png b/extension/ui/images/dust128.png similarity index 100% rename from extension/shared/images/dust128.png rename to extension/ui/images/dust128.png diff --git a/extension/shared/images/dust16.png b/extension/ui/images/dust16.png similarity index 100% rename from extension/shared/images/dust16.png rename to extension/ui/images/dust16.png diff --git a/extension/shared/images/dust32.png b/extension/ui/images/dust32.png similarity index 100% rename from extension/shared/images/dust32.png rename to extension/ui/images/dust32.png diff --git a/extension/shared/images/dust48.png b/extension/ui/images/dust48.png similarity index 100% rename from extension/shared/images/dust48.png rename to extension/ui/images/dust48.png diff --git a/extension/shared/images/icon128.png b/extension/ui/images/icon128.png similarity index 100% rename from extension/shared/images/icon128.png rename to extension/ui/images/icon128.png diff --git a/extension/app/main.html b/extension/ui/main.html similarity index 100% rename from extension/app/main.html rename to extension/ui/main.html diff --git a/extension/app/main.tsx b/extension/ui/main.tsx similarity index 87% rename from extension/app/main.tsx rename to extension/ui/main.tsx index 8c8c42ec9591..6f394ea10756 100644 --- a/extension/app/main.tsx +++ b/extension/ui/main.tsx @@ -1,16 +1,16 @@ // Tailwind base globals -import "./src/css/global.css"; +import "../css/global.css"; // Use sparkle styles, override local globals import "@dust-tt/sparkle/dist/sparkle.css"; // Local tailwind components override sparkle styles -import "./src/css/components.css"; +import "../css/components.css"; // Local custom styles -import "./src/css/custom.css"; +import "../css/custom.css"; +import { AuthProvider } from "@app/ui/components/auth/AuthProvider"; +import { PortProvider } from "@app/ui/contextes/PortContext"; +import { routes } from "@app/ui/pages/routes"; import { Notification } from "@dust-tt/sparkle"; -import { AuthProvider } from "@extension/components/auth/AuthProvider"; -import { PortProvider } from "@extension/components/PortContext"; -import { routes } from "@extension/pages/routes"; import ReactDOM from "react-dom/client"; import { createBrowserRouter, RouterProvider } from "react-router-dom"; diff --git a/extension/shared/pages/ConversationPage.tsx b/extension/ui/pages/ConversationPage.tsx similarity index 76% rename from extension/shared/pages/ConversationPage.tsx rename to extension/ui/pages/ConversationPage.tsx index 8d8513855385..44b0610dcc7b 100644 --- a/extension/shared/pages/ConversationPage.tsx +++ b/extension/ui/pages/ConversationPage.tsx @@ -1,16 +1,16 @@ +import type { ProtectedRouteChildrenProps } from "@app/ui/components/auth/ProtectedRoute"; +import { ConversationContainer } from "@app/ui/components/conversation/ConversationContainer"; +import { ConversationsListButton } from "@app/ui/components/conversation/ConversationsListButton"; +import { FileDropProvider } from "@app/ui/components/conversation/FileUploaderContext"; +import { usePublicConversation } from "@app/ui/components/conversation/usePublicConversation"; +import { DropzoneContainer } from "@app/ui/components/DropzoneContainer"; +import { InputBarProvider } from "@app/ui/components/input_bar/InputBarContext"; import { BarHeader, Button, ChevronLeftIcon, ExternalLinkIcon, } from "@dust-tt/sparkle"; -import type { ProtectedRouteChildrenProps } from "@extension/components/auth/ProtectedRoute"; -import { ConversationContainer } from "@extension/components/conversation/ConversationContainer"; -import { ConversationsListButton } from "@extension/components/conversation/ConversationsListButton"; -import { FileDropProvider } from "@extension/components/conversation/FileUploaderContext"; -import { usePublicConversation } from "@extension/components/conversation/usePublicConversation"; -import { DropzoneContainer } from "@extension/components/DropzoneContainer"; -import { InputBarProvider } from "@extension/components/input_bar/InputBarContext"; import { useNavigate, useParams } from "react-router-dom"; export const ConversationPage = ({ diff --git a/extension/shared/pages/LoginPage.tsx b/extension/ui/pages/LoginPage.tsx similarity index 98% rename from extension/shared/pages/LoginPage.tsx rename to extension/ui/pages/LoginPage.tsx index 7860136dcaa7..6705ed7df507 100644 --- a/extension/shared/pages/LoginPage.tsx +++ b/extension/ui/pages/LoginPage.tsx @@ -1,3 +1,4 @@ +import { useAuth } from "@app/ui/components/auth/AuthProvider"; import { Button, ChevronDownIcon, @@ -10,7 +11,6 @@ import { Page, Spinner, } from "@dust-tt/sparkle"; -import { useAuth } from "@extension/components/auth/AuthProvider"; import { useEffect } from "react"; import { Link, useNavigate } from "react-router-dom"; diff --git a/extension/shared/pages/MainPage.tsx b/extension/ui/pages/MainPage.tsx similarity index 87% rename from extension/shared/pages/MainPage.tsx rename to extension/ui/pages/MainPage.tsx index 6da086b5e915..9da8a920687d 100644 --- a/extension/shared/pages/MainPage.tsx +++ b/extension/ui/pages/MainPage.tsx @@ -1,7 +1,16 @@ +import { getTheme, saveTheme } from "@app/shared/lib/storage"; +import { AssistantFavorites } from "@app/ui/components/assistants/AssistantFavorites"; +import { useAuth } from "@app/ui/components/auth/AuthProvider"; +import type { ProtectedRouteChildrenProps } from "@app/ui/components/auth/ProtectedRoute"; +import { ConversationsListButton } from "@app/ui/components/conversation/ConversationsListButton"; +import { FileDropProvider } from "@app/ui/components/conversation/FileUploaderContext"; +import { DropzoneContainer } from "@app/ui/components/DropzoneContainer"; +import { InputBarProvider } from "@app/ui/components/input_bar/InputBarContext"; import { Avatar, BarHeader, Button, + ConversationContainer, DropdownMenu, DropdownMenuContent, DropdownMenuItem, @@ -15,15 +24,6 @@ import { LightModeIcon, LogoutIcon, } from "@dust-tt/sparkle"; -import { AssistantFavorites } from "@extension/components/assistants/AssistantFavorites"; -import { useAuth } from "@extension/components/auth/AuthProvider"; -import type { ProtectedRouteChildrenProps } from "@extension/components/auth/ProtectedRoute"; -import { ConversationContainer } from "@extension/components/conversation/ConversationContainer"; -import { ConversationsListButton } from "@extension/components/conversation/ConversationsListButton"; -import { FileDropProvider } from "@extension/components/conversation/FileUploaderContext"; -import { DropzoneContainer } from "@extension/components/DropzoneContainer"; -import { InputBarProvider } from "@extension/components/input_bar/InputBarContext"; -import { getTheme, saveTheme } from "@extension/lib/storage"; import { useEffect, useState } from "react"; export type Theme = "light" | "dark" | "system"; diff --git a/extension/shared/pages/RunPage.tsx b/extension/ui/pages/RunPage.tsx similarity index 88% rename from extension/shared/pages/RunPage.tsx rename to extension/ui/pages/RunPage.tsx index ae1dbd76d3b0..ce8f16ce06b8 100644 --- a/extension/shared/pages/RunPage.tsx +++ b/extension/ui/pages/RunPage.tsx @@ -1,7 +1,7 @@ +import { postConversation } from "@app/shared/lib/conversation"; +import { useDustAPI } from "@app/shared/lib/dust_api"; +import { useFileUploaderService } from "@app/ui/hooks/useFileUploaderService"; import { Spinner } from "@dust-tt/sparkle"; -import { useFileUploaderService } from "@extension/hooks/useFileUploaderService"; -import { postConversation } from "@extension/lib/conversation"; -import { useDustAPI } from "@extension/lib/dust_api"; import { useEffect } from "react"; import { useLocation, useNavigate } from "react-router"; diff --git a/extension/shared/pages/routes.tsx b/extension/ui/pages/routes.tsx similarity index 71% rename from extension/shared/pages/routes.tsx rename to extension/ui/pages/routes.tsx index 6b73bd84de27..46f6f16f8c3d 100644 --- a/extension/shared/pages/routes.tsx +++ b/extension/ui/pages/routes.tsx @@ -1,8 +1,8 @@ -import { ProtectedRoute } from "@extension/components/auth/ProtectedRoute"; -import { ConversationPage } from "@extension/pages/ConversationPage"; -import { LoginPage } from "@extension/pages/LoginPage"; -import { MainPage } from "@extension/pages/MainPage"; -import { RunPage } from "@extension/pages/RunPage"; +import { ProtectedRoute } from "@app/ui/components/auth/ProtectedRoute"; +import { ConversationPage } from "@app/ui/pages/ConversationPage"; +import { LoginPage } from "@app/ui/pages/LoginPage"; +import { MainPage } from "@app/ui/pages/MainPage"; +import { RunPage } from "@app/ui/pages/RunPage"; export const routes = [ { From 9164095dac8eaae716447ed5d493d0d982e0f9a3 Mon Sep 17 00:00:00 2001 From: Flavien David Date: Tue, 18 Mar 2025 16:56:03 +0100 Subject: [PATCH 3/8] Restructure webpack config --- extension/package-lock.json | 75 +++++++++---------- extension/package.json | 2 + extension/{app => platforms/chrome}/page.ts | 2 +- .../chrome/webpack.config.ts} | 21 +++--- 4 files changed, 49 insertions(+), 51 deletions(-) rename extension/{app => platforms/chrome}/page.ts (99%) rename extension/{config/webpack.ts => platforms/chrome/webpack.config.ts} (96%) diff --git a/extension/package-lock.json b/extension/package-lock.json index c94f84a18dfc..63c0282c7db6 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -37,10 +37,12 @@ }, "devDependencies": { "@types/chrome": "^0.0.276", + "@types/dotenv-webpack": "^7.0.8", "@types/event-source-polyfill": "^1.0.5", "@types/node": "^22.7.4", "@types/react": "^18.3.11", "@types/react-dom": "^18.3.0", + "@types/webpack-bundle-analyzer": "^4.7.0", "@types/zip-webpack-plugin": "^3.0.6", "@typescript-eslint/eslint-plugin": "^8.8.1", "@typescript-eslint/parser": "^8.8.1", @@ -2922,12 +2924,22 @@ "@types/ms": "*" } }, + "node_modules/@types/dotenv-webpack": { + "version": "7.0.8", + "resolved": "https://registry.npmjs.org/@types/dotenv-webpack/-/dotenv-webpack-7.0.8.tgz", + "integrity": "sha512-JiLJdF2y9dW0eJjKUBlVnIwz/Raej00MOMdKcUuVxYJquvcuMgQdJw7cnN+hRZ7eejYgKr8kZsIw4nihwYYGeA==", + "dev": true, + "dependencies": { + "@types/node": "*", + "tapable": "^2.2.0", + "webpack": "^5" + } + }, "node_modules/@types/estree": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", - "dev": true, - "peer": true + "dev": true }, "node_modules/@types/event-source-polyfill": { "version": "1.0.5", @@ -3123,6 +3135,17 @@ "source-map": "^0.6.0" } }, + "node_modules/@types/webpack-bundle-analyzer": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/@types/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.7.0.tgz", + "integrity": "sha512-c5i2ThslSNSG8W891BRvOd/RoCjI2zwph8maD22b1adtSns20j+0azDDMCK06DiVrzTgnwiDl5Ntmu1YRJw8Sg==", + "dev": true, + "dependencies": { + "@types/node": "*", + "tapable": "^2.2.0", + "webpack": "^5" + } + }, "node_modules/@types/webpack-sources": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-3.2.3.tgz", @@ -3369,7 +3392,6 @@ "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.12.1.tgz", "integrity": "sha512-EKfMUOPRRUTy5UII4qJDGPpqfwjOmZ5jeGFwid9mnoqIFK+e0vqoi1qH56JpmZSzEL53jKnNzScdmftJyG5xWg==", "dev": true, - "peer": true, "dependencies": { "@webassemblyjs/helper-numbers": "1.11.6", "@webassemblyjs/helper-wasm-bytecode": "1.11.6" @@ -3379,29 +3401,25 @@ "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.6.tgz", "integrity": "sha512-ejAj9hfRJ2XMsNHk/v6Fu2dGS+i4UaXBXGemOfQ/JfQ6mdQg/WXtwleQRLLS4OvfDhv8rYnVwH27YJLMyYsxhw==", - "dev": true, - "peer": true + "dev": true }, "node_modules/@webassemblyjs/helper-api-error": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.6.tgz", "integrity": "sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q==", - "dev": true, - "peer": true + "dev": true }, "node_modules/@webassemblyjs/helper-buffer": { "version": "1.12.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.12.1.tgz", "integrity": "sha512-nzJwQw99DNDKr9BVCOZcLuJJUlqkJh+kVzVl6Fmq/tI5ZtEyWT1KZMyOXltXLZJmDtvLCDgwsyrkohEtopTXCw==", - "dev": true, - "peer": true + "dev": true }, "node_modules/@webassemblyjs/helper-numbers": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.6.tgz", "integrity": "sha512-vUIhZ8LZoIWHBohiEObxVm6hwP034jwmc9kuq5GdHZH0wiLVLIPcMCdpJzG4C11cHoQ25TFIQj9kaVADVX7N3g==", "dev": true, - "peer": true, "dependencies": { "@webassemblyjs/floating-point-hex-parser": "1.11.6", "@webassemblyjs/helper-api-error": "1.11.6", @@ -3412,15 +3430,13 @@ "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.6.tgz", "integrity": "sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA==", - "dev": true, - "peer": true + "dev": true }, "node_modules/@webassemblyjs/helper-wasm-section": { "version": "1.12.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.12.1.tgz", "integrity": "sha512-Jif4vfB6FJlUlSbgEMHUyk1j234GTNG9dBJ4XJdOySoj518Xj0oGsNi59cUQF4RRMS9ouBUxDDdyBVfPTypa5g==", "dev": true, - "peer": true, "dependencies": { "@webassemblyjs/ast": "1.12.1", "@webassemblyjs/helper-buffer": "1.12.1", @@ -3433,7 +3449,6 @@ "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.11.6.tgz", "integrity": "sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg==", "dev": true, - "peer": true, "dependencies": { "@xtuc/ieee754": "^1.2.0" } @@ -3443,7 +3458,6 @@ "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.11.6.tgz", "integrity": "sha512-m7a0FhE67DQXgouf1tbN5XQcdWoNgaAuoULHIfGFIEVKA6tu/edls6XnIlkmS6FrXAquJRPni3ZZKjw6FSPjPQ==", "dev": true, - "peer": true, "dependencies": { "@xtuc/long": "4.2.2" } @@ -3452,15 +3466,13 @@ "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.11.6.tgz", "integrity": "sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA==", - "dev": true, - "peer": true + "dev": true }, "node_modules/@webassemblyjs/wasm-edit": { "version": "1.12.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.12.1.tgz", "integrity": "sha512-1DuwbVvADvS5mGnXbE+c9NfA8QRcZ6iKquqjjmR10k6o+zzsRVesil54DKexiowcFCPdr/Q0qaMgB01+SQ1u6g==", "dev": true, - "peer": true, "dependencies": { "@webassemblyjs/ast": "1.12.1", "@webassemblyjs/helper-buffer": "1.12.1", @@ -3477,7 +3489,6 @@ "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.12.1.tgz", "integrity": "sha512-TDq4Ojh9fcohAw6OIMXqiIcTq5KUXTGRkVxbSo1hQnSy6lAM5GSdfwWeSxpAo0YzgsgF182E/U0mDNhuA0tW7w==", "dev": true, - "peer": true, "dependencies": { "@webassemblyjs/ast": "1.12.1", "@webassemblyjs/helper-wasm-bytecode": "1.11.6", @@ -3491,7 +3502,6 @@ "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.12.1.tgz", "integrity": "sha512-Jg99j/2gG2iaz3hijw857AVYekZe2SAskcqlWIZXjji5WStnOpVoat3gQfT/Q5tb2djnCjBtMocY/Su1GfxPBg==", "dev": true, - "peer": true, "dependencies": { "@webassemblyjs/ast": "1.12.1", "@webassemblyjs/helper-buffer": "1.12.1", @@ -3504,7 +3514,6 @@ "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.12.1.tgz", "integrity": "sha512-xikIi7c2FHXysxXe3COrVUPSheuBtpcfhbpFj4gmu7KRLYOzANztwUU0IbsqvMqzuNK2+glRGWCEqZo1WCLyAQ==", "dev": true, - "peer": true, "dependencies": { "@webassemblyjs/ast": "1.12.1", "@webassemblyjs/helper-api-error": "1.11.6", @@ -3519,7 +3528,6 @@ "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.12.1.tgz", "integrity": "sha512-+X4WAlOisVWQMikjbcvY2e0rwPsKQ9F688lksZhBcPycBBuii3O7m8FACbDMWDojpAqvjIncrG8J0XHKyQfVeA==", "dev": true, - "peer": true, "dependencies": { "@webassemblyjs/ast": "1.12.1", "@xtuc/long": "4.2.2" @@ -3573,15 +3581,13 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==", - "dev": true, - "peer": true + "dev": true }, "node_modules/@xtuc/long": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==", - "dev": true, - "peer": true + "dev": true }, "node_modules/acorn": { "version": "8.14.1", @@ -3599,7 +3605,6 @@ "resolved": "https://registry.npmjs.org/acorn-import-attributes/-/acorn-import-attributes-1.9.5.tgz", "integrity": "sha512-n02Vykv5uA3eHGM/Z2dQrcD56kL8TyDb2p1+0P83PClMnC/nc+anbQRhIOWnSq4Ke/KvDPrY3C9hDtC/A3eHnQ==", "dev": true, - "peer": true, "peerDependencies": { "acorn": "^8" } @@ -4342,7 +4347,6 @@ "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.4.tgz", "integrity": "sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==", "dev": true, - "peer": true, "engines": { "node": ">=6.0" } @@ -5620,8 +5624,7 @@ "version": "1.5.4", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.4.tgz", "integrity": "sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==", - "dev": true, - "peer": true + "dev": true }, "node_modules/es-object-atoms": { "version": "1.0.0", @@ -5979,7 +5982,6 @@ "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", "dev": true, - "peer": true, "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^4.1.1" @@ -6183,7 +6185,6 @@ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true, - "peer": true, "engines": { "node": ">=4.0" } @@ -6207,7 +6208,6 @@ "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", "dev": true, - "peer": true, "engines": { "node": ">=0.8.x" } @@ -6637,8 +6637,7 @@ "version": "0.4.1", "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", - "dev": true, - "peer": true + "dev": true }, "node_modules/globals": { "version": "13.24.0", @@ -8048,7 +8047,6 @@ "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", "integrity": "sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==", "dev": true, - "peer": true, "engines": { "node": ">=6.11.5" } @@ -9509,8 +9507,7 @@ "version": "2.6.2", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", - "dev": true, - "peer": true + "dev": true }, "node_modules/node-releases": { "version": "2.0.18", @@ -12841,7 +12838,6 @@ "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.2.tgz", "integrity": "sha512-TnbFSbcOCcDgjZ4piURLCbJ3nJhznVh9kw6F6iokjiFPl8ONxe9A6nMDVXDiNbrSfLILs6vB07F7wLBrwPYzJw==", "dev": true, - "peer": true, "dependencies": { "glob-to-regexp": "^0.4.1", "graceful-fs": "^4.1.2" @@ -12870,7 +12866,6 @@ "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.95.0.tgz", "integrity": "sha512-2t3XstrKULz41MNMBF+cJ97TyHdyQ8HCt//pqErqDvNjU9YQBnZxIHa11VXsi7F3mb5/aO2tuDxdeTPdU7xu9Q==", "dev": true, - "peer": true, "dependencies": { "@types/estree": "^1.0.5", "@webassemblyjs/ast": "^1.12.1", diff --git a/extension/package.json b/extension/package.json index be61ad237651..15f13826d61a 100644 --- a/extension/package.json +++ b/extension/package.json @@ -16,10 +16,12 @@ "license": "ISC", "devDependencies": { "@types/chrome": "^0.0.276", + "@types/dotenv-webpack": "^7.0.8", "@types/event-source-polyfill": "^1.0.5", "@types/node": "^22.7.4", "@types/react": "^18.3.11", "@types/react-dom": "^18.3.0", + "@types/webpack-bundle-analyzer": "^4.7.0", "@types/zip-webpack-plugin": "^3.0.6", "@typescript-eslint/eslint-plugin": "^8.8.1", "@typescript-eslint/parser": "^8.8.1", diff --git a/extension/app/page.ts b/extension/platforms/chrome/page.ts similarity index 99% rename from extension/app/page.ts rename to extension/platforms/chrome/page.ts index 9289957df8e3..11dde2e73e05 100644 --- a/extension/app/page.ts +++ b/extension/platforms/chrome/page.ts @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -import type { CaptureFullPageMessage } from "@extension/lib/messages"; +import type { CaptureFullPageMessage } from "@app/shared/lib/messages"; declare global { interface Window { diff --git a/extension/config/webpack.ts b/extension/platforms/chrome/webpack.config.ts similarity index 96% rename from extension/config/webpack.ts rename to extension/platforms/chrome/webpack.config.ts index 735d572684e4..21037281b364 100644 --- a/extension/config/webpack.ts +++ b/extension/platforms/chrome/webpack.config.ts @@ -1,17 +1,18 @@ -import path from "path"; -import fs from "fs"; -import { promisify } from "util"; -import webpack, { Configuration } from "webpack"; +import { execSync } from "child_process"; import CopyPlugin from "copy-webpack-plugin"; import Dotenv from "dotenv-webpack"; -import ZipPlugin from "zip-webpack-plugin"; -import WebpackBar from "webpackbar"; -import ExtReloader from "webpack-ext-reloader"; +import fs from "fs"; +import path from "path"; import TerserPlugin from "terser-webpack-plugin"; +import { promisify } from "util"; +import type { Configuration } from "webpack"; +import webpack from "webpack"; import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer"; +import ExtReloader from "webpack-ext-reloader"; +import WebpackBar from "webpackbar"; +import ZipPlugin from "zip-webpack-plugin"; -import { Environment } from "./env"; -import { execSync } from "child_process"; +import type { Environment } from "../../config/env"; const rootDir = path.resolve(__dirname, "../"); @@ -84,7 +85,7 @@ export const getConfig = async ({ resolve: { extensions: [".js", ".json", ".mjs", ".jsx", ".ts", ".tsx"], alias: { - "@extension": path.resolve("./app/src"), + "@app": path.resolve(__dirname, "./"), redis: false, // stream: "stream-browserify", // next: false, From bdc527c467f7d2daf155c81976d882a170ca7d68 Mon Sep 17 00:00:00 2001 From: Flavien David Date: Wed, 19 Mar 2025 10:10:15 +0100 Subject: [PATCH 4/8] Fix Chrome build --- extension/.gitignore | 2 +- extension/config/tailwind.config.js | 2 +- extension/package.json | 10 +++---- extension/platforms/chrome/background.ts | 13 ++++---- .../chrome}/contextes/PortContext.tsx | 0 extension/{ui => platforms/chrome}/main.tsx | 8 ++--- extension/platforms/chrome/webpack.config.ts | 30 +++++++++---------- extension/run/build.ts | 19 +++++++++++- extension/run/watch.ts | 19 +++++++++++- extension/shared/lib/auth.ts | 12 ++++---- extension/shared/lib/conversation.ts | 10 +++---- extension/shared/lib/dust_api.ts | 4 +-- extension/shared/lib/messages.ts | 2 +- extension/shared/lib/storage.ts | 4 +-- extension/shared/lib/swr.ts | 2 +- extension/shared/services/platform.ts | 13 +++++++- extension/tsconfig.json | 2 +- .../assistants/AssistantFavorites.tsx | 6 ++-- .../components/assistants/AssistantPicker.tsx | 2 +- .../usePublicAgentConfigurations.ts | 4 +-- extension/ui/pages/MainPage.tsx | 2 +- 21 files changed, 105 insertions(+), 61 deletions(-) rename extension/{ui => platforms/chrome}/contextes/PortContext.tsx (100%) rename extension/{ui => platforms/chrome}/main.tsx (92%) diff --git a/extension/.gitignore b/extension/.gitignore index b287036b250d..94be513be0fd 100644 --- a/extension/.gitignore +++ b/extension/.gitignore @@ -2,5 +2,5 @@ .idea/ node_modules/ -build/* packages/* +platforms/chrome/build/* \ No newline at end of file diff --git a/extension/config/tailwind.config.js b/extension/config/tailwind.config.js index 6e8bd9b36a77..672528af61db 100644 --- a/extension/config/tailwind.config.js +++ b/extension/config/tailwind.config.js @@ -420,7 +420,7 @@ module.exports = { require("tailwind-scrollbar-hide"), require("tailwindcss-animate"), ], - content: ["./app/**/*.tsx"], + content: ["./ui/**/*.tsx"], safelist: [ { pattern: /^bg-/, diff --git a/extension/package.json b/extension/package.json index 15f13826d61a..270ce9cd60b1 100644 --- a/extension/package.json +++ b/extension/package.json @@ -4,11 +4,11 @@ "description": "Dust Chrome Extension", "scripts": { "clean": "rm -rf build/*", - "dev": "npm run clean && tsx run/watch.ts --mode=development", - "package:production": "tsx run/build.ts", - "package:release": "tsx run/build.ts --release", - "analyze": "tsx run/build.ts --analyze", - "lint": "eslint app", + "dev:chrome": "npm run clean && tsx run/watch.ts --platform=chrome", + "package:chrome:production": "tsx run/build.ts --platform=chrome", + "package:chrome:release": "tsx run/build.ts --platform=chrome --release", + "analyze:chrome": "tsx run/build.ts --platform=chrome --analyze", + "lint": "eslint .", "format": "prettier --write .", "format:check": "prettier --check ." }, diff --git a/extension/platforms/chrome/background.ts b/extension/platforms/chrome/background.ts index bae26ad3b6a0..e971a856c77b 100644 --- a/extension/platforms/chrome/background.ts +++ b/extension/platforms/chrome/background.ts @@ -1,12 +1,9 @@ -import type { PendingUpdate } from "shared/lib/storage"; -import { getStoredUser, savePendingUpdate } from "shared/lib/storage"; - import { AUTH0_CLIENT_DOMAIN, AUTH0_CLIENT_ID, DUST_API_AUDIENCE, -} from "../../shared/lib/config"; -import { extractPage } from "../../shared/lib/extraction"; +} from "@app/shared/lib/config"; +import { extractPage } from "@app/shared/lib/extraction"; import type { Auth0AuthorizeResponse, AuthBackgroundMessage, @@ -16,8 +13,10 @@ import type { GetActiveTabBackgroundMessage, GetActiveTabBackgroundResponse, InputBarStatusMessage, -} from "../../shared/lib/messages"; -import { generatePKCE } from "../../shared/lib/utils"; +} from "@app/shared/lib/messages"; +import type { PendingUpdate } from "@app/shared/lib/storage"; +import { getStoredUser, savePendingUpdate } from "@app/shared/lib/storage"; +import { generatePKCE } from "@app/shared/lib/utils"; const log = console.error; diff --git a/extension/ui/contextes/PortContext.tsx b/extension/platforms/chrome/contextes/PortContext.tsx similarity index 100% rename from extension/ui/contextes/PortContext.tsx rename to extension/platforms/chrome/contextes/PortContext.tsx diff --git a/extension/ui/main.tsx b/extension/platforms/chrome/main.tsx similarity index 92% rename from extension/ui/main.tsx rename to extension/platforms/chrome/main.tsx index 6f394ea10756..c2eba6bbc233 100644 --- a/extension/ui/main.tsx +++ b/extension/platforms/chrome/main.tsx @@ -1,14 +1,14 @@ // Tailwind base globals -import "../css/global.css"; +import "../../ui/css/global.css"; // Use sparkle styles, override local globals import "@dust-tt/sparkle/dist/sparkle.css"; // Local tailwind components override sparkle styles -import "../css/components.css"; +import "../../ui/css/components.css"; // Local custom styles -import "../css/custom.css"; +import "../../ui/css/custom.css"; +import { PortProvider } from "@app/platforms/chrome/contextes/PortContext"; import { AuthProvider } from "@app/ui/components/auth/AuthProvider"; -import { PortProvider } from "@app/ui/contextes/PortContext"; import { routes } from "@app/ui/pages/routes"; import { Notification } from "@dust-tt/sparkle"; import ReactDOM from "react-dom/client"; diff --git a/extension/platforms/chrome/webpack.config.ts b/extension/platforms/chrome/webpack.config.ts index 21037281b364..c8355f273a07 100644 --- a/extension/platforms/chrome/webpack.config.ts +++ b/extension/platforms/chrome/webpack.config.ts @@ -14,7 +14,7 @@ import ZipPlugin from "zip-webpack-plugin"; import type { Environment } from "../../config/env"; -const rootDir = path.resolve(__dirname, "../"); +const rootDir = path.resolve(__dirname); const resolvePath = (...segments: string[]) => path.resolve(rootDir, ...segments); @@ -40,8 +40,8 @@ export const getConfig = async ({ shouldBuild: "none" | "prod" | "analyze"; }): Promise => { const isDevelopment = env === "development"; - const baseManifestPath = resolvePath("./config/manifest.base.json"); - const envManifestPath = resolvePath(`./config/manifest.${env}.json`); + const baseManifestPath = resolvePath("./manifests/manifest.base.json"); + const envManifestPath = resolvePath(`./manifests/manifest.${env}.json`); const baseManifest = JSON.parse(await readFileAsync(baseManifestPath)); const envManifest = JSON.parse(await readFileAsync(envManifestPath)); @@ -51,7 +51,7 @@ export const getConfig = async ({ const buildDirPath = resolvePath("./build"); const packageDirPath = - shouldBuild === "prod" ? resolvePath("./packages") : null; + shouldBuild === "prod" ? resolvePath("../../packages") : null; return { mode: isDevelopment ? "development" : "production", @@ -73,9 +73,9 @@ export const getConfig = async ({ performance: false, devtool: isDevelopment ? "inline-source-map" : undefined, entry: { - main: resolvePath("./app/main.tsx"), - background: resolvePath("./app/background.ts"), - page: resolvePath("./app/page.ts"), + main: resolvePath("./main.tsx"), + background: resolvePath("./background.ts"), + page: resolvePath("./page.ts"), }, output: { path: buildDirPath, @@ -85,10 +85,8 @@ export const getConfig = async ({ resolve: { extensions: [".js", ".json", ".mjs", ".jsx", ".ts", ".tsx"], alias: { - "@app": path.resolve(__dirname, "./"), + "@app": path.resolve(__dirname, "../../"), redis: false, - // stream: "stream-browserify", - // next: false, }, fallback: { url: false, @@ -115,7 +113,7 @@ export const getConfig = async ({ loader: "postcss-loader", options: { postcssOptions: { - config: path.resolve(__dirname, "postcss.config.js"), + config: resolvePath("../../config/postcss.config.js"), }, }, }, @@ -126,7 +124,7 @@ export const getConfig = async ({ use: { loader: "ts-loader", options: { - configFile: resolvePath("./tsconfig.json"), + configFile: resolvePath("../../tsconfig.json"), }, }, exclude: /node_modules/, @@ -149,7 +147,9 @@ export const getConfig = async ({ Buffer: ["buffer", "Buffer"], }), new Dotenv({ - path: isDevelopment ? "./.env.development" : "./.env.production", + path: isDevelopment + ? resolvePath("../../.env.development") + : resolvePath("../../.env.production"), }), new CopyPlugin({ patterns: [ @@ -165,11 +165,11 @@ export const getConfig = async ({ to: path.join(buildDirPath, "manifest.json"), }, { - from: resolvePath("./app/main.html"), + from: resolvePath("../../ui/main.html"), to: path.join(buildDirPath, "main.html"), }, { - context: resolvePath("./app/images"), + context: resolvePath("../../ui/images"), from: "**/*.png", to: path.resolve(buildDirPath, "images"), }, diff --git a/extension/run/build.ts b/extension/run/build.ts index 58f881f2787e..6f7c2148d942 100644 --- a/extension/run/build.ts +++ b/extension/run/build.ts @@ -1,7 +1,24 @@ +import type { PlatformType } from "@app/shared/services/platform"; +import { isValidPlatform } from "@app/shared/services/platform"; import webpack from "webpack"; -import { getConfig } from "../config/webpack"; + +import { getConfig as getChromeConfig } from "../platforms/chrome/webpack.config"; + +const configPerPlatform: Record = { + chrome: getChromeConfig, +}; async function main() { + const platform = process.argv + .find((arg) => arg.startsWith("--platform=")) + ?.split("=")[1]; + + if (!isValidPlatform(platform)) { + throw new Error(`Unknown platform: ${platform}`); + } + + const getConfig = configPerPlatform[platform]; + const config = await getConfig({ env: process.argv.includes("--release") ? "release" : "production", shouldBuild: process.argv.includes("--analyze") ? "analyze" : "prod", diff --git a/extension/run/watch.ts b/extension/run/watch.ts index ee6305a6f5dc..b270fbbcea94 100644 --- a/extension/run/watch.ts +++ b/extension/run/watch.ts @@ -1,7 +1,24 @@ +import type { PlatformType } from "@app/shared/services/platform"; +import { isValidPlatform } from "@app/shared/services/platform"; import webpack from "webpack"; -import { getConfig } from "../config/webpack"; + +import { getConfig as getChromeConfig } from "../platforms/chrome/webpack.config"; + +const configPerPlatform: Record = { + chrome: getChromeConfig, +}; async function main() { + const platform = process.argv + .find((arg) => arg.startsWith("--platform=")) + ?.split("=")[1]; + + if (!isValidPlatform(platform)) { + throw new Error(`Unknown platform: ${platform}`); + } + + const getConfig = configPerPlatform[platform]; + const config = await getConfig({ env: "development", shouldBuild: "none" }); const compiler = webpack(config); compiler.watch({ ignored: /node_modules/ }, async (err, res) => { diff --git a/extension/shared/lib/auth.ts b/extension/shared/lib/auth.ts index 1b710918db76..2205f9366e3a 100644 --- a/extension/shared/lib/auth.ts +++ b/extension/shared/lib/auth.ts @@ -1,27 +1,27 @@ -import type { Result, WorkspaceType } from "@dust-tt/client"; -import { Err, Ok } from "@dust-tt/client"; import { AUTH0_CLAIM_NAMESPACE, DEFAULT_DUST_API_DOMAIN, DUST_EU_URL, DUST_US_URL, -} from "@extension/lib/config"; +} from "@app/shared/lib/config"; import { sendAuthMessage, sendRefreshTokenMessage, sentLogoutMessage, -} from "@extension/lib/messages"; +} from "@app/shared/lib/messages"; import type { StoredTokens, StoredUser, UserTypeWithExtensionWorkspaces, -} from "@extension/lib/storage"; +} from "@app/shared/lib/storage"; import { clearStoredData, getStoredTokens, saveTokens, saveUser, -} from "@extension/lib/storage"; +} from "@app/shared/lib/storage"; +import type { Result, WorkspaceType } from "@dust-tt/client"; +import { Err, Ok } from "@dust-tt/client"; import { jwtDecode } from "jwt-decode"; const REGIONS = ["europe-west1", "us-central1"] as const; diff --git a/extension/shared/lib/conversation.ts b/extension/shared/lib/conversation.ts index d53a0d9b305f..de59011310a7 100644 --- a/extension/shared/lib/conversation.ts +++ b/extension/shared/lib/conversation.ts @@ -1,3 +1,8 @@ +import { getAccessToken } from "@app/shared/lib/auth"; +import type { GetActiveTabOptions } from "@app/shared/lib/messages"; +import { sendGetActiveTabMessage } from "@app/shared/lib/messages"; +import { getStoredUser } from "@app/shared/lib/storage"; +import type { UploadedFileWithSupersededContentFragmentId } from "@app/shared/lib/types"; import type { AgentMentionType, AgentMessageNewEvent, @@ -15,11 +20,6 @@ import type { UserType, } from "@dust-tt/client"; import { Err, Ok } from "@dust-tt/client"; -import { getAccessToken } from "@extension/lib/auth"; -import type { GetActiveTabOptions } from "@extension/lib/messages"; -import { sendGetActiveTabMessage } from "@extension/lib/messages"; -import { getStoredUser } from "@extension/lib/storage"; -import type { UploadedFileWithSupersededContentFragmentId } from "@extension/lib/types"; type SubmitMessageError = { type: diff --git a/extension/shared/lib/dust_api.ts b/extension/shared/lib/dust_api.ts index f8537f16afc2..8ee17e8f0535 100644 --- a/extension/shared/lib/dust_api.ts +++ b/extension/shared/lib/dust_api.ts @@ -1,6 +1,6 @@ +import { getAccessToken } from "@app/shared/lib/auth"; +import { useAuth } from "@app/ui/components/auth/AuthProvider"; import { DustAPI } from "@dust-tt/client"; -import { useAuth } from "@extension/components/auth/AuthProvider"; -import { getAccessToken } from "@extension/lib/auth"; export const useDustAPI = () => { const { token, isAuthenticated, isUserSetup, user, workspace } = useAuth(); diff --git a/extension/shared/lib/messages.ts b/extension/shared/lib/messages.ts index 53875284573b..d994f1df9903 100644 --- a/extension/shared/lib/messages.ts +++ b/extension/shared/lib/messages.ts @@ -1,4 +1,4 @@ -import { saveTokens } from "@extension/lib/storage"; +import { saveTokens } from "@app/shared/lib/storage"; export type Auth0AuthorizeResponse = { accessToken: string; diff --git a/extension/shared/lib/storage.ts b/extension/shared/lib/storage.ts index 11ba2e984e25..c9cc77090788 100644 --- a/extension/shared/lib/storage.ts +++ b/extension/shared/lib/storage.ts @@ -1,10 +1,10 @@ +import type { Auth0AuthorizeResponse } from "@app/shared/lib/messages"; +import type { UploadedFileWithKind } from "@app/shared/lib/types"; import type { ContentFragmentType, ExtensionWorkspaceType, UserType, } from "@dust-tt/client"; -import type { Auth0AuthorizeResponse } from "@extension/lib/messages"; -import type { UploadedFileWithKind } from "@extension/lib/types"; export type UserTypeWithExtensionWorkspaces = UserType & { workspaces: ExtensionWorkspaceType[]; diff --git a/extension/shared/lib/swr.ts b/extension/shared/lib/swr.ts index 27dd5c19a238..25cf72596369 100644 --- a/extension/shared/lib/swr.ts +++ b/extension/shared/lib/swr.ts @@ -1,4 +1,4 @@ -import { useAuthErrorCheck } from "@extension/hooks/useAuthErrorCheck"; +import { useAuthErrorCheck } from "@app/ui/hooks/useAuthErrorCheck"; import { useCallback } from "react"; import type { Fetcher, Key, SWRConfiguration } from "swr"; import useSWR, { useSWRConfig } from "swr"; diff --git a/extension/shared/services/platform.ts b/extension/shared/services/platform.ts index e13e4d4aa781..1715eca3ab81 100644 --- a/extension/shared/services/platform.ts +++ b/extension/shared/services/platform.ts @@ -1,3 +1,14 @@ +// TODO(2025-03-19 flav): Add front platform. +const PLATFORM_TYPES = ["chrome"] as const; +export type PlatformType = (typeof PLATFORM_TYPES)[number]; + export interface PlatformService { - platform: "chrome" | "front"; + platform: PlatformType; +} + +export function isValidPlatform(platform: unknown): platform is PlatformType { + return ( + typeof platform === "string" && + PLATFORM_TYPES.includes(platform as PlatformType) + ); } diff --git a/extension/tsconfig.json b/extension/tsconfig.json index 115ece63939f..79fbd4aafa8b 100644 --- a/extension/tsconfig.json +++ b/extension/tsconfig.json @@ -25,6 +25,6 @@ "@app/*": ["./*"] } }, - "include": ["./shared/**/*", "./platforms/**/*", "./ui/**/*"], + "include": ["./shared/**/*", "./platforms/**/*", "./ui/**/*", "./run/**/*"], "exclude": ["node_modules", "build"] } diff --git a/extension/ui/components/assistants/AssistantFavorites.tsx b/extension/ui/components/assistants/AssistantFavorites.tsx index a19892026e25..0e81baf4f274 100644 --- a/extension/ui/components/assistants/AssistantFavorites.tsx +++ b/extension/ui/components/assistants/AssistantFavorites.tsx @@ -1,7 +1,7 @@ import { AssistantCard, Button, CardGrid, Page } from "@dust-tt/sparkle"; -import { usePublicAgentConfigurations } from "@extension/components/assistants/usePublicAgentConfigurations"; -import { InputBarContext } from "@extension/components/input_bar/InputBarContext"; -import type { StoredUser } from "@extension/lib/storage"; +import { usePublicAgentConfigurations } from "@app/ui/components/assistants/usePublicAgentConfigurations"; +import { InputBarContext } from "@app/ui/components/input_bar/InputBarContext"; +import type { StoredUser } from "@app/shared/lib/storage"; import { useCallback, useContext } from "react"; type AssistantFavoritesProps = { diff --git a/extension/ui/components/assistants/AssistantPicker.tsx b/extension/ui/components/assistants/AssistantPicker.tsx index 01d214def670..1818ef6d4acb 100644 --- a/extension/ui/components/assistants/AssistantPicker.tsx +++ b/extension/ui/components/assistants/AssistantPicker.tsx @@ -14,7 +14,7 @@ import { RobotIcon, ScrollArea, } from "@dust-tt/sparkle"; -import { filterAndSortAgents } from "@extension/lib/utils"; +import { filterAndSortAgents } from "@app/shared/lib/utils"; import { useEffect, useState } from "react"; export function AssistantPicker({ diff --git a/extension/ui/components/assistants/usePublicAgentConfigurations.ts b/extension/ui/components/assistants/usePublicAgentConfigurations.ts index a00dfb476158..1c4cc15036ed 100644 --- a/extension/ui/components/assistants/usePublicAgentConfigurations.ts +++ b/extension/ui/components/assistants/usePublicAgentConfigurations.ts @@ -1,6 +1,6 @@ import type { AgentConfigurationViewType } from "@dust-tt/client"; -import { useDustAPI } from "@extension/lib/dust_api"; -import { useSWRWithDefaults } from "@extension/lib/swr"; +import { useDustAPI } from "@app/shared/lib/dust_api"; +import { useSWRWithDefaults } from "@app/shared/lib/swr"; import { useMemo } from "react"; export function usePublicAgentConfigurations( diff --git a/extension/ui/pages/MainPage.tsx b/extension/ui/pages/MainPage.tsx index 9da8a920687d..bb022ff72ad7 100644 --- a/extension/ui/pages/MainPage.tsx +++ b/extension/ui/pages/MainPage.tsx @@ -2,6 +2,7 @@ import { getTheme, saveTheme } from "@app/shared/lib/storage"; import { AssistantFavorites } from "@app/ui/components/assistants/AssistantFavorites"; import { useAuth } from "@app/ui/components/auth/AuthProvider"; import type { ProtectedRouteChildrenProps } from "@app/ui/components/auth/ProtectedRoute"; +import { ConversationContainer } from "@app/ui/components/conversation/ConversationContainer"; import { ConversationsListButton } from "@app/ui/components/conversation/ConversationsListButton"; import { FileDropProvider } from "@app/ui/components/conversation/FileUploaderContext"; import { DropzoneContainer } from "@app/ui/components/DropzoneContainer"; @@ -10,7 +11,6 @@ import { Avatar, BarHeader, Button, - ConversationContainer, DropdownMenu, DropdownMenuContent, DropdownMenuItem, From 25459497584923c164b7f45dde0d683989729f3c Mon Sep 17 00:00:00 2001 From: Flavien David Date: Wed, 19 Mar 2025 10:13:37 +0100 Subject: [PATCH 5/8] =?UTF-8?q?=F0=9F=91=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extension/platforms/chrome/webpack.config.ts | 3 ++- extension/ui/components/assistants/AssistantFavorites.tsx | 4 ++-- extension/ui/components/assistants/AssistantPicker.tsx | 2 +- .../ui/components/assistants/usePublicAgentConfigurations.ts | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/extension/platforms/chrome/webpack.config.ts b/extension/platforms/chrome/webpack.config.ts index c8355f273a07..67f55a00a863 100644 --- a/extension/platforms/chrome/webpack.config.ts +++ b/extension/platforms/chrome/webpack.config.ts @@ -28,6 +28,7 @@ const getCommitHash = () => { try { return execSync("git rev-parse --short HEAD").toString().trim(); } catch (e) { + console.error(e); return "development"; } }; @@ -187,7 +188,7 @@ export const getConfig = async ({ }) : null, isDevelopment - ? // @ts-ignore (it's working) + ? // @ts-expect-error (it's working) new ExtReloader({ port: 9090, reloadPage: true, diff --git a/extension/ui/components/assistants/AssistantFavorites.tsx b/extension/ui/components/assistants/AssistantFavorites.tsx index 0e81baf4f274..ec0ed7d5f338 100644 --- a/extension/ui/components/assistants/AssistantFavorites.tsx +++ b/extension/ui/components/assistants/AssistantFavorites.tsx @@ -1,7 +1,7 @@ -import { AssistantCard, Button, CardGrid, Page } from "@dust-tt/sparkle"; +import type { StoredUser } from "@app/shared/lib/storage"; import { usePublicAgentConfigurations } from "@app/ui/components/assistants/usePublicAgentConfigurations"; import { InputBarContext } from "@app/ui/components/input_bar/InputBarContext"; -import type { StoredUser } from "@app/shared/lib/storage"; +import { AssistantCard, Button, CardGrid, Page } from "@dust-tt/sparkle"; import { useCallback, useContext } from "react"; type AssistantFavoritesProps = { diff --git a/extension/ui/components/assistants/AssistantPicker.tsx b/extension/ui/components/assistants/AssistantPicker.tsx index 1818ef6d4acb..3dbca0ca76e3 100644 --- a/extension/ui/components/assistants/AssistantPicker.tsx +++ b/extension/ui/components/assistants/AssistantPicker.tsx @@ -1,3 +1,4 @@ +import { filterAndSortAgents } from "@app/shared/lib/utils"; import type { LightAgentConfigurationType, LightWorkspaceType, @@ -14,7 +15,6 @@ import { RobotIcon, ScrollArea, } from "@dust-tt/sparkle"; -import { filterAndSortAgents } from "@app/shared/lib/utils"; import { useEffect, useState } from "react"; export function AssistantPicker({ diff --git a/extension/ui/components/assistants/usePublicAgentConfigurations.ts b/extension/ui/components/assistants/usePublicAgentConfigurations.ts index 1c4cc15036ed..cd2b10a8650d 100644 --- a/extension/ui/components/assistants/usePublicAgentConfigurations.ts +++ b/extension/ui/components/assistants/usePublicAgentConfigurations.ts @@ -1,6 +1,6 @@ -import type { AgentConfigurationViewType } from "@dust-tt/client"; import { useDustAPI } from "@app/shared/lib/dust_api"; import { useSWRWithDefaults } from "@app/shared/lib/swr"; +import type { AgentConfigurationViewType } from "@dust-tt/client"; import { useMemo } from "react"; export function usePublicAgentConfigurations( From e2ba6923519c5786e661ba281c3ad371e2e876de Mon Sep 17 00:00:00 2001 From: Flavien David Date: Wed, 19 Mar 2025 10:21:17 +0100 Subject: [PATCH 6/8] Ignore JS files in linter --- extension/.eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/extension/.eslintrc.js b/extension/.eslintrc.js index ac3eec760cb1..1d1c74e88219 100644 --- a/extension/.eslintrc.js +++ b/extension/.eslintrc.js @@ -60,4 +60,5 @@ module.exports = { project: "./tsconfig.json", tsconfigRootDir: __dirname, }, + ignorePatterns: [".eslintrc.js", "config/"], }; From d3800df4c2f6130afbca2a41a86808adc3ffccf4 Mon Sep 17 00:00:00 2001 From: Flavien David Date: Wed, 19 Mar 2025 10:25:11 +0100 Subject: [PATCH 7/8] Fix package command --- .github/workflows/build-and-lint-extension.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-lint-extension.yml b/.github/workflows/build-and-lint-extension.yml index 1635dd624957..426b02758d72 100644 --- a/.github/workflows/build-and-lint-extension.yml +++ b/.github/workflows/build-and-lint-extension.yml @@ -18,4 +18,4 @@ jobs: cache: "npm" cache-dependency-path: ./extension/package-lock.json - working-directory: extension - run: npm install && npm run lint && npm run format:check && npm run package:production + run: npm install && npm run lint && npm run format:check && npm run package:chrome:production From 4742831f2ff6dd46cc69377e6fe560c3b55414b1 Mon Sep 17 00:00:00 2001 From: Flavien David Date: Wed, 19 Mar 2025 10:27:20 +0100 Subject: [PATCH 8/8] =?UTF-8?q?=F0=9F=99=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extension/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/package.json b/extension/package.json index 270ce9cd60b1..ab3ab70489ab 100644 --- a/extension/package.json +++ b/extension/package.json @@ -4,7 +4,7 @@ "description": "Dust Chrome Extension", "scripts": { "clean": "rm -rf build/*", - "dev:chrome": "npm run clean && tsx run/watch.ts --platform=chrome", + "dev:chrome": "npm run clean && tsx run/watch.ts --platform=chrome --mode=development", "package:chrome:production": "tsx run/build.ts --platform=chrome", "package:chrome:release": "tsx run/build.ts --platform=chrome --release", "analyze:chrome": "tsx run/build.ts --platform=chrome --analyze",