mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-23 02:45:38 -06:00
fada067277
* feat(browser): add zero-click extension bootstrap Pre-register deterministic path-derived extension IDs and install a strict native messaging host. Keep the popup and options UI minimal while removing the obsolete copilot and page-share flows. * fix(browser): satisfy native bootstrap CI guards * test(browser): isolate native bootstrap Chrome roots * test(browser): flush native bootstrap profile before status * test(browser): seed Linux native bootstrap identity * fix(browser): preserve native bootstrap upgrade safety Allow immutable root-owned package inputs while keeping mutable state, manifests, and launchers user-owned. Preserve all retired copilot keys whenever active or unrecognized recovery custody remains. * fix(browser): preserve pending copilot custody Retired cleanup now removes copilot state only when the durable registry is exactly empty. Any session, archive, malformed value, future shape, or read failure preserves every retired key. * fix(browser): guard native bootstrap upgrades Fail closed while retired copilot custody remains and make discard durable across partial failures. Require exact launcher-embedded origins and repair full launcher drift without accepting mismatched registrations. * fix(browser): remove stale layout export * chore(release): leave changelog to release flow
81 lines
2.7 KiB
JavaScript
81 lines
2.7 KiB
JavaScript
const statusLine = document.getElementById("status");
|
|
const pairedDetails = document.getElementById("pairedDetails");
|
|
const accessMode = document.getElementById("accessMode");
|
|
const tabAction = document.getElementById("tabAction");
|
|
const settings = document.getElementById("settings");
|
|
const errorLine = document.getElementById("error");
|
|
|
|
async function activeTab() {
|
|
const [tab] = await chrome.tabs.query({ active: true, lastFocusedWindow: true });
|
|
return tab ?? null;
|
|
}
|
|
|
|
function unpairedLabel(nativeBootstrap) {
|
|
if (nativeBootstrap?.disabled) {
|
|
return "Automatic setup disabled";
|
|
}
|
|
if (nativeBootstrap?.state === "manual_required") {
|
|
return "Manual setup required";
|
|
}
|
|
return "Waiting for local OpenClaw";
|
|
}
|
|
|
|
async function refresh() {
|
|
const status = await chrome.runtime.sendMessage({ type: "getStatus" });
|
|
if (status?.ok === false) {
|
|
statusLine.textContent = status.error ?? "Could not read browser status.";
|
|
return;
|
|
}
|
|
pairedDetails.classList.toggle("hidden", !status.paired);
|
|
if (status.retiredCopilotCustodyBlocked === true) {
|
|
statusLine.textContent = "Automation paused; open Settings";
|
|
tabAction.classList.add("hidden");
|
|
return;
|
|
}
|
|
if (!status.paired) {
|
|
statusLine.textContent = unpairedLabel(status.nativeBootstrap);
|
|
tabAction.classList.add("hidden");
|
|
return;
|
|
}
|
|
statusLine.textContent =
|
|
status.state === "on"
|
|
? "Connected"
|
|
: status.state === "connecting"
|
|
? "Connecting…"
|
|
: "OpenClaw relay unavailable";
|
|
accessMode.textContent = status.accessMode === "selected" ? "Selected tabs" : "All tabs";
|
|
const tab = await activeTab();
|
|
if (tab?.id === undefined) {
|
|
tabAction.classList.add("hidden");
|
|
return;
|
|
}
|
|
const access = await chrome.runtime.sendMessage({ type: "getTabAccess", tabId: tab.id });
|
|
tabAction.classList.toggle("hidden", !access.eligible);
|
|
tabAction.textContent = access.accessible ? "Pause on this tab" : "Allow on this tab";
|
|
tabAction.dataset.tabId = String(tab.id);
|
|
tabAction.dataset.mode = status.accessMode;
|
|
tabAction.dataset.grant = String(!access.accessible);
|
|
}
|
|
|
|
async function toggleActiveTabAccess() {
|
|
errorLine.classList.add("hidden");
|
|
const result = await chrome.runtime.sendMessage({
|
|
type: "toggleTabAccess",
|
|
tabId: Number(tabAction.dataset.tabId),
|
|
accessMode: tabAction.dataset.mode,
|
|
grant: tabAction.dataset.grant === "true",
|
|
});
|
|
if (!result?.ok) {
|
|
errorLine.textContent = result?.error ?? "Could not update tab access.";
|
|
errorLine.classList.remove("hidden");
|
|
}
|
|
await refresh();
|
|
}
|
|
|
|
tabAction.addEventListener("click", () => {
|
|
void toggleActiveTabAccess();
|
|
});
|
|
|
|
settings.addEventListener("click", () => chrome.runtime.openOptionsPage());
|
|
void refresh();
|