fix isolated tab handling

This commit is contained in:
Fabian Freund
2026-04-28 11:09:48 +02:00
parent ea6226e2bd
commit a4d66affcb
5 changed files with 9 additions and 7 deletions
@@ -525,12 +525,13 @@ class TabDao extends DatabaseAccessor<TabDatabase> with $TabDaoMixin {
); );
} }
Future<List<String>> getUnassignedTabsOlderThan(DateTime threshold) { Future<List<String>> getUnassignedRegularTabsOlderThan(DateTime threshold) {
final query = selectOnly(db.tab) final query = selectOnly(db.tab)
..addColumns([db.tab.id]) ..addColumns([db.tab.id])
..where( ..where(
db.tab.containerId.isNull() & db.tab.containerId.isNull() &
db.tab.timestamp.isSmallerThanValue(threshold), db.tab.timestamp.isSmallerThanValue(threshold) &
db.tab.tabMode.equalsValue(TabModeDbValue.regular),
); );
return query.map((row) => row.read(db.tab.id)!).get(); return query.map((row) => row.read(db.tab.id)!).get();
@@ -277,7 +277,7 @@ class TabDataRepository extends _$TabDataRepository {
final tabIds = await ref final tabIds = await ref
.read(tabDatabaseProvider) .read(tabDatabaseProvider)
.tabDao .tabDao
.getUnassignedTabsOlderThan(threshold); .getUnassignedRegularTabsOlderThan(threshold);
if (tabIds.isNotEmpty) { if (tabIds.isNotEmpty) {
await ref.read(tabRepositoryProvider.notifier).closeTabs(tabIds); await ref.read(tabRepositoryProvider.notifier).closeTabs(tabIds);
@@ -30,7 +30,7 @@ Future<bool?> showQuitBrowserDialog(BuildContext context) {
icon: const Icon(Icons.warning), icon: const Icon(Icons.warning),
title: const Text('Quit Browser'), title: const Text('Quit Browser'),
content: const Text( content: const Text(
'This will properly shutdown the browser and clear private tabs', 'This will properly shutdown the browser and clear private tab data',
), ),
actions: <Widget>[ actions: <Widget>[
TextButton( TextButton(
@@ -33,7 +33,7 @@ Future<bool?> showSwitchProfileDialog(
icon: const Icon(Icons.warning), icon: const Icon(Icons.warning),
title: const Text('Switch User'), title: const Text('Switch User'),
content: Text( content: Text(
"Switching to User '$profileName' will require a restart of the Browser.", "Switching to User '$profileName' will require a restart of the Browser.\n\nPrivate tab data will be cleared on restart.",
style: const TextStyle(fontWeight: FontWeight.bold), style: const TextStyle(fontWeight: FontWeight.bold),
), ),
actions: [ actions: [
+3 -2
View File
@@ -30,11 +30,12 @@ import 'package:weblibre/features/tor/domain/services/tor_proxy.dart';
Future<void> exitApp(ProviderContainer container) async { Future<void> exitApp(ProviderContainer container) async {
logger.i('Preparing exit'); logger.i('Preparing exit');
// 1. Close private/isolated tabs (clears browsing data for those contexts) // 1. Close private tabs (clears browsing data for private contexts).
// Isolated tabs are persistent and should survive app exit.
try { try {
await container await container
.read(tabDataRepositoryProvider.notifier) .read(tabDataRepositoryProvider.notifier)
.closeAllTabs(includeRegular: false); .closeAllTabs(includeRegular: false, includeIsolated: false);
logger.i('Private tabs closed'); logger.i('Private tabs closed');
} catch (e, st) { } catch (e, st) {
logger.e('Failed to close tabs', error: e, stackTrace: st); logger.e('Failed to close tabs', error: e, stackTrace: st);