webhelm 1.0.35 → 1.0.37

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webhelm",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "description": "Agent browser automation in a visible managed Chrome with persistent JavaScript sessions",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "WebHelm",
4
- "version": "1.0.35",
4
+ "version": "1.0.37",
5
5
  "description": "Own named Chrome tab-group workspaces and lazy reusable tab pools for browser agents.",
6
6
  "permissions": [
7
7
  "storage",
@@ -59,19 +59,43 @@ export function compactQueue(items, {expanded=false,maxHeads=8}={}) {
59
59
  const threads=new Map();
60
60
  for (const [index,item] of all.entries()) {
61
61
  const key=threadKey(item);
62
- if (!threads.has(key)) threads.set(key,{head:item,index,count:0});
62
+ if (!threads.has(key)) threads.set(key,{head:item,index,count:0,items:[]});
63
63
  threads.get(key).count++;
64
+ threads.get(key).items.push(item);
64
65
  }
65
66
  const heads=[...threads.values()].sort((a,b)=>
66
67
  (priority[a.head.state]??5)-(priority[b.head.state]??5)||a.index-b.index);
67
- const visible=expanded ? all : heads.slice(0,Math.max(1,maxHeads)).map(x=>x.head);
68
+ const visible=expanded ? heads.flatMap(x=>x.items) : heads.slice(0,Math.max(1,maxHeads)).map(x=>x.head);
69
+ const headFor=new Map(heads.flatMap(x=>x.items.map(item=>[item.id,x.head])));
68
70
  const behind=new Map(heads.map(x=>[x.head.id,x.count-1]));
69
71
  const uncertain=all.filter(x=>x.state==='UNCERTAIN').length;
70
72
  const blocked=all.filter(x=>x.state==='BLOCKED').length;
71
- return {visible,total:all.length,threads:threads.size,behind,
73
+ return {visible,total:all.length,threads:threads.size,behind,headFor,
72
74
  hidden:all.length-visible.length,uncertain,blocked};
73
75
  }
74
76
 
77
+ // Statuses describe what the user can do, not internal retry counters.
78
+ // A later QUEUED item cannot be sent until earlier items in the same thread resolve.
79
+ export function queueStatusText(item,{head=item,remaining=0}={}) {
80
+ const state=String(item.state||'QUEUED').toUpperCase();
81
+ const following=head.id!==item.id;
82
+ let message;
83
+ if(following && ['UNCERTAIN','BLOCKED'].includes(head.state))
84
+ message=head.state==='UNCERTAIN' ? 'Waiting — previous send unconfirmed' : 'Waiting — previous message blocked';
85
+ else if(following) message='Waiting behind earlier message';
86
+ else message=({
87
+ UNCERTAIN:'Send unconfirmed — open thread to check',
88
+ BLOCKED:'Blocked — needs attention',
89
+ SENDING:'Sending',
90
+ CHECKING:'Checking delivery',
91
+ WAITING:'Waiting to send',
92
+ QUEUED:'Queued to send',
93
+ })[state]||state.toLowerCase();
94
+ if(!following && remaining>0)
95
+ message+=' · '+remaining+' later message'+(remaining===1?'':'s')+' waiting';
96
+ return message;
97
+ }
98
+
75
99
  // Keep hidden groups out of the toolbar even if a running older worker has
76
100
  // not yet reloaded its control RPC. Do not mutate the persisted configuration.
77
101
  export const WORKSPACE_STORAGE_KEY='browserWorkspaceManager.v1';
@@ -42,20 +42,21 @@
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; }
45
- #queue-list { border-top:1px solid light-dark(var(--border),#334155); padding-top:6px; margin-top:2px; max-height:240px; }
46
- #queue-heading { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-top:8px; }
47
- #queue-heading strong { font-size:12px; }
48
- #queue-count { color:light-dark(var(--muted),#acb8c9); font-size:11px; font-weight:400; }
49
- #queue-toggle { width:auto; flex-shrink:0; padding:3px 6px; font-size:11px; }
50
- #queue-note { color:light-dark(var(--muted),#acb8c9); font-size:11px; padding:5px 0; }
51
- .queue-platform { padding:5px 0; }
45
+ #queue-list { border-top:1px solid light-dark(var(--border),#334155); margin-top:6px; padding-top:4px; max-height:240px; }
46
+ .queue-platform { padding:3px 0; }
52
47
  .queue-platform + .queue-platform { border-top:1px solid light-dark(var(--border),#334155); }
53
- .queue-platform-title { font-size:12px; }
54
- .queue-row { display:flex; align-items:center; gap:8px; padding:5px 0; }
48
+ .queue-platform-header { display:flex; align-items:center; justify-content:space-between; gap:6px; }
49
+ .queue-platform-title { font-size:11px; }
50
+ .queue-platform-count { font-size:9px; flex:1; text-align:right; color:light-dark(var(--muted),#acb8c9); white-space:nowrap; }
51
+ #queue-toggle { width:auto; padding:2px 5px; font-size:9px; }
52
+ .queue-row { display:flex; align-items:center; gap:6px; padding:3px 0; }
53
+ .queue-row.queue-followup { margin-left:9px; padding-left:7px; border-left:2px solid light-dark(var(--border),#40516a); }
55
54
  .queue-info { min-width:0; flex:1; overflow-wrap:anywhere; }
56
- .queue-info span { display:block; color:light-dark(var(--muted),#acb8c9); font-size:11px; }
57
- .queue-row button { width:auto; padding:5px 9px; font-size:11px; }
55
+ .queue-info span { display:block; color:light-dark(var(--muted),#acb8c9); font-size:9px; line-height:1.3; }
56
+ .queue-info span.queue-warning { color:light-dark(var(--warning),#f7a4ad); font-weight:500; }
57
+ .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; }
58
58
  button.tab-title, button.queue-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; }
59
+ button.queue-title { font-size:10px; }
59
60
  button.tab-title:hover, button.queue-title:hover { text-decoration:underline; }
60
61
  button.tab-title:disabled, button.queue-title:disabled { cursor:default; text-decoration:none; }
61
62
  .session-info, .queue-info { overflow:hidden; }
@@ -75,9 +76,7 @@
75
76
  <strong>Keep Alive Sites</strong>
76
77
  <div id="keepalive-list" aria-label="Keep Alive Sites">Loading…</div>
77
78
  <div id="workspace-list" class="session-list" aria-label="Workspaces" aria-live="polite">Connecting…</div>
78
- <div id="queue-heading"><strong>Queue <span id="queue-count"></span></strong><button id="queue-toggle" type="button" aria-controls="queue-list" aria-expanded="false" hidden>Show all</button></div>
79
- <div id="queue-note" role="status" hidden></div>
80
- <div id="queue-list" class="session-list" aria-label="Queue" aria-live="polite">No queue entries</div>
79
+ <div id="queue-list" class="session-list" aria-label="Queued submissions" aria-live="polite" hidden></div>
81
80
  <section id="confirmation" hidden aria-label="Confirm clear sessions">
82
81
  <p id="confirm-text">Stop the selected WebHelm session(s)? Tasks in progress may be interrupted. Queued jobs remain and may create new sessions.</p>
83
82
  <div class="buttons">
@@ -1,4 +1,4 @@
1
- import {readKeptSites, setStoredSite, compactQueue, readMenuWorkspaces} from './popup-data.mjs';
1
+ import {readKeptSites, setStoredSite, compactQueue, queueStatusText, readMenuWorkspaces} 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;
@@ -150,29 +150,36 @@ function renderWorkspaces(workspaces, busy, connected) {
150
150
  }
151
151
  }
152
152
 
153
+ const queueToggle=actionButton('Show all',false,()=>{
154
+ queueExpanded=!queueExpanded;
155
+ lastQueueSignature='';
156
+ renderQueue(currentQueue,queueBusy,queueConnected);
157
+ });
158
+ queueToggle.id='queue-toggle';
159
+ queueToggle.setAttribute('aria-controls','queue-list');
160
+
153
161
  function renderQueue(items, busy, connected) {
154
162
  if(!items.length)queueExpanded=false;
155
163
  const view=compactQueue(items,{expanded:queueExpanded,maxHeads:8});
156
164
  const shown=view.visible;
157
165
  const signature=JSON.stringify({shown:shown.map(item=>[item.id,item.platform,item.thread_id,item.title,item.url,item.state,item.attempts]),
158
166
  total:view.total,threads:view.threads,hidden:view.hidden,uncertain:view.uncertain,blocked:view.blocked,
159
- behind:[...view.behind],busy,connected,queueExpanded});
167
+ behind:[...view.behind],relations:shown.map(item=>[item.id,view.headFor.get(item.id)?.id,view.headFor.get(item.id)?.state]),busy,connected,queueExpanded});
160
168
  if (signature===lastQueueSignature) return;
161
169
  lastQueueSignature=signature;
162
- const count=el('queue-count');
163
- count.textContent=view.total ? `${view.total} pending · ${view.threads} thread${view.threads===1?'':'s'}` : 'Empty';
164
- const toggle=el('queue-toggle');
165
- toggle.hidden=!(queueExpanded || view.hidden>0);
166
- toggle.textContent=queueExpanded?'Show less':`Show all ${view.total}`;
167
- toggle.setAttribute('aria-expanded',String(queueExpanded));
168
- const note=el('queue-note');
169
- note.hidden=!view.uncertain && !view.blocked;
170
- if(!note.hidden) note.textContent=[
171
- view.uncertain ? `${view.uncertain} uncertain` : '',
172
- view.blocked ? `${view.blocked} blocked` : '',
173
- ].filter(Boolean).join(' · ') + ' — verify before retrying; later turns in the same thread may be waiting.';
174
-
175
170
  const target=el('queue-list');
171
+ const platformCounts=new Map();
172
+ for (const item of items) {
173
+ const platform=String(item.platform||'Queue');
174
+ if(!platformCounts.has(platform))platformCounts.set(platform,{total:0,threads:new Set()});
175
+ const stat=platformCounts.get(platform);
176
+ stat.total++;
177
+ stat.threads.add(item.thread_id||item.id);
178
+ }
179
+ target.hidden=!items.length;
180
+ queueToggle.hidden=!(queueExpanded || view.hidden>0);
181
+ queueToggle.textContent=queueExpanded?'Show less':'Show all '+view.total;
182
+ queueToggle.setAttribute('aria-expanded',String(queueExpanded));
176
183
  const grouped=new Map();
177
184
  for (const item of shown) {
178
185
  const platform=String(item.platform||'Queue');
@@ -189,20 +196,25 @@ function renderQueue(items, busy, connected) {
189
196
  }
190
197
  if(!items.length) {
191
198
  target.replaceChildren();queueGroups.clear();queueRows.clear();
192
- const empty=document.createElement('div');empty.className='empty-queue';empty.textContent='No queue entries';
193
- target.append(empty);
194
199
  return;
195
200
  }
196
- target.querySelector('.empty-queue')?.remove();
197
201
  for (const [platform,entries] of grouped) {
198
202
  let group=queueGroups.get(platform);
199
203
  if(!group) {
200
204
  group=document.createElement('section');group.className='queue-platform';
205
+ const header=document.createElement('div');header.className='queue-platform-header';
201
206
  const heading=document.createElement('strong');heading.className='queue-platform-title';
202
207
  heading.textContent=platform==='Queue'?'Queue':`${platform} Queue`;
203
208
  const rows=document.createElement('div');rows.className='queue-platform-rows';
204
- group.append(heading,rows);queueGroups.set(platform,group);target.append(group);
209
+ const count=document.createElement('span');count.className='queue-platform-count';
210
+ header.append(heading,count);
211
+ group.append(header,rows);queueGroups.set(platform,group);target.append(group);
205
212
  }
213
+ const stats=platformCounts.get(platform);
214
+ group.querySelector('.queue-platform-count').textContent=stats.threads.size+
215
+ (stats.threads.size===1?' thread':' threads')+' · '+stats.total+
216
+ (stats.total===1?' message':' messages');
217
+ if(platform===grouped.keys().next().value)group.querySelector('.queue-platform-header').append(queueToggle);
206
218
  for (const item of entries) {
207
219
  const key=`${platform}:${item.id}`;
208
220
  let row=queueRows.get(key);
@@ -214,25 +226,39 @@ function renderQueue(items, busy, connected) {
214
226
  catch(error){el('message').textContent=error.message;}
215
227
  },'queue-title');
216
228
  const detail=document.createElement('span');detail.className='queue-detail';
217
- const remove=actionButton('Remove',false,async()=>{
218
- try {const result=await rpc('workspace.control.queueCancel',{queueId:item.id});if(!result.id)throw Error('Missing queue request ID');el('message').textContent='Waiting for WebHelm daemon…';}
229
+ const remove=actionButton('×',false,async()=>{
230
+ try {
231
+ if(row.dataset.state==='UNCERTAIN' && !confirm('Delivery is unconfirmed. This message may already be in ChatGPT. Removing it cannot unsend it and will unblock later messages in this thread. Remove it?'))return;
232
+ const result=await rpc('workspace.control.queueCancel',{queueId:item.id});
233
+ if(!result.id)throw Error('Missing queue request ID');
234
+ el('message').textContent='Waiting for WebHelm daemon…';
235
+ }
219
236
  catch(error){el('message').textContent=error.message;}
220
237
  refresh();
221
- });
238
+ },'queue-remove');
222
239
  row.append(info,remove);info.append(title,detail);queueRows.set(key,row);
223
240
  }
224
241
  const title=row.querySelector('.queue-title');
225
242
  title.textContent=item.title||`${platform} message`;
226
243
  title.title=item.title||`${platform} message`;
227
244
  title.disabled=!connected||!item.url;
228
- const attempts=Number(item.attempts)||0;
229
- const more=!queueExpanded ? (view.behind.get(item.id)||0) : 0;
230
- row.querySelector('.queue-detail').textContent=`${String(item.state||'queued').toLowerCase()} · ${attempts} attempt${attempts===1?'':'s'}`+
231
- (more ? ` · ${more} more in this thread` : '');
245
+ row.dataset.state=item.state;
246
+ const head=view.headFor.get(item.id)||item;
247
+ const following=head.id!==item.id;
248
+ row.classList.toggle('queue-followup',following);
249
+ const detail=row.querySelector('.queue-detail');
250
+ detail.textContent=queueStatusText(item,{head,remaining:!queueExpanded?(view.behind.get(item.id)||0):0});
251
+ detail.classList.toggle('queue-warning',item.state==='UNCERTAIN' || (following && head.state==='UNCERTAIN'));
232
252
  const remove=row.querySelector('button:last-child');
233
253
  const safe=['QUEUED','WAITING','BLOCKED','UNCERTAIN'].includes(item.state);
234
254
  remove.disabled=!safe||busy||!connected;
235
- remove.title=safe?'':'Cannot remove a running or completed submission';
255
+ remove.title=safe?'Remove '+title.textContent+' from queue':'Cannot remove a running or completed submission';
256
+ remove.setAttribute('aria-label',remove.title);
257
+ detail.title=item.state==='UNCERTAIN'
258
+ ? 'A send was attempted but no delivery receipt was confirmed. The message may already be in ChatGPT; it will not be retried automatically.'
259
+ : following && head.state==='UNCERTAIN'
260
+ ? 'This message has not been sent. It waits until the earlier unconfirmed send is resolved.'
261
+ : '';
236
262
  const rows=group.querySelector('.queue-platform-rows');
237
263
  if(row.parentElement!==rows)rows.append(row);
238
264
  }
@@ -273,12 +299,6 @@ async function refresh() {
273
299
  }
274
300
  }
275
301
 
276
- el('queue-toggle').addEventListener('click',()=>{
277
- queueExpanded=!queueExpanded;
278
- lastQueueSignature='';
279
- renderQueue(currentQueue,queueBusy,queueConnected);
280
- });
281
-
282
302
  el('cancel').addEventListener('click', () => {
283
303
  confirming = false;
284
304
  el('confirmation').hidden = true;