Skip to content

Commit dcb671e

Browse files
committed
feat(desktop): inject window.__OPENKB_DESKTOP__ to enable desktop chrome
The #189 frontend gates desktop-only UI (the in-app TitleBar, offset chrome cluster) on a `window.__OPENKB_DESKTOP__` flag. Set it from the shell so those features light up when the UI runs inside Tauri. The window is now created in setup() via WebviewWindowBuilder with an initialization_script, instead of declaratively in tauri.conf.json — an init script runs before page scripts on every navigation, so the flag is present on the splash and (critically) after we navigate the WebView to the sidecar's served UI. tauri.conf.json's windows[] is emptied accordingly. Verified under xvfb (WebKitGTK): with the sidecar serving the new frontend, the Tauri window renders the desktop TitleBar ("OpenKB Studio — Home", traffic lights, Local badge) — confirming the flag reaches the page. cargo build clean. Claude-Session: https://claude.ai/code/session_01KZyUSGAzVL9yxpsWWPv6Y2
1 parent 6d38874 commit dcb671e

2 files changed

Lines changed: 17 additions & 10 deletions

File tree

desktop/src-tauri/src/main.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,22 @@ fn main() {
6868
tauri::Builder::default()
6969
.manage(Sidecar(Mutex::new(None)))
7070
.setup(|app| {
71+
// Create the main window programmatically so we can inject the
72+
// desktop-shell flag the frontend checks (window.__OPENKB_DESKTOP__).
73+
// It gates the in-app TitleBar and other desktop-only chrome. An
74+
// initialization script runs before page scripts on every
75+
// navigation, so the flag is present on the splash AND after we
76+
// navigate to the sidecar's served UI.
77+
tauri::WebviewWindowBuilder::new(
78+
app,
79+
"main",
80+
tauri::WebviewUrl::App("index.html".into()),
81+
)
82+
.title("OpenKB")
83+
.inner_size(1200.0, 800.0)
84+
.initialization_script("window.__OPENKB_DESKTOP__ = true;")
85+
.build()?;
86+
7187
// Non-fatal: if the sidecar can't start (missing binary, port in
7288
// use), keep the window up on the splash rather than crashing the
7389
// app. In `cargo run` dev the bundled sidecar isn't present, so

desktop/src-tauri/tauri.conf.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,7 @@
77
"frontendDist": "splash"
88
},
99
"app": {
10-
"windows": [
11-
{
12-
"label": "main",
13-
"title": "OpenKB",
14-
"width": 1200,
15-
"height": 800,
16-
"resizable": true,
17-
"url": "index.html"
18-
}
19-
],
10+
"windows": [],
2011
"security": {
2112
"csp": null
2213
}

0 commit comments

Comments
 (0)