Skip to content

Commit

Permalink
fix(chat): forced full reload on code update (#180)
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Kadlec <[email protected]>
  • Loading branch information
kapetr authored Jan 15, 2025
1 parent 513211e commit c931479
Show file tree
Hide file tree
Showing 27 changed files with 149 additions and 141 deletions.
21 changes: 0 additions & 21 deletions src/app/(main)/[projectId]/tools/public/page.tsx

This file was deleted.

8 changes: 2 additions & 6 deletions src/app/api/threads-messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@
import { isNotNull } from '@/utils/helpers';
import { client } from '../client';
import { readFile } from '../files';
import {
assertSuccessResponse,
decodeMetadata,
getRequestHeaders,
} from '../utils';
import { assertSuccessResponse, getRequestHeaders } from '../utils';
import {
MessageCreateBody,
MessagesListQuery,
MessageUpdateBody,
} from './types';
import { MessageMetadata, MessageWithFiles } from '@/modules/chat/types';
import { MessageWithFiles } from '@/modules/chat/types';

export const MESSAGES_PAGE_SIZE = 100;

Expand Down
2 changes: 1 addition & 1 deletion src/layout/shell/AppShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import { notFound } from 'next/navigation';
import { PropsWithChildren } from 'react';
import { AppProvider } from '../providers/AppProvider';
import { AppHeader } from './AppHeader';
import classes from './AppShell.module.scss';
import { ensureDefaultOrganizationId } from '@/app/auth/rsc';
import { ModalProvider } from '../providers/ModalProvider';
import classes from './AppShell.module.scss';

interface Props {
projectId: string;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/apps/builder/AppBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ import { Tooltip } from '@/components/Tooltip/Tooltip';
import { useBreakpoint } from '@/hooks/useBreakpoint';
import { useModal } from '@/layout/providers/ModalProvider';
import { NavbarHeading } from '@/layout/shell/Navbar';
import { ChatProvider, useChat } from '@/modules/chat/providers/ChatProvider';
import { ChatProvider } from '@/modules/chat/providers/ChatProvider';
import {
ChatMessage,
MessageMetadata,
MessageWithFiles,
UserChatMessage,
} from '@/modules/chat/types';
import { useLayoutActions } from '@/store/layout';
import { isNotNull } from '@/utils/helpers';
Expand All @@ -52,6 +51,7 @@ import { useAppBuilder, useAppBuilderApi } from './AppBuilderProvider';
import { ArtifactSharedIframe } from './ArtifactSharedIframe';
import { SourceCodeEditor } from './SourceCodeEditor';
import { useAppContext } from '@/layout/providers/AppProvider';
import { useChat } from '@/modules/chat/providers/chat-context';
import { isBotMessage } from '@/modules/chat/utils';

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/apps/builder/SourceCodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import classes from './SourceCodeEditor.module.scss';
import { useEffect, useId, useRef, useState } from 'react';
import { useAppBuilder, useAppBuilderApi } from './AppBuilderProvider';
import { Button } from '@carbon/react';
import { useChat } from '@/modules/chat/providers/ChatProvider';
import { useChat } from '@/modules/chat/providers/chat-context';

interface Props {
onSaveCode: () => void;
Expand Down
3 changes: 2 additions & 1 deletion src/modules/assistants/builder/Builder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { useOnMount } from '@/hooks/useOnMount';
import { useUserSetting } from '@/layout/hooks/useUserSetting';
import { useAppContext } from '@/layout/providers/AppProvider';
import { ChatHomeView } from '@/modules/chat/ChatHomeView';
import { ChatProvider, useChat } from '@/modules/chat/providers/ChatProvider';
import { ChatProvider } from '@/modules/chat/providers/ChatProvider';
import { FilesUploadProvider } from '@/modules/chat/providers/FilesUploadProvider';
import { MessageWithFiles } from '@/modules/chat/types';
import { VectorStoreFilesUploadProvider } from '@/modules/knowledge/files/VectorStoreFilesUploadProvider';
Expand All @@ -45,6 +45,7 @@ import { InstructionsTextArea } from './InstructionsTextArea';
import { KnowledgeSelector } from './KnowledgeSelector';
import { StarterQuestionsTextArea } from './StarterQuestionsTextArea';
import { useDeleteAssistant } from './useDeleteAssistant';
import { useChat } from '@/modules/chat/providers/chat-context';

interface Props {
thread?: Thread;
Expand Down
8 changes: 4 additions & 4 deletions src/modules/chat/ChatHomeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import { useEffect } from 'react';
import { ConversationView } from './ConversationView';
import { EmptyChatView } from './EmptyChatView';
import { threadsQuery } from './history/queries';
import { Thread } from '@/app/api/threads/types';
import { ChatMessage } from './types';
import { useAppContext } from '@/layout/providers/AppProvider';
import {
SendMessageResult,
useChat,
useChatMessages,
} from './providers/ChatProvider';
import { Thread } from '@/app/api/threads/types';
import { ChatMessage } from './types';
import { useAppContext } from '@/layout/providers/AppProvider';
} from './providers/chat-context';

export interface ChatState {
thread: Thread;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/ConversationView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import classes from './ConversationView.module.scss';
import { FilesDropzone } from './layout/FilesDropzone';
import { InputBar } from './layout/InputBar';
import { Message } from './message/Message';
import { useChat, useChatMessages } from './providers/ChatProvider';
import { useFilesUpload } from './providers/FilesUploadProvider';
import { BotChatMessage } from './types';
import { getNewRunSetup, getRunSetup, isBotMessage } from './utils';
import { useChat, useChatMessages } from './providers/chat-context';

interface Props {
onShowMobilePreviewButtonClick?: MouseEventHandler<HTMLButtonElement>;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/EmptyChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import { AssistantAvatar } from './layout/AssistantAvatar';
import { Disclaimer } from './layout/Disclaimer';
import { FilesDropzone } from './layout/FilesDropzone';
import { InputBar } from './layout/InputBar';
import { SendMessageResult, useChat } from './providers/ChatProvider';
import { useFilesUpload } from './providers/FilesUploadProvider';
import { SendMessageResult, useChat } from './providers/chat-context';

interface Props {
onMessageSent?: (result: SendMessageResult) => void;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/assistant-plan/PlanStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import { AnimatePresence, motion } from 'framer-motion';
import JSON5 from 'json5';
import { ReactElement, useCallback, useEffect, useId, useMemo } from 'react';
import { useThreadApi } from '../hooks/useThreadApi';
import { useChat } from '../providers/ChatProvider';
import {
useExpandedStep,
useExpandedStepActions,
Expand All @@ -57,6 +56,7 @@ import { useUserSetting } from '@/layout/hooks/useUserSetting';
import { getToolApproval, getToolReferenceFromToolCall } from './utils';
import { useAppContext } from '@/layout/providers/AppProvider';
import { Spinner } from '@/components/Spinner/Spinner';
import { useChat } from '../providers/chat-context';

interface Props {
step: AssistantPlanStep;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/assistant-plan/PlanWithSources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import clsx from 'clsx';
import { useEffect, useMemo, useState } from 'react';
import { v4 as uuid } from 'uuid';
import { SourcesView } from '../layout/SourcesView';
import { useChat } from '../providers/ChatProvider';
import { useChat } from '../providers/chat-context';
import {
ExpandedStepProvider,
useExpandedStep,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/hooks/useChatStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ import { useQueryClient } from '@tanstack/react-query';
import { readRunQuery } from '../queries';
import { Thread } from '@/app/api/threads/types';
import { getToolApprovalId } from '@/modules/tools/utils';
import { RunController } from '../providers/ChatProvider';
import { EntityWithDecodedMetadata } from '@/app/api/types';
import { useAppContext } from '@/layout/providers/AppProvider';
import { RunController } from '../providers/chat-context';

type RunsCreateBodyDecoded = EntityWithDecodedMetadata<
RunsCreateBody,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/hooks/useRetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { deleteMessage } from '@/app/api/threads-messages';
import { useToast } from '@/layout/providers/ToastProvider';
import { useMutation } from '@tanstack/react-query';
import { v4 as uuid } from 'uuid';
import { useChat } from '../providers/ChatProvider';
import { useChat } from '../providers/chat-context';
import { ChatMessage } from '../types';
import { useAppContext } from '@/layout/providers/AppProvider';

Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/layout/Disclaimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { Container } from '@/components/Container/Container';
import { APP_NAME } from '@/utils/constants';
import { memo } from 'react';
import { useChat } from '../providers/ChatProvider';
import { useChat } from '../providers/chat-context';
import classes from './Disclaimer.module.scss';

export const Disclaimer = memo(function Disclaimer() {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/layout/FilesMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import { IconButton, OverflowMenu, OverflowMenuItem } from '@carbon/react';
import { Attachment } from '@carbon/react/icons';
import { MouseEventHandler } from 'react';
import { useChat } from '../providers/ChatProvider';
import { useChat } from '../providers/chat-context';
// import classes from './FilesMenu.module.scss';

interface Props {
Expand Down
10 changes: 5 additions & 5 deletions src/modules/chat/layout/InputBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ import { useForm } from 'react-hook-form';
import { mergeRefs } from 'react-merge-refs';
import { Attachment } from '../attachments/Attachment';
import { AttachmentsList } from '../attachments/AttachmentsList';
import {
SendMessageResult,
useChat,
useChatMessages,
} from '../providers/ChatProvider';
import { useFilesUpload } from '../providers/FilesUploadProvider';
import { FilesMenu } from './FilesMenu';
import classes from './InputBar.module.scss';
import { PromptSuggestions } from './PromptSuggestions';
import { ThreadSettings } from './ThreadSettings';
import { UserChatMessage } from '../types';
import { useAppContext } from '@/layout/providers/AppProvider';
import {
SendMessageResult,
useChat,
useChatMessages,
} from '../providers/chat-context';

interface Props {
showSuggestions?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/layout/PromptSuggestions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
useRef,
useState,
} from 'react';
import { useChat } from '../providers/ChatProvider';
import { useChat } from '../providers/chat-context';
import classes from './PromptSuggestions.module.scss';

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/layout/ThreadKnowledge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { useInfiniteQuery } from '@tanstack/react-query';
import clsx from 'clsx';
import pluralize from 'pluralize';
import { useId, useMemo } from 'react';
import { useChat } from '../providers/ChatProvider';
import { useChat } from '../providers/chat-context';
import { useFilesUpload } from '../providers/FilesUploadProvider';
import classes from './ThreadKnowledge.module.scss';
import { useAppContext } from '@/layout/providers/AppProvider';
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/layout/ThreadSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
import { AnimatePresence, motion } from 'framer-motion';
import { useMemo, useState } from 'react';
import { mergeRefs } from 'react-merge-refs';
import { useChat } from '../providers/ChatProvider';
import { useChat } from '../providers/chat-context';
import { useFilesUpload } from '../providers/FilesUploadProvider';
import { ThreadKnowledge } from './ThreadKnowledge';
import classes from './ThreadSettings.module.scss';
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/layout/ThreadTools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { ToolToggle } from '@/modules/assistants/tools/ToolToggle';
import { toolsEqual, toolIncluded } from '@/modules/tools/utils';
import { Assistant } from '@/modules/assistants/types';
import { useChat } from '../providers/ChatProvider';
import { useChat } from '../providers/chat-context';
import { EmptyList } from './EmptyList';
import classes from './ThreadTools.module.scss';
import { useAppContext } from '@/layout/providers/AppProvider';
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/message/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import clsx from 'clsx';
import { AnimatePresence, motion } from 'framer-motion';
import { useId } from 'react';
import { useRetry } from '../hooks/useRetry';
import { useChat } from '../providers/ChatProvider';
import { useChat } from '../providers/chat-context';
import { useMessageFeedback } from '../providers/MessageFeedbackProvider';
import { ChatMessage } from '../types';
import classes from './ActionBar.module.scss';
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { PlanWithSources } from '../assistant-plan/PlanWithSources';
import { AttachmentsList } from '../attachments/AttachmentsList';
import { getThreadAssistantName } from '../history/useGetThreadAssistant';
import { useAssistantModal } from '../providers/AssistantModalProvider';
import { useChat } from '../providers/ChatProvider';
import { useChat } from '../providers/chat-context';
import { MessageFeedbackProvider } from '../providers/MessageFeedbackProvider';
import { RunProvider } from '../providers/RunProvider';
import { readRunQuery } from '../queries';
Expand Down
2 changes: 0 additions & 2 deletions src/modules/chat/message/MessageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { ChatMessage } from '../types';
import { MarkdownContent } from './MarkdownContent';
import classes from './MessageContent.module.scss';
import { MessageLoading } from './MessageLoading';
import { useChat } from '../providers/ChatProvider';
import { Spinner } from '@/components/Spinner/Spinner';

export function MessageContent({ message }: { message: ChatMessage }) {
Expand Down Expand Up @@ -86,7 +85,6 @@ export function MessageContent({ message }: { message: ChatMessage }) {
}

function PendingThought({ plan }: { plan?: AssistantPlan }) {
const { assistant } = useChat();
const THROTTLE_WAIT = 2000;
const [thought, setThought] = useState(null);
const pendingThought = getLastCompletedStep(plan)?.thought;
Expand Down
Loading

0 comments on commit c931479

Please sign in to comment.