From 6c1693b8f4121bd7b1368f505120d2971130535d Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Wed, 15 Nov 2023 22:33:50 -0800 Subject: [PATCH] Update first run message on Desktop app with API token setup instructions - Open Web app settings in the default browser via link click - Open Desktop app settings via link click --- src/interface/desktop/chat.html | 10 +++++++++- src/interface/desktop/main.js | 8 ++++++++ src/interface/desktop/preload.js | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/interface/desktop/chat.html b/src/interface/desktop/chat.html index a089939d..ebf93195 100644 --- a/src/interface/desktop/chat.html +++ b/src/interface/desktop/chat.html @@ -328,7 +328,15 @@ .then(data => { if (data.detail) { // If the server returns a 500 error with detail, render a setup hint. - renderMessage("Hi 👋🏾, to get started you have two options:
  1. Use OpenAI:
    1. Get your OpenAI API key
    2. Save it in the Khoj chat settings
    3. Click Configure on the Khoj settings page
  2. Enable offline chat:
    1. Go to the Khoj settings page and enable offline chat
", "khoj"); + first_run_message = `Hi 👋🏾, to get started: +
    +
  1. Generate an API token in the Khoj Web settings
  2. +
  3. Paste it into the API Key field in the Khoj Desktop settings
  4. +
` + .trim() + .replace(/(\r\n|\n|\r)/gm, ""); + + renderMessage(first_run_message, "khoj"); // Disable chat input field and update placeholder text document.getElementById("chat-input").setAttribute("disabled", "disabled"); diff --git a/src/interface/desktop/main.js b/src/interface/desktop/main.js index 9a42bc5f..eb355a5f 100644 --- a/src/interface/desktop/main.js +++ b/src/interface/desktop/main.js @@ -396,6 +396,14 @@ app.whenReady().then(() => { event.reply('update-state', arg); }); + ipcMain.on('navigate', (event, page) => { + win.loadFile(page); + }); + + ipcMain.on('navigateToWebApp', (event, page) => { + shell.openExternal(`${store.get('hostURL')}/${page}`); + }); + ipcMain.handle('getFiles', getFiles); ipcMain.handle('getFolders', getFolders); diff --git a/src/interface/desktop/preload.js b/src/interface/desktop/preload.js index eb5a6cc2..1d4c6ec0 100644 --- a/src/interface/desktop/preload.js +++ b/src/interface/desktop/preload.js @@ -57,3 +57,8 @@ contextBridge.exposeInMainWorld('tokenAPI', { contextBridge.exposeInMainWorld('appInfoAPI', { getInfo: (callback) => ipcRenderer.on('appInfo', callback) }) + +contextBridge.exposeInMainWorld('navigateAPI', { + navigateToSettings: () => ipcRenderer.send('navigate', 'config.html'), + navigateToWebSettings: () => ipcRenderer.send('navigateToWebApp', 'config'), +})