From 7d55a6d0e441bddaf9870c9adfa88f1f72c600a5 Mon Sep 17 00:00:00 2001 From: Dogtiti <499960698@qq.com> Date: Tue, 8 Oct 2024 21:31:01 +0800 Subject: [PATCH 01/12] feat: allow send image only --- app/components/chat.tsx | 7 +++++-- app/store/chat.ts | 22 ++++++++-------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 3d519dee7..77b48abee 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -115,11 +115,14 @@ import { getClientConfig } from "../config/client"; import { useAllModels } from "../utils/hooks"; import { MultimodalContent } from "../client/api"; -const localStorage = safeLocalStorage(); import { ClientApi } from "../client/api"; import { createTTSPlayer } from "../utils/audio"; import { MsEdgeTTS, OUTPUT_FORMAT } from "../utils/ms_edge_tts"; +import { isEmpty } from "lodash-es"; + +const localStorage = safeLocalStorage(); + const ttsPlayer = createTTSPlayer(); const Markdown = dynamic(async () => (await import("./markdown")).Markdown, { @@ -1015,7 +1018,7 @@ function _Chat() { }; const doSubmit = (userInput: string) => { - if (userInput.trim() === "") return; + if (userInput.trim() === "" && isEmpty(attachImages)) return; const matchCommand = chatCommands.match(userInput); if (matchCommand.matched) { setUserInput(""); diff --git a/app/store/chat.ts b/app/store/chat.ts index 968d8cb64..fc1fb23ba 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -337,22 +337,16 @@ export const useChatStore = createPersistStore( if (attachImages && attachImages.length > 0) { mContent = [ - { - type: "text", - text: userContent, - }, + ...(userContent + ? [{ type: "text" as const, text: userContent }] + : []), + ...attachImages.map((url) => ({ + type: "image_url" as const, + image_url: { url }, + })), ]; - mContent = mContent.concat( - attachImages.map((url) => { - return { - type: "image_url", - image_url: { - url: url, - }, - }; - }), - ); } + let userMessage: ChatMessage = createMessage({ role: "user", content: mContent, From 2eebfcf6fe873595a69ac0de805811fa7ed94f12 Mon Sep 17 00:00:00 2001 From: lloydzhou Date: Fri, 11 Oct 2024 11:29:22 +0800 Subject: [PATCH 02/12] client app tauri updater #2966 --- app/components/settings.tsx | 16 ++++++++++++---- app/global.d.ts | 7 +++++++ app/locales/cn.ts | 2 ++ app/locales/en.ts | 2 ++ app/store/update.ts | 2 ++ app/utils.ts | 23 +++++++++++++++++++++++ 6 files changed, 48 insertions(+), 4 deletions(-) diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 9f338718e..9ee919b8d 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -49,7 +49,7 @@ import Locale, { changeLang, getLang, } from "../locales"; -import { copyToClipboard } from "../utils"; +import { copyToClipboard, clientUpdate } from "../utils"; import Link from "next/link"; import { Anthropic, @@ -1357,9 +1357,17 @@ export function Settings() { {checkingUpdate ? ( ) : hasNewVersion ? ( - - {Locale.Settings.Update.GoToUpdate} - + clientConfig?.isApp ? ( + } + text={Locale.Settings.Update.GoToUpdate} + onClick={() => clientUpdate()} + /> + ) : ( + + {Locale.Settings.Update.GoToUpdate} + + ) ) : ( } diff --git a/app/global.d.ts b/app/global.d.ts index 8ee636bcd..897871fec 100644 --- a/app/global.d.ts +++ b/app/global.d.ts @@ -26,6 +26,13 @@ declare interface Window { isPermissionGranted(): Promise; sendNotification(options: string | Options): void; }; + updater: { + checkUpdate(): Promise; + installUpdate(): Promise; + onUpdaterEvent( + handler: (status: UpdateStatusResult) => void, + ): Promise; + }; http: { fetch( url: string, diff --git a/app/locales/cn.ts b/app/locales/cn.ts index e5bcca0ed..3086cc63e 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -205,6 +205,8 @@ const cn = { IsChecking: "正在检查更新...", FoundUpdate: (x: string) => `发现新版本:${x}`, GoToUpdate: "前往更新", + Success: "Update Succesfull.", + Failed: "Update Failed.", }, SendKey: "发送键", Theme: "主题", diff --git a/app/locales/en.ts b/app/locales/en.ts index 120457522..a025a522f 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -207,6 +207,8 @@ const en: LocaleType = { IsChecking: "Checking update...", FoundUpdate: (x: string) => `Found new version: ${x}`, GoToUpdate: "Update", + Success: "Update Succesfull.", + Failed: "Update Failed.", }, SendKey: "Send Key", Theme: "Theme", diff --git a/app/store/update.ts b/app/store/update.ts index e68fde369..327dc5e88 100644 --- a/app/store/update.ts +++ b/app/store/update.ts @@ -6,6 +6,7 @@ import { } from "../constant"; import { getClientConfig } from "../config/client"; import { createPersistStore } from "../utils/store"; +import { clientUpdate } from "../utils"; import ChatGptIcon from "../icons/chatgpt.png"; import Locale from "../locales"; import { ClientApi } from "../client/api"; @@ -119,6 +120,7 @@ export const useUpdateStore = createPersistStore( icon: `${ChatGptIcon.src}`, sound: "Default", }); + clientUpdate(); } } }); diff --git a/app/utils.ts b/app/utils.ts index 5d4501710..9e75ffc7f 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -386,3 +386,26 @@ export function getOperationId(operation: { `${operation.method.toUpperCase()}${operation.path.replaceAll("/", "_")}` ); } + +export function clientUpdate() { + // this a wild for updating client app + return window.__TAURI__?.updater + .checkUpdate() + .then((updateResult) => { + if (updateResult.shouldUpdate) { + window.__TAURI__?.updater + .installUpdate() + .then((result) => { + showToast(Locale.Settings.Update.Success); + }) + .catch((e) => { + console.error("[Install Update Error]", e); + showToast(Locale.Settings.Update.Failed); + }); + } + }) + .catch((e) => { + console.error("[Check Update Error]", e); + showToast(Locale.Settings.Update.Failed); + }); +} From bd9de4dc4db95a6d9aca4567d6147cb5b55b38ab Mon Sep 17 00:00:00 2001 From: lloydzhou Date: Fri, 11 Oct 2024 11:42:36 +0800 Subject: [PATCH 03/12] fix version compare --- app/components/settings.tsx | 4 ++-- app/utils.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 9ee919b8d..c5653543c 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -49,7 +49,7 @@ import Locale, { changeLang, getLang, } from "../locales"; -import { copyToClipboard, clientUpdate } from "../utils"; +import { copyToClipboard, clientUpdate, semverCompare } from "../utils"; import Link from "next/link"; import { Anthropic, @@ -585,7 +585,7 @@ export function Settings() { const [checkingUpdate, setCheckingUpdate] = useState(false); const currentVersion = updateStore.formatVersion(updateStore.version); const remoteId = updateStore.formatVersion(updateStore.remoteVersion); - const hasNewVersion = currentVersion !== remoteId; + const hasNewVersion = semverCompare(currentVersion, remoteId) === -1; const updateUrl = getClientConfig()?.isApp ? RELEASE_URL : UPDATE_URL; function checkUpdate(force = false) { diff --git a/app/utils.ts b/app/utils.ts index 9e75ffc7f..9e9e90f66 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -409,3 +409,14 @@ export function clientUpdate() { showToast(Locale.Settings.Update.Failed); }); } + +// https://gist.github.com/iwill/a83038623ba4fef6abb9efca87ae9ccb +export function semverCompare(a, b) { + if (a.startsWith(b + "-")) return -1; + if (b.startsWith(a + "-")) return 1; + return a.localeCompare(b, undefined, { + numeric: true, + sensitivity: "case", + caseFirst: "upper", + }); +} From a0d4a04192e2221f0ca969cab3236d4090a85955 Mon Sep 17 00:00:00 2001 From: lloydzhou Date: Fri, 11 Oct 2024 11:52:24 +0800 Subject: [PATCH 04/12] update --- app/locales/en.ts | 2 +- app/utils.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/locales/en.ts b/app/locales/en.ts index a025a522f..40471536f 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -207,7 +207,7 @@ const en: LocaleType = { IsChecking: "Checking update...", FoundUpdate: (x: string) => `Found new version: ${x}`, GoToUpdate: "Update", - Success: "Update Succesfull.", + Success: "Update Successful.", Failed: "Update Failed.", }, SendKey: "Send Key", diff --git a/app/utils.ts b/app/utils.ts index 9e9e90f66..d8fc46330 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -411,7 +411,7 @@ export function clientUpdate() { } // https://gist.github.com/iwill/a83038623ba4fef6abb9efca87ae9ccb -export function semverCompare(a, b) { +export function semverCompare(a: string, b: string) { if (a.startsWith(b + "-")) return -1; if (b.startsWith(a + "-")) return 1; return a.localeCompare(b, undefined, { From 819238acaf5114329168f2c95da74d747795daa1 Mon Sep 17 00:00:00 2001 From: Dogtiti <499960698@qq.com> Date: Fri, 11 Oct 2024 20:49:43 +0800 Subject: [PATCH 05/12] fix: i18n --- app/locales/cn.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/locales/cn.ts b/app/locales/cn.ts index 3086cc63e..1e0116ec9 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -205,8 +205,8 @@ const cn = { IsChecking: "正在检查更新...", FoundUpdate: (x: string) => `发现新版本:${x}`, GoToUpdate: "前往更新", - Success: "Update Succesfull.", - Failed: "Update Failed.", + Success: "更新成功!", + Failed: "更新失败", }, SendKey: "发送键", Theme: "主题", From 12e7caa20977d8fbee2d16ec3d33ae3d94472603 Mon Sep 17 00:00:00 2001 From: ccq18 <348578429@qq.com> Date: Mon, 14 Oct 2024 16:03:01 +0800 Subject: [PATCH 06/12] =?UTF-8?q?fix=20=E9=BB=98=E8=AE=A4=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E6=97=B6=E9=97=B4=E6=94=B9=E4=B8=BA3=E5=88=86?= =?UTF-8?q?=E9=92=9F=EF=BC=8C=E6=94=AF=E6=8C=81o1-mini?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/constant.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/constant.ts b/app/constant.ts index a06b8f050..856370511 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -95,7 +95,7 @@ export const UNFINISHED_INPUT = (id: string) => "unfinished-input-" + id; export const STORAGE_KEY = "chatgpt-next-web"; -export const REQUEST_TIMEOUT_MS = 60000; +export const REQUEST_TIMEOUT_MS = 180000; export const EXPORT_MESSAGE_CLASS_NAME = "export-markdown"; From 592f62005b474b78042a373cbfd7361f3de9b323 Mon Sep 17 00:00:00 2001 From: ccq18 <348578429@qq.com> Date: Mon, 14 Oct 2024 16:31:17 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E4=BB=85=E4=BF=AE=E6=94=B9o1=E7=9A=84?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=E4=B8=BA4=E5=88=86?= =?UTF-8?q?=E9=92=9F=EF=BC=8C=E5=87=8F=E5=B0=91o1=E7=B3=BB=E5=88=97?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E8=AF=B7=E6=B1=82=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/client/platforms/openai.ts | 2 +- app/constant.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts index a22633611..76bac59e8 100644 --- a/app/client/platforms/openai.ts +++ b/app/client/platforms/openai.ts @@ -352,7 +352,7 @@ export class ChatGPTApi implements LLMApi { // make a fetch request const requestTimeoutId = setTimeout( () => controller.abort(), - isDalle3 || isO1 ? REQUEST_TIMEOUT_MS * 2 : REQUEST_TIMEOUT_MS, // dalle3 using b64_json is slow. + isDalle3 || isO1 ? REQUEST_TIMEOUT_MS * 4 : REQUEST_TIMEOUT_MS, // dalle3 using b64_json is slow. ); const res = await fetch(chatPath, chatPayload); diff --git a/app/constant.ts b/app/constant.ts index 856370511..a06b8f050 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -95,7 +95,7 @@ export const UNFINISHED_INPUT = (id: string) => "unfinished-input-" + id; export const STORAGE_KEY = "chatgpt-next-web"; -export const REQUEST_TIMEOUT_MS = 180000; +export const REQUEST_TIMEOUT_MS = 60000; export const EXPORT_MESSAGE_CLASS_NAME = "export-markdown"; From 8c39a687b5d8bb44dfcc103ac69910d97220bea7 Mon Sep 17 00:00:00 2001 From: lloydzhou Date: Mon, 14 Oct 2024 16:53:46 +0800 Subject: [PATCH 08/12] update deploy_preview run target --- .github/workflows/deploy_preview.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 30d9b85b4..b98845243 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -3,9 +3,7 @@ name: VercelPreviewDeployment on: pull_request_target: types: - - opened - - synchronize - - reopened + - review_requested env: VERCEL_TEAM: ${{ secrets.VERCEL_TEAM }} From 103106bb9371748b3f1ab3f304846546297657cc Mon Sep 17 00:00:00 2001 From: lloydzhou Date: Mon, 14 Oct 2024 17:09:56 +0800 Subject: [PATCH 09/12] update test run target --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fc885b293..faf7205d9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,6 +7,8 @@ on: tags: - "!*" pull_request: + types: + - review_requested jobs: test: From 7f454cbcec0d5c735726808ccbe75ba897142a31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 10:49:46 +0000 Subject: [PATCH 10/12] Bump @types/jest from 29.5.12 to 29.5.13 Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 29.5.12 to 29.5.13. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) --- updated-dependencies: - dependency-name: "@types/jest" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index e43344534..803c0d1a4 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@tauri-apps/cli": "1.5.11", "@testing-library/jest-dom": "^6.4.8", "@testing-library/react": "^16.0.0", - "@types/jest": "^29.5.12", + "@types/jest": "^29.5.13", "@types/js-yaml": "4.0.9", "@types/lodash-es": "^4.17.12", "@types/node": "^20.11.30", diff --git a/yarn.lock b/yarn.lock index 0f6a29d6d..ef296924e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2263,10 +2263,10 @@ dependencies: "@types/istanbul-lib-report" "*" -"@types/jest@^29.5.12": - version "29.5.12" - resolved "https://registry.npmmirror.com/@types/jest/-/jest-29.5.12.tgz#7f7dc6eb4cf246d2474ed78744b05d06ce025544" - integrity sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw== +"@types/jest@^29.5.13": + version "29.5.13" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.13.tgz#8bc571659f401e6a719a7bf0dbcb8b78c71a8adc" + integrity sha512-wd+MVEZCHt23V0/L642O5APvspWply/rGY5BcW4SUETo2UzPU3Z26qr8jC2qxpimI2jjx9h7+2cj2FwIr01bXg== dependencies: expect "^29.0.0" pretty-format "^29.0.0" From 87d85c10c3b3dcd7a62e174dabb6338f005ce9b7 Mon Sep 17 00:00:00 2001 From: lloydzhou Date: Mon, 14 Oct 2024 21:48:36 +0800 Subject: [PATCH 11/12] update --- src-tauri/tauri.conf.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index cc137ee8a..56a5b46a9 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -99,7 +99,7 @@ "endpoints": [ "https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/releases/latest/download/latest.json" ], - "dialog": false, + "dialog": true, "windows": { "installMode": "passive" }, From 463fa743e987624ab357c4335de0b133ccfa8fd0 Mon Sep 17 00:00:00 2001 From: lloydzhou Date: Tue, 15 Oct 2024 16:10:44 +0800 Subject: [PATCH 12/12] update version --- src-tauri/tauri.conf.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 56a5b46a9..b2c3e04b0 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -9,7 +9,7 @@ }, "package": { "productName": "NextChat", - "version": "2.15.4" + "version": "2.15.5" }, "tauri": { "allowlist": {