From 0350e1f96177967332cecd98382207b2f5131b0c Mon Sep 17 00:00:00 2001 From: phan Date: Wed, 8 May 2024 03:39:47 -0400 Subject: [PATCH] Starting another app instance restore the current instance from tray. --- src/main/index.ts | 7 ++++++- src/renderer/src/app/settings/settings_chat.tsx | 4 ++-- src/renderer/src/lib/provider/openai_compat.ts | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index 34a3a74..c8279c0 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -77,7 +77,12 @@ app.whenReady().then(async () => { app.on("second-instance", () => { // Someone tried to run a second instance, we should focus our window. if (window) { - if (window.isMinimized()) window.restore(); + if (window.isMinimized()) { + window.restore(); + } + if (!window.isVisible()) { + window.show(); + } window.focus(); } }); diff --git a/src/renderer/src/app/settings/settings_chat.tsx b/src/renderer/src/app/settings/settings_chat.tsx index a4a4ce7..e22eaf4 100644 --- a/src/renderer/src/app/settings/settings_chat.tsx +++ b/src/renderer/src/app/settings/settings_chat.tsx @@ -141,7 +141,7 @@ export default function SettingsChat() { {selectedProvider === ProviderE.OPENAI_COMPAT ? ( - + ) : ( - + )} diff --git a/src/renderer/src/lib/provider/openai_compat.ts b/src/renderer/src/lib/provider/openai_compat.ts index 7aaa9c4..af8b377 100644 --- a/src/renderer/src/lib/provider/openai_compat.ts +++ b/src/renderer/src/lib/provider/openai_compat.ts @@ -1,5 +1,6 @@ import { Provider, ProviderConfig, ProviderE, ProviderMessage } from "@/lib/provider/provider"; import { Result } from "@shared/types"; +import { joinPaths } from "@tanstack/router"; import { XFetchConfig } from "src/main/lib/xfetch"; import { v4 } from "uuid"; @@ -53,7 +54,9 @@ async function getChatCompletion( key = config.apiKey; } - const url = config.url; + const localhostReplacedURL = config.url.replace("localhost", "127.0.0.1"); + const url = joinPaths([localhostReplacedURL, "/chat/completions"]); + const headers = { Authorization: `Bearer ${key}` };