Feat : open link on current firefox session
This commit is contained in:
@@ -151,6 +151,49 @@ function migrateIdleStatus(): void {
|
||||
|
||||
migrateIdleStatus();
|
||||
|
||||
/**
|
||||
* `--new-window` et la fermeture systématique de la fenêtre détruisaient à chaque
|
||||
* capture la source « capture de fenêtre » d'OBS, qu'il fallait ensuite repointer
|
||||
* à la main. Les agents configurés avant le correctif portent ces valeurs dans
|
||||
* leur JSON.
|
||||
*
|
||||
* Même précaution qu'au-dessus : seules les configurations restées au défaut sont
|
||||
* reprises, ce qui rend la migration idempotente et respecte les réglages
|
||||
* personnalisés.
|
||||
*/
|
||||
function migrateBrowserWindowReuse(): void {
|
||||
const rows = db
|
||||
.prepare('SELECT id, browser_json FROM agents WHERE browser_json IS NOT NULL')
|
||||
.all() as unknown as Array<{ id: string; browser_json: string }>;
|
||||
const update = db.prepare('UPDATE agents SET browser_json = ? WHERE id = ?');
|
||||
let migrated = 0;
|
||||
|
||||
for (const row of rows) {
|
||||
const browser = safeJsonParse<BrowserSettings & { closeOnStop?: boolean }>(row.browser_json);
|
||||
if (!browser) continue;
|
||||
|
||||
const atLegacyDefault =
|
||||
Array.isArray(browser.args) &&
|
||||
browser.args.length === 1 &&
|
||||
browser.args[0] === '--new-window' &&
|
||||
browser.closeOnStop === true &&
|
||||
browser.onStop === undefined;
|
||||
if (!atLegacyDefault) continue;
|
||||
|
||||
const { closeOnStop: _legacy, ...rest } = browser;
|
||||
update.run(JSON.stringify({ ...rest, args: [], onStop: 'blank' }), row.id);
|
||||
migrated += 1;
|
||||
}
|
||||
|
||||
if (migrated > 0) {
|
||||
console.log(
|
||||
`Migration : réutilisation de la fenêtre du navigateur activée sur ${migrated} agent(s)`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
migrateBrowserWindowReuse();
|
||||
|
||||
export interface AgentRow {
|
||||
id: string;
|
||||
name: string;
|
||||
|
||||
Reference in New Issue
Block a user