feat(extension): add popup toggle to hide Agent control hints (#81)

Add a per-browser "Control hints" switch to the popup that hides the in-page control overlay (status pill + orange glow, along with its input blocker) while the Agent controls a tab. Preference lives in chrome.storage.local (bsk_control_hints_hidden, default: shown) and is applied live in content scripts via storage.onChanged.

Both popup settings rows share a single Switch component; the hint copy lives in an info-icon tooltip.

Refs #62
This commit is contained in:
BB-fat
2026-08-13 10:24:17 +08:00
committed by GitHub
parent f81a1e7796
commit 37fbaacc94
12 changed files with 373 additions and 20 deletions
@@ -0,0 +1,44 @@
import { useEffect, useState } from "react";
import { getControlHintsHidden, STORAGE_KEYS, setControlHintsHidden } from "@/lib/instance-id";
/**
* Popup-side view of the "hide control hints" preference in
* `chrome.storage.local`. Defaults to shown when storage is unavailable
* (e.g. unit tests) so the popup still renders; writes go straight to
* storage and content scripts pick them up via `storage.onChanged`.
*/
export function useControlHintsHidden(): [boolean, (hidden: boolean) => void] {
const [hidden, setHidden] = useState(false);
useEffect(() => {
if (typeof chrome === "undefined" || !chrome.storage?.local) return undefined;
let cancelled = false;
getControlHintsHidden()
.then((value) => {
if (!cancelled) setHidden(value);
})
.catch((err) => {
console.debug("[browser-skill] control-hints preference read failed", err);
});
const onChanged = (changes: Record<string, chrome.storage.StorageChange>, areaName: string) => {
if (areaName !== "local") return;
const change = changes[STORAGE_KEYS.CONTROL_HINTS_HIDDEN];
if (change) setHidden(change.newValue === true);
};
chrome.storage.onChanged.addListener(onChanged);
return () => {
cancelled = true;
chrome.storage.onChanged.removeListener(onChanged);
};
}, []);
const update = (value: boolean) => {
setHidden(value);
if (typeof chrome === "undefined" || !chrome.storage?.local) return;
setControlHintsHidden(value).catch((err) => {
console.debug("[browser-skill] control-hints preference write failed", err);
});
};
return [hidden, update];
}