Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Commit

Permalink
[web] improve performance (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxijonson committed Jul 16, 2023
1 parent c004e47 commit 233a16c
Show file tree
Hide file tree
Showing 140 changed files with 2,967 additions and 1,567 deletions.
1,418 changes: 1,186 additions & 232 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"packages/*"
],
"devDependencies": {
"lerna": "^7.0.2"
"lerna": "^7.0.2",
"typescript": "^5.1.6"
},
"dependencies": {
"immer": "^10.0.2"
Expand Down
48 changes: 24 additions & 24 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@
"dist"
],
"dependencies": {
"@emotion/react": "^11.10.6",
"@mantine/core": "^6.0.14",
"@mantine/dropzone": "6.0.14",
"@mantine/form": "^6.0.14",
"@mantine/hooks": "^6.0.14",
"@mantine/modals": "^6.0.14",
"@mantine/notifications": "^6.0.14",
"@mantine/prism": "^6.0.14",
"@mantine/tiptap": "^6.0.14",
"@tabler/icons-react": "^2.22.0",
"@emotion/react": "^11.11.1",
"@mantine/core": "^6.0.16",
"@mantine/dropzone": "6.0.16",
"@mantine/form": "^6.0.16",
"@mantine/hooks": "^6.0.16",
"@mantine/modals": "^6.0.16",
"@mantine/notifications": "^6.0.16",
"@mantine/prism": "^6.0.16",
"@mantine/tiptap": "^6.0.16",
"@tabler/icons-react": "^2.25.0",
"@tiptap/extension-code-block-lowlight": "^2.0.3",
"@tiptap/extension-link": "^2.0.3",
"@tiptap/pm": "^2.0.3",
Expand All @@ -70,27 +70,27 @@
"lowlight": "^2.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.8.0",
"react-router-dom": "^6.13.0",
"react-icons": "^4.10.1",
"react-router-dom": "^6.14.1",
"uuid": "^9.0.0",
"zod": "^3.21.4",
"zustand": "^4.3.9"
},
"devDependencies": {
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"@vitejs/plugin-react-swc": "^3.0.0",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-prettier": "^4.2.1",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react-swc": "^3.3.2",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.1",
"prettier": "^2.8.4",
"typescript": "^4.9.3",
"vite": "^4.0.0",
"eslint-plugin-react-refresh": "^0.4.3",
"prettier": "^3.0.0",
"typescript": "^5.1.6",
"vite": "^4.4.4",
"vite-plugin-eslint": "^1.8.1",
"vite-plugin-pwa": "^0.16.4"
}
Expand Down
5 changes: 4 additions & 1 deletion packages/web/src/changelog/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { ReactNode } from "react";
import v4_4_0 from "./v4-4-0";
import v4_4_1 from "./v4-4-1";

export type ChangelogEntrySection = {
label: ReactNode;
items: ReactNode[];
description?: ReactNode;
};

export type ChangelogEntry = {
version: string;
date: Date;
sections: ChangelogEntrySection[];
description?: ReactNode;
};

// First entry is the latest version
export const changelog = [v4_4_0];
export const changelog = [v4_4_1, v4_4_0];
21 changes: 21 additions & 0 deletions packages/web/src/changelog/v4-4-1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ChangelogEntry } from ".";
import { CHANGELOG_SECTION } from "../config/constants";

const v4_4_1: ChangelogEntry = {
version: "4.4.1 - Performance Update",
date: new Date("july 15 2023"),
description:
"Although performance was not an issue before, I saw many easy opportunities to improve it. This update contains many small improvements that should make the app feel more responsive and less resource intensive.",
sections: [
{
label: CHANGELOG_SECTION.IMPROVEMENTS,
items: [
"Further improved state management",
"Significantly reduced bundle size by separating dependencies from the main bundle into separate chunks. They will only be loaded when needed.",
"Updated all project dependencies",
],
},
],
};

export default v4_4_1;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Anchor, Stack, Text } from "@mantine/core";
import { DISCORD_SERVER_INVITE } from "../config/constants";
import { DISCORD_SERVER_INVITE } from "../../config/constants";

const About = () => {
return (
Expand Down
32 changes: 32 additions & 0 deletions packages/web/src/components/About/AboutButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Modal, Text } from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { FaRegQuestionCircle } from "react-icons/fa";
import TippedActionIcon from "../common/TippedActionIcon";
import About from "./About";

const AboutButton = () => {
const [showAbout, { open: openAbout, close: closeAbout }] = useDisclosure();

return (
<>
<TippedActionIcon
tip="About this project"
onClick={openAbout}
size="xs"
>
<FaRegQuestionCircle />
</TippedActionIcon>
<Modal
opened={showAbout}
onClose={closeAbout}
size="lg"
centered
title={<Text weight="bold">About GPT Turbo Web</Text>}
>
<About />
</Modal>
</>
);
};

export default AboutButton;
36 changes: 34 additions & 2 deletions packages/web/src/components/AddConversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import {
Card,
createStyles,
} from "@mantine/core";
import AddConversationForm from "./AddConversationForm";
import React from "react";
import { ConversationFormValues } from "../contexts/ConversationFormContext";
import { addConversation } from "../store/actions/conversations/addConversation";
import { setActiveConversation } from "../store/actions/conversations/setActiveConversation";
import { addPersistedConversationId } from "../store/actions/persistence/addPersistedConversationId";
import ConversationForm from "./forms/ConversationForm/ConversationForm";
import { useGetFunction } from "../store/hooks/callableFunctions/useGetFunction";

const useStyles = createStyles((theme) => ({
card: {
Expand All @@ -23,6 +29,32 @@ const useStyles = createStyles((theme) => ({

const AddConversation = () => {
const { classes } = useStyles();
const getFunction = useGetFunction();

const onSubmit = React.useCallback(
({
save,
headers,
proxy,
functionIds,
...values
}: ConversationFormValues) => {
const newConversation = addConversation(values, { headers, proxy });
setActiveConversation(newConversation.id, true);

for (const functionId of functionIds) {
const callableFunction = getFunction(functionId);
if (callableFunction) {
newConversation.addFunction(callableFunction);
}
}

if (save) {
addPersistedConversationId(newConversation.id);
}
},
[getFunction]
);

return (
<Container h="100%" p={0} m={0} fluid>
Expand All @@ -38,7 +70,7 @@ const AddConversation = () => {
<Title order={4} align="center">
New Conversation
</Title>
<AddConversationForm />
<ConversationForm onSubmit={onSubmit} hideAppSettings />
</Stack>
</Card>
</Center>
Expand Down
38 changes: 0 additions & 38 deletions packages/web/src/components/AddConversationForm.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
useMantineColorScheme,
} from "@mantine/core";
import AppStorageUsage from "./AppStorageUsage";
import { useAppStore } from "../store";
import { toggleShowUsage } from "../store/actions/appSettings/toggleShowUsage";
import { useAppStore } from "../../store";
import { toggleShowUsage } from "../../store/actions/appSettings/toggleShowUsage";
import AppSettingsDangerZone from "./AppSettingsDangerZone";

const AppSettings = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Group, SimpleGrid, Stack, Text } from "@mantine/core";
import { removeAllCallableFunctions } from "../store/actions/callableFunctions/removeAllCallableFunctions";
import { removeAllConversations } from "../store/actions/conversations/removeAllConversations";
import InlineConfirmButton from "./InlineConfirmButton";
import { removeAllCallableFunctions } from "../../store/actions/callableFunctions/removeAllCallableFunctions";
import { removeAllConversations } from "../../store/actions/conversations/removeAllConversations";
import InlineConfirmButton from "../common/InlineConfirmButton";
import React from "react";
import { resetCallableFunctionWarnings } from "../store/actions/callableFunctions/resetCallableFunctionWarnings";
import { resetDefaultSettings } from "../store/actions/defaultConversationSettings/resetDefaultSettings";
import { removeAllSavedContexts } from "../store/actions/savedContexts/removeAllSavedContexts";
import { removeAllSavedPrompts } from "../store/actions/savedPrompts/removeAllSavedPrompts";
import { resetCallableFunctionWarnings } from "../../store/actions/callableFunctions/resetCallableFunctionWarnings";
import { resetDefaultSettings } from "../../store/actions/defaultConversationSettings/resetDefaultSettings";
import { removeAllSavedContexts } from "../../store/actions/savedContexts/removeAllSavedContexts";
import { removeAllSavedPrompts } from "../../store/actions/savedPrompts/removeAllSavedPrompts";

const AppSettingsDangerZone = () => {
const actions = React.useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
useMantineTheme,
} from "@mantine/core";
import React from "react";
import { STORAGE_PERSISTENCE_KEY } from "../config/constants";
import { STORAGE_PERSISTENCE_KEY } from "../../config/constants";

interface StorageUsage {
label: string;
Expand Down
Loading

0 comments on commit 233a16c

Please sign in to comment.