fix: Rust-side window creation + RDP tab switch layout delay
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 3m51s
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 3m51s
Tool/help/editor/detach windows: - Moved ALL child window creation from JS-side WebviewWindow to Rust-side WebviewWindowBuilder via new open_child_window command. JS WebviewWindow on macOS WKWebView was creating windows that never fully initialized — the webview content process failed silently. Rust-side creation uses the proper main thread context. - All four call sites (tool, help, editor, detach) now use invoke() - Errors surface as alert() instead of silent failure RDP tab switch: - Immediate force_refresh on tab activation for instant visual feedback - 300ms delayed dimension check (was double-rAF which was too fast) - If dimensions changed, resize + 500ms delayed refresh for clean repaint - Fixes 3/4 resolution rendering after copilot panel toggle Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d462381cce
commit
703ebdd557
@ -14,3 +14,4 @@ pub mod updater;
|
||||
pub mod tools_commands_r2;
|
||||
pub mod workspace_commands;
|
||||
pub mod docker_commands;
|
||||
pub mod window_commands;
|
||||
|
||||
24
src-tauri/src/commands/window_commands.rs
Normal file
24
src-tauri/src/commands/window_commands.rs
Normal file
@ -0,0 +1,24 @@
|
||||
use tauri::AppHandle;
|
||||
use tauri::WebviewWindowBuilder;
|
||||
|
||||
/// Open a child window from the Rust side using WebviewWindowBuilder.
|
||||
/// This is more reliable than JS-side WebviewWindow on macOS WKWebView.
|
||||
#[tauri::command]
|
||||
pub async fn open_child_window(
|
||||
app_handle: AppHandle,
|
||||
label: String,
|
||||
title: String,
|
||||
url: String,
|
||||
width: f64,
|
||||
height: f64,
|
||||
) -> Result<(), String> {
|
||||
let webview_url = tauri::WebviewUrl::App(url.into());
|
||||
WebviewWindowBuilder::new(&app_handle, &label, webview_url)
|
||||
.title(&title)
|
||||
.inner_size(width, height)
|
||||
.resizable(true)
|
||||
.center()
|
||||
.build()
|
||||
.map_err(|e| format!("Failed to create window '{}': {}", label, e))?;
|
||||
Ok(())
|
||||
}
|
||||
@ -234,6 +234,7 @@ pub fn run() {
|
||||
commands::updater::check_for_updates,
|
||||
commands::workspace_commands::save_workspace, commands::workspace_commands::load_workspace,
|
||||
commands::docker_commands::docker_list_containers, commands::docker_commands::docker_list_images, commands::docker_commands::docker_list_volumes, commands::docker_commands::docker_action,
|
||||
commands::window_commands::open_child_window,
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
@ -204,15 +204,21 @@ onBeforeUnmount(() => {
|
||||
if (resizeTimeout) { clearTimeout(resizeTimeout); resizeTimeout = null; }
|
||||
});
|
||||
|
||||
// Focus canvas, re-check dimensions, and force full frame on tab switch
|
||||
// Focus canvas, re-check dimensions, and force full frame on tab switch.
|
||||
// Uses 300ms delay to let the flex layout fully settle (copilot panel toggle, etc.)
|
||||
watch(
|
||||
() => props.isActive,
|
||||
(active) => {
|
||||
if (!active || !canvasRef.value) return;
|
||||
|
||||
// Wait for layout to settle after tab becomes visible
|
||||
requestAnimationFrame(() => {
|
||||
requestAnimationFrame(() => {
|
||||
// Immediate focus so keyboard works right away
|
||||
if (keyboardGrabbed.value) canvasRef.value.focus();
|
||||
|
||||
// Immediate force refresh to show SOMETHING while we check dimensions
|
||||
invoke("rdp_force_refresh", { sessionId: props.sessionId }).catch(() => {});
|
||||
|
||||
// Delayed dimension check — layout needs time to settle
|
||||
setTimeout(() => {
|
||||
const wrapper = canvasWrapper.value;
|
||||
const canvas = canvasRef.value;
|
||||
if (!wrapper || !canvas) return;
|
||||
@ -221,27 +227,22 @@ watch(
|
||||
const newW = Math.round(cw) & ~1;
|
||||
const newH = Math.round(ch);
|
||||
|
||||
// If container size differs from canvas resolution, resize the RDP session
|
||||
if (newW >= 200 && newH >= 200 && (newW !== canvas.width || newH !== canvas.height)) {
|
||||
invoke("rdp_resize", {
|
||||
sessionId: props.sessionId,
|
||||
width: newW,
|
||||
height: newH,
|
||||
}).then(() => {
|
||||
if (canvas) {
|
||||
canvas.width = newW;
|
||||
canvas.height = newH;
|
||||
}
|
||||
setTimeout(() => {
|
||||
invoke("rdp_force_refresh", { sessionId: props.sessionId }).catch(() => {});
|
||||
}, 200);
|
||||
}, 500);
|
||||
}).catch(() => {});
|
||||
} else {
|
||||
// Same size — just refresh the frame
|
||||
invoke("rdp_force_refresh", { sessionId: props.sessionId }).catch(() => {});
|
||||
}
|
||||
|
||||
if (keyboardGrabbed.value) canvas.focus();
|
||||
});
|
||||
});
|
||||
}, 300);
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
@ -133,20 +133,14 @@ async function detachTab(): Promise<void> {
|
||||
session.active = false;
|
||||
|
||||
// Open a new Tauri window for this session
|
||||
const { WebviewWindow } = await import("@tauri-apps/api/webviewWindow");
|
||||
const label = `detached-${session.id.substring(0, 8)}-${Date.now()}`;
|
||||
const wv = new WebviewWindow(label, {
|
||||
try {
|
||||
await invoke("open_child_window", {
|
||||
label: `detached-${session.id.substring(0, 8)}-${Date.now()}`,
|
||||
title: `${session.name} — Wraith`,
|
||||
width: 900,
|
||||
height: 600,
|
||||
resizable: true,
|
||||
center: true,
|
||||
visible: false,
|
||||
focus: true,
|
||||
url: `index.html#/detached-session?sessionId=${session.id}&name=${encodeURIComponent(session.name)}&protocol=${session.protocol}`,
|
||||
width: 900, height: 600,
|
||||
});
|
||||
wv.once("tauri://created", () => { wv.show(); });
|
||||
wv.once("tauri://error", (e) => { console.error("Detach window error:", e); });
|
||||
} catch (err) { console.error("Detach window error:", err); }
|
||||
}
|
||||
|
||||
function closeMenuTab(): void {
|
||||
|
||||
@ -367,20 +367,14 @@ function closeHelpMenuDeferred(): void {
|
||||
|
||||
async function handleHelpAction(page: string): Promise<void> {
|
||||
showHelpMenu.value = false;
|
||||
const { WebviewWindow } = await import("@tauri-apps/api/webviewWindow");
|
||||
const label = `help-${page}-${Date.now()}`;
|
||||
const wv = new WebviewWindow(label, {
|
||||
title: `Wraith — Help`,
|
||||
width: 750,
|
||||
height: 600,
|
||||
resizable: true,
|
||||
center: true,
|
||||
visible: false,
|
||||
focus: true,
|
||||
try {
|
||||
await invoke("open_child_window", {
|
||||
label: `help-${page}-${Date.now()}`,
|
||||
title: "Wraith — Help",
|
||||
url: `index.html#/tool/help?page=${page}`,
|
||||
width: 750, height: 600,
|
||||
});
|
||||
wv.once("tauri://created", () => { wv.show(); });
|
||||
wv.once("tauri://error", (e) => { console.error("Help window error:", e); alert("Window error: " + JSON.stringify(e.payload)); });
|
||||
} catch (err) { console.error("Help window error:", err); alert("Window error: " + String(err)); }
|
||||
}
|
||||
|
||||
async function handleToolAction(tool: string): Promise<void> {
|
||||
@ -394,8 +388,6 @@ async function handleToolAction(tool: string): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
const { WebviewWindow } = await import("@tauri-apps/api/webviewWindow");
|
||||
|
||||
const toolConfig: Record<string, { title: string; width: number; height: number }> = {
|
||||
"network-scanner": { title: "Network Scanner", width: 800, height: 600 },
|
||||
"port-scanner": { title: "Port Scanner", width: 700, height: 500 },
|
||||
@ -416,20 +408,14 @@ async function handleToolAction(tool: string): Promise<void> {
|
||||
|
||||
const sessionId = activeSessionId.value || "";
|
||||
|
||||
// Open tool in a new Tauri window — create hidden, show after webview confirms ready
|
||||
const label = `tool-${tool}-${Date.now()}`;
|
||||
const wv = new WebviewWindow(label, {
|
||||
try {
|
||||
await invoke("open_child_window", {
|
||||
label: `tool-${tool}-${Date.now()}`,
|
||||
title: `Wraith — ${config.title}`,
|
||||
width: config.width,
|
||||
height: config.height,
|
||||
resizable: true,
|
||||
center: true,
|
||||
visible: false,
|
||||
focus: true,
|
||||
url: `index.html#/tool/${tool}?sessionId=${sessionId}`,
|
||||
width: config.width, height: config.height,
|
||||
});
|
||||
wv.once("tauri://created", () => { wv.show(); });
|
||||
wv.once("tauri://error", (e) => { console.error("Tool window error:", e); alert("Window error: " + JSON.stringify(e.payload)); });
|
||||
} catch (err) { console.error("Tool window error:", err); alert("Tool window error: " + String(err)); }
|
||||
}
|
||||
|
||||
async function handleFileMenuAction(action: string): Promise<void> {
|
||||
@ -449,23 +435,14 @@ function handleThemeSelect(theme: ThemeDefinition): void {
|
||||
async function handleOpenFile(entry: FileEntry): Promise<void> {
|
||||
if (!activeSessionId.value) return;
|
||||
try {
|
||||
const { WebviewWindow } = await import("@tauri-apps/api/webviewWindow");
|
||||
const fileName = entry.path.split("/").pop() || entry.path;
|
||||
const label = `editor-${Date.now()}`;
|
||||
const sessionId = activeSessionId.value;
|
||||
|
||||
const wv = new WebviewWindow(label, {
|
||||
await invoke("open_child_window", {
|
||||
label: `editor-${Date.now()}`,
|
||||
title: `${fileName} — Wraith Editor`,
|
||||
width: 800,
|
||||
height: 600,
|
||||
resizable: true,
|
||||
center: true,
|
||||
visible: false,
|
||||
focus: true,
|
||||
url: `index.html#/tool/editor?sessionId=${sessionId}&path=${encodeURIComponent(entry.path)}`,
|
||||
width: 800, height: 600,
|
||||
});
|
||||
wv.once("tauri://created", () => { wv.show(); });
|
||||
wv.once("tauri://error", (e) => { console.error("Editor window error:", e); alert("Window error: " + JSON.stringify(e.payload)); });
|
||||
} catch (err) { console.error("Failed to open editor:", err); }
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user