webhelm 1.0.40 → 1.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/package.json +1 -1
- package/runtime/extension/control-rpc.mjs +4 -5
- package/runtime/extension/manifest.json +1 -1
- package/runtime/extension/popup-data.mjs +12 -5
- package/runtime/extension/popup.html +1 -1
- package/runtime/extension/popup.mjs +9 -4
- package/runtime/extension/site-registry.mjs +14 -3
- package/runtime/site-keepalive.mjs +2 -1
package/README.md
CHANGED
|
@@ -50,7 +50,9 @@ The Actions checkout is `~/.local/webhelm`, with site modules at `~/.local/webhe
|
|
|
50
50
|
## Optional site Keep Alive (Extension)
|
|
51
51
|
|
|
52
52
|
Only a Session in the **WebHelm** Workspace can use the Extension's **Keep Alive** toggle on an HTTPS page to
|
|
53
|
-
register that website's **origin
|
|
53
|
+
register that website's **origin and current path** (without query or fragment).
|
|
54
|
+
There is one site entry per origin, so enabling Keep Alive on another path
|
|
55
|
+
updates its saved destination. The website stays in the popup's Keep Alive
|
|
54
56
|
Sites list even after the original Session ends. Custom/other Workspace
|
|
55
57
|
Sessions have no Keep Alive toggle. A green dot and website name mean that
|
|
56
58
|
the Platform last confirmed login; gray means not confirmed or not logged in
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {siteOrigin, setKeptSite, listKeptSites, sitesWithStatus, reportKeptSite} from "./site-registry.mjs";
|
|
1
|
+
import {siteOrigin, sitePage, setKeptSite, listKeptSites, sitesWithStatus, reportKeptSite} from "./site-registry.mjs";
|
|
2
2
|
function validTabId(tabId) { return Number.isSafeInteger(tabId) && tabId > 0; }
|
|
3
3
|
function validateQueueUrl(url) {
|
|
4
4
|
const parsed = new URL(url);
|
|
@@ -61,8 +61,7 @@ export function createControlRpc({control, manager, summarizeWorkspaces, schedul
|
|
|
61
61
|
if (session.workspace !== 'WebHelm')
|
|
62
62
|
throw Error('Keep Alive can be enabled only from a WebHelm Session');
|
|
63
63
|
const tab = await chromeApi.tabs.get(session.tabId);
|
|
64
|
-
|
|
65
|
-
return setKeptSite(chromeApi,id,Boolean(args.enabled));
|
|
64
|
+
return setKeptSite(chromeApi,tab.url || '',Boolean(args.enabled));
|
|
66
65
|
}
|
|
67
66
|
case "workspace.control.site.remove": {
|
|
68
67
|
const site = (await listKeptSites(chromeApi)).find(s => s.id === args.siteId);
|
|
@@ -72,14 +71,14 @@ export function createControlRpc({control, manager, summarizeWorkspaces, schedul
|
|
|
72
71
|
case "workspace.control.site.open": {
|
|
73
72
|
const site = (await listKeptSites(chromeApi)).find(s => s.id === args.siteId);
|
|
74
73
|
if (!site) throw Error('Keep Alive site is no longer registered');
|
|
75
|
-
const url =
|
|
74
|
+
const url = sitePage(site.url);
|
|
76
75
|
const daemon = await control.status();
|
|
77
76
|
const leasedIds = new Set(daemon.connected ? daemon.sessions.flatMap(session =>
|
|
78
77
|
Array.isArray(session.tabIds) ? session.tabIds : [session.tabId]) : []);
|
|
79
78
|
// Never hand a human-login operation an active agent-owned leased Tab.
|
|
80
79
|
const existing = daemon.connected && (await chromeApi.tabs.query({})).find(tab => {
|
|
81
80
|
if (leasedIds.has(tab.id)) return false;
|
|
82
|
-
try { return
|
|
81
|
+
try { return sitePage(tab.url) === url; } catch { return false; }
|
|
83
82
|
});
|
|
84
83
|
if (existing) {
|
|
85
84
|
await chromeApi.tabs.update(existing.id,{active:true});
|
|
@@ -4,8 +4,13 @@ export const SITE_STORAGE_KEY = 'webhelm.keepalive.sites.v1';
|
|
|
4
4
|
export const SITE_STATUS_KEY = 'webhelm.keepalive.status.v1';
|
|
5
5
|
|
|
6
6
|
function validSite(site) {
|
|
7
|
-
if (!site || typeof site.id !== 'string' || site.
|
|
8
|
-
try {
|
|
7
|
+
if (!site || typeof site.id !== 'string' || typeof site.url !== 'string' || site.enabled !== true) return false;
|
|
8
|
+
try {
|
|
9
|
+
const url = new URL(site.url);
|
|
10
|
+
return url.protocol === 'https:' && !url.username && !url.password &&
|
|
11
|
+
!url.search && !url.hash && url.origin === site.id &&
|
|
12
|
+
site.url === (url.pathname === '/' ? url.origin : url.origin + url.pathname);
|
|
13
|
+
}
|
|
9
14
|
catch { return false; }
|
|
10
15
|
}
|
|
11
16
|
|
|
@@ -32,12 +37,14 @@ export async function readKeptSites(chromeApi, reported) {
|
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
export async function setStoredSite(chromeApi, url, enabled) {
|
|
35
|
-
const
|
|
36
|
-
|
|
40
|
+
const parsed = new URL(url);
|
|
41
|
+
const origin = parsed.origin;
|
|
42
|
+
if (parsed.protocol !== 'https:' || parsed.username || parsed.password) throw Error('Keep Alive requires HTTPS');
|
|
37
43
|
const stored=await chromeApi.storage.local.get(SITE_STORAGE_KEY);
|
|
38
44
|
const current=Array.isArray(stored[SITE_STORAGE_KEY]) ? stored[SITE_STORAGE_KEY] : [];
|
|
39
45
|
const next=current.filter(site=>site?.id!==origin);
|
|
40
|
-
if (enabled) next.push({id:origin,url:origin
|
|
46
|
+
if (enabled) next.push({id:origin,url:parsed.pathname === '/' ? origin : origin + parsed.pathname,
|
|
47
|
+
enabled:true,addedAt:Date.now(),revision:crypto.randomUUID()});
|
|
41
48
|
await chromeApi.storage.local.set({[SITE_STORAGE_KEY]: next.sort((a,b)=>a.id.localeCompare(b.id))});
|
|
42
49
|
if (!enabled) {
|
|
43
50
|
const storedStates=await chromeApi.storage.session.get(SITE_STATUS_KEY);
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
.keepalive-row { display:flex; align-items:center; gap:7px; min-height:25px; padding:2px 0; }
|
|
39
39
|
.keepalive-status { flex:0 0 7px; width:7px; height:7px; border-radius:50%; background:light-dark(#8893a1,#8995a5); }
|
|
40
40
|
.keepalive-status[data-status="alive"] { background:#23915c; }
|
|
41
|
-
.keepalive-row .keepalive-name { flex:1; min-width:0; color:light-dark(var(--muted),#acb8c9); font-size:11px; font-weight:500; }
|
|
41
|
+
.keepalive-row .keepalive-name { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:light-dark(var(--muted),#acb8c9); font-size:11px; font-weight:500; }
|
|
42
42
|
.keepalive-row .keepalive-name.is-logged-in { color:#23915c; }
|
|
43
43
|
.keepalive-row .keepalive-remove { flex:0 0 19px; width:19px; padding:1px; border:0; background:transparent; color:light-dark(var(--muted),#acb8c9); font-size:16px; font-weight:400; line-height:18px; }
|
|
44
44
|
.session-row button.site-enabled { color:#23915c; }
|
|
@@ -50,6 +50,11 @@ function originForTab(url) {
|
|
|
50
50
|
catch { return null; }
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
function siteLabel(url) {
|
|
54
|
+
const page = new URL(url);
|
|
55
|
+
return page.hostname + (page.pathname === '/' ? '' : page.pathname);
|
|
56
|
+
}
|
|
57
|
+
|
|
53
58
|
function renderKeptSites(sites, busy, connected) {
|
|
54
59
|
const signature = JSON.stringify(sites) + `:${busy}:${connected}`;
|
|
55
60
|
if (signature === lastSiteSignature) return;
|
|
@@ -70,14 +75,14 @@ function renderKeptSites(sites, busy, connected) {
|
|
|
70
75
|
status.dataset.status=loggedIn?'alive':'inactive';
|
|
71
76
|
status.title=statusText;
|
|
72
77
|
status.setAttribute('aria-hidden','true');
|
|
73
|
-
const name=actionButton(
|
|
78
|
+
const name=actionButton(siteLabel(site.url),false,async()=>{
|
|
74
79
|
try {
|
|
75
80
|
if (canControlSites) await rpc('workspace.control.site.open',{siteId:site.id});
|
|
76
81
|
else await chrome.tabs.create({url:site.url,active:true});
|
|
77
82
|
} catch(error){el('message').textContent=error.message;}
|
|
78
83
|
},`tab-title keepalive-name ${loggedIn?'is-logged-in':''}`);
|
|
79
|
-
name.title=`${statusText} · Click to open site`;
|
|
80
|
-
name.setAttribute('aria-label',`${
|
|
84
|
+
name.title=`${siteLabel(site.url)} · ${statusText} · Click to open site`;
|
|
85
|
+
name.setAttribute('aria-label',`${siteLabel(site.url)}: ${statusText}. Open site`);
|
|
81
86
|
const remove=actionButton('×',false,async()=>{
|
|
82
87
|
try {
|
|
83
88
|
if (canControlSites) await rpc('workspace.control.site.remove',{siteId:site.id});
|
|
@@ -85,7 +90,7 @@ function renderKeptSites(sites, busy, connected) {
|
|
|
85
90
|
lastSiteSignature='';lastSignature='';refresh();
|
|
86
91
|
} catch(error){el('message').textContent=error.message;}
|
|
87
92
|
},'keepalive-remove');
|
|
88
|
-
remove.title=`Remove ${
|
|
93
|
+
remove.title=`Remove ${siteLabel(site.url)} from Keep Alive`;
|
|
89
94
|
remove.setAttribute('aria-label',remove.title);
|
|
90
95
|
row.append(status,name,remove);
|
|
91
96
|
target.append(row);
|
|
@@ -10,16 +10,27 @@ export function siteOrigin(rawUrl) {
|
|
|
10
10
|
return parsed.origin;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
// Keep one registration per origin, but retain the exact page path for opening
|
|
14
|
+
// and for display. Never persist query parameters or fragments.
|
|
15
|
+
export function sitePage(rawUrl) {
|
|
16
|
+
const parsed = new URL(rawUrl);
|
|
17
|
+
const origin = siteOrigin(rawUrl);
|
|
18
|
+
return parsed.pathname === '/' ? origin : origin + parsed.pathname;
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
export async function listKeptSites(chromeApi) {
|
|
14
22
|
const record = (await chromeApi.storage.local.get(SITE_STORAGE_KEY))[SITE_STORAGE_KEY];
|
|
15
|
-
return Array.isArray(record) ? record.filter(site =>
|
|
16
|
-
typeof site.
|
|
23
|
+
return Array.isArray(record) ? record.filter(site => {
|
|
24
|
+
if (!site || typeof site.id !== 'string' || typeof site.url !== 'string' || site.enabled !== true) return false;
|
|
25
|
+
try { return site.id === siteOrigin(site.url) && site.url === sitePage(site.url); }
|
|
26
|
+
catch { return false; }
|
|
27
|
+
}) : [];
|
|
17
28
|
}
|
|
18
29
|
|
|
19
30
|
export async function setKeptSite(chromeApi, url, enabled) {
|
|
20
31
|
const id = siteOrigin(url);
|
|
21
32
|
const sites = (await listKeptSites(chromeApi)).filter(site => site.id !== id);
|
|
22
|
-
if (enabled) sites.push({id, url:
|
|
33
|
+
if (enabled) sites.push({id, url:sitePage(url), enabled:true, addedAt:Date.now(), revision:crypto.randomUUID()});
|
|
23
34
|
sites.sort((a,b) => a.id.localeCompare(b.id));
|
|
24
35
|
await chromeApi.storage.local.set({[SITE_STORAGE_KEY]: sites});
|
|
25
36
|
if (!enabled) {
|
|
@@ -15,7 +15,8 @@ export function resolveSiteHeartbeat(site, names=listPlatforms, manifestFor=plat
|
|
|
15
15
|
let origin;
|
|
16
16
|
try {
|
|
17
17
|
const url = new URL(site?.url);
|
|
18
|
-
if (!site?.enabled || url.protocol !== 'https:' || url.origin !== site.id ||
|
|
18
|
+
if (!site?.enabled || url.protocol !== 'https:' || url.origin !== site.id ||
|
|
19
|
+
url.username || url.password || url.search || url.hash) return null;
|
|
19
20
|
origin = url.origin;
|
|
20
21
|
} catch { return null; }
|
|
21
22
|
for (const platform of names()) {
|