Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(browser): reset the extension list on browser switch; list it when control arrives with the menu open

AdityaUmalec4bb8a295368
diff --git a/scripts/ci-scope.test.ts b/scripts/ci-scope.test.ts
index 2e4504b120..a71b67c023 100644
--- a/scripts/ci-scope.test.ts
+++ b/scripts/ci-scope.test.ts
@@ -522,7 +522,8 @@ describe("the repository's import graph", () => {
.filter((file) => !/[/\\]ci-scope\.(?:mjs|test\.ts)$/.test(file));
const mentionsTranslations = (file: string) => {
const text = readFileSync(file, "utf8");
- return [...text.matchAll(/locales/g)].some((match) => !/^locales\W{1,6}en\.json/.test(text.slice(match.index, match.index + 24)));
+ // A browser extension's own _locales folder is not one of ours.
+ return [...text.matchAll(/(?<!_)locales/g)].some((match) => !/^locales\W{1,6}en\.json/.test(text.slice(match.index, match.index + 24)));
};
const readers = new Set(files.filter(mentionsTranslations));
const affected = files
diff --git a/src/components/BrowserPanel.tsx b/src/components/BrowserPanel.tsx
index 0f91fed466..4cc907fb55 100644
--- a/src/components/BrowserPanel.tsx
+++ b/src/components/BrowserPanel.tsx
@@ -102,6 +102,7 @@ export function LiveBrowser({ bot, signIn, page }: { bot: Bot; signIn?: BrowserS
useEffect(() => { setFallback(false); }, [bot.id, bot.browserProfile, scopedThread]);
useEffect(() => {
setTabs([]);
+ setExtensions(null);
setNav(stream ? NO_NAV : { ...NO_NAV, canGoBack: true, canGoForward: true });
setStarting(false);
setGone(false);
diff --git a/src/components/browser/ExtensionsMenu.tsx b/src/components/browser/ExtensionsMenu.tsx
index a75ec9d99b..1ab9ecda59 100644
--- a/src/components/browser/ExtensionsMenu.tsx
+++ b/src/components/browser/ExtensionsMenu.tsx
@@ -1,7 +1,7 @@
// The browser panel's Extensions menu: the extensions installed in this bot's browser, each opening its own page for the
// person holding the browser. The server picks the page from the extension's id; chrome:// pages never open from here.
import { Puzzle } from "lucide-react";
-import { useRef } from "react";
+import { useEffect, useRef } from "react";
import { t } from "@/lib/i18n";
@@ -29,6 +29,9 @@ export function ExtensionsMenu({ ready, extensions, onList, onOpen }: {
onOpen: (id: string) => void;
}) {
const menu = useRef<HTMLDetailsElement>(null);
+ // Control can arrive while the menu is already open: ask for the list then too.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ useEffect(() => { if (ready && menu.current?.open) onList(); }, [ready]);
return (
<details ref={menu} className="relative shrink-0" onToggle={(event) => { if (event.currentTarget.open && ready) onList(); }}>
<summary className="list-none cursor-pointer rounded-md p-1.5 text-ink-secondary hover:bg-inset hover:text-ink [&::-webkit-details-marker]:hidden" aria-label={t("browser.extensions.title")} title={t("browser.extensions.title")}><Puzzle size={16} /></summary>