diff --git a/README.md b/README.md index 107a35d29..a50691950 100644 --- a/README.md +++ b/README.md @@ -76,31 +76,31 @@ Jan is an open-source ChatGPT alternative that runs 100% offline on your compute
jan.exe
Intel
M1/M2
jan.deb
jan.AppImage
diff --git a/core/src/node/helper/config.ts b/core/src/node/helper/config.ts
index 71e721578..06f2b03cd 100644
--- a/core/src/node/helper/config.ts
+++ b/core/src/node/helper/config.ts
@@ -4,13 +4,13 @@ import fs from 'fs'
import os from 'os'
import childProcess from 'child_process'
-// TODO: move this to core
const configurationFileName = 'settings.json'
// TODO: do no specify app name in framework module
const defaultJanDataFolder = join(os.homedir(), 'jan')
const defaultAppConfig: AppConfiguration = {
data_folder: defaultJanDataFolder,
+ quick_ask: false,
}
/**
diff --git a/core/src/types/config/appConfigEntity.ts b/core/src/types/config/appConfigEntity.ts
index 81ea0b30f..1402aeca1 100644
--- a/core/src/types/config/appConfigEntity.ts
+++ b/core/src/types/config/appConfigEntity.ts
@@ -1,3 +1,4 @@
export type AppConfiguration = {
data_folder: string
+ quick_ask: boolean
}
diff --git a/docs/plugins/changelog-plugin/fetchData.js b/docs/plugins/changelog-plugin/fetchData.js
index 351ab3932..a9b970b3a 100644
--- a/docs/plugins/changelog-plugin/fetchData.js
+++ b/docs/plugins/changelog-plugin/fetchData.js
@@ -1,5 +1,6 @@
const fs = require('fs');
const path = require('path');
+const fetch = require('node-fetch');
async function fetchData(siteConfig) {
const owner = siteConfig.organizationName;
@@ -70,6 +71,14 @@ async function fetchData(siteConfig) {
// Process the GitHub releases data here
for (const release of releases) {
const version = release.tag_name;
+
+ // Check if the changelog file already exists for the current version
+ const existingChangelogPath = path.join(outputDirectory, `changelog-${version}.mdx`);
+ if (fs.existsSync(existingChangelogPath)) {
+ console.log(`Changelog for version ${version} already exists. Skipping...`);
+ continue;
+ }
+
const releaseUrl = release.html_url;
const issueNumberMatch = release.body.match(/#(\d+)/);
const issueNumber = issueNumberMatch ? parseInt(issueNumberMatch[1], 10) : null;
@@ -94,4 +103,4 @@ async function fetchData(siteConfig) {
}
}
-module.exports = fetchData;
\ No newline at end of file
+module.exports = fetchData;
diff --git a/electron/main.ts b/electron/main.ts
index 78577ac68..70314b169 100644
--- a/electron/main.ts
+++ b/electron/main.ts
@@ -5,7 +5,7 @@ import { join } from 'path'
* Managers
**/
import { windowManager } from './managers/window'
-import { log } from '@janhq/core/node'
+import { getAppConfigurations, log } from '@janhq/core/node'
/**
* IPC Handlers
@@ -43,6 +43,12 @@ const gotTheLock = app.requestSingleInstanceLock()
app
.whenReady()
+ .then(() => {
+ if (!gotTheLock) {
+ app.quit()
+ throw new Error('Another instance of the app is already running')
+ }
+ })
.then(setupReactDevTool)
.then(setupCore)
.then(createUserSpace)
@@ -63,22 +69,20 @@ app
log(`Version: ${app.getVersion()}`)
})
.then(() => {
- if (!gotTheLock) {
- app.quit()
- } else {
- app.on('second-instance', (_event, _commandLine, _workingDirectory) => {
- // Someone tried to run a second instance, we should focus our window.
- windowManager.showMainWindow()
- })
- }
app.on('activate', () => {
if (!BrowserWindow.getAllWindows().length) {
createMainWindow()
+ } else {
+ windowManager.showMainWindow()
}
})
})
.then(() => cleanLogs())
+app.on('second-instance', (_event, _commandLine, _workingDirectory) => {
+ windowManager.showMainWindow()
+})
+
app.on('ready', () => {
registerGlobalShortcuts()
})
@@ -91,7 +95,15 @@ app.once('quit', () => {
cleanUpAndQuit()
})
+app.once('window-all-closed', () => {
+ // Feature Toggle for Quick Ask
+ if (getAppConfigurations().quick_ask) return
+ cleanUpAndQuit()
+})
+
function createQuickAskWindow() {
+ // Feature Toggle for Quick Ask
+ if (!getAppConfigurations().quick_ask) return
const startUrl = app.isPackaged ? `file://${quickAskPath}` : quickAskUrl
windowManager.createQuickAskWindow(preloadPath, startUrl)
}
@@ -103,6 +115,9 @@ function createMainWindow() {
function registerGlobalShortcuts() {
const ret = registerShortcut(quickAskHotKey, (selectedText: string) => {
+ // Feature Toggle for Quick Ask
+ if (!getAppConfigurations().quick_ask) return
+
if (!windowManager.isQuickAskWindowVisible()) {
windowManager.showQuickAskWindow()
windowManager.sendQuickAskSelectedText(selectedText)
diff --git a/electron/managers/mainWindowConfig.ts b/electron/managers/mainWindowConfig.ts
index 184fb1c86..4f1715a94 100644
--- a/electron/managers/mainWindowConfig.ts
+++ b/electron/managers/mainWindowConfig.ts
@@ -5,7 +5,7 @@ export const mainWindowConfig: Electron.BrowserWindowConstructorOptions = {
width: DEFAULT_WIDTH,
minWidth: DEFAULT_WIDTH,
height: DEFAULT_HEIGHT,
- skipTaskbar: true,
+ skipTaskbar: false,
show: true,
trafficLightPosition: {
x: 10,
diff --git a/electron/managers/tray.ts b/electron/managers/tray.ts
index 4e1c1a4ff..b81b1e556 100644
--- a/electron/managers/tray.ts
+++ b/electron/managers/tray.ts
@@ -1,11 +1,15 @@
import { join } from 'path'
import { Tray, app, Menu } from 'electron'
import { windowManager } from '../managers/window'
+import { getAppConfigurations } from '@janhq/core/node'
class TrayManager {
currentTray: Tray | undefined
createSystemTray = () => {
+ // Feature Toggle for Quick Ask
+ if (!getAppConfigurations().quick_ask) return
+
if (this.currentTray) {
return
}
@@ -13,20 +17,28 @@ class TrayManager {
const tray = new Tray(iconPath)
tray.setToolTip(app.getName())
- const contextMenu = Menu.buildFromTemplate([
- {
- label: 'Open Jan',
- type: 'normal',
- click: () => windowManager.showMainWindow(),
- },
- {
- label: 'Open Quick Ask',
- type: 'normal',
- click: () => windowManager.showQuickAskWindow(),
- },
- { label: 'Quit', type: 'normal', click: () => app.quit() },
- ])
- tray.setContextMenu(contextMenu)
+ tray.on('click', () => {
+ windowManager.showQuickAskWindow()
+ })
+
+ // Add context menu for windows only
+ if (process.platform === 'win32') {
+ const contextMenu = Menu.buildFromTemplate([
+ {
+ label: 'Open Jan',
+ type: 'normal',
+ click: () => windowManager.showMainWindow(),
+ },
+ {
+ label: 'Open Quick Ask',
+ type: 'normal',
+ click: () => windowManager.showQuickAskWindow(),
+ },
+ { label: 'Quit', type: 'normal', click: () => app.quit() },
+ ])
+
+ tray.setContextMenu(contextMenu)
+ }
this.currentTray = tray
}
diff --git a/electron/managers/window.ts b/electron/managers/window.ts
index eed80c37c..da8dd4b17 100644
--- a/electron/managers/window.ts
+++ b/electron/managers/window.ts
@@ -2,6 +2,7 @@ import { BrowserWindow, app, shell } from 'electron'
import { quickAskWindowConfig } from './quickAskWindowConfig'
import { AppEvent } from '@janhq/core'
import { mainWindowConfig } from './mainWindowConfig'
+import { getAppConfigurations } from '@janhq/core/node'
/**
* Manages the current window instance.
@@ -43,6 +44,9 @@ class WindowManager {
})
windowManager.mainWindow?.on('close', function (evt) {
+ // Feature Toggle for Quick Ask
+ if (!getAppConfigurations().quick_ask) return
+
if (!isAppQuitting) {
evt.preventDefault()
windowManager.hideMainWindow()
@@ -73,15 +77,11 @@ class WindowManager {
hideMainWindow(): void {
this.mainWindow?.hide()
this._mainWindowVisible = false
- // Only macos
- if (process.platform === 'darwin') app.dock.hide()
}
showMainWindow(): void {
this.mainWindow?.show()
this._mainWindowVisible = true
- // Only macos
- if (process.platform === 'darwin') app.dock.show()
}
hideQuickAskWindow(): void {
diff --git a/web/containers/Providers/DataLoader.tsx b/web/containers/Providers/DataLoader.tsx
index bc1461d5b..7d38a29d6 100644
--- a/web/containers/Providers/DataLoader.tsx
+++ b/web/containers/Providers/DataLoader.tsx
@@ -10,7 +10,10 @@ import useGetSystemResources from '@/hooks/useGetSystemResources'
import useModels from '@/hooks/useModels'
import useThreads from '@/hooks/useThreads'
-import { janDataFolderPathAtom } from '@/helpers/atoms/AppConfig.atom'
+import {
+ janDataFolderPathAtom,
+ quickAskEnabledAtom,
+} from '@/helpers/atoms/AppConfig.atom'
type Props = {
children: ReactNode
@@ -18,6 +21,7 @@ type Props = {
const DataLoader: React.FC+
Enable Vulkan with AMD GPU/APU and Intel Arc GPU for better model performance (reload needed).
@@ -426,6 +437,36 @@ const Advanced = () => { /> + {experimentalEnabled && ( ++ Enable Quick Ask to be triggered via the default hotkey{' '} +