mirror of
https://github.com/open-webui/desktop.git
synced 2026-07-01 20:54:03 -04:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0931b46d66 | |||
| 601137c5de | |||
| a097a83c46 | |||
| f8c20275cd | |||
| fa64bc02b5 | |||
| 20f0aaf40c | |||
| c64e946b38 | |||
| 1902f791cb | |||
| c2f128aec0 | |||
| 64c399738e | |||
| 842c1481f6 | |||
| e7eef2da86 | |||
| aab2a687cc | |||
| 9e204e78b7 |
@@ -263,7 +263,10 @@ jobs:
|
||||
const yaml = require('js-yaml');
|
||||
const x64 = yaml.load(fs.readFileSync('$X64_YML', 'utf8'));
|
||||
const arm = yaml.load(fs.readFileSync('$ARM_YML', 'utf8'));
|
||||
x64.files = [...(x64.files || []), ...(arm.files || [])];
|
||||
const all = [...(x64.files || []), ...(arm.files || [])];
|
||||
const map = new Map();
|
||||
for (const f of all) map.set(f.url, f);
|
||||
x64.files = [...map.values()];
|
||||
const out = yaml.dump(x64, { lineWidth: -1 });
|
||||
fs.writeFileSync('$X64_YML', out);
|
||||
console.log(out);
|
||||
@@ -277,7 +280,8 @@ jobs:
|
||||
- name: Merge Linux latest-linux.yml (x64 + arm64)
|
||||
run: |
|
||||
X64_YML="ubuntu-latest-x64/latest-linux.yml"
|
||||
ARM_YML="ubuntu-24.04-arm-arm64/latest-linux.yml"
|
||||
# electron-builder names the arm64 Linux manifest "latest-linux-arm64.yml"
|
||||
ARM_YML="ubuntu-24.04-arm-arm64/latest-linux-arm64.yml"
|
||||
|
||||
if [ -f "$X64_YML" ] && [ -f "$ARM_YML" ]; then
|
||||
echo "Merging latest-linux.yml from both architectures"
|
||||
@@ -286,7 +290,10 @@ jobs:
|
||||
const yaml = require('js-yaml');
|
||||
const x64 = yaml.load(fs.readFileSync('$X64_YML', 'utf8'));
|
||||
const arm = yaml.load(fs.readFileSync('$ARM_YML', 'utf8'));
|
||||
x64.files = [...(x64.files || []), ...(arm.files || [])];
|
||||
const all = [...(x64.files || []), ...(arm.files || [])];
|
||||
const map = new Map();
|
||||
for (const f of all) map.set(f.url, f);
|
||||
x64.files = [...map.values()];
|
||||
const out = yaml.dump(x64, { lineWidth: -1 });
|
||||
fs.writeFileSync('$X64_YML', out);
|
||||
console.log(out);
|
||||
@@ -294,7 +301,7 @@ jobs:
|
||||
rm -f "$ARM_YML"
|
||||
else
|
||||
echo "Skipping merge — need both $X64_YML and $ARM_YML"
|
||||
ls -la ubuntu-*-*/latest-linux.yml 2>/dev/null || true
|
||||
ls -la ubuntu-*-*/latest-linux*.yml 2>/dev/null || true
|
||||
fi
|
||||
|
||||
- name: Merge Windows latest.yml (x64 + arm64)
|
||||
@@ -309,7 +316,10 @@ jobs:
|
||||
const yaml = require('js-yaml');
|
||||
const x64 = yaml.load(fs.readFileSync('$X64_YML', 'utf8'));
|
||||
const arm = yaml.load(fs.readFileSync('$ARM_YML', 'utf8'));
|
||||
x64.files = [...(x64.files || []), ...(arm.files || [])];
|
||||
const all = [...(x64.files || []), ...(arm.files || [])];
|
||||
const map = new Map();
|
||||
for (const f of all) map.set(f.url, f);
|
||||
x64.files = [...map.values()];
|
||||
const out = yaml.dump(x64, { lineWidth: -1 });
|
||||
fs.writeFileSync('$X64_YML', out);
|
||||
console.log(out);
|
||||
@@ -320,6 +330,72 @@ jobs:
|
||||
ls -la windows-*-*/latest.yml 2>/dev/null || true
|
||||
fi
|
||||
|
||||
- name: Reconcile update manifest hashes
|
||||
run: |
|
||||
# Recompute SHA512 from actual artifact files to ensure manifests
|
||||
# match the real binaries (fixes signed/unsigned hash mismatches)
|
||||
node -e "
|
||||
const fs = require('fs');
|
||||
const crypto = require('crypto');
|
||||
const yaml = require('js-yaml');
|
||||
const path = require('path');
|
||||
|
||||
const manifests = [
|
||||
{ prefix: 'macos-latest-', file: 'latest-mac.yml' },
|
||||
{ prefix: 'ubuntu-', file: 'latest-linux.yml' },
|
||||
{ prefix: 'windows-', file: 'latest.yml' },
|
||||
];
|
||||
|
||||
const allDirs = fs.readdirSync('.').filter(d => {
|
||||
try { return fs.statSync(d).isDirectory(); } catch { return false; }
|
||||
});
|
||||
|
||||
for (const { prefix, file } of manifests) {
|
||||
const dirs = allDirs.filter(d => d.startsWith(prefix));
|
||||
let ymlPath = null;
|
||||
for (const dir of dirs) {
|
||||
const p = path.join(dir, file);
|
||||
if (fs.existsSync(p)) { ymlPath = p; break; }
|
||||
}
|
||||
if (!ymlPath) { console.log('No ' + file + ' found, skipping'); continue; }
|
||||
|
||||
const manifest = yaml.load(fs.readFileSync(ymlPath, 'utf8'));
|
||||
let fixed = 0;
|
||||
|
||||
for (const entry of manifest.files) {
|
||||
for (const dir of dirs) {
|
||||
const filePath = path.join(dir, entry.url);
|
||||
if (fs.existsSync(filePath)) {
|
||||
const buf = fs.readFileSync(filePath);
|
||||
const hash = crypto.createHash('sha512').update(buf).digest('base64');
|
||||
if (hash !== entry.sha512) {
|
||||
console.log('[' + file + '] Fix: ' + entry.url);
|
||||
entry.sha512 = hash;
|
||||
entry.size = buf.length;
|
||||
fixed++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (manifest.path) {
|
||||
for (const dir of dirs) {
|
||||
const filePath = path.join(dir, manifest.path);
|
||||
if (fs.existsSync(filePath)) {
|
||||
const buf = fs.readFileSync(filePath);
|
||||
manifest.sha512 = crypto.createHash('sha512').update(buf).digest('base64');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const out = yaml.dump(manifest, { lineWidth: -1 });
|
||||
fs.writeFileSync(ymlPath, out);
|
||||
console.log('[' + file + '] ' + (fixed ? 'Fixed ' + fixed + ' entries' : 'All hashes OK'));
|
||||
}
|
||||
"
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
env:
|
||||
|
||||
@@ -5,6 +5,39 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.0.20] - 2026-05-07
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Blank Webview on Linux.** Replaced the `--in-process-gpu` Chromium flag with SwiftShader software rendering (`--use-gl=angle --use-angle=swiftshader`). The in-process GPU flag broke `<webview>` guest compositing entirely, leaving connection views blank on all Linux configurations. SwiftShader keeps the GPU process out-of-process (required for webview compositing) while avoiding driver-level crashes (#178).
|
||||
|
||||
## [0.0.19] - 2026-05-06
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Spotlight Pulls to First Desktop on macOS.** Spotlight no longer switches Spaces when triggered from a non-primary desktop. The window is now visible on all workspaces, and `app.focus({ steal: true })` — which activated the entire app and caused the Space switch — has been replaced with targeted window-level focus (#179).
|
||||
- **Gray Screen When Connecting to Server on Linux.** Replaced the `--disable-gpu` Chromium flag with `--in-process-gpu`, which keeps the display compositor alive so `<webview>` guest surfaces actually paint instead of showing a gray rectangle. The previous flag fixed GPU process crashes but broke webview rendering on Debian and Ubuntu (#178).
|
||||
- **Open Terminal Fails Silently Without Python.** Open Terminal now automatically installs Python when it's missing instead of throwing an opaque error. Progress status is surfaced in the UI during installation.
|
||||
- **Corrupt Auto-Update Manifests.** Fixed the release workflow to deduplicate artifact entries during manifest merging, preventing SHA512 checksum mismatches that caused updates to fail silently.
|
||||
|
||||
## [0.0.18] - 2026-05-05
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Downloaded Models Not Recognized by llama.cpp.** Models downloaded from Hugging Face are now stored directly under the `models/` directory instead of a nested `models/huggingface/` subdirectory, so llama-server's model scanner discovers them without manual symlinks. Existing models in the old location are automatically migrated on startup (#177).
|
||||
|
||||
## [0.0.17] - 2026-05-03
|
||||
|
||||
### Added
|
||||
|
||||
- **Webview Context Menu.** Right-clicking inside the webview now shows a native context menu with Cut, Copy, Paste, Undo/Redo, spell-check suggestions, and "Open Link in Browser" — enabling system autofill and password manager integration on login pages (#161).
|
||||
|
||||
### Changed
|
||||
|
||||
- **Windows OpenSSL Compatibility.** The bundled Python's directory is now prepended to `PATH` on Windows so its own OpenSSL DLLs are loaded before any conflicting system-wide installations (Git for Windows, Anaconda, Strawberry Perl, etc.), preventing the `OPENSSL_Uplink: no OPENSSL_Applink` crash on startup (#167).
|
||||
- **Links Open in Default Browser on Windows.** Added `allowpopups` to the webview so that `target="_blank"` link clicks correctly propagate to the main process handler and open in the default browser instead of being silently blocked (#165, #170).
|
||||
- **Linux System Requirements.** Documentation now specifies glibc 2.28+ as a minimum requirement for Linux installations.
|
||||
|
||||
## [0.0.16] - 2026-05-02
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -54,7 +54,7 @@ Use both at the same time.
|
||||
|--|-------------|-------------|
|
||||
| **Disk** | 5 GB+ | ~500 MB |
|
||||
| **RAM** | 16 GB+ | 4 GB |
|
||||
| **OS** | macOS 12+, Windows 10+, modern Linux | Same |
|
||||
| **OS** | macOS 12+, Windows 10+, modern Linux (glibc 2.28+) | Same |
|
||||
|
||||
> [!NOTE]
|
||||
> Local models need serious RAM (7B ≈ 8 GB, 13B ≈ 16 GB). Lighter machine? Connect to a remote server instead.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "open-webui",
|
||||
"version": "0.0.16",
|
||||
"version": "0.0.20",
|
||||
"license": "AGPL-3.0",
|
||||
"description": "Open WebUI Desktop",
|
||||
"main": "./out/main/index.js",
|
||||
|
||||
+220
-110
@@ -106,14 +106,25 @@ if (process.platform === 'linux') {
|
||||
// to work (the portal is enabled by default in Chromium 134+ / Electron 33+).
|
||||
app.commandLine.appendSwitch('ozone-platform-hint', 'auto')
|
||||
|
||||
// Disable GPU acceleration entirely on Linux. This prevents the GPU
|
||||
// process from spawning, which avoids shared-memory allocation failures
|
||||
// in /dev/shm or /tmp that crash the renderer on Ubuntu 24.04+, certain
|
||||
// Wayland compositors, and AppArmor-restricted environments. The lighter
|
||||
// --disable-gpu-compositing flag is insufficient because the GPU process
|
||||
// still starts and attempts shared-memory IPC. Users confirmed that
|
||||
// --disable-gpu resolves both the crash and grey/blank screen (#119, #157).
|
||||
app.commandLine.appendSwitch('disable-gpu')
|
||||
// Force software GL rendering via SwiftShader. The out-of-process GPU
|
||||
// crashes on Ubuntu 24.04+, certain Wayland compositors, and AppArmor-
|
||||
// restricted environments due to shared-memory allocation failures in
|
||||
// /dev/shm or /tmp (#119, #157).
|
||||
//
|
||||
// --disable-gpu kills the display compositor so <webview> guest surfaces
|
||||
// are never painted (#178). --in-process-gpu breaks <webview> guest
|
||||
// compositing entirely (blank webviews on all Linux).
|
||||
//
|
||||
// SwiftShader keeps the GPU process out-of-process (required for
|
||||
// <webview> compositing) while using software rendering to avoid
|
||||
// driver-level crashes.
|
||||
app.commandLine.appendSwitch('use-gl', 'angle')
|
||||
app.commandLine.appendSwitch('use-angle', 'swiftshader')
|
||||
|
||||
// Disable the GPU sandbox — the sandbox setup triggers shared-memory
|
||||
// allocation failures in /dev/shm. The browser process is already
|
||||
// un-sandboxed (--no-sandbox above).
|
||||
app.commandLine.appendSwitch('disable-gpu-sandbox')
|
||||
}
|
||||
|
||||
// ─── GPU Crash Recovery ─────────────────────────────────
|
||||
@@ -295,6 +306,9 @@ function createSpotlightWindow(): BrowserWindow {
|
||||
hasShadow: false,
|
||||
show: false,
|
||||
focusable: true,
|
||||
// Ensure the window appears on whichever Space/desktop the user is
|
||||
// currently on, rather than pulling them back to the primary Space.
|
||||
visibleOnAllWorkspaces: true,
|
||||
icon: path.join(__dirname, 'assets/icon.png'),
|
||||
webPreferences: {
|
||||
preload: join(__dirname, '../preload/spotlight-preload.js'),
|
||||
@@ -331,8 +345,12 @@ function createSpotlightWindow(): BrowserWindow {
|
||||
}
|
||||
|
||||
function showAndFocusSpotlight(win: BrowserWindow, initialQuery?: string): void {
|
||||
// On macOS, avoid `app.focus({ steal: true })` — it activates the whole
|
||||
// application and causes the window manager to switch back to whichever
|
||||
// Space the app was originally launched on (#179). Instead, ensure the
|
||||
// window is visible on all workspaces and focus it directly.
|
||||
if (process.platform === 'darwin') {
|
||||
app.focus({ steal: true })
|
||||
win.setVisibleOnAllWorkspaces(true, { skipTransformProcessType: true })
|
||||
}
|
||||
|
||||
// Reposition fullscreen window to the active display
|
||||
@@ -488,8 +506,8 @@ async function toggleVoiceInput(): Promise<void> {
|
||||
|
||||
// Pre-flight: check a connection is configured
|
||||
try {
|
||||
const config = await getConfig()
|
||||
if (!config.defaultConnectionId || config.connections.length === 0) {
|
||||
const conn = await getDefaultConnection()
|
||||
if (!conn) {
|
||||
log.warn('Voice input: no connection configured')
|
||||
new Notification({
|
||||
title: 'Voice Input',
|
||||
@@ -497,15 +515,6 @@ async function toggleVoiceInput(): Promise<void> {
|
||||
}).show()
|
||||
return
|
||||
}
|
||||
const conn = config.connections.find((c) => c.id === config.defaultConnectionId)
|
||||
if (!conn) {
|
||||
log.warn('Voice input: default connection not found')
|
||||
new Notification({
|
||||
title: 'Voice Input',
|
||||
body: 'Default connection not found. Check your connection settings.'
|
||||
}).show()
|
||||
return
|
||||
}
|
||||
} catch (err: any) {
|
||||
log.warn('Voice input: config check failed:', err)
|
||||
}
|
||||
@@ -535,8 +544,8 @@ async function toggleVoiceInput(): Promise<void> {
|
||||
async function toggleCall(): Promise<void> {
|
||||
// Pre-flight: check a connection is configured
|
||||
try {
|
||||
const config = await getConfig()
|
||||
if (!config.defaultConnectionId || config.connections.length === 0) {
|
||||
const conn = await getDefaultConnection()
|
||||
if (!conn) {
|
||||
log.warn('Call: no connection configured')
|
||||
new Notification({
|
||||
title: 'Call',
|
||||
@@ -544,24 +553,8 @@ async function toggleCall(): Promise<void> {
|
||||
}).show()
|
||||
return
|
||||
}
|
||||
const conn = config.connections.find((c) => c.id === config.defaultConnectionId)
|
||||
if (!conn) {
|
||||
log.warn('Call: default connection not found')
|
||||
new Notification({
|
||||
title: 'Call',
|
||||
body: 'Default connection not found. Check your connection settings.'
|
||||
}).show()
|
||||
return
|
||||
}
|
||||
|
||||
let url = conn.url
|
||||
if (conn.type === 'local' && SERVER_URL) {
|
||||
url = SERVER_URL
|
||||
}
|
||||
if (url.startsWith('http://0.0.0.0')) {
|
||||
url = url.replace('http://0.0.0.0', 'http://localhost')
|
||||
}
|
||||
|
||||
const url = resolveConnectionUrl(conn)
|
||||
sendToRenderer('call', { connectionId: conn.id, url })
|
||||
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
@@ -777,7 +770,8 @@ function createContentWindow(url: string, connectionId: string): BrowserWindow {
|
||||
const updateTray = () => {
|
||||
if (!tray || !CONFIG) return
|
||||
|
||||
const connectionItems = (CONFIG.connections || []).map((conn) => ({
|
||||
// Remote connections from config
|
||||
const remoteItems = (CONFIG.connections || []).map((conn) => ({
|
||||
label: `${conn.id === CONFIG.defaultConnectionId ? '★ ' : ''}${conn.name}`,
|
||||
sublabel: conn.url,
|
||||
click: async () => {
|
||||
@@ -786,6 +780,20 @@ const updateTray = () => {
|
||||
}
|
||||
}))
|
||||
|
||||
// Virtual local connection (when package is installed)
|
||||
const localItem = isPackageInstalled('open-webui')
|
||||
? [{
|
||||
label: `${CONFIG.defaultConnectionId === 'local' ? '★ ' : ''}Open WebUI (Local)`,
|
||||
sublabel: SERVER_URL || `http://127.0.0.1:${CONFIG.localServer?.port ?? 8080}`,
|
||||
click: async () => {
|
||||
const result = await connectTo(buildLocalConnection())
|
||||
if (result) sendToRenderer('connection:open', result)
|
||||
}
|
||||
}]
|
||||
: []
|
||||
|
||||
const allItems = [...localItem, ...remoteItems]
|
||||
|
||||
const trayMenuTemplate = [
|
||||
{
|
||||
label: 'Show Open WebUI',
|
||||
@@ -795,10 +803,10 @@ const updateTray = () => {
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
...(connectionItems.length > 0
|
||||
...(allItems.length > 0
|
||||
? [
|
||||
{ label: 'Connections', enabled: false },
|
||||
...connectionItems,
|
||||
...allItems,
|
||||
{ type: 'separator' }
|
||||
]
|
||||
: []),
|
||||
@@ -830,6 +838,38 @@ const updateTray = () => {
|
||||
|
||||
// ─── Connection Management ──────────────────────────────
|
||||
|
||||
// Build a virtual local connection object from current config.
|
||||
// The local server is never stored in the connections array — it's
|
||||
// implicit when the open-webui package is installed.
|
||||
const buildLocalConnection = (): Connection => {
|
||||
const port = CONFIG?.localServer?.port ?? 8080
|
||||
return {
|
||||
id: 'local',
|
||||
name: 'Open WebUI',
|
||||
type: 'local',
|
||||
url: SERVER_URL || `http://127.0.0.1:${port}`
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve the default connection. 'local' is a virtual ID that
|
||||
// synthesises a Connection on the fly; everything else is looked
|
||||
// up in the persisted connections array (remote only).
|
||||
const getDefaultConnection = async (): Promise<Connection | null> => {
|
||||
const config = await getConfig()
|
||||
if (!config.defaultConnectionId) return null
|
||||
if (config.defaultConnectionId === 'local') return buildLocalConnection()
|
||||
return config.connections.find((c) => c.id === config.defaultConnectionId) ?? null
|
||||
}
|
||||
|
||||
// Resolve the URL for a connection, preferring the live SERVER_URL
|
||||
// for local connections and normalising 0.0.0.0 to localhost.
|
||||
const resolveConnectionUrl = (conn: Connection): string => {
|
||||
let url = conn.url
|
||||
if (conn.type === 'local' && SERVER_URL) url = SERVER_URL
|
||||
if (url.startsWith('http://0.0.0.0')) url = url.replace('http://0.0.0.0', 'http://localhost')
|
||||
return url
|
||||
}
|
||||
|
||||
const connectTo = async (connection: Connection) => {
|
||||
let url = connection.url
|
||||
|
||||
@@ -883,6 +923,27 @@ const startServerHandler = async (): Promise<boolean> => {
|
||||
|
||||
try {
|
||||
CONFIG = await getConfig()
|
||||
|
||||
// Auto-update the open-webui pip package to latest before starting.
|
||||
// Only when autoUpdate is enabled (default) and no version pin is set.
|
||||
const autoUpdate = CONFIG?.localServer?.autoUpdate !== false
|
||||
const versionPin = CONFIG?.localServer?.version
|
||||
if (autoUpdate && !versionPin && isPackageInstalled('open-webui')) {
|
||||
try {
|
||||
log.info('[server] Auto-updating open-webui package to latest…')
|
||||
sendToRenderer('status:install', 'Updating Open WebUI…')
|
||||
await installPackage('open-webui', undefined, (status: string) => {
|
||||
sendToRenderer('status:install', status)
|
||||
})
|
||||
sendToRenderer('status:install', '')
|
||||
log.info('[server] Auto-update complete')
|
||||
} catch (e) {
|
||||
// Non-fatal — start the existing version if upgrade fails
|
||||
log.warn('[server] Auto-update failed, starting existing version:', e)
|
||||
sendToRenderer('status:install', '')
|
||||
}
|
||||
}
|
||||
|
||||
const { url, pid } = await startServer(
|
||||
CONFIG?.localServer?.serveOnLocalNetwork ?? false,
|
||||
CONFIG?.localServer?.port ?? null
|
||||
@@ -1272,6 +1333,61 @@ if (!gotTheLock) {
|
||||
// Malformed URL — let it through so Chromium can handle/reject it
|
||||
}
|
||||
})
|
||||
|
||||
// ── Native right-click context menu (#161) ──────────────────
|
||||
// Electron <webview> guests don't show a context menu by default,
|
||||
// which blocks right-click → Paste / Autofill / password-manager
|
||||
// integration on login pages. Build a native menu with standard
|
||||
// editing actions, spell-check suggestions, and link handling.
|
||||
contents.on('context-menu', (_event, params) => {
|
||||
const menuItems: Electron.MenuItemConstructorOptions[] = []
|
||||
|
||||
// Spell-check suggestions (if any)
|
||||
if (params.misspelledWord && params.dictionarySuggestions?.length) {
|
||||
for (const suggestion of params.dictionarySuggestions) {
|
||||
menuItems.push({
|
||||
label: suggestion,
|
||||
click: () => contents.replaceMisspelling(suggestion)
|
||||
})
|
||||
}
|
||||
menuItems.push({ type: 'separator' })
|
||||
}
|
||||
|
||||
// Link handling
|
||||
if (params.linkURL) {
|
||||
menuItems.push({
|
||||
label: 'Open Link in Browser',
|
||||
click: () => openUrl(params.linkURL)
|
||||
})
|
||||
menuItems.push({
|
||||
label: 'Copy Link',
|
||||
click: () => clipboard.writeText(params.linkURL)
|
||||
})
|
||||
menuItems.push({ type: 'separator' })
|
||||
}
|
||||
|
||||
// Editable field actions (input, textarea, contenteditable)
|
||||
if (params.isEditable) {
|
||||
menuItems.push(
|
||||
{ label: 'Undo', role: 'undo', enabled: params.editFlags.canUndo },
|
||||
{ label: 'Redo', role: 'redo', enabled: params.editFlags.canRedo },
|
||||
{ type: 'separator' },
|
||||
{ label: 'Cut', role: 'cut', enabled: params.editFlags.canCut },
|
||||
{ label: 'Copy', role: 'copy', enabled: params.editFlags.canCopy },
|
||||
{ label: 'Paste', role: 'paste', enabled: params.editFlags.canPaste },
|
||||
{ label: 'Select All', role: 'selectAll', enabled: params.editFlags.canSelectAll }
|
||||
)
|
||||
} else if (params.selectionText) {
|
||||
// Non-editable text selection
|
||||
menuItems.push(
|
||||
{ label: 'Copy', role: 'copy', enabled: params.editFlags.canCopy }
|
||||
)
|
||||
}
|
||||
|
||||
if (menuItems.length > 0) {
|
||||
Menu.buildFromTemplate(menuItems).popup()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1356,6 +1472,18 @@ if (!gotTheLock) {
|
||||
log.warn('open-terminal install failed (non-fatal):', e)
|
||||
)
|
||||
sendToRenderer('status:package', true)
|
||||
// Notify renderer of install state change
|
||||
sendToRenderer('packages:changed', {
|
||||
'open-webui': isPackageInstalled('open-webui')
|
||||
})
|
||||
// Auto-set local as default if no default configured
|
||||
const cfg = await getConfig()
|
||||
if (!cfg.defaultConnectionId) {
|
||||
cfg.defaultConnectionId = 'local'
|
||||
await setConfig(cfg)
|
||||
CONFIG = cfg
|
||||
}
|
||||
updateTray()
|
||||
return true
|
||||
} catch (error) {
|
||||
sendToRenderer('status:package', false)
|
||||
@@ -1386,7 +1514,7 @@ if (!gotTheLock) {
|
||||
reachable: SERVER_REACHABLE
|
||||
}))
|
||||
|
||||
// Connections
|
||||
// Connections (remote only — local is virtual)
|
||||
ipcMain.handle('connections:list', async () => {
|
||||
const config = await getConfig()
|
||||
return config.connections
|
||||
@@ -1401,6 +1529,7 @@ if (!gotTheLock) {
|
||||
await setConfig(config)
|
||||
CONFIG = config
|
||||
updateTray()
|
||||
sendToRenderer('connections:changed', config.connections)
|
||||
return config.connections
|
||||
})
|
||||
|
||||
@@ -1408,11 +1537,12 @@ if (!gotTheLock) {
|
||||
const config = await getConfig()
|
||||
config.connections = config.connections.filter((c) => c.id !== id)
|
||||
if (config.defaultConnectionId === id) {
|
||||
config.defaultConnectionId = config.connections[0]?.id || null
|
||||
config.defaultConnectionId = config.connections[0]?.id || 'local'
|
||||
}
|
||||
await setConfig(config)
|
||||
CONFIG = config
|
||||
updateTray()
|
||||
sendToRenderer('connections:changed', config.connections)
|
||||
return config.connections
|
||||
})
|
||||
|
||||
@@ -1424,6 +1554,7 @@ if (!gotTheLock) {
|
||||
await setConfig(config)
|
||||
CONFIG = config
|
||||
updateTray()
|
||||
sendToRenderer('connections:changed', config.connections)
|
||||
}
|
||||
return config.connections
|
||||
})
|
||||
@@ -1437,6 +1568,10 @@ if (!gotTheLock) {
|
||||
})
|
||||
|
||||
ipcMain.handle('connections:connect', async (_event, id: string) => {
|
||||
// 'local' is a virtual connection — synthesize it
|
||||
if (id === 'local') {
|
||||
return await connectTo(buildLocalConnection())
|
||||
}
|
||||
const config = await getConfig()
|
||||
const conn = config.connections.find((c) => c.id === id)
|
||||
if (conn) {
|
||||
@@ -1477,26 +1612,14 @@ if (!gotTheLock) {
|
||||
|
||||
// Spotlight
|
||||
ipcMain.handle('spotlight:submit', async (_event, query: string, images?: string[]) => {
|
||||
const config = await getConfig()
|
||||
if (!config.defaultConnectionId || config.connections.length === 0) {
|
||||
mainWindow?.show()
|
||||
mainWindow?.focus()
|
||||
return
|
||||
}
|
||||
const conn = config.connections.find((c) => c.id === config.defaultConnectionId)
|
||||
const conn = await getDefaultConnection()
|
||||
if (!conn) {
|
||||
mainWindow?.show()
|
||||
mainWindow?.focus()
|
||||
return
|
||||
}
|
||||
|
||||
let url = conn.url
|
||||
if (conn.type === 'local' && SERVER_URL) {
|
||||
url = SERVER_URL
|
||||
}
|
||||
if (url.startsWith('http://0.0.0.0')) {
|
||||
url = url.replace('http://0.0.0.0', 'http://localhost')
|
||||
}
|
||||
const url = resolveConnectionUrl(conn)
|
||||
|
||||
// Build files payload from screenshot images
|
||||
const files = images?.map((dataUrl, i) => ({
|
||||
@@ -1623,20 +1746,10 @@ if (!gotTheLock) {
|
||||
// Transcribe audio via the connected server's STT endpoint
|
||||
ipcMain.handle('voiceInput:transcribe', async (_event, audioBuffer: ArrayBuffer, rendererToken?: string) => {
|
||||
try {
|
||||
const config = await getConfig()
|
||||
if (!config.defaultConnectionId || config.connections.length === 0) {
|
||||
throw new Error('No connection configured. Set up a connection in Settings first.')
|
||||
}
|
||||
const conn = config.connections.find((c) => c.id === config.defaultConnectionId)
|
||||
if (!conn) throw new Error('Default connection not found. Check your connection settings.')
|
||||
const conn = await getDefaultConnection()
|
||||
if (!conn) throw new Error('No connection configured. Set up a connection in Settings first.')
|
||||
|
||||
let url = conn.url
|
||||
if (conn.type === 'local' && SERVER_URL) {
|
||||
url = SERVER_URL
|
||||
}
|
||||
if (url.startsWith('http://0.0.0.0')) {
|
||||
url = url.replace('http://0.0.0.0', 'http://localhost')
|
||||
}
|
||||
const url = resolveConnectionUrl(conn)
|
||||
|
||||
// Use stored auth token (relayed from webview), fall back to renderer-provided or contentWindow
|
||||
let token = AUTH_TOKEN || rendererToken || ''
|
||||
@@ -1721,27 +1834,14 @@ if (!gotTheLock) {
|
||||
if (!text?.trim()) return
|
||||
|
||||
// Deliver text through the same path as Spotlight
|
||||
const config = await getConfig()
|
||||
if (!config.defaultConnectionId || config.connections.length === 0) {
|
||||
mainWindow?.show()
|
||||
mainWindow?.focus()
|
||||
return
|
||||
}
|
||||
const conn = config.connections.find((c) => c.id === config.defaultConnectionId)
|
||||
const conn = await getDefaultConnection()
|
||||
if (!conn) {
|
||||
mainWindow?.show()
|
||||
mainWindow?.focus()
|
||||
return
|
||||
}
|
||||
|
||||
let url = conn.url
|
||||
if (conn.type === 'local' && SERVER_URL) {
|
||||
url = SERVER_URL
|
||||
}
|
||||
if (url.startsWith('http://0.0.0.0')) {
|
||||
url = url.replace('http://0.0.0.0', 'http://localhost')
|
||||
}
|
||||
|
||||
const url = resolveConnectionUrl(conn)
|
||||
sendToRenderer('query', { query: text.trim(), connectionId: conn.id, url })
|
||||
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
@@ -1773,7 +1873,9 @@ if (!gotTheLock) {
|
||||
ipcMain.handle('open-terminal:start', async () => {
|
||||
try {
|
||||
sendToRenderer('status:open-terminal', 'starting')
|
||||
const result = await startOpenTerminal(CONFIG?.openTerminal?.port ?? null)
|
||||
const result = await startOpenTerminal(CONFIG?.openTerminal?.port ?? null, (status) => {
|
||||
sendToRenderer('status:open-terminal-setup', status)
|
||||
})
|
||||
sendToRenderer('status:open-terminal', 'started')
|
||||
sendToRenderer('open-terminal:ready', result)
|
||||
// Notify webview to register terminal server at system level
|
||||
@@ -1782,9 +1884,6 @@ if (!gotTheLock) {
|
||||
url: result.url,
|
||||
key: result.apiKey
|
||||
})
|
||||
// Save enabled state
|
||||
await setConfig({ openTerminal: { ...CONFIG?.openTerminal, enabled: true } })
|
||||
CONFIG = await getConfig()
|
||||
return result
|
||||
} catch (error) {
|
||||
log.error('Failed to start Open Terminal:', error)
|
||||
@@ -1806,8 +1905,7 @@ if (!gotTheLock) {
|
||||
url: info.url
|
||||
})
|
||||
}
|
||||
await setConfig({ openTerminal: { ...CONFIG?.openTerminal, enabled: false } })
|
||||
CONFIG = await getConfig()
|
||||
|
||||
return true
|
||||
} catch (error) {
|
||||
log.error('Failed to stop Open Terminal:', error)
|
||||
@@ -1848,13 +1946,13 @@ if (!gotTheLock) {
|
||||
if (result.url) {
|
||||
sendToRenderer('connections:openai', {
|
||||
action: 'add',
|
||||
url: `${result.url}/v1`
|
||||
url: `${result.url}/v1`,
|
||||
config: { provider: 'llama.cpp', connection_type: 'local' }
|
||||
})
|
||||
// Refresh model list after backend registers the endpoint
|
||||
setTimeout(() => sendToRenderer('models:refresh'), 1000)
|
||||
}
|
||||
await setConfig({ llamaCpp: { ...CONFIG?.llamaCpp, enabled: true } })
|
||||
CONFIG = await getConfig()
|
||||
|
||||
return result
|
||||
} catch (error) {
|
||||
log.error('Failed to start llamacpp:', error)
|
||||
@@ -1878,8 +1976,7 @@ if (!gotTheLock) {
|
||||
// Refresh model list after removing endpoint
|
||||
setTimeout(() => sendToRenderer('models:refresh'), 500)
|
||||
}
|
||||
await setConfig({ llamaCpp: { ...CONFIG?.llamaCpp, enabled: false } })
|
||||
CONFIG = await getConfig()
|
||||
|
||||
return true
|
||||
} catch (error) {
|
||||
log.error('Failed to stop llamacpp:', error)
|
||||
@@ -1953,7 +2050,13 @@ if (!gotTheLock) {
|
||||
|
||||
ipcMain.handle('package:version', (_event, packageName: string) => getPackageVersion(packageName))
|
||||
ipcMain.handle('package:uninstall', async (_event, packageName: string) => {
|
||||
return uninstallPackage(packageName)
|
||||
const result = uninstallPackage(packageName)
|
||||
// Notify renderer of install state change
|
||||
sendToRenderer('packages:changed', {
|
||||
'open-webui': isPackageInstalled('open-webui')
|
||||
})
|
||||
updateTray()
|
||||
return result
|
||||
})
|
||||
|
||||
ipcMain.handle('dialog:selectFolder', async () => {
|
||||
@@ -2044,7 +2147,9 @@ if (!gotTheLock) {
|
||||
if (CONFIG?.openTerminal?.enabled) {
|
||||
try {
|
||||
sendToRenderer('status:open-terminal', 'starting')
|
||||
const result = await startOpenTerminal(CONFIG?.openTerminal?.port ?? null)
|
||||
const result = await startOpenTerminal(CONFIG?.openTerminal?.port ?? null, (status) => {
|
||||
sendToRenderer('status:open-terminal-setup', status)
|
||||
})
|
||||
sendToRenderer('status:open-terminal', 'started')
|
||||
sendToRenderer('open-terminal:ready', result)
|
||||
} catch (error) {
|
||||
@@ -2068,18 +2173,23 @@ if (!gotTheLock) {
|
||||
}
|
||||
}
|
||||
|
||||
// Check if already configured, auto-connect to default
|
||||
if (CONFIG.defaultConnectionId && CONFIG.connections.length > 0) {
|
||||
const defaultConn = CONFIG.connections.find(
|
||||
(c) => c.id === CONFIG.defaultConnectionId
|
||||
)
|
||||
if (defaultConn) {
|
||||
createMainWindow()
|
||||
const result = await connectTo(defaultConn)
|
||||
if (result) sendToRenderer('connection:open', result)
|
||||
} else {
|
||||
createMainWindow()
|
||||
// Migrate legacy local connection entries out of the connections array
|
||||
if (CONFIG.connections.some((c) => c.type === 'local')) {
|
||||
CONFIG.connections = CONFIG.connections.filter((c) => c.type !== 'local')
|
||||
// Preserve 'local' as default if it was the default
|
||||
if (!CONFIG.defaultConnectionId || CONFIG.defaultConnectionId === 'local') {
|
||||
CONFIG.defaultConnectionId = 'local'
|
||||
}
|
||||
await setConfig(CONFIG)
|
||||
log.info('Migrated legacy local connection entry from connections array')
|
||||
}
|
||||
|
||||
// Check if already configured, auto-connect to default
|
||||
const defaultConn = await getDefaultConnection()
|
||||
if (defaultConn) {
|
||||
createMainWindow()
|
||||
const result = await connectTo(defaultConn)
|
||||
if (result) sendToRenderer('connection:open', result)
|
||||
} else {
|
||||
createMainWindow()
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Downloads files from HF repos, manages a local model cache,
|
||||
* and provides listing/deletion of cached models.
|
||||
*
|
||||
* Cache dir: <userData>/models/huggingface/<repo-slug>/<filename>
|
||||
* Cache dir: <userData>/models/<repo-slug>/<filename>
|
||||
*/
|
||||
|
||||
import * as fs from 'fs'
|
||||
@@ -33,10 +33,37 @@ export interface HfDownloadProgress {
|
||||
// ─── Paths ──────────────────────────────────────────────
|
||||
|
||||
const getHfCacheDir = (): string => {
|
||||
const dir = path.join(getInstallDir(), 'models', 'huggingface')
|
||||
const dir = path.join(getInstallDir(), 'models')
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir, { recursive: true })
|
||||
}
|
||||
|
||||
// Migrate models from legacy models/huggingface/<slug>/ to models/<slug>/
|
||||
const legacyDir = path.join(dir, 'huggingface')
|
||||
if (fs.existsSync(legacyDir)) {
|
||||
try {
|
||||
const entries = fs.readdirSync(legacyDir, { withFileTypes: true })
|
||||
for (const entry of entries) {
|
||||
if (entry.isDirectory()) {
|
||||
const src = path.join(legacyDir, entry.name)
|
||||
const dest = path.join(dir, entry.name)
|
||||
if (!fs.existsSync(dest)) {
|
||||
fs.renameSync(src, dest)
|
||||
log.info(`[huggingface] Migrated ${entry.name} from legacy cache`)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove legacy dir if empty (manifest.json may remain)
|
||||
const remaining = fs.readdirSync(legacyDir)
|
||||
if (remaining.length === 0) {
|
||||
fs.rmdirSync(legacyDir)
|
||||
log.info('[huggingface] Removed empty legacy huggingface/ directory')
|
||||
}
|
||||
} catch (e) {
|
||||
log.warn('[huggingface] Failed to migrate legacy cache:', e)
|
||||
}
|
||||
}
|
||||
|
||||
return dir
|
||||
}
|
||||
|
||||
|
||||
+42
-33
@@ -318,10 +318,7 @@ export const installPython = async (installationDir?: string, onStatus?: (status
|
||||
['-m', 'pip', 'install', 'uv'],
|
||||
{
|
||||
encoding: 'utf-8',
|
||||
env: {
|
||||
...process.env,
|
||||
...(process.platform === 'win32' ? { PYTHONIOENCODING: 'utf-8' } : {})
|
||||
}
|
||||
env: pythonEnv()
|
||||
},
|
||||
(error) => {
|
||||
if (error) reject(error)
|
||||
@@ -350,6 +347,38 @@ export const getPythonPath = (installationDir?: string) => {
|
||||
return path.normalize(getPythonExecutablePath(installationDir || getPythonInstallationDir()))
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a process environment suitable for running the bundled Python.
|
||||
*
|
||||
* On Windows the standalone Python distribution ships its own OpenSSL DLLs
|
||||
* (`libssl-3-x64.dll`, `libcrypto-3-x64.dll`) next to `python.exe`. If a
|
||||
* different OpenSSL installation (Git for Windows, Anaconda, Strawberry Perl,
|
||||
* etc.) appears earlier on the system `PATH`, Python picks up those mismatched
|
||||
* DLLs at load-time, which causes the fatal error:
|
||||
*
|
||||
* OPENSSL_Uplink(..., 08): no OPENSSL_Applink
|
||||
*
|
||||
* To prevent this we prepend the Python installation directory to `PATH` so
|
||||
* Windows finds the correct DLLs first. On non-Windows platforms this is a
|
||||
* harmless no-op.
|
||||
*
|
||||
* Any additional env overrides (e.g. `configEnvVars`) can be spread after
|
||||
* calling this helper.
|
||||
*/
|
||||
const pythonEnv = (extra: Record<string, string> = {}): Record<string, string> => {
|
||||
const base: Record<string, string> = { ...process.env }
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// python.exe lives at the root of the installation directory on Windows
|
||||
const pythonDir = getPythonInstallationDir()
|
||||
const currentPath = process.env['PATH'] || process.env['Path'] || ''
|
||||
base['PATH'] = `${pythonDir};${currentPath}`
|
||||
base['PYTHONIOENCODING'] = 'utf-8'
|
||||
}
|
||||
|
||||
return { ...base, ...extra }
|
||||
}
|
||||
|
||||
export const isPythonInstalled = (installationDir?: string) => {
|
||||
const pythonPath = getPythonPath(installationDir)
|
||||
if (!fs.existsSync(pythonPath)) {
|
||||
@@ -358,10 +387,7 @@ export const isPythonInstalled = (installationDir?: string) => {
|
||||
try {
|
||||
const pythonVersion = execFileSync(pythonPath, ['--version'], {
|
||||
encoding: 'utf-8',
|
||||
env: {
|
||||
...process.env,
|
||||
...(process.platform === 'win32' ? { PYTHONIOENCODING: 'utf-8' } : {})
|
||||
}
|
||||
env: pythonEnv()
|
||||
})
|
||||
log.info('Installed Python Version:', pythonVersion.trim())
|
||||
return true
|
||||
@@ -375,10 +401,7 @@ export const isUvInstalled = (installationDir?: string) => {
|
||||
try {
|
||||
const result = execFileSync(pythonPath, ['-m', 'uv', '--version'], {
|
||||
encoding: 'utf-8',
|
||||
env: {
|
||||
...process.env,
|
||||
...(process.platform === 'win32' ? { PYTHONIOENCODING: 'utf-8' } : {})
|
||||
}
|
||||
env: pythonEnv()
|
||||
})
|
||||
log.info('Installed uv Version:', result.trim())
|
||||
return true
|
||||
@@ -428,10 +451,7 @@ export const installPackage = (packageName: string, version?: string, onStatus?:
|
||||
...(version ? [`${packageName}==${version}`] : [packageName, '-U'])
|
||||
],
|
||||
{
|
||||
env: {
|
||||
...process.env,
|
||||
...(process.platform === 'win32' ? { PYTHONIOENCODING: 'utf-8' } : {})
|
||||
}
|
||||
env: pythonEnv()
|
||||
}
|
||||
)
|
||||
|
||||
@@ -486,10 +506,7 @@ export const isPackageInstalled = (packageName: string): boolean => {
|
||||
try {
|
||||
const info = execFileSync(pythonPath, ['-m', 'uv', 'pip', 'show', packageName], {
|
||||
encoding: 'utf-8',
|
||||
env: {
|
||||
...process.env,
|
||||
...(process.platform === 'win32' ? { PYTHONIOENCODING: 'utf-8' } : {})
|
||||
}
|
||||
env: pythonEnv()
|
||||
})
|
||||
return info.includes(`Name: ${packageName}`)
|
||||
} catch {
|
||||
@@ -503,10 +520,7 @@ export const getPackageVersion = (packageName: string): string | null => {
|
||||
try {
|
||||
const info = execFileSync(pythonPath, ['-m', 'uv', 'pip', 'show', packageName], {
|
||||
encoding: 'utf-8',
|
||||
env: {
|
||||
...process.env,
|
||||
...(process.platform === 'win32' ? { PYTHONIOENCODING: 'utf-8' } : {})
|
||||
}
|
||||
env: pythonEnv()
|
||||
})
|
||||
const match = info.match(/^Version:\s*(.+)$/m)
|
||||
return match ? match[1].trim() : null
|
||||
@@ -521,10 +535,7 @@ export const uninstallPackage = (packageName: string): boolean => {
|
||||
try {
|
||||
execFileSync(pythonPath, ['-m', 'uv', 'pip', 'uninstall', packageName], {
|
||||
encoding: 'utf-8',
|
||||
env: {
|
||||
...process.env,
|
||||
...(process.platform === 'win32' ? { PYTHONIOENCODING: 'utf-8' } : {})
|
||||
}
|
||||
env: pythonEnv()
|
||||
})
|
||||
log.info(`Uninstalled package: ${packageName}`)
|
||||
return true
|
||||
@@ -588,14 +599,12 @@ export const startServer = async (
|
||||
name: 'xterm-256color',
|
||||
cols: 200,
|
||||
rows: 50,
|
||||
env: {
|
||||
...process.env,
|
||||
env: pythonEnv({
|
||||
...(configEnvVars ?? {}),
|
||||
DATA_DIR: dataDir,
|
||||
WEBUI_SECRET_KEY: secretKey,
|
||||
PYTHONUNBUFFERED: '1',
|
||||
...(process.platform === 'win32' ? { PYTHONIOENCODING: 'utf-8' } : {})
|
||||
}
|
||||
PYTHONUNBUFFERED: '1'
|
||||
})
|
||||
})
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
installPackage,
|
||||
isPackageInstalled,
|
||||
isPythonInstalled,
|
||||
installPython,
|
||||
portInUse
|
||||
} from './index'
|
||||
import { ServiceLock, isProcessAlive } from './service-lock'
|
||||
@@ -38,7 +39,8 @@ export const getOpenTerminalPty = (): pty.IPty | null => ptyProcess
|
||||
export const getOpenTerminalLog = (): string[] => logBuffer
|
||||
|
||||
export const startOpenTerminal = async (
|
||||
port: number | null = null
|
||||
port: number | null = null,
|
||||
onStatus?: (status: string) => void
|
||||
): Promise<{ url: string; apiKey: string; pid: number }> => {
|
||||
if (!lock.acquire()) {
|
||||
return { url, apiKey, pid }
|
||||
@@ -46,9 +48,27 @@ export const startOpenTerminal = async (
|
||||
|
||||
await stopOpenTerminal()
|
||||
|
||||
if (!isPythonInstalled()) throw new Error('Python is not installed')
|
||||
if (!isPythonInstalled()) {
|
||||
log.info('Python not installed — installing automatically for Open Terminal…')
|
||||
onStatus?.('Installing Python…')
|
||||
try {
|
||||
const ok = await installPython(undefined, onStatus)
|
||||
if (!ok) throw new Error('Python installation returned false')
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`Python is required for Open Terminal but installation failed: ${err?.message ?? err}`
|
||||
)
|
||||
}
|
||||
if (!isPythonInstalled()) {
|
||||
throw new Error(
|
||||
'Python was installed but could not be verified. Please restart the app and try again.'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (!isPackageInstalled('open-terminal')) {
|
||||
log.info('open-terminal not installed, attempting install...')
|
||||
onStatus?.('Installing Open Terminal package…')
|
||||
try {
|
||||
await installPackage('open-terminal')
|
||||
} catch (err) {
|
||||
|
||||
@@ -50,9 +50,11 @@
|
||||
const serverReachable = $derived($serverInfo?.reachable)
|
||||
|
||||
const isInitializing = $derived($appState === 'initializing')
|
||||
const hasLocal = $derived(($connections ?? []).some((c) => c.type === 'local'))
|
||||
const localConn = $derived(($connections ?? []).find((c) => c.type === 'local'))
|
||||
const remoteConnections = $derived(($connections ?? []).filter((c) => c.type !== 'local'))
|
||||
const localConn = $derived(localInstalled
|
||||
? { id: 'local', name: 'Open WebUI', type: 'local' as const, url: `http://127.0.0.1:${$config?.localServer?.port ?? 8080}` }
|
||||
: null
|
||||
)
|
||||
const remoteConnections = $derived($connections ?? [])
|
||||
|
||||
// Open Terminal state
|
||||
let openTerminalStatus = $state<string | null>(null)
|
||||
@@ -62,6 +64,7 @@
|
||||
let llamaCppStatus = $state<string | null>(null)
|
||||
let llamaCppInfo = $state<{ url?: string; pid?: number } | null>(null)
|
||||
let llamaCppSetupStatus = $state('')
|
||||
let openTerminalSetupStatus = $state('')
|
||||
|
||||
const startInstall = async (options?: { installOpenTerminal?: boolean; installLlamaCpp?: boolean; installDir?: string }) => {
|
||||
installPhase = 'working'
|
||||
@@ -109,14 +112,7 @@
|
||||
const info = await window.electronAPI.getServerInfo()
|
||||
|
||||
installStatus = $i18n.t('main.install.settingUpConnection')
|
||||
await window.electronAPI.addConnection({
|
||||
id: 'local',
|
||||
name: 'Local',
|
||||
type: 'local',
|
||||
url: info?.url || 'http://127.0.0.1:8080'
|
||||
})
|
||||
await window.electronAPI.setDefaultConnection('local')
|
||||
connections.set(await window.electronAPI.getConnections())
|
||||
config.set(await window.electronAPI.getConfig())
|
||||
|
||||
// Wait for server to actually be reachable before showing connected view
|
||||
@@ -140,7 +136,6 @@
|
||||
|
||||
// Now connect — the server is ready
|
||||
installStatus = ''
|
||||
localInstalled = true
|
||||
connect('local')
|
||||
installPhase = 'idle'
|
||||
} catch (e: any) {
|
||||
@@ -177,7 +172,6 @@
|
||||
type: 'remote',
|
||||
url: u
|
||||
})
|
||||
connections.set(await window.electronAPI.getConnections())
|
||||
config.set(await window.electronAPI.getConfig())
|
||||
url = ''
|
||||
error = ''
|
||||
@@ -211,13 +205,10 @@
|
||||
return
|
||||
}
|
||||
|
||||
const conn = ($connections ?? []).find((c) => c.id === id)
|
||||
if (!conn) return
|
||||
|
||||
activeConnectionId = id
|
||||
|
||||
if (conn.type === 'local') {
|
||||
// Local needs server start — use IPC
|
||||
if (id === 'local') {
|
||||
// Local needs server start — use IPC (no renderer-side conn needed)
|
||||
connectingId = id
|
||||
view = 'welcome'
|
||||
window.electronAPI.connectTo(id).then((result: any) => {
|
||||
@@ -239,6 +230,8 @@
|
||||
}
|
||||
})
|
||||
} else {
|
||||
const conn = ($connections ?? []).find((c) => c.id === id)
|
||||
if (!conn) return
|
||||
// Remote — open immediately, no IPC needed
|
||||
connectingId = ''
|
||||
openConnections.set(id, conn.url)
|
||||
@@ -256,7 +249,6 @@
|
||||
|
||||
const remove = async (id: string) => {
|
||||
await window.electronAPI.removeConnection(id)
|
||||
connections.set(await window.electronAPI.getConnections())
|
||||
config.set(await window.electronAPI.getConfig())
|
||||
if (activeConnectionId === id) {
|
||||
disconnect()
|
||||
@@ -265,11 +257,15 @@
|
||||
openConnections = new Map(openConnections)
|
||||
}
|
||||
|
||||
// Sync active connection info to parent
|
||||
$effect(() => {
|
||||
const conn = ($connections ?? []).find((c) => c.id === activeConnectionId)
|
||||
activeConnectionName = conn?.name ?? ''
|
||||
isLocalConnection = conn?.type === 'local'
|
||||
if (activeConnectionId === 'local') {
|
||||
activeConnectionName = localConn?.name ?? 'Open WebUI'
|
||||
isLocalConnection = true
|
||||
} else {
|
||||
const conn = ($connections ?? []).find((c) => c.id === activeConnectionId)
|
||||
activeConnectionName = conn?.name ?? ''
|
||||
isLocalConnection = false
|
||||
}
|
||||
})
|
||||
|
||||
// React to showingLogs from parent — open the server log panel
|
||||
@@ -432,11 +428,20 @@
|
||||
|
||||
// ── Desktop-only state (not forwarded to webviews) ─
|
||||
if (data.type === 'status:open-terminal') { openTerminalStatus = data.data; return }
|
||||
if (data.type === 'open-terminal:ready') { openTerminalInfo = data.data; openTerminalStatus = 'started'; return }
|
||||
if (data.type === 'status:open-terminal-setup') { openTerminalSetupStatus = data.data ?? ''; return }
|
||||
if (data.type === 'open-terminal:ready') { openTerminalInfo = data.data; openTerminalStatus = 'started'; openTerminalSetupStatus = ''; return }
|
||||
if (data.type === 'status:llamacpp') { llamaCppStatus = data.data; return }
|
||||
if (data.type === 'status:llamacpp-setup') { llamaCppSetupStatus = data.data ?? ''; return }
|
||||
if (data.type === 'llamacpp:ready') { llamaCppInfo = data.data; llamaCppStatus = 'started'; llamaCppSetupStatus = ''; return }
|
||||
if (data.type === 'status:install') { installStatus = data.data ?? ''; return }
|
||||
if (data.type === 'packages:changed') {
|
||||
localInstalled = !!data.data?.['open-webui']
|
||||
return
|
||||
}
|
||||
if (data.type === 'connections:changed') {
|
||||
connections.set(data.data ?? [])
|
||||
return
|
||||
}
|
||||
|
||||
// ── Everything else → broadcast to all webviews ───
|
||||
sendToWebview(data)
|
||||
@@ -486,8 +491,10 @@
|
||||
await window.electronAPI.stopOpenTerminal()
|
||||
openTerminalStatus = null
|
||||
openTerminalInfo = null
|
||||
openTerminalSetupStatus = ''
|
||||
} else {
|
||||
openTerminalStatus = 'starting'
|
||||
openTerminalSetupStatus = ''
|
||||
const result = await window.electronAPI.startOpenTerminal()
|
||||
if (result) {
|
||||
openTerminalInfo = result
|
||||
@@ -495,6 +502,7 @@
|
||||
} else {
|
||||
openTerminalStatus = 'failed'
|
||||
}
|
||||
openTerminalSetupStatus = ''
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,7 +546,6 @@
|
||||
{onOpenSettings}
|
||||
onRename={async (id, name) => {
|
||||
await window.electronAPI.updateConnection(id, { name })
|
||||
connections.set(await window.electronAPI.getConnections())
|
||||
}}
|
||||
onRemove={remove}
|
||||
{openGithub}
|
||||
@@ -580,7 +587,7 @@
|
||||
statusText={activeLog === 'server'
|
||||
? (serverStatus === 'starting' ? 'Starting Open WebUI…' : serverStatus === 'running' && !serverReachable ? 'Waiting for server…' : installStatus || '')
|
||||
: activeLog === 'open-terminal'
|
||||
? (openTerminalStatus === 'stopping' ? 'Stopping Open Terminal…' : openTerminalStatus === 'starting' ? 'Starting Open Terminal…' : '')
|
||||
? (openTerminalStatus === 'stopping' ? 'Stopping Open Terminal…' : openTerminalSetupStatus || (openTerminalStatus === 'starting' ? 'Starting Open Terminal…' : ''))
|
||||
: (llamaCppStatus === 'stopping' ? 'Stopping llama-server…' : llamaCppSetupStatus || (llamaCppStatus === 'starting' ? 'Starting llama-server…' : llamaCppStatus === 'setting-up' ? 'Setting up llama.cpp…' : ''))}
|
||||
connectPty={getConnectPty(activeLog)}
|
||||
disconnectPty={getDisconnectPty(activeLog)}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte'
|
||||
import { fade, fly } from 'svelte/transition'
|
||||
import { connections, config, serverInfo, appState } from '../../../stores'
|
||||
import { config, serverInfo, appState } from '../../../stores'
|
||||
import i18n from '../../../i18n'
|
||||
import LocalInstall from '../../Setup/LocalInstall.svelte'
|
||||
import GetStartedModal from './GetStartedModal.svelte'
|
||||
@@ -80,7 +80,7 @@
|
||||
|
||||
// Server is starting up (local)
|
||||
const serverStarting = $derived(
|
||||
localConn && localInstalled && (
|
||||
localInstalled && (
|
||||
$serverInfo?.status === 'starting' ||
|
||||
($serverInfo?.status === 'running' && !$serverInfo?.reachable)
|
||||
)
|
||||
@@ -94,7 +94,7 @@
|
||||
|
||||
const isLoading = $derived(
|
||||
connectingId !== '' ||
|
||||
(serverStarting && activeConnectionId === localConn?.id) ||
|
||||
(serverStarting && activeConnectionId === 'local') ||
|
||||
(view === 'connected' && !activeWebviewError && webviewLoading.get(activeConnectionId) === true)
|
||||
)
|
||||
|
||||
@@ -270,6 +270,7 @@
|
||||
style="display: {view === 'connected' && activeConnectionId === connId ? 'flex' : 'none'}"
|
||||
partition="persist:connection-{connId}"
|
||||
preload={contentPreloadPath}
|
||||
allowpopups
|
||||
></webview>
|
||||
{/each}
|
||||
|
||||
@@ -388,7 +389,7 @@
|
||||
|
||||
<div class="flex-1 flex items-center justify-center px-6 relative overflow-hidden">
|
||||
{#if view === 'welcome'}
|
||||
{#if remoteConnections.length > 0 || (localConn && localInstalled)}
|
||||
{#if remoteConnections.length > 0 || localInstalled}
|
||||
<div class="text-center max-w-[320px]" in:fade={{ duration: 200 }}>
|
||||
<div class="text-lg opacity-80 mb-1.5">{$i18n.t('app.name')}</div>
|
||||
<div class="text-[12px] opacity-30 mb-6">
|
||||
@@ -486,7 +487,6 @@
|
||||
autoStart={autoInstall}
|
||||
onBack={() => { autoInstall = false; onSetView('welcome') }}
|
||||
onComplete={async () => {
|
||||
connections.set(await window.electronAPI.getConnections())
|
||||
config.set(await window.electronAPI.getConfig())
|
||||
onSetView('welcome')
|
||||
}}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
const remove = async (id: string) => {
|
||||
await window.electronAPI.removeConnection(id)
|
||||
connections.set(await window.electronAPI.getConnections())
|
||||
config.set(await window.electronAPI.getConfig())
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -429,7 +429,7 @@
|
||||
</div>
|
||||
<Switch
|
||||
checked={$config?.llamaCpp?.enabled ?? false}
|
||||
onToggle={() => updateConfig('enabled', !($config?.llamaCpp?.enabled ?? false))}
|
||||
onchange={(value) => updateConfig('enabled', value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
type: 'remote',
|
||||
url: u
|
||||
})
|
||||
connections.set(await window.electronAPI.getConnections())
|
||||
config.set(await window.electronAPI.getConfig())
|
||||
url = ''; name = ''; view = 'list'
|
||||
} catch { error = $i18n.t('setup.connectionManager.failed') }
|
||||
@@ -48,10 +47,8 @@
|
||||
}
|
||||
const remove = async (id: string) => {
|
||||
await window.electronAPI.removeConnection(id)
|
||||
const conns = await window.electronAPI.getConnections()
|
||||
connections.set(conns)
|
||||
config.set(await window.electronAPI.getConfig())
|
||||
if (conns.length === 0) appState.set('setup')
|
||||
if (($connections ?? []).length === 0) appState.set('setup')
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { fade, fly } from 'svelte/transition'
|
||||
import { onMount } from 'svelte'
|
||||
import { connections, config, serverInfo } from '../../stores'
|
||||
import { config, serverInfo } from '../../stores'
|
||||
import i18n from '../../i18n'
|
||||
|
||||
import logoImage from '../../assets/images/splash.png'
|
||||
@@ -33,14 +33,7 @@
|
||||
await window.electronAPI.startServer()
|
||||
const info = await window.electronAPI.getServerInfo()
|
||||
|
||||
await window.electronAPI.addConnection({
|
||||
id: 'local',
|
||||
name: 'Local',
|
||||
type: 'local',
|
||||
url: info?.url || 'http://127.0.0.1:8080'
|
||||
})
|
||||
await window.electronAPI.setDefaultConnection('local')
|
||||
connections.set(await window.electronAPI.getConnections())
|
||||
config.set(await window.electronAPI.getConfig())
|
||||
|
||||
phase = 'done'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte'
|
||||
import { fly, fade } from 'svelte/transition'
|
||||
import { appState, connections, config } from '../../stores'
|
||||
import { appState, config } from '../../stores'
|
||||
import i18n from '../../i18n'
|
||||
import LocalInstall from './LocalInstall.svelte'
|
||||
|
||||
@@ -30,16 +30,15 @@
|
||||
try {
|
||||
const valid = await window.electronAPI.validateUrl(u)
|
||||
if (!valid) { error = $i18n.t('setup.couldNotReachServer'); connecting = false; return }
|
||||
const connId = crypto.randomUUID()
|
||||
await window.electronAPI.addConnection({
|
||||
id: crypto.randomUUID(),
|
||||
id: connId,
|
||||
name: new URL(u).hostname,
|
||||
type: 'remote',
|
||||
url: u
|
||||
})
|
||||
connections.set(await window.electronAPI.getConnections())
|
||||
config.set(await window.electronAPI.getConfig())
|
||||
const conns = await window.electronAPI.getConnections()
|
||||
await window.electronAPI.connectTo(conns[conns.length - 1].id)
|
||||
await window.electronAPI.connectTo(connId)
|
||||
appState.set('ready')
|
||||
} catch {
|
||||
error = $i18n.t('setup.connectionFailed')
|
||||
|
||||
Reference in New Issue
Block a user