mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-25 00:16:29 +02:00
browser open only on manual action by user
This commit is contained in:
parent
5ee4f8a848
commit
cb68c93357
3 changed files with 1 additions and 36 deletions
|
|
@ -1,18 +1,8 @@
|
||||||
import { BrowserWindow } from 'electron';
|
|
||||||
import type { IBrowserControlService } from '@x/core/dist/application/browser-control/service.js';
|
import type { IBrowserControlService } from '@x/core/dist/application/browser-control/service.js';
|
||||||
import type { BrowserControlAction, BrowserControlInput, BrowserControlResult } from '@x/shared/dist/browser-control.js';
|
import type { BrowserControlAction, BrowserControlInput, BrowserControlResult } from '@x/shared/dist/browser-control.js';
|
||||||
import { browserViewManager } from './view.js';
|
import { browserViewManager } from './view.js';
|
||||||
import { normalizeNavigationTarget } from './navigation.js';
|
import { normalizeNavigationTarget } from './navigation.js';
|
||||||
|
|
||||||
function emitPaneState(open: boolean): void {
|
|
||||||
const windows = BrowserWindow.getAllWindows();
|
|
||||||
for (const win of windows) {
|
|
||||||
if (!win.isDestroyed() && win.webContents) {
|
|
||||||
win.webContents.send('browser:didRequestPaneState', { open });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildSuccessResult(
|
function buildSuccessResult(
|
||||||
action: BrowserControlAction,
|
action: BrowserControlAction,
|
||||||
message: string,
|
message: string,
|
||||||
|
|
@ -37,24 +27,18 @@ function buildErrorResult(action: BrowserControlAction, error: string): BrowserC
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ElectronBrowserControlService implements IBrowserControlService {
|
export class ElectronBrowserControlService implements IBrowserControlService {
|
||||||
private ensurePaneOpen(): void {
|
|
||||||
emitPaneState(true);
|
|
||||||
browserViewManager.setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
async execute(
|
async execute(
|
||||||
input: BrowserControlInput,
|
input: BrowserControlInput,
|
||||||
ctx?: { signal?: AbortSignal },
|
ctx?: { signal?: AbortSignal },
|
||||||
): Promise<BrowserControlResult> {
|
): Promise<BrowserControlResult> {
|
||||||
const signal = ctx?.signal;
|
const signal = ctx?.signal;
|
||||||
this.ensurePaneOpen();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch (input.action) {
|
switch (input.action) {
|
||||||
case 'open': {
|
case 'open': {
|
||||||
await browserViewManager.ensureActiveTabReady(signal);
|
await browserViewManager.ensureActiveTabReady(signal);
|
||||||
const page = await browserViewManager.readPageSummary(signal, { waitForReady: false }) ?? undefined;
|
const page = await browserViewManager.readPageSummary(signal, { waitForReady: false }) ?? undefined;
|
||||||
return buildSuccessResult('open', 'Opened the browser pane.', page);
|
return buildSuccessResult('open', 'Opened a browser session.', page);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'get-state':
|
case 'get-state':
|
||||||
|
|
|
||||||
|
|
@ -789,19 +789,6 @@ function App() {
|
||||||
return cleanup
|
return cleanup
|
||||||
}, [refreshVoiceAvailability])
|
}, [refreshVoiceAvailability])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const cleanup = window.ipc.on('browser:didRequestPaneState', (event) => {
|
|
||||||
if (event.open) {
|
|
||||||
setIsBrowserOpen(true)
|
|
||||||
setIsChatSidebarOpen(true)
|
|
||||||
setIsRightPaneMaximized(false)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
setIsBrowserOpen(false)
|
|
||||||
})
|
|
||||||
return cleanup
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const handleStartRecording = useCallback(() => {
|
const handleStartRecording = useCallback(() => {
|
||||||
setIsRecording(true)
|
setIsRecording(true)
|
||||||
isRecordingRef.current = true
|
isRecordingRef.current = true
|
||||||
|
|
|
||||||
|
|
@ -708,12 +708,6 @@ const ipcSchemas = {
|
||||||
req: BrowserStateSchema,
|
req: BrowserStateSchema,
|
||||||
res: z.null(),
|
res: z.null(),
|
||||||
},
|
},
|
||||||
'browser:didRequestPaneState': {
|
|
||||||
req: z.object({
|
|
||||||
open: z.boolean(),
|
|
||||||
}),
|
|
||||||
res: z.null(),
|
|
||||||
},
|
|
||||||
// Billing channels
|
// Billing channels
|
||||||
'billing:getInfo': {
|
'billing:getInfo': {
|
||||||
req: z.null(),
|
req: z.null(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue