refactor: better camoufox instance tracking

This commit is contained in:
zhom
2025-07-31 03:56:41 +04:00
parent 2fd344b9bb
commit 63000c72bd
20 changed files with 1623 additions and 457 deletions
+19 -11
View File
@@ -84,15 +84,22 @@ export function ProfileSelectorDialog({
// First, try to find a running profile that can be used for opening links
const runningAvailableProfile = profileList.find((profile) => {
const isRunning = runningProfiles.has(profile.name);
return isRunning && browserState.canUseProfileForLinks(profile);
// Simple check without browserState dependency
return (
isRunning &&
profile.browser !== "tor-browser" &&
profile.browser !== "mullvad-browser"
);
});
if (runningAvailableProfile) {
setSelectedProfile(runningAvailableProfile.name);
} else {
// If no running profile is available, find the first available profile
const availableProfile = profileList.find((profile) =>
browserState.canUseProfileForLinks(profile),
const availableProfile = profileList.find(
(profile) =>
profile.browser !== "tor-browser" &&
profile.browser !== "mullvad-browser",
);
if (availableProfile) {
setSelectedProfile(availableProfile.name);
@@ -104,7 +111,7 @@ export function ProfileSelectorDialog({
} finally {
setIsLoading(false);
}
}, [runningProfiles, browserState]);
}, [runningProfiles]);
// Helper function to get tooltip content for profiles - now uses shared hook
const getProfileTooltipContent = (profile: BrowserProfile): string | null => {
@@ -227,11 +234,12 @@ export function ProfileSelectorDialog({
return (
<Tooltip key={profile.name}>
<TooltipTrigger asChild>
<span className="inline-flex">
<SelectItem
value={profile.name}
disabled={!canUseForLinks}
>
<SelectItem
value={profile.name}
disabled={!canUseForLinks}
asChild
>
<span>
<div
className={`flex items-center gap-2 ${
!canUseForLinks ? "opacity-50" : ""
@@ -276,8 +284,8 @@ export function ProfileSelectorDialog({
</Badge>
)}
</div>
</SelectItem>
</span>
</span>
</SelectItem>
</TooltipTrigger>
{tooltipContent && (
<TooltipContent>{tooltipContent}</TooltipContent>