webhelm 1.0.38 → 1.0.39
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/package.json
CHANGED
|
@@ -96,6 +96,17 @@ export function queueStatusText(item,{head=item,remaining=0}={}) {
|
|
|
96
96
|
return message;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
// Snapshot elapsed time once when the extension menu opens.
|
|
100
|
+
export function formatQueueElapsed(createdAt, snapshotSeconds) {
|
|
101
|
+
const created=Number(createdAt);
|
|
102
|
+
if(!Number.isFinite(created)||created<=0)return null;
|
|
103
|
+
const elapsed=Math.max(0,Math.floor(snapshotSeconds-created));
|
|
104
|
+
if(elapsed<60)return elapsed+'s';
|
|
105
|
+
if(elapsed<3600)return Math.floor(elapsed/60)+'m';
|
|
106
|
+
if(elapsed<86400)return Math.floor(elapsed/3600)+'h';
|
|
107
|
+
return Math.floor(elapsed/86400)+'d';
|
|
108
|
+
}
|
|
109
|
+
|
|
99
110
|
// Keep hidden groups out of the toolbar even if a running older worker has
|
|
100
111
|
// not yet reloaded its control RPC. Do not mutate the persisted configuration.
|
|
101
112
|
export const WORKSPACE_STORAGE_KEY='browserWorkspaceManager.v1';
|
|
@@ -48,16 +48,16 @@
|
|
|
48
48
|
.queue-platform-title { display:block; font-size:11px; }
|
|
49
49
|
.queue-thread { padding:3px 0 3px 6px; }
|
|
50
50
|
.queue-thread + .queue-thread { border-top:1px solid light-dark(var(--border),#334155); }
|
|
51
|
-
.queue-thread-
|
|
51
|
+
.queue-thread-link { display:block; font-size:10px; font-family:ui-monospace,monospace; font-weight:500; color:light-dark(var(--accent),#8dbdff); overflow-wrap:anywhere; text-decoration:underline; cursor:pointer; }
|
|
52
52
|
.queue-row { display:flex; align-items:center; gap:5px; padding:2px 0 2px 9px; }
|
|
53
53
|
.queue-info { min-width:0; flex:1; display:flex; gap:4px; align-items:baseline; overflow:hidden; }
|
|
54
54
|
.queue-meta { flex-shrink:0; white-space:nowrap; color:light-dark(var(--muted),#acb8c9); font-size:9px; }
|
|
55
55
|
.queue-unconfirmed .queue-title { color:light-dark(var(--warning),#f7a4ad); }
|
|
56
56
|
.queue-row button.queue-remove { flex:0 0 20px; width:20px; height:20px; padding:0; border:0; background:transparent; color:light-dark(var(--muted),#acb8c9); font-size:16px; font-weight:400; line-height:18px; }
|
|
57
|
-
button.tab-title
|
|
58
|
-
|
|
59
|
-
button.tab-title:hover
|
|
60
|
-
button.tab-title:disabled
|
|
57
|
+
button.tab-title { flex:1; min-width:0; width:100%; padding:0; border:0; border-radius:2px; background:transparent; color:inherit; text-align:left; font-size:12px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; cursor:pointer; }
|
|
58
|
+
.queue-title { flex:1; min-width:0; font-size:10px; font-weight:400; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
|
59
|
+
button.tab-title:hover { text-decoration:underline; }
|
|
60
|
+
button.tab-title:disabled { cursor:default; text-decoration:none; }
|
|
61
61
|
.session-info, .queue-info { overflow:hidden; }
|
|
62
62
|
.queue-info .queue-title { margin:0; }
|
|
63
63
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {readKeptSites, setStoredSite, readMenuWorkspaces} from './popup-data.mjs';
|
|
1
|
+
import {readKeptSites, setStoredSite, readMenuWorkspaces, formatQueueElapsed} from './popup-data.mjs';
|
|
2
2
|
const el = id => document.getElementById(id);
|
|
3
3
|
el('extension-version').textContent = `v${chrome.runtime.getManifest().version}`;
|
|
4
4
|
let confirming = false;
|
|
@@ -15,6 +15,7 @@ let queueConnected = false;
|
|
|
15
15
|
const queueRows = new Map();
|
|
16
16
|
const queueGroups = new Map();
|
|
17
17
|
const queueThreadGroups = new Map();
|
|
18
|
+
const queueOpenedAtSeconds=Math.floor(Date.now()/1000);
|
|
18
19
|
|
|
19
20
|
async function rpc(method, args = {}) {
|
|
20
21
|
const response = await chrome.runtime.sendMessage({method, args});
|
|
@@ -151,10 +152,9 @@ function renderWorkspaces(workspaces, busy, connected) {
|
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
function renderQueue(items, busy, connected) {
|
|
154
|
-
const nowSeconds=Math.floor(Date.now()/1000);
|
|
155
155
|
const signature=JSON.stringify({
|
|
156
156
|
items:items.map(item=>[item.id,item.platform,item.thread_id,item.title,item.url,item.state,item.attempts,item.created_at]),
|
|
157
|
-
|
|
157
|
+
busy,connected,
|
|
158
158
|
});
|
|
159
159
|
if(signature===lastQueueSignature)return;
|
|
160
160
|
lastQueueSignature=signature;
|
|
@@ -195,11 +195,23 @@ function renderQueue(items, busy, connected) {
|
|
|
195
195
|
let thread=queueThreadGroups.get(threadKey);
|
|
196
196
|
if(!thread){
|
|
197
197
|
thread=document.createElement('section');thread.className='queue-thread';
|
|
198
|
-
const
|
|
199
|
-
|
|
198
|
+
const link=document.createElement('a');link.className='queue-thread-link';
|
|
199
|
+
link.textContent=threadId;
|
|
200
|
+
link.addEventListener('click',async event=>{
|
|
201
|
+
event.preventDefault();
|
|
202
|
+
const queueId=thread.querySelector('.queue-row')?.dataset.queueId;
|
|
203
|
+
if(!queueId)return;
|
|
204
|
+
try{await rpc('workspace.control.openQueue',{queueId});}
|
|
205
|
+
catch(error){el('message').textContent=error.message;}
|
|
206
|
+
});
|
|
200
207
|
const rows=document.createElement('div');rows.className='queue-thread-rows';
|
|
201
|
-
thread.append(
|
|
208
|
+
thread.append(link,rows);queueThreadGroups.set(threadKey,thread);
|
|
202
209
|
}
|
|
210
|
+
const link=thread.querySelector('.queue-thread-link');
|
|
211
|
+
const url=entries.find(item=>item.url)?.url;
|
|
212
|
+
if(connected&&url)link.href=url;
|
|
213
|
+
else link.removeAttribute('href');
|
|
214
|
+
link.title=threadId;
|
|
203
215
|
const rows=thread.querySelector('.queue-thread-rows');
|
|
204
216
|
for(const item of entries){
|
|
205
217
|
const key=platform+':'+item.id;
|
|
@@ -207,10 +219,7 @@ function renderQueue(items, busy, connected) {
|
|
|
207
219
|
if(!row){
|
|
208
220
|
row=document.createElement('div');row.className='queue-row';
|
|
209
221
|
const info=document.createElement('div');info.className='queue-info';
|
|
210
|
-
const title=
|
|
211
|
-
try{await rpc('workspace.control.openQueue',{queueId:item.id});el('message').textContent='Queue destination opened.';}
|
|
212
|
-
catch(error){el('message').textContent=error.message;}
|
|
213
|
-
},'queue-title');
|
|
222
|
+
const title=document.createElement('span');title.className='queue-title';
|
|
214
223
|
const meta=document.createElement('span');meta.className='queue-meta';
|
|
215
224
|
const remove=actionButton('×',false,async()=>{
|
|
216
225
|
try{
|
|
@@ -226,15 +235,12 @@ function renderQueue(items, busy, connected) {
|
|
|
226
235
|
const title=row.querySelector('.queue-title');
|
|
227
236
|
title.textContent=item.title||platform+' message';
|
|
228
237
|
title.title=(item.title||platform+' message')+(item.state==='UNCERTAIN'?' — Send not confirmed; check thread before removing.':'');
|
|
229
|
-
|
|
238
|
+
row.dataset.queueId=item.id;
|
|
230
239
|
row.dataset.state=item.state;
|
|
231
240
|
row.classList.toggle('queue-unconfirmed',item.state==='UNCERTAIN');
|
|
232
|
-
const
|
|
233
|
-
const seconds=Number.isFinite(age)&&age>0 ? Math.max(0,nowSeconds-Math.floor(age)) : null;
|
|
241
|
+
const elapsed=formatQueueElapsed(item.created_at,queueOpenedAtSeconds);
|
|
234
242
|
const attempts=Math.max(0,Number(item.attempts)||0);
|
|
235
|
-
row.querySelector('.queue-meta').textContent='('+
|
|
236
|
-
(seconds===null?'':seconds+' second'+(seconds===1?'':'s')+', ')+
|
|
237
|
-
attempts+' attempt'+(attempts===1?'':'s')+')';
|
|
243
|
+
row.querySelector('.queue-meta').textContent='('+(elapsed??'–')+'/'+attempts+')';
|
|
238
244
|
const remove=row.querySelector('.queue-remove');
|
|
239
245
|
const cancellable=['QUEUED','WAITING','BLOCKED','UNCERTAIN'].includes(item.state);
|
|
240
246
|
remove.disabled=!cancellable||busy||!connected;
|
|
@@ -268,7 +274,7 @@ async function refresh() {
|
|
|
268
274
|
el('message').textContent = 'Applying WebHelm action…';
|
|
269
275
|
} else if (state.lastResult) {
|
|
270
276
|
el('message').textContent = state.lastResult.ok
|
|
271
|
-
? (state.lastResult.queue_id ? '
|
|
277
|
+
? (state.lastResult.queue_id ? '' : `Last action: stopped ${state.lastResult.stoppedCount} session(s).`)
|
|
272
278
|
: `Last action failed: ${state.lastResult.error}`;
|
|
273
279
|
}
|
|
274
280
|
} catch (error) {
|