route CLI logs to host processes only
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { BrowserWindow, dialog, ipcMain, type OpenDialogOptions } from "electron"
|
import { BrowserWindow, dialog, ipcMain, type OpenDialogOptions } from "electron"
|
||||||
import type { CliLogEntry, CliProcessManager, CliStatus } from "./process-manager"
|
import type { CliProcessManager, CliStatus } from "./process-manager"
|
||||||
|
|
||||||
interface DialogOpenRequest {
|
interface DialogOpenRequest {
|
||||||
mode: "directory" | "file"
|
mode: "directory" | "file"
|
||||||
@@ -26,12 +26,6 @@ export function setupCliIPC(mainWindow: BrowserWindow, cliManager: CliProcessMan
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
cliManager.on("log", (entry: CliLogEntry) => {
|
|
||||||
if (!mainWindow.isDestroyed()) {
|
|
||||||
mainWindow.webContents.send("cli:log", entry)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
cliManager.on("error", (error: Error) => {
|
cliManager.on("error", (error: Error) => {
|
||||||
if (!mainWindow.isDestroyed()) {
|
if (!mainWindow.isDestroyed()) {
|
||||||
mainWindow.webContents.send("cli:error", { message: error.message })
|
mainWindow.webContents.send("cli:error", { message: error.message })
|
||||||
|
|||||||
@@ -5,10 +5,6 @@ const electronAPI = {
|
|||||||
ipcRenderer.on("cli:status", (_, data) => callback(data))
|
ipcRenderer.on("cli:status", (_, data) => callback(data))
|
||||||
return () => ipcRenderer.removeAllListeners("cli:status")
|
return () => ipcRenderer.removeAllListeners("cli:status")
|
||||||
},
|
},
|
||||||
onCliLog: (callback) => {
|
|
||||||
ipcRenderer.on("cli:log", (_, data) => callback(data))
|
|
||||||
return () => ipcRenderer.removeAllListeners("cli:log")
|
|
||||||
},
|
|
||||||
onCliError: (callback) => {
|
onCliError: (callback) => {
|
||||||
ipcRenderer.on("cli:error", (_, data) => callback(data))
|
ipcRenderer.on("cli:error", (_, data) => callback(data))
|
||||||
return () => ipcRenderer.removeAllListeners("cli:error")
|
return () => ipcRenderer.removeAllListeners("cli:error")
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ impl CliProcessManager {
|
|||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
let line = buffer.trim_end();
|
let line = buffer.trim_end();
|
||||||
if !line.is_empty() {
|
if !line.is_empty() {
|
||||||
let _ = app.emit("cli:log", json!({"stream": stream, "message": line}));
|
log_line(&format!("[cli][{}] {}", stream, line));
|
||||||
|
|
||||||
if ready.load(Ordering::SeqCst) {
|
if ready.load(Ordering::SeqCst) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
1
packages/ui/src/types/global.d.ts
vendored
1
packages/ui/src/types/global.d.ts
vendored
@@ -21,7 +21,6 @@ declare global {
|
|||||||
|
|
||||||
interface ElectronAPI {
|
interface ElectronAPI {
|
||||||
onCliStatus?: (callback: (data: unknown) => void) => () => void
|
onCliStatus?: (callback: (data: unknown) => void) => () => void
|
||||||
onCliLog?: (callback: (data: unknown) => void) => () => void
|
|
||||||
onCliError?: (callback: (data: unknown) => void) => () => void
|
onCliError?: (callback: (data: unknown) => void) => () => void
|
||||||
getCliStatus?: () => Promise<unknown>
|
getCliStatus?: () => Promise<unknown>
|
||||||
openDialog?: (options: ElectronDialogOptions) => Promise<ElectronDialogResult>
|
openDialog?: (options: ElectronDialogOptions) => Promise<ElectronDialogResult>
|
||||||
|
|||||||
Reference in New Issue
Block a user